[antlr-interest] [3.0b4] StackOverflowError report
Robert Baruch
autophile at zoominternet.net
Tue Oct 24 20:03:51 PDT 2006
>
> observe that both of the above grammars get syntax errors when run.
>
> this happens because there is no base-case for the r0 recursive
> rule. that is,
> an r0 *ALWAYS* has another r0 as its tail. thus we are expected to
> parse an
> INFINITE sequence of N's followed by an EOF. Impossible.
>
> do you mean r0 : r1 + ; or r0 : (r1 r0) | r1 ; <-- both are
> equivalent.
> or perhaps r0 : r1 * ; or r0 : (r1 r0) | /*empty*/ ; <-- both are
> equivalent.
>
My application generates random grammars, then runs them through
ANTLR. Any grammar that passes ANTLR compilation gets run through the
Java compiler. Any grammar that passes Java compilation gets run
against a few test sentences. So I really meant r0 : r1 r0.
> i do not know why error recovery terminates under the `r0 : N r0 ;`
> rule but
> not under the `r0 : r1 r0 ;` rule.
That's the key. To my eyes anyway, the two grammars are equivalent,
yet one causes ANTLR to crash, while the other proceeds normally.
--Rob
More information about the antlr-interest
mailing list