[stringtemplate-interest] Attribute not found exception? Revisited

Terence Parr parrt at cs.usfca.edu
Tue Nov 28 17:27:29 PST 2006


On Nov 8, 2006, at 12:46 PM, Caleb Lyness wrote:
>
> With ref to the following thread:
> http://www.antlr.org:8080/pipermail/stringtemplate-interest/2006- 
> March/000291.html
>
> * I am looking for a way to ask a template what attributes it is  
> using/wanting.
> So far I have overloaded a Map class which records which keys are  
> requested.
> I pass this in as the attributes list. At the end of a template gen  
> I know what was
> requested and what was not.
>
> Q: Can I do this with out actually rendering, (via toString())...  
> i.e. is there another way?

Hi Caleb.  Can you override StringTemplate.	public Object getAttribute 
(String name)?  Then map ST name to Set of attribute names.  This  
will catch every reference to an attribute with in every template,  
but it does not say which are optional.  Hmm... to track those that  
are missing but referenced, it seems like you could override  
something in ASTExpr to render "missing attr" or something.
Ter


More information about the stringtemplate-interest mailing list