summaryrefslogtreecommitdiff
path: root/pycparser/c_lexer.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-07-13 06:40:36 -0700
committerEli Bendersky <eliben@gmail.com>2013-07-13 06:40:36 -0700
commit2a826bcffe76422a7c576f12640a1202b1f7e88b (patch)
treefb0f47dd2ad42f2477b1545ccf37b29c431921d7 /pycparser/c_lexer.py
parentffa18094fe6c76ea6bc864b442f65b3668406289 (diff)
downloadpycparser-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.py7
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.