ply grammar: Fixup Tokenizer class so you can get lexer arguments
authorNathan Binkert <nate@binkert.org>
Thu, 24 Sep 2009 01:28:29 +0000 (18:28 -0700)
committerNathan Binkert <nate@binkert.org>
Thu, 24 Sep 2009 01:28:29 +0000 (18:28 -0700)
src/python/m5/util/grammar.py

index 93c2c84c45dcbae4f7e8346f7f2b44dee4ac1b0d..ab5f35868872120a084e79b695f7f3f233b9d258 100644 (file)
@@ -55,6 +55,7 @@ class Tokenizer(object):
                         break
                     yield tok
         self.input = _input()
+        self.lexer = lexer
 
     def next(self):
         return self.input.next()
@@ -68,6 +69,9 @@ class Tokenizer(object):
         except StopIteration:
             return None
 
+    def __getattr__(self, attr):
+        return getattr(self.lexer, attr)
+
 class Grammar(object):
     def __init__(self, output=None, debug=False):
         self.yacc_args = {}