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

login
register
mail settings
Submitter Yuya Nishihara
Date July 17, 2015, 12:34 p.m.
Message ID <3cdc85527cbbe58d148e.1437136445@mimosa>
Download mbox | patch
Permalink /patch/10026/
State Accepted
Headers show

Comments

Yuya Nishihara - July 17, 2015, 12:34 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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:]))