[prev in list] [next in list] [prev in thread] [next in thread] 

List:       stringtemplate-interest
Subject:    Re: [stringtemplate-interest] Bug/Problem passing parameters into
From:       Terence Parr <parrt () cs ! usfca ! edu>
Date:       2010-11-06 3:14:25
Message-ID: 26BA92F4-6149-4EC2-8292-1566EDA0C694 () cs ! usfca ! edu
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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
[Attachment #5 (unknown)]

<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; "><br><div><div>On Nov 5, 2010, at 6:39 PM, \
Mike Goodwin wrote:</div><br class="Apple-interchange-newline"><blockquote \
type="cite"><div>Hi Terence,<br><br><blockquote \
type="cite">element(el,x)::=&lt;&lt;<br></blockquote><blockquote \
type="cite">$x$$el.name$&lt;br&gt;<br></blockquote><blockquote \
type="cite">$x$$el.children:element(el=it,x=x+" ")$<br></blockquote><blockquote \
type="cite"><blockquote type="cite"><blockquote \
type="cite"><br></blockquote></blockquote></blockquote><blockquote \
type="cite">tree(root)::=&lt;&lt;<br></blockquote><blockquote \
type="cite">&lt;html&gt;<br></blockquote><blockquote type="cite"> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;body&gt;<br></blockquote><blockquote \
type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;code&gt;<br></blockquote><blockquote \
type="cite">$root:element(el=it, x="")$<br></blockquote><blockquote type="cite"> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/code&gt;<br></blockquote><blockquote \
type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/body&gt;<br></blockquote><blockquote \
type="cite">&lt;/html&gt;<br></blockquote><br>I find the scoping implications/rules a \
bit confusing. Looking at<br>this, twice we have el=it. The 'it' presumably comes \
from the scope in<br>that of the template we are calling. How could we then refer to \
the<br>outer 'it' in the setting expression? What about the x &nbsp;... \
etc.?<br></div></blockquote><div><br></div>actually it refers to the iteration from \
root:element(...) in that context. imagine</div><div><br></div><div>$root:{ r | \
$element(el=r, x="")$}$</div><div><br><blockquote type="cite"><div>The extra template \
was being used, but had been simplified whilst<br>trying to get things working.<font \
class="Apple-style-span" color="#000000"><font class="Apple-style-span" \
color="#144FAE"><br></font></font></div></blockquote><br></div><div>ah. got \
it.</div><div>Ter</div></body></html>



_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest@antlr.org
http://www.antlr.org/mailman/listinfo/stringtemplate-interest


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic