Define an unambiguous contextfree grammar in BNF capable of
Define an unambiguous context-free grammar in BNF capable of generating only palindromes of binary numbers. A palindrome is a string which reads the same forward as backward. For example, the strings 0, 1,00, 11, 101, and 100101001 are palindromes while the strings 10, 01, and 10101010 are not. The empty string is not in this language
Solution
The grammar for the given question is
S-> 0S0|1S1
S-> 0|1|00|11
The given grammar will accept strings like 0, 1, 00, 11, 101, and 100101001. and is unambiguous because every string has unique leftmost derivation.
