[stringtemplate-interest] [PATCH] STdaily stringtemplate-11-09-2007.17: Group hierarchy fix.
Terence Parr
parrt at cs.usfca.edu
Mon Dec 10 17:41:40 PST 2007
Hi. I have played around. a definite bug here...can't decide best
fix. Probably is to alter StringTemplateGroupLoader interface to have
public StringTemplateGroup loadGroup(String groupName,
Class templateLexer,
StringTemplateGroup superGroup);
because it can't parse superGroup w/o knowing template format.
Hmm...worried about breaking code by changing the interface. Thoughts?
Oh, added the nameToGroupMap update too. thanks.
Ter
On Dec 7, 2007, at 10:55 PM, Zenaan Harkness wrote:
> Here's my git output for this patch:
>
> StringTemplateGroup defaults to DefaultTemplateLexer.class for its
> lexer.
>
> This is all very well for groups representing directories of
> individual ST
> file based templates, but is a bug when using STG group files, which
> default
> to use of AngleBracketLexer.
>
> In particular, when an STG group file hierarchy is used, eg
> "SubSTGroup : SuperSTGroup;" at top of a group file, the
> PathGroupLoader,
> for example, can be used to auto-load parent template group(s).
> Except that the lexer for the parent, by default is not angle
> bracket lexer.
>
> This change updates org.antlr.stringtemplate.PathGroupLoader, which
> is only used to load parent groups anyway, to default to using angle
> lexer.
>
> A minor bug is also fixed, where StringTemplateGroup instances
> constructed
> with a Reader are now added to nameToGroupMap (they were not before,
> but
> other instances were).
> ---
> src/org/antlr/stringtemplate/PathGroupLoader.java | 4 +++-
> .../antlr/stringtemplate/StringTemplateGroup.java | 1 +
> 2 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/src/org/antlr/stringtemplate/PathGroupLoader.java b/src/
> org/antlr/stringtemplate/PathGroupLoader.java
> index 623937f..7129ca0 100644
> --- a/src/org/antlr/stringtemplate/PathGroupLoader.java
> +++ b/src/org/antlr/stringtemplate/PathGroupLoader.java
> @@ -5,6 +5,8 @@ import java.util.List;
> import java.util.StringTokenizer;
> import java.util.ArrayList;
>
> +import org.antlr.stringtemplate.language.AngleBracketTemplateLexer;
> +
> /** A brain dead loader that looks only in the directory(ies) you
> * specify in the ctor.
> * You may specify the char encoding.
> @@ -58,7 +60,7 @@ public class PathGroupLoader implements
> StringTemplateGroupLoader {
> error("no such group file "+groupName+".stg");
> return null;
> }
> - group = new StringTemplateGroup(br, null, errors, superGroup);
> + group = new StringTemplateGroup(br,
> AngleBracketTemplateLexer.class, errors, superGroup);
> }
> catch (IOException ioe) {
> error("can't load group "+groupName, ioe);
> diff --git a/src/org/antlr/stringtemplate/StringTemplateGroup.java b/
> src/org/antlr/stringtemplate/StringTemplateGroup.java
> index 9378828..5aae477 100755
> --- a/src/org/antlr/stringtemplate/StringTemplateGroup.java
> +++ b/src/org/antlr/stringtemplate/StringTemplateGroup.java
> @@ -269,6 +269,7 @@ public class StringTemplateGroup {
> }
> setSuperGroup(superGroup);
> parseGroup(r);
> + nameToGroupMap.put(getName(), this);
> verifyInterfaceImplementations();
> }
>
> --
> 1.5.2.5
>
>
> --
> Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
> Please respect the confidentiality of this email as sensibly
> warranted.
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list