001/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
002/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
003/*
004 *   Copyright (C) 2005 Christian Schulte <cs@schulte.it>
005 *   All rights reserved.
006 *
007 *   Redistribution and use in source and binary forms, with or without
008 *   modification, are permitted provided that the following conditions
009 *   are met:
010 *
011 *     o Redistributions of source code must retain the above copyright
012 *       notice, this list of conditions and the following disclaimer.
013 *
014 *     o Redistributions in binary form must reproduce the above copyright
015 *       notice, this list of conditions and the following disclaimer in
016 *       the documentation and/or other materials provided with the
017 *       distribution.
018 *
019 *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
020 *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
021 *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
022 *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
023 *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
024 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
025 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
026 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
028 *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 *
030 *   $JOMC: VersionParser.jj 5091 2016-04-04 15:40:17Z schulte $
031 *
032 */
033package org.jomc.util;
034
035/**
036 * Describes the input token stream.
037 */
038
039public class Token implements java.io.Serializable {
040
041  /**
042   * The version identifier for this Serializable class.
043   * Increment only if the <i>serialized</i> form of the
044   * class changes.
045   */
046  private static final long serialVersionUID = 1L;
047
048  /**
049   * An integer that describes the kind of this token.  This numbering
050   * system is determined by JavaCCParser, and a table of these numbers is
051   * stored in the file ...Constants.java.
052   */
053  public int kind;
054
055  /** The line number of the first character of this Token. */
056  public int beginLine;
057  /** The column number of the first character of this Token. */
058  public int beginColumn;
059  /** The line number of the last character of this Token. */
060  public int endLine;
061  /** The column number of the last character of this Token. */
062  public int endColumn;
063
064  /**
065   * The string image of the token.
066   */
067  public String image;
068
069  /**
070   * A reference to the next regular (non-special) token from the input
071   * stream.  If this is the last token from the input stream, or if the
072   * token manager has not read tokens beyond this one, this field is
073   * set to null.  This is true only if this token is also a regular
074   * token.  Otherwise, see below for a description of the contents of
075   * this field.
076   */
077  public Token next;
078
079  /**
080   * This field is used to access special tokens that occur prior to this
081   * token, but after the immediately preceding regular (non-special) token.
082   * If there are no such special tokens, this field is set to null.
083   * When there are more than one such special token, this field refers
084   * to the last of these special tokens, which in turn refers to the next
085   * previous special token through its specialToken field, and so on
086   * until the first special token (whose specialToken field is null).
087   * The next fields of special tokens refer to other special tokens that
088   * immediately follow it (without an intervening regular token).  If there
089   * is no such token, this field is null.
090   */
091  public Token specialToken;
092
093  /**
094   * An optional attribute value of the Token.
095   * Tokens which are not used as syntactic sugar will often contain
096   * meaningful values that will be used later on by the compiler or
097   * interpreter. This attribute value is often different from the image.
098   * Any subclass of Token that actually wants to return a non-null value can
099   * override this method as appropriate.
100   */
101  public Object getValue() {
102    return null;
103  }
104
105  /**
106   * No-argument constructor
107   */
108  public Token() {}
109
110  /**
111   * Constructs a new token for the specified Image.
112   */
113  public Token(int kind)
114  {
115    this(kind, null);
116  }
117
118  /**
119   * Constructs a new token for the specified Image and Kind.
120   */
121  public Token(int kind, String image)
122  {
123    this.kind = kind;
124    this.image = image;
125  }
126
127  /**
128   * Returns the image.
129   */
130  public String toString()
131  {
132    return image;
133  }
134
135  /**
136   * Returns a new Token object, by default. However, if you want, you
137   * can create and return subclass objects based on the value of ofKind.
138   * Simply add the cases to the switch for all those special cases.
139   * For example, if you have a subclass of Token called IDToken that
140   * you want to create if ofKind is ID, simply add something like :
141   *
142   *    case MyParserConstants.ID : return new IDToken(ofKind, image);
143   *
144   * to the following switch statement. Then you can cast matchedToken
145   * variable to the appropriate type and use sit in your lexical actions.
146   */
147  public static Token newToken(int ofKind, String image)
148  {
149    switch(ofKind)
150    {
151      default : return new Token(ofKind, image);
152    }
153  }
154
155  public static Token newToken(int ofKind)
156  {
157    return newToken(ofKind, null);
158  }
159
160}
161/* JavaCC - OriginalChecksum=ff07e18e294bee4dd154be05a0ab2859 (do not edit this line) */