[antlr-interest] How to use arg* when rewriting with StringTemplate
Robert.Klaus at innovations.de
Robert.Klaus at innovations.de
Wed Oct 24 08:13:12 PDT 2007
Hi,
I would like to rewrite a language using a TreeGrammar. For this purpose
I have defined a matching rule and rewrite with a template like this:
^(ID args+=arg*) -> template(id={$ID.text}, arg={$args}) "<id> ( <arg;
separator=\", \"> )"
So what happens is that the rule "arg"'s return template is added to an
ArrayList which then is passed to the template. However "arg" does not
return a template as it does not need to rewrite something.
arg:
INTEGER
| FLOAT
| BOOLEAN
;
So what I need is the original text from each arg. When the arguments
are known, I can do it easily like this:
^(PLUS a=arg b=arg) -> template(a={$a.text}, a={$b.text}) "add (<a>,
<b>)"
How can I use this when I match arg*?
Thanks in advance,
Robert
-------------------------------------------------------------
Robert Klaus
Diplom Informatiker
Product Development
-------------------------------------------------------------
Innovations Softwaretechnologie GmbH
Ziegelei 7
88090 Immenstaad
Germany
Phone: +49(0)7545-202-339
robert.klaus at innovations.de
www.visual-rules.com
-------------------------------------------------------------
Executives:
Achim Berger, Thomas Cotic, Walter Pitz
Register Court Ulm HRB 631622
-------------------------------------------------------------
More information about the antlr-interest
mailing list