# Defining a regular grammar but without $Q \rightarrow \varepsilon$

I defined a regular grammar (FSM), which starts with $$ab$$ and ends with $$ba$$ the following way:

1. $$S \rightarrow aS$$
2. $$S \rightarrow bS$$
3. $$S \rightarrow aT$$
4. $$T \rightarrow bR$$
5. $$R \rightarrow aQ$$
6. $$Q \rightarrow aQ$$
7. $$Q \rightarrow bQ$$
8. $$Q \rightarrow \epsilon$$

, where $$S$$ is the starting element, $$\epsilon$$ is the empty (null) element and the rest are just variables.

The rules 6, 7 and 8 are there, so we can end a word. However, I am trying to rewrite my grammer but without the $$Q \rightarrow \epsilon$$. I can’t use the empty element.

Can it be done? I’m not sure how.

Thanks