Thanks Jerry and Terence,<br><br>I can verified that both method worked nicely.<br><br>Jerry syntax lend itself nicely for a simple case. Though Terence answer was closer to what I am looking for since I was looking for a general case. Both will be used, thanks again.<br>
<br>Best,<br><br>Hoang<br><br><br><br><div class="gmail_quote">On Mon, Dec 14, 2009 at 2:24 PM, Terence Parr <span dir="ltr">&lt;<a href="mailto:parrt@cs.usfca.edu">parrt@cs.usfca.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi. you can use<br>
<br>
&lt;Entity.Properties, Entity.Name:{p, n | &lt;GenerateProperty(Property=p, Name=n)&gt;}&gt;<br>
<br>
Ter<br>
<div><div></div><div class="h5"><br>
On Dec 14, 2009, at 12:09 AM, Hoang Tang wrote:<br>
<br>
&gt; I have a template group that look like below:<br>
&gt;<br>
&gt; group main;<br>
&gt; main(Entity) ::= &lt;&lt;<br>
&gt; public class &lt;Entity.Name&gt;<br>
&gt; {<br>
&gt;     &lt;Entity.Properties:GenerateProperty()&gt;<br>
&gt; }<br>
&gt; &gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; GenerateProperty(Property) ::= &lt;&lt;<br>
&gt; &lt;Property.Attributes; separator=&quot;\n&quot;&gt;<br>
&gt; public &lt;Property.Type&gt; &lt;Property.Name&gt;<br>
&gt; {<br>
&gt;     get<br>
&gt;     {<br>
&gt;         return _entity.&lt;Property.Name&gt;;<br>
&gt;     }<br>
&gt;<br>
&gt; };<br>
&gt; &gt;&gt;<br>
&gt;<br>
&gt; This work fine, but what happen if I want to accept another variable for the GenerateProperty tempate for example we need to add an EntityName so we can use it to call a static method.<br>
&gt;<br>
&gt; GenerateProperty(Property, EntityName) ::= &lt;&lt;<br>
&gt; &lt;Property.Attributes; separator=&quot;\n&quot;&gt;<br>
&gt; public &lt;Property.Type&gt; &lt;Property.Name&gt;<br>
&gt; {<br>
&gt;     get<br>
&gt;     {<br>
&gt;         return &lt;EntityName&gt;.Validate(_entity.&lt;Property.Name&gt;);<br>
&gt;     }<br>
&gt;<br>
&gt; };<br>
&gt; &gt;&gt;<br>
&gt;<br>
&gt; How do I reference it then? &lt;Entity.Properties, Entity.Name:GenerateProperty()&gt; doesn&#39;t seem to work...<br>
&gt;<br>
&gt; Where entity is a simple class<br>
&gt;<br>
&gt; Entity<br>
&gt; {<br>
&gt;      public string Name;<br>
&gt;      public List&lt;Property&gt; Properties;<br>
&gt; }<br>
&gt; Property<br>
&gt; {<br>
&gt;      public string Name;<br>
&gt;      public string Type;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Lastly, I must say this is one of the most elegantly design template &quot;engine&quot; there is. The concept of automatic enumerable of multi-valued lend itself nicely to code generation... Of course it&#39;s much more than that. Let just say that I am impressed with the whole design.<br>

&gt;<br>
&gt; Best,<br>
&gt;<br>
&gt; Hoang<br>
&gt;<br>
</div></div><div><div></div><div class="h5">&gt; _______________________________________________<br>
&gt; stringtemplate-interest mailing list<br>
&gt; <a href="mailto:stringtemplate-interest@antlr.org">stringtemplate-interest@antlr.org</a><br>
&gt; <a href="http://www.antlr.org/mailman/listinfo/stringtemplate-interest" target="_blank">http://www.antlr.org/mailman/listinfo/stringtemplate-interest</a><br>
<br>
</div></div></blockquote></div><br>