[antlr-interest] How can I set the text of a node?
Pauba, Kevin L
KLPauba at west.com
Tue Sep 22 09:06:25 PDT 2009
I have two rules for assignments to handle an optional LET keyword:
...
| KW_let // Rule A
lhs = var
op = operator
rhs = expression
-> ^(KW_let $lhs $op $rhs)
| lhs = var // Rule B
op = operator
rhs = expression
-> ^(KW_let $lhs $op $rhs)
...
Here's two related gunit test cases:
"let $var = 15" -> (let $var = 15)
"$var = 15" -> (let $var = 15)
But when I run it, it fails on the second case:
test10 (assignmentStatement, line22) -
expected: (let $var = 15)
actual: (KW_let $var = 15)
Is there a way to set the text of the root node of the tree constructed with "Rule B" that would allow this test case to pass?
I tried something similar to what's shown on pg. 183 of TDAR but I couldn't figure out how to add the child nodes for $lhs, $op and $rhs.
Thanks!
More information about the antlr-interest
mailing list