I have this code:
import pyparsing as pp
point = pp.Literal(\".\")
number = pp.Combine(pp.Word(pp.nums) + pp.Optional(point + pp.Word(pp.nums)))
In this grammar, a function call is at the same level as a variable reference or numeric literal, so I would add it as part of the definition of atom
:
function_call = Group(ident + lpar + Group(Optional(delimitedList(expr))) + rpar)
atom = number | function_call | ident | pp.Group(lpar + expr + rpar)
Also note the use of delimitedList
in place of expr + ZeroOrMore(comma + expr)
.