Implement the tokenize method in class Lexer