/// <summary>
 /// Creates a StringTemplateGroup instance that manages a set of
 /// templates defined in a "group file".
 /// </summary>
 /// <param name="reader">Input stream for group file data</param>
 /// <param name="lexer">Lexer to use for breaking up templates into chunks</param>
 /// <param name="errorListener">Error message sink</param>
 /// <param name="superGroup">Parent (or super/base) group</param>
 /// <returns>A StringTemplateGroup instance or null if no group is found</returns>
 public StringTemplateGroup CreateGroup(
     TextReader reader,
     Type lexer,
     IStringTemplateErrorListener errorListener,
     StringTemplateGroup superGroup)
 {
     return new StringTemplateGroup(reader, lexer, errorListener, superGroup);
 }
        /// <summary>
        /// Construct an instance that loads groups/interfaces from the single dir or 
        /// multiple dirs specified and uses the specified encoding.
        /// </summary>
        /// <remarks>
        /// If a specified directory is an absolute path, the full path is used to 
        /// locate the template group or interface file.
        /// 
        /// If a specified directory is a relative path, the path is taken to be
        /// relative to the location of the stringtemplate assembly itself.
        /// 
        /// TODO: Check shadow-copying doesn't knock this outta whack.
        /// </remarks>
        public EmbeddedResourceGroupLoader(
            IStringTemplateGroupFactory factory,
            IStringTemplateErrorListener errorListener,
            Assembly assembly,
            string namespaceRoot)
        {
            if (assembly == null)
                throw new ArgumentNullException("assembly", "An assembly must be specified");

            if (namespaceRoot == null)
                throw new ArgumentNullException("namespaceRoot", "A namespace must be specified");

            this.factory = (factory == null) ? new DefaultGroupFactory() : factory;
            this.errorListener = (errorListener == null) ? NullErrorListener.DefaultNullListener : errorListener;
            this.assembly = assembly;
            this.namespaceRoot = namespaceRoot;
        }
 public CommonGroupLoader(IStringTemplateErrorListener errorListener, Encoding encoding, params string[] directoryNames)
     : this(new DefaultGroupFactory(), errorListener, encoding, directoryNames)
 {
 }
Example #4
0
 /** <summary>
  *  Pass a single dir or multiple dirs separated by colons from which
  *  to load groups/interfaces.
  *  </summary>
  */
 public PathGroupLoader( string dirStr, IStringTemplateErrorListener errors )
 {
     _errors = errors;
     Directories = new ReadOnlyCollection<string>(dirStr.Split(':'));
 }
 /** <summary>Create an interface from the input stream</summary> */
 public StringTemplateGroupInterface( TextReader r,
                                     IStringTemplateErrorListener errors,
                                     StringTemplateGroupInterface superInterface )
 {
     this._listener = errors;
     SuperInterface = superInterface;
     ParseInterface( r );
 }
 public StringTemplateGroup( TextReader r, Type lexer, IStringTemplateErrorListener errors )
     : this(r, lexer, errors, (StringTemplateGroup)null)
 {
 }
Example #7
0
 public CommonGroupLoader( IStringTemplateErrorListener errors )
     : base(errors)
 {
 }
Example #8
0
 /** <summary>
  *  Pass a single dir or multiple dirs separated by colons from which
  *  to load groups/interfaces.
  *  </summary>
  */
 public PathGroupLoader(string dirStr, IStringTemplateErrorListener errors)
 {
     _errors     = errors;
     Directories = new ReadOnlyCollection <string>(dirStr.Split(':'));
 }
 public StringTemplateGroup(TextReader r, IStringTemplateErrorListener errorListener, StringTemplateGroup superGroup)
     : this(r, null, errorListener, superGroup)
 {
 }
 /// <summary>
 /// Create a group from the input stream, but use a nondefault lexer
 /// to break the templates up into chunks.  This is usefor changing
 /// the delimiter from the default $...$ to <...>, for example.
 /// </summary>
 public StringTemplateGroup(
     TextReader r,
     Type lexer,
     IStringTemplateErrorListener errorListener,
     StringTemplateGroup superGroup)
 {
     this.templatesDefinedInGroupFile = true;
     this.templateLexerClass = (lexer == null) ? typeof(AngleBracketTemplateLexer) : lexer;
     this.errorListener = (errorListener == null) ? DEFAULT_ERROR_LISTENER : errorListener;
     this.superGroup = superGroup;
     this.templateLoader = new NullTemplateLoader();
     ParseGroup(r);
     VerifyInterfaceImplementations();
 }
 public StringTemplateGroup(TextReader r, IStringTemplateErrorListener errorListener)
     : this(r, null, errorListener, null)
 {
 }
 /// <summary>
 /// Creates a group manager for some templates, all of which are
 /// loaded via a <see cref="StringTemplateLoader"/>.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="templateLoader"></param>
 /// <param name="lexer"></param>
 /// <param name="errorListener"></param>
 public StringTemplateGroup(
     string name,
     StringTemplateLoader templateLoader,
     Type lexer,
     IStringTemplateErrorListener errorListener,
     StringTemplateGroup superGroup)
 {
     this.name = name;
     nameToGroupMap[name] = this;
     if (templateLoader == null)
         this.templateLoader = new NullTemplateLoader();
     else
         this.templateLoader = templateLoader;
     this.templateLexerClass = lexer;
     if (errorListener == null)
         this.errorListener = DEFAULT_ERROR_LISTENER;
     else
         this.errorListener = errorListener;
     this.superGroup = superGroup;
 }
 /// <summary>
 /// Creates a StringTemplateGroup instance that manages a set of 
 /// templates that are accessible via a specified 
 /// <seealso cref="StringTemplateLoader"/>.
 /// </summary>
 /// <param name="name">Input stream for group file data</param>
 /// <param name="templateLoader">Loader for retrieving this group's templates</param>
 /// <param name="lexer">Lexer to use for breaking up templates into chunks</param>
 /// <param name="errorListener">Error message sink</param>
 /// <param name="superGroup">Parent (or super/base) group</param>
 /// <returns>A StringTemplateGroup instance or null</returns>
 public StringTemplateGroup CreateGroup(
     string name,
     StringTemplateLoader templateLoader,
     Type lexer,
     IStringTemplateErrorListener errorListener,
     StringTemplateGroup superGroup)
 {
     return new StringTemplateGroup(name, templateLoader, lexer, errorListener, superGroup);
 }
 /// <summary>
 /// Construct an instance that loads groups/interfaces from the single dir or 
 /// multiple dirs specified and uses the specified encoding.
 /// </summary>
 /// <remarks>
 /// If a specified directory is an absolute path, the full path is used to 
 /// locate the template group or interface file.
 /// 
 /// If a specified directory is a relative path, the path is taken to be
 /// relative to the location of the stringtemplate assembly itself.
 /// 
 /// TODO: Check shadow-copying doesn't knock this outta whack.
 /// </remarks>
 public CommonGroupLoader(
     IStringTemplateGroupFactory factory,
     IStringTemplateErrorListener errorListener,
     Encoding encoding,
     params string[] directoryNames)
 {
     this.factory = factory;
     this.errorListener = (errorListener == null) ? new NullErrorListener() : errorListener;
     this.encoding = encoding;
     foreach (string directoryName in directoryNames)
     {
         string fullpath;
         if (Path.IsPathRooted(directoryName))
         {
             fullpath = directoryName;
         }
         else
         {
             fullpath = string.Format("{0}/{1}",
                 AppDomain.CurrentDomain.BaseDirectory,
                 directoryName
                 );
         }
         if ( File.Exists(fullpath) || !Directory.Exists(fullpath) )
         {
             Error("group loader: no such dir " + fullpath);
         }
         else
         {
             if (directories == null)
             {
                 directories = new ArrayList();
             }
             directories.Add(fullpath);
         }
     }
 }
