[stringtemplate-interest] Defer definition of a parameter in a StringTemplate function
Jose Juan Tapia
jjtapia at gmail.com
Fri Jun 3 11:45:08 PDT 2011
So suppose I want to produce the following output with a Stringtemplate
<TopLevel id="T1">
<LowLevel id="T1_L1"/>
</TopLevel>
<TopLevel id="T2">
<LowLevel id="T2_L1"/>
<LowLevel id="T2_L2"/>
</TopLevel>
Right now my Stringtemplate grammar looks something like this
Root(id,topCollection)::<<
<topCollection; separator="\n">
>>
Top(id,lowCollection)::<<
\<TopLevel id="T<id>"\>
<lowCollection; separator="\n">
\</TopLevel\>
>>
Low(id)::=<<
\<LowerLevel id="<id>"\/>
>>
With things being defined separately through an ANTLR grammar in a
bottom up fashion. (So when all the LowLevel tags
of a given TopLevel section are created, they are passed to the upper
level of the grammar as an array of stringTemplates).
My problem right now with this definition is doesn't manage the id's
correctly at all. I was wondering if there was a way to defer the
definition of the Low function id parameter and define it latter on
StringTemplate itself , something like
<topCollection(id="T<i>"); separator="\n">
<lowCollection(id="<id>_L<i>"; separator="\n">
An alternative solution to this would be to manage all the indexing
from ANTLR instead of using the <i> tag (which is what
I'm doing right now), but I think using ANTLR for keeping the indexing
would be messier (since there are several nested levels of indexing in
my true grammar) so I was wondering if there was a way to do this with
StringTemplate.
--
José Juan Tapia Valenzuela
Research Associate
University of Pittsburgh
3076.1 Biological Sciences Tower 3
Pittsburgh, Pa 15260
More information about the stringtemplate-interest
mailing list