001/** 002 * Unit-API - Units of Measurement API for Java 003 * Copyright (c) 2005-2015, 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 Unit-API 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 systems.uom.ucum.internal.format; 033 034/** 035 * Describes the input token stream. 036 * 037 * @version 0.5.2, August 8, 2015 038 */ 039 040public final class Token { 041 042 /** 043 * The Serialization identifier for this class. 044 * Increment only if the <i>serialized</i> form of the 045 * class changes. 046 */ 047// private static final long serialVersionUID = 2188279658897600591L; 048 049 /** 050 * An integer that describes the kind of this token. This numbering 051 * system is determined by JavaCCParser, and a table of these numbers is 052 * stored in the file ...Constants.java. 053 */ 054 public int kind; 055 056 /** The line number of the first character of this Token. */ 057 public int beginLine; 058 /** The column number of the first character of this Token. */ 059 public int beginColumn; 060 /** The line number of the last character of this Token. */ 061 public int endLine; 062 /** The column number of the last character of this Token. */ 063 public int endColumn; 064 065 /** 066 * The string image of the token. 067 */ 068 public String image; 069 070 /** 071 * A reference to the next regular (non-special) token from the input 072 * stream. If this is the last token from the input stream, or if the 073 * token manager has not read tokens beyond this one, this field is 074 * set to null. This is true only if this token is also a regular 075 * token. Otherwise, see below for a description of the contents of 076 * this field. 077 */ 078 public Token next; 079 080 /** 081 * This field is used to access special tokens that occur prior to this 082 * token, but after the immediately preceding regular (non-special) token. 083 * If there are no such special tokens, this field is set to null. 084 * When there are more than one such special token, this field refers 085 * to the last of these special tokens, which in turn refers to the next 086 * previous special token through its specialToken field, and so on 087 * until the first special token (whose specialToken field is null). 088 * The next fields of special tokens refer to other special tokens that 089 * immediately follow it (without an intervening regular token). If there 090 * is no such token, this field is null. 091 */ 092 public Token specialToken; 093 094 /** 095 * An optional attribute value of the Token. 096 * Tokens which are not used as syntactic sugar will often contain 097 * meaningful values that will be used later on by the compiler or 098 * interpreter. This attribute value is often different from the image. 099 * Any subclass of Token that actually wants to return a non-null value can 100 * override this method as appropriate. 101 */ 102 public Object getValue() { 103 return null; 104 } 105 106 /** 107 * No-argument constructor 108 */ 109 public Token() {} 110 111 /** 112 * Constructs a new token for the specified Image. 113 */ 114 public Token(int kind) 115 { 116 this(kind, null); 117 } 118 119 /** 120 * Constructs a new token for the specified Image and Kind. 121 */ 122 public Token(int kind, String image) 123 { 124 this.kind = kind; 125 this.image = image; 126 } 127 128 /** 129 * Returns the image. 130 */ 131 public String toString() 132 { 133 return image; 134 } 135 136 /** 137 * Returns a new Token object, by default. However, if you want, you 138 * can create and return subclass objects based on the value of ofKind. 139 * Simply add the cases to the switch for all those special cases. 140 * For example, if you have a subclass of Token called IDToken that 141 * you want to create if ofKind is ID, simply add something like : 142 * 143 * case MyParserConstants.ID : return new IDToken(ofKind, image); 144 * 145 * to the following switch statement. Then you can cast matchedToken 146 * variable to the appropriate type and use sit in your lexical actions. 147 */ 148 public static Token newToken(int ofKind, String image) 149 { 150 switch(ofKind) 151 { 152 default : return new Token(ofKind, image); 153 } 154 } 155 156 public static Token newToken(int ofKind) 157 { 158 return newToken(ofKind, null); 159 } 160 161} 162/* JavaCC - OriginalChecksum=08d08345e10cca30522247698d4478e6 (do not edit this line) */