Hi Morgan,

Well, I'm a newbie too, but I can tell you how I understand and use 
StringTemplates. For me, the end result of walking a tree that produces 
StringTemplates is a StringTemplate which contains elements which are 
themselves StringTemplates (or lists of String Templates), which contains 
elements which are themselves StringTemplates (or lists of String Templates), 
and so on. At this point no "rendering" to actual strings has been done. After 
the giant StringTemplate amalgam is created, rendering the top level 
StringTemplate will render all the sub-StringTemplate in turn, all the way down 
the tree.

In a way you have created a different sort of StringTemplate tree during the 
tree walk, but it is not the AST itself.

So as you are walking a tree, you are taking the StringTemplates returned by 
rules and putting them into StringTemplates of the containing rules, and the 
top level rule returns the top level StringTemplate.

I hope this is clear, and the experts can correct my misunderstandings,

- Andy

-----Original Message-----
From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Morgan Jones
Sent: Thursday, November 17, 2011 8:39 AM
To: antlr-interest@antlr.org
Subject: [antlr-interest] confused about rendering all String Templates...

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

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


________________________________

CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files or 
previous e-mail messages attached to it, may contain information that is 
confidential and/or legally privileged. If you are not the intended recipient, 
or a person responsible for delivering it to the intended recipient, please DO 
NOT disclose the contents to another person, store or copy the information in 
any medium, or use any of the information contained in or attached to this 
transmission for any purpose. If you have received this transmission in error, 
please immediately notify the sender by reply email or at 
priv...@plantronics.com, and destroy the original transmission and its 
attachments without reading or saving in any manner.

For further information about Plantronics - the Company, its products, brands, 
partners, please visit our website www.plantronics.com.

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to