Antlr4.Tool.Grammar.SetTokenForType C# (CSharp) Method

SetTokenForType() public method

public SetTokenForType ( int ttype, string text ) : void
ttype int
text string
return void
        public virtual void SetTokenForType(int ttype, string text)
        {
            if (ttype == TokenConstants.Eof)
            {
                // ignore EOF, it will be reported as an error separately
                return;
            }

            if (ttype >= typeToTokenList.Count)
            {
                Utils.SetSize(typeToTokenList, ttype + 1);
            }
            string prevToken = typeToTokenList[ttype];
            if (prevToken == null || prevToken[0] == '\'')
            {
                // only record if nothing there before or if thing before was a literal
                typeToTokenList[ttype] = text;
            }
        }