[antlr-interest] Lexer rules for numbers and intervals
Peggy Fieland
madcapmaggie at yahoo.com
Thu Aug 5 07:33:31 PDT 2004
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 yahoo.com> 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
<*> 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