[antlr-interest] REAL or int or Range
Jim Idle
jimi at temporal-wave.com
Tue Jan 22 08:50:32 PST 2008
Alex,
See prior posts on this. The code I gave you used the parser, but was
also able to return '.' vs '..'. What you need to do is basically
lookahead in the rule yourself and reject the akts that are not what you
want, akin to this:
fragment DOT : '.' ;
range
: '.'
( ('.')=>'.' // It is indeed two dots
| { $type = DOT; } // Just a dot
)
;
Personally I think that you end up with tighter code this way as you are
specifying exactly what you want ot happen, but there are many who
believe that ANTLR should just 'do it' ;-)
Jim
> -----Original Message-----
> From: Alexander Gängel [mailto:alexander at gaengel.de]
> Sent: Tuesday, January 22, 2008 7:06 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] REAL or int or Range
>
> ok, I see.
>
> is there any workaround ?
>
> cause the Language I try to parse not only allows int real and rang
but
> also functions like 13.div(2) so if the lexer could distinguish '.'
and
> '..' I think this would not be such an hard Problem then.
>
> Alexander
>
> Gavin Lambert schrieb:
> > At 22:32 22/01/2008, Alexander Gängel wrote:
> >
> >> Ok so it works, but shouldn't LL(*) distinguish between '.' and
> '..'
> >
> > Arguably yes, but the lookahead in the lexer definitely seems to be
> > biased towards only LL(1) at the moment. Ter said he's going to
look
> > into it sometime.
> >
> >
More information about the antlr-interest
mailing list