* Get a map from rule names to rule indexes. * Used for XPath and tree pattern compilation.
()
| 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]; |