[antlr-interest] Can someone please explain

Silvain Piree s.piree at enneya.com
Fri Jun 21 06:43:45 PDT 2002


Bals,

do I understand correctly that First(B) means the tokens
that can follow B?

The grammar rule I mentioned is the full grammar!

    rule:    A (B)? C D E       |     A (B)? C D F   ;
    First(B) = 'C'
    First(C) = 'D'
    Intersection = null

Silvain

>  It might be the case in ur grammar that intersection of
> First(B) and First(C) is not null.
>
> > I understand the solution, but I don't understand the problem!
> >
> > Why is making a token optional in both subrules producing
> > a conflict that can not be resolved with regular lookahead?
> >
> > Silvain
> >
> > >  Use syntactic predicate like this
> > >
> > >  (A(B)?)=>A(B)?
> > >
> > > It will remove the warnings but I'm not sure about run time
> > > behaviour... and not sure if you add some new production,
> > > whether i will work or not.
> > >
> > > > I'm getting nondeterminism warnings on my grammar but
> > > > I don't understand why.
> > > >
> > > > Following rule does not cause a problem when using k=5:
> > > >
> > > > rule:    A B C D E       |     A B C D F   ;
> > > >
> > > > But, when I make the B optional then I get a nondeterminism
> > > > warning regardless of lookahead 'k':
> > > >
> > > > rule:    A (B)? C D E       |     A (B)? C D F   ;
> > > >
> > > > Any suggestions would be much appreciated,
> > > >
> > > > Silvain
> >
> >
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list