1 /* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */ 2 package com.quiotix.html.parser; 3 4 /** 5 * Describes the input token stream. 6 */ 7 8 public class Token { 9 10 /** 11 * An integer that describes the kind of this token. This numbering 12 * system is determined by JavaCCParser, and a table of these numbers is 13 * stored in the file ...Constants.java. 14 */ 15 public int kind; 16 17 /** The line number of the first character of this Token. */ 18 public int beginLine; 19 /** The column number of the first character of this Token. */ 20 public int beginColumn; 21 /** The line number of the last character of this Token. */ 22 public int endLine; 23 /** The column number of the last character of this Token. */ 24 public int endColumn; 25 26 /** 27 * The string image of the token. 28 */ 29 public String image; 30 31 /** 32 * A reference to the next regular (non-special) token from the input 33 * stream. If this is the last token from the input stream, or if the 34 * token manager has not read tokens beyond this one, this field is 35 * set to null. This is true only if this token is also a regular 36 * token. Otherwise, see below for a description of the contents of 37 * this field. 38 */ 39 public Token next; 40 41 /** 42 * This field is used to access special tokens that occur prior to this 43 * token, but after the immediately preceding regular (non-special) token. 44 * If there are no such special tokens, this field is set to null. 45 * When there are more than one such special token, this field refers 46 * to the last of these special tokens, which in turn refers to the next 47 * previous special token through its specialToken field, and so on 48 * until the first special token (whose specialToken field is null). 49 * The next fields of special tokens refer to other special tokens that 50 * immediately follow it (without an intervening regular token). If there 51 * is no such token, this field is null. 52 */ 53 public Token specialToken; 54 55 /** 56 * An optional attribute value of the Token. 57 * Tokens which are not used as syntactic sugar will often contain 58 * meaningful values that will be used later on by the compiler or 59 * interpreter. This attribute value is often different from the image. 60 * Any subclass of Token that actually wants to return a non-null value can 61 * override this method as appropriate. 62 */ 63 public Object getValue() { 64 return null; 65 } 66 67 /** 68 * No-argument contructor 69 */ 70 public Token() {} 71 72 /** 73 * Constructs a new token for the specified Image. 74 */ 75 public Token(int kind) 76 { 77 this(kind, null); 78 } 79 80 /** 81 * Constructs a new token for the specified Image and Kind. 82 */ 83 public Token(int kind, String image) 84 { 85 this.kind = kind; 86 this.image = image; 87 } 88 89 /** 90 * Returns the image. 91 */ 92 public String toString() 93 { 94 return image; 95 } 96 97 /** 98 * Returns a new Token object, by default. However, if you want, you 99 * can create and return subclass objects based on the value of ofKind. 100 * Simply add the cases to the switch for all those special cases. 101 * For example, if you have a subclass of Token called IDToken that 102 * you want to create if ofKind is ID, simply add something like : 103 * 104 * case MyParserConstants.ID : return new IDToken(ofKind, image); 105 * 106 * to the following switch statement. Then you can cast matchedToken 107 * variable to the appropriate type and use it in your lexical actions. 108 */ 109 public static final Token newToken(int ofKind, String image) 110 { 111 switch(ofKind) 112 { 113 default : return new Token(ofKind, image); 114 } 115 } 116 117 /** 118 * @return a Token of the given kind 119 */ 120 public static final Token newToken(int ofKind) 121 { 122 return newToken(ofKind, null); 123 } 124 125 }