[prev in list] [next in list] [prev in thread] [next in thread]
List: stringtemplate-interest
Subject: Re: [stringtemplate-interest] Question on math operations (plus,
From: Terence Parr <parrt () cs ! usfca ! edu>
Date: 2011-12-03 17:21:03
Message-ID: C0D7DB4B-7741-433C-91A0-98505F9A489D () cs ! usfca ! edu
[Download RAW message or body]
Hi. Sorry but ST only displays/formats--it cannot compute, just like printf can't do math. This is by design.
Ter
On Dec 2, 2011, at 4:46 PM, Jiwon Seo wrote:
> Hi,
>
> I need to do some simple subtraction inside a template, like
> following. (the reason for this is, it is much simpler to do this in a
> template than in Java and pass an argument to the template).
>
> <args:{a | argument_<i> and nesting_<length(params)-i>}>
>
> So, basically I want to be able to compute a number by subtracting an
> index from the length of another attributes ( <length(params) - i> )
>
> Is there any way I can do something like this?
>
> The length of the params (in the above example) is limited (like from
> 1 to 5), so if I can use a map which takes a tuple, I can do
> following:
>
> IndexMap ::= [
> (5, 1) : 4,
> (5, 2) : 3,
> (5, 3) : 2,
> ...
> (3, 1): 2,
> ...
> (2, 1): 1,
> default: "ERROR!!!"
> ]
>
> and use it like this:
>
> <args:{a | argument_<i> and nesting_<IndexMap.(params,i)>}>
>
> But it seems like it is not supported either.
>
> Thanks,
>
> -Jiwon
> _______________________________________________
> 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