[stringtemplate-interest] File based templates and maps.
Caleb Lyness
caleb.lyness at ezswitch.net
Mon Oct 23 14:03:44 PDT 2006
Terence Parr wrote:
> On Oct 19, 2006, at 11:53 PM, John Snyders wrote:
>
>
>> There are many characters that can't be used as a map key without
>> enclosing
>> in ().
>> I don't think it matters if the map is declared in code or in the
>> group
>> file.
>>
>
> actually yes that is true-- the key is a string so doesn't matter
> during the definition. When you pull it out though, we are
> overloading the dot operator which requires an identifier.
>
So noted.
>
>> It has to do with what is allowed after . in an attribute reference
>> atom DOT ID is allowed where atom is ID, STRING, INT, or
>> ANONYMOUS_TEMPLATE.
>>
>> So if your map key is "a:.b" or even "first" $map.a:.b$ and
>> $map.first$
>> won't work.
>>
>
> does $map.("a:.b")$ work?
>
Yes. Looks a bit nasty: but here is an example:
String templateGroupDef = "group test; \n"+
"aMap ::= [ \n"+
"\"a:.b\": \"A Test\"\n"+
"]\n"+
"templ() ::= \"<aMap.(\\\"a:.b\\\")>\"";
StringTemplateGroup group = new StringTemplateGroup(new
StringReader(templateGroupDef));
System.out.println(templateGroupDef);
System.out.println(group.getInstanceOf("templ").toString());
This gives you:
group test;
aMap ::= [
"a:.b": "A Test"
]
templ() ::= "<aMap.(\"a:.b\")>"
A Test
>
>> So I'm not sure this (integer keys) is a bug but I'm still confused
>> as to
>> why ST needs to parse integers at all.
>>
>
> yes, ST should not parse integers. $map.("1")$ should work.
>
It does work. Probably should change status from bug to "caveat"
Cheers
Caleb.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20061023/7eb32908/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3269 bytes
Desc: S/MIME Cryptographic Signature
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20061023/7eb32908/attachment-0001.bin
More information about the stringtemplate-interest
mailing list