[stringtemplate-interest] How does one map properties/methods of an object to ST attributes?
Terence Parr
parrt at cs.usfca.edu
Mon Oct 15 17:46:29 PDT 2007
On Oct 15, 2007, at 3:57 PM, Johannes Luber wrote:
> As one can see, only the RootInterpreter object shows up on the
> output.
> What I am doing wrong? Considering that I'm using ANTLR I can't assign
> other other template arguments automatically - at least not that I
> know
> of. Do I have to create an own tree walker which feeds to adapted
> templates?
Hi Johannes,
in general, you need to build up a tree of sub templates. For
example if you are building a template for a Java class, you need to
build not only the outer class definition template, but all of the
method templates and then within those, all of the statement
templates. Within those, you need to build all of the expression
templates. The way to do this is by recognizing the various
subtrees, which typically means a tree grammar. Imagine that each
rule in your grammar returns a sub template, which effectively maps a
subtree to a sub template. The invoking rule builds a bigger
template and so on up until the root rule which builds the overall
template.
Ter
More information about the stringtemplate-interest
mailing list