1 /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ 2 /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ 3 /* 4 * Copyright 2010-2011 The 99 Software Foundation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.nnsoft.commons.bspi; 19 20 /** 21 * Describes the input token stream. 22 */ 23 24 public class Token implements java.io.Serializable { 25 26 /** 27 * The version identifier for this Serializable class. 28 * Increment only if the <i>serialized</i> form of the 29 * class changes. 30 */ 31 private static final long serialVersionUID = 1L; 32 33 /** 34 * An integer that describes the kind of this token. This numbering 35 * system is determined by JavaCCParser, and a table of these numbers is 36 * stored in the file ...Constants.java. 37 */ 38 public int kind; 39 40 /** The line number of the first character of this Token. */ 41 public int beginLine; 42 /** The column number of the first character of this Token. */ 43 public int beginColumn; 44 /** The line number of the last character of this Token. */ 45 public int endLine; 46 /** The column number of the last character of this Token. */ 47 public int endColumn; 48 49 /** 50 * The string image of the token. 51 */ 52 public String image; 53 54 /** 55 * A reference to the next regular (non-special) token from the input 56 * stream. If this is the last token from the input stream, or if the 57 * token manager has not read tokens beyond this one, this field is 58 * set to null. This is true only if this token is also a regular 59 * token. Otherwise, see below for a description of the contents of 60 * this field. 61 */ 62 public Token next; 63 64 /** 65 * This field is used to access special tokens that occur prior to this 66 * token, but after the immediately preceding regular (non-special) token. 67 * If there are no such special tokens, this field is set to null. 68 * When there are more than one such special token, this field refers 69 * to the last of these special tokens, which in turn refers to the next 70 * previous special token through its specialToken field, and so on 71 * until the first special token (whose specialToken field is null). 72 * The next fields of special tokens refer to other special tokens that 73 * immediately follow it (without an intervening regular token). If there 74 * is no such token, this field is null. 75 */ 76 public Token specialToken; 77 78 /** 79 * An optional attribute value of the Token. 80 * Tokens which are not used as syntactic sugar will often contain 81 * meaningful values that will be used later on by the compiler or 82 * interpreter. This attribute value is often different from the image. 83 * Any subclass of Token that actually wants to return a non-null value can 84 * override this method as appropriate. 85 */ 86 public Object getValue() { 87 return null; 88 } 89 90 /** 91 * No-argument constructor 92 */ 93 public Token() {} 94 95 /** 96 * Constructs a new token for the specified Image. 97 */ 98 public Token(int kind) 99 { 100 this(kind, null); 101 } 102 103 /** 104 * Constructs a new token for the specified Image and Kind. 105 */ 106 public Token(int kind, String image) 107 { 108 this.kind = kind; 109 this.image = image; 110 } 111 112 /** 113 * Returns the image. 114 */ 115 public String toString() 116 { 117 return image; 118 } 119 120 /** 121 * Returns a new Token object, by default. However, if you want, you 122 * can create and return subclass objects based on the value of ofKind. 123 * Simply add the cases to the switch for all those special cases. 124 * For example, if you have a subclass of Token called IDToken that 125 * you want to create if ofKind is ID, simply add something like : 126 * 127 * case MyParserConstants.ID : return new IDToken(ofKind, image); 128 * 129 * to the following switch statement. Then you can cast matchedToken 130 * variable to the appropriate type and use sit in your lexical actions. 131 */ 132 public static Token newToken(int ofKind, String image) 133 { 134 switch(ofKind) 135 { 136 default : return new Token(ofKind, image); 137 } 138 } 139 140 public static Token newToken(int ofKind) 141 { 142 return newToken(ofKind, null); 143 } 144 145 } 146 /* JavaCC - OriginalChecksum=33aacd1a7971ba560dfb1efa7b62c14a (do not edit this line) */