Skip to content

Package: Token

Token

nameinstructionbranchcomplexitylinemethod
Token()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
newToken(int)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
toString()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package com.sun.el.parser;
18:
19: import java.io.Serializable;
20:
21: /**
22: * Describes the input token stream.
23: */
24:
25: public class Token implements Serializable {
26:
27: /**
28: * An integer that describes the kind of this token. This numbering system is determined by JavaCCParser, and a table of
29: * these numbers is stored in the file ...Constants.java.
30: */
31: public int kind;
32:
33: /**
34: * beginLine and beginColumn describe the position of the first character of this token; endLine and endColumn describe
35: * the position of the last character of this token.
36: */
37: public int beginLine, beginColumn, endLine, endColumn;
38:
39: /**
40: * The string image of the token.
41: */
42: public String image;
43:
44: /**
45: * A reference to the next regular (non-special) token from the input stream. If this is the last token from the input
46: * stream, or if the token manager has not read tokens beyond this one, this field is set to null. This is true only if
47: * this token is also a regular token. Otherwise, see below for a description of the contents of this field.
48: */
49: public Token next;
50:
51: /**
52: * This field is used to access special tokens that occur prior to this token, but after the immediately preceding
53: * regular (non-special) token. If there are no such special tokens, this field is set to null. When there are more than
54: * one such special token, this field refers to the last of these special tokens, which in turn refers to the next
55: * previous special token through its specialToken field, and so on until the first special token (whose specialToken
56: * field is null). The next fields of special tokens refer to other special tokens that immediately follow it (without
57: * an intervening regular token). If there is no such token, this field is null.
58: */
59: public Token specialToken;
60:
61: /**
62: * Returns the image.
63: */
64: @Override
65: public String toString() {
66: return image;
67: }
68:
69: /**
70: * Returns a new Token object, by default. However, if you want, you can create and return subclass objects based on the
71: * value of ofKind. Simply add the cases to the switch for all those special cases. For example, if you have a subclass
72: * of Token called IDToken that you want to create if ofKind is ID, simlpy add something like :
73: *
74: * case MyParserConstants.ID : return new IDToken();
75: *
76: * to the following switch statement. Then you can cast matchedToken variable to the appropriate type and use it in your
77: * lexical actions.
78: */
79: public static final Token newToken(int ofKind) {
80: switch (ofKind) {
81: default:
82: return new Token();
83: }
84: }
85:
86: }