Write a BNF grammar for recognizing all sentences in the form of anbn-2, where n>1.
For example, aa, aaab, aaaabb are all accepted,
but abbb, aab, aabb are not
(Hint: use recursion).
This is my derivation:
S ::= AZ
Z ::= A | AAB
A ::= a
B ::= b
Is this correct?
EDIT: Maybe this is correct?
S -> a | X | Y
X-> aX | a
Y -> aX | b