[antlr-interest] [C target] [3.1.1] Memory consumption goes through the roof with rewrite rules

Gavin Lambert antlr at mirality.co.nz
Tue Jan 20 11:16:32 PST 2009


At 05:03 21/01/2009, Sam Harwell wrote:
 >I've seen some cases where the lexer will emit a 0-length token 
and
 >not proceed. This creates empty tokens until the system runs out 
of
 >memory.  I'm not familiar with the C target's internals, so 
maybe
 >someone else can direct you to the correct function to watch for 

 >this behavior?
 >
 >Now I wish I saved a copy of a grammar that showed this 
behavior.
 >:\ I remember its cause and solution were relatively easy to
 >identify at the time, so I fixed my grammar and moved on.

The most common way to get that problem is to use a construct like 
this:

INT: ('0'..'9')*;

Note the use of * instead of +.



More information about the antlr-interest mailing list