[stringtemplate-interest] List construction as argument

Terence Parr parrt at cs.usfca.edu
Sun Dec 2 12:08:07 PST 2007


Hi Dennis, I think maybe we fixed this in 3.1.  Can you try one of  
the daily builds before I investigate? This typically only happens  
with iterators. Maybe I am using an iterator for that list construction.

http://www.stringtemplate.org/download/build/ 
stringtemplate-11-09-2007.17.tar.gz

Ter
On Dec 2, 2007, at 12:05 PM, Dennis Waldherr wrote:

> 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
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list