[PATCH 4 of 6] parser: take suffix action if no infix action is defined

Yuya Nishihara yuya at tcha.org
Fri Jul 17 07:34:05 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1436187701 -32400
#      Mon Jul 06 22:01:41 2015 +0900
# Node ID 3cdc85527cbbe58d148e3c2d9bdeb3281acb1976
# Parent  b1c727ea2cccd6c417f4315f60f91e08a7227ec8
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.

diff --git a/mercurial/parser.py b/mercurial/parser.py
--- a/mercurial/parser.py
+++ b/mercurial/parser.py
@@ -62,7 +62,7 @@ class parser(object):
             token, value, pos = self._advance()
             # handle infix rules, take as suffix if unambiguous
             infix, suffix = self._elements[token][3:]
-            if suffix and not self._hasnewterm():
+            if suffix and not (infix and self._hasnewterm()):
                 expr = (suffix[0], expr)
             elif infix:
                 expr = (infix[0], expr, self._parseoperand(*infix[1:]))


More information about the Mercurial-devel mailing list