# What would be CFG for all strings which does not contain bbb?

Is there a way to get complement? Following is my solution for CFG of all strings that DON'T contain bbb.

S -> aA | aaB | aB | bA | bbA
A -> aA| aB
A -> epsilon
B -> bA | bbA
B -> epsilon


Is this right?

• The answer-checking part of your question is off-topic since saying "yes" or "no" isn't much use to you and is very unlikely to be useful to anyone else in the future. Please read related meta discussions here and here and adjust your question accordingly, e.g. by formulating a specific question about a single element of your answer you are uncertain about. – David Richerby Jun 11 '15 at 12:18
• Are you sure you want "context-free"? Your language and your grammar are regular (well, at least you could easily make them regular). – john_leo Jun 11 '15 at 14:03
• The empty word $\epsilon$ is in your language since it does not contain $bbb$, but your grammar does not allow for it. – babou Jun 11 '15 at 16:27