diff options
author | Tim Hatch <tim@timhatch.com> | 2014-10-28 15:15:10 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-10-28 15:15:10 -0700 |
commit | bf24a5e0f926faa55bc2e2c99047b5b23b1b22a2 (patch) | |
tree | ced90aeff80578ece12883ecf1343db98f4f1bd3 | |
parent | 118aa6d3bc35bffb0b85f759e465f1c5a88972e8 (diff) | |
download | pygments-bf24a5e0f926faa55bc2e2c99047b5b23b1b22a2.tar.gz |
Improve comments for RegexLexer inheritance.
-rw-r--r-- | pygments/lexer.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py index 21f595be..e0230f1d 100644 --- a/pygments/lexer.py +++ b/pygments/lexer.py @@ -539,6 +539,10 @@ class RegexLexerMeta(LexerMeta): for state, items in iteritems(toks): curitems = tokens.get(state) if curitems is None: + # N.b. because this is assigned by reference, sufficiently + # deep hierarchies are processed incrementally (e.g. for + # A(B), B(C), C(RegexLexer), B will be premodified so X(B) + # will not see any inherits in B). tokens[state] = items try: inherit_ndx = items.index(inherit) @@ -554,6 +558,8 @@ class RegexLexerMeta(LexerMeta): # Replace the "inherit" value with the items curitems[inherit_ndx:inherit_ndx+1] = items try: + # N.b. this is the index in items (that is, the superclass + # copy), so offset required when storing below. new_inh_ndx = items.index(inherit) except ValueError: pass |