summaryrefslogtreecommitdiff
path: root/pyparsing/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyparsing/helpers.py')
-rw-r--r--pyparsing/helpers.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/pyparsing/helpers.py b/pyparsing/helpers.py
index dc183a0..1328a79 100644
--- a/pyparsing/helpers.py
+++ b/pyparsing/helpers.py
@@ -783,17 +783,15 @@ def infix_notation(
thisExpr = Forward().set_name(term_name)
if rightLeftAssoc is OpAssoc.LEFT:
if arity == 1:
- matchExpr = _FB(lastExpr + opExpr) + Group(
- lastExpr + opExpr + opExpr[...]
- )
+ matchExpr = _FB(lastExpr + opExpr) + Group(lastExpr + opExpr[1, ...])
elif arity == 2:
if opExpr is not None:
matchExpr = _FB(lastExpr + opExpr + lastExpr) + Group(
- lastExpr + opExpr + lastExpr + (opExpr + lastExpr)[...]
+ lastExpr + (opExpr + lastExpr)[1, ...]
)
else:
matchExpr = _FB(lastExpr + lastExpr) + Group(
- lastExpr + lastExpr + lastExpr[...]
+ lastExpr + lastExpr[1, ...]
)
elif arity == 3:
matchExpr = _FB(
@@ -808,11 +806,11 @@ def infix_notation(
elif arity == 2:
if opExpr is not None:
matchExpr = _FB(lastExpr + opExpr + thisExpr) + Group(
- lastExpr + opExpr + thisExpr + (opExpr + thisExpr)[...]
+ lastExpr + (opExpr + thisExpr)[1, ...]
)
else:
matchExpr = _FB(lastExpr + thisExpr) + Group(
- lastExpr + thisExpr + thisExpr[...]
+ lastExpr + thisExpr[1, ...]
)
elif arity == 3:
matchExpr = _FB(
@@ -823,7 +821,7 @@ def infix_notation(
matchExpr.set_parse_action(*pa)
else:
matchExpr.set_parse_action(pa)
- thisExpr <<= matchExpr.set_name(term_name) | lastExpr
+ thisExpr <<= (matchExpr | lastExpr).setName(term_name)
lastExpr = thisExpr
ret <<= lastExpr
return ret