[antlr-interest] Weird operator precedence
Sohail Somani
sohail at taggedtype.net
Fri Oct 14 00:37:14 PDT 2005
Hi guys,
In the language I am parsing, the below is valid (I hope its enough of a
grammar for you to help me). I have implemented operator precedence in
the same way as Scott Stanchfields:
exponentExpression
: primitiveElement (POWER signExpression)*
;
signExpression
: ((PLUS|MINUS))* exponentExpression
;
That is, exponentiation has higher precedence than negation except when
the exponent is a signExpression.
However, ANTLR tells me that there is nondeterminism upon k==1:POWER
between alt 1 and exit branch of the exponentExpression. I thought I
understood why ANTLR tells me this, but now I'm not sure. And I'm also
not sure if I can hush this warning safely.
Thanks in advance for your input,
Sohail
More information about the antlr-interest
mailing list