[stringtemplate-interest] it, i, i0 for ST v4

Terence Parr parrt at cs.usfca.edu
Wed Dec 22 16:48:05 PST 2010


Surely.  The idea is that v4 always has a parameter list but can still inherit stuff that is not a parameter of that template.  When we apply a template, v3 let you avoid parameter like this:

$names:bold()$

where

bold(x) ::= "<b>$x$</b>"

Now, v4 will let you have more than one AND pass args in map operation:

$names:bold("hi")$

bold(x,y) ::= "<b>$y$: $x$</b>"

v4 sets first arg(s) to map iteration values.

$names,phones:bold()$

would work, setting x,y automatically

Ter

On Dec 22, 2010, at 4:44 PM, Barrie Treloar wrote:

> On Wed, Dec 22, 2010 at 3:27 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
>> 
>> On Dec 21, 2010, at 8:22 PM, Sam Harwell wrote:
>>> This whole issue is an edge case of a larger "problem" I'm facing - I wish
>>> that templates with one unassigned argument could be used any place a
>>> template with a single arg can be used. From your bold(x) example, what I
>>> mean is this:
>>> 
>>> format(tag,x) ::= "<$tag$>$x$</$tag$>"
>>> 
>>> <names:format(tag="b")>
>>> 
>>> The anonymous template version this is exactly what you suggested, with
>>> exactly 1 named but unassigned parameter and 0 or more named assignments.
>> 
>> That is exactly how v4 works :)  First arg(s) get values. 'cept no names:
> 
> Can you expand on that, or link to documentation, please?
>> From the little lurker understanding I have this feels black magicish
> and something I'm bound to forget and bump into.
> 
> Cheers
> _______________________________________________
> 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