summaryrefslogtreecommitdiff
path: root/pygments/lexer.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-02-06 07:30:30 +0100
committerGeorg Brandl <georg@python.org>2012-02-06 07:30:30 +0100
commitbb2f7a8bdfce72f688d1c673c087213b73f47447 (patch)
tree316bc100ad349c4a07ac2b1fe373e9ecf25937ea /pygments/lexer.py
parent0af9aeea0bff0b5af3a8801140e641ac38b01ced (diff)
parenta2d3afbf60be0693638a05f0485c445f4d5413da (diff)
downloadpygments-bb2f7a8bdfce72f688d1c673c087213b73f47447.tar.gz
Merge newLISP lexer from https://bitbucket.org/cormullion/pygments-main
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r--pygments/lexer.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 53ea5ac1..46f86076 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -5,7 +5,7 @@
Base lexer classes.
- :copyright: Copyright 2006-2011 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
@@ -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
@@ -439,7 +441,7 @@ class RegexLexerMeta(LexerMeta):
def __call__(cls, *args, **kwds):
"""Instantiate cls after preprocessing its token definitions."""
- if not hasattr(cls, '_tokens'):
+ if '_tokens' not in cls.__dict__:
cls._all_tokens = {}
cls._tmpname = 0
if hasattr(cls, 'token_variants') and cls.token_variants: