[antlr-interest] non-determinism warning

Tarun Khanna tkhanna at redhat.com
Wed Jul 6 06:34:21 PDT 2005


Hi Terence, Monty

Thanks...for your help.

I am new to ANTLR and I am trying to learn to play with this neat tool.
The only reason I said I wanted k=1 was, because I wanted to know if
there is a standard way of solving this problem by using some sort of
predicate or something similar to left-factoring.

However I guess k>1 is the way to go in such situations, as has been
suggested in the replies.

Thanks again for your time and advice....

I'll throw in some more questions pretty soon...

Tarun
On Tue, 2005-07-05 at 15:16 -0700, Terence Parr wrote:
> On Jul 5, 2005, at 12:13 PM, Monty Zukowski wrote:
> 
> > Monty Zukowski wrote:
> >
> >
> >> Otherwise you could keep your own state and do something like
> >>
> >>  (DOT
> >>    {!tabMatched}?(IDENT|TAB{tabMatched=true;})
> >>    | (SOME_IMAGINARY_TOKEN_THAT_YOUR_LEXER_NEVER_PRODUCES)
> >>  )*
> >>
> >>
> >
> > OK, I'm not used to thinking of stuff with k=1.  My example won't  
> > work.
> >   It's a neat trick, but not the right one :)
> >
> > Convince me of a good reason not to use k=2 and I'll put some more
> > thought into it.
> 
> The language is not LL(1)...no way to avoid k>1.  If you see DOT, you  
> just don't know what to pick.
> 
> Ter
> --
> CS Professor & Grad Director, University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Cofounder, http://www.jguru.com
> 



More information about the antlr-interest mailing list