[antlr-interest] Question regarding stringtemplate usage design

Gustaf Johansson gustaf.j at gmail.com
Fri Feb 5 02:31:31 PST 2010


Hi,

I have a antlr parser that is using stringtemplates to "translate" the input.
Im having problems when i want to reorder the output from the input,
when this spans multiple rules down.

Simplified example: (this is what i have, but its obviously not working)

prog: a b=ID -> progTempl(a={$a.st}, b={$b.text});
a: x=ID y=ID -> aTempl(x={$x.text}, y={$y.text});


I would like the output to be:

"a.y b a.x"

So the question is basically, how do i return multiple string from a
stringtemplate?
Since im using $a.st in the prog rule i get the entire text, but i
would want it in 2 chunks. So i can insert b "between" the 2 chunks.

Best Regards Gustaf


More information about the antlr-interest mailing list