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