##// END OF EJS Templates
parser: extract function that tests if next token may start new term...
Yuya Nishihara -
r25804:f0a77cb6 default
parent child Browse files
Show More
@@ -29,6 +29,9 b' class parser(object):'
29 t = self.current
29 t = self.current
30 self.current = next(self._iter, None)
30 self.current = next(self._iter, None)
31 return t
31 return t
32 def _hasnewterm(self):
33 'True if next token may start new term'
34 return bool(self._elements[self.current[0]][1])
32 def _match(self, m):
35 def _match(self, m):
33 'make sure the tokenizer matches an end condition'
36 'make sure the tokenizer matches an end condition'
34 if self.current[0] != m:
37 if self.current[0] != m:
@@ -59,7 +62,7 b' class parser(object):'
59 token, value, pos = self._advance()
62 token, value, pos = self._advance()
60 infix, suffix = self._elements[token][2:]
63 infix, suffix = self._elements[token][2:]
61 # check for suffix - next token isn't a valid prefix
64 # check for suffix - next token isn't a valid prefix
62 if suffix and not self._elements[self.current[0]][1]:
65 if suffix and not self._hasnewterm():
63 expr = (suffix[0], expr)
66 expr = (suffix[0], expr)
64 else:
67 else:
65 # handle infix rules
68 # handle infix rules
General Comments 0
You need to be logged in to leave comments. Login now