[antlr-interest] Question with greedy

Jim Idle jimi at temporal-wave.com
Thu Sep 24 10:43:09 PDT 2009


On 09/24/2009 10:11 AM, Dave Dutcher wrote:
>
> Didn't that used to work in Antlr 2?  I think that would be a very useful
> feature to have back.
>
>    
We have explained this many times in the past but it is to do with the 
performance gains achieved by not associating text with tokens unless 
you really need it and so do so yourself.

You can also do this:

T1 : '/*' r=FRAGRULE '*/'  { setText($r.text); } ;

So in practice it is only a minor inconvenience, for a simpler and 
faster lexer :-)

Jim
> Dave
>
>    
>> -----Original Message-----
>> From: antlr-interest-bounces at antlr.org
>> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
>> Sent: Thursday, September 24, 2009 11:39 AM
>> Cc: antlr-interest at antlr.org
>> Subject: Re: [antlr-interest] Question with greedy
>>
>> On 09/24/2009 06:20 AM, Gordon Tyler wrote:
>>      
>>> To exclude the /* and */ would something like this work?
>>>
>>> COMMENT
>>>    	:  '/*'! ( options {greedy=false;} : . )* '*/'!
>>>
>>>        
>> No :-)
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email
>> -address
>>      
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>    



More information about the antlr-interest mailing list