On Thu, 2008-08-28 at 15:36 -0600, Kurt Otte wrote:
> Jim,
>
> Sorry to add another thing to the list, but I think I may have found
> another bug or perhaps there is a better way to construct the rewrite
> rule to avoid making lots of AST copies. Do you know of a way to
> avoid rewrite rules doing lots of copies?
>
> I have boiled my grammar down to show the problem using toy input.
> When the parser is fed a nested block such as the one below it
> consumes over 2GB of memory and crashes when it runs out of memory.
That looks like a bug - in fact, I think I remember saying to myself
"now I have put in factories for everything, I should not call dup on
the trees! However, I also remember doing that, so perhaps it is
something to do with your grammar) Sorry, but I still won't be able to
look in to this until the weekend :-(
Jim
>
>
> conditional
> : 'if' '(' constant ')' ifblock=block
> // This rewrite rule kills conditionals
> -> ^(CONDITIONAL constant ^(IF $ifblock))
> ;
>
>
> if (0)
> {
> if (0)
> {
> if (0)
> {
> if (0)
> {
> if (0)
> {
> if (0)
> {
> if (0)
> {
> boo;
> }
> }
> }
> }
> }
> }
> }
>
> When digging into it a bit with a profiler, it appears that the
> problem is in the rewrite rule. The rewrite rule for 'conditional' is
> calling ADAPTOR->addChild() and dupTree() recursively millions of
> times which in effect continuously allocates memory until it runs out.
> Is there some way from a syntax point of view that I can construct a
> rewrite rule such that it minimizes the tree dups?
>
> Attached is a zip file, with this toy example to reproduce the problem.
>
> Thanks in advance for any thoughts or advice,
>
> Kurt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address