From: happybrowndog <happybrowndog@ho...>  20080518 06:44:57

Hi, I have been trying to solve this, but just can't figure it out. I have a function with parameters that I want to parse. The function is of this form: NUMBERTOSTR(param) where param is any expression that evaluates to an integer or floating point number, for example: 3 + 2 (3 + 2) / 4 ((3 + 2) / 4) + 7 param thus can have any number of brackets. So I coded param using the following pyparsing expression: param = Forward() param << ZeroOrMany("(") + Operand + Operator + Operand + ZeroOrMany(")") + ZeroOrMany("(") + Optional(param) + ZeroOrMany(")") and NUMBERTOSTR is coded as follows: NUMBERTOSTR = Literal("NUMBERTOSTR(") + param + Literal(")") Here is the problem: NUMBERTOSTR.parseString("NUMBERTOSTR(( ( (3+2)/4) + 7 ) )") returns an exception of not being able to find a ")" character. The reason appears to be that ZeroOrMany(")") consumes all the right brackets so that Literal(")") in NUMBERTOSTR is left wanting. How do I solve this? 