[antlr-interest] Help to make an iteration (somehing go wrong with previous)

Bryan Ewbank ewbank at gmail.com
Tue Oct 25 12:52:55 PDT 2005


Hmm.  ANTLR allows you to build your tree, but you have to process it
yourself.  ANTLR does not provide any runtime support for this type of
operation; it allows you to walk trees and operate on them...

One way to do this, if you want to use ANTLR's treeparser to drive
your execution, is something like this:

eval:
   ... ... ... | while_stmt | ... ... ...
   ;

while_stmt : #( WHILE e:expr s:stmt ) { while (eval(#e) == true) {
eval(#s); } };

You still have to define what "eval(X)" means, but the "program
counter" is managed by ANTLR via tree walker.

Hope this helps,
- Bryan


More information about the antlr-interest mailing list