[antlr-interest] Advice with backtracking/ambiguity
Ken Williams
ken.williams at thomsonreuters.com
Wed Jun 2 14:29:03 PDT 2010
Jim Idle (ji... at temporal-wave.com) 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
ken.williams at thomsonreuters.com
More information about the antlr-interest
mailing list