[antlr-interest] StringTemplate

John851 JOHN851 at yandex.ru
Fri Sep 25 04:32:10 PDT 2009


Hello,

I try to use StringTemplate to write a simple codegen.

Can I use nested ST templates in my .stg file?
Smth. like this:
//---------------------------------------
group ANTLRLangCodGen;

dictdef()::="dict([<element; separator=",">])"

element()::="<cell; separator=",">"

cell(axis,value)::="(<axis; separator=",">),<value>"
//---------------------------------------

Where "element" and "cell" are nested templates.

And other question:
How to load a .stg file and use templates in my tree grammar in ANTLRworks ?
And how to pass plain string argument's value to template? Is it possible only via labels like in the following example?

rule1: $var1=WORLD -> SayHello(word={$var1.text});

Thank you


More information about the antlr-interest mailing list