[stringtemplate-interest] Setting the default lexer on the common group loader
Terence Parr
parrt at cs.usfca.edu
Sun Jul 19 13:01:02 PDT 2009
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
More information about the stringtemplate-interest
mailing list