Find a grammar for the following language:
a*b | a
(a*b | b*a)*
I think I have the answer for 1 (S -> aS | b) but I'm pretty confused on the second one. Any help would be greatly appreciated.
Language; (ab | ba)*
S -> SA | epsilon
A here represents (ab | ba)
A -> B
A -> C
B represents (a*b)
B -> [Insert rule here]
C represents (b*a)
C -> [Insert rule here]