[antlr-interest] still more predicate syntax (resolution?)
Terence Parr
parrt at cs.usfca.edu
Fri Dec 9 09:49:04 PST 2005
Ok, I forgot something. Semantic predicates used for disambiguation
don't need to be on the left edge precisely. They just need to be
visible to a decision. Here's a nice little example I like:
a : ID (',' ID)* {p}? (',' ID)* ;
Clearly ",b,c" is a problem for the first loop as it doesn't know
whether to match or terminate. ANTLR v3 uses semantic information,
p, to resolve. In this case, the loop will continue while !p and LA
(1)==',' which I think is pretty slick.
So, {...}? must be the disambig sem pred as => would look weird in
the middle of a production. (...)=> makes too much sense so we leave
that as the syn pred. For gated sem pred, I'm going to leave as I
have it now: {...}? => which says semantic predicate that implies
matching the production.
Ok, I guess I had the right answer to start with. Hooray for me. :)
And now back to your regularly scheduled mailing list...
Ter
More information about the antlr-interest
mailing list