Lexeme.define returns an instance. Do not use Lexeme.analyze from now on, use the instance after #define. e.g. lexer = Lexeme.define and then lexer.analyze