> > S -> M | U> > M -> iEtMeM | a> > U -> iEtS
is really close to the unambiguous grammar. The only place you went wrong
is that the M rule is off just a bit. It should be
M -> iEtMeU
Since a one-armed if can be hung off the Else clause of a two-armed If with
no ambiguity.

> Linlist Leo <linlist@fudan.edu> schreef> > It is well-known the following grammar is ambiguous so that it is> > not LR(k) for any k.> > S -> iEtSeS | iEtS | a> > ('a' is not important, maybe just some assigning statement)> >> > But it can be written in an umambiguous way. I devised the following> > grammar(maybe incorrect).> > S -> M | U> > M -> iEtMeM | a> > U -> iEtS> >> > I guess it LR(1). Any correction will be welcomed.