[stringtemplate-interest] nesting templates and getting theloop count of the outer loop

Roel Vanhout rvanhout at riks.nl
Wed Oct 29 02:19:38 PDT 2008


Here's how I see it; the engine 'executes' outer() for the first time.
<i0>, in outer, is 0. Then, for every element, inner() is called with
the argument argument '0'. In my example, inner() would be called 2
times. So group_nr in inside inner could only be 0 for the first element
and then 1 for the second element if it is set to the value of <i0>
_inside inner_, i.e. if it is evaluated as 'the value of <i0> inside
inner'.

I may be looking at this in a too code-like way, I don't know - but is
there a way to do what I want?


cheers,

roel
 

-----Original Message-----
From: Terence Parr [mailto:parrt at cs.usfca.edu] 
Sent: Tuesday, October 28, 2008 19:35
To: Roel Vanhout
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] nesting templates and getting
theloop count of the outer loop


On Oct 28, 2008, at 7:01 AM, Roel Vanhout wrote:

> To illustrate, I have made a minimal example program. The program and 
> template file below produce the output:
>
> Group 0
>  Page 0.0
>  Page 1.1
> Group 1
>  Page 0.0
>  Page 1.1
>  Page 2.2

correct.

> Whereas I would have expected it to be:
>
> Group 0
>  Page 0.0
>  Page 0.1
> Group 1
>  Page 1.0
>  Page 1.1
>  Page 1.2

if you pass group_nr = i0 to inner,  how could they have different
values?

Ter






More information about the stringtemplate-interest mailing list