summaryrefslogtreecommitdiff
path: root/pygments/lexer.py
diff options
context:
space:
mode:
authorAlastair Houghton <alastair@coriolis-systems.com>2013-01-03 12:10:25 +0000
committerAlastair Houghton <alastair@coriolis-systems.com>2013-01-03 12:10:25 +0000
commite594d501a73f5255db2f919cf841996103b115b4 (patch)
treea417cf5439e10a26afa46eb13f5b719069d6e216 /pygments/lexer.py
parent3c081914779ce96aff16717742f522a50af97c66 (diff)
downloadpygments-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.py21
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__: