[stringtemplate-interest] [ST4] Specifying delimiter in group files
Terence Parr
parrt at cs.usfca.edu
Wed Jan 26 17:04:00 PST 2011
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
More information about the stringtemplate-interest
mailing list