Lucene.Net.QueryParsers.Surround.Parser.Token.NewToken C# (CSharp) Method

NewToken() public static method

Returns a new Token object, by default. However, if you want, you can create and return subclass objects based on the value of ofKind. Simply add the cases to the switch for all those special cases. For example, if you have a subclass of Token called IDToken that you want to create if ofKind is ID, simply add something like : case MyParserConstants.ID : return new IDToken(ofKind, image); to the following switch statement. Then you can cast matchedToken variable to the appropriate type and use sit in your lexical actions.
public static NewToken ( int ofKind, string image ) : Token
ofKind int
image string
return Token
		public static Token NewToken(int ofKind, string image)
		{
			switch (ofKind)
			{
				default:  return new Token(ofKind, image);
			}
		}
		

Same methods

Token::NewToken ( int ofKind ) : Token

Usage Example

Ejemplo n.º 1
0
        protected Token JjFillToken()
        {
            Token  t;
            string curTokenImage;
            int    beginLine;
            int    endLine;
            int    beginColumn;
            int    endColumn;
            string im = jjstrLiteralImages[jjmatchedKind];

            curTokenImage = (im == null) ? m_input_stream.Image : im;
            beginLine     = m_input_stream.BeginLine;
            beginColumn   = m_input_stream.BeginColumn;
            endLine       = m_input_stream.EndLine;
            endColumn     = m_input_stream.EndColumn;
            t             = Token.NewToken(jjmatchedKind, curTokenImage);

            t.BeginLine   = beginLine;
            t.EndLine     = endLine;
            t.BeginColumn = beginColumn;
            t.EndColumn   = endColumn;

            return(t);
        }