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

Hardy, Stephen Stephen_Hardy at rabbit.com
Sat Jul 14 14:15:54 PDT 2007


There seems to be a bug in StringTemplate.java and/or Antlr, where the
following member function recurses infinitely because (somehow)
enclosingInstance == this.

 

            public AttributeRenderer getAttributeRenderer(Class
attributeClassType) {

                        ...

 

                        // we have no renderer overrides for the
template or none for class arg

                        // check parent template if we are embedded

                        if ( enclosingInstance!=null ) {

                                    return
enclosingInstance.getAttributeRenderer(attributeClassType);

                        }

            ...

            }

 

The piece of Antlr code which exposes this bug (taken from my own tree
parser based on Terence's C grammar) is 

 

 

parameter_declaration

    : ^(PARMDEC ^(DECLSPEC declaration_specifiers)
(dad+=decl_or_abstract_decl)*)

    -> template(ds={$declaration_specifiers.st}, d={$dad})

<< 

    <ds> <d; separator=" ">

>> 

    ;

 

 

Removing the <d; ...> from the template hides the problem.  Of course
the real cause of this problem may be something else, so I would be
happy to share the entire source code if necessary.  Antlrworks shows
that the AST is being built as expected, and the AST parses successfully
by the tree grammar, but adding the template output shows up this error.
Stack overflows are problematic to debug, since the stack trace seems to
lose the "interesting" part which first calls the recursive routine
(sigh).

 

Regards,

SJH

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070714/7d181ea3/attachment.html 


More information about the antlr-interest mailing list