[antlr-interest] Problem parsing float numbers
smcfarlin at ocsnet.net
Wed Nov 25 14:58:32 PST 2009
How are you using these lexer rules? Check the parse tree in
ANTLRWorks interpreter or debugger. You should be able to determine
what lexer rule is being used for your input. This works for me with
prog : start* ;
start: NUM | EXP | ENUM ;
fragment DIGIT : '0'..'9' ;
fragment INT : DIGIT + ;
NUM : INT ( '.' INT)? ;
EXP : ( 'E' | 'e' ) ( '-' | '+')? NUM ;
ENUM : NUM ( EXP )? ;
On Nov 25, 2009, at 2:43 PM, Marcel Schaible wrote:
> Hello everybody,
> I have a problem with parsing floating point numbers:
> My grammar contains the following part for recognizing floats:
> fragment DIGIT : '0'..'9' ;
> fragment INT : DIGIT + ;
> NUM : INT ( '.' INT)? ;
> EXP : ( 'E' | 'e' ) ( '-' | '+')? NUM ;
> ENUM : NUM ( EXP )? ;
> When I feed into the parser 1.0 I got the following error message:
> line 1:0 required (...)+ loop did not match anything at input '1.0'
> I did not see the problem. Any ideas and comments are welcome!
> Thanks in advance for your help.
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest