2

There is a grammar G given:

    S->XaX
    X->aX|bX|eps

I just replied to the first question that was about showing that this grammar is ambiguous. The second question is to find an unambiguous equivalent grammar of this grammar given. I don't really know how to do it or from where to start. Can anyone help me?

Annie
  • 21
  • 1

1 Answers1

1

Your language consists of all words over $\{a,b\}$ which contain $a$. This is a regular language, and so it has an unambiguous regular grammar - essentially a DFA - which is not so difficult to construct for this language. Regular grammars constructed from DFAs are unambiguous, so this would be an unambiguous grammar for the same language.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514