Mercurial > hg-stable
changeset 25804:f0a77cb6316a
parser: extract function that tests if next token may start new term
Future patches will separate primary expression and prefix operator actions.
This function will be used to resolve ambiguity of them.
This is a step to remove the old-style revexpr parser. We need both ":" and
":y" operators for backward compatibility.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 05 Jul 2015 11:54:14 +0900 |
parents | b3004d273874 |
children | 584044e5ad57 |
files | mercurial/parser.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/parser.py Sun Jul 05 18:09:15 2015 +0900 +++ b/mercurial/parser.py Sun Jul 05 11:54:14 2015 +0900 @@ -29,6 +29,9 @@ t = self.current self.current = next(self._iter, None) return t + def _hasnewterm(self): + 'True if next token may start new term' + return bool(self._elements[self.current[0]][1]) def _match(self, m): 'make sure the tokenizer matches an end condition' if self.current[0] != m: @@ -59,7 +62,7 @@ token, value, pos = self._advance() infix, suffix = self._elements[token][2:] # check for suffix - next token isn't a valid prefix - if suffix and not self._elements[self.current[0]][1]: + if suffix and not self._hasnewterm(): expr = (suffix[0], expr) else: # handle infix rules