[stringtemplate-interest] How best to do recursive hetero template calls?
Gerald Rosenberg
gerald at certiv.net
Mon Feb 15 10:40:15 PST 2010
Looking for the best/proper way to do a recursive heterogeneous template
expansion.
The initial attribute is effectively defined as:
public class Element {
public String type; // can be "TypeA" or "TypeB"
public Element[ ] children;
. . .
}
The actual implementation is a fair bit more complex, so before I go too
far down the wrong path, can anyone please comment on this as being a
workable approach. Something better? Alternates? Gotchas(how to
handle first == rest)?
Thanks...
/////////////////////////////////////////////////////////////////////////////
Main(rootElement) ::= <<
<(rootElement.type)(first(rootElement.children),
rest(rootElement.children))>
}
>>
TypeA(element, remainder) ::= <<
BEGIN-A
<(first(remainder.children).type)(first(remainder.children),
rest(remainder.children))>
END-A
>>
TypeB(element, remainder) ::= <<
BEGIN-B
<(first(remainder.children).type)(first(remainder.children),
rest(remainder.children))>
END-B
>>
/////////////////////////////////////////////////////////////////////////////
More information about the stringtemplate-interest
mailing list