[Pyparsing] Order problem in binary operation with operationPrecedence()
Brought to you by:
ptmcg
From: Gustavo N. <me...@gu...> - 2009-07-06 20:00:27
|
Hello again, everybody. I've defined a Pyparsing grammar for boolean expressions, based on operationPrecedence() and I have an strange problem. This grammar has five types of operands: 3 literals (string, number, set) and 2 non-literals (variable, function). The following expressions work like a charm: * "pi == 3.1416" * "pi > 3.1416" * "pi < 3.1416" * "pi => 3.1416" * "pi <= 3.1416" But if I rearrange the operands, I'd get an exception (like "Expected end of text (at char 7), (line:1, col:8)"): * "3.1416 == pi" * "3.1416 < pi" * "3.1416 > pi" * etc. Every other combination of operands work, AFAIK, except when the first operand in a binary operation is a number: * "hello" in {"hi", "bye", "hello", "good-bye"} * "e < pi" * "pi > e" What's going wrong? I've attached an excerpt from my library for you to reproduce it easily. Thanks in advance! -- Gustavo Narea <xri://=Gustavo>. | Tech blog: =Gustavo/(+blog)/tech ~ About me: =Gustavo/about | |