[antlr-interest] Very high runtime and memory usage caused by trivial grammar => Is it my mistake?
Bart Kiers
bkiers at gmail.com
Thu Oct 21 00:51:08 PDT 2010
On Thu, Oct 21, 2010 at 9:13 AM, Cremerius Ralf (DGS-EC/ECC3) <
Ralf.Cremerius at de.bosch.com> wrote:
> ...
>
> SOMETOKEN
> : ('a')*;
>
> ...
>
> 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?
>
>
The rule:
SOMETOKEN
: ('a')*
;
matches empty strings, and there are an infinite amount of them before your
input "<". This is probably the cause of the behavior you're
witnessing. Change it into 'a'+ and see if things run differently.
Regards,
Bart.
More information about the antlr-interest
mailing list