yukigo-ast 0.1.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/CHANGELOG.md +19 -0
- package/dist/globals/generics.d.ts +740 -0
- package/dist/globals/generics.js +1128 -0
- package/dist/globals/helpers.d.ts +4 -0
- package/dist/globals/helpers.js +76 -0
- package/dist/globals/operators.d.ts +251 -0
- package/dist/globals/operators.js +336 -0
- package/dist/globals/patterns.d.ts +170 -0
- package/dist/globals/patterns.js +261 -0
- package/dist/globals/runtime.d.ts +22 -0
- package/dist/globals/runtime.js +6 -0
- package/dist/globals/types.d.ts +185 -0
- package/dist/globals/types.js +329 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/paradigms/data.d.ts +246 -0
- package/dist/paradigms/data.js +348 -0
- package/dist/paradigms/functional.d.ts +59 -0
- package/dist/paradigms/functional.js +103 -0
- package/dist/paradigms/imperative.d.ts +124 -0
- package/dist/paradigms/imperative.js +188 -0
- package/dist/paradigms/logic.d.ts +163 -0
- package/dist/paradigms/logic.js +240 -0
- package/dist/paradigms/object.d.ts +201 -0
- package/dist/paradigms/object.js +308 -0
- package/dist/visitor.d.ts +254 -0
- package/dist/visitor.js +426 -0
- package/package.json +25 -0
- package/src/globals/generics.ts +1421 -0
- package/src/globals/helpers.ts +107 -0
- package/src/globals/operators.ts +515 -0
- package/src/globals/patterns.ts +321 -0
- package/src/globals/runtime.ts +33 -0
- package/src/globals/types.ts +375 -0
- package/src/index.ts +12 -0
- package/src/paradigms/data.ts +393 -0
- package/src/paradigms/functional.ts +129 -0
- package/src/paradigms/imperative.ts +232 -0
- package/src/paradigms/logic.ts +314 -0
- package/src/paradigms/object.ts +366 -0
- package/src/visitor.ts +692 -0
- package/tsconfig.json +22 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./visitor.js"
|
|
2
|
+
export * from "./globals/helpers.js"
|
|
3
|
+
export * from "./globals/generics.js"
|
|
4
|
+
export * from "./globals/operators.js"
|
|
5
|
+
export * from "./globals/patterns.js"
|
|
6
|
+
export * from "./globals/types.js"
|
|
7
|
+
export * from "./globals/runtime.js"
|
|
8
|
+
export * from "./paradigms/functional.js"
|
|
9
|
+
export * from "./paradigms/object.js"
|
|
10
|
+
export * from "./paradigms/imperative.js"
|
|
11
|
+
export * from "./paradigms/logic.js"
|
|
12
|
+
export * from "./paradigms/data.js"
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { ASTNode, Expression, SourceLocation, SymbolPrimitive } from "../globals/generics.js";
|
|
2
|
+
import { Visitor } from "../visitor.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a query to retrieve data from a database table.
|
|
6
|
+
* @category SQL
|
|
7
|
+
* @example
|
|
8
|
+
* SELECT * FROM users WHERE age > 18
|
|
9
|
+
*/
|
|
10
|
+
export class Select extends ASTNode {
|
|
11
|
+
/** @hidden */
|
|
12
|
+
public columns: Expression[];
|
|
13
|
+
/** @hidden */
|
|
14
|
+
public from: string;
|
|
15
|
+
/** @hidden */
|
|
16
|
+
public where?: Expression;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
columns: Expression[],
|
|
20
|
+
from: string,
|
|
21
|
+
where?: Expression,
|
|
22
|
+
loc?: SourceLocation
|
|
23
|
+
) {
|
|
24
|
+
super(loc);
|
|
25
|
+
this.columns = columns;
|
|
26
|
+
this.from = from;
|
|
27
|
+
this.where = where;
|
|
28
|
+
}
|
|
29
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
30
|
+
return visitor.visitSelect?.(this);
|
|
31
|
+
}
|
|
32
|
+
public toJSON() {
|
|
33
|
+
return {
|
|
34
|
+
type: "Select",
|
|
35
|
+
columns: this.columns.map((c) => c.toJSON()),
|
|
36
|
+
from: this.from,
|
|
37
|
+
where: this.where.toJSON(),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Represents a command to modify existing records in a database table.
|
|
44
|
+
* @category SQL
|
|
45
|
+
* @example
|
|
46
|
+
* UPDATE products SET price = 10 WHERE id = 1
|
|
47
|
+
*/
|
|
48
|
+
export class Update extends ASTNode {
|
|
49
|
+
/** @hidden */
|
|
50
|
+
public table: string;
|
|
51
|
+
/** @hidden */
|
|
52
|
+
public assignments: Expression[];
|
|
53
|
+
/** @hidden */
|
|
54
|
+
public where?: Expression;
|
|
55
|
+
|
|
56
|
+
constructor(
|
|
57
|
+
table: string,
|
|
58
|
+
assignments: Expression[],
|
|
59
|
+
where?: Expression,
|
|
60
|
+
loc?: SourceLocation
|
|
61
|
+
) {
|
|
62
|
+
super(loc);
|
|
63
|
+
this.table = table;
|
|
64
|
+
this.assignments = assignments;
|
|
65
|
+
this.where = where;
|
|
66
|
+
}
|
|
67
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
68
|
+
return visitor.visitUpdate?.(this);
|
|
69
|
+
}
|
|
70
|
+
public toJSON() {
|
|
71
|
+
return {
|
|
72
|
+
type: "Update",
|
|
73
|
+
table: this.table,
|
|
74
|
+
assignments: this.assignments.map((assign) => assign.toJSON()),
|
|
75
|
+
where: this.where.toJSON(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Represents a command to remove records from a database table.
|
|
82
|
+
* @category SQL
|
|
83
|
+
* @example
|
|
84
|
+
* DELETE FROM sessions WHERE last_active < '2023-01-01'
|
|
85
|
+
*/
|
|
86
|
+
export class Delete extends ASTNode {
|
|
87
|
+
/** @hidden */
|
|
88
|
+
public table: string;
|
|
89
|
+
/** @hidden */
|
|
90
|
+
public where?: Expression;
|
|
91
|
+
|
|
92
|
+
constructor(table: string, where?: Expression, loc?: SourceLocation) {
|
|
93
|
+
super(loc);
|
|
94
|
+
this.table = table;
|
|
95
|
+
this.where = where;
|
|
96
|
+
}
|
|
97
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
98
|
+
return visitor.visitDelete?.(this);
|
|
99
|
+
}
|
|
100
|
+
public toJSON() {
|
|
101
|
+
return {
|
|
102
|
+
type: "Delete",
|
|
103
|
+
table: this.table,
|
|
104
|
+
where: this.where.toJSON(),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Represents a command to insert new records into a database table.
|
|
111
|
+
* @category SQL
|
|
112
|
+
* @example
|
|
113
|
+
* INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com')
|
|
114
|
+
*/
|
|
115
|
+
export class InsertInto extends ASTNode {
|
|
116
|
+
/** @hidden */
|
|
117
|
+
public table: string;
|
|
118
|
+
/** @hidden */
|
|
119
|
+
public columns: string[];
|
|
120
|
+
/** @hidden */
|
|
121
|
+
public values: Expression[][];
|
|
122
|
+
|
|
123
|
+
constructor(
|
|
124
|
+
table: string,
|
|
125
|
+
columns: string[],
|
|
126
|
+
values: Expression[][],
|
|
127
|
+
loc?: SourceLocation
|
|
128
|
+
) {
|
|
129
|
+
super(loc);
|
|
130
|
+
this.table = table;
|
|
131
|
+
this.columns = columns;
|
|
132
|
+
this.values = values;
|
|
133
|
+
}
|
|
134
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
135
|
+
return visitor.visitInsertInto?.(this);
|
|
136
|
+
}
|
|
137
|
+
public toJSON() {
|
|
138
|
+
return {
|
|
139
|
+
type: "InsertInto",
|
|
140
|
+
table: this.table,
|
|
141
|
+
columns: this.columns,
|
|
142
|
+
values: this.values.map((val) => val.map((v) => v.toJSON())),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Represents a command to create a new database container.
|
|
149
|
+
* @category SQL
|
|
150
|
+
* @example
|
|
151
|
+
* CREATE DATABASE production_db
|
|
152
|
+
*/
|
|
153
|
+
export class CreateDatabase extends ASTNode {
|
|
154
|
+
/** @hidden */
|
|
155
|
+
public name: string;
|
|
156
|
+
|
|
157
|
+
constructor(name: string, loc?: SourceLocation) {
|
|
158
|
+
super(loc);
|
|
159
|
+
this.name = name;
|
|
160
|
+
}
|
|
161
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
162
|
+
return visitor.visitCreateDatabase?.(this);
|
|
163
|
+
}
|
|
164
|
+
public toJSON() {
|
|
165
|
+
return {
|
|
166
|
+
type: "CreateDatabase",
|
|
167
|
+
name: this.name,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Represents a command to modify the properties of an existing database.
|
|
174
|
+
* @category SQL
|
|
175
|
+
* @example
|
|
176
|
+
* ALTER DATABASE production_db SET READ_ONLY = OFF
|
|
177
|
+
*/
|
|
178
|
+
export class AlterDatabase extends ASTNode {
|
|
179
|
+
/** @hidden */
|
|
180
|
+
public name: string;
|
|
181
|
+
/** @hidden */
|
|
182
|
+
public action: string;
|
|
183
|
+
|
|
184
|
+
constructor(name: string, action: string, loc?: SourceLocation) {
|
|
185
|
+
super(loc);
|
|
186
|
+
this.name = name;
|
|
187
|
+
this.action = action;
|
|
188
|
+
}
|
|
189
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
190
|
+
return visitor.visitAlterDatabase?.(this);
|
|
191
|
+
}
|
|
192
|
+
public toJSON() {
|
|
193
|
+
return {
|
|
194
|
+
type: "AlterDatabase",
|
|
195
|
+
name: this.name,
|
|
196
|
+
action: this.action,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Represents a command to define a new table and its schema.
|
|
203
|
+
* @category SQL
|
|
204
|
+
* @example
|
|
205
|
+
* CREATE TABLE employees (id INT, name VARCHAR(100))
|
|
206
|
+
*/
|
|
207
|
+
export class CreateTable extends ASTNode {
|
|
208
|
+
/** @hidden */
|
|
209
|
+
public name: string;
|
|
210
|
+
/** @hidden */
|
|
211
|
+
public columns: Expression[];
|
|
212
|
+
|
|
213
|
+
constructor(name: string, columns: Expression[], loc?: SourceLocation) {
|
|
214
|
+
super(loc);
|
|
215
|
+
this.name = name;
|
|
216
|
+
this.columns = columns;
|
|
217
|
+
}
|
|
218
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
219
|
+
return visitor.visitCreateTable?.(this);
|
|
220
|
+
}
|
|
221
|
+
public toJSON() {
|
|
222
|
+
return {
|
|
223
|
+
type: "CreateTable",
|
|
224
|
+
name: this.name,
|
|
225
|
+
columns: this.columns.map((c) => c.toJSON()),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Represents a command to modify an existing table structure (e.g., adding columns).
|
|
232
|
+
* @category SQL
|
|
233
|
+
* @example
|
|
234
|
+
* ALTER TABLE employees ADD COLUMN email VARCHAR(255)
|
|
235
|
+
*/
|
|
236
|
+
export class AlterTable extends ASTNode {
|
|
237
|
+
/** @hidden */
|
|
238
|
+
public name: string;
|
|
239
|
+
/** @hidden */
|
|
240
|
+
public action: Expression;
|
|
241
|
+
|
|
242
|
+
constructor(name: string, action: Expression, loc?: SourceLocation) {
|
|
243
|
+
super(loc);
|
|
244
|
+
this.name = name;
|
|
245
|
+
this.action = action;
|
|
246
|
+
}
|
|
247
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
248
|
+
return visitor.visitAlterTable?.(this);
|
|
249
|
+
}
|
|
250
|
+
public toJSON() {
|
|
251
|
+
return {
|
|
252
|
+
type: "AlterTable",
|
|
253
|
+
name: this.name,
|
|
254
|
+
action: this.action.toJSON(),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Represents a command to delete a table and all its data permanently.
|
|
261
|
+
* @category SQL
|
|
262
|
+
* @example
|
|
263
|
+
* DROP TABLE old_logs
|
|
264
|
+
*/
|
|
265
|
+
export class DropTable extends ASTNode {
|
|
266
|
+
/** @hidden */
|
|
267
|
+
public name: string;
|
|
268
|
+
|
|
269
|
+
constructor(name: string, loc?: SourceLocation) {
|
|
270
|
+
super(loc);
|
|
271
|
+
this.name = name;
|
|
272
|
+
}
|
|
273
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
274
|
+
return visitor.visitDropTable?.(this);
|
|
275
|
+
}
|
|
276
|
+
public toJSON() {
|
|
277
|
+
return {
|
|
278
|
+
type: "DropTable",
|
|
279
|
+
name: this.name,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Represents a command to create a search index on table columns to improve query performance.
|
|
286
|
+
* @category SQL
|
|
287
|
+
* @example
|
|
288
|
+
* CREATE INDEX idx_lastname ON employees (lastname)
|
|
289
|
+
*/
|
|
290
|
+
export class CreateIndex extends ASTNode {
|
|
291
|
+
/** @hidden */
|
|
292
|
+
public name: string;
|
|
293
|
+
/** @hidden */
|
|
294
|
+
public table: string;
|
|
295
|
+
/** @hidden */
|
|
296
|
+
public columns: string[];
|
|
297
|
+
|
|
298
|
+
constructor(
|
|
299
|
+
name: string,
|
|
300
|
+
table: string,
|
|
301
|
+
columns: string[],
|
|
302
|
+
loc?: SourceLocation
|
|
303
|
+
) {
|
|
304
|
+
super(loc);
|
|
305
|
+
this.name = name;
|
|
306
|
+
this.table = table;
|
|
307
|
+
this.columns = columns;
|
|
308
|
+
}
|
|
309
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
310
|
+
return visitor.visitCreateIndex?.(this);
|
|
311
|
+
}
|
|
312
|
+
public toJSON() {
|
|
313
|
+
return {
|
|
314
|
+
type: "CreateIndex",
|
|
315
|
+
name: this.name,
|
|
316
|
+
table: this.table,
|
|
317
|
+
columns: this.columns,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Represents a command to remove an existing search index.
|
|
324
|
+
* @category SQL
|
|
325
|
+
* @example
|
|
326
|
+
* DROP INDEX idx_lastname
|
|
327
|
+
*/
|
|
328
|
+
export class DropIndex extends ASTNode {
|
|
329
|
+
/** @hidden */
|
|
330
|
+
public name: string;
|
|
331
|
+
|
|
332
|
+
constructor(name: string, loc?: SourceLocation) {
|
|
333
|
+
super(loc);
|
|
334
|
+
this.name = name;
|
|
335
|
+
}
|
|
336
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
337
|
+
return visitor.visitDropIndex?.(this);
|
|
338
|
+
}
|
|
339
|
+
public toJSON() {
|
|
340
|
+
return {
|
|
341
|
+
type: "DropIndex",
|
|
342
|
+
name: this.name,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Represents a command to save changes made in a transaction.
|
|
348
|
+
* @category SQL
|
|
349
|
+
* @example
|
|
350
|
+
* COMMIT TRAN transaction_name
|
|
351
|
+
*/
|
|
352
|
+
export class Commit extends ASTNode {
|
|
353
|
+
/** @hidden */
|
|
354
|
+
public name: SymbolPrimitive;
|
|
355
|
+
|
|
356
|
+
constructor(name: SymbolPrimitive, loc?: SourceLocation) {
|
|
357
|
+
super(loc);
|
|
358
|
+
this.name = name;
|
|
359
|
+
}
|
|
360
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
361
|
+
return visitor.visitCommit?.(this);
|
|
362
|
+
}
|
|
363
|
+
public toJSON() {
|
|
364
|
+
return {
|
|
365
|
+
type: "Commit",
|
|
366
|
+
name: this.name,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Represents a command to undo changes made in a transaction.
|
|
372
|
+
* @category SQL
|
|
373
|
+
* @example
|
|
374
|
+
* ROLLBACK TRAN transaction_name
|
|
375
|
+
*/
|
|
376
|
+
export class Rollback extends ASTNode {
|
|
377
|
+
/** @hidden */
|
|
378
|
+
public name: SymbolPrimitive;
|
|
379
|
+
|
|
380
|
+
constructor(name: SymbolPrimitive, loc?: SourceLocation) {
|
|
381
|
+
super(loc);
|
|
382
|
+
this.name = name;
|
|
383
|
+
}
|
|
384
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
385
|
+
return visitor.visitRollback?.(this);
|
|
386
|
+
}
|
|
387
|
+
public toJSON() {
|
|
388
|
+
return {
|
|
389
|
+
type: "Rollback",
|
|
390
|
+
name: this.name,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ASTNode,
|
|
3
|
+
Expression,
|
|
4
|
+
SourceLocation,
|
|
5
|
+
SymbolPrimitive,
|
|
6
|
+
} from "../globals/generics.js";
|
|
7
|
+
import { Pattern } from "../globals/patterns.js";
|
|
8
|
+
import { Visitor } from "../visitor.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents function composition (e.g., f . g).
|
|
12
|
+
* @category Expressions
|
|
13
|
+
*/
|
|
14
|
+
export class CompositionExpression extends ASTNode {
|
|
15
|
+
/** @hidden */
|
|
16
|
+
public right: Expression;
|
|
17
|
+
/** @hidden */
|
|
18
|
+
public left: Expression;
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
left: Expression,
|
|
22
|
+
right: Expression,
|
|
23
|
+
loc?: SourceLocation
|
|
24
|
+
) {
|
|
25
|
+
super(loc);
|
|
26
|
+
this.left = left;
|
|
27
|
+
this.right = right;
|
|
28
|
+
}
|
|
29
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
30
|
+
return visitor.visitCompositionExpression?.(this);
|
|
31
|
+
}
|
|
32
|
+
public toJSON() {
|
|
33
|
+
return {
|
|
34
|
+
type: "CompositionExpression",
|
|
35
|
+
left: this.left.toJSON(),
|
|
36
|
+
right: this.right.toJSON(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Represents an anonymous function or lambda abstraction.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* \x -> x + 1
|
|
46
|
+
* @category Expressions
|
|
47
|
+
*/
|
|
48
|
+
export class Lambda extends ASTNode {
|
|
49
|
+
/** @hidden */
|
|
50
|
+
public body: Expression;
|
|
51
|
+
/** @hidden */
|
|
52
|
+
public parameters: Pattern[];
|
|
53
|
+
|
|
54
|
+
constructor(
|
|
55
|
+
parameters: Pattern[],
|
|
56
|
+
body: Expression,
|
|
57
|
+
loc?: SourceLocation
|
|
58
|
+
) {
|
|
59
|
+
super(loc);
|
|
60
|
+
this.parameters = parameters;
|
|
61
|
+
this.body = body;
|
|
62
|
+
}
|
|
63
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
64
|
+
return visitor.visitLambda?.(this);
|
|
65
|
+
}
|
|
66
|
+
public toJSON() {
|
|
67
|
+
return {
|
|
68
|
+
type: "Lambda",
|
|
69
|
+
body: this.body.toJSON(),
|
|
70
|
+
parameters: this.parameters.map((p) => p.toJSON()),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Represents a yield statement, often used in generators or coroutines.
|
|
76
|
+
* @category Statements
|
|
77
|
+
*/
|
|
78
|
+
export class Yield extends ASTNode {
|
|
79
|
+
/** @hidden */
|
|
80
|
+
public expression: Expression;
|
|
81
|
+
|
|
82
|
+
constructor(expression: Expression, loc?: SourceLocation) {
|
|
83
|
+
super(loc);
|
|
84
|
+
this.expression = expression;
|
|
85
|
+
}
|
|
86
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
87
|
+
return visitor.visitYield?.(this);
|
|
88
|
+
}
|
|
89
|
+
public toJSON() {
|
|
90
|
+
return {
|
|
91
|
+
type: "Yield",
|
|
92
|
+
expression: this.expression.toJSON(),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Represents the application of a function to an argument.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* map (*2) [1..5]
|
|
102
|
+
* @category Expressions
|
|
103
|
+
*/
|
|
104
|
+
export class Application extends ASTNode {
|
|
105
|
+
/** @hidden */
|
|
106
|
+
public parameter: Expression;
|
|
107
|
+
/** @hidden */
|
|
108
|
+
public functionExpr: Expression;
|
|
109
|
+
|
|
110
|
+
constructor(
|
|
111
|
+
functionExpr: Expression,
|
|
112
|
+
parameter: Expression,
|
|
113
|
+
loc?: SourceLocation
|
|
114
|
+
) {
|
|
115
|
+
super(loc);
|
|
116
|
+
this.functionExpr = functionExpr;
|
|
117
|
+
this.parameter = parameter;
|
|
118
|
+
}
|
|
119
|
+
public accept<R>(visitor: Visitor<R>): R {
|
|
120
|
+
return visitor.visitApplication?.(this);
|
|
121
|
+
}
|
|
122
|
+
public toJSON() {
|
|
123
|
+
return {
|
|
124
|
+
type: "Application",
|
|
125
|
+
function: this.functionExpr.toJSON(),
|
|
126
|
+
parameter: this.parameter.toJSON(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|