[stringtemplate-interest] Creating new attributes?

Morten Olav Hansen mortenoh at gmail.com
Wed Nov 17 20:13:58 PST 2010


Ah, ok.. that makes sense. So is it possible to assign this attribute
to something else before entering the iteration-loop? or do you have
an idea of a workaround?

Regards,
Morten

On Thu, Nov 18, 2010 at 3:37 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
> Oh. don't forget that i0 in <it.states: state_n(i0); separator="\n"> is redefining i0 since it's a template application.  i0 in that context is 0 then 1 etc... even when i0 comes in as 2342 from <regions: region_n(); separator="\n\n">
> Ter
> On Nov 17, 2010, at 5:11 PM, Morten Olav Hansen wrote:
>
>> Yes, thats what I'm already doing.
>>
>> statemachine(regions) ::= <<
>> <regions: region_n(); separator="\n\n">
>>>>
>>
>> region_n() ::= <<
>> Region region<i0>;
>> <it.states: state_n(i0); separator="\n">
>>>>
>>
>> state_n(rid) ::= <<
>> State state_<it.id>_<rid>;
>>>>
>>
>> region(id, states, transitions) ::= << >>
>> state(id) ::= << >>
>> transition(from, to) ::= << >>
>>
>> For the first region i0 is 0, and the state_n also receives 0 (rid =
>> 0). If there is another region, i0 is 1, and state_n should now get
>> rid = 1, but it still evaluates to 0.
>>
>> So it seems to be taking the value of i0 inside state_n (which is of
>> course 0 if there there is only one state). Thats why I was hoping to
>> somehow force evaluation of i0 in region_n.
>>
>> Regards,
>> Morten
>>
>> On Thu, Nov 18, 2010 at 1:52 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
>>> Hi. Try passing i/i0/it as a parameter with different name to new template to rename them.
>>> Ter
>>> On Nov 17, 2010, at 4:10 PM, Morten Olav Hansen wrote:
>>>
>>>> Hi
>>>>
>>>> I'm having a problem with my iterators (related to my problem in the
>>>> mail before). It seems that I can't use it/i/i0 as a parameter when I
>>>> have two levels of iterators, and I want to use information from the
>>>> outer iteration in the inner iteration (it and i0 in my case). They
>>>> seem to be evaluated by name, rather than value, and the value of
>>>> it/i/i0 has of course changed in the inner iterator.
>>>>
>>>> Is it possible in StringTemplate to assign these attributes to a new
>>>> attribute? So I send send this one instead.
>>>>
>>>> Regards,
>>>> Morten
>>>> _______________________________________________
>>>> stringtemplate-interest mailing list
>>>> stringtemplate-interest at antlr.org
>>>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>>>
>>>
>
>


More information about the stringtemplate-interest mailing list