Theory of Formal Languages With Applications