diff options
author | Tim Hatch <tim@timhatch.com> | 2013-05-09 17:34:44 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2013-05-09 17:34:44 -0700 |
commit | e6ee6af9da9b8f5d38db70222bc3eca3f8a07110 (patch) | |
tree | b391dd7ecde4b8974aa734001b4ae8b63d6de5b3 /pygments/lexers/shell.py | |
parent | 3ea722b4b51d7136a489dc58c2f9add443b7c697 (diff) | |
download | pygments-e6ee6af9da9b8f5d38db70222bc3eca3f8a07110.tar.gz |
Split PowerShell root into two states, so we know when a close paren is
expected.
Fixes #869
Diffstat (limited to 'pygments/lexers/shell.py')
-rw-r--r-- | pygments/lexers/shell.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py index d117fd86..eb87a674 100644 --- a/pygments/lexers/shell.py +++ b/pygments/lexers/shell.py @@ -370,8 +370,7 @@ class PowerShellLexer(RegexLexer): 'root': [ # we need to count pairs of parentheses for correct highlight # of '$(...)' blocks in strings - (r'\(', Punctuation, '#push'), - (r'\)', Punctuation, '#pop'), + (r'\(', Punctuation, 'child'), (r'\s+', Text), (r'^(\s*#[#\s]*)(\.(?:%s))([^\n]*$)' % '|'.join(commenthelp), bygroups(Comment, String.Doc, Comment)), @@ -393,6 +392,10 @@ class PowerShellLexer(RegexLexer): (r'\w+', Name), (r'[.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::', Punctuation), ], + 'child': [ + (r'\)', Punctuation, '#pop'), + include('root'), + ], 'multline': [ (r'[^#&.]+', Comment.Multiline), (r'#(>|>)', Comment.Multiline, '#pop'), @@ -402,14 +405,14 @@ class PowerShellLexer(RegexLexer): 'string': [ (r"`[0abfnrtv'\"\$]", String.Escape), (r'[^$`"]+', String.Double), - (r'\$\(', Punctuation, 'root'), + (r'\$\(', Punctuation, 'child'), (r'""', String.Double), (r'[`$]', String.Double), (r'"', String.Double, '#pop'), ], 'heredoc-double': [ (r'\n"@', String.Heredoc, '#pop'), - (r'\$\(', Punctuation, 'root'), + (r'\$\(', Punctuation, 'child'), (r'[^@\n]+"]', String.Heredoc), (r".", String.Heredoc), ] |