[antlr-interest] Prediction DFA bug?
Gavin Lambert
antlr at mirality.co.nz
Fri Mar 6 13:18:01 PST 2009
At 06:16 7/03/2009, Andreas Meyer wrote:
>The produced parser had some strange properties, namely, it
>was misled into wrong rules, and then complained about
>mismatched keywords, ie, while looking for a statement
>beginning with keyword_1, it decided to go for the
>statement rule beginning with keyword_2, which in turn
>raised a PredicateFailedException:
>
>keyword_2: {is_keyword2()}? IDENTIFIER;
I believe you need to use a gated predicate instead for that to
work as you'd expect:
keyword_2: {is_keyword2()}? => IDENTIFIER;
But I'm still firmly of the opinion (which seemed to be backed up
by the rest of your message) that overusing predicates harms
performance, since they need to be re-evaluated quite frequently,
whereas regular token lookahead can be very quickly evaluated
using bitsets. (I haven't done testing, though -- this is just a
gut feeling.)
More information about the antlr-interest
mailing list