summaryrefslogtreecommitdiff
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
parent3dbb6abf983c61577b18cec59bec324be3dec98e (diff)
downloadpygments-3d2eae0ea357ed504ee5a88a53c468e40d0f5539.tar.gz
fixed asm lexers, fixed #pop / #push in multitarget
-rw-r--r--pygments/lexer.py20
-rw-r--r--pygments/lexers/asm.py6
2 files changed, 14 insertions, 12 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:]
diff --git a/pygments/lexers/asm.py b/pygments/lexers/asm.py
index 6f2e42ba..a8850968 100644
--- a/pygments/lexers/asm.py
+++ b/pygments/lexers/asm.py
@@ -158,7 +158,7 @@ class DObjdumpLexer(DelegatingLexer):
mimetypes = ['text/x-d-objdump']
def __init__(self, **options):
- super(D_ObjdumpLexer, self).__init__(DLexer, ObjdumpLexer, **options)
+ super(DObjdumpLexer, self).__init__(DLexer, ObjdumpLexer, **options)
class CppObjdumpLexer(DelegatingLexer):
@@ -171,7 +171,7 @@ class CppObjdumpLexer(DelegatingLexer):
mimetypes = ['text/x-cpp-objdump']
def __init__(self, **options):
- super(Cpp_ObjdumpLexer, self).__init__(CppLexer, ObjdumpLexer, **options)
+ super(CppObjdumpLexer, self).__init__(CppLexer, ObjdumpLexer, **options)
class CObjdumpLexer(DelegatingLexer):
@@ -184,7 +184,7 @@ class CObjdumpLexer(DelegatingLexer):
mimetypes = ['text/x-c-objdump']
def __init__(self, **options):
- super(C_ObjdumpLexer, self).__init__(CLexer, ObjdumpLexer, **options)
+ super(CObjdumpLexer, self).__init__(CLexer, ObjdumpLexer, **options)
class LlvmLexer(RegexLexer):