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

franck102 franck102 at yahoo.com
Mon Nov 28 11:59:27 PST 2011


Well... almost great :) The rule that generates the EQUAL to be adjusted in
really deep in the hierarchy, and whether the rule should use EQUALS or
ASSIGN depends on rules on the call path (like addExpression below) so that
would be a lot of parameter passing & setting.

Even with a scope, I would have to properly turn off the flag anytime an
intermediate rule inserts a level in the tree, maybe something like
addExpression : compareExpression ( { $rewriteEqual = false; } '+'
compareExpression ) 
... which is a bit error prone.

Basically the rule that generates EQUAL should instead generate ASSIGN iff
its parent node root is of type STATEMENT... and that information is only
readily available after the AST has been built.

Franck

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


More information about the antlr-interest mailing list