[stringtemplate-interest] How best to do recursive hetero template calls?

Terence Parr parrt at cs.usfca.edu
Sat Feb 20 11:43:58 PST 2010


To me,  it's not the job of ST to manage a list of your output templates. There to many kinds of data structures you might want and I'm not sure introducing new syntax is the right approach. In my tools, I use the same template to generate multiple output files with no problem. For example, my root grammar returns a list of template:

options { output=template; }
file returns [List templates]
	:	d+=decl+ {templates=$d;}
	;

decl : stuff -> decltemplate(...) ;

> And here is the tie in to the tree walk.  My case is a root container 
> that can contain any mix of containers and controls, repeating.  The 
> tree walk works perfectly but results in one massive string.  Everything 
> would have to be realized using inner classes.  In practice, each 
> container needs to be generated to a separate string that could then be 
> saved as a separate class file.

personally, I would simply remove the top level of the template if it's just saying "make a list". If there's no text, why would you use a template. If there is text, how could you get away with a list? how do you break up the template? by lines?

Ter


More information about the stringtemplate-interest mailing list