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