Lexer implementation