Georg Brandl avatar Georg Brandl committed 6d6b51e Merge

Merged in zzamboni/pygments-main (pull request #13)

Comments (0)

Files changed (2)

pygments/lexers/_mapping.py

     'CObjdumpLexer': ('pygments.lexers.asm', 'c-objdump', ('c-objdump',), ('*.c-objdump',), ('text/x-c-objdump',)),
     'CSharpAspxLexer': ('pygments.lexers.dotnet', 'aspx-cs', ('aspx-cs',), ('*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd'), ()),
     'CSharpLexer': ('pygments.lexers.dotnet', 'C#', ('csharp', 'c#'), ('*.cs',), ('text/x-csharp',)),
+    'Cfengine3Lexer': ('pygments.lexers.other', 'CFEngine3', ('cfengine3', 'cf3'), ('*.cf',), ()),
     'CheetahHtmlLexer': ('pygments.lexers.templates', 'HTML+Cheetah', ('html+cheetah', 'html+spitfire'), (), ('text/html+cheetah', 'text/html+spitfire')),
     'CheetahJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Cheetah', ('js+cheetah', 'javascript+cheetah', 'js+spitfire', 'javascript+spitfire'), (), ('application/x-javascript+cheetah', 'text/x-javascript+cheetah', 'text/javascript+cheetah', 'application/x-javascript+spitfire', 'text/x-javascript+spitfire', 'text/javascript+spitfire')),
     'CheetahLexer': ('pygments.lexers.templates', 'Cheetah', ('cheetah', 'spitfire'), ('*.tmpl', '*.spt'), ('application/x-cheetah', 'application/x-spitfire')),

pygments/lexers/other.py

            'BashSessionLexer', 'ModelicaLexer', 'RebolLexer', 'ABAPLexer',
            'NewspeakLexer', 'GherkinLexer', 'AsymptoteLexer',
            'PostScriptLexer', 'AutohotkeyLexer', 'GoodDataCLLexer',
-           'MaqlLexer', 'ProtoBufLexer', 'HybrisLexer', 'AwkLexer']
+           'MaqlLexer', 'ProtoBufLexer', 'HybrisLexer', 'AwkLexer',
+           'Cfengine3Lexer']
 
 line_re  = re.compile('.*?\n')
 
             (r"'(\\\\|\\'|[^'])*'", String.Single),
         ]
     }
+
+class Cfengine3Lexer(RegexLexer):
+    """
+    Lexer for `CFEngine3 <http://cfengine.org>`_ policy files.
+
+    """
+
+    name = 'CFEngine3'
+    aliases = ['cfengine3', 'cf3']
+    filenames = [ '*.cf' ]
+    mimetypes = []
+
+    tokens = {
+        'root': [
+            (r'#.*?\n', Comment),
+            (r'(body)(\s+)(\S+)(\s+)(control)',
+             bygroups(Keyword, Text, Keyword, Text, Keyword)),
+            (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()',
+             bygroups(Keyword, Text, Keyword, Text, Name.Function, Punctuation), 'arglist'),
+            (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)',
+             bygroups(Keyword, Text, Keyword, Text, Name.Function)),
+            (r'(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)',
+             bygroups(Punctuation,Name.Variable,Punctuation,
+                      Text,Keyword.Type,Text,Operator,Text)),
+            (r'(\S+)(\s*)(=>)(\s*)',
+             bygroups(Keyword.Reserved,Text,Operator,Text)),
+            (r'"', String, 'string'),
+            (r'(\w+)(\()', bygroups(Name.Function, Punctuation)),
+            (r'([\w.!&|]+)(::)', bygroups(Name.Class, Punctuation)),
+            (r'(\w+)(:)', bygroups(Keyword.Declaration,Punctuation)),
+            (r'@[\{\(][^\)\}]+[\}\)]', Name.Variable),
+            (r'[(){},;]', Punctuation),
+            (r'=>', Operator),
+            (r'\d+\.\d+', Number.Float),
+            (r'\d+', Number.Integer),
+            (r'\w+', Name.Function),
+            (r'\s+', Text),
+        ],
+        'string': [
+            (r'\$[\{\(]', String.Interpol, 'interpol'),
+            (r'\\.', String.Escape),
+            (r'"', String, '#pop'),
+            (r'\n', String),
+            (r'.', String),
+        ],
+        'interpol': [
+            (r'\$[\{\(]', String.Interpol, '#push'),
+            (r'[\}\)]', String.Interpol, '#pop'),
+            (r'[^\$\{\(\)\}]+', String.Interpol),
+        ],
+        'arglist': [
+            (r'\)', Punctuation, '#pop'),
+            (r',', Punctuation),
+            (r'\w+', Name.Variable),
+            (r'\s+', Text),
+        ],
+    }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.