summaryrefslogtreecommitdiff
path: root/pygments/lexer.py
diff options
context:
space:
mode:
authormitsuhiko <devnull@localhost>2007-09-28 18:55:13 +0200
committermitsuhiko <devnull@localhost>2007-09-28 18:55:13 +0200
commit3d2eae0ea357ed504ee5a88a53c468e40d0f5539 (patch)
tree4db47e4c06ae5dc3f4d0541b728291d451bff04a /pygments/lexer.py
parent3dbb6abf983c61577b18cec59bec324be3dec98e (diff)
downloadpygments-3d2eae0ea357ed504ee5a88a53c468e40d0f5539.tar.gz
fixed asm lexers, fixed #pop / #push in multitarget
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r--pygments/lexer.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 0850650e..5c41d4a2 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -403,15 +403,11 @@ class RegexLexerMeta(LexerMeta):
new_state = (new_state,)
elif isinstance(tdef2, tuple):
# push more than one state
- new_state = []
for state in tdef2:
- if state == '#pop':
- new_state.append(-1)
- else:
- assert state in unprocessed, \
- 'unknown new state ' + state
- new_state.append(state)
- new_state = tuple(new_state)
+ assert (state in unprocessed or
+ state in ('#pop', '#push')), \
+ 'unknown new state ' + state
+ new_state = tdef2
else:
assert False, 'unknown new state def %r' % tdef2
tokens.append((rex, tdef[1], new_state))
@@ -492,7 +488,13 @@ class RegexLexer(Lexer):
if new_state is not None:
# state transition
if isinstance(new_state, tuple):
- statestack.extend(new_state)
+ for state in new_state:
+ if state == '#pop':
+ statestack.pop()
+ elif state == '#push':
+ statestack.append(statestack[-1])
+ else:
+ statestack.append(state)
elif isinstance(new_state, int):
# pop
del statestack[new_state:]