[stringtemplate-interest] Wishlist: $[list1], [list2]$ and null attributes

Roman Odaisky roma at qwertty.com
Sat Sep 6 02:39:03 PDT 2008


Greetings,

I propose a small change to list handling. Namely, null elements should not be 
eliminated from the list until either strip() is requested or a template is 
about to be applied. That would allow code like this:

$ ["x", "y", "z"], [x, y, z] : { k, v | $k$=$v$}; separator={; } $

Currently, if this is called with x={X}, y=null, z={Z}, the result will 
be “x=X; y=Z” instead of the expected “x=X; z=Z”, because null elements are 
stripped too early.

Side note: the current syntax doesn’t seem to allow applying additional 
templates to only one of the lists. A workaround would be

$list1, list2: { k, v | $template(k={...$k$...}, v={...$v$...})$}$

though it requires an additional named template. Obvious attempts like

$list1, list2: { k, v | ${...}(k={...$k$...}, v={...$v$...})$}$

and

$list1, list2: { k, v | ${...$k$...}, {...$v$...}:{ k, v | ...}$}$

failed with weird errors.

-- 
WBR
Roman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2286 bytes
Desc: not available
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080906/5ab2714d/attachment.bin 


More information about the stringtemplate-interest mailing list