My parser grammar can generate a number of subtrees with similar structure,
and just a different root type. In the tree grammar I am trying to just pass
such a subtree along without any changes, but that is turning out to be much
trickier than I expected, am I missing something?
Given this AST: ^( AND true false ) I want the tree grammar to generate the
same AST subtree.
The following attempts are not working:
^( ( AND | OR ) booleanExpression booleanExpression ) // no rewrite =>
flattens the tree,
// I get a nil root and 3 children
^( ( root=AND | root=OR ) booleanExpression booleanExpression )
-> ( ( AND | OR ) booleanExpression booleanExpression ) //
syntax error
^( ( root=AND | root=OR ) booleanExpression booleanExpression )
-> ( AND? OR? booleanExpression booleanExpression ) //
syntax error
^( root=(AND | OR ) booleanExpression booleanExpression )
-> ( $root booleanExpression booleanExpression ) // runtime
error, $root is empty
Am I going to have to split those rules??
Any suggestion appreciated!
--
View this message in context:
http://antlr.1301665.n2.nabble.com/Tree-building-limitation-in-tree-grammars-tp7038639p7038639.html
Sent from the ANTLR mailing list archive at Nabble.com.
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.