diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2016-01-01 01:13:22 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2016-01-01 01:13:22 +0000 |
commit | ffe44eedb91ca1fd98e491e99566210a46818b8e (patch) | |
tree | 6593afc0f8d04f7e705c5409cb7cedf9394ba32e /src/pyparsing.py | |
parent | a899588d852cc879b6cb20761bfde12a06ef4a90 (diff) | |
download | pyparsing-git-ffe44eedb91ca1fd98e491e99566210a46818b8e.tar.gz |
More internal expression naming, in internal elements of infixNotation
Diffstat (limited to 'src/pyparsing.py')
-rw-r--r-- | src/pyparsing.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pyparsing.py b/src/pyparsing.py index da55b0a..d1d5b53 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -58,7 +58,7 @@ The pyparsing module handles some of the problems that are typically vexing when """
__version__ = "2.0.8"
-__versionTime__ = "31 Dec 2015 06:02"
+__versionTime__ = "31 Dec 2015 19:10"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -3596,11 +3596,12 @@ def infixNotation( baseExpr, opList, lpar=Suppress('('), rpar=Suppress(')') ): lastExpr = baseExpr | ( lpar + ret + rpar )
for i,operDef in enumerate(opList):
opExpr,arity,rightLeftAssoc,pa = (operDef + (None,))[:4]
+ termName = "%s term" % opExpr if arity < 3 else "%s%s term" % opExpr
if arity == 3:
if opExpr is None or len(opExpr) != 2:
raise ValueError("if numterms=3, opExpr must be a tuple or list of two expressions")
opExpr1, opExpr2 = opExpr
- thisExpr = Forward()#.setName("expr%d" % i)
+ thisExpr = Forward().setName(termName)
if rightLeftAssoc == opAssoc.LEFT:
if arity == 1:
matchExpr = FollowedBy(lastExpr + opExpr) + Group( lastExpr + OneOrMore( opExpr ) )
@@ -3634,7 +3635,7 @@ def infixNotation( baseExpr, opList, lpar=Suppress('('), rpar=Suppress(')') ): raise ValueError("operator must indicate right or left associativity")
if pa:
matchExpr.setParseAction( pa )
- thisExpr <<= ( matchExpr | lastExpr )
+ thisExpr <<= ( matchExpr.setName(termName) | lastExpr )
lastExpr = thisExpr
ret <<= lastExpr
return ret
|