[antlr-interest] Re: Lexer rules for numbers and intervals

Peggy Fieland madcapmaggie at yahoo.com
Thu Aug 5 08:23:09 PDT 2004


Try doing the same thing for floating numbers that I
did for integers.
I also had to add some extra cases like
  (integer dot dot integer) => integer dot dot
integer,

etc before I got everything to work.

Check the generated code for the parser.


--- beckersheinzsb <beckersheinzsb at yahoo.com> wrote:

> thanks for your effort
> 
> but the problem is, that I've not only integers but
> also floating 
> point values which use the dot as decimal point.
> 
> That means that 1.5..4.6 should also be possible.
> 
> If I try to pars 5..6 the lexer splits this into 5.
> and .6
> and then then the parser throws an exception.
> 
> Heinz
> 
> --- In antlr-interest at yahoogroups.com, Peggy Fieland
> 
> <madcapmaggie at y...> wrote:
> > 
> > Yes,
> > 
> > I added:
> > 
> > protected DOT_DOT:  "..";
> > to the lexer and
> > 
> > interval:
> >    variable DOT_DOT variable
> > to the parser
> > This works fine for variables.
> > I ended up with:
> > 
> > (   integer DOT DOT integer ) => integer DOT DOT
> > integer
> > 
> > for the integer ranges. 
> > 
> > Peggy
> > 
> > --- beckersheinzsb <beckersheinzsb at y...> wrote:
> > 
> > > Hello
> > > 
> > > I have the following rules in my lexer:
> > > 
> > > protected
> > > DOT     :   '.'        ;
> > > 
> > > protected
> > > DIGIT   :   '0'..'9'   ;
> > > 
> > > NUMBER  : (DOT (DIGIT)+)
> > >         | (DIGIT)+ (DOT (DIGIT)*)?;
> > > 
> > > 
> > > This piece works fine but now i want to add
> > > intervals, e.g. 5..9
> > > If I try to define a rule like
> > > 
> > > INTERVAL_SIGN  : DOT DOT ;
> > > 
> > > I get a nondeterminism.
> > > 
> > > I see that it is difficult to distinguish
> between
> > > the second subrule 
> > > of NUMBER and an interval 5..9 (NUMBER
> INTERVAL_SIGN
> > > NUMBER). Do I 
> > > have to left-factor? 
> > > Or is there a possibility to achieve that the
> lexer
> > > recognizes two 
> > > following dots as an interval sign at all?
> > > 
> > > Could you please give me a hint
> > > 
> > > thanks a lot
> > > greets
> > > 
> > > heinz
> > > 
> > > 
> > > 
> > > 
> > > 
> > >  
> > > Yahoo! Groups Links
> > > 
> > > 
> > >     antlr-interest-unsubscribe at yahoogroups.com
> > > 
> > >  
> > > 
> > > 
> > 
> > 
> > 
> > 		
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - 50x more storage than other
> providers!
> > http://promotions.yahoo.com/new_mail
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
>     antlr-interest-unsubscribe at yahoogroups.com
> 
>  
> 
> 



		
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list