[antlr-interest] String Template Q: How do I implement object identifiers?

Austin Hastings Austin_Hastings at Yahoo.com
Wed Nov 21 23:36:00 PST 2007


Howdy,

I'm trying to generate output using StringTemplate's, and I'd like to 
apply a serial number to each object created. The idea is to output 
something like:

Object foo32 = new Object(...);
String string33 = new String(...);
FooBar foobar34 = new FooBar(...);

I'm simplifying radically here, and the actual generation of the objects 
is widely separated. Because of this, and because large parts of the app 
*don't* need serial numbers, I would really rather not pass an Integer 
parameter to every generate-code method.

What I'd prefer would be a built-in (surely I'm not the only one needing 
this - look at all the numbered variables in ANTLR output), or perhaps 
some kind of built-in variable mechanism in the ST system.

Does something already exist to solve this problem, or will I have to 
build a custom adaptor object?

Thanks,

=Austin



More information about the antlr-interest mailing list