[stringtemplate-interest] Passing values into templates
Ben Hood
0x6e6562 at gmail.com
Sat Apr 19 08:49:22 PDT 2008
Hi,
Although my current work is the 2nd project I've used ST to do
multiple language code generation, I'm still fairly new to it and
haven't understood all of the facets of the library yet.
I'm trying to generate a generic processing template that can be
subclassed for different target languages
At the moment I'm trying to pass in the result of a computation from
within a super template:
temp() ::= <<
int next = .....
if (next <ge()> 0x20 && next <le()> 0x2f) {
return <readBytes(length={ next - 0x20 })>;
}
>>
with
ge() ::= ">="
le() ::= "\<="
and
readBytes(length) ::= "<! This should be overriden by a subclass
template !>"
I'd like to be able to implement the readBytes(length) template in a
subtemplate that is specific to the target language.
Am I approaching this wrongly?
Do I need to approach the template definition for a language specific
function invocation in a more generic fashion than I'm doing here?
If so, how?
Thanks in advance,
Ben
More information about the stringtemplate-interest
mailing list