001/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
002/**
003 *
004 * Licensed to the Apache Software Foundation (ASF) under one or more
005 * contributor license agreements.  See the NOTICE file distributed with
006 * this work for additional information regarding copyright ownership.
007 * The ASF licenses this file to You under the Apache License, Version 2.0
008 * (the "License"); you may not use this file except in compliance with
009 * the License.  You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.granite.gravity.selector;
021
022/**
023 * Describes the input token stream.
024 */
025public class Token {
026
027  /**
028   * An integer that describes the kind of this token.  This numbering
029   * system is determined by JavaCCParser, and a table of these numbers is
030   * stored in the file ...Constants.java.
031   */
032  public int kind;
033
034  /**
035   * beginLine and beginColumn describe the position of the first character
036   * of this token; endLine and endColumn describe the position of the
037   * last character of this token.
038   */
039  public int beginLine, beginColumn, endLine, endColumn;
040
041  /**
042   * The string image of the token.
043   */
044  public String image;
045
046  /**
047   * A reference to the next regular (non-special) token from the input
048   * stream.  If this is the last token from the input stream, or if the
049   * token manager has not read tokens beyond this one, this field is
050   * set to null.  This is true only if this token is also a regular
051   * token.  Otherwise, see below for a description of the contents of
052   * this field.
053   */
054  public Token next;
055
056  /**
057   * This field is used to access special tokens that occur prior to this
058   * token, but after the immediately preceding regular (non-special) token.
059   * If there are no such special tokens, this field is set to null.
060   * When there are more than one such special token, this field refers
061   * to the last of these special tokens, which in turn refers to the next
062   * previous special token through its specialToken field, and so on
063   * until the first special token (whose specialToken field is null).
064   * The next fields of special tokens refer to other special tokens that
065   * immediately follow it (without an intervening regular token).  If there
066   * is no such token, this field is null.
067   */
068  public Token specialToken;
069
070  /**
071   * Returns the image.
072   */
073  @Override
074  public String toString()
075  {
076     return image;
077  }
078
079  /**
080   * Returns a new Token object, by default. However, if you want, you
081   * can create and return subclass objects based on the value of ofKind.
082   * Simply add the cases to the switch for all those special cases.
083   * For example, if you have a subclass of Token called IDToken that
084   * you want to create if ofKind is ID, simlpy add something like :
085   *
086   *    case MyParserConstants.ID : return new IDToken();
087   *
088   * to the following switch statement. Then you can cast matchedToken
089   * variable to the appropriate type and use it in your lexical actions.
090   */
091  public static final Token newToken(int ofKind)
092  {
093     switch(ofKind)
094     {
095       default : return new Token();
096     }
097  }
098
099}