memoize lexer and add debug stats