MCPcopy Create free account
hub / github.com/antlr/antlr4 / getTokenTypeMap

Method getTokenTypeMap

runtime/JavaScript/src/antlr4/Recognizer.js:53–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51 }
52
53 getTokenTypeMap() {
54 const tokenNames = this.getTokenNames();
55 if (tokenNames===null) {
56 throw("The current recognizer does not provide a list of token names.");
57 }
58 let result = this.tokenTypeMapCache[tokenNames];
59 if(result===undefined) {
60 result = tokenNames.reduce(function(o, k, i) { o[k] = i; });
61 result.EOF = Token.EOF;
62 this.tokenTypeMapCache[tokenNames] = result;
63 }
64 return result;
65 }
66
67 /**
68 * Get a map from rule names to rule indexes.

Callers 1

getTokenTypeMethod · 0.95

Calls 2

getTokenNamesMethod · 0.95
reduceMethod · 0.45

Tested by

no test coverage detected