Provide a base class for text modes as well.

Moved config to GrammarConfig and made it as agnostic as possible.