@arcgis/arcade-parser 5.2.0-next.94
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/LICENSE.md +19 -0
- package/README.md +12 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +2342 -0
- package/dist/types.d.ts +1270 -0
- package/dist/utils.d.ts +4 -0
- package/package.json +16 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,1270 @@
|
|
|
1
|
+
/** Arcade literals. */
|
|
2
|
+
export const Literals: {
|
|
3
|
+
readonly False: "false";
|
|
4
|
+
readonly Null: "null";
|
|
5
|
+
readonly True: "true";
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/** Arcade literals. */
|
|
9
|
+
export type Literals = (typeof Literals)[keyof typeof Literals];
|
|
10
|
+
|
|
11
|
+
/** Arcade keywords. */
|
|
12
|
+
export const Keywords: {
|
|
13
|
+
readonly Break: "break";
|
|
14
|
+
readonly Continue: "continue";
|
|
15
|
+
readonly Else: "else";
|
|
16
|
+
readonly For: "for";
|
|
17
|
+
readonly Function: "function";
|
|
18
|
+
readonly If: "if";
|
|
19
|
+
readonly Import: "import";
|
|
20
|
+
readonly Export: "export";
|
|
21
|
+
readonly In: "in";
|
|
22
|
+
readonly Return: "return";
|
|
23
|
+
readonly Var: "var";
|
|
24
|
+
readonly While: "while";
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Arcade contextual keywords. */
|
|
28
|
+
export const ContextualKeywords: {
|
|
29
|
+
From: string;
|
|
30
|
+
Of: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Arcade keywords. */
|
|
34
|
+
export type Keywords = (typeof Keywords)[keyof typeof Keywords];
|
|
35
|
+
|
|
36
|
+
/** Arcade AST Node Types. */
|
|
37
|
+
export const NodeTypes: {
|
|
38
|
+
readonly AssignmentExpression: "AssignmentExpression";
|
|
39
|
+
readonly ArrayExpression: "ArrayExpression";
|
|
40
|
+
readonly BlockComment: "BlockComment";
|
|
41
|
+
readonly BlockStatement: "BlockStatement";
|
|
42
|
+
readonly BinaryExpression: "BinaryExpression";
|
|
43
|
+
readonly BreakStatement: "BreakStatement";
|
|
44
|
+
readonly CallExpression: "CallExpression";
|
|
45
|
+
readonly ContinueStatement: "ContinueStatement";
|
|
46
|
+
readonly EmptyStatement: "EmptyStatement";
|
|
47
|
+
readonly ExpressionStatement: "ExpressionStatement";
|
|
48
|
+
readonly ExportNamedDeclaration: "ExportNamedDeclaration";
|
|
49
|
+
readonly ExportSpecifier: "ExportSpecifier";
|
|
50
|
+
readonly ForStatement: "ForStatement";
|
|
51
|
+
readonly ForInStatement: "ForInStatement";
|
|
52
|
+
readonly ForOfStatement: "ForOfStatement";
|
|
53
|
+
readonly FunctionDeclaration: "FunctionDeclaration";
|
|
54
|
+
readonly Identifier: "Identifier";
|
|
55
|
+
readonly IfStatement: "IfStatement";
|
|
56
|
+
readonly ImportDeclaration: "ImportDeclaration";
|
|
57
|
+
readonly ImportDefaultSpecifier: "ImportDefaultSpecifier";
|
|
58
|
+
readonly LineComment: "LineComment";
|
|
59
|
+
readonly Literal: "Literal";
|
|
60
|
+
readonly LogicalExpression: "LogicalExpression";
|
|
61
|
+
readonly MemberAccessChainExpression: "MemberAccessChainExpression";
|
|
62
|
+
readonly MemberExpression: "MemberExpression";
|
|
63
|
+
readonly ObjectExpression: "ObjectExpression";
|
|
64
|
+
readonly Program: "Program";
|
|
65
|
+
readonly Property: "Property";
|
|
66
|
+
readonly ReturnStatement: "ReturnStatement";
|
|
67
|
+
readonly SafeMemberExpression: "SafeMemberExpression";
|
|
68
|
+
readonly TemplateElement: "TemplateElement";
|
|
69
|
+
readonly TemplateLiteral: "TemplateLiteral";
|
|
70
|
+
readonly UnaryExpression: "UnaryExpression";
|
|
71
|
+
readonly UpdateExpression: "UpdateExpression";
|
|
72
|
+
readonly VariableDeclaration: "VariableDeclaration";
|
|
73
|
+
readonly VariableDeclarator: "VariableDeclarator";
|
|
74
|
+
readonly WhileStatement: "WhileStatement";
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Arcade AST Node Types. */
|
|
78
|
+
export type NodeTypes = (typeof NodeTypes)[keyof typeof NodeTypes];
|
|
79
|
+
|
|
80
|
+
/** Arcade update operators. */
|
|
81
|
+
export const UpdateOperators: readonly [
|
|
82
|
+
"++",
|
|
83
|
+
"--"
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
/** Arcade update operators. */
|
|
87
|
+
export type UpdateOperators = (typeof UpdateOperators)[number];
|
|
88
|
+
|
|
89
|
+
/** Arcade unary operators. */
|
|
90
|
+
export const UnaryOperators: readonly [
|
|
91
|
+
"-",
|
|
92
|
+
"+",
|
|
93
|
+
"!",
|
|
94
|
+
"~"
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
/** Arcade unary operators. */
|
|
98
|
+
export type UnaryOperators = (typeof UnaryOperators)[number];
|
|
99
|
+
|
|
100
|
+
/** Arcade assignment operators. */
|
|
101
|
+
export const AssignmentOperators: readonly [
|
|
102
|
+
"=",
|
|
103
|
+
"/=",
|
|
104
|
+
"*=",
|
|
105
|
+
"%=",
|
|
106
|
+
"+=",
|
|
107
|
+
"-="
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
/** Arcade assignment operators. */
|
|
111
|
+
export type AssignmentOperators = (typeof AssignmentOperators)[number];
|
|
112
|
+
|
|
113
|
+
/** Arcade logical operators. */
|
|
114
|
+
export const LogicalOperators: readonly [
|
|
115
|
+
"||",
|
|
116
|
+
"&&"
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
/** Arcade logical operators. */
|
|
120
|
+
export type LogicalOperators = (typeof LogicalOperators)[number];
|
|
121
|
+
|
|
122
|
+
/** Arcade binary operators. */
|
|
123
|
+
export const BinaryOperators: readonly [
|
|
124
|
+
"|",
|
|
125
|
+
"&",
|
|
126
|
+
">>",
|
|
127
|
+
"<<",
|
|
128
|
+
">>>",
|
|
129
|
+
"^",
|
|
130
|
+
"==",
|
|
131
|
+
"!=",
|
|
132
|
+
"<",
|
|
133
|
+
"<=",
|
|
134
|
+
">",
|
|
135
|
+
">=",
|
|
136
|
+
"+",
|
|
137
|
+
"-",
|
|
138
|
+
"*",
|
|
139
|
+
"/",
|
|
140
|
+
"%"
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
/** Arcade binary operators. */
|
|
144
|
+
export type BinaryOperators = (typeof BinaryOperators)[number];
|
|
145
|
+
|
|
146
|
+
export const SafeAccessOperator: "?.";
|
|
147
|
+
|
|
148
|
+
export type SafeAccessOperator = typeof SafeAccessOperator;
|
|
149
|
+
|
|
150
|
+
/** Arcade operators precedence. */
|
|
151
|
+
export const OperatorPrecedence: {
|
|
152
|
+
readonly "||": 1;
|
|
153
|
+
readonly "&&": 2;
|
|
154
|
+
readonly "|": 3;
|
|
155
|
+
readonly "^": 4;
|
|
156
|
+
readonly "&": 5;
|
|
157
|
+
readonly "==": 6;
|
|
158
|
+
readonly "!=": 6;
|
|
159
|
+
readonly "<": 7;
|
|
160
|
+
readonly ">": 7;
|
|
161
|
+
readonly "<=": 7;
|
|
162
|
+
readonly ">=": 7;
|
|
163
|
+
readonly "<<": 8;
|
|
164
|
+
readonly ">>": 8;
|
|
165
|
+
readonly ">>>": 8;
|
|
166
|
+
readonly "+": 9;
|
|
167
|
+
readonly "-": 9;
|
|
168
|
+
readonly "*": 10;
|
|
169
|
+
readonly "/": 10;
|
|
170
|
+
readonly "%": 10;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/** Describe a position in the source code as 1-based line number and 0-based column number. */
|
|
174
|
+
export interface Position {
|
|
175
|
+
/** The 1-based line number. */
|
|
176
|
+
line: number;
|
|
177
|
+
/** The 0-based column number. */
|
|
178
|
+
column: number;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Describe a range in the source code between two positions as [start, end].
|
|
183
|
+
* Start is inclusive and end is exclusive.
|
|
184
|
+
* Positions are 1-based line number and 0-based column number.
|
|
185
|
+
*/
|
|
186
|
+
export interface SourceLocation {
|
|
187
|
+
/** The position of the first character of the parsed source region (inclusive). */
|
|
188
|
+
start: Position;
|
|
189
|
+
/** The position of the first character after the parsed source region (exclusive). */
|
|
190
|
+
end: Position;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Describe the location of a character in the source code. */
|
|
194
|
+
export interface Marker extends Position {
|
|
195
|
+
/** The zero based index of the character where the marker begins in the source code. */
|
|
196
|
+
index: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Describe the location of a an item in the source code.
|
|
201
|
+
* The range is [inclusive, exclusive].
|
|
202
|
+
* The location is 1-based line number and 0-based column number.
|
|
203
|
+
*/
|
|
204
|
+
export interface ItemLocation {
|
|
205
|
+
/** The location of the item in the source code as start and end positions. */
|
|
206
|
+
loc: SourceLocation;
|
|
207
|
+
/**
|
|
208
|
+
* The range of the item in the source code as start and end indexes.
|
|
209
|
+
* The range is [inclusive, exclusive].
|
|
210
|
+
*/
|
|
211
|
+
range: [number, number];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Arcade scanner token types. */
|
|
215
|
+
export const TokenTypes: {
|
|
216
|
+
readonly Unknown: 0;
|
|
217
|
+
readonly BooleanLiteral: 1;
|
|
218
|
+
readonly EOF: 2;
|
|
219
|
+
readonly Identifier: 3;
|
|
220
|
+
readonly Keyword: 4;
|
|
221
|
+
readonly NullLiteral: 5;
|
|
222
|
+
readonly NumericLiteral: 6;
|
|
223
|
+
readonly Punctuator: 7;
|
|
224
|
+
readonly StringLiteral: 8;
|
|
225
|
+
readonly Template: 10;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/** Arcade scanner token types. */
|
|
229
|
+
export type TokenTypes = (typeof TokenTypes)[keyof typeof TokenTypes];
|
|
230
|
+
|
|
231
|
+
/** Arcade scanner token names. */
|
|
232
|
+
export const TokenNames: readonly [
|
|
233
|
+
"Unknown",
|
|
234
|
+
"Boolean",
|
|
235
|
+
"<end>",
|
|
236
|
+
"Identifier",
|
|
237
|
+
"Keyword",
|
|
238
|
+
"Null",
|
|
239
|
+
"Numeric",
|
|
240
|
+
"Punctuator",
|
|
241
|
+
"String",
|
|
242
|
+
"RegularExpression",
|
|
243
|
+
"Template"
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
/** Arcade scanner token names. */
|
|
247
|
+
export type TokenNames = (typeof TokenNames)[number];
|
|
248
|
+
|
|
249
|
+
/** Define the options for the scanner. */
|
|
250
|
+
export interface TokenizeOptions {
|
|
251
|
+
tolerant?: boolean;
|
|
252
|
+
range?: boolean;
|
|
253
|
+
loc?: boolean;
|
|
254
|
+
comment?: boolean;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Define a token returned by the scanner. */
|
|
258
|
+
export interface Token extends ItemLocation {
|
|
259
|
+
/** The type of the token found. */
|
|
260
|
+
type: TokenNames | typeof NodeTypes.BlockComment | typeof NodeTypes.LineComment;
|
|
261
|
+
/** The value of the token. */
|
|
262
|
+
value: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** Define the options for the parser. */
|
|
266
|
+
export interface ParseOptions {
|
|
267
|
+
tolerant?: boolean;
|
|
268
|
+
tokens?: boolean;
|
|
269
|
+
comments?: boolean;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Arcade diagnostic error codes. */
|
|
273
|
+
export const DiagnosticCodes: {
|
|
274
|
+
readonly InvalidModuleUri: "InvalidModuleUri";
|
|
275
|
+
readonly ForInOfLoopInitializer: "ForInOfLoopInitializer";
|
|
276
|
+
readonly IdentifierExpected: "IdentifierExpected";
|
|
277
|
+
readonly InvalidEscapedReservedWord: "InvalidEscapedReservedWord";
|
|
278
|
+
readonly InvalidExpression: "InvalidExpression";
|
|
279
|
+
readonly InvalidFunctionIdentifier: "InvalidFunctionIdentifier";
|
|
280
|
+
readonly InvalidHexEscapeSequence: "InvalidHexEscapeSequence";
|
|
281
|
+
readonly InvalidLeftHandSideInAssignment: "InvalidLeftHandSideInAssignment";
|
|
282
|
+
readonly InvalidLeftHandSideInForIn: "InvalidLeftHandSideInForIn";
|
|
283
|
+
readonly InvalidTemplateHead: "InvalidTemplateHead";
|
|
284
|
+
readonly InvalidVariableAssignment: "InvalidVariableAssignment";
|
|
285
|
+
readonly KeyMustBeString: "KeyMustBeString";
|
|
286
|
+
readonly NoFunctionInsideBlock: "NoFunctionInsideBlock";
|
|
287
|
+
readonly NoFunctionInsideFunction: "NoFunctionInsideFunction";
|
|
288
|
+
readonly ModuleExportRootOnly: "ModuleExportRootOnly";
|
|
289
|
+
readonly ModuleImportRootOnly: "ModuleImportRootOnly";
|
|
290
|
+
readonly PunctuatorExpected: "PunctuatorExpected";
|
|
291
|
+
readonly TemplateOctalLiteral: "TemplateOctalLiteral";
|
|
292
|
+
readonly UnexpectedBoolean: "UnexpectedBoolean";
|
|
293
|
+
readonly UnexpectedEndOfScript: "UnexpectedEndOfScript";
|
|
294
|
+
readonly UnexpectedIdentifier: "UnexpectedIdentifier";
|
|
295
|
+
readonly UnexpectedKeyword: "UnexpectedKeyword";
|
|
296
|
+
readonly UnexpectedNull: "UnexpectedNull";
|
|
297
|
+
readonly UnexpectedNumber: "UnexpectedNumber";
|
|
298
|
+
readonly UnexpectedPunctuator: "UnexpectedPunctuator";
|
|
299
|
+
readonly UnexpectedString: "UnexpectedString";
|
|
300
|
+
readonly UnexpectedTemplate: "UnexpectedTemplate";
|
|
301
|
+
readonly UnexpectedToken: "UnexpectedToken";
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/** Arcade diagnostic error codes. */
|
|
305
|
+
export type DiagnosticCodes = (typeof DiagnosticCodes)[keyof typeof DiagnosticCodes];
|
|
306
|
+
|
|
307
|
+
/** Arcade diagnostic messages. */
|
|
308
|
+
export const DiagnosticMessages: Record<DiagnosticCodes, string>;
|
|
309
|
+
|
|
310
|
+
/** Arcade diagnostic data. */
|
|
311
|
+
export type DiagnosticData = Record<string, number | string>;
|
|
312
|
+
|
|
313
|
+
/** Define the properties of a diagnostic. */
|
|
314
|
+
export interface DiagnosticApi extends Marker {
|
|
315
|
+
/** The diagnostic code. */
|
|
316
|
+
code: DiagnosticCodes;
|
|
317
|
+
/** The diagnostic description. */
|
|
318
|
+
description?: string;
|
|
319
|
+
/** The length of the token. */
|
|
320
|
+
len?: number;
|
|
321
|
+
/** The associated diagnostic data. */
|
|
322
|
+
data?: DiagnosticData | null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** The Arcade diagnostic class. */
|
|
326
|
+
export class Diagnostic extends Error {
|
|
327
|
+
constructor(diagnosticApi: DiagnosticApi);
|
|
328
|
+
code: DiagnosticCodes;
|
|
329
|
+
column: number;
|
|
330
|
+
data?: DiagnosticData | null;
|
|
331
|
+
/** @default "esri.arcade.lib.diagnostic" */
|
|
332
|
+
readonly declaredRootClass: string;
|
|
333
|
+
description?: string;
|
|
334
|
+
index: number;
|
|
335
|
+
len: number;
|
|
336
|
+
line: number;
|
|
337
|
+
range: SourceLocation;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Define a line comment. */
|
|
341
|
+
export interface LineComment extends ItemLocation {
|
|
342
|
+
readonly type: typeof NodeTypes.LineComment;
|
|
343
|
+
/** The value of the comment. */
|
|
344
|
+
value: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** Define a block comment. */
|
|
348
|
+
export interface BlockComment extends ItemLocation {
|
|
349
|
+
readonly type: typeof NodeTypes.BlockComment;
|
|
350
|
+
/** The value of the comment. */
|
|
351
|
+
value: string;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Define a comment of type block or line. */
|
|
355
|
+
export type Comment = BlockComment | LineComment;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Define the delegate for the parser.
|
|
359
|
+
*
|
|
360
|
+
* @param node
|
|
361
|
+
*/
|
|
362
|
+
export type Delegate = (node: Node) => void;
|
|
363
|
+
|
|
364
|
+
/** Define the types of Arcade Declaration. */
|
|
365
|
+
export type Declaration = ExportNamedDeclaration | FunctionDeclaration | ImportDeclaration | VariableDeclaration;
|
|
366
|
+
|
|
367
|
+
/** Define the types of Arcade Statement. */
|
|
368
|
+
export type Statement = BlockStatement | BreakStatement | ContinueStatement | Declaration | EmptyStatement | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | IfStatement | ReturnStatement | WhileStatement;
|
|
369
|
+
|
|
370
|
+
/** Define the types of Arcade Expression. */
|
|
371
|
+
export type Expression = ArrayExpression | AssignmentExpression | BinaryExpression | CallExpression | Identifier | Literal | LogicalExpression | MemberAccessChainExpression | MemberExpression | ObjectExpression | SafeMemberExpression | TemplateLiteral | UnaryExpression | UpdateExpression;
|
|
372
|
+
|
|
373
|
+
/** Define the types of Arcade AST Node (excluding comments). */
|
|
374
|
+
export type Node = Expression | ImportDefaultSpecifier | Program | Property | Statement | TemplateElement | VariableDeclarator;
|
|
375
|
+
|
|
376
|
+
/** Define the base properties of any Arcade AST Node. */
|
|
377
|
+
export interface NodeBase<T extends NodeTypes> extends ItemLocation {
|
|
378
|
+
/** The type of the node. */
|
|
379
|
+
type: T;
|
|
380
|
+
/** The leading comments of the node. */
|
|
381
|
+
leadingComments?: Comment[];
|
|
382
|
+
/** The trailing comments of the node. */
|
|
383
|
+
trailingComments?: Comment[];
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** Define an Arcade program. */
|
|
387
|
+
export interface Program extends NodeBase<typeof NodeTypes.Program> {
|
|
388
|
+
/** The collection of statements in the program. */
|
|
389
|
+
body: Statement[];
|
|
390
|
+
/** The collection of comments inside the program. */
|
|
391
|
+
comments?: Comment[];
|
|
392
|
+
/** The collection of tokens inside the program. */
|
|
393
|
+
tokens?: Token[];
|
|
394
|
+
/** The collection of errors inside the program. */
|
|
395
|
+
errors?: Error[];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Define an Arcade export declaration.
|
|
400
|
+
* Example: export function foo() {}
|
|
401
|
+
* The declaration is the function declaration: function foo() {}
|
|
402
|
+
* The specifiers are foo and bar
|
|
403
|
+
*/
|
|
404
|
+
export interface ExportNamedDeclaration extends NodeBase<typeof NodeTypes.ExportNamedDeclaration> {
|
|
405
|
+
/**
|
|
406
|
+
* The declaration of the export.
|
|
407
|
+
* Example: export function foo() {}
|
|
408
|
+
* The declaration is the function declaration: function foo() {}
|
|
409
|
+
*/
|
|
410
|
+
declaration: FunctionDeclaration | VariableDeclaration;
|
|
411
|
+
/**
|
|
412
|
+
* The specifiers of the export.
|
|
413
|
+
* Example: export { foo, bar }
|
|
414
|
+
* The specifiers are foo and bar.
|
|
415
|
+
*/
|
|
416
|
+
specifiers: ExportSpecifier[];
|
|
417
|
+
/**
|
|
418
|
+
* The source of the export.
|
|
419
|
+
* Example: export { foo, bar } from "./my-module"
|
|
420
|
+
* The source is "./my-module"
|
|
421
|
+
*/
|
|
422
|
+
source: Literal | null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Define an Arcade export specifier.
|
|
427
|
+
* Example: export { foo as bar }
|
|
428
|
+
* The specifier is foo as bar.
|
|
429
|
+
*/
|
|
430
|
+
export interface ExportSpecifier extends NodeBase<typeof NodeTypes.ExportSpecifier> {
|
|
431
|
+
/**
|
|
432
|
+
* The exported identifier.
|
|
433
|
+
* Example: export { foo as bar }
|
|
434
|
+
* The exported identifier is bar.
|
|
435
|
+
*/
|
|
436
|
+
exported: Identifier;
|
|
437
|
+
/**
|
|
438
|
+
* The local identifier.
|
|
439
|
+
* Example: export { foo as bar }
|
|
440
|
+
* The local identifier is foo.
|
|
441
|
+
*/
|
|
442
|
+
local: Identifier;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Define an Arcade import declaration.
|
|
447
|
+
* Example: import { foo, bar } from "./my-module"
|
|
448
|
+
* The specifiers are foo and bar.
|
|
449
|
+
* The source is "./my-module"
|
|
450
|
+
*/
|
|
451
|
+
export interface ImportDeclaration extends NodeBase<typeof NodeTypes.ImportDeclaration> {
|
|
452
|
+
/**
|
|
453
|
+
* The specifiers of the import.
|
|
454
|
+
* Example: import { foo, bar } from "./my-module"
|
|
455
|
+
* The specifiers are foo and bar.
|
|
456
|
+
*/
|
|
457
|
+
specifiers: ImportDefaultSpecifier[];
|
|
458
|
+
/**
|
|
459
|
+
* The source of the import.
|
|
460
|
+
* Example: import { foo, bar } from "./my-module"
|
|
461
|
+
* The source is "./my-module"
|
|
462
|
+
*/
|
|
463
|
+
source: Literal;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Define an Arcade import default specifier.
|
|
468
|
+
* Example: import "./my-module"
|
|
469
|
+
* The local is "./my-module"
|
|
470
|
+
*/
|
|
471
|
+
export interface ImportDefaultSpecifier extends NodeBase<typeof NodeTypes.ImportDefaultSpecifier> {
|
|
472
|
+
/**
|
|
473
|
+
* The local identifier.
|
|
474
|
+
* Example: import "./my-module"
|
|
475
|
+
* The local is "./my-module"
|
|
476
|
+
*/
|
|
477
|
+
local: Identifier;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** Define an Arcade function declaration. */
|
|
481
|
+
export interface FunctionDeclaration extends NodeBase<typeof NodeTypes.FunctionDeclaration> {
|
|
482
|
+
/**
|
|
483
|
+
* The identifier of the function.
|
|
484
|
+
* Example: function foo() {}
|
|
485
|
+
* The identifier is foo.
|
|
486
|
+
*/
|
|
487
|
+
id: Identifier;
|
|
488
|
+
/**
|
|
489
|
+
* The parameters of the function.
|
|
490
|
+
* Example: function foo(bar, baz) {}
|
|
491
|
+
* The parameters are bar and baz.
|
|
492
|
+
*/
|
|
493
|
+
params: Identifier[];
|
|
494
|
+
/**
|
|
495
|
+
* The body of the function.
|
|
496
|
+
* Example: function foo() { return 1; }
|
|
497
|
+
* The body is { return 1; }
|
|
498
|
+
*/
|
|
499
|
+
body: BlockStatement;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Define an Arcade variable declaration.
|
|
504
|
+
* Example: var foo = 1, bar = 2;
|
|
505
|
+
* The declarators are foo = 1 and bar = 2.
|
|
506
|
+
*/
|
|
507
|
+
export interface VariableDeclaration extends NodeBase<typeof NodeTypes.VariableDeclaration> {
|
|
508
|
+
/**
|
|
509
|
+
* The declarators of the variable declaration.
|
|
510
|
+
* Example: var foo = 1, bar = 2;
|
|
511
|
+
* The declarators are foo = 1 and bar = 2.
|
|
512
|
+
*/
|
|
513
|
+
declarations: VariableDeclarator[];
|
|
514
|
+
/** The kind is always "var" for Arcade. */
|
|
515
|
+
kind: "var";
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Define an Arcade variable declarator.
|
|
520
|
+
* Example: var foo = 1;
|
|
521
|
+
* The identifier is foo.
|
|
522
|
+
* The init is 1.
|
|
523
|
+
*/
|
|
524
|
+
export interface VariableDeclarator extends NodeBase<typeof NodeTypes.VariableDeclarator> {
|
|
525
|
+
/** The identifier of the variable declarator. */
|
|
526
|
+
id: Identifier;
|
|
527
|
+
/** The init of the variable declarator. */
|
|
528
|
+
init: Expression | null;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Define an Arcade block statement.
|
|
533
|
+
* Example: { return 1; }
|
|
534
|
+
*/
|
|
535
|
+
export interface BlockStatement extends NodeBase<typeof NodeTypes.BlockStatement> {
|
|
536
|
+
/** The collection of statements in the block. */
|
|
537
|
+
body: Statement[];
|
|
538
|
+
/** The collection of comments inside the block. */
|
|
539
|
+
innerComments?: Comment[];
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Define an Arcade break statement.
|
|
544
|
+
* Example: for (var i = 0; i < 10; i++) { break; }
|
|
545
|
+
*/
|
|
546
|
+
export type BreakStatement = NodeBase<typeof NodeTypes.BreakStatement>;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Define an Arcade continue statement.
|
|
550
|
+
* Example: for (var i = 0; i < 10; i++) { continue; }
|
|
551
|
+
*/
|
|
552
|
+
export type ContinueStatement = NodeBase<typeof NodeTypes.ContinueStatement>;
|
|
553
|
+
|
|
554
|
+
/** Define an Arcade empty statement. */
|
|
555
|
+
export type EmptyStatement = NodeBase<typeof NodeTypes.EmptyStatement>;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Define an Arcade expression statement.
|
|
559
|
+
* Example: a = 1;
|
|
560
|
+
*/
|
|
561
|
+
export interface ExpressionStatement extends NodeBase<typeof NodeTypes.ExpressionStatement> {
|
|
562
|
+
/** The expression of the statement. */
|
|
563
|
+
expression: Expression;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Define an Arcade for-in statement.
|
|
568
|
+
* Example:
|
|
569
|
+
* ```
|
|
570
|
+
* var arr = ['a', 'b'];
|
|
571
|
+
* for (var i in arr) {
|
|
572
|
+
* Console(arr[i])
|
|
573
|
+
* }
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
export interface ForInStatement extends NodeBase<typeof NodeTypes.ForInStatement> {
|
|
577
|
+
/** The left: `var i`. */
|
|
578
|
+
left: Identifier | VariableDeclaration;
|
|
579
|
+
/** The right: `arr`. */
|
|
580
|
+
right: Expression;
|
|
581
|
+
/** The body: `Console(arr[i])`. */
|
|
582
|
+
body: Statement;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Define an Arcade for-of statement.
|
|
587
|
+
* Example:
|
|
588
|
+
* ```
|
|
589
|
+
* var arr = ['a', 'b'];
|
|
590
|
+
* for (var v in arr) {
|
|
591
|
+
* Console(v)
|
|
592
|
+
* }
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
export interface ForOfStatement extends NodeBase<typeof NodeTypes.ForOfStatement> {
|
|
596
|
+
/** The left side: `var v`. */
|
|
597
|
+
left: Identifier | VariableDeclaration;
|
|
598
|
+
/** The right side: `arr`. */
|
|
599
|
+
right: Expression;
|
|
600
|
+
/** The body: `Console(v)`. */
|
|
601
|
+
body: Statement;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Define an Arcade for statement.
|
|
606
|
+
* Example: for (var i = 0; i < 10; i++) { console(i); }
|
|
607
|
+
*/
|
|
608
|
+
export interface ForStatement extends NodeBase<typeof NodeTypes.ForStatement> {
|
|
609
|
+
/**
|
|
610
|
+
* The init of the for statement.
|
|
611
|
+
* Example: for (var i = 0; i < 10; i++) { console(i); }
|
|
612
|
+
* The init is var i = 0.
|
|
613
|
+
*/
|
|
614
|
+
init: Expression | VariableDeclaration | null;
|
|
615
|
+
/**
|
|
616
|
+
* The test of the for statement.
|
|
617
|
+
* Example: for (var i = 0; i < 10; i++) { console(i); }
|
|
618
|
+
* The test is i < 10.
|
|
619
|
+
*/
|
|
620
|
+
test: Expression | null;
|
|
621
|
+
/**
|
|
622
|
+
* The update of the for statement.
|
|
623
|
+
* Example: for (var i = 0; i < 10; i++) { console(i); }
|
|
624
|
+
* The update is i++.
|
|
625
|
+
*/
|
|
626
|
+
update: Expression | null;
|
|
627
|
+
/** The body of the for statement. */
|
|
628
|
+
body: Statement;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Define an Arcade function declaration.
|
|
633
|
+
* Example: while (a < 10) { console(a++); }
|
|
634
|
+
*/
|
|
635
|
+
export interface WhileStatement extends NodeBase<typeof NodeTypes.WhileStatement> {
|
|
636
|
+
/**
|
|
637
|
+
* The test of the while statement.
|
|
638
|
+
* Example: while (a < 10) { console(a++); }
|
|
639
|
+
* The test is a < 10.
|
|
640
|
+
*/
|
|
641
|
+
test: Exclude<Expression, AssignmentExpression | UpdateExpression>;
|
|
642
|
+
/** The body of the while statement. */
|
|
643
|
+
body: Statement;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Define an Arcade if statement.
|
|
648
|
+
* Example: if (a < 10) { console(a++); } else { console(a--); }
|
|
649
|
+
*/
|
|
650
|
+
export interface IfStatement extends NodeBase<typeof NodeTypes.IfStatement> {
|
|
651
|
+
/**
|
|
652
|
+
* The test of the if statement.
|
|
653
|
+
* Example: if (a < 10) { console(a++); } else { console(a--); }
|
|
654
|
+
* The test is a < 10.
|
|
655
|
+
*/
|
|
656
|
+
test: Exclude<Expression, AssignmentExpression | UpdateExpression>;
|
|
657
|
+
/**
|
|
658
|
+
* The consequent of the if statement.
|
|
659
|
+
* Example: if (a < 10) { console(a++); } else { console(a--); }
|
|
660
|
+
* The consequent is console(a++).
|
|
661
|
+
*/
|
|
662
|
+
consequent: Statement;
|
|
663
|
+
/**
|
|
664
|
+
* The alternate of the if statement.
|
|
665
|
+
* Example: if (a < 10) { console(a++); } else { console(a--); }
|
|
666
|
+
* The alternate is console(a--).
|
|
667
|
+
*/
|
|
668
|
+
alternate: Statement | null;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Define an Arcade return statement.
|
|
673
|
+
* Example: return 1;
|
|
674
|
+
*/
|
|
675
|
+
export interface ReturnStatement extends NodeBase<typeof NodeTypes.ReturnStatement> {
|
|
676
|
+
/** The argument of the return statement. */
|
|
677
|
+
argument: Expression | null;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Define an Arcade array expression.
|
|
682
|
+
* Example: [1, 2, 3]
|
|
683
|
+
*/
|
|
684
|
+
export interface ArrayExpression extends NodeBase<typeof NodeTypes.ArrayExpression> {
|
|
685
|
+
/** The elements of the array expression. */
|
|
686
|
+
elements: Expression[];
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Define an Arcade assignment expression.
|
|
691
|
+
* Example: a = 1;
|
|
692
|
+
*/
|
|
693
|
+
export interface AssignmentExpression extends NodeBase<typeof NodeTypes.AssignmentExpression> {
|
|
694
|
+
/**
|
|
695
|
+
* The operator of the assignment expression.
|
|
696
|
+
* Example: a = 1;
|
|
697
|
+
*/
|
|
698
|
+
operator: AssignmentOperators;
|
|
699
|
+
/**
|
|
700
|
+
* The left side of the assignment expression.
|
|
701
|
+
* Example: a = 1;
|
|
702
|
+
* The left side is a.
|
|
703
|
+
*/
|
|
704
|
+
left: Identifier | MemberExpression;
|
|
705
|
+
/**
|
|
706
|
+
* The right side of the assignment expression.
|
|
707
|
+
* Example: a = 1;
|
|
708
|
+
* The right side is 1.
|
|
709
|
+
*/
|
|
710
|
+
right: Expression;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Define an Arcade binary expression.
|
|
715
|
+
* Example: a << 1; or a + 1;
|
|
716
|
+
*/
|
|
717
|
+
export interface BinaryExpression extends NodeBase<typeof NodeTypes.BinaryExpression> {
|
|
718
|
+
/**
|
|
719
|
+
* The operator of the binary expression.
|
|
720
|
+
* Example: a << 1; or a + 1;
|
|
721
|
+
* The operator is << or +.
|
|
722
|
+
*/
|
|
723
|
+
operator: BinaryOperators;
|
|
724
|
+
/**
|
|
725
|
+
* The left side of the binary expression.
|
|
726
|
+
* Example: a << 1; or a + 1;
|
|
727
|
+
* The left side is a.
|
|
728
|
+
*/
|
|
729
|
+
left: Expression;
|
|
730
|
+
/**
|
|
731
|
+
* The right side of the binary expression.
|
|
732
|
+
* Example: a << 1; or a + 1;
|
|
733
|
+
* The right side is 1.
|
|
734
|
+
*/
|
|
735
|
+
right: Expression;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Define an Arcade call expression.
|
|
740
|
+
* Example: foo(1, 2, 3)
|
|
741
|
+
*/
|
|
742
|
+
export interface CallExpression extends NodeBase<typeof NodeTypes.CallExpression> {
|
|
743
|
+
/**
|
|
744
|
+
* The callee of the call expression.
|
|
745
|
+
* Example: foo(1, 2, 3)
|
|
746
|
+
* The callee is foo.
|
|
747
|
+
*/
|
|
748
|
+
callee: Expression;
|
|
749
|
+
/**
|
|
750
|
+
* The arguments of the call expression.
|
|
751
|
+
* Example: foo(1, 2, 3)
|
|
752
|
+
* The arguments are 1, 2 and 3.
|
|
753
|
+
*/
|
|
754
|
+
arguments: Expression[];
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Define an Arcade identifier.
|
|
759
|
+
* Example: foo
|
|
760
|
+
*/
|
|
761
|
+
export interface Identifier extends NodeBase<typeof NodeTypes.Identifier> {
|
|
762
|
+
/**
|
|
763
|
+
* The name of the identifier.
|
|
764
|
+
* Example: foo
|
|
765
|
+
* The name is foo.
|
|
766
|
+
*/
|
|
767
|
+
name: string;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Define an Arcade literal.
|
|
772
|
+
* Example: 1 or "foo"
|
|
773
|
+
* The value is 1 or "foo".
|
|
774
|
+
*/
|
|
775
|
+
export interface Literal extends NodeBase<typeof NodeTypes.Literal> {
|
|
776
|
+
/** Indicate if the literal is a string. */
|
|
777
|
+
isString: boolean;
|
|
778
|
+
/**
|
|
779
|
+
* The value of the literal.
|
|
780
|
+
* Example: 1 or "foo"
|
|
781
|
+
* The value is 1 or "foo".
|
|
782
|
+
*/
|
|
783
|
+
value: boolean | number | string | null;
|
|
784
|
+
/**
|
|
785
|
+
* The raw value of the literal.
|
|
786
|
+
* Example: 1 or "foo"
|
|
787
|
+
* The raw value is "1" or "foo".
|
|
788
|
+
*/
|
|
789
|
+
raw: string;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Define an Arcade logical expression.
|
|
794
|
+
* Example: a || b
|
|
795
|
+
*/
|
|
796
|
+
export interface LogicalExpression extends NodeBase<typeof NodeTypes.LogicalExpression> {
|
|
797
|
+
/**
|
|
798
|
+
* The operator of the logical expression.
|
|
799
|
+
* Example: a || b
|
|
800
|
+
* The operator is ||.
|
|
801
|
+
*/
|
|
802
|
+
operator: LogicalOperators;
|
|
803
|
+
/**
|
|
804
|
+
* The left side of the logical expression.
|
|
805
|
+
* Example: a || b
|
|
806
|
+
* The left side is a.
|
|
807
|
+
* Note that left can never be an AssignmentExpression or an UpdateExpression.
|
|
808
|
+
*/
|
|
809
|
+
left: Expression;
|
|
810
|
+
/**
|
|
811
|
+
* The right side of the logical expression.
|
|
812
|
+
* Example: a || b
|
|
813
|
+
* The right side is b.
|
|
814
|
+
* Note that right can never be an AssignmentExpression or an UpdateExpression.
|
|
815
|
+
*/
|
|
816
|
+
right: Expression;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Define an Arcade computed member expression.
|
|
821
|
+
* Example: foo[1]
|
|
822
|
+
*/
|
|
823
|
+
export interface ComputedMemberExpression extends NodeBase<typeof NodeTypes.MemberExpression> {
|
|
824
|
+
readonly computed: true;
|
|
825
|
+
/**
|
|
826
|
+
* The object of the member expression.
|
|
827
|
+
* Example: foo[1]
|
|
828
|
+
* The object is foo.
|
|
829
|
+
*/
|
|
830
|
+
object: Expression;
|
|
831
|
+
/**
|
|
832
|
+
* The property of the member expression.
|
|
833
|
+
* Example: foo[1]
|
|
834
|
+
* The property is 1.
|
|
835
|
+
*/
|
|
836
|
+
property: Expression;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Define an Arcade safe computed member expression.
|
|
841
|
+
* Example: foo?.[1]
|
|
842
|
+
*/
|
|
843
|
+
export interface SafeComputedMemberExpression extends NodeBase<typeof NodeTypes.SafeMemberExpression> {
|
|
844
|
+
readonly computed: true;
|
|
845
|
+
/**
|
|
846
|
+
* The object of the member expression.
|
|
847
|
+
* Example: foo?.[1]
|
|
848
|
+
* The object is foo.
|
|
849
|
+
*/
|
|
850
|
+
object: Expression;
|
|
851
|
+
/**
|
|
852
|
+
* The property of the member expression.
|
|
853
|
+
* Example: foo?.[1]
|
|
854
|
+
* The property is 1.
|
|
855
|
+
*/
|
|
856
|
+
property: Expression;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Define an Arcade non-computed member expression.
|
|
861
|
+
* Example: foo.bar
|
|
862
|
+
*/
|
|
863
|
+
export interface NonComputedMemberExpression extends NodeBase<typeof NodeTypes.MemberExpression> {
|
|
864
|
+
readonly computed: false;
|
|
865
|
+
/**
|
|
866
|
+
* The object of the member expression.
|
|
867
|
+
* Example: foo.bar
|
|
868
|
+
* The object is foo.
|
|
869
|
+
*/
|
|
870
|
+
object: Expression;
|
|
871
|
+
/**
|
|
872
|
+
* The property of the member expression.
|
|
873
|
+
* Example: foo.bar
|
|
874
|
+
* The property is bar.
|
|
875
|
+
*/
|
|
876
|
+
property: Identifier;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Define an Arcade safe non-computed member expression.
|
|
881
|
+
* Example: foo?.bar
|
|
882
|
+
*/
|
|
883
|
+
export interface SafeNonComputedMemberExpression extends NodeBase<typeof NodeTypes.SafeMemberExpression> {
|
|
884
|
+
readonly computed: false;
|
|
885
|
+
/**
|
|
886
|
+
* The object of the member expression.
|
|
887
|
+
* Example: foo?.bar
|
|
888
|
+
* The object is foo.
|
|
889
|
+
*/
|
|
890
|
+
object: Expression;
|
|
891
|
+
/**
|
|
892
|
+
* The property of the member expression.
|
|
893
|
+
* Example: foo?.bar
|
|
894
|
+
* The property is bar.
|
|
895
|
+
*/
|
|
896
|
+
property: Identifier;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Define an Arcade member expression.
|
|
901
|
+
* Example: foo.bar or foo[1]
|
|
902
|
+
*/
|
|
903
|
+
export type MemberExpression = ComputedMemberExpression | NonComputedMemberExpression;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Define an Arcade safe member expression.
|
|
907
|
+
* Example: foo?.bar or foo?.[1]
|
|
908
|
+
*/
|
|
909
|
+
export type SafeMemberExpression = SafeComputedMemberExpression | SafeNonComputedMemberExpression;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* The enclosing scope for SafeMemberExpressions. Failed accesses in `expression` (or descendent `callee`/`object` expressions)
|
|
913
|
+
* result in this entire chain evaluating to `null`.
|
|
914
|
+
* Example: `foo?.bar?.["baz"]`, `foo()?.bar`, `foo.bar?.baz`, `foo?.bar.baz`, `foo?.bar()` are all single chains
|
|
915
|
+
*/
|
|
916
|
+
export interface MemberAccessChainExpression extends NodeBase<typeof NodeTypes.MemberAccessChainExpression> {
|
|
917
|
+
expression: Expression;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Define an Arcade object expression.
|
|
922
|
+
* Example: { foo: 1, bar: 2 }
|
|
923
|
+
*/
|
|
924
|
+
export interface ObjectExpression extends NodeBase<typeof NodeTypes.ObjectExpression> {
|
|
925
|
+
/** The collection of properties of the object expression. */
|
|
926
|
+
properties: Property[];
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/** Define an Arcade object property. */
|
|
930
|
+
export interface Property extends NodeBase<typeof NodeTypes.Property> {
|
|
931
|
+
kind: "init";
|
|
932
|
+
/**
|
|
933
|
+
* The key of the property.
|
|
934
|
+
* Example: { foo: 1 } or { foo }
|
|
935
|
+
* The key is foo.
|
|
936
|
+
*/
|
|
937
|
+
key: Identifier | Literal;
|
|
938
|
+
/**
|
|
939
|
+
* The value of the property.
|
|
940
|
+
* Example: { foo: 1 } or { foo }
|
|
941
|
+
* The value is 1 or foo.
|
|
942
|
+
*/
|
|
943
|
+
value: Expression;
|
|
944
|
+
/**
|
|
945
|
+
* Indicate if the property is a shorthand.
|
|
946
|
+
* Example: { foo }
|
|
947
|
+
* The property is a shorthand.
|
|
948
|
+
*/
|
|
949
|
+
shorthand: boolean;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Define an Arcade template literal.
|
|
954
|
+
* Example: `foo ${value} bar`
|
|
955
|
+
*/
|
|
956
|
+
export interface TemplateLiteral extends NodeBase<typeof NodeTypes.TemplateLiteral> {
|
|
957
|
+
/**
|
|
958
|
+
* The collection of quasis of the template literal.
|
|
959
|
+
* Example: `foo ${value} bar`
|
|
960
|
+
* The quasis are foo and bar.
|
|
961
|
+
*/
|
|
962
|
+
quasis: TemplateElement[];
|
|
963
|
+
/**
|
|
964
|
+
* The collection of expressions of the template literal.
|
|
965
|
+
* Example: `foo ${value1} - ${value2} bar`
|
|
966
|
+
* The expressions are value1 and value2.
|
|
967
|
+
*/
|
|
968
|
+
expressions: Expression[];
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/** Define an Arcade template element. */
|
|
972
|
+
export interface TemplateElement extends NodeBase<typeof NodeTypes.TemplateElement> {
|
|
973
|
+
/**
|
|
974
|
+
* The value of the template element.
|
|
975
|
+
* Example: `foo ${value}`
|
|
976
|
+
* The value is foo.
|
|
977
|
+
*/
|
|
978
|
+
value: TemplateElementValue;
|
|
979
|
+
/**
|
|
980
|
+
* Indicate if the template element is a tail.
|
|
981
|
+
* Example: `foo ${value} bar`
|
|
982
|
+
* The template element for foo is not a tail.
|
|
983
|
+
* The template element for bar is a tail.
|
|
984
|
+
*/
|
|
985
|
+
tail?: boolean;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/** Define an Arcade template element value. */
|
|
989
|
+
export interface TemplateElementValue {
|
|
990
|
+
/** The cooked value of the template element. */
|
|
991
|
+
cooked?: string;
|
|
992
|
+
/** The raw value of the template element. */
|
|
993
|
+
raw: string;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Define an Arcade unary expression.
|
|
998
|
+
* Example: -1
|
|
999
|
+
*/
|
|
1000
|
+
export interface UnaryExpression extends NodeBase<typeof NodeTypes.UnaryExpression> {
|
|
1001
|
+
readonly prefix: true;
|
|
1002
|
+
/**
|
|
1003
|
+
* The operator of the unary expression.
|
|
1004
|
+
* Example: -1
|
|
1005
|
+
* The operator is -.
|
|
1006
|
+
*/
|
|
1007
|
+
operator: UnaryOperators;
|
|
1008
|
+
/**
|
|
1009
|
+
* The argument of the unary expression.
|
|
1010
|
+
* Example: -1
|
|
1011
|
+
* The argument is 1.
|
|
1012
|
+
*/
|
|
1013
|
+
argument: Expression;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Define an Arcade update expression.
|
|
1018
|
+
* Example: a++
|
|
1019
|
+
*/
|
|
1020
|
+
export interface UpdateExpression extends NodeBase<typeof NodeTypes.UpdateExpression> {
|
|
1021
|
+
/**
|
|
1022
|
+
* The operator of the update expression.
|
|
1023
|
+
* Example: a++
|
|
1024
|
+
* The operator is ++.
|
|
1025
|
+
*/
|
|
1026
|
+
operator: UpdateOperators;
|
|
1027
|
+
/**
|
|
1028
|
+
* The argument of the update expression.
|
|
1029
|
+
* Example: a++
|
|
1030
|
+
* The argument is a.
|
|
1031
|
+
*/
|
|
1032
|
+
argument: CallExpression | Identifier | MemberExpression;
|
|
1033
|
+
/**
|
|
1034
|
+
* Indicate if the update expression is a prefix.
|
|
1035
|
+
* Example: ++a
|
|
1036
|
+
* The update expression is a prefix.
|
|
1037
|
+
*/
|
|
1038
|
+
prefix: boolean;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Test if the item is an Arcade Program.
|
|
1043
|
+
*
|
|
1044
|
+
* @param item
|
|
1045
|
+
*/
|
|
1046
|
+
export function isProgram(item: unknown): item is Program;
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Test if the item is an Arcade Statement.
|
|
1050
|
+
*
|
|
1051
|
+
* @param item
|
|
1052
|
+
*/
|
|
1053
|
+
export function isStatement(item: unknown): item is Statement;
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Test if the item is an Arcade BlockStatement.
|
|
1057
|
+
*
|
|
1058
|
+
* @param item
|
|
1059
|
+
*/
|
|
1060
|
+
export function isBlockStatement(item: unknown): item is BlockStatement;
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Test if the item is an Arcade BlockComment.
|
|
1064
|
+
*
|
|
1065
|
+
* @param item
|
|
1066
|
+
*/
|
|
1067
|
+
export function isBlockComment(item: unknown): item is BlockComment;
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Test if the item is an Arcade BreakStatement.
|
|
1071
|
+
*
|
|
1072
|
+
* @param item
|
|
1073
|
+
*/
|
|
1074
|
+
export function isBreakStatement(item: unknown): item is BreakStatement;
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Test if the item is an Arcade ContinueStatement.
|
|
1078
|
+
*
|
|
1079
|
+
* @param item
|
|
1080
|
+
*/
|
|
1081
|
+
export function isContinueStatement(item: unknown): item is ContinueStatement;
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Test if the item is an Arcade EmptyStatement.
|
|
1085
|
+
*
|
|
1086
|
+
* @param item
|
|
1087
|
+
*/
|
|
1088
|
+
export function isEmptyStatement(item: unknown): item is EmptyStatement;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Test if the item is an Arcade ExpressionStatement.
|
|
1092
|
+
*
|
|
1093
|
+
* @param item
|
|
1094
|
+
*/
|
|
1095
|
+
export function isExpressionStatement(item: unknown): item is ExpressionStatement;
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Test if the item is an Arcade ForInStatement.
|
|
1099
|
+
*
|
|
1100
|
+
* @param item
|
|
1101
|
+
*/
|
|
1102
|
+
export function isForInStatement(item: unknown): item is ForInStatement;
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Test if the item is an Arcade ForOfStatement.
|
|
1106
|
+
*
|
|
1107
|
+
* @param item
|
|
1108
|
+
*/
|
|
1109
|
+
export function isForOfStatement(item: unknown): item is ForOfStatement;
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Test if the item is an Arcade ForStatement.
|
|
1113
|
+
*
|
|
1114
|
+
* @param item
|
|
1115
|
+
*/
|
|
1116
|
+
export function isForStatement(item: unknown): item is ForStatement;
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Test if the item is an Arcade FunctionDeclaration.
|
|
1120
|
+
*
|
|
1121
|
+
* @param item
|
|
1122
|
+
*/
|
|
1123
|
+
export function isFunctionDeclaration(item: unknown): item is FunctionDeclaration;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Test if the item is an Arcade IfStatement.
|
|
1127
|
+
*
|
|
1128
|
+
* @param item
|
|
1129
|
+
*/
|
|
1130
|
+
export function isIfStatement(item: unknown): item is IfStatement;
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Test if the item is an Arcade ReturnStatement.
|
|
1134
|
+
*
|
|
1135
|
+
* @param item
|
|
1136
|
+
*/
|
|
1137
|
+
export function isReturnStatement(item: unknown): item is ReturnStatement;
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* Test if the item is an Arcade VariableDeclaration.
|
|
1141
|
+
*
|
|
1142
|
+
* @param item
|
|
1143
|
+
*/
|
|
1144
|
+
export function isVariableDeclaration(item: unknown): item is VariableDeclaration;
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* Test if the item is an Arcade Expression.
|
|
1148
|
+
*
|
|
1149
|
+
* @param item
|
|
1150
|
+
*/
|
|
1151
|
+
export function isExpression(item: unknown): item is Expression;
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Test if the item is an Arcade ArrayExpression.
|
|
1155
|
+
*
|
|
1156
|
+
* @param item
|
|
1157
|
+
*/
|
|
1158
|
+
export function isArrayExpression(item: unknown): item is ArrayExpression;
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Test if the item is an Arcade AssignmentExpression.
|
|
1162
|
+
*
|
|
1163
|
+
* @param item
|
|
1164
|
+
*/
|
|
1165
|
+
export function isAssignmentExpression(item: unknown): item is AssignmentExpression;
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Test if the item is an Arcade BinaryExpression.
|
|
1169
|
+
*
|
|
1170
|
+
* @param item
|
|
1171
|
+
*/
|
|
1172
|
+
export function isBinaryExpression(item: unknown): item is BinaryExpression;
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Test if the item is an Arcade CallExpression.
|
|
1176
|
+
*
|
|
1177
|
+
* @param item
|
|
1178
|
+
*/
|
|
1179
|
+
export function isCallExpression(item: unknown): item is CallExpression;
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Test if the item is an Arcade Identifier.
|
|
1183
|
+
*
|
|
1184
|
+
* @param item
|
|
1185
|
+
*/
|
|
1186
|
+
export function isIdentifier(item: unknown): item is Identifier;
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Test if the item is an Arcade Literal.
|
|
1190
|
+
*
|
|
1191
|
+
* @param item
|
|
1192
|
+
*/
|
|
1193
|
+
export function isLiteral(item: unknown): item is Literal;
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Test if the item is an Arcade LogicalExpression.
|
|
1197
|
+
*
|
|
1198
|
+
* @param item
|
|
1199
|
+
*/
|
|
1200
|
+
export function isLogicalExpression(item: unknown): item is LogicalExpression;
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Test if the item is an Arcade ObjectExpression.
|
|
1204
|
+
*
|
|
1205
|
+
* @param item
|
|
1206
|
+
*/
|
|
1207
|
+
export function isObjectExpression(item: unknown): item is ObjectExpression;
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Test if the item is an Arcade TemplateLiteral.
|
|
1211
|
+
*
|
|
1212
|
+
* @param item
|
|
1213
|
+
*/
|
|
1214
|
+
export function isTemplateLiteral(item: unknown): item is TemplateLiteral;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* Test if the item is an Arcade MemberExpression.
|
|
1218
|
+
*
|
|
1219
|
+
* @param item
|
|
1220
|
+
*/
|
|
1221
|
+
export function isMemberExpression(item: unknown): item is MemberExpression;
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* Test if the item is an Arcade SafeMemberExpression.
|
|
1225
|
+
*
|
|
1226
|
+
* @param item
|
|
1227
|
+
*/
|
|
1228
|
+
export function isSafeMemberExpression(item: unknown): item is SafeMemberExpression;
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Test if the item is an Arcade MemberAccessChainExpression.
|
|
1232
|
+
*
|
|
1233
|
+
* @param item
|
|
1234
|
+
*/
|
|
1235
|
+
export function isMemberAccessChainExpression(item: unknown): item is MemberAccessChainExpression;
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Test if the item is an Arcade UnaryExpression.
|
|
1239
|
+
*
|
|
1240
|
+
* @param item
|
|
1241
|
+
*/
|
|
1242
|
+
export function isUnaryExpression(item: unknown): item is UnaryExpression;
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* Test if the item is an Arcade UpdateExpression.
|
|
1246
|
+
*
|
|
1247
|
+
* @param item
|
|
1248
|
+
*/
|
|
1249
|
+
export function isUpdateExpression(item: unknown): item is UpdateExpression;
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* Test if the item is an Arcade VariableDeclarator.
|
|
1253
|
+
*
|
|
1254
|
+
* @param item
|
|
1255
|
+
*/
|
|
1256
|
+
export function isVariableDeclarator(item: unknown): item is VariableDeclarator;
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Test if the item is an Arcade Property.
|
|
1260
|
+
*
|
|
1261
|
+
* @param item
|
|
1262
|
+
*/
|
|
1263
|
+
export function isProperty(item: unknown): item is Property;
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Test if the item is an Arcade TemplateElement.
|
|
1267
|
+
*
|
|
1268
|
+
* @param item
|
|
1269
|
+
*/
|
|
1270
|
+
export function isTemplateElement(item: unknown): item is TemplateElement;
|