[antlr-interest] What's the difference between these two rules?

Gavin Lambert antlr at mirality.co.nz
Wed Nov 26 03:20:04 PST 2008


At 23:48 26/11/2008, chain one wrote:
>Could someone tell me what the difference is between the 
>following two rules?
>
>stat
>options{backtrack=true}
>: declaration
>| expression
>;
>
>stat
>:(declaration)=> declaration
>| expression
>;

As I understand it, the former could end up behaving identically 
to the latter if ANTLR determines that there's any possibility of 
ambiguity between declaration and expression.  Otherwise the 
former is identical to the latter without the use of the synpred 
(or itself without the option).

The latter on the other hand will always try to pre-evaluate 
declaration.


I could be wrong, though.



More information about the antlr-interest mailing list