diff options
author | Alastair Houghton <alastair@coriolis-systems.com> | 2013-01-03 12:10:25 +0000 |
---|---|---|
committer | Alastair Houghton <alastair@coriolis-systems.com> | 2013-01-03 12:10:25 +0000 |
commit | e594d501a73f5255db2f919cf841996103b115b4 (patch) | |
tree | a417cf5439e10a26afa46eb13f5b719069d6e216 /pygments/lexer.py | |
parent | 3c081914779ce96aff16717742f522a50af97c66 (diff) | |
download | pygments-e594d501a73f5255db2f919cf841996103b115b4.tar.gz |
Remove the unnecessary analyse_text methods, reduce the default priorities. Also remove some trailing whitespace and tighten-up a couple of except clauses.
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r-- | pygments/lexer.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py index 8535d086..b8cf69fb 100644 --- a/pygments/lexer.py +++ b/pygments/lexer.py @@ -442,7 +442,7 @@ class RegexLexerMeta(LexerMeta): if isinstance(tdef, _inherit): # processed already continue - + assert type(tdef) is tuple, "wrong rule def %r" % tdef try: @@ -494,30 +494,29 @@ class RegexLexerMeta(LexerMeta): try: inherit_ndx = items.index(inherit) - except: - inherit_ndx = -1 - - if inherit_ndx != -1: - inheritable[state] = inherit_ndx + except ValueError: + continue + + inheritable[state] = inherit_ndx continue - + inherit_ndx = inheritable.pop(state, None) if inherit_ndx is None: continue # Replace the "inherit" value with the items curitems[inherit_ndx:inherit_ndx+1] = items - + try: new_inh_ndx = items.index(inherit) - except: + except ValueError: new_inh_ndx = -1 - + if new_inh_ndx != -1: inheritable[state] = inherit_ndx + new_inh_ndx return tokens - + def __call__(cls, *args, **kwds): """Instantiate cls after preprocessing its token definitions.""" if '_tokens' not in cls.__dict__: |