[stringtemplate-interest] cannot embed template anonymous in itself
Stevenson, Todd (GE Healthcare, consultant)
ToddStevenson at ge.com
Tue Jan 26 11:58:18 PST 2010
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;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20100126/acb5ad88/attachment.html
More information about the stringtemplate-interest
mailing list