[stringtemplate-interest] set attributes in two templates from one rule

Terence Parr parrt at cs.usfca.edu
Thu Jan 10 17:54:28 PST 2008


On Jan 9, 2008, at 8:05 PM, Sanjay Agravat wrote:

> Thanks for the reply.  I ended up creating an ArrayList to keep  
> track of the instance vars and that solved the problem.
>
> As a hypothetical question - is it possible to have two  
> StringTemplates to output from your tree grammar ( i.e. one template  
> like JavaBean.stg and the other one called Main.stg)?


Sure.  ANTLR generates header files, parsers, and lexers all from the  
same grammar file.  Of course, ANTLR's rewrite rules are just setting  
rule return values so it is up to you to collect those templates and  
put them in whatever files you want templates.  Each rewrite rule only  
computes one template, if that's what you mean.

Ter



More information about the stringtemplate-interest mailing list