Mercurial > hg
changeset 25817:42ac9d1d1572
parser: reorder infix/suffix handling to be similar to prefix/primary flow
It can be exactly the same flow as the prefix/primary handling. A suffix
action is accepted only if the next token never starts new term.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 06 Jul 2015 21:55:55 +0900 |
parents | 43a8a87fc175 |
children | 455190fb4e51 |
files | mercurial/parser.py |
diffstat | 1 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/parser.py Sun Jul 05 12:09:27 2015 +0900 +++ b/mercurial/parser.py Mon Jul 06 21:55:55 2015 +0900 @@ -60,15 +60,14 @@ # gather tokens until we meet a lower binding strength while bind < self._elements[self.current[0]][0]: token, value, pos = self._advance() + # handle infix rules, take as suffix if unambiguous infix, suffix = self._elements[token][3:] - # check for suffix - next token isn't a valid prefix if suffix and not self._hasnewterm(): expr = (suffix[0], expr) + elif infix: + expr = (infix[0], expr, self._parseoperand(*infix[1:])) else: - # handle infix rules - if not infix: - raise error.ParseError(_("not an infix: %s") % token, pos) - expr = (infix[0], expr, self._parseoperand(*infix[1:])) + raise error.ParseError(_("not an infix: %s") % token, pos) return expr def parse(self, tokeniter): 'generate a parse tree from tokens'