[stringtemplate-interest] Variables in Template Parameters

Terence Parr parrt at cs.usfca.edu
Mon Nov 9 13:31:08 PST 2009


Try $object.(attributeHoldingPropertyName)$

Ter
On Nov 9, 2009, at 1:14 PM, Brain, Jim wrote:

> Is there a way to allow $getter$, which is passed “get$name$()” to  
> expand $name$ to “Name”?
>
> import org.antlr.stringtemplate.*;
> public class STTest {
>       public static void main(String[] args) {
>             StringTemplateGroup stg = new StringTemplateGroup 
> ("Source");
>             stg.defineTemplate("reader","$type$.$getter$");
>             StringTemplateGroup stg2 = new StringTemplateGroup 
> ("Class");
>             stg2.setSuperGroup(stg);
>             StringTemplate st = stg2.defineTemplate("prop","$reader 
> (getter=\"get$name$()\")$");
>             st.setAttribute("name","Name");
>             st.setAttribute("type","TYPE");
>             System.out.println(st.toString());
>       }
> }
>
> When I run this, I get:
>
> TYPE.get$name$()
>
> Which means the attributes are flowing through correctly, but the  
> substitution in the parameter is not occurring.
>
> -- 
> Jim Brain, AFP Architecture, 319-355-2070
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list