[stringtemplate-interest] Bug/Problem passing parameters into iteration

Terence Parr parrt at cs.usfca.edu
Fri Nov 5 20:14:25 PDT 2010


On Nov 5, 2010, at 6:39 PM, Mike Goodwin wrote:

> Hi Terence,
> 
>> element(el,x)::=<<
>> $x$$el.name$<br>
>> $x$$el.children:element(el=it,x=x+" ")$
>>>> 
>> tree(root)::=<<
>> <html>
>>       <body>
>>               <code>
>> $root:element(el=it, x="")$
>>               </code>
>>       </body>
>> </html>
> 
> I find the scoping implications/rules a bit confusing. Looking at
> this, twice we have el=it. The 'it' presumably comes from the scope in
> that of the template we are calling. How could we then refer to the
> outer 'it' in the setting expression? What about the x  ... etc.?

actually it refers to the iteration from root:element(...) in that context. imagine

$root:{ r | $element(el=r, x="")$}$

> The extra template was being used, but had been simplified whilst
> trying to get things working.

ah. got it.
Ter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20101105/2ff5135f/attachment.html 


More information about the stringtemplate-interest mailing list