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 (C) Christian Schulte, 2005-206 |
5 | * All rights reserved. |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions |
9 | * are met: |
10 | * |
11 | * o Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. |
13 | * |
14 | * o Redistributions in binary form must reproduce the above copyright |
15 | * notice, this list of conditions and the following disclaimer in |
16 | * the documentation and/or other materials provided with the |
17 | * distribution. |
18 | * |
19 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
21 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
22 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | * |
30 | * $JOMC: VersionParser.jj 4613 2012-09-22 10:07:08Z schulte $ |
31 | * |
32 | */ |
33 | package org.jomc.util; |
34 | |
35 | /** |
36 | * Describes the input token stream. |
37 | */ |
38 | |
39 | public class Token implements java.io.Serializable { |
40 | |
41 | /** |
42 | * The version identifier for this Serializable class. |
43 | * Increment only if the <i>serialized</i> form of the |
44 | * class changes. |
45 | */ |
46 | private static final long serialVersionUID = 1L; |
47 | |
48 | /** |
49 | * An integer that describes the kind of this token. This numbering |
50 | * system is determined by JavaCCParser, and a table of these numbers is |
51 | * stored in the file ...Constants.java. |
52 | */ |
53 | public int kind; |
54 | |
55 | /** The line number of the first character of this Token. */ |
56 | public int beginLine; |
57 | /** The column number of the first character of this Token. */ |
58 | public int beginColumn; |
59 | /** The line number of the last character of this Token. */ |
60 | public int endLine; |
61 | /** The column number of the last character of this Token. */ |
62 | public int endColumn; |
63 | |
64 | /** |
65 | * The string image of the token. |
66 | */ |
67 | public String image; |
68 | |
69 | /** |
70 | * A reference to the next regular (non-special) token from the input |
71 | * stream. If this is the last token from the input stream, or if the |
72 | * token manager has not read tokens beyond this one, this field is |
73 | * set to null. This is true only if this token is also a regular |
74 | * token. Otherwise, see below for a description of the contents of |
75 | * this field. |
76 | */ |
77 | public Token next; |
78 | |
79 | /** |
80 | * This field is used to access special tokens that occur prior to this |
81 | * token, but after the immediately preceding regular (non-special) token. |
82 | * If there are no such special tokens, this field is set to null. |
83 | * When there are more than one such special token, this field refers |
84 | * to the last of these special tokens, which in turn refers to the next |
85 | * previous special token through its specialToken field, and so on |
86 | * until the first special token (whose specialToken field is null). |
87 | * The next fields of special tokens refer to other special tokens that |
88 | * immediately follow it (without an intervening regular token). If there |
89 | * is no such token, this field is null. |
90 | */ |
91 | public Token specialToken; |
92 | |
93 | /** |
94 | * An optional attribute value of the Token. |
95 | * Tokens which are not used as syntactic sugar will often contain |
96 | * meaningful values that will be used later on by the compiler or |
97 | * interpreter. This attribute value is often different from the image. |
98 | * Any subclass of Token that actually wants to return a non-null value can |
99 | * override this method as appropriate. |
100 | */ |
101 | public Object getValue() { |
102 | return null; |
103 | } |
104 | |
105 | /** |
106 | * No-argument constructor |
107 | */ |
108 | public Token() {} |
109 | |
110 | /** |
111 | * Constructs a new token for the specified Image. |
112 | */ |
113 | public Token(int kind) |
114 | { |
115 | this(kind, null); |
116 | } |
117 | |
118 | /** |
119 | * Constructs a new token for the specified Image and Kind. |
120 | */ |
121 | public Token(int kind, String image) |
122 | { |
123 | this.kind = kind; |
124 | this.image = image; |
125 | } |
126 | |
127 | /** |
128 | * Returns the image. |
129 | */ |
130 | public String toString() |
131 | { |
132 | return image; |
133 | } |
134 | |
135 | /** |
136 | * Returns a new Token object, by default. However, if you want, you |
137 | * can create and return subclass objects based on the value of ofKind. |
138 | * Simply add the cases to the switch for all those special cases. |
139 | * For example, if you have a subclass of Token called IDToken that |
140 | * you want to create if ofKind is ID, simply add something like : |
141 | * |
142 | * case MyParserConstants.ID : return new IDToken(ofKind, image); |
143 | * |
144 | * to the following switch statement. Then you can cast matchedToken |
145 | * variable to the appropriate type and use sit in your lexical actions. |
146 | */ |
147 | public static Token newToken(int ofKind, String image) |
148 | { |
149 | switch(ofKind) |
150 | { |
151 | default : return new Token(ofKind, image); |
152 | } |
153 | } |
154 | |
155 | public static Token newToken(int ofKind) |
156 | { |
157 | return newToken(ofKind, null); |
158 | } |
159 | |
160 | } |
161 | /* JavaCC - OriginalChecksum=64712a1def4bfb3b8acdaabf482331d7 (do not edit this line) */ |