private static string[] GenerateTokenNames(IVocabulary vocabulary, int length) { string[] tokenNames = new string[length]; for (int i = 0; i < tokenNames.Length; i++) { tokenNames[i] = vocabulary.GetLiteralName(i); if (tokenNames[i] == null) { tokenNames[i] = vocabulary.GetSymbolicName(i); } if (tokenNames[i] == null) { tokenNames[i] = "<INVALID>"; } } return tokenNames; }
private static string[] GenerateTokenNames(IVocabulary vocabulary, int length) { string[] tokenNames = new string[length]; for (int i = 0; i < tokenNames.Length; i++) { tokenNames[i] = vocabulary.GetLiteralName(i); if (tokenNames[i] == null) { tokenNames[i] = vocabulary.GetSymbolicName(i); } if (tokenNames[i] == null) { tokenNames[i] = "<INVALID>"; } } return(tokenNames); }
protected virtual IDictionary <string, int> CreateTokenTypeMap(IVocabulary vocabulary) { var result = new Dictionary <string, int>(); for (int i = 0; i <= Atn.maxTokenType; i++) { string literalName = vocabulary.GetLiteralName(i); if (literalName != null) { result[literalName] = i; } string symbolicName = vocabulary.GetSymbolicName(i); if (symbolicName != null) { result[symbolicName] = i; } } result["EOF"] = TokenConstants.EOF; return(result); }