[antlr-interest] Generating text from models

Mike Pagel mike at mpagel.de
Fri Dec 5 12:53:32 PST 2008


>> Can ST do this as well?
> Well, it depends on what the arguments are.  if it's an attribute or 
> string of some kind, you can use the format option and a renderer.
That would probably work but look a little weird I guess.
> Any time I need to pass an argument back into the model from the 
> template, I ask myself whether I am allowing the model to leak into 
> the template. If it looks the program, it probably is. That is not 
> something you want to happen to your template. In your case, It's hard 
> to tell. But, xpath stuff to pull specific nodes from a data structure 
> makes me a bit nervous unless you are just descending through the 
> various nodes. One could argue that the template should simply be 
> displaying data, not encoding how to jump around and ask about tree. 
> One test is to ask whether or not you could use that template with 
> another data structure. just something to think about.
I hear you. However not only the structure but also the higher level 
node values of the processed XML are part of a standardized format, 
where only certain leaf nodes contain variable configuration values. In 
that case I think it is justified to have templates that pull out 
particular values at the given position and generate code for 
corresponding constants for it.

But I do see that this is a really special case... Thanks a lot, I 
really appreciate your thoughts.

Mike


More information about the antlr-interest mailing list