Antlr4.Runtime.CommonToken.CommonToken C# (CSharp) Method

CommonToken() public method

Constructs a new CommonToken as a copy of another IToken .

If oldToken is also a CommonToken instance, the newly constructed token will share a reference to the Text() field and the Tuple{T1, T2} stored in source . Otherwise, Text() will be assigned the result of calling Text() , and source will be constructed from the result of IToken.TokenSource() and IToken.InputStream() .

public CommonToken ( IToken oldToken ) : System
oldToken IToken The token to copy.
return System
        public CommonToken(IToken oldToken)
        {
            _type = oldToken.Type;
            _line = oldToken.Line;
            index = oldToken.TokenIndex;
            charPositionInLine = oldToken.Column;
            _channel = oldToken.Channel;
            start = oldToken.StartIndex;
            stop = oldToken.StopIndex;
            if (oldToken is Antlr4.Runtime.CommonToken)
            {
                _text = ((Antlr4.Runtime.CommonToken)oldToken)._text;
                source = ((Antlr4.Runtime.CommonToken)oldToken).source;
            }
            else
            {
                _text = oldToken.Text;
                source = Tuple.Create(oldToken.TokenSource, oldToken.InputStream);
            }
        }

Same methods

CommonToken::CommonToken ( ICharStream>.Tuple source, int type, int channel, int start, int stop ) : System
CommonToken::CommonToken ( int type ) : System
CommonToken::CommonToken ( int type, string text ) : System