[stringtemplate-interest] List construction as argument
Terence Parr
parrt at cs.usfca.edu
Sun Dec 9 14:47:14 PST 2007
On Dec 3, 2007, at 6:39 AM, John Snyders wrote:
> This really sounds like the problem I described here:
> http://www.antlr.org:8080/pipermail/stringtemplate-interest/2007-November/001265.html
>
> I remember the problem is the same no matter if the list is literal
> or passed in as an attribute. Once you pass a list
> to a template it gets turned into an iterator and you can only use
> it once. I think that it is critical to fix before
> 3.1 is released.
Seems passing a list and ref'ing 2x is fine:
public void testMultipleRefsToListAttribute() throws Exception {
String templates =
"group test;" +newline+
"f(x) ::= \"<x> <x>\""+newline
;
StringTemplateGroup group =
new StringTemplateGroup(new StringReader(templates));
StringTemplate e = group.getInstanceOf("f");
e.setAttribute("x", "Ter");
e.setAttribute("x", "Tom");
String expecting = "TerTom TerTom";
assertEquals(expecting, e.toString());
}
passes.
It must only be the internal list?
Ter
More information about the stringtemplate-interest
mailing list