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

List:       stringtemplate-interest
Subject:    [stringtemplate-interest] final changes for 2.2
From:       parrt () cs ! usfca ! edu (Terence Parr)
Date:       2005-07-09 18:21:29
Message-ID: 496EA430-DC0D-4557-A18C-0FE8A3992852 () cs ! usfca ! edu
[Download RAW message or body]

Hi,

I believe I have finished StringTemplate 2.2; perhaps next week I can  
get to the documentation update before I leave for Asia on the 19th.   
I've added about 50 new unit tests. :)  I try to add a test for each  
bug I encounter and for new features of course.  Some highly groovy  
stuff added today.  The main thing I needed for ANTLR code gen was  
the ability to ask for the first element of group of multi-valued  
attributes:

<first(tokenRefs+ruleRefs+labelRefs):doSomethingSpecial()>

to treat it differently and then to walk the others normally:

<rest(tokenRefs+ruleRefs+labelRefs):doNormalThing()>

That is pretty sweet!

Regards,
Ter
-------------
CHANGES FOR TODAY:

07-09-2005

o added multiple attributes to left of the apply operator; works for
anonymous templates only, though. $names,phones:{n,p | $n$: $p$}$.   
An error
is generated if you have too many args for the number of parallel
lists.  Iteration proceeds while at least one of the attributes
({names} or {phones}, in this case) has values.

o added '+' cat operator for multi-valued attributes, yielding single,
longer multi-valued attribute.  $mine+yours$ is a new list with both
elements; all of "mine" first then all of yours.

o allows any template invocation to assume sole argument name if
just one formal argument.  If you do {$bold(name)$} and {bold} has one
formal argument, then it gets the value of name.  This works also for
template application:

<<
test(names) ::= << <names:bold(),italics(); separator=", "> >>
bold(x) ::= "*<x>*"
italics(y) ::= "_<y>_"
 >>

Note: The binding of a value to the name of a sole formal argument is
done dynamically so that indirect template invocation and lazy
evaluation stuff works properly.  For example {(templateName)(value)}
should work for different templates with differently-name (but sole)
args.  See unit test testInvokeIndirectTemplateWithSingleFormalArgs().

o I changed the first, rest, tail operators from yesterday.  It was
weird doing {users:first()}...seems like {first(users)} is better.
This introduces a function-like syntax, which necessitated the "assign
to sole formal arg" functionality above that supports things like
{bold(name)}.  Makes it possible to say {first(rest(names))} to get
second element now.  Previous syntax made it impossible.

--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com

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

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