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