Your grammar allows aaba
, which it shouldn't, as there should always be a even number of a
s:
ABCD
aABCD
aaBCD
aabCD
aabaD
aaba
A correct answer would be:
Start → A B
A → a A a | B
B → bB | ε
B
generates any number ofb
s (including none).A
is a sequence ofa
, followed byB
, followed by the same number ofa