コード例 #1
0
ファイル: GrammarLexer.cs プロジェクト: genechiaramonte/dsl
	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;
	}
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }