[antlr-interest] Implementing if statements in a tree parsing Interpreter
Matthew M. Burke
mmburke at gwu.edu
Fri May 8 12:15:33 PDT 2009
Thanks to all who wrote with suggestions, etc.
I finally twigged to a solution that allowed me to get the approach I
had started to work---probably should have spotted this quicker. In
case anybody's interested, the key line of code is flagged below:
Matthew M. Burke wrote:
>
> Now in the tree parser, I have
>
> statement
> : ...
> | ^(SAME_CMD a=val b=val .) {
> int aval = $a.value;
> int bval = $b.value;
> if (a == b) {
> // HERE'S THE KEY
>
CommonTree
blockRoot = (CommonTree)($statement.start.getChild(2));
......
> }
> }
> | ...
> ;
>
>
More information about the antlr-interest
mailing list