[antlr-interest] Changing the root of a tree in a tree parser

franck102 franck102 at yahoo.com
Mon Nov 28 02:32:06 PST 2011


I am trying to do something that seems pretty simple, which is adjusting the
root token of a tree in my tree parser.
Basically my parser always sees a=b as a comparison and generates ^( EQUAL a
b) as an AST, and in the tree parser I want to adjust that to ^( ASSIGN a b)
if I am at the statement level:

statement
    : ifStatement
    | ...
    | expressionStatement { if ($expressionStatement.tree.getType() ==
EQUALS) { <set tree type to ASSIGN> }

If I try to introduce an assignmentStatement (just in the tree parser) I get
mutually recursive rule, so that isn't an option...

Any suggestion?


--
View this message in context: http://antlr.1301665.n2.nabble.com/Changing-the-root-of-a-tree-in-a-tree-parser-tp7038239p7038239.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list