[stringtemplate-interest] Bug in group map parsing??

Caleb Lyness caleb.lyness at ezswitch.net
Sat Dec 23 07:32:18 PST 2006


>   
>> "default" is a reserved words for maps I believe. I ran into this
>> problem a couple weeks ago. IMO, the parser should know what context
>> "default" is being used in and allow it if not in a map.
>>     
>
> Hi Guys. :) So we should allow keywords as variables? ;)
>   
No not at all.

Look at the map definition as given on the wiki:

map :   '['
            keyValuePair (',' keyValuePair)*
            ( ',' "default" ':' keyValue )?
        ']'
    ;

keyValuePair
    :   STRING ':' keyValue 
    ;

*keyValue
    :   BIGSTRING
    |   STRING
    |   "key"
    |       
    ;*

>From this is quite clear that a key value can be either a string, a big
string or the built in
id of key or nothing at all (empty string). If I put something in quotes
I expect it to be a
string, if I put it in double angle brackets I expect it to be a
bigstring. If my string contains
the word default it is definitely not a keyword - its a string. default
is not an uncommon
word to use as a string literal.


back onto the other problem of the default alone:
The above definition does not allow it. Perhaps a modification as follows:

map :   '[' mapPairs ']'
    ;

mapPairs 
    : keyValuePair (',' keyValuePair)* ( ',' defaultValuePair )?
    | defaultValuePair 


defaultValuePair
    : "default" ':' keyValue
    ;
 
keyValuePair
    :   STRING ':' keyValue 
    ;



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20061223/68aa113e/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/20061223/68aa113e/attachment-0001.bin 


More information about the stringtemplate-interest mailing list