summaryrefslogtreecommitdiff
path: root/sphinx/pycode/pgen2
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-30 12:42:26 +0100
committerGeorg Brandl <georg@python.org>2008-12-30 12:42:26 +0100
commit998660e41e99b171d029a0e6aa7b85fc0ba62373 (patch)
tree452521e7761a7fa32465d1486ece58c3aea6d5a0 /sphinx/pycode/pgen2
parent6bec10bbcf957d4a26dc5b3db2f4a099382abf56 (diff)
downloadsphinx-998660e41e99b171d029a0e6aa7b85fc0ba62373.tar.gz
* Add a tag-finding method based on tokens.
* Don't parse immediately if tokenizing suffices. * Also cache by file name.
Diffstat (limited to 'sphinx/pycode/pgen2')
-rw-r--r--sphinx/pycode/pgen2/driver.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/sphinx/pycode/pgen2/driver.py b/sphinx/pycode/pgen2/driver.py
index 3e9e1043..edc882fa 100644
--- a/sphinx/pycode/pgen2/driver.py
+++ b/sphinx/pycode/pgen2/driver.py
@@ -42,8 +42,8 @@ class Driver(object):
column = 0
type = value = start = end = line_text = None
prefix = ""
- for quintuple in tokens:
- type, value, start, end, line_text = quintuple
+ opmap = grammar.opmap
+ for type, value, start, end, line_text in tokens:
if start != (lineno, column):
assert (lineno, column) <= start, ((lineno, column), start)
s_lineno, s_column = start
@@ -62,13 +62,13 @@ class Driver(object):
column = 0
continue
if type == token.OP:
- type = grammar.opmap[value]
- if debug:
- self.logger.debug("%s %r (prefix=%r)",
- token.tok_name[type], value, prefix)
+ type = opmap[value]
+ # if debug:
+ # self.logger.debug("%s %r (prefix=%r)",
+ # token.tok_name[type], value, prefix)
if p.addtoken(type, value, (prefix, start)):
- if debug:
- self.logger.debug("Stop.")
+ # if debug:
+ # self.logger.debug("Stop.")
break
prefix = ""
lineno, column = end
@@ -77,7 +77,7 @@ class Driver(object):
column = 0
else:
# We never broke out -- EOF is too soon (how can this happen???)
- raise parse.ParseError("incomplete input", t, v, x)
+ raise parse.ParseError("incomplete input", type, value, line_text)
return p.rootnode
def parse_stream_raw(self, stream, debug=False):