@minduscript/parser 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +2 -0
- package/dist/exe.d.ts +2 -0
- package/dist/exe.js +75 -0
- package/dist/expression-parser.d.ts +25 -0
- package/dist/expression-parser.js +349 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +17 -0
- package/dist/nodes.d.ts +648 -0
- package/dist/nodes.js +167 -0
- package/dist/parser.d.ts +5 -0
- package/dist/parser.js +1280 -0
- package/package.json +26 -0
package/dist/nodes.d.ts
ADDED
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
import type { Token, TokenType } from '@minduscript/lexer';
|
|
2
|
+
export declare enum NodeType {
|
|
3
|
+
DOCUMENT = 161,
|
|
4
|
+
IMPORT_LIST = 162,
|
|
5
|
+
IMPORT_STATEMENT = 163,
|
|
6
|
+
CODE_BLOCK = 164,
|
|
7
|
+
STATEMENT_LIST = 165,
|
|
8
|
+
STATEMENT = 166,
|
|
9
|
+
SINGLE_STATEMENT = 167,
|
|
10
|
+
BLOCK_STATEMENT = 168,
|
|
11
|
+
STATEMENT_BODY = 169,
|
|
12
|
+
BLOCK_STATEMENT_BODY = 170,
|
|
13
|
+
MACRO_PARAM_LIST = 171,
|
|
14
|
+
MACRO_ARG_LIST = 172,
|
|
15
|
+
EXPRESSION = 173,
|
|
16
|
+
UNARY_OP_EXPRESSION = 174,
|
|
17
|
+
BINARY_OP_EXPRESSION = 175,
|
|
18
|
+
FUNCTION_CALL_EXPRESSION = 176,
|
|
19
|
+
MACRO_CALL_EXPRESSION = 177,
|
|
20
|
+
LITERAL_EXPRESSION = 178,
|
|
21
|
+
IDENTIFIER_EXPRESSION = 179,
|
|
22
|
+
RADAR_CONDITION = 180,
|
|
23
|
+
RADAR_SORT_CONFIG = 181,
|
|
24
|
+
UNIT_LOCATE_BUILDING_GROUP = 182,
|
|
25
|
+
ASSIGN_OP = 183
|
|
26
|
+
}
|
|
27
|
+
export type NodeBase = {
|
|
28
|
+
tokens: Token[];
|
|
29
|
+
};
|
|
30
|
+
export type DocumentNode = NodeBase & {
|
|
31
|
+
type: NodeType.DOCUMENT;
|
|
32
|
+
importList: ImportStatementNode[];
|
|
33
|
+
statementList: StatementNode[];
|
|
34
|
+
};
|
|
35
|
+
export type ImportListNode = NodeBase & {
|
|
36
|
+
type: NodeType.IMPORT_LIST;
|
|
37
|
+
first: ImportStatementNode;
|
|
38
|
+
other: ImportListNode | undefined;
|
|
39
|
+
};
|
|
40
|
+
export type ImportStatementNode = NodeBase & {
|
|
41
|
+
type: NodeType.IMPORT_STATEMENT;
|
|
42
|
+
name: string;
|
|
43
|
+
asName: string;
|
|
44
|
+
from: string;
|
|
45
|
+
};
|
|
46
|
+
export type CodeBlockNode = NodeBase & {
|
|
47
|
+
type: NodeType.CODE_BLOCK;
|
|
48
|
+
statements: StatementNode[];
|
|
49
|
+
};
|
|
50
|
+
export type StatementListNode = NodeBase & {
|
|
51
|
+
type: NodeType.STATEMENT_LIST;
|
|
52
|
+
first: StatementNode;
|
|
53
|
+
other: StatementListNode | undefined;
|
|
54
|
+
};
|
|
55
|
+
export type SingleStatementNodeBase = NodeBase & {
|
|
56
|
+
type: NodeType.SINGLE_STATEMENT;
|
|
57
|
+
};
|
|
58
|
+
export declare enum StatementType {
|
|
59
|
+
EMPTY = 0,
|
|
60
|
+
VARIABLE_DEFINE = 1,
|
|
61
|
+
ASSIGN = 2,
|
|
62
|
+
CONTROL = 3,
|
|
63
|
+
MACRO_DEFINE = 4,
|
|
64
|
+
MACRO_CALL = 5,
|
|
65
|
+
IF_ELSE = 6,
|
|
66
|
+
IF = 7,
|
|
67
|
+
FOR = 8,
|
|
68
|
+
WHILE = 9,
|
|
69
|
+
LOOP_CONTROL = 10,
|
|
70
|
+
RETURN = 11,
|
|
71
|
+
BIND = 12
|
|
72
|
+
}
|
|
73
|
+
export type EmptyStatementNode = SingleStatementNodeBase & {
|
|
74
|
+
statementType: StatementType.EMPTY;
|
|
75
|
+
};
|
|
76
|
+
export type VariableDefineStatementNode = SingleStatementNodeBase & {
|
|
77
|
+
statementType: StatementType.VARIABLE_DEFINE;
|
|
78
|
+
variableName: string;
|
|
79
|
+
isConst: boolean;
|
|
80
|
+
expression: ExpressionNode;
|
|
81
|
+
};
|
|
82
|
+
export declare enum AssignType {
|
|
83
|
+
SIMPLE = 0,
|
|
84
|
+
ADD = 1,
|
|
85
|
+
SUB = 2,
|
|
86
|
+
MUL = 3,
|
|
87
|
+
DIV = 4,
|
|
88
|
+
IDIV = 5,
|
|
89
|
+
MOD = 6,
|
|
90
|
+
POW = 7,
|
|
91
|
+
AND = 8,
|
|
92
|
+
SHL = 9,
|
|
93
|
+
SHR = 10,
|
|
94
|
+
BITAND = 11,
|
|
95
|
+
BITOR = 12,
|
|
96
|
+
XOR = 13,
|
|
97
|
+
OR = 14
|
|
98
|
+
}
|
|
99
|
+
export type AssignStatementNode = SingleStatementNodeBase & {
|
|
100
|
+
statementType: StatementType.ASSIGN;
|
|
101
|
+
assignType: AssignType;
|
|
102
|
+
variableName: string;
|
|
103
|
+
expression: ExpressionNode;
|
|
104
|
+
};
|
|
105
|
+
export declare enum ControlType {
|
|
106
|
+
READ = 0,
|
|
107
|
+
WRITE = 1,
|
|
108
|
+
DRAW_CLEAR = 2,
|
|
109
|
+
DRAW_COLOR = 3,
|
|
110
|
+
DRAW_COL = 4,
|
|
111
|
+
DRAW_STROKE = 5,
|
|
112
|
+
DRAW_LINE = 6,
|
|
113
|
+
DRAW_RECT = 7,
|
|
114
|
+
DRAW_LINE_RECT = 8,
|
|
115
|
+
DRAW_POLY = 9,
|
|
116
|
+
DRAW_LINE_POLY = 10,
|
|
117
|
+
DRAW_TRIANGLE = 11,
|
|
118
|
+
DRAW_IMAGE = 12,
|
|
119
|
+
PRINT = 13,
|
|
120
|
+
DRAW_FLUSH = 14,
|
|
121
|
+
PRINT_FLUSH = 15,
|
|
122
|
+
GET_LINK = 16,
|
|
123
|
+
SET_ENABLED = 17,
|
|
124
|
+
SET_SHOOT = 18,
|
|
125
|
+
SET_SHOOT_P = 19,
|
|
126
|
+
SET_CONFIG = 20,
|
|
127
|
+
SET_COLOR = 21,
|
|
128
|
+
RADAR = 22,
|
|
129
|
+
SENSOR = 23,
|
|
130
|
+
PACK_COLOR = 24,
|
|
131
|
+
WAIT = 25,
|
|
132
|
+
CPU_STOP = 26,
|
|
133
|
+
UNIT_BIND = 27,
|
|
134
|
+
UNIT_RADAR = 28,
|
|
135
|
+
UNIT_LOCATE = 29,
|
|
136
|
+
IDLE = 30,
|
|
137
|
+
STOP = 31,
|
|
138
|
+
MOVE = 32,
|
|
139
|
+
APPROACH = 33,
|
|
140
|
+
PATH_FIND = 34,
|
|
141
|
+
AUTO_PATH_FIND = 35,
|
|
142
|
+
BOOST = 36,
|
|
143
|
+
TARGET = 37,
|
|
144
|
+
TARGET_P = 38,
|
|
145
|
+
ITEM_DROP = 39,
|
|
146
|
+
ITEM_TAKE = 40,
|
|
147
|
+
PAY_DROP = 41,
|
|
148
|
+
PAY_TAKE = 42,
|
|
149
|
+
PAY_ENTER = 43,
|
|
150
|
+
MINE = 44,
|
|
151
|
+
FLAG = 45,
|
|
152
|
+
BUILD = 46,
|
|
153
|
+
GET_BLOCK = 47,
|
|
154
|
+
WITHIN = 48,
|
|
155
|
+
UNBIND = 49
|
|
156
|
+
}
|
|
157
|
+
export type StatementNodeControlBase = SingleStatementNodeBase & {
|
|
158
|
+
statementType: StatementType.CONTROL;
|
|
159
|
+
};
|
|
160
|
+
export type StatementNodeRead = StatementNodeControlBase & {
|
|
161
|
+
controlType: ControlType.READ;
|
|
162
|
+
output: IdentifierExpressionNode;
|
|
163
|
+
memoryName: ExpressionNode;
|
|
164
|
+
memoryIndex: ExpressionNode;
|
|
165
|
+
};
|
|
166
|
+
export type StatementNodeWrite = StatementNodeControlBase & {
|
|
167
|
+
controlType: ControlType.WRITE;
|
|
168
|
+
value: ExpressionNode;
|
|
169
|
+
memoryName: ExpressionNode;
|
|
170
|
+
memoryIndex: ExpressionNode;
|
|
171
|
+
};
|
|
172
|
+
export type StatementNodeDrawClear = StatementNodeControlBase & {
|
|
173
|
+
controlType: ControlType.DRAW_CLEAR;
|
|
174
|
+
r: ExpressionNode;
|
|
175
|
+
g: ExpressionNode;
|
|
176
|
+
b: ExpressionNode;
|
|
177
|
+
};
|
|
178
|
+
export type StatementNodeDrawColor = StatementNodeControlBase & {
|
|
179
|
+
controlType: ControlType.DRAW_COLOR;
|
|
180
|
+
r: ExpressionNode;
|
|
181
|
+
g: ExpressionNode;
|
|
182
|
+
b: ExpressionNode;
|
|
183
|
+
a: ExpressionNode;
|
|
184
|
+
};
|
|
185
|
+
export type StatementNodeDrawCol = StatementNodeControlBase & {
|
|
186
|
+
controlType: ControlType.DRAW_COL;
|
|
187
|
+
color: ExpressionNode;
|
|
188
|
+
};
|
|
189
|
+
export type StatementNodeDrawStroke = StatementNodeControlBase & {
|
|
190
|
+
controlType: ControlType.DRAW_STROKE;
|
|
191
|
+
width: ExpressionNode;
|
|
192
|
+
};
|
|
193
|
+
export type StatementNodeDrawLine = StatementNodeControlBase & {
|
|
194
|
+
controlType: ControlType.DRAW_LINE;
|
|
195
|
+
x: ExpressionNode;
|
|
196
|
+
y: ExpressionNode;
|
|
197
|
+
x2: ExpressionNode;
|
|
198
|
+
y2: ExpressionNode;
|
|
199
|
+
};
|
|
200
|
+
export type StatementNodeDrawRect = StatementNodeControlBase & {
|
|
201
|
+
controlType: ControlType.DRAW_RECT;
|
|
202
|
+
x: ExpressionNode;
|
|
203
|
+
y: ExpressionNode;
|
|
204
|
+
width: ExpressionNode;
|
|
205
|
+
height: ExpressionNode;
|
|
206
|
+
};
|
|
207
|
+
export type StatementNodeDrawLineRect = StatementNodeControlBase & {
|
|
208
|
+
controlType: ControlType.DRAW_LINE_RECT;
|
|
209
|
+
x: ExpressionNode;
|
|
210
|
+
y: ExpressionNode;
|
|
211
|
+
width: ExpressionNode;
|
|
212
|
+
height: ExpressionNode;
|
|
213
|
+
};
|
|
214
|
+
export type StatementNodeDrawPoly = StatementNodeControlBase & {
|
|
215
|
+
controlType: ControlType.DRAW_POLY;
|
|
216
|
+
x: ExpressionNode;
|
|
217
|
+
y: ExpressionNode;
|
|
218
|
+
sides: ExpressionNode;
|
|
219
|
+
radius: ExpressionNode;
|
|
220
|
+
rotation: ExpressionNode;
|
|
221
|
+
};
|
|
222
|
+
export type StatementNodeDrawLinePoly = StatementNodeControlBase & {
|
|
223
|
+
controlType: ControlType.DRAW_LINE_POLY;
|
|
224
|
+
x: ExpressionNode;
|
|
225
|
+
y: ExpressionNode;
|
|
226
|
+
sides: ExpressionNode;
|
|
227
|
+
radius: ExpressionNode;
|
|
228
|
+
rotation: ExpressionNode;
|
|
229
|
+
};
|
|
230
|
+
export type StatementNodeDrawTriangle = StatementNodeControlBase & {
|
|
231
|
+
controlType: ControlType.DRAW_TRIANGLE;
|
|
232
|
+
x: ExpressionNode;
|
|
233
|
+
y: ExpressionNode;
|
|
234
|
+
x2: ExpressionNode;
|
|
235
|
+
y2: ExpressionNode;
|
|
236
|
+
x3: ExpressionNode;
|
|
237
|
+
y3: ExpressionNode;
|
|
238
|
+
};
|
|
239
|
+
export type StatementNodeDrawImage = StatementNodeControlBase & {
|
|
240
|
+
controlType: ControlType.DRAW_IMAGE;
|
|
241
|
+
x: ExpressionNode;
|
|
242
|
+
y: ExpressionNode;
|
|
243
|
+
image: ExpressionNode;
|
|
244
|
+
size: ExpressionNode;
|
|
245
|
+
rotation: ExpressionNode;
|
|
246
|
+
};
|
|
247
|
+
export type StatementNodePrint = StatementNodeControlBase & {
|
|
248
|
+
controlType: ControlType.PRINT;
|
|
249
|
+
value: ExpressionNode;
|
|
250
|
+
};
|
|
251
|
+
export type StatementNodeDrawFlush = StatementNodeControlBase & {
|
|
252
|
+
controlType: ControlType.DRAW_FLUSH;
|
|
253
|
+
target: ExpressionNode;
|
|
254
|
+
};
|
|
255
|
+
export type StatementNodePrintFlush = StatementNodeControlBase & {
|
|
256
|
+
controlType: ControlType.PRINT_FLUSH;
|
|
257
|
+
target: ExpressionNode;
|
|
258
|
+
};
|
|
259
|
+
export type StatementNodeGetLink = StatementNodeControlBase & {
|
|
260
|
+
controlType: ControlType.GET_LINK;
|
|
261
|
+
result: IdentifierExpressionNode;
|
|
262
|
+
id: ExpressionNode;
|
|
263
|
+
};
|
|
264
|
+
export type StatementNodeSetEnabled = StatementNodeControlBase & {
|
|
265
|
+
controlType: ControlType.SET_ENABLED;
|
|
266
|
+
building: ExpressionNode;
|
|
267
|
+
value: ExpressionNode;
|
|
268
|
+
};
|
|
269
|
+
export type StatementNodeSetShoot = StatementNodeControlBase & {
|
|
270
|
+
controlType: ControlType.SET_SHOOT;
|
|
271
|
+
building: ExpressionNode;
|
|
272
|
+
x: ExpressionNode;
|
|
273
|
+
y: ExpressionNode;
|
|
274
|
+
shoot: ExpressionNode;
|
|
275
|
+
};
|
|
276
|
+
export type StatementNodeSetShootP = StatementNodeControlBase & {
|
|
277
|
+
controlType: ControlType.SET_SHOOT_P;
|
|
278
|
+
building: ExpressionNode;
|
|
279
|
+
unit: ExpressionNode;
|
|
280
|
+
shoot: ExpressionNode;
|
|
281
|
+
};
|
|
282
|
+
export type StatementNodeSetConfig = StatementNodeControlBase & {
|
|
283
|
+
controlType: ControlType.SET_CONFIG;
|
|
284
|
+
building: ExpressionNode;
|
|
285
|
+
config: ExpressionNode;
|
|
286
|
+
};
|
|
287
|
+
export type StatementNodeSetColor = StatementNodeControlBase & {
|
|
288
|
+
controlType: ControlType.SET_COLOR;
|
|
289
|
+
building: ExpressionNode;
|
|
290
|
+
color: ExpressionNode;
|
|
291
|
+
};
|
|
292
|
+
export declare enum RadarCondition {
|
|
293
|
+
ANY = 0,
|
|
294
|
+
ENEMY = 1,
|
|
295
|
+
ALLY = 2,
|
|
296
|
+
PLAYER = 3,
|
|
297
|
+
ATTACKER = 4,
|
|
298
|
+
FLYING = 5,
|
|
299
|
+
BOSS = 6,
|
|
300
|
+
GROUND = 7
|
|
301
|
+
}
|
|
302
|
+
export declare enum RadarSortConfig {
|
|
303
|
+
DISTANCE = 0,
|
|
304
|
+
HEALTH = 1,
|
|
305
|
+
SHIELD = 2,
|
|
306
|
+
ARMOR = 3,
|
|
307
|
+
MAX_HEALTH = 4
|
|
308
|
+
}
|
|
309
|
+
export type StatementNodeRadar = StatementNodeControlBase & {
|
|
310
|
+
controlType: ControlType.RADAR;
|
|
311
|
+
building: ExpressionNode;
|
|
312
|
+
condition1: RadarCondition;
|
|
313
|
+
condition2: RadarCondition;
|
|
314
|
+
condition3: RadarCondition;
|
|
315
|
+
order: ExpressionNode;
|
|
316
|
+
sort: RadarSortConfig;
|
|
317
|
+
result: IdentifierExpressionNode;
|
|
318
|
+
};
|
|
319
|
+
export type StatementNodeSensor = StatementNodeControlBase & {
|
|
320
|
+
controlType: ControlType.SENSOR;
|
|
321
|
+
target: ExpressionNode;
|
|
322
|
+
building: ExpressionNode;
|
|
323
|
+
result: IdentifierExpressionNode;
|
|
324
|
+
};
|
|
325
|
+
export type StatementNodePackColor = StatementNodeControlBase & {
|
|
326
|
+
controlType: ControlType.PACK_COLOR;
|
|
327
|
+
result: IdentifierExpressionNode;
|
|
328
|
+
r: ExpressionNode;
|
|
329
|
+
g: ExpressionNode;
|
|
330
|
+
b: ExpressionNode;
|
|
331
|
+
a: ExpressionNode;
|
|
332
|
+
};
|
|
333
|
+
export type StatementNodeWait = StatementNodeControlBase & {
|
|
334
|
+
controlType: ControlType.WAIT;
|
|
335
|
+
time: ExpressionNode;
|
|
336
|
+
};
|
|
337
|
+
export type StatementNodeCpuStop = StatementNodeControlBase & {
|
|
338
|
+
controlType: ControlType.CPU_STOP;
|
|
339
|
+
};
|
|
340
|
+
export type StatementNodeUnitBind = StatementNodeControlBase & {
|
|
341
|
+
controlType: ControlType.UNIT_BIND;
|
|
342
|
+
unit: ExpressionNode;
|
|
343
|
+
};
|
|
344
|
+
export type StatementNodeUnitRadar = StatementNodeControlBase & {
|
|
345
|
+
controlType: ControlType.UNIT_RADAR;
|
|
346
|
+
condition1: RadarCondition;
|
|
347
|
+
condition2: RadarCondition;
|
|
348
|
+
condition3: RadarCondition;
|
|
349
|
+
order: ExpressionNode;
|
|
350
|
+
sort: RadarSortConfig;
|
|
351
|
+
result: IdentifierExpressionNode;
|
|
352
|
+
};
|
|
353
|
+
export declare enum UnitLocateCategory {
|
|
354
|
+
ORE = 0,
|
|
355
|
+
BUILDING = 1,
|
|
356
|
+
SPAWN = 2,
|
|
357
|
+
DAMAGED = 3
|
|
358
|
+
}
|
|
359
|
+
export type StatementNodeUnitLocateOre = StatementNodeControlBase & {
|
|
360
|
+
controlType: ControlType.UNIT_LOCATE;
|
|
361
|
+
category: UnitLocateCategory.ORE;
|
|
362
|
+
target: ExpressionNode;
|
|
363
|
+
outX: IdentifierExpressionNode;
|
|
364
|
+
outY: IdentifierExpressionNode;
|
|
365
|
+
found: IdentifierExpressionNode;
|
|
366
|
+
};
|
|
367
|
+
export declare enum UnitLocateBuildingGroup {
|
|
368
|
+
CORE = 0,
|
|
369
|
+
STORAGE = 1,
|
|
370
|
+
GENERATOR = 2,
|
|
371
|
+
TURRET = 3,
|
|
372
|
+
FACTORY = 4,
|
|
373
|
+
REPAIR = 5,
|
|
374
|
+
BATTERY = 6,
|
|
375
|
+
REACTOR = 7
|
|
376
|
+
}
|
|
377
|
+
export type StatementNodeUnitLocateBuilding = StatementNodeControlBase & {
|
|
378
|
+
controlType: ControlType.UNIT_LOCATE;
|
|
379
|
+
category: UnitLocateCategory.BUILDING;
|
|
380
|
+
group: UnitLocateBuildingGroup;
|
|
381
|
+
enemy: ExpressionNode;
|
|
382
|
+
outX: IdentifierExpressionNode;
|
|
383
|
+
outY: IdentifierExpressionNode;
|
|
384
|
+
found: IdentifierExpressionNode;
|
|
385
|
+
building: IdentifierExpressionNode;
|
|
386
|
+
};
|
|
387
|
+
export type StatementNodeUnitLocateSpawn = StatementNodeControlBase & {
|
|
388
|
+
controlType: ControlType.UNIT_LOCATE;
|
|
389
|
+
category: UnitLocateCategory.SPAWN;
|
|
390
|
+
outX: IdentifierExpressionNode;
|
|
391
|
+
outY: IdentifierExpressionNode;
|
|
392
|
+
found: IdentifierExpressionNode;
|
|
393
|
+
building: IdentifierExpressionNode;
|
|
394
|
+
};
|
|
395
|
+
export type StatementNodeUnitLocateDamaged = StatementNodeControlBase & {
|
|
396
|
+
controlType: ControlType.UNIT_LOCATE;
|
|
397
|
+
category: UnitLocateCategory.DAMAGED;
|
|
398
|
+
outX: IdentifierExpressionNode;
|
|
399
|
+
outY: IdentifierExpressionNode;
|
|
400
|
+
found: IdentifierExpressionNode;
|
|
401
|
+
building: IdentifierExpressionNode;
|
|
402
|
+
};
|
|
403
|
+
export type StatementNodeIdle = StatementNodeControlBase & {
|
|
404
|
+
controlType: ControlType.IDLE;
|
|
405
|
+
};
|
|
406
|
+
export type StatementNodeStop = StatementNodeControlBase & {
|
|
407
|
+
controlType: ControlType.STOP;
|
|
408
|
+
};
|
|
409
|
+
export type StatementNodeMove = StatementNodeControlBase & {
|
|
410
|
+
controlType: ControlType.MOVE;
|
|
411
|
+
x: ExpressionNode;
|
|
412
|
+
y: ExpressionNode;
|
|
413
|
+
};
|
|
414
|
+
export type StatementNodeApproach = StatementNodeControlBase & {
|
|
415
|
+
controlType: ControlType.APPROACH;
|
|
416
|
+
x: ExpressionNode;
|
|
417
|
+
y: ExpressionNode;
|
|
418
|
+
distance: ExpressionNode;
|
|
419
|
+
};
|
|
420
|
+
export type StatementNodePathFind = StatementNodeControlBase & {
|
|
421
|
+
controlType: ControlType.PATH_FIND;
|
|
422
|
+
x: ExpressionNode;
|
|
423
|
+
y: ExpressionNode;
|
|
424
|
+
};
|
|
425
|
+
export type StatementNodeAutoPathFind = StatementNodeControlBase & {
|
|
426
|
+
controlType: ControlType.AUTO_PATH_FIND;
|
|
427
|
+
};
|
|
428
|
+
export type StatementNodeBoost = StatementNodeControlBase & {
|
|
429
|
+
controlType: ControlType.BOOST;
|
|
430
|
+
enabled: ExpressionNode;
|
|
431
|
+
};
|
|
432
|
+
export type StatementNodeTarget = StatementNodeControlBase & {
|
|
433
|
+
controlType: ControlType.TARGET;
|
|
434
|
+
x: ExpressionNode;
|
|
435
|
+
y: ExpressionNode;
|
|
436
|
+
shoot: ExpressionNode;
|
|
437
|
+
};
|
|
438
|
+
export type StatementNodeTargetP = StatementNodeControlBase & {
|
|
439
|
+
controlType: ControlType.TARGET_P;
|
|
440
|
+
unit: ExpressionNode;
|
|
441
|
+
shoot: ExpressionNode;
|
|
442
|
+
};
|
|
443
|
+
export type StatementNodeItemDrop = StatementNodeControlBase & {
|
|
444
|
+
controlType: ControlType.ITEM_DROP;
|
|
445
|
+
building: ExpressionNode;
|
|
446
|
+
amount: ExpressionNode;
|
|
447
|
+
};
|
|
448
|
+
export type StatementNodeItemTake = StatementNodeControlBase & {
|
|
449
|
+
controlType: ControlType.ITEM_TAKE;
|
|
450
|
+
building: ExpressionNode;
|
|
451
|
+
item: ExpressionNode;
|
|
452
|
+
amount: ExpressionNode;
|
|
453
|
+
};
|
|
454
|
+
export type StatementNodePayDrop = StatementNodeControlBase & {
|
|
455
|
+
controlType: ControlType.PAY_DROP;
|
|
456
|
+
};
|
|
457
|
+
export type StatementNodePayTake = StatementNodeControlBase & {
|
|
458
|
+
controlType: ControlType.PAY_TAKE;
|
|
459
|
+
takeUnits: ExpressionNode;
|
|
460
|
+
};
|
|
461
|
+
export type StatementNodePayEnter = StatementNodeControlBase & {
|
|
462
|
+
controlType: ControlType.PAY_ENTER;
|
|
463
|
+
};
|
|
464
|
+
export type StatementNodeMine = StatementNodeControlBase & {
|
|
465
|
+
controlType: ControlType.MINE;
|
|
466
|
+
x: ExpressionNode;
|
|
467
|
+
y: ExpressionNode;
|
|
468
|
+
};
|
|
469
|
+
export type StatementNodeFlag = StatementNodeControlBase & {
|
|
470
|
+
controlType: ControlType.FLAG;
|
|
471
|
+
flag: ExpressionNode;
|
|
472
|
+
};
|
|
473
|
+
export type StatementNodeBuild = StatementNodeControlBase & {
|
|
474
|
+
controlType: ControlType.BUILD;
|
|
475
|
+
x: ExpressionNode;
|
|
476
|
+
y: ExpressionNode;
|
|
477
|
+
block: ExpressionNode;
|
|
478
|
+
rotation: ExpressionNode;
|
|
479
|
+
config: ExpressionNode;
|
|
480
|
+
};
|
|
481
|
+
export type StatementNodeGetBlock = StatementNodeControlBase & {
|
|
482
|
+
controlType: ControlType.GET_BLOCK;
|
|
483
|
+
x: ExpressionNode;
|
|
484
|
+
y: ExpressionNode;
|
|
485
|
+
outType: IdentifierExpressionNode;
|
|
486
|
+
building: IdentifierExpressionNode;
|
|
487
|
+
floor: IdentifierExpressionNode;
|
|
488
|
+
};
|
|
489
|
+
export type StatementNodeWithin = StatementNodeControlBase & {
|
|
490
|
+
controlType: ControlType.WITHIN;
|
|
491
|
+
x: ExpressionNode;
|
|
492
|
+
y: ExpressionNode;
|
|
493
|
+
radius: ExpressionNode;
|
|
494
|
+
result: IdentifierExpressionNode;
|
|
495
|
+
};
|
|
496
|
+
export type StatementNodeUnbind = StatementNodeControlBase & {
|
|
497
|
+
controlType: ControlType.UNBIND;
|
|
498
|
+
};
|
|
499
|
+
export type ControlStatementNode = StatementNodeRead | StatementNodeWrite | StatementNodeDrawClear | StatementNodeDrawColor | StatementNodeDrawCol | StatementNodeDrawStroke | StatementNodeDrawLine | StatementNodeDrawRect | StatementNodeDrawLineRect | StatementNodeDrawPoly | StatementNodeDrawLinePoly | StatementNodeDrawTriangle | StatementNodeDrawImage | StatementNodePrint | StatementNodeDrawFlush | StatementNodePrintFlush | StatementNodeGetLink | StatementNodeSetEnabled | StatementNodeSetShoot | StatementNodeSetShootP | StatementNodeSetConfig | StatementNodeSetColor | StatementNodeRadar | StatementNodeSensor | StatementNodePackColor | StatementNodeWait | StatementNodeCpuStop | StatementNodeUnitBind | StatementNodeUnitRadar | StatementNodeUnitLocateOre | StatementNodeUnitLocateBuilding | StatementNodeUnitLocateSpawn | StatementNodeUnitLocateDamaged | StatementNodeIdle | StatementNodeStop | StatementNodeMove | StatementNodeApproach | StatementNodePathFind | StatementNodeAutoPathFind | StatementNodeBoost | StatementNodeTarget | StatementNodeTargetP | StatementNodeItemDrop | StatementNodeItemTake | StatementNodePayDrop | StatementNodePayTake | StatementNodePayEnter | StatementNodeMine | StatementNodeFlag | StatementNodeBuild | StatementNodeGetBlock | StatementNodeWithin | StatementNodeUnbind;
|
|
500
|
+
export type MacroDefineStatementNode = NodeBase & {
|
|
501
|
+
type: NodeType.BLOCK_STATEMENT;
|
|
502
|
+
statementType: StatementType.MACRO_DEFINE;
|
|
503
|
+
name: string;
|
|
504
|
+
inputParams: string[];
|
|
505
|
+
outputParams: string[];
|
|
506
|
+
body: StatementNode[];
|
|
507
|
+
};
|
|
508
|
+
export type MacroParamListNode = NodeBase & {
|
|
509
|
+
type: NodeType.MACRO_PARAM_LIST;
|
|
510
|
+
first: IdentifierExpressionNode;
|
|
511
|
+
other: MacroParamListNode | undefined;
|
|
512
|
+
};
|
|
513
|
+
export type MacroCallStatementNode = SingleStatementNodeBase & {
|
|
514
|
+
statementType: StatementType.MACRO_CALL;
|
|
515
|
+
name: string;
|
|
516
|
+
inputArgs: ExpressionNode[];
|
|
517
|
+
outputArgs: IdentifierExpressionNode[];
|
|
518
|
+
};
|
|
519
|
+
export type MacroArgListNode = NodeBase & {
|
|
520
|
+
type: NodeType.MACRO_ARG_LIST;
|
|
521
|
+
first: ExpressionNode;
|
|
522
|
+
other: MacroArgListNode | undefined;
|
|
523
|
+
};
|
|
524
|
+
export type IfElseStatementNode = NodeBase & {
|
|
525
|
+
type: NodeType.BLOCK_STATEMENT;
|
|
526
|
+
statementType: StatementType.IF_ELSE;
|
|
527
|
+
condition: ExpressionNode;
|
|
528
|
+
ifBody: StatementNode[];
|
|
529
|
+
elseBody: StatementNode[];
|
|
530
|
+
};
|
|
531
|
+
export type IfStatementNode = NodeBase & {
|
|
532
|
+
type: NodeType.BLOCK_STATEMENT;
|
|
533
|
+
statementType: StatementType.IF;
|
|
534
|
+
condition: ExpressionNode;
|
|
535
|
+
ifBody: StatementNode[];
|
|
536
|
+
};
|
|
537
|
+
export type ForStatementNode = NodeBase & {
|
|
538
|
+
type: NodeType.BLOCK_STATEMENT;
|
|
539
|
+
statementType: StatementType.FOR;
|
|
540
|
+
init: StatementNode;
|
|
541
|
+
condition: ExpressionNode;
|
|
542
|
+
increment: StatementNode | undefined;
|
|
543
|
+
body: StatementNode[];
|
|
544
|
+
};
|
|
545
|
+
export type WhileStatementNode = NodeBase & {
|
|
546
|
+
type: NodeType.BLOCK_STATEMENT;
|
|
547
|
+
statementType: StatementType.WHILE;
|
|
548
|
+
condition: ExpressionNode;
|
|
549
|
+
body: StatementNode[];
|
|
550
|
+
};
|
|
551
|
+
export declare enum LoopControlType {
|
|
552
|
+
CONTINUE = 0,
|
|
553
|
+
BREAK = 1
|
|
554
|
+
}
|
|
555
|
+
export type LoopControlStatementNode = SingleStatementNodeBase & {
|
|
556
|
+
statementType: StatementType.LOOP_CONTROL;
|
|
557
|
+
controlType: LoopControlType;
|
|
558
|
+
};
|
|
559
|
+
export type ReturnStatementNode = SingleStatementNodeBase & {
|
|
560
|
+
statementType: StatementType.RETURN;
|
|
561
|
+
expression: ExpressionNode;
|
|
562
|
+
};
|
|
563
|
+
export type BindStatementNode = SingleStatementNodeBase & {
|
|
564
|
+
statementType: StatementType.BIND;
|
|
565
|
+
variableName: string;
|
|
566
|
+
};
|
|
567
|
+
export type SingleStatementNode = EmptyStatementNode | VariableDefineStatementNode | AssignStatementNode | ControlStatementNode | MacroCallStatementNode | LoopControlStatementNode | ReturnStatementNode | BindStatementNode;
|
|
568
|
+
export type BlockStatementNode = MacroDefineStatementNode | IfElseStatementNode | IfStatementNode | ForStatementNode | WhileStatementNode;
|
|
569
|
+
type ModifyUnion<T, K extends PropertyKey, V> = T extends any ? {
|
|
570
|
+
[P in keyof T]: P extends K ? V : T[P];
|
|
571
|
+
} : never;
|
|
572
|
+
export type StatementBodyNode = ModifyUnion<SingleStatementNode, 'type', NodeType.STATEMENT_BODY>;
|
|
573
|
+
export type StatementNode = ModifyUnion<SingleStatementNode | BlockStatementNode, 'type', NodeType.STATEMENT>;
|
|
574
|
+
export type ExpressionNode = NodeBase & {
|
|
575
|
+
type: NodeType.EXPRESSION;
|
|
576
|
+
child: ExpressionChildNode;
|
|
577
|
+
};
|
|
578
|
+
export type UnaryOpType = TokenType.NOT | TokenType.FLIP;
|
|
579
|
+
export type UnaryOpExpressionNode = NodeBase & {
|
|
580
|
+
type: NodeType.UNARY_OP_EXPRESSION;
|
|
581
|
+
opType: UnaryOpType;
|
|
582
|
+
child: ExpressionChildNode;
|
|
583
|
+
};
|
|
584
|
+
export type BinaryOpType = TokenType.OR | TokenType.AND | TokenType.EQ | TokenType.NE | TokenType.LESS | TokenType.LE | TokenType.GREATER | TokenType.GE | TokenType.STRICT_EQ | TokenType.BITOR | TokenType.XOR | TokenType.BITAND | TokenType.SHL | TokenType.SHR | TokenType.ADD | TokenType.SUB | TokenType.MUL | TokenType.DIV | TokenType.IDIV | TokenType.MOD | TokenType.POW;
|
|
585
|
+
export type BinaryOpExpressionNode = NodeBase & {
|
|
586
|
+
type: NodeType.BINARY_OP_EXPRESSION;
|
|
587
|
+
opType: BinaryOpType;
|
|
588
|
+
lChild: ExpressionChildNode;
|
|
589
|
+
rChild: ExpressionChildNode;
|
|
590
|
+
};
|
|
591
|
+
export type Functions = TokenType.MAX | TokenType.MIN | TokenType.ANGLE | TokenType.ANGLE_DIFF | TokenType.LEN | TokenType.NOISE | TokenType.ABS | TokenType.LOG | TokenType.LOG10 | TokenType.FLOOR | TokenType.CEIL | TokenType.SQRT | TokenType.RAND | TokenType.SIN | TokenType.COS | TokenType.TAN | TokenType.ASIN | TokenType.ACOS | TokenType.ATAN;
|
|
592
|
+
export type FunctionCallExpressionNode = NodeBase & {
|
|
593
|
+
type: NodeType.FUNCTION_CALL_EXPRESSION;
|
|
594
|
+
function: Functions;
|
|
595
|
+
args: ExpressionChildNode[];
|
|
596
|
+
};
|
|
597
|
+
export type MacroCallExpressionNode = NodeBase & {
|
|
598
|
+
type: NodeType.MACRO_CALL_EXPRESSION;
|
|
599
|
+
name: string;
|
|
600
|
+
inputArgs: ExpressionChildNode[];
|
|
601
|
+
outputArgs: IdentifierExpressionNode[];
|
|
602
|
+
};
|
|
603
|
+
export type LiteralExpressionNode = NodeBase & {
|
|
604
|
+
type: NodeType.LITERAL_EXPRESSION;
|
|
605
|
+
value: number | boolean | string | null;
|
|
606
|
+
};
|
|
607
|
+
export declare enum IdentifierType {
|
|
608
|
+
SIMPLE = 0,
|
|
609
|
+
LET = 1,
|
|
610
|
+
CONST = 2
|
|
611
|
+
}
|
|
612
|
+
export type MindustryIdentifierExpressionNode = NodeBase & {
|
|
613
|
+
type: NodeType.IDENTIFIER_EXPRESSION;
|
|
614
|
+
value: string;
|
|
615
|
+
isMindustry: true;
|
|
616
|
+
};
|
|
617
|
+
export type MinduscriptIdentifierExpressionNode = NodeBase & {
|
|
618
|
+
type: NodeType.IDENTIFIER_EXPRESSION;
|
|
619
|
+
value: string;
|
|
620
|
+
identifierType: IdentifierType;
|
|
621
|
+
isMindustry: false;
|
|
622
|
+
};
|
|
623
|
+
export type IdentifierExpressionNode = MinduscriptIdentifierExpressionNode | MindustryIdentifierExpressionNode;
|
|
624
|
+
export type RadarConditionNode = NodeBase & {
|
|
625
|
+
type: NodeType.RADAR_CONDITION;
|
|
626
|
+
value: RadarCondition;
|
|
627
|
+
};
|
|
628
|
+
export type RadarSortConfigNode = NodeBase & {
|
|
629
|
+
type: NodeType.RADAR_SORT_CONFIG;
|
|
630
|
+
value: RadarSortConfig;
|
|
631
|
+
};
|
|
632
|
+
export type UnitLocateBuildingGroupNode = NodeBase & {
|
|
633
|
+
type: NodeType.UNIT_LOCATE_BUILDING_GROUP;
|
|
634
|
+
value: UnitLocateBuildingGroup;
|
|
635
|
+
};
|
|
636
|
+
export type BlockStatementBodyNode = NodeBase & {
|
|
637
|
+
type: NodeType.BLOCK_STATEMENT_BODY;
|
|
638
|
+
statements: StatementNode[];
|
|
639
|
+
};
|
|
640
|
+
export type AssignOpNode = NodeBase & {
|
|
641
|
+
type: NodeType.ASSIGN_OP;
|
|
642
|
+
assignType: AssignType;
|
|
643
|
+
};
|
|
644
|
+
export type ExpressionChildNode = UnaryOpExpressionNode | BinaryOpExpressionNode | FunctionCallExpressionNode | MacroCallExpressionNode | LiteralExpressionNode | IdentifierExpressionNode;
|
|
645
|
+
export type Node = DocumentNode | ImportListNode | ImportStatementNode | CodeBlockNode | StatementListNode | StatementNode | SingleStatementNode | BlockStatementNode | StatementBodyNode | MacroParamListNode | MacroArgListNode | RadarConditionNode | RadarSortConfigNode | UnitLocateBuildingGroupNode | ExpressionNode | ExpressionChildNode | BlockStatementBodyNode | AssignOpNode;
|
|
646
|
+
export type ASTNode = DocumentNode | ImportStatementNode | StatementNode | ExpressionNode | ExpressionChildNode;
|
|
647
|
+
export type ASTNodeTypes = ASTNode['type'];
|
|
648
|
+
export {};
|