Refactor lexer