1 | /* | |
2 | * Copyright 2006 - 2013 | |
3 | * Stefan Balev <stefan.balev@graphstream-project.org> | |
4 | * Julien Baudry <julien.baudry@graphstream-project.org> | |
5 | * Antoine Dutot <antoine.dutot@graphstream-project.org> | |
6 | * Yoann Pign�� <yoann.pigne@graphstream-project.org> | |
7 | * Guilhelm Savin <guilhelm.savin@graphstream-project.org> | |
8 | * | |
9 | * This file is part of GraphStream <http://graphstream-project.org>. | |
10 | * | |
11 | * GraphStream is a library whose purpose is to handle static or dynamic | |
12 | * graph, create them from scratch, file or any source and display them. | |
13 | * | |
14 | * This program is free software distributed under the terms of two licenses, the | |
15 | * CeCILL-C license that fits European law, and the GNU Lesser General Public | |
16 | * License. You can use, modify and/ or redistribute the software under the terms | |
17 | * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following | |
18 | * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by | |
19 | * the Free Software Foundation, either version 3 of the License, or (at your | |
20 | * option) any later version. | |
21 | * | |
22 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY | |
23 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
24 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | |
25 | * | |
26 | * You should have received a copy of the GNU Lesser General Public License | |
27 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
28 | * | |
29 | * The fact that you are presently reading this means that you have had | |
30 | * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms. | |
31 | */ | |
32 | package org.graphstream.util.parser; | |
33 | ||
34 | /** | |
35 | * Describes the input token stream. | |
36 | */ | |
37 | ||
38 | public class Token implements java.io.Serializable { | |
39 | ||
40 | /** | |
41 | * The version identifier for this Serializable class. Increment only if the | |
42 | * <i>serialized</i> form of the class changes. | |
43 | */ | |
44 | private static final long serialVersionUID = 1L; | |
45 | ||
46 | /** | |
47 | * An integer that describes the kind of this token. This numbering system | |
48 | * is determined by JavaCCParser, and a table of these numbers is stored in | |
49 | * the file ...Constants.java. | |
50 | */ | |
51 | public int kind; | |
52 | ||
53 | /** The line number of the first character of this Token. */ | |
54 | public int beginLine; | |
55 | /** The column number of the first character of this Token. */ | |
56 | public int beginColumn; | |
57 | /** The line number of the last character of this Token. */ | |
58 | public int endLine; | |
59 | /** The column number of the last character of this Token. */ | |
60 | public int endColumn; | |
61 | ||
62 | /** | |
63 | * The string image of the token. | |
64 | */ | |
65 | public String image; | |
66 | ||
67 | /** | |
68 | * A reference to the next regular (non-special) token from the input | |
69 | * stream. If this is the last token from the input stream, or if the token | |
70 | * manager has not read tokens beyond this one, this field is set to null. | |
71 | * This is true only if this token is also a regular token. Otherwise, see | |
72 | * below for a description of the contents of this field. | |
73 | */ | |
74 | public Token next; | |
75 | ||
76 | /** | |
77 | * This field is used to access special tokens that occur prior to this | |
78 | * token, but after the immediately preceding regular (non-special) token. | |
79 | * If there are no such special tokens, this field is set to null. When | |
80 | * there are more than one such special token, this field refers to the last | |
81 | * of these special tokens, which in turn refers to the next previous | |
82 | * special token through its specialToken field, and so on until the first | |
83 | * special token (whose specialToken field is null). The next fields of | |
84 | * special tokens refer to other special tokens that immediately follow it | |
85 | * (without an intervening regular token). If there is no such token, this | |
86 | * field is null. | |
87 | */ | |
88 | public Token specialToken; | |
89 | ||
90 | /** | |
91 | * An optional attribute value of the Token. Tokens which are not used as | |
92 | * syntactic sugar will often contain meaningful values that will be used | |
93 | * later on by the compiler or interpreter. This attribute value is often | |
94 | * different from the image. Any subclass of Token that actually wants to | |
95 | * return a non-null value can override this method as appropriate. | |
96 | */ | |
97 | public Object getValue() { | |
98 |
1
1. getValue : mutated return of Object value for org/graphstream/util/parser/Token::getValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
99 | } | |
100 | ||
101 | /** | |
102 | * No-argument constructor | |
103 | */ | |
104 | public Token() { | |
105 | } | |
106 | ||
107 | /** | |
108 | * Constructs a new token for the specified Image. | |
109 | */ | |
110 | public Token(int kind) { | |
111 | this(kind, null); | |
112 | } | |
113 | ||
114 | /** | |
115 | * Constructs a new token for the specified Image and Kind. | |
116 | */ | |
117 | public Token(int kind, String image) { | |
118 | this.kind = kind; | |
119 | this.image = image; | |
120 | } | |
121 | ||
122 | /** | |
123 | * Returns the image. | |
124 | */ | |
125 | public String toString() { | |
126 |
1
1. toString : mutated return of Object value for org/graphstream/util/parser/Token::toString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return image; |
127 | } | |
128 | ||
129 | /** | |
130 | * Returns a new Token object, by default. However, if you want, you can | |
131 | * create and return subclass objects based on the value of ofKind. Simply | |
132 | * add the cases to the switch for all those special cases. For example, if | |
133 | * you have a subclass of Token called IDToken that you want to create if | |
134 | * ofKind is ID, simply add something like : | |
135 | * | |
136 | * case MyParserConstants.ID : return new IDToken(ofKind, image); | |
137 | * | |
138 | * to the following switch statement. Then you can cast matchedToken | |
139 | * variable to the appropriate type and use sit in your lexical actions. | |
140 | */ | |
141 | public static Token newToken(int ofKind, String image) { | |
142 | switch (ofKind) { | |
143 | default: | |
144 |
1
1. newToken : mutated return of Object value for org/graphstream/util/parser/Token::newToken to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Token(ofKind, image); |
145 | } | |
146 | } | |
147 | ||
148 | public static Token newToken(int ofKind) { | |
149 |
1
1. newToken : mutated return of Object value for org/graphstream/util/parser/Token::newToken to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return newToken(ofKind, null); |
150 | } | |
151 | ||
152 | } | |
153 | /* | |
154 | * JavaCC - OriginalChecksum=0c00a7ff8fbeeb2312a89d5c1c4252da (do not edit this | |
155 | * line) | |
156 | */ | |
Mutations | ||
98 |
1.1 |
|
126 |
1.1 |
|
144 |
1.1 |
|
149 |
1.1 |