[antlr-interest] about range float and stuff

Jim Idle jimi at temporal-wave.com
Fri Nov 4 09:32:21 PDT 2011


Please re-read the lexer rules, or better still run them. The DOTDOT lexer
token type just returns the '..' and not the numbers to either side.


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Fabien Hermenier
> Sent: Thursday, November 03, 2011 11:29 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] about range float and stuff
>
> Hi
>
> In an earlier version of my language, I had to parse range of integers
> in various base. Now I want to include float. I have read
> http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+poi
> nt,+dot,+range,+time+specs
> but I've still got some questions.
>
> All the work seems to be done at the lexer level so the type of the
> following tokens will be as example:
> 5 : DECIMAL_LITTERAL
> 07 : OCTAL_LITTERAL
> 7.5: FLOATING_POINT_LITTERAL
> 5..7 : DOTDOT
>
> In the last example, the result is not very convenient because I will
> still have to extract the bounds and compute their type by myself which
> seems quite redundant with the job performed by the lexer.
> May be I am missing something ?
>
> I would rather be able to express the range at the parser level which
> seems much more convenient to me:
> range: FLOATING_POINT_LITTERAL DOTDOT FLOATING_POINT_LITTERAL.
> In this way, I will also be able to manage the possible spaces between
> the bounds and the DOTDOT.
>
> So, am I right to try to parse range at the parser level ? Or is there
> a solution to extract easily the bounds with their type if I am doing
> the job at the lexer level ?
>
> Thanks in advance,
> Fabien.
>
>
>
>
> 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