comparison mercurial/parser.py @ 25818:455190fb4e51

parser: take suffix action if no infix action is defined If no infix action is defined, a suffix action isn't ambiguous, so it should be taken no matter if the next token can be an operand. This is exactly the same flow as prefix/primary handling. This change has no effect now because all suffix tokens have infix actions.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 06 Jul 2015 22:01:41 +0900
parents 42ac9d1d1572
children 7448df709b2e
comparison
equal deleted inserted replaced
25817:42ac9d1d1572 25818:455190fb4e51
60 # gather tokens until we meet a lower binding strength 60 # gather tokens until we meet a lower binding strength
61 while bind < self._elements[self.current[0]][0]: 61 while bind < self._elements[self.current[0]][0]:
62 token, value, pos = self._advance() 62 token, value, pos = self._advance()
63 # handle infix rules, take as suffix if unambiguous 63 # handle infix rules, take as suffix if unambiguous
64 infix, suffix = self._elements[token][3:] 64 infix, suffix = self._elements[token][3:]
65 if suffix and not self._hasnewterm(): 65 if suffix and not (infix and self._hasnewterm()):
66 expr = (suffix[0], expr) 66 expr = (suffix[0], expr)
67 elif infix: 67 elif infix:
68 expr = (infix[0], expr, self._parseoperand(*infix[1:])) 68 expr = (infix[0], expr, self._parseoperand(*infix[1:]))
69 else: 69 else:
70 raise error.ParseError(_("not an infix: %s") % token, pos) 70 raise error.ParseError(_("not an infix: %s") % token, pos)