thesis: rewrite lexer impl details