tokenTypeMap property

Map<String, int> get tokenTypeMap
inherited

Get a map from token names to token types.

Used for XPath and tree pattern compilation.

Implementation

Map<String, int> get tokenTypeMap {
  final _vocabulary = vocabulary;

  var result = tokenTypeMapCache[_vocabulary];
  if (result == null) {
    result = {};
    for (var i = 0; i <= getATN().maxTokenType; i++) {
      final literalName = _vocabulary.getLiteralName(i);
      if (literalName != null) {
        result[literalName] = i;
      }

      final symbolicName = _vocabulary.getSymbolicName(i);
      if (symbolicName != null) {
        result[symbolicName] = i;
      }
    }

    result['EOF'] = Token.EOF;
    result = Map.unmodifiable(result);
    tokenTypeMapCache[_vocabulary] = result;
  }

  return result;
}