[antlr-interest] 3.0 resetStateNumbersToBeContiguous error

Thomas Brandon tbrandonau at gmail.com
Wed Jun 28 00:15:14 PDT 2006


I have been trying to get a grammar for C going in Antlr 3 but keep running
errors in resetStateNumbersToBeContiguous (max state num != max renumbered
state) for various rules. I have looked and there does not seem to be any
left recursion in the rule, I'm pretty sure all possible recursive paths
include a terminal. What exactly causes this error? Are there any hints for
diagnosing the cause of the error? As analysis has failed it looks like most
of the really nice information you'd get from Antlr to diagnose such issues
is unavailable. 3.0b1 adds a nicer error message but does not seem to
provide much more information. I have managed to somewhat chart the issues
but largely through trial and error, removing rules I suspect might cause
troubles and rewriting the grammar a number of times in different ways and
seeing where it falls apart. Are there any better methods?

I understand you can set a fixed k and resolve the issue that way but this
seems like a non-optimal solution as I think some of the ambiguities should
be resolvable without backtracking (especially the main statement rule which
currently requires fixed lookahead + a predicate to distinguish varDef and
funcDef rules).

Also, what effect does setting a fixed lookahead on one rule have on the
analysis of calling rules?

And, specifically, has anyone looked at doing a C grammar in Antlr 3?

Oh yeah, and wow, Antlr 3 rocks.

Tom.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060628/94f67987/attachment.html


More information about the antlr-interest mailing list