[stringtemplate-interest] stringtemplate-interest Digest, Vol 58, Issue 10

Stevenson, Todd (GE Healthcare, consultant) ToddStevenson at ge.com
Thu Jan 28 13:33:53 PST 2010


Is that limited to the case where the instance of StringTemplate
 attempts to set an attribute with itself as an argument?

              st.setAttribute("myAttr", st);

Or is it just using the same template definition? 

Can you give me some hints on how I would debug this?

Thanks.


-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of
stringtemplate-interest-request at antlr.org
Sent: Wednesday, January 27, 2010 1:00 PM
To: stringtemplate-interest at antlr.org
Subject: stringtemplate-interest Digest, Vol 58, Issue 10

Send stringtemplate-interest mailing list submissions to
	stringtemplate-interest at antlr.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://www.antlr.org/mailman/listinfo/stringtemplate-interest
or, via email, send a message with subject or body 'help' to
	stringtemplate-interest-request at antlr.org

You can reach the person managing the list at
	stringtemplate-interest-owner at antlr.org

When replying, please edit your Subject line so it is more specific than
"Re: Contents of stringtemplate-interest digest..."


Today's Topics:

   1. Re: cannot embed template anonymous in	itself (Terence Parr)


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

Message: 1
Date: Tue, 26 Jan 2010 12:22:05 -0800
From: Terence Parr <parrt at cs.usfca.edu>
Subject: Re: [stringtemplate-interest] cannot embed template anonymous
	in	itself
To: stringtemplate-interest List <stringtemplate-interest at antlr.org>
Message-ID: <34FD40D5-62EA-43A8-9F31-BEFFA528F219 at cs.usfca.edu>
Content-Type: text/plain; charset=us-ascii

hi. the error when you try to say set an st's enclosing instance to
itself. nested/recursive templates is a design requirement so it's
allowd but you can't create infinite enclosing cycles.  I can't be my
own parent.
Ter
On Jan 26, 2010, at 11:58 AM, Stevenson, Todd (GE Healthcare,
consultant) wrote:

> I don't understand the restrictions in StringTemplate that won't allow
me to build a template that is recursive in nature.  The code where this
is failing looks like this code.  It recursively builds a tree until
there are no child nodes left.  However StringTemplate throws an
exception not allowing this recursive method call. 
>  
> Any ideas?
>  
> public StringTemplate printTree() {
> 
>     StringTemplate st = new StringTemplate("$parent$\n 
> $child;separator=\"\n\"$\n");
> 
> 
>     st.setAttribute("parent", parent.toST());
> 
> 
> // print all your child nodes
> 
>     MyNode curr = this.child;
> 
>     while (curr!= null) {
> 
>         st.setAttribute("child", curr.printTree());
> 
>         curr = curr.sibling;
> 
>     }
> 
> 
>     return st;
> 
> }
> 



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

_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
http://www.antlr.org/mailman/listinfo/stringtemplate-interest


End of stringtemplate-interest Digest, Vol 58, Issue 10
*******************************************************


More information about the stringtemplate-interest mailing list