Added a simple DFA simulator function.