[antlr-interest] REAL or int or Range

Jim Idle jimi at temporal-wave.com
Tue Jan 22 11:09:34 PST 2008


Just a typo. But when you define using fragments, then you will quite 
often make a function call in the lexer, rather than just matching. So 
it is slower. In this case it may not matter.

Jim

> -----Original Message-----
> From: Gavin Lambert [mailto:antlr at mirality.co.nz]
> Sent: Tuesday, January 22, 2008 10:49 AM
> To: Jim Idle; antlr-interest at antlr.org
> Subject: Re: [antlr-interest] REAL or int or Range
> 
> At 05:50 23/01/2008, Jim Idle wrote:
>  >
>  >fragment DOT : '.' ;
>  >
>  >range
>  >: '.'
>  >    (     ('.')=>'.'         // It is indeed two dots
>  >       |  { $type = DOT; }   // Just a dot
>  >    )
>  >;
> 
> Except the "range" rule needs to be a lexer rule as well.  So
> "RANGE" instead.  And if you're defining DOT like that anyway, you
> might as well write it like this:
> 
> fragment DOT : '.';
> 
> RANGE
>    : DOT
>      ( (DOT) => DOT
>      | {$type = DOT; }
>      )
>    ;
> 




More information about the antlr-interest mailing list