This isn't left factored, it is doing the lookahead that you require to 
distinguish the two. In v4 this will be different, but for now, this is what 
you will need to do.

Or, don't try to do it in the lexer at all and construct parser rules for it.

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Ken Williams
> Sent: Wednesday, June 02, 2010 2:29 PM
> To: [email protected]
> Subject: Re: [antlr-interest] Advice with backtracking/ambiguity
> 
> Jim Idle ([email protected]) wrote:
> 
> > You need:
> >
> > fragment DIGITS : ('0'..'9')+ ;
> > DATE
> > : DIGITS
> >   (
> >       (SLASH DIGITS SLASH DIGITS)=> SLASH DIGITS SLASH DIGITS
> >     | {$type = DIGITS; }
> > ;
> >
> > SLASH : '/' ;
> 
> Thanks.  But it seems like it'll get nasty pretty quick when I put this
> back
> into the "real" grammar I'm working on.  If I have to left-factor
> everything
> I'll be rather confused.
> 
> Is there not a way besides factoring?  In TheBook on page 299 it talks
> about
> "rather than left-factor the grammar, making it less readable...", and
> I
> tend to agree in this case.
> 
> --
> Ken Williams
> Sr. Research Scientist
> Thomson Reuters
> Phone: 651-848-7712
> [email protected]
> 
> 
> 
> 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