[antlr-interest] a simple (not for me :)) grammar problem
Jim Idle
jimi at temporal-wave.com
Tue Jan 8 10:07:30 PST 2008
I think that the trick you are looking for is:
grammar harry;
start
: (number_stuff)+
;
number_stuff
: (FLOAT | NUMBER) (DOT ID)?
;
ID
: ('a'..'z' | 'A'..'Z')+
;
fragment
FLOAT
: '0'..'9'+ '.' '0'..'9'
;
NUMBER
: ('0'..'9')+
(
('.' '0'..'9')=> ('.' ('0'..'9')+)
{ $type = FLOAT; }
|// Just an integer
)
;
DOT
: '.'
;
OTHER
: . {$channel = HIDDEN; }
;
If whitespace is significant to the parser then pass it back of course.
Jim
> -----Original Message-----
> From: Mark Volkmann [mailto:r.mark.volkmann at gmail.com]
> Sent: Monday, January 07, 2008 3:58 PM
> To: Fırat Küçük
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] a simple (not for me :)) grammar problem
>
> I have at least a partial answer to my own question.
> The generated lexer class contains the method mToken which throws a
More information about the antlr-interest
mailing list