[antlr-interest] predicate and ambiguity
ld at galador.net
Sun Jul 8 08:15:01 PDT 2007
I need to write a predicate to differentiate these rule: unary and atom
unary : (PLUS|MINUS)? (LPAREN identifier RPAREN /* casts */)* atom
atom : identifier
| LPAREN (expression (COMMA expression)*)? RPAREN
Basically I need to test if "LPAREN identifier RPAREN" is a cast, i.e. if the identifier is a type.
How could I wrote a predicate to test part of might be returned?
Thinking more about it I have been able to refactor succesffully the rule above in the following (working grammar):
unary : (PLUS|MINUS)? cast ;
cast : ((LPAREN identifier RPAREN) cast) => (LPAREN identifier RPAREN) cast
(BTW, ANTLR Works is really helpful and really cool! I feel like it's much easer to overcome grammar problem with it!!!)
Anyway, I still wonder how to a predicate as above, that is I look for a structure A B C where B verify some property to read the stuff as A B C.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest