How come this grammar is unambiguous?

78 Views Asked by At

Equivalent unambiguous grammar: \begin{align} S &\rightarrow ABA|AB|BA|A|B \\ A &\rightarrow aA | a \\ B &\rightarrow aB|b \end{align}

an unambiguous language has only one parse tree, but there are two parse trees for the grammar above:

$ABA > ABa > aBa > aba$

$ABA > aBA > abA > aba$

1

There are 1 best solutions below

0
On

It's not about the grammar, it's about the strings. If you see aaba there's only one way to parse it: aa is A, b is B, a is A, and the aaba = ABA is S.