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