Example #15
0
 /** <summary>
  *  Pass a single dir or multiple dirs separated by colons from which
  *  to load groups/interfaces.  These are interpreted as relative
  *  paths to be used with CLASSPATH to locate groups.  E.g.,
  *  If you pass in "org/antlr/codegen/templates" and ask to load
  *  group "foo" it will try to load via classpath as
  *  "org/antlr/codegen/templates/foo".
  *  </summary>
  */
 public CommonGroupLoader( string dirStr, IStringTemplateErrorListener errors )
     : base(dirStr, errors)
 {
 }
Example #16
0
 public PathGroupLoader(IStringTemplateErrorListener errors)
 {
     _errors = errors;
 }
Example #17
0
 public CommonGroupLoader(IStringTemplateErrorListener errors)
     : base(errors)
 {
 }
 public StringTemplateGroupInterface( TextReader r, IStringTemplateErrorListener errors )
     : this(r, errors, (StringTemplateGroupInterface)null)
 {
 }
Example #19
0
 /** <summary>
  *  Pass a single dir or multiple dirs separated by colons from which
  *  to load groups/interfaces.  These are interpreted as relative
  *  paths to be used with CLASSPATH to locate groups.  E.g.,
  *  If you pass in "org/antlr/codegen/templates" and ask to load
  *  group "foo" it will try to load via classpath as
  *  "org/antlr/codegen/templates/foo".
  *  </summary>
  */
 public CommonGroupLoader(string dirStr, IStringTemplateErrorListener errors)
     : base(dirStr, errors)
 {
 }
 public StringTemplateGroup( TextReader r, IStringTemplateErrorListener errors )
     : this(r, typeof( AngleBracketTemplateLexer ), errors, (StringTemplateGroup)null)
 {
 }
Example #21
0
 public PathGroupLoader( IStringTemplateErrorListener errors )
 {
     _errors = errors;
 }
 /** <summary>
  *  Create a group from the input stream, but use a nondefault lexer
  *  to break the templates up into chunks.  This is usefor changing
  *  the delimiter from the default $...$ to &lt;...>, for example.
  *  </summary>
  */
 public StringTemplateGroup( TextReader r,
                            Type lexer,
                            IStringTemplateErrorListener errors,
                            StringTemplateGroup superGroup )
 {
     this._templatesDefinedInGroupFile = true;
     // if no lexer specified, then assume <...> when loading from group file
     if ( lexer == null )
     {
         lexer = typeof( AngleBracketTemplateLexer );
     }
     TemplateLexerClass = lexer;
     if ( errors != null )
     {
         // always have to have a listener
         this._listener = errors;
     }
     SuperGroup = superGroup;
     ParseGroup( r );
     _nameToGroupMap[_name] = this;
     VerifyInterfaceImplementations();
 }
 /// <summary>
 /// Creates a StringTemplateGroupInterface instance that manages a set of
 /// template interface definitions defined in a "group interface file".
 /// </summary>
 /// <param name="reader">Input stream for group-interface file data</param>
 /// <param name="errorListener">Error message sink</param>
 /// <param name="superGroup">Parent (or super/base) group interface</param>
 /// <returns>A StringTemplateGroupInterface instance or null</returns>
 public StringTemplateGroupInterface CreateInterface(
     TextReader reader,
     IStringTemplateErrorListener errorListener,
     StringTemplateGroupInterface superInterface)
 {
     return new StringTemplateGroupInterface(reader, errorListener, superInterface);
 }