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