Refactor lexical analyzer: use table of states