[antlr-interest] greedy=false for lexersBy default

Terence Parr parrt at cs.usfca.edu
Fri May 23 16:21:16 PDT 2008


it is specific to a block.

~'"' doesn't work if you need escapes etc...

>> STRING : '"' ('\\' '"'|.)* '"' ;

Ter
On May 23, 2008, at 4:09 PM, Loring Craymer wrote:

> Ter--
>
> I'm uneasy about this, but then I tend to avoid the greedy=false  
> shortcut in favor of being precise (~'"' instead of . in this  
> case).  Why not make "greedy" a grammar-level option, instead?
>
> --Loring
>
> ----- Original Message ----
>> From: Terence Parr <parrt at cs.usfca.edu>
>> To: antlr-interest Interest <antlr-interest at antlr.org>
>> Sent: Friday, May 23, 2008 3:32:31 PM
>> Subject: [antlr-interest] greedy=false for lexersBy default
>>
>> hi,
>>
>>  I'm thinking of changing lexers to use greedy=false by default so
>> that things like
>>
>> STRING : '"' ('\\' '"'|.)* '"' ;
>>
>>  so I don't have to say
>>
>> STRING : '"' (options {greedy=false;}:'\\' '"'|.)* '"' ;
>>
>> I think with a dot in there it works now:
>>
>> CMT : '//' .* '\n' ;
>>
>> Any objections to me flipping this real quick for 3.1?
>>
>> Ter
>
>
>
>
>



More information about the antlr-interest mailing list