[antlr-interest] Tree - Replace nodes in tree

Michael Bedward michael.bedward at gmail.com
Wed Mar 18 17:12:12 PDT 2009


Hello Des,

It's no problem to do this in a tree grammar.  For instance, here is
an example from one of my tree grammars

expr            : ^(ASSIGN assign_op var expr)
                  -> {isImageVar($var.text)}? ^(IMAGE_WRITE var expr)
                  -> ^(ASSIGN assign_op var expr)

Here I replace an ASSIGN node with an IMAGE_WRITE node conditional on
the result of a lookup in the predicate.

Michael


More information about the antlr-interest mailing list