[stringtemplate-interest] feature request: attribute name as enum

Terence Parr parrt at cs.usfca.edu
Sun Dec 4 15:47:48 PST 2011


An interesting thought. is this so that you could get some compile time warnings if you type in the wrong attribute name? how would you coordinate the enum constants with the attributes defined in the template file? Actually, maybe that could be automatically generated by a tool that looks at ST files and generates in enums?

If we take this a step further, perhaps there should be a tool that looks at templates and generates interfaces for them so that we can create them directly with constructors and typed attributes?

 Instead of getInstanceOf("foo") and then st.add("x", 34); we could do:

new foo(34);

from:

foo(x) ::= "value: <x>"

 Interesting. What do other people think?

Ter
On Sep 16, 2011, at 2:07 AM, AuFinNS wrote:

> Hello, 
> 
> is it suitable to have an stringtemplate add method with signature
> 
> 	public ST add(Enum<?> name,  java.lang.Object value) {
> 		return add(name.name(), value);
> 	}
> 
> for easy work with enums?
> 
> Many thanks!
> Best Regards, Max
> 
> 
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20111204/6c25dcfd/attachment.html 


More information about the stringtemplate-interest mailing list