diff options
author | Georg Brandl <georg@python.org> | 2014-09-20 10:05:54 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-09-20 10:05:54 +0200 |
commit | 8910155e28667fa2117f32cacd320194431fc805 (patch) | |
tree | 1cc311cf83b2fc15c4ce40a369a5096a63b89822 | |
parent | 40170ef1e363bfa8f3bfca8c2ce3756c014a63fb (diff) | |
download | pygments-8910155e28667fa2117f32cacd320194431fc805.tar.gz |
Fix inefficient lexing of whitespace before preprocessor macros in SourcePawn/Pawn.
-rw-r--r-- | pygments/lexers/pawn.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pygments/lexers/pawn.py b/pygments/lexers/pawn.py index aab043ad..d506072e 100644 --- a/pygments/lexers/pawn.py +++ b/pygments/lexers/pawn.py @@ -30,6 +30,8 @@ class SourcePawnLexer(RegexLexer): #: optional Comment or Whitespace _ws = r'(?:\s|//.*?\n|/\*.*?\*/)+' + #: only one /* */ style comment + _ws1 = r'\s*(?:/[*].*?[*]/\s*)*' tokens = { 'root': [ @@ -37,8 +39,8 @@ class SourcePawnLexer(RegexLexer): ('^#if\s+0', Comment.Preproc, 'if0'), ('^#', Comment.Preproc, 'macro'), # or with whitespace - ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'), - ('^' + _ws + '#', Comment.Preproc, 'macro'), + ('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'), + ('^' + _ws1 + '#', Comment.Preproc, 'macro'), (r'\n', Text), (r'\s+', Text), (r'\\\n', Text), # line continuation @@ -140,6 +142,8 @@ class PawnLexer(RegexLexer): #: optional Comment or Whitespace _ws = r'(?:\s|//.*?\n|/[*][\w\W]*?[*]/)+' + #: only one /* */ style comment + _ws1 = r'\s*(?:/[*].*?[*]/\s*)*' tokens = { 'root': [ @@ -147,8 +151,8 @@ class PawnLexer(RegexLexer): ('^#if\s+0', Comment.Preproc, 'if0'), ('^#', Comment.Preproc, 'macro'), # or with whitespace - ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'), - ('^' + _ws + '#', Comment.Preproc, 'macro'), + ('^' + _ws1 + r'#if\s+0', Comment.Preproc, 'if0'), + ('^' + _ws1 + '#', Comment.Preproc, 'macro'), (r'\n', Text), (r'\s+', Text), (r'\\\n', Text), # line continuation |