<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Terence, thanks for your reply.<br><br>After I read your comments, I tried many combination to make it work<br>and the only way was to explicitly assign parameters to the template like this:<br><br>group templates;<br><br>mainTemplate(listOfClasses) ::= &lt;&lt;<br>&lt;listOfClasses:classDeclaration(iter=it, parent="TopClass"); separator="\n"&gt;<br>&gt;&gt;<br><br>classDeclaration(iter, parent) ::= &lt;&lt;<br>class &lt;iter.name&gt; : public &lt;parent&gt;<br>{<br>&nbsp;&nbsp;&nbsp; &lt;iter.listOfSubClasses:classDeclaration(parent=iter.name, iter=it); separator="\n"&gt;<br>}<br>&gt;&gt;<br><br>Notice that the parameters are reversed in the second call to classDeclaration().<br>It  doesn't work if I don't reverse them!?<br><br>Anyway it works, but I don't know if it's normal.<br>Maybe I missed something.<br><br>Vincent<br><br><br><br>&gt; CC: stringtemplate-interest@antlr.org<br>&gt; From: parrt@cs.usfca.edu<br>&gt; To: vincedupuis@hotmail.com<br>&gt; Subject: Re: [stringtemplate-interest] Help with recursive template application<br>&gt; Date: Thu, 20 Aug 2009 11:53:22 -0700<br>&gt; <br>&gt; <br>&gt; On Aug 19, 2009, at 6:28 PM, Vincent Dupuis wrote:<br>&gt; <br>&gt; &gt; Hi,<br>&gt; &gt;<br>&gt; &gt; I'm trying to pass a "parent" value in a recursive template  <br>&gt; &gt; application<br>&gt; &gt; but without success. Here are my templates:<br>&gt; &gt;<br>&gt; &gt; group templates;<br>&gt; &gt;<br>&gt; &gt; mainTemplate(listOfClasses) ::= &lt;&lt;<br>&gt; &gt; &lt;listOfClasses:classDeclaration("TopClass"); separator="\n"&gt;<br>&gt; &gt; &gt;&gt;<br>&gt; <br>&gt; you are passing to parameters here: the iterated value and the string.  <br>&gt; If there is one parameter, the iteration operator sets that sole  <br>&gt; parameter to the iterated value.<br>&gt; T<br>&gt; <br>&gt; &gt;<br>&gt; &gt; classDeclaration(parent) ::= &lt;&lt;<br>&gt; &gt; class &lt;it.name&gt; : public &lt;parent&gt;<br>&gt; &gt; {<br>&gt; &gt;     &lt;it.listOfSubClasses:classDeclaration({&lt;it.name&gt;});  <br>&gt; &gt; separator="\n"&gt;<br>&gt; &gt; }<br>&gt; &gt; &gt;&gt;<br>&gt; &gt;<br>&gt; &gt; Considering A, B, and C classes are TopClass and that BB class is an  <br>&gt; &gt; inner class of B.<br>&gt; &gt;<br>&gt; &gt; and the output is...<br>&gt; &gt;<br>&gt; &gt; class A : public TopClass<br>&gt; &gt; {<br>&gt; &gt; }<br>&gt; &gt; class B : public TopClass<br>&gt; &gt; {<br>&gt; &gt;     class BB : public BB<br>&gt; &gt;     {<br>&gt; &gt;     }<br>&gt; &gt; }<br>&gt; &gt; class C : public TopClass<br>&gt; &gt; {<br>&gt; &gt; }<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Why I don't get the right value for class BB ?<br>&gt; &gt; Like:<br>&gt; &gt;<br>&gt; &gt;     class BB : public B<br>&gt; &gt;     {<br>&gt; &gt;     }<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Somebody knows why?<br>&gt; &gt;<br>&gt; &gt; Thanks,<br>&gt; &gt;<br>&gt; &gt; Vince<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Créez un personnage à votre image pour votre WL Messenger Venez voir  <br>&gt; &gt; _______________________________________________<br>&gt; &gt; stringtemplate-interest mailing list<br>&gt; &gt; stringtemplate-interest@antlr.org<br>&gt; &gt; http://www.antlr.org/mailman/listinfo/stringtemplate-interest<br>&gt; <br><br /><hr />Attention à tous les Humains. Nous sommes vos photos.  <a href='http://go.microsoft.com/?linkid=9666048' target='_new'>Libérez-nous de vos disques durs.</a></body>
</html>