[antlr-interest] Understanding nondeterminism warnings: and how to debug them

Martin Probst mail at martin-probst.com
Thu Feb 23 12:16:50 PST 2006


Hi,

> I cant seem to get rid of the few nondeterminism warnings that appear 
> when I attempt to generate the parser.
> How would I debug something like this? Line #14 does not have "BEGIN" 
> ...how do the warning line #'s correspond to my grammar?

Try to think like the parser. You're at some line after the PROGRAM ID
SEMI_COLON stuff and the next token you get is BEGIN. Now you have the
choice to enter one of the optional blocks, but which one? It always has
to be possible to decide from just the one token type (for k==1) which
rule to take. Apparently in your grammar that's not the case (though I
cannot see what's the problem in line #14 - are you sure the numbers are
right?).

You can get a better idea of what's going on by reading the source code,
that helps a lot to understand the whole thing.

Martin



More information about the antlr-interest mailing list