[antlr-interest] disambiguating sempred in a closure?
J Chapman Flack
jflack at math.purdue.edu
Fri Dec 21 14:58:25 PST 2007
Ok, here is the simplified grammar that really does
demonstrate my dilemma. The predicates can't do what
I need because of the grouping parentheses added to
factor out the common something_else suffix.
I can get the code I want if I leave off the grouping
parens and duplicate the something_else suffix on
each branch. Is that the best I can do? I hate to
duplicate the something_else (which is followed by
a nontrivial action).
Is the story the same in ANTLR 3?
-Chap
class CelebParser extends Parser;
prod : something
( options { greedy=true; }
: ( { muppet }? ( KERMIT | FOZZIE )
| { turtle }? ( LEONARDO | DONATELLO )
)
something_else
)*
;
something : APPLE
| HOWITZER
;
something_else : SPACESHIP
| APTERYX
;
More information about the antlr-interest
mailing list