{"record":{"id":"361d230f754ae149","repo":"antlr/antlr4","slug":"the-current-recognizer-does-not-provide-a-list-of-361d23","errorCode":null,"errorMessage":"The current recognizer does not provide a list of rule names.","messagePattern":"The current recognizer does not provide a list of rule names\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"runtime/CSharp/src/Recognizer.cs","lineNumber":108,"sourceCode":"            }\n            result[\"EOF\"] = TokenConstants.EOF;\n            return result;\n        }\n\n        /// <summary>Get a map from rule names to rule indexes.</summary>\n        /// <remarks>\n        /// Get a map from rule names to rule indexes.\n        /// <p>Used for XPath and tree pattern compilation.</p>\n        /// </remarks>\n        [NotNull]\n        public virtual IDictionary<string, int> RuleIndexMap\n        {\n            get\n            {\n                string[] ruleNames = RuleNames;\n                if (ruleNames == null)\n                {\n                    throw new NotSupportedException(\"The current recognizer does not provide a list of rule names.\");\n                }\n\n                return ruleIndexMapCache.GetValue(ruleNames, Utils.ToMap);\n            }\n        }\n\n        public virtual int GetTokenType(string tokenName)\n        {\n            int ttype;\n            if (TokenTypeMap.TryGetValue(tokenName, out ttype))\n            {\n                return ttype;\n            }\n            return TokenConstants.InvalidType;\n        }\n\n        /// <summary>\n        /// If this recognizer was generated, it will have a serialized ATN","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/runtime/CSharp/src/Recognizer.cs#L90-L126","documentation":"Error \"The current recognizer does not provide a list of rule names.\" thrown in antlr/antlr4.","triggerScenarios":"Recognizer.RuleNames accessed on a recognizer subclass that does not expose rule names.","commonSituations":"Override RuleNames in generated recognizers; do not call it on a bare Recognizer.","solutions":["Provide rule names: use a generated parser (which supplies RuleNames) instead of a bare Recognizer, or construct the recognizer subclass that defines rule names.","Check the recognizer type before asking for rule names and handle the unsupported case."],"exampleFix":"// use the generated parser whose RuleNames array is populated\nvar parser = new MyGrammarParser(tokens);","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}