And turn of the backtracking option of course..

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Jim Idle
> Sent: Wednesday, June 02, 2010 1:11 PM
> To: [email protected]
> Subject: Re: [antlr-interest] Advice with backtracking/ambiguity
> 
> Remember antlr.markmail.org as it will give you lots of examples of
> this. You need:
> 
> fragment DIGITS : ('0'..'9')+ ;
> DATE
> : DIGITS
>   (
>       (SLASH DIGITS SLASH DIGITS)=> SLASH DIGITS SLASH DIGITS
>     | {$type = DIGITS; }
> ;
> 
> SLASH : '/' ;
> 
> Jim
> 
> > -----Original Message-----
> > From: [email protected] [mailto:antlr-interest-
> > [email protected]] On Behalf Of Ken Williams
> > Sent: Wednesday, June 02, 2010 1:04 PM
> > To: [email protected]
> > Subject: [antlr-interest] Advice with backtracking/ambiguity
> >
> > Hi,
> >
> > Here's a simple grammar demonstrating something I'm working with:
> >
> > ------------------------------
> > grammar testg;
> >
> > options {
> >     backtrack=true;
> >     memoize=true;
> >     output=AST;
> > }
> >
> > cite    :    token+ EOF ;
> >
> > token    :    DATE | SLASH | DIGITS ;
> >
> > DATE    :    DIGITS SLASH DIGITS SLASH DIGITS ;
> >
> > WS    :    ( ' ' | '\t'| '\f' | '\n' | '\r' ) {skip();} ;
> >
> > SLASH    :    '/' ;
> > DIGITS    :    ('0'..'9')+ ;
> > --------------------------------
> >
> >
> > As you can see, there's an ambiguity with DATE.  What I'm trying to
> do
> > is to
> > use the DATE rule when it can succeed, and use DATE & SLASH
> otherwise.
> 
> 
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address




List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to