[antlr-interest] New article on StringTemplates and Treewalkers

Kay Roepke kroepke at dolphin-services.de
Thu Jan 12 13:39:39 PST 2006


On 12. Jan 2006, at 16:43 Uhr, Andy Tripp wrote:

> I'm not following you exactly, but I think it's a reasonable  
> question. I don't buy that I could, for example,
> use StringTemplate to output C# instead of Java, without major  
> changes to my code. I don't think
> ANTLR could output MS or Haskell (or Lisp) without major changes.  
> ST is not fullfilling the
> "separate your view from your translation" promise in any cases  
> other than the most trivial, contrived cases
> (or when the output languages are so similar as C++/Java/C# and the  
> domain is so limited as in the case
> of all the code that ANTLR spits out).

Chiming in late, but I have one remark to make:
ST isn't the view! It certainly is part of the view, but it's not the  
entire view. The code generator is the view.
ST simply gets rid of all those prints in your code and puts the  
parameterized text into one place. I personally have
used and written template systems (engines, whatever) for a few years  
now, and am very pleased with the approach.
If I understand your approach correctly, it seems to me that your  
"patterns" are some kind of templates, too.
To me they look like mini-grammars (sorry for that ;)) with  
integrated templates (the RHS of the '-->').
The v's and x's are template variables and the rest of the text is  
copied verbatim. Are there any control structures
you use?

Regards,

Kay


More information about the antlr-interest mailing list