Refactored dfa build algorithm in parser module