MCPcopy Index your code
hub / github.com/antlr/antlr4 / getRuleIndexMap

Method getRuleIndexMap

runtime/JavaScript/src/antlr4/Recognizer.js:71–82  ·  view source on GitHub ↗

* Get a map from rule names to rule indexes. * Used for XPath and tree pattern compilation.

()

Source from the content-addressed store, hash-verified

69 * <p>Used for XPath and tree pattern compilation.</p>
70 */
71 getRuleIndexMap() {
72 const ruleNames = this.ruleNames;
73 if (ruleNames===null) {
74 throw("The current recognizer does not provide a list of rule names.");
75 }
76 let result = this.ruleIndexMapCache[ruleNames]; // todo: should it be Recognizer.ruleIndexMapCache ?
77 if(result===undefined) {
78 result = ruleNames.reduce(function(o, k, i) { o[k] = i; });
79 this.ruleIndexMapCache[ruleNames] = result;
80 }
81 return result;
82 }
83
84 getTokenType(tokenName) {
85 const ttype = this.getTokenTypeMap()[tokenName];

Callers 1

getRuleIndexMethod · 0.45

Calls 1

reduceMethod · 0.45

Tested by

no test coverage detected