[antlr-interest] how to get back to the beginning of while loop?
Randall R Schulz
rschulz at sonic.net
Sat May 5 14:04:26 PDT 2007
Richard,
On Saturday 05 May 2007 13:43, Richard Hu wrote:
> Hi, All:
>
> I am using Antlr to build an interpreter, how do I tell the tree
> walker to go back to the beginning of a while loop to check the
> condition again after executing the body of the loop?
One pretty easy way is to use a method call in the interpreter to
execute (interpret) the body of the loop (or conditional, etc.). That
way the calling method retains all the context that exists outside the
body / block. Presumably that's where the loop conditionals are
interpreted, thus localizing the loop control at that level, leaving
the evaluation of the loop body to the method invoked to interpret that
body.
> thanks a lot for the help
>
> --Richard
Randall Schulz
More information about the antlr-interest
mailing list