[stringtemplate-interest] howto set separator in parallel list iteration
Jens Boeykens
jens.boeykens at gmail.com
Mon Jul 7 01:28:12 PDT 2008
Looks like the parallel iteration doesn't work correctly either. I miscopied
my input...
input: INT -> test(a={$int}) | CHAR -> test(b={$CHAR})
output: INT -> test (a = {$int}) CHAR -> test (a = {$int})
So it is correct for the first list [INT, CHAR], but it doesn't iterate over
the second list [-> test(a={$int}), -> test(b={$CHAR})]
The "-> test(b={$CHAR})" doesn't appear in the output. Instead the first
element is displayed twice
What I want to generate is (same as input):
Expected output: INT -> test(a={$int}) | CHAR -> test(b={$CHAR})
Greetings
2008/7/7 Jens Boeykens <jens.boeykens at gmail.com>:
> Hello!
>
> I have a problem with iterating parallel lists. I use antlr together with
> stringtemplate to generate templates. My antlr code looks like this:
>
> altList
> : ^( (a+=alternative r+=rewrite)+ )
> ->altList(alternative={$a}, rewrite = {$r})
> ;
>
>
> my stringtemplate:
>
> altList(alternative, rewrite) ::= <<
> <alternative,rewrite: {alt,rw | <alt> <rw>}>
> >>
>
>
>
> This gives
> input : INT -> test (a = {$int}) | CHAR -> test (a = {$int})
> output: INT -> test (a = {$int}) CHAR -> test (a = {$int})
>
> So parallel iterating works, but the separator '|' is missing in the output
> (before CHAR).
>
> What should I change in my template so I can add a separator.
> Something like <alternative,rewrite: {alt,rw | <alt> <rw> | }> or
> <alternative,rewrite: {alt,rw | <alt> <rw>; separator=" | "}>
> doesn't work...
>
> Thanks!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080707/e4277043/attachment.html
More information about the stringtemplate-interest
mailing list