[antlr-interest] ambiguous grammar
jagad
jagad at enciety.com
Mon Oct 6 21:25:02 PDT 2003
Hi Jbb,
>
> I haven't actually tried running this through the antlr.Tool, but I
> think it is unambigous:
>
> rule1 : '(' expr (COMMA expr)* ')'
> expr : factor (op factor)*
> factor : INTEGER | rule1
> op : '+' | '-'
>
Yes, it's works, Thanks!
> But the above accepts "(1,2)+3" or "3+(2,1)" while your original
> grammar does not. I think a simple semantic error check for the
> presence of a COMMA when an op is encountered would be easy to add if
> that restriction is important...
Correct, the semantic error checking is easy to do with ANTLR, now my
Delphi/Kylix grammar is works :)
>
> Hope this helps.
> -jbb
>
It's very helpfull to me :)
Thanks and Kindest Regards
jagad
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list