Hello,
I wonder whether I can use if statements in action code of rules. Here is an
example of a rule for which I would need such an if statement:
x[Object o]
: lp='(' y? ')'
-> ^( NodeX[$lp, "NodeX"] { ((BaseTree) $o).getChild(0) } { ((BaseTree)
$o).getChild(1) } y? )
In above rule, I create a NodeX with three children. The first child is the
left child of the tree passed as argument, the second child is the right
child of the tree passed as argument, and the optional third child is y. The
action code works perfectly.
However, I would like to change the rule as follows:
If the tree passed as argument has only one child, then NodeX will have a
NodeThis as first child and the only child of the argument tree as second
child.
If the tree passed as argument has two children, then I want to keep above
action code.
Is there action syntax that allows me to express this? And if yes, how would
I express this?
Thanks for your help,
Stephanie
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.