summaryrefslogtreecommitdiff
path: root/pygments/lexer.py
diff options
context:
space:
mode:
authorGaurav Jain <gaurav@gauravjain.org>2014-05-18 04:15:41 -0400
committerGaurav Jain <gaurav@gauravjain.org>2014-05-18 04:15:41 -0400
commitd3399178e86e83c3ffa8d0b188d0478d12c90431 (patch)
treeccf0ac20f8566f76964a192e89a424c116279069 /pygments/lexer.py
parent74dac1d119073e0642287690887d257d76814edb (diff)
downloadpygments-d3399178e86e83c3ffa8d0b188d0478d12c90431.tar.gz
Add support for default state transition in ExtendedRegexLexer
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r--pygments/lexer.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 205b7495..0ede7927 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -675,15 +675,16 @@ class ExtendedRegexLexer(RegexLexer):
for rexmatch, action, new_state in statetokens:
m = rexmatch(text, ctx.pos, ctx.end)
if m:
- if type(action) is _TokenType:
- yield ctx.pos, action, m.group()
- ctx.pos = m.end()
- else:
- for item in action(self, m, ctx):
- yield item
- if not new_state:
- # altered the state stack?
- statetokens = tokendefs[ctx.stack[-1]]
+ if action is not None:
+ if type(action) is _TokenType:
+ yield ctx.pos, action, m.group()
+ ctx.pos = m.end()
+ else:
+ for item in action(self, m, ctx):
+ yield item
+ if not new_state:
+ # altered the state stack?
+ statetokens = tokendefs[ctx.stack[-1]]
# CAUTION: callback must set ctx.pos!
if new_state is not None:
# state transition