grammar.py (6501:1b5863aba48c) grammar.py (6660:a886774d5ae1)
1# Copyright (c) 2006-2009 Nathan Binkert <nate@binkert.org>
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 41 unchanged lines hidden (view full) ---

50 lexer.lineno = i + 1
51 lexer.input(line)
52 while True:
53 tok = lexer.token()
54 if not tok:
55 break
56 yield tok
57 self.input = _input()
1# Copyright (c) 2006-2009 Nathan Binkert <nate@binkert.org>
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 41 unchanged lines hidden (view full) ---

50 lexer.lineno = i + 1
51 lexer.input(line)
52 while True:
53 tok = lexer.token()
54 if not tok:
55 break
56 yield tok
57 self.input = _input()
58 self.lexer = lexer
58
59 def next(self):
60 return self.input.next()
61
62 def __iter__(self):
63 return self
64
65 def token(self):
66 try:
67 return self.next()
68 except StopIteration:
69 return None
70
59
60 def next(self):
61 return self.input.next()
62
63 def __iter__(self):
64 return self
65
66 def token(self):
67 try:
68 return self.next()
69 except StopIteration:
70 return None
71
72 def __getattr__(self, attr):
73 return getattr(self.lexer, attr)
74
71class Grammar(object):
72 def __init__(self, output=None, debug=False):
73 self.yacc_args = {}
74 self.yacc_args['debug'] = debug
75
76 if output:
77 import os
78

--- 41 unchanged lines hidden ---
75class Grammar(object):
76 def __init__(self, output=None, debug=False):
77 self.yacc_args = {}
78 self.yacc_args['debug'] = debug
79
80 if output:
81 import os
82

--- 41 unchanged lines hidden ---