[antlr-interest] StringTemplate stack overflow exception, stringtemplate-3.0

Hardy, Stephen Stephen_Hardy at rabbit.com
Sun Jul 15 18:43:11 PDT 2007


OK, welding done...

 

Well , it turns out that there *is* a loop in the template inclusion,
but there are more steps than indicated by the trace.  Maybe there's a
limit in the code somewhere.  However, I don't understand why this
should cause an exception since recursion is such a natural part of most
grammars.  The input file was a single line of C code (as mentioned
before, I am using the ANSI C grammar in tree parser form), so it should
not have gone anywhere near blowing the java stack.

 

Any suggestions for a workaround?

 

What is the interpretation of the "references=[...]" stuff in the trace.
Sure, I have scs and d attributes in some of the templates, but not in
any of those listed.  Maybe it is some sort of run-time indication of
how it got to the particular state.  Needs a bit of explanation though.

 

Regards,

SJH



 

________________________________

 

Terence,

 

Here is the console output when lint mode is turned on...

 

Exception in thread "main" java.lang.IllegalStateException: infinite
recursion to 

     <anonymous([])@58> referenced in <anonymous([])@53>; stack trace:

<anonymous([])@58>, attributes=[dd=<anonymous()@57>], references=[dd,
scs, d]>

<anonymous([])@53>, attributes=[d, ds=<anonymous()@52>], references=[ds,
scs, d]>

<anonymous([])@54>, attributes=[p=List[..<anonymous()@53>..]],
references=[p, scs, d]>

<anonymous([])@55>, attributes=[pl=<anonymous()@54>, v], references=[pl,
scs, d]>

<anonymous([])@56>, attributes=[ptl=<anonymous()@55>], references=[ptl,
scs, d]>

<anonymous([])@57>, attributes=[dsuf=List[..<anonymous()@56>..], id],
references=[id, dsuf, scs, d]>

<anonymous([])@58> (start of recursive cycle)

...

 

 

Without (as yet) fully understanding the above, it seems odd that every
line contains a "pointer" to the previous line in the attributes
*except* the second line (@53) refers to @52 and not @58.  Hmmm...

 

I'll look into it some more.  Somebody is about to use a welder, so I
have to log off for a while.  This is Fiji :-)

 

Regards,

SJH

 

 

> -----Original Message-----

> 

> Hi. Can you turn on lint mode in ST?  It detects infinite cycles in

> your tree of STs.

> Ter

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070715/e165068f/attachment-0001.html 


More information about the antlr-interest mailing list