[stringtemplate-interest] List construction as argument
Dennis Waldherr
Dennis.Waldherr at uni-ulm.de
Sun Dec 2 12:05:06 PST 2007
Hi,
I have a problem with using a list generated by the "[...]" operator. I
tried to set an template argument directly with a generated list. Then I
tried to acccess the list twice in that template, which didn't work.
I'm using stringtemplate-3.0 and here's a group file which fails to
deliver the result I expected:
group simple;
f1() ::= << <f2(["a", "b"])> >>
f2(x) ::= << <x> <x> >>
I'm new to using stringtemplate so I might have made an error here, but
it doesn't print any warning/error messages so I hope that is "good enough".
Java version of this:
public void templateTest() {
String templates = "group simple;" +
"f1() ::= << <f2([\"a\", \"b\"])> >>" +
"f2(x) ::= << <x> <x> >>";
// Use the constructor that accepts a Reader
StringTemplateGroup group = new StringTemplateGroup(
new StringReader(templates));
StringTemplate t = group.getInstanceOf("f1");
System.out.println(t);
}
I expected to get "ab" twice in my output, but I only get it once.
Placing more <x> doesn't change anything so I guess the first one
somehow "consumes" the list (which would seem to be a strange side
effect, at least to me).
"Help meeee" :)
Greetings,
Dennis
More information about the stringtemplate-interest
mailing list