Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/com/sun/java_cup/internal/runtime/Symbol.java
38829 views
1
/*
2
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.java_cup.internal.runtime;
27
28
/**
29
* Defines the Symbol class, which is used to represent all terminals
30
* and nonterminals while parsing. The lexer should pass CUP Symbols
31
* and CUP returns a Symbol.
32
*
33
* @author Frank Flannery
34
*/
35
36
/* ****************************************************************
37
Class Symbol
38
what the parser expects to receive from the lexer.
39
the token is identified as follows:
40
sym: the symbol type
41
parse_state: the parse state.
42
value: is the lexical value of type Object
43
left : is the left position in the original input file
44
right: is the right position in the original input file
45
******************************************************************/
46
47
public class Symbol {
48
49
/*******************************
50
Constructor for l,r values
51
*******************************/
52
53
public Symbol(int id, int l, int r, Object o) {
54
this(id);
55
left = l;
56
right = r;
57
value = o;
58
}
59
60
/*******************************
61
Constructor for no l,r values
62
********************************/
63
64
public Symbol(int id, Object o) {
65
this(id);
66
left = -1;
67
right = -1;
68
value = o;
69
}
70
71
/*****************************
72
Constructor for no value
73
***************************/
74
75
public Symbol(int sym_num, int l, int r) {
76
sym = sym_num;
77
left = l;
78
right = r;
79
value = null;
80
}
81
82
/***********************************
83
Constructor for no value or l,r
84
***********************************/
85
86
public Symbol(int sym_num) {
87
this(sym_num, -1);
88
left = -1;
89
right = -1;
90
value = null;
91
}
92
93
/***********************************
94
Constructor to give a start state
95
***********************************/
96
public Symbol(int sym_num, int state)
97
{
98
sym = sym_num;
99
parse_state = state;
100
}
101
102
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
103
104
/** The symbol number of the terminal or non terminal being represented */
105
public int sym;
106
107
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
108
109
/** The parse state to be recorded on the parse stack with this symbol.
110
* This field is for the convenience of the parser and shouldn't be
111
* modified except by the parser.
112
*/
113
public int parse_state;
114
/** This allows us to catch some errors caused by scanners recycling
115
* symbols. For the use of the parser only. [CSA, 23-Jul-1999] */
116
boolean used_by_parser = false;
117
118
/*******************************
119
The data passed to parser
120
*******************************/
121
122
public int left, right;
123
public Object value;
124
125
/*****************************
126
Printing this token out. (Override for pretty-print).
127
****************************/
128
public String toString() { return "#"+sym; }
129
}
130
131