[antlr-interest] Organization of complex template structures

Loring Craymer lgcraymer at yahoo.com
Mon Dec 22 00:52:19 PST 2008


Mike--

StringTemplateGroupLoader.loadGroup(String name, StringTemplateGroup base) returns a StringTemplateGroup that has the "name" template group loaded on top of (can override) base.  The readily available example is in org.antlr.codegen.CodeGenerator.loadTemplates().

Templates can only invoke templates from within the same group--the lookup mechanism enforces this--but this should be rare.  The normal approach is to use template instances as arguments, so that template instances are constructed hierarchically.  Templates are abstracted from their arguments, but not from any called templates.  The antlr source is fairly good about following this principle.

When I wrote about splitting groups, I meant that Group A can be sliced into Group B, C, and  D; if A fully satisfies interface I, then B, C and D each satisfy a part of I but jointly satisfy all of I.  Templates within groups are loosely coupled, so the dividing points would usually be arbitrarily chosen.

--Loring



----- Original Message ----
> From: Mike Pagel <mike at mpagel.de>
> To: antlr-interest at antlr.org
> Sent: Sunday, December 21, 2008 11:48:05 PM
> Subject: Re: [antlr-interest] Organization of complex template structures
> 
> Hey Loring,
> 
> maybe I missed a feature of ST so far. You said:
> 
> > 4.)  A StringTemplateGroup can load multiple template groups, so any large 
> group can be split up into several smaller groups and all can be loaded into a 
> single StringTemplateGroup.  [I have not had reason to do this; it seems more 
> common to override some templates in one group with another.]
> >  
> I thought you'd have to load a *single* group file into a 
> StringTemplateGroup and the only way to combine it with other groups is 
> through static (in the group file) or dynamic (through the loader) 
> inheritance. How do you load let's say three template groups "a.stg", 
> "b.stg" and "c.stg" and can they then call into each other?
> 
> Your phrasing ("large group can be split up into smaller groups") could 
> imply hierarchical groups containing groups containing templates, but 
> this is not possible, right?
> 
> I am sorry if I actually missed those parts of the docs, any links or 
> samples are appreciated.
> 
> 
> Thanks,
> Mike
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address



      


More information about the antlr-interest mailing list