-
Notifications
You must be signed in to change notification settings - Fork 0
/
Express.java
262 lines (201 loc) · 5.46 KB
/
Express.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
package dev.alephpt.Dis;
import java.util.List;
abstract class Express {
interface Visitor<R> {
R visitAssignExpress(Assign express);
R visitCountExpress(Count express);
R visitUnaryExpress(Unary express);
R visitBinaryExpress(Binary express);
R visitCallingExpress(Calling express);
R visitSelfExpress(Self express);
R visitGetPropsExpress(GetProps express);
R visitSetPropsExpress(SetProps express);
R visitGroupingExpress(Grouping express);
R visitLiteralExpress(Literal express);
R visitLogicalExpress(Logical express);
R visitVariableExpress(Variable express);
R visitParentVariableExpress(ParentVariable express);
R visitGlobalVariableExpress(GlobalVariable express);
}
// Assign Express Definition //
static class Assign extends Express {
Assign(Token name, Express value) {
this.name = name;
this.value = value;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitAssignExpress(this);
}
final Token name;
final Express value;
}
// Count Express Definition //
static class Count extends Express {
Count(Token operator, Express identifier, Token name) {
this.operator = operator;
this.identifier = identifier;
this.name = name;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitCountExpress(this);
}
final Token operator;
final Express identifier;
final Token name;
}
// Unary Express Definition //
static class Unary extends Express {
Unary(Token operator, Express right) {
this.operator = operator;
this.right = right;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitUnaryExpress(this);
}
final Token operator;
final Express right;
}
// Binary Express Definition //
static class Binary extends Express {
Binary(Express left, Token operator, Express right) {
this.left = left;
this.operator = operator;
this.right = right;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitBinaryExpress(this);
}
final Express left;
final Token operator;
final Express right;
}
// Calling Express Definition //
static class Calling extends Express {
Calling(Express called, List<Express> args) {
this.called = called;
this.args = args;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitCallingExpress(this);
}
final Express called;
final List<Express> args;
}
// Self Express Definition //
static class Self extends Express {
Self(Token keyword) {
this.keyword = keyword;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitSelfExpress(this);
}
final Token keyword;
}
// GetProps Express Definition //
static class GetProps extends Express {
GetProps(Express object, Token name) {
this.object = object;
this.name = name;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitGetPropsExpress(this);
}
final Express object;
final Token name;
}
// SetProps Express Definition //
static class SetProps extends Express {
SetProps(Express object, Token locale, Token name, Express value) {
this.object = object;
this.locale = locale;
this.name = name;
this.value = value;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitSetPropsExpress(this);
}
final Express object;
final Token locale;
final Token name;
final Express value;
}
// Grouping Express Definition //
static class Grouping extends Express {
Grouping(Express expression) {
this.expression = expression;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitGroupingExpress(this);
}
final Express expression;
}
// Literal Express Definition //
static class Literal extends Express {
Literal(Object value) {
this.value = value;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitLiteralExpress(this);
}
final Object value;
}
// Logical Express Definition //
static class Logical extends Express {
Logical(Express left, Token operator, Express right) {
this.left = left;
this.operator = operator;
this.right = right;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitLogicalExpress(this);
}
final Express left;
final Token operator;
final Express right;
}
// Variable Express Definition //
static class Variable extends Express {
Variable(Token name) {
this.name = name;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitVariableExpress(this);
}
final Token name;
}
// ParentVariable Express Definition //
static class ParentVariable extends Express {
ParentVariable(Token name) {
this.name = name;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitParentVariableExpress(this);
}
final Token name;
}
// GlobalVariable Express Definition //
static class GlobalVariable extends Express {
GlobalVariable(Token name) {
this.name = name;
}
@Override
<R> R accept(Visitor<R> visitor) {
return visitor.visitGlobalVariableExpress(this);
}
final Token name;
}
abstract <R> R accept(Visitor<R> visitor);
}