[antlr-interest] String Template Questions

Terence Parr parrt at cs.usfca.edu
Fri Jun 6 13:24:49 PDT 2008


On Jun 6, 2008, at 1:20 PM, David Beckedorff wrote:

>
> Q1.
>
> I have a template hierarchy going, so
>
>        group   WebAppSiLayer : FeatureBase ;
>
>
> Now in my Java program, I have:
>
>     StringTemplateGroup featureBaseSTG =  
> StringTemplateGroup.loadGroup("FeatureBase");
>     featureBaseSTG.registerRenderer(Object.class, new  
> StFormatRenderer());
>
>>
>     StringTemplateGroup siLayerSTG =  
> StringTemplateGroup.loadGroup("WebAppSiLayer", featureBaseSTG);
>     siLayerSTG.registerRenderer(Object.class, new StFormatRenderer());
>
>
> So the question is whether the second registration of my  
> StFormatRenderer class (implements AttributeRenderer) is actually  
> necessary, since it has already been registered with the super- 
> template?

Well,You'll have to try it, but I believe I look upwards in the  
hierarchy if I do not see a renderer register.

>
> Q2.
>
> In ANTLR's Java.stg file, there are, I guess, template  
> interpolations like <@imports>, <@end>, <@members>, <@preamble>,  
> etc.  What's the purpose of the '@' characters? What's going on here?
>

That is a template region. Look at that keyword in a search of the doc.
Ter


More information about the antlr-interest mailing list