[antlr-interest] How do I skip a subtree walking in a tree grammar?

Gavin Lambert antlr at mirality.co.nz
Mon Mar 16 13:20:47 PDT 2009


At 09:09 17/03/2009, Shihwei Li wrote:
>Is this related to syntactic predicate? I can sort of understand 
>the idea behind, but I am not familiar with the syntactic 
>predicate yet. So still need some help from you.

These are actually semantic predicates.

>I tried the tree grammar you provided, and I got compilation 
>errors in the generated java code, such as
>
>   if ( ((a)) ) {s = 18;}
>   else if ( (true) ) {s = 19;}
>
>Saying that 'a' is not defined.

Ah, ok; looks like the predicates are being hoisted out of 
context.  Try removing the => arrows.  I can never remember when 
one should be used vs. the other :)



More information about the antlr-interest mailing list