Hello,

I used ANTLR v3.2 and ANTLRWorks v1.4 to build multiple small tools. Recently I 
encountered the problem, that a rather trivial grammar causes IMHO 
inappropriately high runtime and memory usage.

Looking for my mistake, I stripped the grammar down to following one:

----------------------------------------------------------------------------------------------------------------------------------------

grammar problem;

main_rule
        :       SOMETOKEN;

SOMETOKEN
        :       ('a')*;

----------------------------------------------------------------------------------------------------------------------------------------

>From this source file I compiled a grammar using ANTLRWorks v1.4 and 
>surrounded it with the standard Java code from the TDAR (so nothing special 
>here).

If I feed the parser some input, that is not valid with respect to the above 
grammar (it can be anything, take e.g. the following string of only one 
character: "<"), it will take a lot of processor time and consume very high 
amounts of memory. E.g. I configured a limit of 1 GB of RAM in Eclipse (using 
"-Xmx1024m") and it's taking this amount.

To be complete, I also list the code calling the parser here:

----------------------------------------------------------------------------------------------------------------------------------------

public static void main(String[] args) throws Exception
{
        ANTLRStringStream       input   = new ANTLRStringStream("<");
        problemLexer            lexer   = new problemLexer(input);
        CommonTokenStream       tokens  = new CommonTokenStream(lexer);
        problemParser           parser  = new problemParser(tokens);
        parser.main_rule();
}

----------------------------------------------------------------------------------------------------------------------------------------

=> Did I make some beginner's error and I'm just not able to see it?

Thanks in advance and best regards,
   Ralf Cremerius


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to