Re: grammar q



Per Freem wrote:
hi

suppose we have the following grammar:

r -> sr | s
s -> b | Eps | r

where Eps represents the empty string.. is it ambiguous? i can see a
leftmost derivation of 'b':

r=>s=>b

and a leftmost derivation of bEps

r=>sr=>br=>bs=>bEps

but does that count as two distinct leftmost derivations for the same
string? we normally think b and bEps are the same, since Eps is just
empty but for this purpose are they considered so?

yes it is considered ambiguous because b and bEps are the same.
.