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