[stringtemplate-interest] [RE:] Re: i0 with alternating templates

Terence Parr parrt at cs.usfca.edu
Thu Aug 25 18:22:03 PDT 2011


Hi Guys,

Sure. I decided that i and i0 should not be dynamically scoped / visible to invoked templates.  sometimes very hard to figure out what i is and particularly when nested {...} are used.  So it never is dynamically visible.

t() ::= "<i>"

is a bit odd, right?   no parameter def.

t(n) ::= "<n>"

is better. then we can use i from {...}

<data:{<t(i)>}>

Ter
On Aug 24, 2011, at 7:47 AM, Daniel Brenner wrote:

> Interessting: I would have expected that i and i0 are available in each loop and not only in anonymous templates. What is the reason for this? (for me this makes no sence... so far)
>  
> Anyway: thanks a lot!
>  
> Cheers,
>  
> - Daniel
>  
>  
>  
>  Ursprüngliche Nachricht 
>  Absender:	 Udo Borkowski ub at abego-software.de
>  Gesendet am:	 23.08.2011 18:45:34
>  Betreff:	 [RE:] Re: [stringtemplate-interest] i0 with alternating templates
>  Empfänger:	 Daniel Brenner daniel.brenner at cas.de
>  CC:	  stringtemplate-interest at antlr.org
> Wrapping the template calls into anonymous templates will give you access to i and i0.
> 
> In your example it may look like this:
> 
> $results:{$resultlistOddRow(i, someVar)$}, {$resultlistEvenRow(i, someVar)$}$
> 
> With the templates resultlistOddRow  and resultlistEvenRow  defined like this:
> 
> resultlistOddRow(nr,p) ::= "$nr$. $p$ (odd)$\n$"
> resultlistEvenRow(nr,p) ::= "$nr$. $p$ (even)$\n$"
> 
> and 
> results: [A, B, C, D]
> someVar: x
> 
> ST4 will render:
> 
> 1. x (odd)
> 2. x (even)
> 3. x (odd)
> 4. x (even)
> 
> Udo
> 
> 
> 
> 
> On 23.08.2011, at 14:43, Daniel Brenner wrote:
> 
>> Hi,
>> 
>> I have a table with results that was build using alternating templates. The following lines is used for this:
>> 
>> $results:resultlistOddRow(somevar), resultlistEvenRow(somevar)$
>> 
>> How can I number the rows? In the templates resultlistOddRow and resultlistEvenRow I tried to access $i$ and $i0$ but stringtemplate keeps telling me "implicitly-defined attribute i not visible" and "implicitly-defined attribute i0 not visible".
>> 
>> Any ideas?
>> 
>> Cheers,
>> 
>> - Daniel
>> 
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110825/5f61a811/attachment.html 


More information about the stringtemplate-interest mailing list