[antlr-interest] confused about rendering all String Templates...

Morgan Jones mjones at pobox.com
Thu Nov 17 08:39:17 PST 2011


I've gotten a lexer, parser (that outputs AST) and a tree parser work.

Currently the tree parser contain little code snippets that include
System.out.println to print my translated file.

Not very pretty, but it works.

My next step was to switch to StringTemplates, because I thought it
would help me clean up the tree parser.
So far my initial efforts haven't yielded much.

After reading TP's books and (this morning) about 40 pages of interest
messages about templates I'm beginning to think I might be
misunderstanding the use of String Templates...

I thought I could include a template and after walking my tree I could
call getTemplate on my return object and then toString to have it dump
out the results of ALL my templates, but as far as I can tell it only
prints out the template of the rule  I called.

I've debugged the resulting .java file and I can step into the results
from each rule and see that a correct template is created.
But I can't figure out how to "walk" all the templates and have them
dump out my results.

>From the reading I've done this morning I'm beginning to believe that
the templates aren't expected to do this...

Can someone clear this up for me?
Point me in the direction of a template example that demonstrates this
if it is suppose to work.

Any help is appreciated.

Morgan


More information about the antlr-interest mailing list