implemeting a DFA for recognizing regular expressions.