summaryrefslogtreecommitdiff
path: root/pygments/lexer.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-02-05 08:57:50 +0100
committerGeorg Brandl <georg@python.org>2012-02-05 08:57:50 +0100
commit6f19baa8c640cc781aff79c176cec86eca47a932 (patch)
tree049459939336bfba1cb88fad4b9dab86d8751be4 /pygments/lexer.py
parentf9c7782595344ef9cdcb81f3ef93b6ca012d5f02 (diff)
downloadpygments-6f19baa8c640cc781aff79c176cec86eca47a932.tar.gz
Closes #693: fix ObjectiveC lexer throwing errors sometimes because bygroups() does not skip empty groups for callbacks.
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r--pygments/lexer.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 33427ae3..ecd11a5a 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -274,12 +274,14 @@ def bygroups(*args):
if data:
yield match.start(i + 1), action, data
else:
- if ctx:
- ctx.pos = match.start(i + 1)
- for item in action(lexer, _PseudoMatch(match.start(i + 1),
- match.group(i + 1)), ctx):
- if item:
- yield item
+ data = match.group(i + 1)
+ if data is not None:
+ if ctx:
+ ctx.pos = match.start(i + 1)
+ for item in action(lexer, _PseudoMatch(match.start(i + 1),
+ data), ctx):
+ if item:
+ yield item
if ctx:
ctx.pos = match.end()
return callback