Commits

Norbert Melzer committed fc07ee0

Added a lexer for hxml, the haXe-Makefile-Language

Simply a hxml file is a list of compilerswitches, that you would give to the
haxe compiler normaly. But with the "--next" line you can set up multiple files
that will be compiled in this single hxml file.

The actual tokens are only stubs.

I added comments for what the single expressions math, so one could figure out
some tokens that fits better semantically.

Also I have to excuse the bad indendation style, I am not from python, and do
not really understand the "semantically whitespace" stuff in the context of
python. Also I did not find a guide about codestyle for the project. All I did
was hitting enter at about 80 chars and to hope it will work.

  • Participants
  • Parent commits 1b3c03b
  • Branches hxml

Comments (0)

Files changed (2)

pygments/lexers/_mapping.py

     'HamlLexer': ('pygments.lexers.web', 'Haml', ('haml', 'HAML'), ('*.haml',), ('text/x-haml',)),
     'HaskellLexer': ('pygments.lexers.functional', 'Haskell', ('haskell', 'hs'), ('*.hs',), ('text/x-haskell',)),
     'HaxeLexer': ('pygments.lexers.web', 'haXe', ('hx', 'haXe'), ('*.hx',), ('text/haxe',)),
+    'HaxeMLLexer': ('pygments.lexers.text', 'haxeML', ('haxeml', 'hxml'), ('*.hxml',), ()),
     'HtmlDjangoLexer': ('pygments.lexers.templates', 'HTML+Django/Jinja', ('html+django', 'html+jinja'), (), ('text/html+django', 'text/html+jinja')),
     'HtmlGenshiLexer': ('pygments.lexers.templates', 'HTML+Genshi', ('html+genshi', 'html+kid'), (), ('text/html+genshi',)),
     'HtmlLexer': ('pygments.lexers.web', 'HTML', ('html',), ('*.html', '*.htm', '*.xhtml', '*.xslt'), ('text/html', 'application/xhtml+xml')),

pygments/lexers/text.py

            'GroffLexer', 'ApacheConfLexer', 'BBCodeLexer', 'MoinWikiLexer',
            'RstLexer', 'VimLexer', 'GettextLexer', 'SquidConfLexer',
            'DebianControlLexer', 'DarcsPatchLexer', 'YamlLexer',
-           'LighttpdConfLexer', 'NginxConfLexer', 'CMakeLexer']
+           'LighttpdConfLexer', 'NginxConfLexer', 'CMakeLexer',  'HaxeMLLexer']
 
 
 class IniLexer(RegexLexer):
         ]
     }
 
+class HaxeMLLexer(RegexLexer):
+    """
+    Lexer for `haXe build` files.
+    """
+    name = 'haxeML'
+    aliases = ['haxeml', 'hxml']
+    filenames = ['*.hxml']
+
+    tokens = {
+        'root': [
+            (r'(--)(next)',  bygroups( Punctuation, Generic.Heading ) ),
+                # Seperator
+            (r'(-)(prompt|debug|v)', bygroups( Punctuation, Keyword.Keyword ) ),
+                # Compiler switches with one dash
+            (r'(--)(neko-source|flash-strict|flash-use-stage|no-opt|no-traces|'
+             r'no-inline|times|no-output)', bygroups( Punctuation,  Keyword)),
+                # Compilerswitches with two dashes
+            (r'(-)(cpp|js|neko|x|as3|swf9?|swf-lib|php|xml|main|lib|D|resource|'
+             r'cp|cmd)( +)(.+)',  bygroups( Punctuation, 
+                                            Keyword, 
+                                            Whitespace,
+                                            String)), 
+                # targets and other options that take an argument
+            (r'(-)(swf-version)( +)(\d+)', bygroups( Punctuation, 
+                                                     Keyword, 
+                                                     Number.Integer ) ),
+                # Options that take only numerical arguments
+            (r'(-)(swf-header)( +)(\d+)(:)(\d+)(:)(\d+)(:)([A-Fa-f0-9]{6})', 
+                bygroups( Punctuation,
+                          Keyword, 
+                          Whitespace, 
+                          Number.Integer, 
+                          Punctuation, 
+                          Number.Integer, 
+                          Punctuation, 
+                          Number.Integer, 
+                          Punctuation, 
+                          Number.Hex)), 
+                # An Option that defines the size, the fps and the background 
+                # color of an flash movie
+            (r'(--)(js-namespace|php-front|php-lib|remap|gen-hx-classes)( +)'
+             r'(.+)', bygroups( Punctuation,  Keyword,  Whitespace,  String)), 
+                # options with two dashes that takes arguments
+            (r'#.*', Comment.Single ) 
+                # single line comment, multiline does not exists
+        ]
+    }