[stringtemplate-interest] [ST4] Specifying delimiter in group files

Johannes Luber JALuber at gmx.de
Thu Jan 27 15:09:17 PST 2011


> An interesting proposal.  How do others feel about moving delimiter spec
> to the templates instead of code?  is a separate file the right idea for
> STGroupDir groups?
> Ter

Looks good to me.

Johannes

> On Jan 27, 2011, at 7:25 AM, Udo Borkowski wrote:
> 
> > I suggest we defined one set of delimiter as the default (I guess the
> current favorite is '<','>').
> > 
> > When a group file uses different delimiter than the default it must
> explicitly specify them (e.g. by using a new "delimiter" statement, as
> suggested in the original post).
> > 
> > For the GroupDir case I suggest to have an extra (optional) file in the
> directory (e.g. "group.config") that may hold the "delimiter" statement for
> the whole group. I.e. if the "group.config" file exists and defines  the
> delimiter they are use for all template files in the directory. In a
> "template file" there must not be any "delimiter" statement.
> > 
> > One will no longer specify delimiter in the source code for STGroupFile
> and STGroupDir. However I would keep the STGroup(char delimiterStartChar,
> char delimiterStopChar) constructor, just in case one wants to create a
> group "on the fly", e.g. when writing inline test cases.
> > 
> > 
> > Udo
> > 
> > 
> > 
> > 
> > On 27.01.2011, at 02:04, Terence Parr wrote:
> > 
> >> Actually, this brings up an excellent point. why are we doing
> >> 
> >> STGroup g = new STGroupFile("t.stg", '$', '$');
> >> 
> >> when the file itself and not the code should determine what the
> delimiters are. the code should not care. If we change the delimiter in the file,
> the code no longer works.
> >> 
> >> Even if we're doing STGroupDir("/tmp/templates") I don't think we
> should specify the delimiters. It might be the case that the templates use
> different delimiters.  Hmm... groups currently only understand one  set of
> delimiters so maybe this is okay for dirs.
> >> 
> >> I'd like to be consistent though. with the directory version, we
> wouldn't know with the delimiter was until we read in one of the templates. not
> sure I like that.
> >> 
> >> suggestions anyone?
> >> 
> >> Ter
> >> 
> >> On Jan 26, 2011, at 2:19 AM, Udo Borkowski wrote:
> >> 
> >>> Hi,
> >>> 
> >>> I am currently using different sets of delimiter in different group
> files (e.g. '$','$' vs. '<','>'). Depending on this I need to make sure the
> STGroup is create with the proper delimiter.
> >>> 
> >>> What do you think of making it more explicit in the group file, what
> delimiter it uses?
> >>> 
> >>> This may be achieved with a new (optional) syntax element in the group
> grammar, defining the delimiter for this file. It may look like:
> >>> 
> >>> delimiter
> >>> 	: 'delimiter' s=STRING e=STRING {
> >>> 				//TODO: check if s and e have length 1, or better: use CHAR token
> >>> 				group.delimiterStartChar=$s.charAt(0);
> >>> 				group.delimiterEndChar=$e.charAt(0);
> >>> 			}
> >>> 
> >>> (Code not tested)
> >>> 
> >>> This statement would overwrite the previous delimiter setting in the
> group.
> >>> 
> >>> The delimiter statement need to be speficied before the first def
> element.
> >>> 
> >>> 
> >>> 
> >>> Udo
> >>> 
> >>> 
> >>> _______________________________________________
> >>> stringtemplate-interest mailing list
> >>> stringtemplate-interest at antlr.org
> >>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> >> 
> > 
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest

-- 
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl


More information about the stringtemplate-interest mailing list