[antlr-interest] [stringtemplate-interest] File based templates and maps.

Terence Parr parrt at cs.usfca.edu
Thu Oct 19 16:14:21 PDT 2006


Wow!  Interesting...seems a bug.

added:

http://www.antlr.org/wiki/display/ST/numbers+not+allowed+as+keys

Ter
On Oct 19, 2006, at 4:05 PM, Caleb Lyness wrote:

> Terence Parr wrote:
>> try now...a spammer created 100 spam users. :(
> Sorted.
> -----
>
> Here is another problem I ran into while playing with maps:
>
> If the map has a number in the key you can't reference it directly.
>
> E.g.
>
> The map is defined as:
>
> collectionFailure ::= [
>   "1":     "Revoked",
>   "2":     "Other",
>   "A":     "Settled",
>   "B":     "Frozen",
>   default: "Unknown"
> ]
>
> If a tempate .st file refers to the map directly
>
> $collectionFailure.1$     - it fails (see below)
> $collectionFailure.A$     - works
>
> but if I use $collectionFailure.(reasonCode)$
> then Bobs your uncle it can be 1 or A...
>
> action parse error in group base templates line 0; template context  
> is [bodies/example1]
> line 1:19: unexpected token: 1
>     at org.antlr.stringtemplate.language.ActionParser.primaryExpr 
> (ActionParser.java:703)
>     at org.antlr.stringtemplate.language.ActionParser.expr 
> (ActionParser.java:430)
>     at org.antlr.stringtemplate.language.ActionParser.templatesExpr 
> (ActionParser.java:212)
>     at org.antlr.stringtemplate.language.ActionParser.action 
> (ActionParser.java:126)
>
>> Ter
>>
>> On Oct 19, 2006, at 10:39 AM, Caleb Lyness wrote:
>>
>>>>> I think it would be nice for future newbies if there was an  
>>>>> example along side the file based template (.st) method in the  
>>>>> source. Would speed the learning curve up a bit. cf: src\org 
>>>>> \antlr\stringtemplate\test.
>>>> Add a quick tutorial :) http://www.antlr.org/wiki/display/ST/ 
>>>> Tutorials
>>> Pitty, I cannot:
>>> I don't have a login and I can't create one.
>>>
>>> The following error(s) occurred:
>>> This installation of Confluence is not licensed to add any more  
>>> users. Please contact the site administrators for more information.
>>>
>>>
>>
>>
>



More information about the antlr-interest mailing list