diff options
author | Georg Brandl <georg@python.org> | 2012-02-05 13:11:54 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-02-05 13:11:54 +0100 |
commit | 384e3a8e9aa2b72b16e0daede06c5973305ae9cd (patch) | |
tree | a8e016d4b500242a0fad321418955bf610ae3a36 /pygments/lexer.py | |
parent | 7d9fd398089c674c839f8e095dee022b087cf19f (diff) | |
parent | 69af79be2e99f8d7124607c27d8a35389416f3f5 (diff) | |
download | pygments-384e3a8e9aa2b72b16e0daede06c5973305ae9cd.tar.gz |
Merge Fantom lexer from https://bitbucket.org/ivan_inozemtsev/pygments-main
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r-- | pygments/lexer.py | 18 |
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: |