From f6c0e57e1100c19e5c3b63f99514bda3322f9b23 Mon Sep 17 00:00:00 2001 From: moculus Date: Sat, 21 Feb 2009 04:24:14 +0000 Subject: [PATCH] fixed nested grammars --HG-- branch : pmacs2 --- lex.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lex.py b/lex.py index f9a6ae6..c18d2d5 100755 --- a/lex.py +++ b/lex.py @@ -128,8 +128,9 @@ class NocasePatternRule(PatternRule): reflags = re.IGNORECASE class FakeWindow(object): - def __init__(self, app): + def __init__(self, app, b): self.application = app + self.buffer = b class OverrideError(Exception): pass class OverridePatternRule(PatternRule): @@ -139,13 +140,16 @@ class OverridePatternRule(PatternRule): if lexer.action == 'lex': a = lexer.mode.window.application try: + b = lexer.mode.window.buffer modecls = a.modes[d['mode']] - mode = modecls(FakeWindow(lexer.mode.window.application)) + mode = modecls(FakeWindow(lexer.mode.window.application, b)) if hasattr(mode, 'grammar') and hasattr(mode, 'colors'): lexer.mode.gstack['%s' % d['token']] = mode else: raise OverrideError("argh: %r" % mode) except (KeyError, AttributeError, OverrideError): + # uncomment raise to fix dynamic highlighting + #raise pass yield self.make_token(lexer, m.group(0), self.name, parent, d) raise StopIteration