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

List:       stringtemplate-interest
Subject:    Re: [stringtemplate-interest] Re : Question on using index
From:       Jiwon Seo <jiwon () stanford ! edu>
Date:       2011-11-28 19:34:21
Message-ID: CAGWbJj_oK6Lpwxcq4XY1P+-X66owf_eg1OGh21iVSVA87EFjrQ () mail ! gmail ! com
[Download RAW message or body]

I ended up doing this:

<sorted:{s|<if(s)><insert("pos",
concat("prefix",i0),concat("prefix",i0))><endif>}; separator=";\n">

where concat concatenates the two input strings.

Is this the right way (and clean way) to do what I want?

Thanks.

On Mon, Nov 28, 2011 at 11:24 AM, Jiwon Seo <jiwon@stanford.edu> wrote:
> When I try to do that, it says "mismatched input '{' expecting ELLIPSIS"
>
> <sorted:{s|<if(s)><insertSorted(pos="pos",
> {"pref"<i0>},{"pref"<i0>})><endif>}; separator=";\n">
>
> I tried with and without <> and also with and without "" ("pref" vs pref)
>
> Should that work?
>
> On Mon, Nov 28, 2011 at 11:13 AM, Matthieu Wipliez <mwipliez@yahoo.fr> wrote:
>> Hi Jiwon,
>> you can use an anonymous template to do that:
>> <insert("pos", {prefix<i0>})>
>> (the + operator is not available in ST 4 IIRC)
>> Cheers
>> Matthieu
>>
>> ________________________________
>> De : Jiwon Seo <jiwon@stanford.edu>
>> À : Terence Parr <parrt@cs.usfca.edu>
>> Cc : stringtemplate-interest@antlr.org
>> Envoyé le : Lundi 28 Novembre 2011 20h03
>> Objet : Re: [stringtemplate-interest] Question on using index variable(<i>
>> and <i0>) in invoked template
>>
>> Thanks.
>>
>> Actually I have one more question.
>> What I really want to do is to concatenate <i0> with a constant string
>> and pass it as an argument
>> as following:
>>
>> <sorted:{s|<if(s)><insert("pos", "prefix"+<i0>)><endif>}; separator=";\n">
>>
>> but it seems like it doesn't work with or without <>
>>
>> -Jiwon
>>
>>
>> On Mon, Nov 28, 2011 at 9:02 AM, Terence Parr <parrt@cs.usfca.edu> wrote:
>>> hi. once inside <…> just use i0.  <insert("pos", i0)> :)
>>> Ter
>>> On Nov 28, 2011, at 2:08 AM, Jiwon Seo wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm trying to invoke a template inside an anonymous template as
>>>> following:
>>>>
>>>> <sorted:{s|<if(s)><insert("pos", <i0>)><endif>}; separator=";\n">
>>>>
>>>> So, for each value (s) in the attribute sorted, I want to add a string
>>>> generated by the template insert only when s has the value true.
>>>> When invoking the insert template, I need to pass the iteration count
>>>> (index of s in the sorted).
>>>>
>>>> The above template code produces an error message that <i0> is
>>>> unexpected (more accurately, the "<" is unexpected).
>>>>
>>>> How can I pass the iteration count to the invoked template?
>>>>
>>>> Thanks!
>>>> _______________________________________________
>>>> stringtemplate-interest mailing list
>>>> stringtemplate-interest@antlr.org
>>>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>>>
>>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest@antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>>
>>
>>
>
_______________________________________________
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