[antlr-interest] Way to send two different trees based on input to rule?
Brian DeVries
contingencyplan at gmail.com
Sat Nov 25 05:47:46 PST 2006
Hello all,
I have an ANTLR v3 parser rule that takes a boolean parameter, does some
stuff, and outputs (part of) an AST. When that parameter is true, I want it
to output a certain node in the tree, and something else when it's false. Is
there a way to do this? I'm thinking semantic predicates, but the v2
documentation from the website states that predicates in the middle of the
rule are validating, and I couldn't get the disambiguating one to work on
another rule a few days ago (it was still treating it as a validating
predicate).
Toy example (should be syntactically right):
rule [boolean b]
: X y -> ^(R X y)
;
I'm wanting something like
rule [boolean b]
: X y /* if $b == true */ -> ^(R X y)
/* else */ -> ^(R Z y)
;
Thanks!
~Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20061125/8f202a37/attachment.html
More information about the antlr-interest
mailing list