[antlr-interest] [ST] How subtemplates work?
Cristian Peraferrer
corellian.c at gmail.com
Tue Mar 11 09:57:32 PDT 2008
Hi!
I have looked for subtemplates working examples or how subtemplates
work in the ST wiki but I haven't managed to find out.
My question is, with this StringTemplate GroupFile:
pnml(xmlns) ::= <<
<pnml xmlns="$xmlns$">
$net$
</pnml>
>>
net(id, type) ::= <<
<net id="$id$" type="$type$">
foobar
</net>
>>
How should I implement my .g file to make the pnml template make use
of net template?
For example:
grammar Test1;
options {output = template;}
s : INT '&' ID '&' net ';' -> pnml(xmlns={$INT.text}) ;
net : ID -> net(id={$ID.text},type={$ID.text}) ;
ID : 'a'..'z'+ ;
INT : '0'..'9'+ ('.' '0'..'9'+)+ ;
WS : (' '|'\t'|'\n'|'\r') {skip();} ;
Which is not correct...
Thanks in advance,
Cris.
--
GPG Key-ID: 0x564903FA - Jabber ID: corellian at swissjabber.ch
More information about the antlr-interest
mailing list