[antlr-interest] C runtime issue
Jim Idle
jimi at temporal-wave.com
Tue Feb 3 08:35:45 PST 2009
Andy Grove wrote:
> Hi,
>
> When I invoke my generated C parser, I see memory usage climb from
> 770MB to 4GB in a few seconds and the parser never returns. My init
> code is as follows:
>
Hi Andy,
I have recently made a lot of changes to try an auto-track and release
memory and rewrite streams in the C runtime this will help everyone
(more details ot his later this week once I have tested it more).
However this does not look like your issue here. Usually, this problem
is created by an incorrect lexer rule that is matching nothing, hence
the parser asks the lexer for the first token and the empty rule matches
and nothing is consumed from the input stream. Hence your lexer will
carry on returning empty tokens until it runs out of memory.
Look for the following errors:
TOKEN : ('a'..'z')* ; // Note that this should be + and not *
TOK : ; // Forgot to define this or meant it to be fragment
I am pretty sure that this is what you will find somewhere. If you
single step into the LA routine, then you can trace through to the
fillBuffer() method, which is trying to create the token stream before
it gives the first token back to the parser. Keep stepping and you will
find yourself in the code for a lexer rule. It is likely that first
lexer rule that you enter that is in error.
Jim
More information about the antlr-interest
mailing list