[stringtemplate-interest] How does one map properties/methods of an object to ST attributes?
Johannes Luber
jaluber at gmx.de
Tue Oct 16 02:30:07 PDT 2007
Terence Parr wrote:
>
> 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
>
The problem in my case is that I need to manipulate the tree after the
recognition for optimization purposes etc., so I can't use ANTLR's
inbuilt faculties while building the tree. So I have write an own tree
walker after all, don't I?
Johannes
More information about the stringtemplate-interest
mailing list