[antlr-interest] changed 'x' to "x" for v3

Terence Parr parrt at cs.usfca.edu
Sun Nov 27 10:54:44 PST 2005


On Nov 27, 2005, at 10:34 AM, Stefan Rank wrote:

> on 27.11.2005 18:07 Terence Parr said the following:
>> On Nov 26, 2005, at 4:04 PM, Ric Klaren wrote:
>>> Just a thought: Isn't it easier then to use single quotes in  
>>> stead of
>>> double quotes for everything ? Assuming that double quotes are used
>>> more often.
>> Hi Ric.  I'm willing to change it to '...' just to make those  
>> unit  tests readable again!  However, we should focus on what is  
>> better for  the people that specify a grammar.  Most people will  
>> be used to  seeing double quotes for strings but the double quotes  
>> around a char  (particularly in a "0".."9" situation) will seem  
>> unusual.  The other  way, actually might not bother people 'int'  
>> and 'begin' actually  immediately make you say "oh, they are using  
>> single quote for string  character".   Hmm...did I just convince  
>> myself to spend 4 hours  changing tests/examples/code to single  
>> quotes?  Argh!  Ok, we better  wait until people come back to work  
>> on Monday to decide this.  I'm  all ears as we say...suggestions?
>
> This may be heretic, but what about allowing both variants?
> (just as python does)

Hi Stefan. :)  Well, I'm of the camp that likes one way to do each  
thing.  Escaping a quote happens once or twice in for parsing a  
language like Java...not a big deal.  I did consider the issue of  
perhaps multi-line strings etc..., but you are breaking stuff up into  
bites on purpose with a parser...you don't get long token string  
definitions.

> This makes parsing harder, but everyone can choose what looks best,  
> a source of error (using the wrong quotes) is eliminated, and the  
> need to escape is reduced to the cases where you have both ' and "  
> inside the string.

I'm mainly concerned with the 100s of unit tests I have that are now  
unreadable.  i'm tempted to make it '...' just to get my unit tests  
back ;)

I was thinking on the way to my office today that perhaps if we use  
'...' for literals, then "..." could be used for a lexer grammar  
fragment like: "'0'..'9'* ('X'|'L')", but then I decided that this is  
rarely what you want...unless you are trying to write a small amazing  
example for a journal paper article ;)

Ter


More information about the antlr-interest mailing list