diff options
author | Georg Brandl <georg@python.org> | 2014-03-04 16:17:34 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-03-04 16:17:34 +0100 |
commit | 0421e494637b42690be680872e8e5aa43ca5e550 (patch) | |
tree | 39c50f98e2358bfb51754914937886123f41f5c2 | |
parent | e7ec14d69541995b8e51c2d6f3be1ec6444b6edc (diff) | |
download | pygments-0421e494637b42690be680872e8e5aa43ca5e550.tar.gz |
Overhaul the Makefile lexer a bit more.
-rw-r--r-- | pygments/lexers/text.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py index 956dbd32..8de786c2 100644 --- a/pygments/lexers/text.py +++ b/pygments/lexers/text.py @@ -227,6 +227,10 @@ class BaseMakefileLexer(RegexLexer): 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)', @@ -241,11 +245,15 @@ class BaseMakefileLexer(RegexLexer): # 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), @@ -253,12 +261,13 @@ class BaseMakefileLexer(RegexLexer): (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), ], } |