[stringtemplate-interest] Accessing outer iterator in nested templates

Sriram msg.sriram at gmail.com
Wed Feb 13 16:38:23 PST 2008


OK. This is what I tried to do. Please let me know what I am doing wrong.

templateMain(semanticIndices) ::= <<
<semanticIndices:templateM1(outer=i); separator="\n">
>>

templateM1(semanticIndices, outer) ::= <<
<outer><semanticIndices>
>>

Attribute <outer> holds the correct iteration value. However, the
attribute <semanticIndices> is not set.

-Sriram

On Feb 13, 2008 6:53 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> Hi.I think that the most recent i0 will hide the version above... try
> using a parameter set to i.
>
> templateMain(semanticIndices) ::= <<
> <semanticIndices:templateM1(outer=i); separator="\n">
>  >>
> then ref <outer> below.
> Ter
>
>
>
> On Feb 13, 2008, at 11:40 AM, Sriram wrote:
>
> > I am trying to use the iterator attribute <i> in the following
> > example:
> >
> > templateMain(semanticIndices) ::=<<
> > <semanticIndices:templateM1(); separator="\n">
> >>>
> >
> > templateM1(semanticIndices) ::= <<
> > <semanticIndices:templateM2(); separator="\n">
> >>>
> >
> > templateM2(semanticIndices) ::= <<
> > newArgs[<semanticIndices>] = args<###>[<i0>];
> >>>
> >
> > templateMain is invoked with an (ArrayList of Int Arrays) as its
> > parameter.
> >
> > Main{
> >  ...
> >  M1{
> >     ...
> >     M2{
> >         ...
> >     }
> >  }
> > }
> >
> > It tries to perform the function of a nested loop. At the placeholder
> > <###>, I need to access the iterator of templateM1. Please let me know
> > if someone has come across such a problem.
> >
> > - Sriram
> > _______________________________________________
> > stringtemplate-interest mailing list
> > stringtemplate-interest at antlr.org
> > http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
>


More information about the stringtemplate-interest mailing list