I'm trying to find CFG's that generate a regular language over the alphabet {a b}
I believe I got this one right: All strings that end in b and have an even number of b's in total:
$\qquad S \to SS \\ \qquad S \to YbYb \mid \varepsilon \\ \qquad Y \to aY \mid \varepsilon$
However, Im not sure how to accomplish this with an odd number of b's.
So for example, how could I find a CFG that generates all strings that end in b and have an odd number of b's in total: So far I have this,
$\qquad S \to SS \\ \qquad S \to YYb \mid \varepsilon \\ \qquad Y \to abY \mid baY \mid \varepsilon$
But this can generate abababb so it's incorrect and Im stumped at this point.