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.
Files changed (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/globals/generics.d.ts +740 -0
  3. package/dist/globals/generics.js +1128 -0
  4. package/dist/globals/helpers.d.ts +4 -0
  5. package/dist/globals/helpers.js +76 -0
  6. package/dist/globals/operators.d.ts +251 -0
  7. package/dist/globals/operators.js +336 -0
  8. package/dist/globals/patterns.d.ts +170 -0
  9. package/dist/globals/patterns.js +261 -0
  10. package/dist/globals/runtime.d.ts +22 -0
  11. package/dist/globals/runtime.js +6 -0
  12. package/dist/globals/types.d.ts +185 -0
  13. package/dist/globals/types.js +329 -0
  14. package/dist/index.d.ts +12 -0
  15. package/dist/index.js +12 -0
  16. package/dist/paradigms/data.d.ts +246 -0
  17. package/dist/paradigms/data.js +348 -0
  18. package/dist/paradigms/functional.d.ts +59 -0
  19. package/dist/paradigms/functional.js +103 -0
  20. package/dist/paradigms/imperative.d.ts +124 -0
  21. package/dist/paradigms/imperative.js +188 -0
  22. package/dist/paradigms/logic.d.ts +163 -0
  23. package/dist/paradigms/logic.js +240 -0
  24. package/dist/paradigms/object.d.ts +201 -0
  25. package/dist/paradigms/object.js +308 -0
  26. package/dist/visitor.d.ts +254 -0
  27. package/dist/visitor.js +426 -0
  28. package/package.json +25 -0
  29. package/src/globals/generics.ts +1421 -0
  30. package/src/globals/helpers.ts +107 -0
  31. package/src/globals/operators.ts +515 -0
  32. package/src/globals/patterns.ts +321 -0
  33. package/src/globals/runtime.ts +33 -0
  34. package/src/globals/types.ts +375 -0
  35. package/src/index.ts +12 -0
  36. package/src/paradigms/data.ts +393 -0
  37. package/src/paradigms/functional.ts +129 -0
  38. package/src/paradigms/imperative.ts +232 -0
  39. package/src/paradigms/logic.ts +314 -0
  40. package/src/paradigms/object.ts +366 -0
  41. package/src/visitor.ts +692 -0
  42. package/tsconfig.json +22 -0
@@ -0,0 +1,740 @@
1
+ import { Application, CompositionExpression, Lambda, Yield } from "../paradigms/functional.js";
2
+ import { EntryPoint, Enumeration, ForLoop, Procedure, Repeat, Structure, While } from "../paradigms/imperative.js";
3
+ import { Call, Clause, Exist, Findall, Forall, Not, RuntimePredicate } from "../paradigms/logic.js";
4
+ import { Attribute, Class, Implement, Include, Interface, Method, New, Object, Self, Send, Super } from "../paradigms/object.js";
5
+ import { Visitor } from "../visitor.js";
6
+ import { Operation } from "./operators.js";
7
+ import { Pattern } from "./patterns.js";
8
+ import { LazyList, RuntimeFunction } from "./runtime.js";
9
+ import { Type, TypeAlias, TypeCast, TypeSignature } from "./types.js";
10
+ export type Modify<T, R> = Omit<T, keyof R> & R;
11
+ type Metadata = Map<string, any>;
12
+ /**
13
+ * @hidden
14
+ */
15
+ export declare abstract class ASTNode {
16
+ /** @hidden */
17
+ loc: SourceLocation;
18
+ /** @hidden */
19
+ metadata: Metadata;
20
+ constructor(loc?: SourceLocation, metadata?: Metadata);
21
+ setMetadata(key: string, value: any): void;
22
+ getMetadata<T>(key: string): T | undefined;
23
+ hasMetadata(key: string): boolean;
24
+ /** @hidden */
25
+ abstract accept<R>(visitor: Visitor<R>): R;
26
+ /** @hidden */
27
+ abstract toJSON(): object;
28
+ }
29
+ /**
30
+ * Generic number primitive
31
+ * @category Literals
32
+ */
33
+ export declare class NumberPrimitive extends ASTNode {
34
+ /** @hidden */
35
+ value: number;
36
+ constructor(value: number, loc?: SourceLocation);
37
+ accept<R>(visitor: Visitor<R>): R;
38
+ /**
39
+ * Compares the primitive to other Primitive passed by argument
40
+ * @param other Another Primitive to compare to.
41
+ * @returns True if both primitive have the same value
42
+ */
43
+ equals(other: Primitive): boolean;
44
+ toJSON(): {
45
+ type: string;
46
+ value: number;
47
+ };
48
+ }
49
+ /**
50
+ * Generic boolean primitive
51
+ * @category Literals
52
+ */
53
+ export declare class BooleanPrimitive extends ASTNode {
54
+ /** @hidden */
55
+ value: boolean;
56
+ constructor(value: boolean, loc?: SourceLocation);
57
+ accept<R>(visitor: Visitor<R>): R;
58
+ /**
59
+ * Compares the primitive to other Primitive passed by argument
60
+ * @param other Another Primitive to compare to.
61
+ * @returns True if both primitive have the same value
62
+ */
63
+ equals(other: Primitive): boolean;
64
+ toJSON(): {
65
+ type: string;
66
+ value: boolean;
67
+ };
68
+ }
69
+ /**
70
+ * Represent lists - generic uniform variable-size collection of elements. Lists typically map to arrays, lists or sequence-like structures.
71
+ * @category Literals
72
+ */
73
+ export declare class ListPrimitive extends ASTNode {
74
+ /** @hidden */
75
+ elements: Expression[];
76
+ constructor(elements: Expression[], loc?: SourceLocation);
77
+ accept<R>(visitor: Visitor<R>): R;
78
+ /**
79
+ * Compares the primitive to other Primitive passed by argument
80
+ * @param other Another Primitive to compare to.
81
+ * @returns True if both primitive have the same value
82
+ */
83
+ equals(other: Primitive): boolean;
84
+ toJSON(): {
85
+ type: string;
86
+ value: Expression[];
87
+ };
88
+ }
89
+ /**
90
+ * Generic char primitive
91
+ * @category Literals
92
+ */
93
+ export declare class CharPrimitive extends ASTNode {
94
+ /** @hidden */
95
+ value: string;
96
+ constructor(value: string, loc?: SourceLocation);
97
+ accept<R>(visitor: Visitor<R>): R;
98
+ /**
99
+ * Compares the primitive to other Primitive passed by argument
100
+ * @param other Another Primitive to compare to.
101
+ * @returns True if both primitive have the same value
102
+ */
103
+ equals(other: Primitive): boolean;
104
+ toJSON(): {
105
+ type: string;
106
+ value: string;
107
+ };
108
+ }
109
+ /**
110
+ * Generic string primitive
111
+ * @category Literals
112
+ */
113
+ export declare class StringPrimitive extends ASTNode {
114
+ /** @hidden */
115
+ value: string;
116
+ constructor(value: string, loc?: SourceLocation);
117
+ accept<R>(visitor: Visitor<R>): R;
118
+ /**
119
+ * Compares the primitive to other Primitive passed by argument
120
+ * @param other Another Primitive to compare to.
121
+ * @returns True if both primitive have the same value
122
+ */
123
+ equals(other: Primitive): boolean;
124
+ toJSON(): {
125
+ type: string;
126
+ value: string;
127
+ };
128
+ }
129
+ /**
130
+ * Generic null/undefined primitive
131
+ * @category Literals
132
+ */
133
+ export declare class NilPrimitive extends ASTNode {
134
+ /** @hidden */
135
+ value: undefined | null;
136
+ constructor(value: undefined | null, loc?: SourceLocation);
137
+ accept<R>(visitor: Visitor<R>): R;
138
+ /**
139
+ * Compares the primitive to other Primitive passed by argument
140
+ * @param other Another Primitive to compare to.
141
+ * @returns True if both primitive have the same value
142
+ */
143
+ equals(other: Primitive): boolean;
144
+ toJSON(): {
145
+ type: string;
146
+ value: null;
147
+ };
148
+ }
149
+ /**
150
+ * Generic symbol primitive
151
+ * @category Literals
152
+ */
153
+ export declare class SymbolPrimitive extends ASTNode {
154
+ /** @hidden */
155
+ value: string;
156
+ constructor(value: string, loc?: SourceLocation);
157
+ accept<R>(visitor: Visitor<R>): R;
158
+ /**
159
+ * Compares the primitive to other Primitive passed by argument
160
+ * @param other Another Primitive to compare to.
161
+ * @returns True if both primitive have the same value
162
+ */
163
+ equals(other: Primitive): boolean;
164
+ toJSON(): {
165
+ type: string;
166
+ value: string;
167
+ };
168
+ }
169
+ export type YukigoPrimitive = "YuNumber" | "YuString" | "YuChar" | "YuBoolean" | "YuTuple" | "YuList" | "YuNil" | "YuDict" | "YuObject" | "YuSymbol";
170
+ export type LogicResult = {
171
+ success: boolean;
172
+ solutions: Map<string, string>;
173
+ };
174
+ export type PrimitiveValue = number | boolean | string | RuntimeFunction | RuntimePredicate | LogicResult | LazyList | null | void | PrimitiveValue[] | undefined;
175
+ export type Primitive = NumberPrimitive | BooleanPrimitive | CharPrimitive | StringPrimitive | NilPrimitive | SymbolPrimitive | ListPrimitive;
176
+ /**
177
+ * Source location information
178
+ */
179
+ export declare class SourceLocation {
180
+ line: number;
181
+ column: number;
182
+ constructor(line: number, column: number);
183
+ toJSON(): {
184
+ type: string;
185
+ line: number;
186
+ column: number;
187
+ };
188
+ }
189
+ /**
190
+ * Represent tuples - generic non-uniform fixed-size collection of elements
191
+ *
192
+ * @example
193
+ * (1, "Hello", true)
194
+ * @category Expressions
195
+ */
196
+ export declare class TupleExpression extends ASTNode {
197
+ /** @hidden */
198
+ elements: Expression[];
199
+ constructor(elements: Expression[], loc?: SourceLocation);
200
+ accept<R>(visitor: Visitor<R>): R;
201
+ toJSON(): any;
202
+ }
203
+ /**
204
+ * Fields of a data expression representations
205
+ * @category Expressions
206
+ */
207
+ export declare class FieldExpression extends ASTNode {
208
+ /** @hidden */
209
+ expression: Expression;
210
+ /** @hidden */
211
+ name: SymbolPrimitive;
212
+ constructor(name: SymbolPrimitive, expression: Expression, loc?: SourceLocation);
213
+ accept<R>(visitor: Visitor<R>): R;
214
+ toJSON(): any;
215
+ }
216
+ /**
217
+ * Data expression, used to construct Records
218
+ * @example
219
+ * f = DataName { fieldName = 2 }
220
+ * @category Expressions
221
+ */
222
+ export declare class DataExpression extends ASTNode {
223
+ /** @hidden */
224
+ contents: FieldExpression[];
225
+ /** @hidden */
226
+ name: SymbolPrimitive;
227
+ constructor(name: SymbolPrimitive, contents: FieldExpression[], loc?: SourceLocation);
228
+ accept<R>(visitor: Visitor<R>): R;
229
+ toJSON(): any;
230
+ }
231
+ /**
232
+ * Cons expression, represent a concatenation of a head and a tail
233
+ * @example
234
+ * f = x : xs
235
+ * @category Expressions
236
+ */
237
+ export declare class ConsExpression extends ASTNode {
238
+ /** @hidden */
239
+ tail: Expression;
240
+ /** @hidden */
241
+ head: Expression;
242
+ constructor(head: Expression, tail: Expression, loc?: SourceLocation);
243
+ accept<R>(visitor: Visitor<R>): R;
244
+ toJSON(): any;
245
+ }
246
+ /**
247
+ * Represent let...in expressions normally used in Haskell
248
+ * @example
249
+ * f = let x = 2 in x * 4
250
+ * @category Expressions
251
+ */
252
+ export declare class LetInExpression extends ASTNode {
253
+ /** @hidden */
254
+ expression: Expression;
255
+ /** @hidden */
256
+ declarations: Sequence;
257
+ constructor(declarations: Sequence, expression: Expression, loc?: SourceLocation);
258
+ accept<R>(visitor: Visitor<R>): R;
259
+ toJSON(): {
260
+ type: string;
261
+ declarations: any;
262
+ expression: any;
263
+ };
264
+ }
265
+ /**
266
+ * Otherwise used as the default case in GuardBody
267
+ * @example
268
+ * f x
269
+ * | x == 2 = 16
270
+ * | otherwise = x * 8
271
+ * @category Declarations
272
+ */
273
+ export declare class Otherwise extends ASTNode {
274
+ accept<R>(visitor: Visitor<R>): R;
275
+ toJSON(): {
276
+ type: string;
277
+ };
278
+ }
279
+ /**
280
+ * ListComprehension when the for expression is a yield.
281
+ * Scala's for comprehensions, Erlang's and Haskell's list comprehensions
282
+ * @example
283
+ * m = [ f x | x <- [1, 2, 3, 4] ]
284
+ * @category Expressions
285
+ */
286
+ export declare class ListComprehension extends ASTNode {
287
+ /** @hidden */
288
+ generators: (Generator | Expression)[];
289
+ /** @hidden */
290
+ projection: Expression;
291
+ constructor(projection: Expression, generators: (Generator | Expression)[], loc?: SourceLocation);
292
+ accept<R>(visitor: Visitor<R>): R;
293
+ toJSON(): any;
294
+ }
295
+ /**
296
+ * Generator represents patterns like "Just m <- ms" or "x <- [1,2,3]"
297
+ * @example
298
+ * x <- [1, 2, 3, 4]
299
+ * @category Declarations
300
+ */
301
+ export declare class Generator extends ASTNode {
302
+ /** @hidden */
303
+ expression: Expression;
304
+ /** @hidden */
305
+ variable: SymbolPrimitive;
306
+ constructor(variable: SymbolPrimitive, expression: Expression, loc?: SourceLocation);
307
+ accept<R>(visitor: Visitor<R>): R;
308
+ toJSON(): any;
309
+ }
310
+ /**
311
+ * RangeExpression represents when a list is given by comprehension in a defined range
312
+ * @example
313
+ * (1..10)
314
+ * @example
315
+ * (1, 2..10)
316
+ * @example
317
+ * (1..)
318
+ * @category Expressions
319
+ */
320
+ export declare class RangeExpression extends ASTNode {
321
+ /** @hidden */
322
+ step?: Expression;
323
+ /** @hidden */
324
+ end?: Expression;
325
+ /** @hidden */
326
+ start: Expression;
327
+ constructor(start: Expression, end?: Expression, // undefined for infinite ranges like [0..]
328
+ step?: Expression, // for [start, second .. end] syntax
329
+ loc?: SourceLocation);
330
+ accept<R>(visitor: Visitor<R>): R;
331
+ toJSON(): any;
332
+ }
333
+ export type Expression = Primitive | Operation | TupleExpression | Print | Otherwise | ConsExpression | Self | Sequence | New | Include | Implement | DataExpression | CompositionExpression | Lambda | For | Application | Exist | Forall | Findall | Not | TypeCast | ListComprehension | RangeExpression;
334
+ /**
335
+ * Generic conditional If statements.
336
+ * Nested `else if` need to be desugared into `else { if ... }`
337
+ * @example
338
+ * if (condition) { ... } else { ... }
339
+ * @category Expressions
340
+ */
341
+ export declare class If extends ASTNode {
342
+ /** @hidden */
343
+ elseExpr: Expression;
344
+ /** @hidden */
345
+ then: Expression;
346
+ /** @hidden */
347
+ condition: Expression;
348
+ constructor(condition: Expression, then: Expression, elseExpr: Expression, loc?: SourceLocation);
349
+ accept<R>(visitor: Visitor<R>): R;
350
+ toJSON(): any;
351
+ }
352
+ /**
353
+ * Generic return statement.
354
+ * @example
355
+ * // In Haskell
356
+ * f x = x * 2
357
+ * // The parser takes the body and uses it as a Return
358
+ * @example
359
+ * function f(x) {
360
+ * return x * 2 // The node holds this expression
361
+ * }
362
+ * @category Statements
363
+ */
364
+ export declare class Return extends ASTNode {
365
+ /** @hidden */
366
+ body?: Expression;
367
+ constructor(body?: Expression, loc?: SourceLocation);
368
+ accept<R>(visitor: Visitor<R>): R;
369
+ toJSON(): any;
370
+ }
371
+ /**
372
+ * Generic field in a Record statement.
373
+ * The name can be undefined to support positional-only Records
374
+ * @example
375
+ * ... { name :: String }
376
+ * @category Declarations
377
+ */
378
+ export declare class Field extends ASTNode {
379
+ /** @hidden */
380
+ value: Type;
381
+ /** @hidden */
382
+ name: SymbolPrimitive | undefined;
383
+ constructor(name: SymbolPrimitive | undefined, value: Type, loc?: SourceLocation);
384
+ accept<R>(visitor: Visitor<R>): R;
385
+ toJSON(): {
386
+ type: string;
387
+ name: {
388
+ type: string;
389
+ value: string;
390
+ };
391
+ value: any;
392
+ };
393
+ }
394
+ /**
395
+ * Generic constructor node.
396
+ * Holds an array of Field nodes.
397
+ * @example
398
+ * data Record = Constructor { field :: String }
399
+ * @category Declarations
400
+ */
401
+ export declare class Constructor extends ASTNode {
402
+ /** @hidden */
403
+ fields: Field[];
404
+ /** @hidden */
405
+ name: SymbolPrimitive;
406
+ constructor(name: SymbolPrimitive, fields: Field[], loc?: SourceLocation);
407
+ accept<R>(visitor: Visitor<R>): R;
408
+ toJSON(): {
409
+ type: string;
410
+ name: {
411
+ type: string;
412
+ value: string;
413
+ };
414
+ fields: {
415
+ type: string;
416
+ name: {
417
+ type: string;
418
+ value: string;
419
+ };
420
+ value: any;
421
+ }[];
422
+ };
423
+ }
424
+ /**
425
+ * Generic Record statement node.
426
+ * @example
427
+ * data Record = Constructor { field :: String }
428
+ * data PositionalRecord = Constructor String String
429
+ * @category Declarations
430
+ */
431
+ export declare class Record extends ASTNode {
432
+ /** @hidden */
433
+ deriving?: SymbolPrimitive[];
434
+ /** @hidden */
435
+ contents: Constructor[];
436
+ /** @hidden */
437
+ name: SymbolPrimitive;
438
+ constructor(name: SymbolPrimitive, contents: Constructor[], deriving?: SymbolPrimitive[], loc?: SourceLocation);
439
+ accept<R>(visitor: Visitor<R>): R;
440
+ toJSON(): {
441
+ type: string;
442
+ name: {
443
+ type: string;
444
+ value: string;
445
+ };
446
+ contents: {
447
+ type: string;
448
+ name: {
449
+ type: string;
450
+ value: string;
451
+ };
452
+ fields: {
453
+ type: string;
454
+ name: {
455
+ type: string;
456
+ value: string;
457
+ };
458
+ value: any;
459
+ }[];
460
+ }[];
461
+ deriving: {
462
+ type: string;
463
+ value: string;
464
+ }[];
465
+ };
466
+ }
467
+ /**
468
+ * Represents the body of an Equation that does not have guards.
469
+ * Most languages match the body of its equations to it.
470
+ * @example
471
+ * f x = x + 2
472
+ * // The body is the `x + 2` part
473
+ * @example
474
+ * function f(x) {
475
+ * return x + 2;
476
+ * }
477
+ * @category Declarations
478
+ */
479
+ export declare class UnguardedBody extends ASTNode {
480
+ /** @hidden */
481
+ sequence: Sequence;
482
+ constructor(sequence: Sequence, loc?: SourceLocation);
483
+ accept<R>(visitor: Visitor<R>): R;
484
+ toJSON(): {
485
+ type: string;
486
+ sequence: any;
487
+ };
488
+ }
489
+ /**
490
+ * Represents the body of an Equation that does have guards.
491
+ * For example, Haskell's guards
492
+ * @example
493
+ * f x
494
+ * | x > 2 = x * 2
495
+ * | otherwise = x / 2
496
+ * @category Declarations
497
+ */
498
+ export declare class GuardedBody extends ASTNode {
499
+ /** @hidden */
500
+ body: Expression;
501
+ /** @hidden */
502
+ condition: Expression;
503
+ constructor(condition: Expression, body: Expression, loc?: SourceLocation);
504
+ accept<R>(visitor: Visitor<R>): R;
505
+ toJSON(): any;
506
+ }
507
+ /**
508
+ * Represents one Equation with its arguments and body. Allows for overloading and pattern matching.
509
+ * You may define the return statement to access it more easily.
510
+ *
511
+ * @example
512
+ * add 0 y = y
513
+ * add x y = x + y
514
+ * @category Declarations
515
+ */
516
+ export declare class Equation extends ASTNode {
517
+ /** @hidden */
518
+ patterns: Pattern[];
519
+ /** @hidden */
520
+ body: UnguardedBody | GuardedBody[];
521
+ /** @hidden */
522
+ returnExpr?: Return;
523
+ constructor(patterns: Pattern[], body: UnguardedBody | GuardedBody[], returnExpr?: Return, loc?: SourceLocation);
524
+ /** @hidden */
525
+ accept<R>(visitor: Visitor<R>): R;
526
+ /** @hidden */
527
+ toJSON(): any;
528
+ }
529
+ /**
530
+ * Functional / Imperative programming function declaration.
531
+ * It is is composed by an identifier and one or more equations
532
+ * @example
533
+ * int foo (int bar) {
534
+ * return bar;
535
+ * }
536
+ * @example
537
+ * def foo(bar):
538
+ * return bar
539
+ * @category Declarations
540
+ */
541
+ export declare class Function extends ASTNode {
542
+ /** @hidden */
543
+ equations: Equation[];
544
+ /** @hidden */
545
+ identifier: SymbolPrimitive;
546
+ constructor(identifier: SymbolPrimitive, equations: Equation[], loc?: SourceLocation);
547
+ accept<R>(visitor: Visitor<R>): R;
548
+ toJSON(): any;
549
+ }
550
+ /**
551
+ * Represents a case expression, selecting a branch based on pattern matching against a value.
552
+ *
553
+ * @example
554
+ * case x of
555
+ * [] -> 0
556
+ * (x:xs) -> 1 + length xs
557
+ * @category Expressions
558
+ */
559
+ export declare class Case extends ASTNode {
560
+ /** @hidden */
561
+ body: Expression;
562
+ /** @hidden */
563
+ condition: Expression;
564
+ constructor(condition: Expression, body: Expression, loc?: SourceLocation);
565
+ accept<R>(visitor: Visitor<R>): R;
566
+ toJSON(): {
567
+ type: string;
568
+ condition: any;
569
+ body: any;
570
+ };
571
+ }
572
+ /**
573
+ * Represents a switch statement, selecting execution paths based on value equality.
574
+ * @category Expressions
575
+ */
576
+ export declare class Switch extends ASTNode {
577
+ /** @hidden */
578
+ defaultExpr?: Expression;
579
+ /** @hidden */
580
+ cases: Case[];
581
+ /** @hidden */
582
+ value: Expression;
583
+ constructor(value: Expression, cases: Case[], defaultExpr?: Expression, loc?: SourceLocation);
584
+ accept<R>(visitor: Visitor<R>): R;
585
+ toJSON(): any;
586
+ }
587
+ /**
588
+ * Represents a catch block for handling exceptions thrown in a try block.
589
+ * @category Statements
590
+ */
591
+ export declare class Catch extends ASTNode {
592
+ /** @hidden */
593
+ body: Expression;
594
+ /** @hidden */
595
+ patterns: Pattern[];
596
+ constructor(patterns: Pattern[], body: Expression, loc?: SourceLocation);
597
+ accept<R>(visitor: Visitor<R>): R;
598
+ toJSON(): {
599
+ type: string;
600
+ patterns: any[];
601
+ body: any;
602
+ };
603
+ }
604
+ /**
605
+ * Represents a try block, wrapping code that might throw exceptions.
606
+ *
607
+ * @example
608
+ * try { ... } catch e : DomainException { ... }
609
+ * @category Statements
610
+ */
611
+ export declare class Try extends ASTNode {
612
+ /** @hidden */
613
+ finallyExpr: Expression;
614
+ /** @hidden */
615
+ catchExpr: Catch[];
616
+ /** @hidden */
617
+ body: Expression;
618
+ constructor(body: Expression, catchExpr: Catch[], finallyExpr: Expression, loc?: SourceLocation);
619
+ accept<R>(visitor: Visitor<R>): R;
620
+ toJSON(): any;
621
+ }
622
+ /**
623
+ * Represents an explicit raising or throwing of an exception or error.
624
+ * @category Statements
625
+ */
626
+ export declare class Raise extends ASTNode {
627
+ /** @hidden */
628
+ body: Expression;
629
+ constructor(body: Expression, loc?: SourceLocation);
630
+ accept<R>(visitor: Visitor<R>): R;
631
+ toJSON(): any;
632
+ }
633
+ /**
634
+ * Represents a command to output data to the standard output.
635
+ * @category Statements
636
+ */
637
+ export declare class Print extends ASTNode {
638
+ /** @hidden */
639
+ expression: Expression;
640
+ constructor(expression: Expression, loc?: SourceLocation);
641
+ accept<R>(visitor: Visitor<R>): R;
642
+ toJSON(): any;
643
+ }
644
+ /**
645
+ * Represents a command to read input from the user or standard input.
646
+ * @category Statements
647
+ */
648
+ export declare class Input extends ASTNode {
649
+ /** @hidden */
650
+ variable: SymbolPrimitive;
651
+ /** @hidden */
652
+ message: Expression;
653
+ constructor(message: Expression, variable: SymbolPrimitive, loc?: SourceLocation);
654
+ accept<R>(visitor: Visitor<R>): R;
655
+ toJSON(): any;
656
+ }
657
+ /**
658
+ * Represents a for-loop control structure for iterating over a sequence or range.
659
+ * @category Statements
660
+ */
661
+ export declare class For extends ASTNode {
662
+ /** @hidden */
663
+ statements: Statement[];
664
+ /** @hidden */
665
+ body: Expression;
666
+ constructor(body: Expression, statements: Statement[], loc?: SourceLocation);
667
+ accept<R>(visitor: Visitor<R>): R;
668
+ toJSON(): any;
669
+ }
670
+ /**
671
+ * Represents a control flow statement to exit the current loop immediately.
672
+ * @category Statements
673
+ */
674
+ export declare class Break extends ASTNode {
675
+ /** @hidden */
676
+ body?: Expression;
677
+ constructor(body?: Expression, loc?: SourceLocation);
678
+ accept<R>(visitor: Visitor<R>): R;
679
+ toJSON(): any;
680
+ }
681
+ /**
682
+ * Represents a control flow statement to skip the rest of the current loop iteration.
683
+ * @category Statements
684
+ */
685
+ export declare class Continue extends ASTNode {
686
+ /** @hidden */
687
+ body?: Expression;
688
+ constructor(body?: Expression, loc?: SourceLocation);
689
+ accept<R>(visitor: Visitor<R>): R;
690
+ toJSON(): any;
691
+ }
692
+ /**
693
+ * Represents a variable usage or reference in an expression.
694
+ * @category Expressions
695
+ */
696
+ export declare class Variable extends ASTNode {
697
+ /** @hidden */
698
+ variableType?: Type;
699
+ /** @hidden */
700
+ expression: Expression;
701
+ /** @hidden */
702
+ identifier: SymbolPrimitive;
703
+ constructor(identifier: SymbolPrimitive, expression: Expression, variableType?: Type, loc?: SourceLocation);
704
+ accept<R>(visitor: Visitor<R>): R;
705
+ toJSON(): any;
706
+ }
707
+ /**
708
+ * Represents an assignment operation, binding a value to a variable.
709
+ *
710
+ * @example
711
+ * count = count + 1
712
+ * @category Statements
713
+ */
714
+ export declare class Assignment extends ASTNode {
715
+ /** @hidden */
716
+ expression: Expression;
717
+ /** @hidden */
718
+ identifier: SymbolPrimitive;
719
+ constructor(identifier: SymbolPrimitive, expression: Expression, loc?: SourceLocation);
720
+ accept<R>(visitor: Visitor<R>): R;
721
+ toJSON(): any;
722
+ }
723
+ /**
724
+ * Represents a sequence of statements executed in order.
725
+ * @category Statements
726
+ */
727
+ export declare class Sequence extends ASTNode {
728
+ /** @hidden */
729
+ statements: Statement[];
730
+ constructor(statements: Statement[], loc?: SourceLocation);
731
+ accept<R>(visitor: Visitor<R>): R;
732
+ toJSON(): any;
733
+ }
734
+ export type Statement = EntryPoint | Function | Clause | Procedure | TypeAlias | TypeSignature | Class | Object | Method | Super | Attribute | Interface | Switch | Send | Try | Return | Print | Input | Raise | Structure | Break | Continue | Call | Enumeration | Variable | Assignment | Yield | Record | If | Repeat | ForLoop | While;
735
+ export type AST = Statement[];
736
+ export interface YukigoParser {
737
+ errors?: string[];
738
+ parse: (code: string) => AST;
739
+ }
740
+ export {};