1. raichoo
  2. pygments-main

Commits

Georg Brandl  committed dba8724

Overhaul the Makefile lexer a bit more.

  • Participants
  • Parent commits b0ec891
  • Branches default

Comments (0)

Files changed (1)

File pygments/lexers/text.py

View file
  • Ignore whitespace
 
     tokens = {
         'root': [
+            # recipes (need to allow spaces because of expandtabs)
+            (r'^(?:[\t ]+.*\n|\n)+', using(BashLexer)),
+            # special variables
+            (r'\$[<@$+%?|*]', Keyword),
             (r'\s+', Text),
             (r'#.*?\n', Comment),
             (r'(export)(\s+)(?=[a-zA-Z0-9_${}\t -]+\n)',
             # targets
             (r'([^\n:]+)(:+)([ \t]*)', bygroups(Name.Function, Operator, Text),
              'block-header'),
-            # recipes
-            (r'^(?:[\t ]+.*\n|\n)+', using(BashLexer)),
             # expansions
-            (r'\$\((?:.*\\\n|.*\n)+', using(BashLexer)),
-            # TODO: add paren handling (grr)
+            (r'\$\(', Keyword, 'expansion'),
+        ],
+        'expansion': [
+            (r'[^$a-zA-Z_)]+', Text),
+            (r'[a-zA-Z_]+', Name.Variable),
+            (r'\$', Keyword),
+            (r'\(', Keyword, '#push'),
+            (r'\)', Keyword, '#pop'),
         ],
         'export': [
             (r'[a-zA-Z0-9_${}-]+', Name.Variable),
             (r'\s+', Text),
         ],
         'block-header': [
-            (r'[^,\\\n#]+', Number),
-            (r',', Punctuation),
-            (r'#.*?\n', Comment),
+            (r'[,|]', Punctuation),
+            (r'#.*?\n', Comment, '#pop'),
             (r'\\\n', Text), # line continuation
-            (r'\\.', Text),
-            (r'(?:[\t ]+.*\n|\n)+', using(BashLexer), '#pop'),
+            (r'\$\(', Keyword, 'expansion'),
+            (r'[a-zA-Z_]+', Name),
+            (r'\n', Text, '#pop'),
+            (r'.', Text),
         ],
     }