[antlr-interest] How to implement an IF

Bryan Ewbank ewbank at gmail.com
Mon Dec 4 08:48:30 PST 2006


I don't know antlr3 syntax, but the general idea is to process only
the elements you want, and skip ths others.  In other words, delay
processing the "assign" until you know that the condition is true.

^(IF condition x:.)        // x is NOT evaluated, merely captured
   { if ($condition.value) { stat(x); }

Hope this helps!

> I want to add to the expression evaluation a conditional expression:
>
> I think I have correctly built the lexer and parser stuff, but I can't
> figure out how to check the condition and then act. My tree stuff
> parse the condition, no matter if the condition is true or false. I am
> probably missing something here.


More information about the antlr-interest mailing list