[antlr-interest] Problem, with minimal problem-causing grammar
parrt at cs.usfca.edu
Sun Jun 10 17:13:21 PDT 2007
On Jun 9, 2007, at 9:45 PM, Phil Oliver wrote:
> I've been having problems defining a grammar in ANTLRworks (1.0.2,
> latest) - I keep getting the "java.net.ConnectException: Connection
> refused: connect" problem, which, contrary to the assumptions of
> some, does not appear to have anything to do with port numbers, but
> with an uncaught Java out of memory problem. Every generated
> grammar that I've tested in Eclipse, that has that problem in
> ANTLRworks, blows up with an out of memory error, despite having
> over a gigabyte of RAM available to the JVM.
Interesting. I get that memory error unless I use:
java -Xmx80M Test
which makes sense because all of the keywords you have. The DFA
must be huge. Yep, if you look at DFA4_eotS, which is a run length
encoding of the DFA tables, you'll see that they can get very big.
80M seems to make it work okay.
> This is (almost) the minimal problem grammar that I could create
> that causes the problem, a very simple one. No grammar errors are
> flagged. If there's an obvious problem to fix (that actually does
> fix it), I'd appreciate some feedback. Otherwise it looks like a
> bug in ANTLR to me, I'm guessing some kind of code generation
> resulting in an infinite loop that depletes memory.
just increase the memory a little bit.
> Some notes: removing say a few more random token definitions seems
> to clear up the problem. Removing either StrNoHash or StrNoQuotAmp
> removes the problem as well (but both together do not blow up when
> the number of predefined tokens is slightly reduced.) Changing k=*
> to k=1 doesn't fix anything.
ANTLR does not seem to like tokens that can match no characters,
which you have a grammar:
StrNoHash : CharNoHash*;
StrNoQuotAmp : CharNoQuotAmp*;
These are meaningless because (...)* loops are optional. I think
antlr might be going crazy here for these tokens, but I believe I
have a bug report and already.
thanks for the report.
More information about the antlr-interest