[antlr-interest] Please advice about float

Gevik babakhani gevik at xs4all.nl
Mon Sep 19 07:06:43 PDT 2005


Dear all,

 

I would like to parse integers and simple floats without exponents. Is this
the correct grammar?

 

class MyLexer extends Lexer;

options {

            k=2;

}

                                                                        

NUMBER          :           INT ((FLOAT)?)

                        ;

protected

FLOAT              : ('.' INT)

                        ;

protected

INT                   :           (DIGIT)+

                        ;

 


protected                                               

DIGIT                :           '0'..'9'

                        ;

 

WS     :

    (' ' 

    | '\t' 

    | '\r' '\n' { newline(); } 

    | '\n'      { newline(); }

    ) 

    { $setType(Token.SKIP); } 

  ;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050919/2787c1c6/attachment.html


More information about the antlr-interest mailing list