[stringtemplate-interest] Setting the default lexer on the common group loader

ed ed edeustace at yahoo.com
Sun Jul 19 15:02:45 PDT 2009


Terence, 
You are a scholar and a gent!

For the record here is what I have now:
StringTemplateGroupLoader loader = new CommonGroupLoader(FOLDER, new ErrorListener() );
StringTemplateGroup.registerGroupLoader(loader);
StringTemplateGroup group = StringTemplateGroup.loadGroup("classgroup", DefaultTemplateLexer.class, new StringTemplateGroup("super") );
StringTemplate template = group.getInstanceOf("classGenerator");
template.setAttribute("config", "config" );
log.info(template.toString() );

Best,
Ed





________________________________
From: Terence Parr <parrt at cs.usfca.edu>
To: ed ed <edeustace at yahoo.com>
Cc: stringtemplate-interest at antlr.org
Sent: Sunday, July 19, 2009 9:01:02 PM
Subject: Re: [stringtemplate-interest] Setting the default lexer on the common group loader

Hi Ed,

can you try using the lexer argument on the constructor to the group? I think the problem is related to loading the templates before the appropriate lexer has  been set.
Ter
On Jul 19, 2009, at 12:58 PM, ed ed wrote:

> Hello,
> I've been playing around with StringTemplate 3.2 and enjoying it greatly.
> 
> When I started I began using the $ as my expression delimiter. This was working great while developing locally.
> 
> I'm now trying to generate a .jar within which I have my bundled Templates. The docs state that you need to use CommonGroupLoader for jar files. (http://www.antlr.org/wiki/display/ST/Group+Files). However the default lexer token for groups is the Angle bracket (<>).
> 
> I can see in the docs how to change the delimiter for a template group that I'm creating  a new instance of:
> http://www.antlr.org/wiki/display/ST/Setting+the+expression+delimiters
> 
> But I don't know how to change the default delimiter when using the comon group loader.
> 
> This is what I'm trying:
> StringTemplateGroupLoader loader = new CommonGroupLoader(FOLDER, new ErrorListener() );
> StringTemplateGroup.registerGroupLoader(loader);
> StringTemplateGroup.registerDefaultLexer(DefaultTemplateLexer.class);
> StringTemplateGroup group = StringTemplateGroup.loadGroup("classgroup");
> StringTemplate template = group.getInstanceOf("classGenerator");
> template.setAttribute("config", "config" );
> log.info(template.toString() );
> 
> For a template like so:
> group classgroup;
> 
> classGenerator(config,setup) ::= <<
>     hello $config$
>     hello "config"
>     hello <config>
>  >>
> 
> I get:
> hello $config$
> hello "config"
> hello config
> 
> The closest thing I've found is this:
> http://www.antlr.org/pipermail/stringtemplate-interest/2007-May/001046.html
> 
> Any tips greatly appreciated,
> Best,
> Ed
> 
> 
> 
> _______________________________________________
> 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/20090719/7a120ab8/attachment.html 


More information about the stringtemplate-interest mailing list