[stringtemplate-interest] who uses regions?
Sam Harwell
sharwell at pixelminegames.com
Thu Jun 30 13:22:05 PDT 2011
The following is allowed and works like you'd expect:
foo() ::= <<
<@bar()>
>>
@foo.bar() ::= <<
<@subbar()>
>>
@foo.bar.subbar() ::= <<
Yay!
>>
The following is not allowed:
foo() ::= <<
<@bar><@subbar>Nay!<@end><@end>
>>
The following both produce empty output but foo2 does not print any message
about a missing template:
foo() ::= <<
<bar()>
>>
foo2() ::= <<
<@bar()>
>>
-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Thursday, June 30, 2011 2:59 PM
To: stringtemplate-interest Template
Subject: Re: [stringtemplate-interest] who uses regions?
On Jun 30, 2011, at 12:39 PM, Sam Harwell wrote:
> I actually came up with an idea last week concerning this, but figured
> you were done looking at regions so I didn't mention it. Looks like
> that might not be the case anymore. :)
>
> Summary of how it could work:
>
> * Get rid of explicit/implicit/embedded regions. Regions are always
> defined explicitly, and a region reference is just a normal template
reference.
How do you define explicitly? Can you give an example?
T
> * Allow a template definition to be formatted as "@dotted.ident.ifier".
> * For the above rule, the template name is "@dotted.ident.ifier". The
> character '@' is a new ID start char. The characters '-', '_', and '.'
> are ID characters (but not ID start chars).
> * A template expression <@name> refers to @currentTemplate.name.
>
> In the implementation, the notion of regions is now gone. The @ syntax
> is just shorthand for adding "@currentTemplateName." to the name of
> the template to lookup, which makes them effectively the same as they
> used to be since the automatic insertion of the current template name
> means you can only reference them within a specific template.
>
> If <@name()> appears within a template named "@other.item", the extra
> @ is dropped when forming "@other.item.name".
>
> When looking up a template, if the name starts with @ and isn't found,
> return an empty template without printing an error message (covers the
> case where implicit regions were used before).
>
> Sam
>
> -----Original Message-----
> From: stringtemplate-interest-bounces at antlr.org
> [mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of
> Terence Parr
> Sent: Thursday, June 30, 2011 1:56 PM
> To: stringtemplate-interest Template
> Subject: [stringtemplate-interest] who uses regions?
>
> they are driving me nuts in STv4 implementation. i'm not even sure
> what they mean anymore with subdirs and /a/b/c/d style references with
> inheritance mixed in.
>
> I don't use anymore myself. I released I needed them in ANTLR v3 code
> gen due to forcing too much of logic into templates. v4 does all
> thinking in code and constructs internal model and then just makes
> templates and fills and renders.
>
> i'd love to eject regions but not if people use. I guess ANTLR 3.4
> needs them...hmm...
>
> Ter
> _______________________________________________
> 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
More information about the stringtemplate-interest
mailing list