diff options
author | Eli Bendersky <eliben@gmail.com> | 2013-07-13 06:40:36 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2013-07-13 06:40:36 -0700 |
commit | 2a826bcffe76422a7c576f12640a1202b1f7e88b (patch) | |
tree | fb0f47dd2ad42f2477b1545ccf37b29c431921d7 /pycparser/c_lexer.py | |
parent | ffa18094fe6c76ea6bc864b442f65b3668406289 (diff) | |
download | pycparser-2a826bcffe76422a7c576f12640a1202b1f7e88b.tar.gz |
Remember last_token in the lexer, instead of using tokenfunc
Diffstat (limited to 'pycparser/c_lexer.py')
-rw-r--r-- | pycparser/c_lexer.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py index 8a4a0b1..393f0a8 100644 --- a/pycparser/c_lexer.py +++ b/pycparser/c_lexer.py @@ -46,6 +46,9 @@ class CLexer(object): self.type_lookup_func = type_lookup_func self.filename = '' + # Keeps track of the last token returned from self.token() + self.last_token = None + # Allow either "# line" or "# <num>" to support GCC's # cpp output # @@ -71,8 +74,8 @@ class CLexer(object): self.lexer.input(text) def token(self): - g = self.lexer.token() - return g + self.last_token = self.lexer.token() + return self.last_token def find_tok_column(self, token): """ Find the column of the token in its line. |