<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) ::= <<<br><listOfClasses:classDeclaration(iter=it, parent="TopClass"); separator="\n"><br>>><br><br>classDeclaration(iter, parent) ::= <<<br>class <iter.name> : public <parent><br>{<br> <iter.listOfSubClasses:classDeclaration(parent=iter.name, iter=it); separator="\n"><br>}<br>>><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>> CC: stringtemplate-interest@antlr.org<br>> From: parrt@cs.usfca.edu<br>> To: vincedupuis@hotmail.com<br>> Subject: Re: [stringtemplate-interest] Help with recursive template application<br>> Date: Thu, 20 Aug 2009 11:53:22 -0700<br>> <br>> <br>> On Aug 19, 2009, at 6:28 PM, Vincent Dupuis wrote:<br>> <br>> > Hi,<br>> ><br>> > I'm trying to pass a "parent" value in a recursive template <br>> > application<br>> > but without success. Here are my templates:<br>> ><br>> > group templates;<br>> ><br>> > mainTemplate(listOfClasses) ::= <<<br>> > <listOfClasses:classDeclaration("TopClass"); separator="\n"><br>> > >><br>> <br>> you are passing to parameters here: the iterated value and the string. <br>> If there is one parameter, the iteration operator sets that sole <br>> parameter to the iterated value.<br>> T<br>> <br>> ><br>> > classDeclaration(parent) ::= <<<br>> > class <it.name> : public <parent><br>> > {<br>> > <it.listOfSubClasses:classDeclaration({<it.name>}); <br>> > separator="\n"><br>> > }<br>> > >><br>> ><br>> > Considering A, B, and C classes are TopClass and that BB class is an <br>> > inner class of B.<br>> ><br>> > and the output is...<br>> ><br>> > class A : public TopClass<br>> > {<br>> > }<br>> > class B : public TopClass<br>> > {<br>> > class BB : public BB<br>> > {<br>> > }<br>> > }<br>> > class C : public TopClass<br>> > {<br>> > }<br>> ><br>> ><br>> > Why I don't get the right value for class BB ?<br>> > Like:<br>> ><br>> > class BB : public B<br>> > {<br>> > }<br>> ><br>> ><br>> > Somebody knows why?<br>> ><br>> > Thanks,<br>> ><br>> > Vince<br>> ><br>> ><br>> > Créez un personnage à votre image pour votre WL Messenger Venez voir <br>> > _______________________________________________<br>> > stringtemplate-interest mailing list<br>> > stringtemplate-interest@antlr.org<br>> > http://www.antlr.org/mailman/listinfo/stringtemplate-interest<br>> <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>