[antlr-interest] Can I force a token to have precendence in the lexer?

Jim Idle jimi at temporal-wave.com
Tue Apr 20 14:48:05 PDT 2010


This examples does everything you need and more, so you can pare it down to just your examples.

http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+point%2C+dot%2C+range%2C+time+specs


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Andy Hull
> Sent: Tuesday, April 20, 2010 2:42 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Can I force a token to have precendence in
> the lexer?
> 
> I have the following lexer tokens defined:
> 
> I have the following expression "x={1..3};"
> 
> I'm expecting the input between the braces to be recognized as FLOAT,
> AUTO, FLOAT but what I actually get is just a FLOAT  ".3" in the token
> stream of "x","=","{",".3","}",";"
> 
> 
> AUTO  :  '...';
> 
> FLOAT
>     :   ('0' .. '9')+ '.' ('0' .. '9')+ EXPONENT?
>     |   '.' ( '0' .. '9' )+ EXPONENT?
>     |   ('0' .. '9')+ EXPONENT
>     |   ('0' .. '9')+
>     ;
> 
> I think the float is matching too much. Can anyone help?
> 
> Thanks
> --
> Andy Hull | Senior Software Engineer
> SunRun Inc.<http://www.sunrunhome.com/>
> direct  415.684.9851
> 
> Review SunRun on Yelp<http://www.yelp.com/biz/sunrun-san-francisco>
> click on the link above and then on 'write a review'
> 
> 
> 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