yukigo-mini-parser 0.2.3 → 0.2.7

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.
@@ -0,0 +1,4628 @@
1
+ var YukigoMiniParser = (() => {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __commonJS = (cb, mod) => function __require() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+
36
+ // ../../node_modules/nearley/lib/nearley.js
37
+ var require_nearley = __commonJS({
38
+ "../../node_modules/nearley/lib/nearley.js"(exports, module) {
39
+ (function(root, factory) {
40
+ if (typeof module === "object" && module.exports) {
41
+ module.exports = factory();
42
+ } else {
43
+ root.nearley = factory();
44
+ }
45
+ })(exports, function() {
46
+ function Rule2(name, symbols, postprocess) {
47
+ this.id = ++Rule2.highestId;
48
+ this.name = name;
49
+ this.symbols = symbols;
50
+ this.postprocess = postprocess;
51
+ return this;
52
+ }
53
+ Rule2.highestId = 0;
54
+ Rule2.prototype.toString = function(withCursorAt) {
55
+ var symbolSequence = typeof withCursorAt === "undefined" ? this.symbols.map(getSymbolShortDisplay).join(" ") : this.symbols.slice(0, withCursorAt).map(getSymbolShortDisplay).join(" ") + " \u25CF " + this.symbols.slice(withCursorAt).map(getSymbolShortDisplay).join(" ");
56
+ return this.name + " \u2192 " + symbolSequence;
57
+ };
58
+ function State(rule, dot, reference, wantedBy) {
59
+ this.rule = rule;
60
+ this.dot = dot;
61
+ this.reference = reference;
62
+ this.data = [];
63
+ this.wantedBy = wantedBy;
64
+ this.isComplete = this.dot === rule.symbols.length;
65
+ }
66
+ State.prototype.toString = function() {
67
+ return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
68
+ };
69
+ State.prototype.nextState = function(child) {
70
+ var state = new State(this.rule, this.dot + 1, this.reference, this.wantedBy);
71
+ state.left = this;
72
+ state.right = child;
73
+ if (state.isComplete) {
74
+ state.data = state.build();
75
+ state.right = void 0;
76
+ }
77
+ return state;
78
+ };
79
+ State.prototype.build = function() {
80
+ var children = [];
81
+ var node = this;
82
+ do {
83
+ children.push(node.right.data);
84
+ node = node.left;
85
+ } while (node.left);
86
+ children.reverse();
87
+ return children;
88
+ };
89
+ State.prototype.finish = function() {
90
+ if (this.rule.postprocess) {
91
+ this.data = this.rule.postprocess(this.data, this.reference, Parser.fail);
92
+ }
93
+ };
94
+ function Column(grammar2, index) {
95
+ this.grammar = grammar2;
96
+ this.index = index;
97
+ this.states = [];
98
+ this.wants = {};
99
+ this.scannable = [];
100
+ this.completed = {};
101
+ }
102
+ Column.prototype.process = function(nextColumn) {
103
+ var states = this.states;
104
+ var wants = this.wants;
105
+ var completed = this.completed;
106
+ for (var w = 0; w < states.length; w++) {
107
+ var state = states[w];
108
+ if (state.isComplete) {
109
+ state.finish();
110
+ if (state.data !== Parser.fail) {
111
+ var wantedBy = state.wantedBy;
112
+ for (var i = wantedBy.length; i--; ) {
113
+ var left = wantedBy[i];
114
+ this.complete(left, state);
115
+ }
116
+ if (state.reference === this.index) {
117
+ var exp = state.rule.name;
118
+ (this.completed[exp] = this.completed[exp] || []).push(state);
119
+ }
120
+ }
121
+ } else {
122
+ var exp = state.rule.symbols[state.dot];
123
+ if (typeof exp !== "string") {
124
+ this.scannable.push(state);
125
+ continue;
126
+ }
127
+ if (wants[exp]) {
128
+ wants[exp].push(state);
129
+ if (completed.hasOwnProperty(exp)) {
130
+ var nulls = completed[exp];
131
+ for (var i = 0; i < nulls.length; i++) {
132
+ var right = nulls[i];
133
+ this.complete(state, right);
134
+ }
135
+ }
136
+ } else {
137
+ wants[exp] = [state];
138
+ this.predict(exp);
139
+ }
140
+ }
141
+ }
142
+ };
143
+ Column.prototype.predict = function(exp) {
144
+ var rules = this.grammar.byName[exp] || [];
145
+ for (var i = 0; i < rules.length; i++) {
146
+ var r = rules[i];
147
+ var wantedBy = this.wants[exp];
148
+ var s = new State(r, 0, this.index, wantedBy);
149
+ this.states.push(s);
150
+ }
151
+ };
152
+ Column.prototype.complete = function(left, right) {
153
+ var copy = left.nextState(right);
154
+ this.states.push(copy);
155
+ };
156
+ function Grammar(rules, start) {
157
+ this.rules = rules;
158
+ this.start = start || this.rules[0].name;
159
+ var byName = this.byName = {};
160
+ this.rules.forEach(function(rule) {
161
+ if (!byName.hasOwnProperty(rule.name)) {
162
+ byName[rule.name] = [];
163
+ }
164
+ byName[rule.name].push(rule);
165
+ });
166
+ }
167
+ Grammar.fromCompiled = function(rules, start) {
168
+ var lexer = rules.Lexer;
169
+ if (rules.ParserStart) {
170
+ start = rules.ParserStart;
171
+ rules = rules.ParserRules;
172
+ }
173
+ var rules = rules.map(function(r) {
174
+ return new Rule2(r.name, r.symbols, r.postprocess);
175
+ });
176
+ var g = new Grammar(rules, start);
177
+ g.lexer = lexer;
178
+ return g;
179
+ };
180
+ function StreamLexer() {
181
+ this.reset("");
182
+ }
183
+ StreamLexer.prototype.reset = function(data, state) {
184
+ this.buffer = data;
185
+ this.index = 0;
186
+ this.line = state ? state.line : 1;
187
+ this.lastLineBreak = state ? -state.col : 0;
188
+ };
189
+ StreamLexer.prototype.next = function() {
190
+ if (this.index < this.buffer.length) {
191
+ var ch = this.buffer[this.index++];
192
+ if (ch === "\n") {
193
+ this.line += 1;
194
+ this.lastLineBreak = this.index;
195
+ }
196
+ return { value: ch };
197
+ }
198
+ };
199
+ StreamLexer.prototype.save = function() {
200
+ return {
201
+ line: this.line,
202
+ col: this.index - this.lastLineBreak
203
+ };
204
+ };
205
+ StreamLexer.prototype.formatError = function(token, message) {
206
+ var buffer = this.buffer;
207
+ if (typeof buffer === "string") {
208
+ var lines = buffer.split("\n").slice(
209
+ Math.max(0, this.line - 5),
210
+ this.line
211
+ );
212
+ var nextLineBreak = buffer.indexOf("\n", this.index);
213
+ if (nextLineBreak === -1) nextLineBreak = buffer.length;
214
+ var col = this.index - this.lastLineBreak;
215
+ var lastLineDigits = String(this.line).length;
216
+ message += " at line " + this.line + " col " + col + ":\n\n";
217
+ message += lines.map(function(line, i) {
218
+ return pad(this.line - lines.length + i + 1, lastLineDigits) + " " + line;
219
+ }, this).join("\n");
220
+ message += "\n" + pad("", lastLineDigits + col) + "^\n";
221
+ return message;
222
+ } else {
223
+ return message + " at index " + (this.index - 1);
224
+ }
225
+ function pad(n, length) {
226
+ var s = String(n);
227
+ return Array(length - s.length + 1).join(" ") + s;
228
+ }
229
+ };
230
+ function Parser(rules, start, options) {
231
+ if (rules instanceof Grammar) {
232
+ var grammar2 = rules;
233
+ var options = start;
234
+ } else {
235
+ var grammar2 = Grammar.fromCompiled(rules, start);
236
+ }
237
+ this.grammar = grammar2;
238
+ this.options = {
239
+ keepHistory: false,
240
+ lexer: grammar2.lexer || new StreamLexer()
241
+ };
242
+ for (var key in options || {}) {
243
+ this.options[key] = options[key];
244
+ }
245
+ this.lexer = this.options.lexer;
246
+ this.lexerState = void 0;
247
+ var column = new Column(grammar2, 0);
248
+ var table = this.table = [column];
249
+ column.wants[grammar2.start] = [];
250
+ column.predict(grammar2.start);
251
+ column.process();
252
+ this.current = 0;
253
+ }
254
+ Parser.fail = {};
255
+ Parser.prototype.feed = function(chunk) {
256
+ var lexer = this.lexer;
257
+ lexer.reset(chunk, this.lexerState);
258
+ var token;
259
+ while (true) {
260
+ try {
261
+ token = lexer.next();
262
+ if (!token) {
263
+ break;
264
+ }
265
+ } catch (e) {
266
+ var nextColumn = new Column(this.grammar, this.current + 1);
267
+ this.table.push(nextColumn);
268
+ var err = new Error(this.reportLexerError(e));
269
+ err.offset = this.current;
270
+ err.token = e.token;
271
+ throw err;
272
+ }
273
+ var column = this.table[this.current];
274
+ if (!this.options.keepHistory) {
275
+ delete this.table[this.current - 1];
276
+ }
277
+ var n = this.current + 1;
278
+ var nextColumn = new Column(this.grammar, n);
279
+ this.table.push(nextColumn);
280
+ var literal = token.text !== void 0 ? token.text : token.value;
281
+ var value = lexer.constructor === StreamLexer ? token.value : token;
282
+ var scannable = column.scannable;
283
+ for (var w = scannable.length; w--; ) {
284
+ var state = scannable[w];
285
+ var expect = state.rule.symbols[state.dot];
286
+ if (expect.test ? expect.test(value) : expect.type ? expect.type === token.type : expect.literal === literal) {
287
+ var next = state.nextState({ data: value, token, isToken: true, reference: n - 1 });
288
+ nextColumn.states.push(next);
289
+ }
290
+ }
291
+ nextColumn.process();
292
+ if (nextColumn.states.length === 0) {
293
+ var err = new Error(this.reportError(token));
294
+ err.offset = this.current;
295
+ err.token = token;
296
+ throw err;
297
+ }
298
+ if (this.options.keepHistory) {
299
+ column.lexerState = lexer.save();
300
+ }
301
+ this.current++;
302
+ }
303
+ if (column) {
304
+ this.lexerState = lexer.save();
305
+ }
306
+ this.results = this.finish();
307
+ return this;
308
+ };
309
+ Parser.prototype.reportLexerError = function(lexerError) {
310
+ var tokenDisplay, lexerMessage;
311
+ var token = lexerError.token;
312
+ if (token) {
313
+ tokenDisplay = "input " + JSON.stringify(token.text[0]) + " (lexer error)";
314
+ lexerMessage = this.lexer.formatError(token, "Syntax error");
315
+ } else {
316
+ tokenDisplay = "input (lexer error)";
317
+ lexerMessage = lexerError.message;
318
+ }
319
+ return this.reportErrorCommon(lexerMessage, tokenDisplay);
320
+ };
321
+ Parser.prototype.reportError = function(token) {
322
+ var tokenDisplay = (token.type ? token.type + " token: " : "") + JSON.stringify(token.value !== void 0 ? token.value : token);
323
+ var lexerMessage = this.lexer.formatError(token, "Syntax error");
324
+ return this.reportErrorCommon(lexerMessage, tokenDisplay);
325
+ };
326
+ Parser.prototype.reportErrorCommon = function(lexerMessage, tokenDisplay) {
327
+ var lines = [];
328
+ lines.push(lexerMessage);
329
+ var lastColumnIndex = this.table.length - 2;
330
+ var lastColumn = this.table[lastColumnIndex];
331
+ var expectantStates = lastColumn.states.filter(function(state) {
332
+ var nextSymbol = state.rule.symbols[state.dot];
333
+ return nextSymbol && typeof nextSymbol !== "string";
334
+ });
335
+ if (expectantStates.length === 0) {
336
+ lines.push("Unexpected " + tokenDisplay + ". I did not expect any more input. Here is the state of my parse table:\n");
337
+ this.displayStateStack(lastColumn.states, lines);
338
+ } else {
339
+ lines.push("Unexpected " + tokenDisplay + ". Instead, I was expecting to see one of the following:\n");
340
+ var stateStacks = expectantStates.map(function(state) {
341
+ return this.buildFirstStateStack(state, []) || [state];
342
+ }, this);
343
+ stateStacks.forEach(function(stateStack) {
344
+ var state = stateStack[0];
345
+ var nextSymbol = state.rule.symbols[state.dot];
346
+ var symbolDisplay = this.getSymbolDisplay(nextSymbol);
347
+ lines.push("A " + symbolDisplay + " based on:");
348
+ this.displayStateStack(stateStack, lines);
349
+ }, this);
350
+ }
351
+ lines.push("");
352
+ return lines.join("\n");
353
+ };
354
+ Parser.prototype.displayStateStack = function(stateStack, lines) {
355
+ var lastDisplay;
356
+ var sameDisplayCount = 0;
357
+ for (var j = 0; j < stateStack.length; j++) {
358
+ var state = stateStack[j];
359
+ var display = state.rule.toString(state.dot);
360
+ if (display === lastDisplay) {
361
+ sameDisplayCount++;
362
+ } else {
363
+ if (sameDisplayCount > 0) {
364
+ lines.push(" ^ " + sameDisplayCount + " more lines identical to this");
365
+ }
366
+ sameDisplayCount = 0;
367
+ lines.push(" " + display);
368
+ }
369
+ lastDisplay = display;
370
+ }
371
+ };
372
+ Parser.prototype.getSymbolDisplay = function(symbol) {
373
+ return getSymbolLongDisplay(symbol);
374
+ };
375
+ Parser.prototype.buildFirstStateStack = function(state, visited) {
376
+ if (visited.indexOf(state) !== -1) {
377
+ return null;
378
+ }
379
+ if (state.wantedBy.length === 0) {
380
+ return [state];
381
+ }
382
+ var prevState = state.wantedBy[0];
383
+ var childVisited = [state].concat(visited);
384
+ var childResult = this.buildFirstStateStack(prevState, childVisited);
385
+ if (childResult === null) {
386
+ return null;
387
+ }
388
+ return [state].concat(childResult);
389
+ };
390
+ Parser.prototype.save = function() {
391
+ var column = this.table[this.current];
392
+ column.lexerState = this.lexerState;
393
+ return column;
394
+ };
395
+ Parser.prototype.restore = function(column) {
396
+ var index = column.index;
397
+ this.current = index;
398
+ this.table[index] = column;
399
+ this.table.splice(index + 1);
400
+ this.lexerState = column.lexerState;
401
+ this.results = this.finish();
402
+ };
403
+ Parser.prototype.rewind = function(index) {
404
+ if (!this.options.keepHistory) {
405
+ throw new Error("set option `keepHistory` to enable rewinding");
406
+ }
407
+ this.restore(this.table[index]);
408
+ };
409
+ Parser.prototype.finish = function() {
410
+ var considerations = [];
411
+ var start = this.grammar.start;
412
+ var column = this.table[this.table.length - 1];
413
+ column.states.forEach(function(t) {
414
+ if (t.rule.name === start && t.dot === t.rule.symbols.length && t.reference === 0 && t.data !== Parser.fail) {
415
+ considerations.push(t);
416
+ }
417
+ });
418
+ return considerations.map(function(c) {
419
+ return c.data;
420
+ });
421
+ };
422
+ function getSymbolLongDisplay(symbol) {
423
+ var type = typeof symbol;
424
+ if (type === "string") {
425
+ return symbol;
426
+ } else if (type === "object") {
427
+ if (symbol.literal) {
428
+ return JSON.stringify(symbol.literal);
429
+ } else if (symbol instanceof RegExp) {
430
+ return "character matching " + symbol;
431
+ } else if (symbol.type) {
432
+ return symbol.type + " token";
433
+ } else if (symbol.test) {
434
+ return "token matching " + String(symbol.test);
435
+ } else {
436
+ throw new Error("Unknown symbol type: " + symbol);
437
+ }
438
+ }
439
+ }
440
+ function getSymbolShortDisplay(symbol) {
441
+ var type = typeof symbol;
442
+ if (type === "string") {
443
+ return symbol;
444
+ } else if (type === "object") {
445
+ if (symbol.literal) {
446
+ return JSON.stringify(symbol.literal);
447
+ } else if (symbol instanceof RegExp) {
448
+ return symbol.toString();
449
+ } else if (symbol.type) {
450
+ return "%" + symbol.type;
451
+ } else if (symbol.test) {
452
+ return "<" + String(symbol.test) + ">";
453
+ } else {
454
+ throw new Error("Unknown symbol type: " + symbol);
455
+ }
456
+ }
457
+ }
458
+ return {
459
+ Parser,
460
+ Grammar,
461
+ Rule: Rule2
462
+ };
463
+ });
464
+ }
465
+ });
466
+
467
+ // ../../node_modules/moo/moo.js
468
+ var require_moo = __commonJS({
469
+ "../../node_modules/moo/moo.js"(exports, module) {
470
+ (function(root, factory) {
471
+ if (typeof define === "function" && define.amd) {
472
+ define([], factory);
473
+ } else if (typeof module === "object" && module.exports) {
474
+ module.exports = factory();
475
+ } else {
476
+ root.moo = factory();
477
+ }
478
+ })(exports, function() {
479
+ "use strict";
480
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
481
+ var toString = Object.prototype.toString;
482
+ var hasSticky = typeof new RegExp().sticky === "boolean";
483
+ function isRegExp(o) {
484
+ return o && toString.call(o) === "[object RegExp]";
485
+ }
486
+ function isObject(o) {
487
+ return o && typeof o === "object" && !isRegExp(o) && !Array.isArray(o);
488
+ }
489
+ function reEscape(s) {
490
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, function(x) {
491
+ if (x === "-") return "\\x2d";
492
+ return "\\" + x;
493
+ });
494
+ }
495
+ function reGroups(s) {
496
+ var re = new RegExp("|" + s);
497
+ return re.exec("").length - 1;
498
+ }
499
+ function reCapture(s) {
500
+ return "(" + s + ")";
501
+ }
502
+ function reUnion(regexps) {
503
+ if (!regexps.length) return "(?!)";
504
+ var source = regexps.map(function(s) {
505
+ return "(?:" + s + ")";
506
+ }).join("|");
507
+ return "(?:" + source + ")";
508
+ }
509
+ function regexpOrLiteral(obj) {
510
+ if (typeof obj === "string") {
511
+ return "(?:" + reEscape(obj) + ")";
512
+ } else if (isRegExp(obj)) {
513
+ if (obj.ignoreCase) throw new Error("RegExp /i flag not allowed");
514
+ if (obj.global) throw new Error("RegExp /g flag is implied");
515
+ if (obj.sticky) throw new Error("RegExp /y flag is implied");
516
+ if (obj.multiline) throw new Error("RegExp /m flag is implied");
517
+ return obj.source;
518
+ } else {
519
+ throw new Error("Not a pattern: " + obj);
520
+ }
521
+ }
522
+ function pad(s, length) {
523
+ if (s.length > length) {
524
+ return s;
525
+ }
526
+ return Array(length - s.length + 1).join(" ") + s;
527
+ }
528
+ function lastNLines(string2, numLines) {
529
+ var position = string2.length;
530
+ var lineBreaks = 0;
531
+ while (true) {
532
+ var idx = string2.lastIndexOf("\n", position - 1);
533
+ if (idx === -1) {
534
+ break;
535
+ } else {
536
+ lineBreaks++;
537
+ }
538
+ position = idx;
539
+ if (lineBreaks === numLines) {
540
+ break;
541
+ }
542
+ if (position === 0) {
543
+ break;
544
+ }
545
+ }
546
+ var startPosition = lineBreaks < numLines ? 0 : position + 1;
547
+ return string2.substring(startPosition).split("\n");
548
+ }
549
+ function objectToRules(object) {
550
+ var keys = Object.getOwnPropertyNames(object);
551
+ var result = [];
552
+ for (var i = 0; i < keys.length; i++) {
553
+ var key = keys[i];
554
+ var thing = object[key];
555
+ var rules = [].concat(thing);
556
+ if (key === "include") {
557
+ for (var j = 0; j < rules.length; j++) {
558
+ result.push({ include: rules[j] });
559
+ }
560
+ continue;
561
+ }
562
+ var match = [];
563
+ rules.forEach(function(rule) {
564
+ if (isObject(rule)) {
565
+ if (match.length) result.push(ruleOptions(key, match));
566
+ result.push(ruleOptions(key, rule));
567
+ match = [];
568
+ } else {
569
+ match.push(rule);
570
+ }
571
+ });
572
+ if (match.length) result.push(ruleOptions(key, match));
573
+ }
574
+ return result;
575
+ }
576
+ function arrayToRules(array) {
577
+ var result = [];
578
+ for (var i = 0; i < array.length; i++) {
579
+ var obj = array[i];
580
+ if (obj.include) {
581
+ var include = [].concat(obj.include);
582
+ for (var j = 0; j < include.length; j++) {
583
+ result.push({ include: include[j] });
584
+ }
585
+ continue;
586
+ }
587
+ if (!obj.type) {
588
+ throw new Error("Rule has no type: " + JSON.stringify(obj));
589
+ }
590
+ result.push(ruleOptions(obj.type, obj));
591
+ }
592
+ return result;
593
+ }
594
+ function ruleOptions(type, obj) {
595
+ if (!isObject(obj)) {
596
+ obj = { match: obj };
597
+ }
598
+ if (obj.include) {
599
+ throw new Error("Matching rules cannot also include states");
600
+ }
601
+ var options = {
602
+ defaultType: type,
603
+ lineBreaks: !!obj.error || !!obj.fallback,
604
+ pop: false,
605
+ next: null,
606
+ push: null,
607
+ error: false,
608
+ fallback: false,
609
+ value: null,
610
+ type: null,
611
+ shouldThrow: false
612
+ };
613
+ for (var key in obj) {
614
+ if (hasOwnProperty.call(obj, key)) {
615
+ options[key] = obj[key];
616
+ }
617
+ }
618
+ if (typeof options.type === "string" && type !== options.type) {
619
+ throw new Error("Type transform cannot be a string (type '" + options.type + "' for token '" + type + "')");
620
+ }
621
+ var match = options.match;
622
+ options.match = Array.isArray(match) ? match : match ? [match] : [];
623
+ options.match.sort(function(a, b) {
624
+ return isRegExp(a) && isRegExp(b) ? 0 : isRegExp(b) ? -1 : isRegExp(a) ? 1 : b.length - a.length;
625
+ });
626
+ return options;
627
+ }
628
+ function toRules(spec) {
629
+ return Array.isArray(spec) ? arrayToRules(spec) : objectToRules(spec);
630
+ }
631
+ var defaultErrorRule = ruleOptions("error", { lineBreaks: true, shouldThrow: true });
632
+ function compileRules(rules, hasStates) {
633
+ var errorRule = null;
634
+ var fast = /* @__PURE__ */ Object.create(null);
635
+ var fastAllowed = true;
636
+ var unicodeFlag = null;
637
+ var groups = [];
638
+ var parts = [];
639
+ for (var i = 0; i < rules.length; i++) {
640
+ if (rules[i].fallback) {
641
+ fastAllowed = false;
642
+ }
643
+ }
644
+ for (var i = 0; i < rules.length; i++) {
645
+ var options = rules[i];
646
+ if (options.include) {
647
+ throw new Error("Inheritance is not allowed in stateless lexers");
648
+ }
649
+ if (options.error || options.fallback) {
650
+ if (errorRule) {
651
+ if (!options.fallback === !errorRule.fallback) {
652
+ throw new Error("Multiple " + (options.fallback ? "fallback" : "error") + " rules not allowed (for token '" + options.defaultType + "')");
653
+ } else {
654
+ throw new Error("fallback and error are mutually exclusive (for token '" + options.defaultType + "')");
655
+ }
656
+ }
657
+ errorRule = options;
658
+ }
659
+ var match = options.match.slice();
660
+ if (fastAllowed) {
661
+ while (match.length && typeof match[0] === "string" && match[0].length === 1) {
662
+ var word = match.shift();
663
+ fast[word.charCodeAt(0)] = options;
664
+ }
665
+ }
666
+ if (options.pop || options.push || options.next) {
667
+ if (!hasStates) {
668
+ throw new Error("State-switching options are not allowed in stateless lexers (for token '" + options.defaultType + "')");
669
+ }
670
+ if (options.fallback) {
671
+ throw new Error("State-switching options are not allowed on fallback tokens (for token '" + options.defaultType + "')");
672
+ }
673
+ }
674
+ if (match.length === 0) {
675
+ continue;
676
+ }
677
+ fastAllowed = false;
678
+ groups.push(options);
679
+ for (var j = 0; j < match.length; j++) {
680
+ var obj = match[j];
681
+ if (!isRegExp(obj)) {
682
+ continue;
683
+ }
684
+ if (unicodeFlag === null) {
685
+ unicodeFlag = obj.unicode;
686
+ } else if (unicodeFlag !== obj.unicode && options.fallback === false) {
687
+ throw new Error("If one rule is /u then all must be");
688
+ }
689
+ }
690
+ var pat = reUnion(match.map(regexpOrLiteral));
691
+ var regexp = new RegExp(pat);
692
+ if (regexp.test("")) {
693
+ throw new Error("RegExp matches empty string: " + regexp);
694
+ }
695
+ var groupCount = reGroups(pat);
696
+ if (groupCount > 0) {
697
+ throw new Error("RegExp has capture groups: " + regexp + "\nUse (?: \u2026 ) instead");
698
+ }
699
+ if (!options.lineBreaks && regexp.test("\n")) {
700
+ throw new Error("Rule should declare lineBreaks: " + regexp);
701
+ }
702
+ parts.push(reCapture(pat));
703
+ }
704
+ var fallbackRule = errorRule && errorRule.fallback;
705
+ var flags = hasSticky && !fallbackRule ? "ym" : "gm";
706
+ var suffix = hasSticky || fallbackRule ? "" : "|";
707
+ if (unicodeFlag === true) flags += "u";
708
+ var combined = new RegExp(reUnion(parts) + suffix, flags);
709
+ return { regexp: combined, groups, fast, error: errorRule || defaultErrorRule };
710
+ }
711
+ function compile(rules) {
712
+ var result = compileRules(toRules(rules));
713
+ return new Lexer({ start: result }, "start");
714
+ }
715
+ function checkStateGroup(g, name, map) {
716
+ var state = g && (g.push || g.next);
717
+ if (state && !map[state]) {
718
+ throw new Error("Missing state '" + state + "' (in token '" + g.defaultType + "' of state '" + name + "')");
719
+ }
720
+ if (g && g.pop && +g.pop !== 1) {
721
+ throw new Error("pop must be 1 (in token '" + g.defaultType + "' of state '" + name + "')");
722
+ }
723
+ }
724
+ function compileStates(states, start) {
725
+ var all = states.$all ? toRules(states.$all) : [];
726
+ delete states.$all;
727
+ var keys = Object.getOwnPropertyNames(states);
728
+ if (!start) start = keys[0];
729
+ var ruleMap = /* @__PURE__ */ Object.create(null);
730
+ for (var i = 0; i < keys.length; i++) {
731
+ var key = keys[i];
732
+ ruleMap[key] = toRules(states[key]).concat(all);
733
+ }
734
+ for (var i = 0; i < keys.length; i++) {
735
+ var key = keys[i];
736
+ var rules = ruleMap[key];
737
+ var included = /* @__PURE__ */ Object.create(null);
738
+ for (var j = 0; j < rules.length; j++) {
739
+ var rule = rules[j];
740
+ if (!rule.include) continue;
741
+ var splice = [j, 1];
742
+ if (rule.include !== key && !included[rule.include]) {
743
+ included[rule.include] = true;
744
+ var newRules = ruleMap[rule.include];
745
+ if (!newRules) {
746
+ throw new Error("Cannot include nonexistent state '" + rule.include + "' (in state '" + key + "')");
747
+ }
748
+ for (var k = 0; k < newRules.length; k++) {
749
+ var newRule = newRules[k];
750
+ if (rules.indexOf(newRule) !== -1) continue;
751
+ splice.push(newRule);
752
+ }
753
+ }
754
+ rules.splice.apply(rules, splice);
755
+ j--;
756
+ }
757
+ }
758
+ var map = /* @__PURE__ */ Object.create(null);
759
+ for (var i = 0; i < keys.length; i++) {
760
+ var key = keys[i];
761
+ map[key] = compileRules(ruleMap[key], true);
762
+ }
763
+ for (var i = 0; i < keys.length; i++) {
764
+ var name = keys[i];
765
+ var state = map[name];
766
+ var groups = state.groups;
767
+ for (var j = 0; j < groups.length; j++) {
768
+ checkStateGroup(groups[j], name, map);
769
+ }
770
+ var fastKeys = Object.getOwnPropertyNames(state.fast);
771
+ for (var j = 0; j < fastKeys.length; j++) {
772
+ checkStateGroup(state.fast[fastKeys[j]], name, map);
773
+ }
774
+ }
775
+ return new Lexer(map, start);
776
+ }
777
+ function keywordTransform(map) {
778
+ var isMap = typeof Map !== "undefined";
779
+ var reverseMap = isMap ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null);
780
+ var types = Object.getOwnPropertyNames(map);
781
+ for (var i = 0; i < types.length; i++) {
782
+ var tokenType = types[i];
783
+ var item = map[tokenType];
784
+ var keywordList = Array.isArray(item) ? item : [item];
785
+ keywordList.forEach(function(keyword) {
786
+ if (typeof keyword !== "string") {
787
+ throw new Error("keyword must be string (in keyword '" + tokenType + "')");
788
+ }
789
+ if (isMap) {
790
+ reverseMap.set(keyword, tokenType);
791
+ } else {
792
+ reverseMap[keyword] = tokenType;
793
+ }
794
+ });
795
+ }
796
+ return function(k) {
797
+ return isMap ? reverseMap.get(k) : reverseMap[k];
798
+ };
799
+ }
800
+ var Lexer = function(states, state) {
801
+ this.startState = state;
802
+ this.states = states;
803
+ this.buffer = "";
804
+ this.stack = [];
805
+ this.reset();
806
+ };
807
+ Lexer.prototype.reset = function(data, info) {
808
+ this.buffer = data || "";
809
+ this.index = 0;
810
+ this.line = info ? info.line : 1;
811
+ this.col = info ? info.col : 1;
812
+ this.queuedToken = info ? info.queuedToken : null;
813
+ this.queuedText = info ? info.queuedText : "";
814
+ this.queuedThrow = info ? info.queuedThrow : null;
815
+ this.setState(info ? info.state : this.startState);
816
+ this.stack = info && info.stack ? info.stack.slice() : [];
817
+ return this;
818
+ };
819
+ Lexer.prototype.save = function() {
820
+ return {
821
+ line: this.line,
822
+ col: this.col,
823
+ state: this.state,
824
+ stack: this.stack.slice(),
825
+ queuedToken: this.queuedToken,
826
+ queuedText: this.queuedText,
827
+ queuedThrow: this.queuedThrow
828
+ };
829
+ };
830
+ Lexer.prototype.setState = function(state) {
831
+ if (!state || this.state === state) return;
832
+ this.state = state;
833
+ var info = this.states[state];
834
+ this.groups = info.groups;
835
+ this.error = info.error;
836
+ this.re = info.regexp;
837
+ this.fast = info.fast;
838
+ };
839
+ Lexer.prototype.popState = function() {
840
+ this.setState(this.stack.pop());
841
+ };
842
+ Lexer.prototype.pushState = function(state) {
843
+ this.stack.push(this.state);
844
+ this.setState(state);
845
+ };
846
+ var eat = hasSticky ? function(re, buffer) {
847
+ return re.exec(buffer);
848
+ } : function(re, buffer) {
849
+ var match = re.exec(buffer);
850
+ if (match[0].length === 0) {
851
+ return null;
852
+ }
853
+ return match;
854
+ };
855
+ Lexer.prototype._getGroup = function(match) {
856
+ var groupCount = this.groups.length;
857
+ for (var i = 0; i < groupCount; i++) {
858
+ if (match[i + 1] !== void 0) {
859
+ return this.groups[i];
860
+ }
861
+ }
862
+ throw new Error("Cannot find token type for matched text");
863
+ };
864
+ function tokenToString() {
865
+ return this.value;
866
+ }
867
+ Lexer.prototype.next = function() {
868
+ var index = this.index;
869
+ if (this.queuedGroup) {
870
+ var token = this._token(this.queuedGroup, this.queuedText, index);
871
+ this.queuedGroup = null;
872
+ this.queuedText = "";
873
+ return token;
874
+ }
875
+ var buffer = this.buffer;
876
+ if (index === buffer.length) {
877
+ return;
878
+ }
879
+ var group = this.fast[buffer.charCodeAt(index)];
880
+ if (group) {
881
+ return this._token(group, buffer.charAt(index), index);
882
+ }
883
+ var re = this.re;
884
+ re.lastIndex = index;
885
+ var match = eat(re, buffer);
886
+ var error = this.error;
887
+ if (match == null) {
888
+ return this._token(error, buffer.slice(index, buffer.length), index);
889
+ }
890
+ var group = this._getGroup(match);
891
+ var text = match[0];
892
+ if (error.fallback && match.index !== index) {
893
+ this.queuedGroup = group;
894
+ this.queuedText = text;
895
+ return this._token(error, buffer.slice(index, match.index), index);
896
+ }
897
+ return this._token(group, text, index);
898
+ };
899
+ Lexer.prototype._token = function(group, text, offset) {
900
+ var lineBreaks = 0;
901
+ if (group.lineBreaks) {
902
+ var matchNL = /\n/g;
903
+ var nl = 1;
904
+ if (text === "\n") {
905
+ lineBreaks = 1;
906
+ } else {
907
+ while (matchNL.exec(text)) {
908
+ lineBreaks++;
909
+ nl = matchNL.lastIndex;
910
+ }
911
+ }
912
+ }
913
+ var token = {
914
+ type: typeof group.type === "function" && group.type(text) || group.defaultType,
915
+ value: typeof group.value === "function" ? group.value(text) : text,
916
+ text,
917
+ toString: tokenToString,
918
+ offset,
919
+ lineBreaks,
920
+ line: this.line,
921
+ col: this.col
922
+ };
923
+ var size = text.length;
924
+ this.index += size;
925
+ this.line += lineBreaks;
926
+ if (lineBreaks !== 0) {
927
+ this.col = size - nl + 1;
928
+ } else {
929
+ this.col += size;
930
+ }
931
+ if (group.shouldThrow) {
932
+ var err = new Error(this.formatError(token, "invalid syntax"));
933
+ throw err;
934
+ }
935
+ if (group.pop) this.popState();
936
+ else if (group.push) this.pushState(group.push);
937
+ else if (group.next) this.setState(group.next);
938
+ return token;
939
+ };
940
+ if (typeof Symbol !== "undefined" && Symbol.iterator) {
941
+ var LexerIterator = function(lexer) {
942
+ this.lexer = lexer;
943
+ };
944
+ LexerIterator.prototype.next = function() {
945
+ var token = this.lexer.next();
946
+ return { value: token, done: !token };
947
+ };
948
+ LexerIterator.prototype[Symbol.iterator] = function() {
949
+ return this;
950
+ };
951
+ Lexer.prototype[Symbol.iterator] = function() {
952
+ return new LexerIterator(this);
953
+ };
954
+ }
955
+ Lexer.prototype.formatError = function(token, message) {
956
+ if (token == null) {
957
+ var text = this.buffer.slice(this.index);
958
+ var token = {
959
+ text,
960
+ offset: this.index,
961
+ lineBreaks: text.indexOf("\n") === -1 ? 0 : 1,
962
+ line: this.line,
963
+ col: this.col
964
+ };
965
+ }
966
+ var numLinesAround = 2;
967
+ var firstDisplayedLine = Math.max(token.line - numLinesAround, 1);
968
+ var lastDisplayedLine = token.line + numLinesAround;
969
+ var lastLineDigits = String(lastDisplayedLine).length;
970
+ var displayedLines = lastNLines(
971
+ this.buffer,
972
+ this.line - token.line + numLinesAround + 1
973
+ ).slice(0, 5);
974
+ var errorLines = [];
975
+ errorLines.push(message + " at line " + token.line + " col " + token.col + ":");
976
+ errorLines.push("");
977
+ for (var i = 0; i < displayedLines.length; i++) {
978
+ var line = displayedLines[i];
979
+ var lineNo = firstDisplayedLine + i;
980
+ errorLines.push(pad(String(lineNo), lastLineDigits) + " " + line);
981
+ if (lineNo === token.line) {
982
+ errorLines.push(pad("", lastLineDigits + token.col + 1) + "^");
983
+ }
984
+ }
985
+ return errorLines.join("\n");
986
+ };
987
+ Lexer.prototype.clone = function() {
988
+ return new Lexer(this.states, this.state);
989
+ };
990
+ Lexer.prototype.has = function(tokenType) {
991
+ return true;
992
+ };
993
+ return {
994
+ compile,
995
+ states: compileStates,
996
+ error: Object.freeze({ error: true }),
997
+ fallback: Object.freeze({ fallback: true }),
998
+ keywords: keywordTransform
999
+ };
1000
+ });
1001
+ }
1002
+ });
1003
+
1004
+ // ../../node_modules/moo-ignore/index.js
1005
+ var require_moo_ignore = __commonJS({
1006
+ "../../node_modules/moo-ignore/index.js"(exports, module) {
1007
+ var moo2 = require_moo();
1008
+ function makeLexer2(tokens, ignoreTokens, options = {}) {
1009
+ let lexer;
1010
+ let oldnext;
1011
+ let newTokens = {};
1012
+ lexer = moo2.compile(tokens);
1013
+ oldnext = lexer.next;
1014
+ lexer.ignore = function(...types) {
1015
+ if (this.ignoreSet) {
1016
+ this.ignoreSet = /* @__PURE__ */ new Set([...this.ignoreSet, ...types]);
1017
+ } else this.ignoreSet = new Set(types);
1018
+ };
1019
+ lexer.next = function() {
1020
+ while (true) {
1021
+ let token = oldnext.call(this);
1022
+ if (token == void 0 || !this.ignoreSet.has(token.type)) {
1023
+ return token;
1024
+ }
1025
+ }
1026
+ };
1027
+ if (options.eof) {
1028
+ let oldReset = lexer.reset;
1029
+ lexer.reset = function(input) {
1030
+ if (tokens.EOF) input += tokens.EOF;
1031
+ return oldReset.call(this, input);
1032
+ };
1033
+ }
1034
+ if (ignoreTokens) {
1035
+ lexer.ignoreSet = new Set(ignoreTokens);
1036
+ }
1037
+ return lexer;
1038
+ }
1039
+ module.exports = {
1040
+ /**
1041
+ * The lexer constructor
1042
+ */
1043
+ makeLexer: makeLexer2,
1044
+ /**
1045
+ * The moo object (as built in `const moo = require("moo")`)
1046
+ */
1047
+ moo: moo2
1048
+ };
1049
+ }
1050
+ });
1051
+
1052
+ // src/lexer.ts
1053
+ var lexer_exports = {};
1054
+ __export(lexer_exports, {
1055
+ MiniLexer: () => MiniLexer,
1056
+ MiniLexerConfig: () => MiniLexerConfig
1057
+ });
1058
+ var import_moo, import_moo_ignore, keywords, MiniLexerConfig, MiniLexer;
1059
+ var init_lexer = __esm({
1060
+ "src/lexer.ts"() {
1061
+ import_moo = __toESM(require_moo(), 1);
1062
+ import_moo_ignore = __toESM(require_moo_ignore(), 1);
1063
+ keywords = [
1064
+ "return",
1065
+ "if",
1066
+ "else"
1067
+ ];
1068
+ MiniLexerConfig = {
1069
+ EOF: "*__EOF__*",
1070
+ wildcard: "_",
1071
+ WS: /[ \t]+/,
1072
+ comment: /--.*?$|{-[\s\S]*?-}/,
1073
+ number: /0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|(?:\d*\.\d+|\d+)(?:[eE][+-]?\d+)?/,
1074
+ char: /'(?:\\['\\bfnrtv0]|\\u[0-9a-fA-F]{4}|[^'\\\n\r])?'/,
1075
+ string: /"(?:\\["\\bfnrtv0]|\\u[0-9a-fA-F]{4}|[^"\\\n\r])*"/,
1076
+ bool: {
1077
+ match: ["True", "False"]
1078
+ },
1079
+ semicolon: ";",
1080
+ assign: ":=",
1081
+ notEqual: "!=",
1082
+ equal: "==",
1083
+ gte: ">=",
1084
+ gt: ">",
1085
+ lte: "<=",
1086
+ lt: "<",
1087
+ lparen: "(",
1088
+ rparen: ")",
1089
+ lsquare: "[",
1090
+ rsquare: "]",
1091
+ lbracket: "{",
1092
+ rbracket: "}",
1093
+ comma: ",",
1094
+ operator: /\+|\*/,
1095
+ variable: {
1096
+ match: /[a-z_][a-zA-Z0-9_']*/,
1097
+ type: import_moo.default.keywords({
1098
+ keyword: keywords
1099
+ })
1100
+ },
1101
+ NL: { match: /\r?\n/, lineBreaks: true }
1102
+ };
1103
+ MiniLexer = (0, import_moo_ignore.makeLexer)(MiniLexerConfig, ["NL", "comment"], {
1104
+ eof: true
1105
+ });
1106
+ }
1107
+ });
1108
+
1109
+ // ../yukigo-ast/dist/globals/generics.js
1110
+ var ASTNode, SourceLocation;
1111
+ var init_generics = __esm({
1112
+ "../yukigo-ast/dist/globals/generics.js"() {
1113
+ ASTNode = class {
1114
+ /** @hidden */
1115
+ loc;
1116
+ /** @hidden */
1117
+ metadata = /* @__PURE__ */ new Map();
1118
+ constructor(loc, metadata) {
1119
+ this.loc = loc;
1120
+ this.metadata = metadata ?? /* @__PURE__ */ new Map();
1121
+ }
1122
+ setMetadata(key, value) {
1123
+ this.metadata.set(key, value);
1124
+ }
1125
+ getMetadata(key) {
1126
+ return this.metadata.get(key);
1127
+ }
1128
+ hasMetadata(key) {
1129
+ return this.metadata.has(key);
1130
+ }
1131
+ static [Symbol.hasInstance](instance) {
1132
+ if (!instance || typeof instance !== "object")
1133
+ return false;
1134
+ let proto = Object.getPrototypeOf(instance);
1135
+ while (proto) {
1136
+ if (proto.constructor.name === this.name)
1137
+ return true;
1138
+ proto = Object.getPrototypeOf(proto);
1139
+ }
1140
+ return false;
1141
+ }
1142
+ is(nodeType) {
1143
+ return this instanceof nodeType || this.constructor.name === nodeType.name;
1144
+ }
1145
+ dispatchVisit(visitor, callback) {
1146
+ return callback ? callback.call(visitor, this) : visitor.fallback(this);
1147
+ }
1148
+ };
1149
+ SourceLocation = class {
1150
+ line;
1151
+ column;
1152
+ constructor(line, column) {
1153
+ this.line = line;
1154
+ this.column = column;
1155
+ }
1156
+ toJSON() {
1157
+ return {
1158
+ type: "SourceLocation",
1159
+ line: this.line,
1160
+ column: this.column
1161
+ };
1162
+ }
1163
+ };
1164
+ }
1165
+ });
1166
+
1167
+ // ../yukigo-ast/dist/globals/expressions.js
1168
+ var TupleExpression, FieldExpression, DataExpression, ConsExpression, LetInExpression, Otherwise, ListComprehension, Generator, RangeExpression, NamedArgument, GuardedExpression, Guard;
1169
+ var init_expressions = __esm({
1170
+ "../yukigo-ast/dist/globals/expressions.js"() {
1171
+ init_generics();
1172
+ TupleExpression = class extends ASTNode {
1173
+ /** @hidden */
1174
+ elements;
1175
+ constructor(elements, loc) {
1176
+ super(loc);
1177
+ this.elements = elements;
1178
+ }
1179
+ accept(visitor) {
1180
+ return this.dispatchVisit(visitor, visitor.visitTupleExpr);
1181
+ }
1182
+ toJSON() {
1183
+ return {
1184
+ type: "TupleExpression",
1185
+ elements: this.elements.map((expr) => expr.toJSON())
1186
+ };
1187
+ }
1188
+ };
1189
+ FieldExpression = class extends ASTNode {
1190
+ /** @hidden */
1191
+ expression;
1192
+ /** @hidden */
1193
+ name;
1194
+ constructor(name, expression, loc) {
1195
+ super(loc);
1196
+ this.name = name;
1197
+ this.expression = expression;
1198
+ }
1199
+ accept(visitor) {
1200
+ return this.dispatchVisit(visitor, visitor.visitFieldExpr);
1201
+ }
1202
+ toJSON() {
1203
+ return {
1204
+ type: "FieldExpression",
1205
+ name: this.name.toJSON(),
1206
+ expression: this.expression.toJSON()
1207
+ };
1208
+ }
1209
+ };
1210
+ DataExpression = class extends ASTNode {
1211
+ /** @hidden */
1212
+ contents;
1213
+ /** @hidden */
1214
+ name;
1215
+ constructor(name, contents, loc) {
1216
+ super(loc);
1217
+ this.name = name;
1218
+ this.contents = contents;
1219
+ }
1220
+ accept(visitor) {
1221
+ return this.dispatchVisit(visitor, visitor.visitDataExpr);
1222
+ }
1223
+ toJSON() {
1224
+ return {
1225
+ type: "DataExpression",
1226
+ name: this.name.toJSON(),
1227
+ contents: this.contents.map((expr) => expr.toJSON())
1228
+ };
1229
+ }
1230
+ };
1231
+ ConsExpression = class extends ASTNode {
1232
+ /** @hidden */
1233
+ tail;
1234
+ /** @hidden */
1235
+ head;
1236
+ constructor(head, tail, loc) {
1237
+ super(loc);
1238
+ this.head = head;
1239
+ this.tail = tail;
1240
+ }
1241
+ accept(visitor) {
1242
+ return this.dispatchVisit(visitor, visitor.visitConsExpr);
1243
+ }
1244
+ toJSON() {
1245
+ return {
1246
+ type: "ConsExpression",
1247
+ head: this.head.toJSON(),
1248
+ tail: this.tail.toJSON()
1249
+ };
1250
+ }
1251
+ };
1252
+ LetInExpression = class extends ASTNode {
1253
+ /** @hidden */
1254
+ expression;
1255
+ /** @hidden */
1256
+ declarations;
1257
+ constructor(declarations, expression, loc) {
1258
+ super(loc);
1259
+ this.declarations = declarations;
1260
+ this.expression = expression;
1261
+ }
1262
+ accept(visitor) {
1263
+ return this.dispatchVisit(visitor, visitor.visitLetInExpr);
1264
+ }
1265
+ toJSON() {
1266
+ return {
1267
+ type: "LetInExpression",
1268
+ declarations: this.declarations.toJSON(),
1269
+ expression: this.expression.toJSON()
1270
+ };
1271
+ }
1272
+ };
1273
+ Otherwise = class extends ASTNode {
1274
+ accept(visitor) {
1275
+ return this.dispatchVisit(visitor, visitor.visitOtherwise);
1276
+ }
1277
+ toJSON() {
1278
+ return {
1279
+ type: "Otherwise"
1280
+ };
1281
+ }
1282
+ };
1283
+ ListComprehension = class extends ASTNode {
1284
+ /** @hidden */
1285
+ generators;
1286
+ /** @hidden */
1287
+ projection;
1288
+ constructor(projection, generators, loc) {
1289
+ super(loc);
1290
+ this.projection = projection;
1291
+ this.generators = generators;
1292
+ }
1293
+ accept(visitor) {
1294
+ return this.dispatchVisit(visitor, visitor.visitListComprehension);
1295
+ }
1296
+ toJSON() {
1297
+ return {
1298
+ type: "ListComprehension",
1299
+ projection: this.projection.toJSON(),
1300
+ generators: this.generators.map((gen) => gen.toJSON())
1301
+ };
1302
+ }
1303
+ };
1304
+ Generator = class extends ASTNode {
1305
+ /** @hidden */
1306
+ expression;
1307
+ /** @hidden */
1308
+ variable;
1309
+ constructor(variable2, expression, loc) {
1310
+ super(loc);
1311
+ this.variable = variable2;
1312
+ this.expression = expression;
1313
+ }
1314
+ accept(visitor) {
1315
+ return this.dispatchVisit(visitor, visitor.visitGenerator);
1316
+ }
1317
+ toJSON() {
1318
+ return {
1319
+ type: "Generator",
1320
+ variable: this.variable.toJSON(),
1321
+ expression: this.expression.toJSON()
1322
+ };
1323
+ }
1324
+ };
1325
+ RangeExpression = class extends ASTNode {
1326
+ /** @hidden */
1327
+ step;
1328
+ /** @hidden */
1329
+ end;
1330
+ /** @hidden */
1331
+ start;
1332
+ constructor(start, end, step, loc) {
1333
+ super(loc);
1334
+ this.start = start;
1335
+ this.end = end;
1336
+ this.step = step;
1337
+ }
1338
+ accept(visitor) {
1339
+ return this.dispatchVisit(visitor, visitor.visitRangeExpression);
1340
+ }
1341
+ toJSON() {
1342
+ return {
1343
+ type: "RangeExpression",
1344
+ start: this.start.toJSON(),
1345
+ end: this.end?.toJSON(),
1346
+ step: this.step?.toJSON()
1347
+ };
1348
+ }
1349
+ };
1350
+ NamedArgument = class extends ASTNode {
1351
+ identifier;
1352
+ expression;
1353
+ constructor(identifier, expression, loc) {
1354
+ super(loc);
1355
+ this.identifier = identifier;
1356
+ this.expression = expression;
1357
+ }
1358
+ accept(visitor) {
1359
+ return this.dispatchVisit(visitor, visitor.visitNamedArgument);
1360
+ }
1361
+ toJSON() {
1362
+ return {
1363
+ type: "NamedArgument",
1364
+ identifier: this.identifier.toJSON(),
1365
+ expression: this.expression.toJSON()
1366
+ };
1367
+ }
1368
+ };
1369
+ GuardedExpression = class extends ASTNode {
1370
+ guards;
1371
+ constructor(guards, loc) {
1372
+ super(loc);
1373
+ this.guards = guards;
1374
+ }
1375
+ accept(visitor) {
1376
+ return this.dispatchVisit(visitor, visitor.visitGuardedExpression);
1377
+ }
1378
+ toJSON() {
1379
+ return {
1380
+ type: "GuardedExpression",
1381
+ guards: this.guards.map((g) => g.toJSON())
1382
+ };
1383
+ }
1384
+ };
1385
+ Guard = class extends ASTNode {
1386
+ /** @hidden */
1387
+ body;
1388
+ /** @hidden */
1389
+ condition;
1390
+ constructor(condition, body, loc) {
1391
+ super(loc);
1392
+ this.condition = condition;
1393
+ this.body = body;
1394
+ }
1395
+ accept(visitor) {
1396
+ return this.dispatchVisit(visitor, visitor.visitGuard);
1397
+ }
1398
+ toJSON() {
1399
+ return {
1400
+ type: "Guard",
1401
+ condition: this.condition.toJSON(),
1402
+ body: this.body.toJSON()
1403
+ };
1404
+ }
1405
+ };
1406
+ }
1407
+ });
1408
+
1409
+ // ../yukigo-ast/dist/globals/primitives.js
1410
+ function isYukigoPrimitive(node) {
1411
+ return node instanceof BasePrimitive;
1412
+ }
1413
+ var BasePrimitive, NumberPrimitive, BooleanPrimitive, CharPrimitive, StringPrimitive, NilPrimitive, SymbolPrimitive, ListPrimitive;
1414
+ var init_primitives = __esm({
1415
+ "../yukigo-ast/dist/globals/primitives.js"() {
1416
+ init_generics();
1417
+ BasePrimitive = class extends ASTNode {
1418
+ value;
1419
+ constructor(value, loc) {
1420
+ super(loc);
1421
+ this.value = value;
1422
+ }
1423
+ /**
1424
+ * Generic equality check.
1425
+ */
1426
+ equals(other) {
1427
+ if (this.constructor !== other.constructor)
1428
+ return false;
1429
+ return this.value === other.value;
1430
+ }
1431
+ toJSON() {
1432
+ return {
1433
+ type: this.jsonType,
1434
+ value: this.value
1435
+ };
1436
+ }
1437
+ };
1438
+ NumberPrimitive = class extends BasePrimitive {
1439
+ get jsonType() {
1440
+ return "YuNumber";
1441
+ }
1442
+ accept(visitor) {
1443
+ return this.dispatchVisit(visitor, visitor.visitNumberPrimitive);
1444
+ }
1445
+ };
1446
+ BooleanPrimitive = class extends BasePrimitive {
1447
+ get jsonType() {
1448
+ return "YuBoolean";
1449
+ }
1450
+ accept(visitor) {
1451
+ return this.dispatchVisit(visitor, visitor.visitBooleanPrimitive);
1452
+ }
1453
+ };
1454
+ CharPrimitive = class extends BasePrimitive {
1455
+ get jsonType() {
1456
+ return "YuChar";
1457
+ }
1458
+ accept(visitor) {
1459
+ return this.dispatchVisit(visitor, visitor.visitCharPrimitive);
1460
+ }
1461
+ };
1462
+ StringPrimitive = class extends BasePrimitive {
1463
+ get jsonType() {
1464
+ return "YuString";
1465
+ }
1466
+ accept(visitor) {
1467
+ return this.dispatchVisit(visitor, visitor.visitStringPrimitive);
1468
+ }
1469
+ };
1470
+ NilPrimitive = class extends BasePrimitive {
1471
+ get jsonType() {
1472
+ return "YuNil";
1473
+ }
1474
+ accept(visitor) {
1475
+ return this.dispatchVisit(visitor, visitor.visitNilPrimitive);
1476
+ }
1477
+ };
1478
+ SymbolPrimitive = class extends BasePrimitive {
1479
+ get jsonType() {
1480
+ return "YuSymbol";
1481
+ }
1482
+ accept(visitor) {
1483
+ return this.dispatchVisit(visitor, visitor.visitSymbolPrimitive);
1484
+ }
1485
+ };
1486
+ ListPrimitive = class _ListPrimitive extends BasePrimitive {
1487
+ get jsonType() {
1488
+ return "YuList";
1489
+ }
1490
+ accept(visitor) {
1491
+ return this.dispatchVisit(visitor, visitor.visitListPrimitive);
1492
+ }
1493
+ equals(other) {
1494
+ if (!(other instanceof _ListPrimitive))
1495
+ return false;
1496
+ if (this.value.length !== other.value.length)
1497
+ return false;
1498
+ return this.value.every((elem, i) => {
1499
+ const otherElem = other.value[i];
1500
+ if (!isYukigoPrimitive(otherElem))
1501
+ return false;
1502
+ if ("equals" in elem && typeof elem.equals === "function")
1503
+ return elem.equals(otherElem);
1504
+ return elem === otherElem;
1505
+ });
1506
+ }
1507
+ };
1508
+ }
1509
+ });
1510
+
1511
+ // ../yukigo-ast/dist/globals/statements.js
1512
+ var If, Return, Field, Constructor, Record, UnguardedBody, NativeBody, Equation, Function, Case, Switch, Catch, Try, Raise, Print, Input, For, Break, Continue, Variable, Assignment, Sequence;
1513
+ var init_statements = __esm({
1514
+ "../yukigo-ast/dist/globals/statements.js"() {
1515
+ init_generics();
1516
+ init_primitives();
1517
+ If = class extends ASTNode {
1518
+ /** @hidden */
1519
+ elseExpr;
1520
+ /** @hidden */
1521
+ then;
1522
+ /** @hidden */
1523
+ condition;
1524
+ constructor(condition, then, elseExpr, loc) {
1525
+ super(loc);
1526
+ this.condition = condition;
1527
+ this.then = then;
1528
+ this.elseExpr = elseExpr;
1529
+ }
1530
+ accept(visitor) {
1531
+ return this.dispatchVisit(visitor, visitor.visitIf);
1532
+ }
1533
+ toJSON() {
1534
+ return {
1535
+ type: "If",
1536
+ condition: this.condition.toJSON(),
1537
+ then: this.then.toJSON(),
1538
+ else: this.elseExpr.toJSON()
1539
+ };
1540
+ }
1541
+ };
1542
+ Return = class extends ASTNode {
1543
+ /** @hidden */
1544
+ body;
1545
+ constructor(body = new NilPrimitive(null), loc) {
1546
+ super(loc);
1547
+ this.body = body;
1548
+ }
1549
+ accept(visitor) {
1550
+ return this.dispatchVisit(visitor, visitor.visitReturn);
1551
+ }
1552
+ toJSON() {
1553
+ return {
1554
+ type: "Return",
1555
+ body: this.body?.toJSON()
1556
+ };
1557
+ }
1558
+ };
1559
+ Field = class extends ASTNode {
1560
+ /** @hidden */
1561
+ value;
1562
+ /** @hidden */
1563
+ name;
1564
+ constructor(name, value, loc) {
1565
+ super(loc);
1566
+ this.name = name;
1567
+ this.value = value;
1568
+ }
1569
+ accept(visitor) {
1570
+ return this.dispatchVisit(visitor, visitor.visitField);
1571
+ }
1572
+ toJSON() {
1573
+ return {
1574
+ type: "Field",
1575
+ name: this.name?.toJSON(),
1576
+ value: this.value.toJSON()
1577
+ };
1578
+ }
1579
+ };
1580
+ Constructor = class extends ASTNode {
1581
+ /** @hidden */
1582
+ fields;
1583
+ /** @hidden */
1584
+ name;
1585
+ constructor(name, fields, loc) {
1586
+ super(loc);
1587
+ this.name = name;
1588
+ this.fields = fields;
1589
+ }
1590
+ accept(visitor) {
1591
+ return this.dispatchVisit(visitor, visitor.visitConstructor);
1592
+ }
1593
+ toJSON() {
1594
+ return {
1595
+ type: "Constructor",
1596
+ name: this.name.toJSON(),
1597
+ fields: this.fields.map((f) => f.toJSON())
1598
+ };
1599
+ }
1600
+ };
1601
+ Record = class extends ASTNode {
1602
+ /** @hidden */
1603
+ deriving;
1604
+ /** @hidden */
1605
+ contents;
1606
+ /** @hidden */
1607
+ name;
1608
+ constructor(name, contents, deriving, loc) {
1609
+ super(loc);
1610
+ this.name = name;
1611
+ this.contents = contents;
1612
+ this.deriving = deriving;
1613
+ }
1614
+ accept(visitor) {
1615
+ return this.dispatchVisit(visitor, visitor.visitRecord);
1616
+ }
1617
+ toJSON() {
1618
+ return {
1619
+ type: "Record",
1620
+ name: this.name.toJSON(),
1621
+ contents: this.contents.map((constructor) => constructor.toJSON()),
1622
+ deriving: this.deriving?.map((d) => d.toJSON())
1623
+ };
1624
+ }
1625
+ };
1626
+ UnguardedBody = class extends ASTNode {
1627
+ /** @hidden */
1628
+ sequence;
1629
+ constructor(sequence, loc) {
1630
+ super(loc);
1631
+ this.sequence = sequence;
1632
+ }
1633
+ accept(visitor) {
1634
+ return this.dispatchVisit(visitor, visitor.visitUnguardedBody);
1635
+ }
1636
+ toJSON() {
1637
+ return {
1638
+ type: "UnguardedBody",
1639
+ sequence: this.sequence.toJSON()
1640
+ };
1641
+ }
1642
+ };
1643
+ NativeBody = class extends ASTNode {
1644
+ constructor(loc) {
1645
+ super(loc);
1646
+ }
1647
+ accept(visitor) {
1648
+ return this.dispatchVisit(visitor, visitor.visitNativeBody);
1649
+ }
1650
+ toJSON() {
1651
+ return {
1652
+ type: "NativeBody"
1653
+ };
1654
+ }
1655
+ };
1656
+ Equation = class extends ASTNode {
1657
+ /** @hidden */
1658
+ patterns;
1659
+ /** @hidden */
1660
+ body;
1661
+ /** @hidden */
1662
+ returnExpr;
1663
+ constructor(patterns, body, returnExpr, loc) {
1664
+ super(loc);
1665
+ this.patterns = patterns;
1666
+ this.body = body;
1667
+ this.returnExpr = returnExpr;
1668
+ }
1669
+ /** @hidden */
1670
+ accept(visitor) {
1671
+ return this.dispatchVisit(visitor, visitor.visitEquation);
1672
+ }
1673
+ /** @hidden */
1674
+ toJSON() {
1675
+ return {
1676
+ type: "Equation",
1677
+ patterns: this.patterns.map((pattern) => pattern.toJSON()),
1678
+ body: Array.isArray(this.body) ? this.body.map((guard) => guard.toJSON()) : this.body.toJSON(),
1679
+ return: this.returnExpr?.toJSON()
1680
+ };
1681
+ }
1682
+ };
1683
+ Function = class extends ASTNode {
1684
+ /** @hidden */
1685
+ equations;
1686
+ /** @hidden */
1687
+ identifier;
1688
+ constructor(identifier, equations, loc) {
1689
+ super(loc);
1690
+ this.identifier = identifier;
1691
+ this.equations = equations;
1692
+ }
1693
+ accept(visitor) {
1694
+ return this.dispatchVisit(visitor, visitor.visitFunction);
1695
+ }
1696
+ toJSON() {
1697
+ return {
1698
+ type: "Function",
1699
+ identifier: this.identifier.toJSON(),
1700
+ equations: this.equations.map((eq) => eq.toJSON())
1701
+ };
1702
+ }
1703
+ };
1704
+ Case = class extends ASTNode {
1705
+ /** @hidden */
1706
+ body;
1707
+ /** @hidden */
1708
+ condition;
1709
+ constructor(condition, body, loc) {
1710
+ super(loc);
1711
+ this.condition = condition;
1712
+ this.body = body;
1713
+ }
1714
+ accept(visitor) {
1715
+ return this.dispatchVisit(visitor, visitor.visitCase);
1716
+ }
1717
+ toJSON() {
1718
+ return {
1719
+ type: "Case",
1720
+ condition: this.condition.toJSON(),
1721
+ body: this.body.toJSON()
1722
+ };
1723
+ }
1724
+ };
1725
+ Switch = class extends ASTNode {
1726
+ /** @hidden */
1727
+ defaultExpr;
1728
+ /** @hidden */
1729
+ cases;
1730
+ /** @hidden */
1731
+ value;
1732
+ constructor(value, cases, defaultExpr, loc) {
1733
+ super(loc);
1734
+ this.value = value;
1735
+ this.cases = cases;
1736
+ this.defaultExpr = defaultExpr;
1737
+ }
1738
+ accept(visitor) {
1739
+ return this.dispatchVisit(visitor, visitor.visitSwitch);
1740
+ }
1741
+ toJSON() {
1742
+ return {
1743
+ type: "Switch",
1744
+ value: this.value.toJSON(),
1745
+ cases: this.cases.map((caseVal) => ({
1746
+ condition: caseVal.condition.toJSON(),
1747
+ body: caseVal.body.toJSON()
1748
+ })),
1749
+ default: this.defaultExpr?.toJSON()
1750
+ };
1751
+ }
1752
+ };
1753
+ Catch = class extends ASTNode {
1754
+ /** @hidden */
1755
+ body;
1756
+ /** @hidden */
1757
+ patterns;
1758
+ constructor(patterns, body, loc) {
1759
+ super(loc);
1760
+ this.patterns = patterns;
1761
+ this.body = body;
1762
+ }
1763
+ accept(visitor) {
1764
+ return this.dispatchVisit(visitor, visitor.visitCatch);
1765
+ }
1766
+ toJSON() {
1767
+ return {
1768
+ type: "Catch",
1769
+ patterns: this.patterns.map((pat) => pat.toJSON()),
1770
+ body: this.body.toJSON()
1771
+ };
1772
+ }
1773
+ };
1774
+ Try = class extends ASTNode {
1775
+ /** @hidden */
1776
+ finallyExpr;
1777
+ /** @hidden */
1778
+ catchExpr;
1779
+ /** @hidden */
1780
+ body;
1781
+ constructor(body, catchExpr, finallyExpr, loc) {
1782
+ super(loc);
1783
+ this.body = body;
1784
+ this.catchExpr = catchExpr;
1785
+ this.finallyExpr = finallyExpr;
1786
+ }
1787
+ accept(visitor) {
1788
+ return this.dispatchVisit(visitor, visitor.visitTry);
1789
+ }
1790
+ toJSON() {
1791
+ return {
1792
+ type: "Try",
1793
+ body: this.body.toJSON(),
1794
+ catch: this.catchExpr.map(({ patterns, body }) => ({
1795
+ condition: patterns.map((pattern) => pattern.toJSON()),
1796
+ body: body.toJSON()
1797
+ })),
1798
+ finally: this.finallyExpr.toJSON()
1799
+ };
1800
+ }
1801
+ };
1802
+ Raise = class extends ASTNode {
1803
+ /** @hidden */
1804
+ body;
1805
+ constructor(body, loc) {
1806
+ super(loc);
1807
+ this.body = body;
1808
+ }
1809
+ accept(visitor) {
1810
+ return this.dispatchVisit(visitor, visitor.visitRaise);
1811
+ }
1812
+ toJSON() {
1813
+ return {
1814
+ type: "Raise",
1815
+ body: this.body.toJSON()
1816
+ };
1817
+ }
1818
+ };
1819
+ Print = class extends ASTNode {
1820
+ /** @hidden */
1821
+ expression;
1822
+ constructor(expression, loc) {
1823
+ super(loc);
1824
+ this.expression = expression;
1825
+ }
1826
+ accept(visitor) {
1827
+ return this.dispatchVisit(visitor, visitor.visitPrint);
1828
+ }
1829
+ toJSON() {
1830
+ return {
1831
+ type: "Print",
1832
+ expression: this.expression.toJSON()
1833
+ };
1834
+ }
1835
+ };
1836
+ Input = class extends ASTNode {
1837
+ /** @hidden */
1838
+ variable;
1839
+ /** @hidden */
1840
+ message;
1841
+ constructor(message, variable2, loc) {
1842
+ super(loc);
1843
+ this.message = message;
1844
+ this.variable = variable2;
1845
+ }
1846
+ accept(visitor) {
1847
+ return this.dispatchVisit(visitor, visitor.visitInput);
1848
+ }
1849
+ toJSON() {
1850
+ return {
1851
+ type: "Input",
1852
+ message: this.message.toJSON(),
1853
+ variable: this.variable.toJSON()
1854
+ };
1855
+ }
1856
+ };
1857
+ For = class extends ASTNode {
1858
+ /** @hidden */
1859
+ statements;
1860
+ /** @hidden */
1861
+ body;
1862
+ constructor(body, statements, loc) {
1863
+ super(loc);
1864
+ this.body = body;
1865
+ this.statements = statements;
1866
+ }
1867
+ accept(visitor) {
1868
+ return this.dispatchVisit(visitor, visitor.visitFor);
1869
+ }
1870
+ toJSON() {
1871
+ return {
1872
+ type: "For",
1873
+ body: this.body.toJSON(),
1874
+ statements: this.statements.map((stmt) => stmt.toJSON())
1875
+ };
1876
+ }
1877
+ };
1878
+ Break = class extends ASTNode {
1879
+ /** @hidden */
1880
+ body;
1881
+ constructor(body = new NilPrimitive(null), loc) {
1882
+ super(loc);
1883
+ this.body = body;
1884
+ }
1885
+ accept(visitor) {
1886
+ return this.dispatchVisit(visitor, visitor.visitBreak);
1887
+ }
1888
+ toJSON() {
1889
+ return {
1890
+ type: "Break",
1891
+ body: this.body?.toJSON()
1892
+ };
1893
+ }
1894
+ };
1895
+ Continue = class extends ASTNode {
1896
+ /** @hidden */
1897
+ body;
1898
+ constructor(body = new NilPrimitive(null), loc) {
1899
+ super(loc);
1900
+ this.body = body;
1901
+ }
1902
+ accept(visitor) {
1903
+ return this.dispatchVisit(visitor, visitor.visitContinue);
1904
+ }
1905
+ toJSON() {
1906
+ return {
1907
+ type: "Continue",
1908
+ body: this.body?.toJSON()
1909
+ };
1910
+ }
1911
+ };
1912
+ Variable = class extends ASTNode {
1913
+ /** @hidden */
1914
+ variableType;
1915
+ /** @hidden */
1916
+ expression;
1917
+ /** @hidden */
1918
+ identifier;
1919
+ constructor(identifier, expression, variableType, loc) {
1920
+ super(loc);
1921
+ this.identifier = identifier;
1922
+ this.expression = expression;
1923
+ this.variableType = variableType;
1924
+ }
1925
+ accept(visitor) {
1926
+ return this.dispatchVisit(visitor, visitor.visitVariable);
1927
+ }
1928
+ toJSON() {
1929
+ return {
1930
+ type: "Variable",
1931
+ identifier: this.identifier.toJSON(),
1932
+ expression: this.expression.toJSON(),
1933
+ variableType: this.variableType?.toJSON()
1934
+ };
1935
+ }
1936
+ };
1937
+ Assignment = class extends ASTNode {
1938
+ /** @hidden */
1939
+ expression;
1940
+ /** @hidden */
1941
+ identifier;
1942
+ constructor(identifier, expression, loc) {
1943
+ super(loc);
1944
+ this.identifier = identifier;
1945
+ this.expression = expression;
1946
+ }
1947
+ accept(visitor) {
1948
+ return this.dispatchVisit(visitor, visitor.visitAssignment);
1949
+ }
1950
+ toJSON() {
1951
+ return {
1952
+ type: "Assignment",
1953
+ identifier: this.identifier.toJSON(),
1954
+ expression: this.expression.toJSON()
1955
+ };
1956
+ }
1957
+ };
1958
+ Sequence = class extends ASTNode {
1959
+ /** @hidden */
1960
+ statements;
1961
+ constructor(statements, loc) {
1962
+ super(loc);
1963
+ this.statements = statements;
1964
+ }
1965
+ accept(visitor) {
1966
+ return this.dispatchVisit(visitor, visitor.visitSequence);
1967
+ }
1968
+ toJSON() {
1969
+ return {
1970
+ type: "Sequence",
1971
+ statements: this.statements.map((stmt) => stmt.toJSON())
1972
+ };
1973
+ }
1974
+ };
1975
+ }
1976
+ });
1977
+
1978
+ // ../yukigo-ast/dist/globals/operators.js
1979
+ var ArithmeticUnaryOperation, ArithmeticBinaryOperation, ListUnaryOperation, ListBinaryOperation, ComparisonOperation, LogicalBinaryOperation, LogicalUnaryOperation, BitwiseBinaryOperation, BitwiseUnaryOperation, StringOperation, UnifyOperation, AssignOperation;
1980
+ var init_operators = __esm({
1981
+ "../yukigo-ast/dist/globals/operators.js"() {
1982
+ init_generics();
1983
+ ArithmeticUnaryOperation = class extends ASTNode {
1984
+ /** @hidden */
1985
+ operand;
1986
+ /** @hidden */
1987
+ operator;
1988
+ constructor(operator, operand, loc) {
1989
+ super(loc);
1990
+ this.operator = operator;
1991
+ this.operand = operand;
1992
+ }
1993
+ accept(visitor) {
1994
+ return this.dispatchVisit(visitor, visitor.visitArithmeticUnaryOperation);
1995
+ }
1996
+ toJSON() {
1997
+ return {
1998
+ type: "ArithmeticUnaryOperation",
1999
+ operator: this.operator,
2000
+ operand: this.operand
2001
+ };
2002
+ }
2003
+ };
2004
+ ArithmeticBinaryOperation = class extends ASTNode {
2005
+ /** @hidden */
2006
+ right;
2007
+ /** @hidden */
2008
+ left;
2009
+ /** @hidden */
2010
+ operator;
2011
+ constructor(operator, left, right, loc) {
2012
+ super(loc);
2013
+ this.operator = operator;
2014
+ this.left = left;
2015
+ this.right = right;
2016
+ }
2017
+ accept(visitor) {
2018
+ return this.dispatchVisit(visitor, visitor.visitArithmeticBinaryOperation);
2019
+ }
2020
+ toJSON() {
2021
+ return {
2022
+ type: "ArithmeticBinaryOperation",
2023
+ operator: this.operator,
2024
+ left: this.left,
2025
+ right: this.right
2026
+ };
2027
+ }
2028
+ };
2029
+ ListUnaryOperation = class extends ASTNode {
2030
+ /** @hidden */
2031
+ operand;
2032
+ /** @hidden */
2033
+ operator;
2034
+ constructor(operator, operand, loc) {
2035
+ super(loc);
2036
+ this.operator = operator;
2037
+ this.operand = operand;
2038
+ }
2039
+ accept(visitor) {
2040
+ return this.dispatchVisit(visitor, visitor.visitListUnaryOperation);
2041
+ }
2042
+ toJSON() {
2043
+ return {
2044
+ type: "ListUnaryOperation",
2045
+ operator: this.operator,
2046
+ operand: this.operand
2047
+ };
2048
+ }
2049
+ };
2050
+ ListBinaryOperation = class extends ASTNode {
2051
+ /** @hidden */
2052
+ right;
2053
+ /** @hidden */
2054
+ left;
2055
+ /** @hidden */
2056
+ operator;
2057
+ constructor(operator, left, right, loc) {
2058
+ super(loc);
2059
+ this.operator = operator;
2060
+ this.left = left;
2061
+ this.right = right;
2062
+ }
2063
+ accept(visitor) {
2064
+ return this.dispatchVisit(visitor, visitor.visitListBinaryOperation);
2065
+ }
2066
+ toJSON() {
2067
+ return {
2068
+ type: "ListBinaryOperation",
2069
+ operator: this.operator,
2070
+ left: this.left,
2071
+ right: this.right
2072
+ };
2073
+ }
2074
+ };
2075
+ ComparisonOperation = class extends ASTNode {
2076
+ /** @hidden */
2077
+ right;
2078
+ /** @hidden */
2079
+ left;
2080
+ /** @hidden */
2081
+ operator;
2082
+ constructor(operator, left, right, loc) {
2083
+ super(loc);
2084
+ this.operator = operator;
2085
+ this.left = left;
2086
+ this.right = right;
2087
+ }
2088
+ accept(visitor) {
2089
+ return this.dispatchVisit(visitor, visitor.visitComparisonOperation);
2090
+ }
2091
+ toJSON() {
2092
+ return {
2093
+ type: "ComparisonOperation",
2094
+ operator: this.operator,
2095
+ left: this.left,
2096
+ right: this.right
2097
+ };
2098
+ }
2099
+ };
2100
+ LogicalBinaryOperation = class extends ASTNode {
2101
+ /** @hidden */
2102
+ right;
2103
+ /** @hidden */
2104
+ left;
2105
+ /** @hidden */
2106
+ operator;
2107
+ constructor(operator, left, right, loc) {
2108
+ super(loc);
2109
+ this.operator = operator;
2110
+ this.left = left;
2111
+ this.right = right;
2112
+ }
2113
+ accept(visitor) {
2114
+ return this.dispatchVisit(visitor, visitor.visitLogicalBinaryOperation);
2115
+ }
2116
+ toJSON() {
2117
+ return {
2118
+ type: "LogicalBinaryOperation",
2119
+ operator: this.operator,
2120
+ left: this.left,
2121
+ right: this.right
2122
+ };
2123
+ }
2124
+ };
2125
+ LogicalUnaryOperation = class extends ASTNode {
2126
+ /** @hidden */
2127
+ operand;
2128
+ /** @hidden */
2129
+ operator;
2130
+ constructor(operator, operand, loc) {
2131
+ super(loc);
2132
+ this.operator = operator;
2133
+ this.operand = operand;
2134
+ }
2135
+ accept(visitor) {
2136
+ return this.dispatchVisit(visitor, visitor.visitLogicalUnaryOperation);
2137
+ }
2138
+ toJSON() {
2139
+ return {
2140
+ type: "LogicalUnaryOperation",
2141
+ operator: this.operator,
2142
+ operand: this.operand
2143
+ };
2144
+ }
2145
+ };
2146
+ BitwiseBinaryOperation = class extends ASTNode {
2147
+ /** @hidden */
2148
+ right;
2149
+ /** @hidden */
2150
+ left;
2151
+ /** @hidden */
2152
+ operator;
2153
+ constructor(operator, left, right, loc) {
2154
+ super(loc);
2155
+ this.operator = operator;
2156
+ this.left = left;
2157
+ this.right = right;
2158
+ }
2159
+ accept(visitor) {
2160
+ return this.dispatchVisit(visitor, visitor.visitBitwiseBinaryOperation);
2161
+ }
2162
+ toJSON() {
2163
+ return {
2164
+ type: "BitwiseBinaryOperation",
2165
+ operator: this.operator,
2166
+ left: this.left,
2167
+ right: this.right
2168
+ };
2169
+ }
2170
+ };
2171
+ BitwiseUnaryOperation = class extends ASTNode {
2172
+ /** @hidden */
2173
+ operand;
2174
+ /** @hidden */
2175
+ operator;
2176
+ constructor(operator, operand, loc) {
2177
+ super(loc);
2178
+ this.operator = operator;
2179
+ this.operand = operand;
2180
+ }
2181
+ accept(visitor) {
2182
+ return this.dispatchVisit(visitor, visitor.visitBitwiseUnaryOperation);
2183
+ }
2184
+ toJSON() {
2185
+ return {
2186
+ type: "BitwiseUnaryOperation",
2187
+ operator: this.operator,
2188
+ operand: this.operand
2189
+ };
2190
+ }
2191
+ };
2192
+ StringOperation = class extends ASTNode {
2193
+ /** @hidden */
2194
+ right;
2195
+ /** @hidden */
2196
+ left;
2197
+ /** @hidden */
2198
+ operator;
2199
+ constructor(operator, left, right, loc) {
2200
+ super(loc);
2201
+ this.operator = operator;
2202
+ this.left = left;
2203
+ this.right = right;
2204
+ }
2205
+ accept(visitor) {
2206
+ return this.dispatchVisit(visitor, visitor.visitStringOperation);
2207
+ }
2208
+ toJSON() {
2209
+ return {
2210
+ type: "StringOperation",
2211
+ operator: this.operator,
2212
+ left: this.left,
2213
+ right: this.right
2214
+ };
2215
+ }
2216
+ };
2217
+ UnifyOperation = class extends ASTNode {
2218
+ /** @hidden */
2219
+ right;
2220
+ /** @hidden */
2221
+ left;
2222
+ /** @hidden */
2223
+ operator;
2224
+ constructor(operator, left, right, loc) {
2225
+ super(loc);
2226
+ this.operator = operator;
2227
+ this.left = left;
2228
+ this.right = right;
2229
+ }
2230
+ accept(visitor) {
2231
+ return this.dispatchVisit(visitor, visitor.visitUnifyOperation);
2232
+ }
2233
+ toJSON() {
2234
+ return {
2235
+ type: "UnifyOperation",
2236
+ operator: this.operator,
2237
+ left: this.left,
2238
+ right: this.right
2239
+ };
2240
+ }
2241
+ };
2242
+ AssignOperation = class extends ASTNode {
2243
+ /** @hidden */
2244
+ right;
2245
+ /** @hidden */
2246
+ left;
2247
+ /** @hidden */
2248
+ operator;
2249
+ constructor(operator, left, right, loc) {
2250
+ super(loc);
2251
+ this.operator = operator;
2252
+ this.left = left;
2253
+ this.right = right;
2254
+ }
2255
+ accept(visitor) {
2256
+ return this.dispatchVisit(visitor, visitor.visitAssignOperation);
2257
+ }
2258
+ toJSON() {
2259
+ return {
2260
+ type: "AssignOperation",
2261
+ operator: this.operator,
2262
+ left: this.left,
2263
+ right: this.right
2264
+ };
2265
+ }
2266
+ };
2267
+ }
2268
+ });
2269
+
2270
+ // ../yukigo-ast/dist/globals/patterns.js
2271
+ function isPattern(node) {
2272
+ return node instanceof BasePattern;
2273
+ }
2274
+ var BasePattern, NamedPattern, ArgsPattern, ListBasedPattern, BinaryPattern, VariablePattern, LiteralPattern, ApplicationPattern, TuplePattern, ListPattern, FunctorPattern, AsPattern, WildcardPattern, UnionPattern, ConstructorPattern, ConsPattern, TypePattern;
2275
+ var init_patterns = __esm({
2276
+ "../yukigo-ast/dist/globals/patterns.js"() {
2277
+ init_generics();
2278
+ BasePattern = class extends ASTNode {
2279
+ constructor(loc) {
2280
+ super(loc);
2281
+ }
2282
+ };
2283
+ NamedPattern = class extends BasePattern {
2284
+ name;
2285
+ constructor(name, loc) {
2286
+ super(loc);
2287
+ this.name = name;
2288
+ }
2289
+ toJSON() {
2290
+ return {
2291
+ type: this.jsonType,
2292
+ name: this.name.toJSON()
2293
+ };
2294
+ }
2295
+ };
2296
+ ArgsPattern = class extends BasePattern {
2297
+ /** @hidden */
2298
+ identifier;
2299
+ /** @hidden */
2300
+ args;
2301
+ constructor(identifier, args, loc) {
2302
+ super(loc);
2303
+ this.identifier = identifier;
2304
+ this.args = args;
2305
+ }
2306
+ toJSON() {
2307
+ return {
2308
+ type: this.jsonType,
2309
+ identifier: this.identifier.toJSON(),
2310
+ args: this.args.map((arg) => arg.toJSON())
2311
+ };
2312
+ }
2313
+ };
2314
+ ListBasedPattern = class extends BasePattern {
2315
+ /** @hidden */
2316
+ elements;
2317
+ constructor(elements, loc) {
2318
+ super(loc);
2319
+ this.elements = elements;
2320
+ }
2321
+ toJSON() {
2322
+ return {
2323
+ type: this.jsonType,
2324
+ elements: this.elements.map((arg) => arg.toJSON())
2325
+ };
2326
+ }
2327
+ };
2328
+ BinaryPattern = class extends BasePattern {
2329
+ /** @hidden */
2330
+ left;
2331
+ /** @hidden */
2332
+ right;
2333
+ constructor(left, right, loc) {
2334
+ super(loc);
2335
+ this.left = left;
2336
+ this.right = right;
2337
+ }
2338
+ toJSON() {
2339
+ return {
2340
+ type: this.jsonType,
2341
+ left: this.left.toJSON(),
2342
+ right: this.right.toJSON()
2343
+ };
2344
+ }
2345
+ };
2346
+ VariablePattern = class extends NamedPattern {
2347
+ get jsonType() {
2348
+ return "VariablePattern";
2349
+ }
2350
+ constructor(name, loc) {
2351
+ super(name, loc);
2352
+ }
2353
+ accept(visitor) {
2354
+ return this.dispatchVisit(visitor, visitor.visitVariablePattern);
2355
+ }
2356
+ toString() {
2357
+ return this.name.value;
2358
+ }
2359
+ };
2360
+ LiteralPattern = class extends NamedPattern {
2361
+ get jsonType() {
2362
+ return "LiteralPattern";
2363
+ }
2364
+ constructor(name, loc) {
2365
+ super(name, loc);
2366
+ }
2367
+ accept(visitor) {
2368
+ return this.dispatchVisit(visitor, visitor.visitLiteralPattern);
2369
+ }
2370
+ toString() {
2371
+ const { name } = this;
2372
+ return String(name.value);
2373
+ }
2374
+ };
2375
+ ApplicationPattern = class extends ArgsPattern {
2376
+ get jsonType() {
2377
+ return "ApplicationPattern";
2378
+ }
2379
+ constructor(symbol, args, loc) {
2380
+ super(symbol, args, loc);
2381
+ }
2382
+ accept(visitor) {
2383
+ return this.dispatchVisit(visitor, visitor.visitApplicationPattern);
2384
+ }
2385
+ toString() {
2386
+ const constr = this.identifier.value;
2387
+ const args = this.args.map((pat) => pat.toString()).join(" ");
2388
+ return `${constr} ${args}`;
2389
+ }
2390
+ };
2391
+ TuplePattern = class extends ListBasedPattern {
2392
+ get jsonType() {
2393
+ return "TuplePattern";
2394
+ }
2395
+ constructor(elements, loc) {
2396
+ super(elements, loc);
2397
+ }
2398
+ accept(visitor) {
2399
+ return this.dispatchVisit(visitor, visitor.visitTuplePattern);
2400
+ }
2401
+ toString() {
2402
+ return `(${this.elements.map((e) => e.toString()).join(", ")})`;
2403
+ }
2404
+ };
2405
+ ListPattern = class extends ListBasedPattern {
2406
+ get jsonType() {
2407
+ return "ListPattern";
2408
+ }
2409
+ constructor(elements, loc) {
2410
+ super(elements, loc);
2411
+ }
2412
+ accept(visitor) {
2413
+ return this.dispatchVisit(visitor, visitor.visitListPattern);
2414
+ }
2415
+ toString() {
2416
+ const { elements } = this;
2417
+ if (elements.length === 0)
2418
+ return "[]";
2419
+ return `[${this.elements.map((e) => e.toString()).join(", ")}]`;
2420
+ }
2421
+ };
2422
+ FunctorPattern = class extends ArgsPattern {
2423
+ get jsonType() {
2424
+ return "FunctorPattern";
2425
+ }
2426
+ constructor(symbol, args, loc) {
2427
+ super(symbol, args, loc);
2428
+ }
2429
+ accept(visitor) {
2430
+ return this.dispatchVisit(visitor, visitor.visitFunctorPattern);
2431
+ }
2432
+ toString() {
2433
+ const constr = this.identifier.value;
2434
+ const args = this.args.map((pat) => pat.toString()).join(" ");
2435
+ return `${constr} ${args}`;
2436
+ }
2437
+ };
2438
+ AsPattern = class extends BinaryPattern {
2439
+ get jsonType() {
2440
+ return "AsPattern";
2441
+ }
2442
+ constructor(left, right, loc) {
2443
+ super(left, right, loc);
2444
+ }
2445
+ accept(visitor) {
2446
+ return this.dispatchVisit(visitor, visitor.visitAsPattern);
2447
+ }
2448
+ toString() {
2449
+ const alias = this.left.toString();
2450
+ const pattern = this.right.toString();
2451
+ return `${alias}@${pattern}`;
2452
+ }
2453
+ };
2454
+ WildcardPattern = class extends BasePattern {
2455
+ get jsonType() {
2456
+ return "WildcardPattern";
2457
+ }
2458
+ accept(visitor) {
2459
+ return this.dispatchVisit(visitor, visitor.visitWildcardPattern);
2460
+ }
2461
+ toJSON() {
2462
+ return {
2463
+ type: "WildcardPattern",
2464
+ name: "_"
2465
+ };
2466
+ }
2467
+ toString() {
2468
+ return "_";
2469
+ }
2470
+ };
2471
+ UnionPattern = class extends ListBasedPattern {
2472
+ get jsonType() {
2473
+ return "UnionPattern";
2474
+ }
2475
+ constructor(patterns, loc) {
2476
+ super(patterns, loc);
2477
+ }
2478
+ accept(visitor) {
2479
+ return this.dispatchVisit(visitor, visitor.visitUnionPattern);
2480
+ }
2481
+ toString() {
2482
+ const inner = this.elements.map((pat) => pat.toString()).join(" | ");
2483
+ return `(${inner})`;
2484
+ }
2485
+ };
2486
+ ConstructorPattern = class extends ArgsPattern {
2487
+ get jsonType() {
2488
+ return "ConstructorPattern";
2489
+ }
2490
+ constructor(symbol, args, loc) {
2491
+ super(symbol, args, loc);
2492
+ }
2493
+ accept(visitor) {
2494
+ return this.dispatchVisit(visitor, visitor.visitConstructorPattern);
2495
+ }
2496
+ toString() {
2497
+ const constr = this.identifier.value;
2498
+ const args = this.args.map((pat) => pat.toString()).join(" ");
2499
+ return `${constr} ${args}`;
2500
+ }
2501
+ };
2502
+ ConsPattern = class extends BinaryPattern {
2503
+ get jsonType() {
2504
+ return "ConsPattern";
2505
+ }
2506
+ constructor(left, right, loc) {
2507
+ super(left, right, loc);
2508
+ }
2509
+ accept(visitor) {
2510
+ return this.dispatchVisit(visitor, visitor.visitConsPattern);
2511
+ }
2512
+ toString() {
2513
+ const head = this.left.toString();
2514
+ const tail = this.right.toString();
2515
+ return `(${head}:${tail})`;
2516
+ }
2517
+ };
2518
+ TypePattern = class extends BasePattern {
2519
+ get jsonType() {
2520
+ return "TypePattern";
2521
+ }
2522
+ /** @hidden */
2523
+ targetType;
2524
+ /** @hidden */
2525
+ innerPattern;
2526
+ constructor(targetType, innerPattern, loc) {
2527
+ super(loc);
2528
+ this.targetType = targetType;
2529
+ this.innerPattern = innerPattern;
2530
+ }
2531
+ accept(visitor) {
2532
+ return this.dispatchVisit(visitor, visitor.visitTypePattern);
2533
+ }
2534
+ toJSON() {
2535
+ return {
2536
+ type: "TypePattern",
2537
+ targetType: this.targetType.toJSON(),
2538
+ innerPattern: this.innerPattern?.toJSON()
2539
+ };
2540
+ }
2541
+ toString() {
2542
+ const typeStr = this.targetType.toString();
2543
+ return this.innerPattern ? `(${typeStr} ${this.innerPattern.toString()})` : typeStr;
2544
+ }
2545
+ };
2546
+ }
2547
+ });
2548
+
2549
+ // ../yukigo-ast/dist/globals/types.js
2550
+ var SimpleType, TypeVar, TypeApplication, ListType, TupleType, Constraint, ParameterizedType, ConstrainedType, TypeAlias, TypeSignature, TypeCast;
2551
+ var init_types = __esm({
2552
+ "../yukigo-ast/dist/globals/types.js"() {
2553
+ init_generics();
2554
+ SimpleType = class extends ASTNode {
2555
+ /** @hidden */
2556
+ constraints;
2557
+ /** @hidden */
2558
+ value;
2559
+ constructor(value, constraints, loc) {
2560
+ super(loc);
2561
+ this.value = value;
2562
+ this.constraints = constraints;
2563
+ }
2564
+ accept(visitor) {
2565
+ return this.dispatchVisit(visitor, visitor.visitSimpleType);
2566
+ }
2567
+ toString() {
2568
+ return this.value;
2569
+ }
2570
+ toJSON() {
2571
+ return {
2572
+ type: "SimpleType",
2573
+ value: this.value,
2574
+ constraints: this.constraints.map((c) => c.toJSON())
2575
+ };
2576
+ }
2577
+ };
2578
+ TypeVar = class extends ASTNode {
2579
+ /** @hidden */
2580
+ constraints;
2581
+ /** @hidden */
2582
+ value;
2583
+ constructor(value, constraints, loc) {
2584
+ super(loc);
2585
+ this.value = value;
2586
+ this.constraints = constraints;
2587
+ }
2588
+ accept(visitor) {
2589
+ return this.dispatchVisit(visitor, visitor.visitTypeVar);
2590
+ }
2591
+ toString() {
2592
+ return this.value;
2593
+ }
2594
+ toJSON() {
2595
+ return {
2596
+ type: "TypeVar",
2597
+ value: this.value,
2598
+ constraints: this.constraints.map((c) => c.toJSON())
2599
+ };
2600
+ }
2601
+ };
2602
+ TypeApplication = class _TypeApplication extends ASTNode {
2603
+ /** @hidden */
2604
+ argument;
2605
+ /** @hidden */
2606
+ functionType;
2607
+ constructor(functionType, argument, loc) {
2608
+ super(loc);
2609
+ this.functionType = functionType;
2610
+ this.argument = argument;
2611
+ }
2612
+ accept(visitor) {
2613
+ return this.dispatchVisit(visitor, visitor.visitTypeApplication);
2614
+ }
2615
+ toString() {
2616
+ const func = this.functionType.toString();
2617
+ let arg = this.argument.toString();
2618
+ if (this.argument instanceof _TypeApplication || this.argument instanceof ParameterizedType) {
2619
+ arg = `(${arg})`;
2620
+ }
2621
+ return `${func} ${arg}`;
2622
+ }
2623
+ toJSON() {
2624
+ return {
2625
+ type: "TypeApplication",
2626
+ function: this.functionType.toJSON(),
2627
+ argument: this.argument.toJSON()
2628
+ };
2629
+ }
2630
+ };
2631
+ ListType = class extends ASTNode {
2632
+ /** @hidden */
2633
+ constraints;
2634
+ /** @hidden */
2635
+ values;
2636
+ constructor(values, constraints, loc) {
2637
+ super(loc);
2638
+ this.values = values;
2639
+ this.constraints = constraints;
2640
+ }
2641
+ accept(visitor) {
2642
+ return this.dispatchVisit(visitor, visitor.visitListType);
2643
+ }
2644
+ toString() {
2645
+ return `[${this.values.toString()}]`;
2646
+ }
2647
+ toJSON() {
2648
+ return {
2649
+ type: "ListType",
2650
+ values: this.values.toJSON(),
2651
+ constraints: this.constraints.map((c) => c.toJSON())
2652
+ };
2653
+ }
2654
+ };
2655
+ TupleType = class extends ASTNode {
2656
+ /** @hidden */
2657
+ constraints;
2658
+ /** @hidden */
2659
+ values;
2660
+ constructor(values, constraints, loc) {
2661
+ super(loc);
2662
+ this.values = values;
2663
+ this.constraints = constraints;
2664
+ }
2665
+ accept(visitor) {
2666
+ return this.dispatchVisit(visitor, visitor.visitTupleType);
2667
+ }
2668
+ toString() {
2669
+ return `(${this.values.map((t) => t.toString()).join(", ")})`;
2670
+ }
2671
+ toJSON() {
2672
+ return {
2673
+ type: "TupleType",
2674
+ values: this.values.map((val) => val.toJSON()),
2675
+ constraints: this.constraints.map((c) => c.toJSON())
2676
+ };
2677
+ }
2678
+ };
2679
+ Constraint = class extends ASTNode {
2680
+ /** @hidden */
2681
+ parameters;
2682
+ /** @hidden */
2683
+ name;
2684
+ constructor(name, parameters, loc) {
2685
+ super(loc);
2686
+ this.name = name;
2687
+ this.parameters = parameters;
2688
+ }
2689
+ accept(visitor) {
2690
+ return this.dispatchVisit(visitor, visitor.visitConstraint);
2691
+ }
2692
+ toJSON() {
2693
+ return {
2694
+ type: "Constraint",
2695
+ name: this.name,
2696
+ parameters: this.parameters.map((p) => p.toJSON())
2697
+ };
2698
+ }
2699
+ };
2700
+ ParameterizedType = class _ParameterizedType extends ASTNode {
2701
+ /** @hidden */
2702
+ constraints;
2703
+ /** @hidden */
2704
+ returnType;
2705
+ /** @hidden */
2706
+ inputs;
2707
+ constructor(inputs, returnType, constraints, loc) {
2708
+ super(loc);
2709
+ this.inputs = inputs;
2710
+ this.returnType = returnType;
2711
+ this.constraints = constraints;
2712
+ }
2713
+ accept(visitor) {
2714
+ return this.dispatchVisit(visitor, visitor.visitParameterizedType);
2715
+ }
2716
+ toString() {
2717
+ const inputs = this.inputs.map((t) => {
2718
+ const str = t.toString();
2719
+ return t instanceof _ParameterizedType ? `(${str})` : str;
2720
+ });
2721
+ const ret = this.returnType.toString();
2722
+ const signature = [...inputs, ret].join(" -> ");
2723
+ if (this.constraints.length > 0) {
2724
+ const constraints = this.constraints.map((c) => {
2725
+ const params = c.parameters.map((p) => p.toString()).join(" ");
2726
+ return params ? `${c.name} ${params}` : c.name;
2727
+ }).join(", ");
2728
+ const context = this.constraints.length > 1 ? `(${constraints})` : constraints;
2729
+ return `${context} => ${signature}`;
2730
+ }
2731
+ return signature;
2732
+ }
2733
+ toJSON() {
2734
+ return {
2735
+ type: "ParameterizedType",
2736
+ inputs: this.inputs.map((p) => p.toJSON()),
2737
+ return: this.returnType.toJSON(),
2738
+ constraints: this.constraints.map((p) => p.toJSON())
2739
+ };
2740
+ }
2741
+ };
2742
+ ConstrainedType = class extends ASTNode {
2743
+ /** @hidden */
2744
+ constraints;
2745
+ constructor(constraints, loc) {
2746
+ super(loc);
2747
+ this.constraints = constraints;
2748
+ }
2749
+ accept(visitor) {
2750
+ return this.dispatchVisit(visitor, visitor.visitConstrainedType);
2751
+ }
2752
+ toJSON() {
2753
+ return {
2754
+ type: "ConstrainedType",
2755
+ constraints: this.constraints.map((p) => p.toJSON())
2756
+ };
2757
+ }
2758
+ };
2759
+ TypeAlias = class extends ASTNode {
2760
+ /** @hidden */
2761
+ value;
2762
+ /** @hidden */
2763
+ variables;
2764
+ /** @hidden */
2765
+ identifier;
2766
+ constructor(identifier, variables, value, loc) {
2767
+ super(loc);
2768
+ this.identifier = identifier;
2769
+ this.variables = variables;
2770
+ this.value = value;
2771
+ }
2772
+ accept(visitor) {
2773
+ return this.dispatchVisit(visitor, visitor.visitTypeAlias);
2774
+ }
2775
+ toJSON() {
2776
+ return {
2777
+ type: "TypeAlias",
2778
+ identifier: this.identifier.toJSON(),
2779
+ variables: this.variables,
2780
+ value: this.value.toJSON()
2781
+ };
2782
+ }
2783
+ };
2784
+ TypeSignature = class extends ASTNode {
2785
+ /** @hidden */
2786
+ body;
2787
+ /** @hidden */
2788
+ identifier;
2789
+ constructor(identifier, body, loc) {
2790
+ super(loc);
2791
+ this.identifier = identifier;
2792
+ this.body = body;
2793
+ }
2794
+ accept(visitor) {
2795
+ return this.dispatchVisit(visitor, visitor.visitTypeSignature);
2796
+ }
2797
+ toJSON() {
2798
+ return {
2799
+ type: "TypeSignature",
2800
+ identifier: this.identifier.toJSON(),
2801
+ body: this.body.toJSON()
2802
+ };
2803
+ }
2804
+ };
2805
+ TypeCast = class extends ASTNode {
2806
+ /** @hidden */
2807
+ body;
2808
+ /** @hidden */
2809
+ expression;
2810
+ constructor(expression, body, loc) {
2811
+ super(loc);
2812
+ this.expression = expression;
2813
+ this.body = body;
2814
+ }
2815
+ accept(visitor) {
2816
+ return this.dispatchVisit(visitor, visitor.visitTypeCast);
2817
+ }
2818
+ toJSON() {
2819
+ return {
2820
+ type: "TypeCast",
2821
+ expression: this.expression.toJSON(),
2822
+ body: this.body.toJSON()
2823
+ };
2824
+ }
2825
+ };
2826
+ }
2827
+ });
2828
+
2829
+ // ../yukigo-ast/dist/globals/testing.js
2830
+ var TestGroup, Test, Assert, Truth, Equality, Failure;
2831
+ var init_testing = __esm({
2832
+ "../yukigo-ast/dist/globals/testing.js"() {
2833
+ init_generics();
2834
+ TestGroup = class extends ASTNode {
2835
+ name;
2836
+ group;
2837
+ constructor(name, group, loc) {
2838
+ super(loc);
2839
+ this.name = name;
2840
+ this.group = group;
2841
+ }
2842
+ accept(visitor) {
2843
+ return this.dispatchVisit(visitor, visitor.visitTestGroup);
2844
+ }
2845
+ toJSON() {
2846
+ return {
2847
+ type: "TestGroup",
2848
+ name: this.name,
2849
+ group: this.group
2850
+ };
2851
+ }
2852
+ };
2853
+ Test = class extends ASTNode {
2854
+ name;
2855
+ body;
2856
+ args;
2857
+ constructor(name, body, args = [], loc) {
2858
+ super(loc);
2859
+ this.name = name;
2860
+ this.body = body;
2861
+ this.args = args;
2862
+ }
2863
+ accept(visitor) {
2864
+ return this.dispatchVisit(visitor, visitor.visitTest);
2865
+ }
2866
+ toJSON() {
2867
+ return {
2868
+ type: "Test",
2869
+ name: this.name,
2870
+ body: this.body,
2871
+ args: this.args
2872
+ };
2873
+ }
2874
+ };
2875
+ Assert = class extends ASTNode {
2876
+ negated;
2877
+ body;
2878
+ constructor(negated, body, loc) {
2879
+ super(loc);
2880
+ this.negated = negated;
2881
+ this.body = body;
2882
+ }
2883
+ accept(visitor) {
2884
+ return this.dispatchVisit(visitor, visitor.visitAssert);
2885
+ }
2886
+ toJSON() {
2887
+ return {
2888
+ type: "Assert",
2889
+ negated: this.negated,
2890
+ body: this.body
2891
+ };
2892
+ }
2893
+ };
2894
+ Truth = class extends ASTNode {
2895
+ body;
2896
+ constructor(body, loc) {
2897
+ super(loc);
2898
+ this.body = body;
2899
+ }
2900
+ accept(visitor) {
2901
+ return this.dispatchVisit(visitor, visitor.visitTruth);
2902
+ }
2903
+ toJSON() {
2904
+ return {
2905
+ type: "Truth",
2906
+ body: this.body
2907
+ };
2908
+ }
2909
+ };
2910
+ Equality = class extends ASTNode {
2911
+ expected;
2912
+ value;
2913
+ constructor(expected, value, loc) {
2914
+ super(loc);
2915
+ this.expected = expected;
2916
+ this.value = value;
2917
+ }
2918
+ accept(visitor) {
2919
+ return this.dispatchVisit(visitor, visitor.visitEquality);
2920
+ }
2921
+ toJSON() {
2922
+ return {
2923
+ type: "Equality",
2924
+ expected: this.expected,
2925
+ value: this.value
2926
+ };
2927
+ }
2928
+ };
2929
+ Failure = class extends ASTNode {
2930
+ func;
2931
+ message;
2932
+ constructor(func, message, loc) {
2933
+ super(loc);
2934
+ this.func = func;
2935
+ this.message = message;
2936
+ }
2937
+ accept(visitor) {
2938
+ return this.dispatchVisit(visitor, visitor.visitFailure);
2939
+ }
2940
+ toJSON() {
2941
+ return {
2942
+ type: "Failure",
2943
+ func: this.func,
2944
+ message: this.message
2945
+ };
2946
+ }
2947
+ };
2948
+ }
2949
+ });
2950
+
2951
+ // ../yukigo-ast/dist/paradigms/functional.js
2952
+ var CompositionExpression, Lambda, Yield, Application;
2953
+ var init_functional = __esm({
2954
+ "../yukigo-ast/dist/paradigms/functional.js"() {
2955
+ init_generics();
2956
+ CompositionExpression = class extends ASTNode {
2957
+ /** @hidden */
2958
+ right;
2959
+ /** @hidden */
2960
+ left;
2961
+ constructor(left, right, loc) {
2962
+ super(loc);
2963
+ this.left = left;
2964
+ this.right = right;
2965
+ }
2966
+ accept(visitor) {
2967
+ return this.dispatchVisit(visitor, visitor.visitCompositionExpression);
2968
+ }
2969
+ toJSON() {
2970
+ return {
2971
+ type: "CompositionExpression",
2972
+ left: this.left.toJSON(),
2973
+ right: this.right.toJSON()
2974
+ };
2975
+ }
2976
+ };
2977
+ Lambda = class extends ASTNode {
2978
+ /** @hidden */
2979
+ body;
2980
+ /** @hidden */
2981
+ parameters;
2982
+ constructor(parameters, body, loc) {
2983
+ super(loc);
2984
+ this.parameters = parameters;
2985
+ this.body = body;
2986
+ }
2987
+ accept(visitor) {
2988
+ return this.dispatchVisit(visitor, visitor.visitLambda);
2989
+ }
2990
+ toJSON() {
2991
+ return {
2992
+ type: "Lambda",
2993
+ body: this.body.toJSON(),
2994
+ parameters: this.parameters.map((p) => p.toJSON())
2995
+ };
2996
+ }
2997
+ };
2998
+ Yield = class extends ASTNode {
2999
+ /** @hidden */
3000
+ expression;
3001
+ constructor(expression, loc) {
3002
+ super(loc);
3003
+ this.expression = expression;
3004
+ }
3005
+ accept(visitor) {
3006
+ return this.dispatchVisit(visitor, visitor.visitYield);
3007
+ }
3008
+ toJSON() {
3009
+ return {
3010
+ type: "Yield",
3011
+ expression: this.expression.toJSON()
3012
+ };
3013
+ }
3014
+ };
3015
+ Application = class extends ASTNode {
3016
+ /** @hidden */
3017
+ parameter;
3018
+ /** @hidden */
3019
+ functionExpr;
3020
+ constructor(functionExpr, parameter, loc) {
3021
+ super(loc);
3022
+ this.functionExpr = functionExpr;
3023
+ this.parameter = parameter;
3024
+ }
3025
+ accept(visitor) {
3026
+ return this.dispatchVisit(visitor, visitor.visitApplication);
3027
+ }
3028
+ toJSON() {
3029
+ return {
3030
+ type: "Application",
3031
+ function: this.functionExpr.toJSON(),
3032
+ parameter: this.parameter.toJSON()
3033
+ };
3034
+ }
3035
+ };
3036
+ }
3037
+ });
3038
+
3039
+ // ../yukigo-ast/dist/paradigms/object.js
3040
+ var Method, Attribute, Object2, Class, Interface, Send, New, Implement, Self, Super, PrimitiveMethod;
3041
+ var init_object = __esm({
3042
+ "../yukigo-ast/dist/paradigms/object.js"() {
3043
+ init_generics();
3044
+ Method = class extends ASTNode {
3045
+ /** @hidden */
3046
+ equations;
3047
+ /** @hidden */
3048
+ identifier;
3049
+ /** @hidden */
3050
+ isAbstract;
3051
+ constructor(identifier, equations, loc, isAbstract = false) {
3052
+ super(loc);
3053
+ this.identifier = identifier;
3054
+ this.equations = equations;
3055
+ this.isAbstract = isAbstract;
3056
+ }
3057
+ accept(visitor) {
3058
+ return this.dispatchVisit(visitor, visitor.visitMethod);
3059
+ }
3060
+ toJSON() {
3061
+ return {
3062
+ type: "Method",
3063
+ identifier: this.identifier.toJSON(),
3064
+ equations: this.equations.map((eq) => eq.toJSON())
3065
+ };
3066
+ }
3067
+ };
3068
+ Attribute = class extends ASTNode {
3069
+ /** @hidden */
3070
+ expression;
3071
+ /** @hidden */
3072
+ identifier;
3073
+ constructor(identifier, expression, loc) {
3074
+ super(loc);
3075
+ this.identifier = identifier;
3076
+ this.expression = expression;
3077
+ }
3078
+ accept(visitor) {
3079
+ return this.dispatchVisit(visitor, visitor.visitAttribute);
3080
+ }
3081
+ toJSON() {
3082
+ return {
3083
+ type: "Attribute",
3084
+ identifier: this.identifier.toJSON(),
3085
+ expression: this.expression.toJSON()
3086
+ };
3087
+ }
3088
+ };
3089
+ Object2 = class extends ASTNode {
3090
+ /** @hidden */
3091
+ expression;
3092
+ /** @hidden */
3093
+ identifier;
3094
+ /** @hidden */
3095
+ extendsSymbol;
3096
+ /** @hidden */
3097
+ extendsArgs;
3098
+ constructor(identifier, expression, loc) {
3099
+ super(loc);
3100
+ this.identifier = identifier;
3101
+ this.expression = expression;
3102
+ }
3103
+ accept(visitor) {
3104
+ return this.dispatchVisit(visitor, visitor.visitObject);
3105
+ }
3106
+ toJSON() {
3107
+ return {
3108
+ type: "Object",
3109
+ identifier: this.identifier.toJSON(),
3110
+ expression: this.expression.toJSON(),
3111
+ extendsSymbol: this.extendsSymbol ? this.extendsSymbol.toJSON() : void 0,
3112
+ extendsArgs: this.extendsArgs ? this.extendsArgs.map((a) => a.toJSON()) : void 0
3113
+ };
3114
+ }
3115
+ };
3116
+ Class = class extends ASTNode {
3117
+ /** @hidden */
3118
+ expression;
3119
+ /** @hidden */
3120
+ implementsNode;
3121
+ /** @hidden */
3122
+ extendsSymbol;
3123
+ /** @hidden */
3124
+ identifier;
3125
+ /** @hidden */
3126
+ includes;
3127
+ constructor(identifier, extendsSymbol, implementsNode, includes, expression, loc) {
3128
+ super(loc);
3129
+ this.identifier = identifier;
3130
+ this.extendsSymbol = extendsSymbol;
3131
+ this.implementsNode = implementsNode;
3132
+ this.includes = includes;
3133
+ this.expression = expression;
3134
+ }
3135
+ accept(visitor) {
3136
+ return this.dispatchVisit(visitor, visitor.visitClass);
3137
+ }
3138
+ toJSON() {
3139
+ return {
3140
+ type: "Class",
3141
+ identifier: this.identifier.toJSON(),
3142
+ extends: this.extendsSymbol?.toJSON(),
3143
+ implements: this.implementsNode?.toJSON(),
3144
+ includes: this.includes.map((s) => s.toJSON()),
3145
+ expression: this.expression.toJSON()
3146
+ };
3147
+ }
3148
+ };
3149
+ Interface = class extends ASTNode {
3150
+ /** @hidden */
3151
+ expression;
3152
+ /** @hidden */
3153
+ extendsSymbol;
3154
+ /** @hidden */
3155
+ identifier;
3156
+ constructor(identifier, extendsSymbol, expression, loc) {
3157
+ super(loc);
3158
+ this.identifier = identifier;
3159
+ this.extendsSymbol = extendsSymbol;
3160
+ this.expression = expression;
3161
+ }
3162
+ accept(visitor) {
3163
+ return this.dispatchVisit(visitor, visitor.visitInterface);
3164
+ }
3165
+ toJSON() {
3166
+ return {
3167
+ type: "Interface",
3168
+ identifier: this.identifier.toJSON(),
3169
+ extends: this.extendsSymbol.map((symbol) => symbol.toJSON()),
3170
+ expression: this.expression.toJSON()
3171
+ };
3172
+ }
3173
+ };
3174
+ Send = class extends ASTNode {
3175
+ /** @hidden */
3176
+ args;
3177
+ /** @hidden */
3178
+ selector;
3179
+ /** @hidden */
3180
+ receiver;
3181
+ /** @hidden */
3182
+ constructor(receiver, selector, args, loc) {
3183
+ super(loc);
3184
+ this.receiver = receiver;
3185
+ this.selector = selector;
3186
+ this.args = args;
3187
+ }
3188
+ accept(visitor) {
3189
+ return this.dispatchVisit(visitor, visitor.visitSend);
3190
+ }
3191
+ toJSON() {
3192
+ return {
3193
+ type: "Send",
3194
+ receiver: this.receiver.toJSON(),
3195
+ selector: this.selector.toJSON(),
3196
+ arguments: this.args.map((arg) => arg.toJSON())
3197
+ };
3198
+ }
3199
+ };
3200
+ New = class extends ASTNode {
3201
+ /** @hidden */
3202
+ args;
3203
+ /** @hidden */
3204
+ identifier;
3205
+ constructor(identifier, args, loc) {
3206
+ super(loc);
3207
+ this.identifier = identifier;
3208
+ this.args = args;
3209
+ }
3210
+ accept(visitor) {
3211
+ return this.dispatchVisit(visitor, visitor.visitNew);
3212
+ }
3213
+ toJSON() {
3214
+ return {
3215
+ type: "New",
3216
+ identifier: this.identifier.toJSON(),
3217
+ arguments: this.args.map((arg) => arg.toJSON())
3218
+ };
3219
+ }
3220
+ };
3221
+ Implement = class extends ASTNode {
3222
+ /** @hidden */
3223
+ identifier;
3224
+ constructor(identifier, loc) {
3225
+ super(loc);
3226
+ this.identifier = identifier;
3227
+ }
3228
+ accept(visitor) {
3229
+ return this.dispatchVisit(visitor, visitor.visitImplement);
3230
+ }
3231
+ toJSON() {
3232
+ return {
3233
+ type: "Implement",
3234
+ identifier: this.identifier.toJSON()
3235
+ };
3236
+ }
3237
+ };
3238
+ Self = class extends ASTNode {
3239
+ accept(visitor) {
3240
+ return this.dispatchVisit(visitor, visitor.visitSelf);
3241
+ }
3242
+ toJSON() {
3243
+ return {
3244
+ type: "Self"
3245
+ };
3246
+ }
3247
+ };
3248
+ Super = class extends ASTNode {
3249
+ /** @hidden */
3250
+ args;
3251
+ constructor(args, loc) {
3252
+ super(loc);
3253
+ this.args = args;
3254
+ }
3255
+ accept(visitor) {
3256
+ return this.dispatchVisit(visitor, visitor.visitSuper);
3257
+ }
3258
+ toJSON() {
3259
+ return {
3260
+ type: "Super",
3261
+ args: this.args
3262
+ };
3263
+ }
3264
+ };
3265
+ PrimitiveMethod = class extends ASTNode {
3266
+ operator;
3267
+ equations;
3268
+ constructor(operator, equations, loc) {
3269
+ super(loc);
3270
+ this.operator = operator;
3271
+ this.equations = equations;
3272
+ }
3273
+ accept(visitor) {
3274
+ return this.dispatchVisit(visitor, visitor.visitPrimitiveMethod);
3275
+ }
3276
+ toJSON() {
3277
+ return {
3278
+ type: "PrimitiveMethod",
3279
+ operator: this.operator,
3280
+ equations: this.equations
3281
+ };
3282
+ }
3283
+ };
3284
+ }
3285
+ });
3286
+
3287
+ // ../yukigo-ast/dist/paradigms/imperative.js
3288
+ var EntryPoint, Procedure, Structure, Enumeration, While, Repeat, ForLoop;
3289
+ var init_imperative = __esm({
3290
+ "../yukigo-ast/dist/paradigms/imperative.js"() {
3291
+ init_generics();
3292
+ EntryPoint = class extends ASTNode {
3293
+ /** @hidden */
3294
+ expression;
3295
+ /** @hidden */
3296
+ identifier;
3297
+ constructor(identifier, expression, loc) {
3298
+ super(loc);
3299
+ this.identifier = identifier;
3300
+ this.expression = expression;
3301
+ }
3302
+ accept(visitor) {
3303
+ return this.dispatchVisit(visitor, visitor.visitEntryPoint);
3304
+ }
3305
+ toJSON() {
3306
+ return {
3307
+ type: "EntryPoint",
3308
+ identifier: this.identifier.toJSON(),
3309
+ expression: this.expression.toJSON()
3310
+ };
3311
+ }
3312
+ };
3313
+ Procedure = class extends ASTNode {
3314
+ /** @hidden */
3315
+ equations;
3316
+ /** @hidden */
3317
+ identifier;
3318
+ constructor(identifier, equations, loc) {
3319
+ super(loc);
3320
+ this.identifier = identifier;
3321
+ this.equations = equations;
3322
+ }
3323
+ accept(visitor) {
3324
+ return this.dispatchVisit(visitor, visitor.visitProcedure);
3325
+ }
3326
+ toJSON() {
3327
+ return {
3328
+ type: "Procedure",
3329
+ identifier: this.identifier.toJSON(),
3330
+ equations: this.equations.map((eq) => eq.toJSON())
3331
+ };
3332
+ }
3333
+ };
3334
+ Structure = class extends ASTNode {
3335
+ /** @hidden */
3336
+ elements;
3337
+ /** @hidden */
3338
+ identifier;
3339
+ constructor(identifier, elements, loc) {
3340
+ super();
3341
+ this.identifier = identifier;
3342
+ this.elements = elements;
3343
+ this.loc = loc;
3344
+ }
3345
+ accept(visitor) {
3346
+ return this.dispatchVisit(visitor, visitor.visitStructure);
3347
+ }
3348
+ toJSON() {
3349
+ return {
3350
+ type: "Structure",
3351
+ identifier: this.identifier.toJSON(),
3352
+ expressions: this.elements.map((elem) => elem.toJSON())
3353
+ };
3354
+ }
3355
+ };
3356
+ Enumeration = class extends ASTNode {
3357
+ /** @hidden */
3358
+ contents;
3359
+ /** @hidden */
3360
+ identifier;
3361
+ constructor(identifier, contents, loc) {
3362
+ super(loc);
3363
+ this.identifier = identifier;
3364
+ this.contents = contents;
3365
+ }
3366
+ accept(visitor) {
3367
+ return this.dispatchVisit(visitor, visitor.visitEnumeration);
3368
+ }
3369
+ toJSON() {
3370
+ return {
3371
+ type: "Enumeration",
3372
+ identifier: this.identifier.toJSON(),
3373
+ expressions: this.contents.map((c) => c.toJSON())
3374
+ };
3375
+ }
3376
+ };
3377
+ While = class extends ASTNode {
3378
+ /** @hidden */
3379
+ body;
3380
+ /** @hidden */
3381
+ condition;
3382
+ constructor(condition, body, loc) {
3383
+ super(loc);
3384
+ this.condition = condition;
3385
+ this.body = body;
3386
+ }
3387
+ accept(visitor) {
3388
+ return this.dispatchVisit(visitor, visitor.visitWhile);
3389
+ }
3390
+ toJSON() {
3391
+ return {
3392
+ type: "While",
3393
+ condition: this.condition.toJSON(),
3394
+ body: this.body.toJSON()
3395
+ };
3396
+ }
3397
+ };
3398
+ Repeat = class extends ASTNode {
3399
+ /** @hidden */
3400
+ body;
3401
+ /** @hidden */
3402
+ count;
3403
+ constructor(count, body, loc) {
3404
+ super(loc);
3405
+ this.count = count;
3406
+ this.body = body;
3407
+ }
3408
+ accept(visitor) {
3409
+ return this.dispatchVisit(visitor, visitor.visitRepeat);
3410
+ }
3411
+ toJSON() {
3412
+ return {
3413
+ type: "Repeat",
3414
+ count: this.count.toJSON(),
3415
+ body: this.body.toJSON()
3416
+ };
3417
+ }
3418
+ };
3419
+ ForLoop = class extends ASTNode {
3420
+ /** @hidden */
3421
+ body;
3422
+ /** @hidden */
3423
+ update;
3424
+ /** @hidden */
3425
+ condition;
3426
+ /** @hidden */
3427
+ initialization;
3428
+ constructor(initialization, condition, update, body, loc) {
3429
+ super(loc);
3430
+ this.initialization = initialization;
3431
+ this.condition = condition;
3432
+ this.update = update;
3433
+ this.body = body;
3434
+ }
3435
+ accept(visitor) {
3436
+ return this.dispatchVisit(visitor, visitor.visitForLoop);
3437
+ }
3438
+ toJSON() {
3439
+ return {
3440
+ type: "ForLoop",
3441
+ initialization: this.initialization.toJSON(),
3442
+ condition: this.condition.toJSON(),
3443
+ update: this.update.toJSON(),
3444
+ body: this.body.toJSON()
3445
+ };
3446
+ }
3447
+ };
3448
+ }
3449
+ });
3450
+
3451
+ // ../yukigo-ast/dist/paradigms/logic.js
3452
+ var Rule, Call, Fact, Query, Exist, Not, Findall, Forall, Goal, LogicConstraint;
3453
+ var init_logic = __esm({
3454
+ "../yukigo-ast/dist/paradigms/logic.js"() {
3455
+ init_generics();
3456
+ Rule = class extends ASTNode {
3457
+ /** @hidden */
3458
+ equations;
3459
+ /** @hidden */
3460
+ identifier;
3461
+ constructor(identifier, equations, loc) {
3462
+ super(loc);
3463
+ this.identifier = identifier;
3464
+ this.equations = equations;
3465
+ }
3466
+ accept(visitor) {
3467
+ return this.dispatchVisit(visitor, visitor.visitRule);
3468
+ }
3469
+ toJSON() {
3470
+ return {
3471
+ type: "Rule",
3472
+ identifier: this.identifier.toJSON(),
3473
+ equations: this.equations.map((expr) => expr.toJSON())
3474
+ };
3475
+ }
3476
+ };
3477
+ Call = class extends ASTNode {
3478
+ /** @hidden */
3479
+ args;
3480
+ /** @hidden */
3481
+ callee;
3482
+ constructor(callee, args, loc) {
3483
+ super(loc);
3484
+ this.callee = callee;
3485
+ this.args = args;
3486
+ }
3487
+ accept(visitor) {
3488
+ return this.dispatchVisit(visitor, visitor.visitCall);
3489
+ }
3490
+ toJSON() {
3491
+ return {
3492
+ type: "Call",
3493
+ callee: this.callee.toJSON(),
3494
+ patterns: this.args.map((p) => p.toJSON())
3495
+ };
3496
+ }
3497
+ };
3498
+ Fact = class extends ASTNode {
3499
+ /** @hidden */
3500
+ patterns;
3501
+ /** @hidden */
3502
+ identifier;
3503
+ constructor(identifier, patterns, loc) {
3504
+ super(loc);
3505
+ this.identifier = identifier;
3506
+ this.patterns = patterns;
3507
+ }
3508
+ accept(visitor) {
3509
+ return this.dispatchVisit(visitor, visitor.visitFact);
3510
+ }
3511
+ toJSON() {
3512
+ return {
3513
+ type: "Fact",
3514
+ identifier: this.identifier.toJSON(),
3515
+ patterns: this.patterns.map((p) => p.toJSON())
3516
+ };
3517
+ }
3518
+ };
3519
+ Query = class extends ASTNode {
3520
+ /** @hidden */
3521
+ expressions;
3522
+ constructor(expressions, loc) {
3523
+ super(loc);
3524
+ this.expressions = expressions;
3525
+ }
3526
+ accept(visitor) {
3527
+ return this.dispatchVisit(visitor, visitor.visitQuery);
3528
+ }
3529
+ toJSON() {
3530
+ return {
3531
+ type: "Query",
3532
+ expressions: this.expressions.map((expr) => expr.toJSON())
3533
+ };
3534
+ }
3535
+ };
3536
+ Exist = class extends ASTNode {
3537
+ /** @hidden */
3538
+ patterns;
3539
+ /** @hidden */
3540
+ identifier;
3541
+ constructor(identifier, patterns, loc) {
3542
+ super(loc);
3543
+ this.identifier = identifier;
3544
+ this.patterns = patterns;
3545
+ }
3546
+ accept(visitor) {
3547
+ return this.dispatchVisit(visitor, visitor.visitExist);
3548
+ }
3549
+ toJSON() {
3550
+ return {
3551
+ type: "Exist",
3552
+ identifier: this.identifier.toJSON(),
3553
+ patterns: this.patterns.map((p) => p.toJSON())
3554
+ };
3555
+ }
3556
+ };
3557
+ Not = class extends ASTNode {
3558
+ /** @hidden */
3559
+ expression;
3560
+ constructor(expression, loc) {
3561
+ super(loc);
3562
+ this.expression = expression;
3563
+ }
3564
+ accept(visitor) {
3565
+ return this.dispatchVisit(visitor, visitor.visitNot);
3566
+ }
3567
+ toJSON() {
3568
+ return {
3569
+ type: "Not",
3570
+ expression: this.expression.toJSON()
3571
+ };
3572
+ }
3573
+ };
3574
+ Findall = class extends ASTNode {
3575
+ /** @hidden */
3576
+ bag;
3577
+ /** @hidden */
3578
+ goal;
3579
+ /** @hidden */
3580
+ template;
3581
+ constructor(template, goal, bag, loc) {
3582
+ super(loc);
3583
+ this.template = template;
3584
+ this.goal = goal;
3585
+ this.bag = bag;
3586
+ }
3587
+ accept(visitor) {
3588
+ return this.dispatchVisit(visitor, visitor.visitFindall);
3589
+ }
3590
+ toJSON() {
3591
+ return {
3592
+ type: "Findall",
3593
+ template: this.template.toJSON(),
3594
+ goal: this.goal.toJSON(),
3595
+ bag: this.bag.toJSON()
3596
+ };
3597
+ }
3598
+ };
3599
+ Forall = class extends ASTNode {
3600
+ /** @hidden */
3601
+ action;
3602
+ /** @hidden */
3603
+ condition;
3604
+ constructor(condition, action, loc) {
3605
+ super(loc);
3606
+ this.condition = condition;
3607
+ this.action = action;
3608
+ }
3609
+ accept(visitor) {
3610
+ return this.dispatchVisit(visitor, visitor.visitForall);
3611
+ }
3612
+ toJSON() {
3613
+ return {
3614
+ type: "Forall",
3615
+ condition: this.condition.toJSON(),
3616
+ action: this.action.toJSON()
3617
+ };
3618
+ }
3619
+ };
3620
+ Goal = class extends ASTNode {
3621
+ /** @hidden */
3622
+ args;
3623
+ /** @hidden */
3624
+ identifier;
3625
+ constructor(identifier, args, loc) {
3626
+ super(loc);
3627
+ this.identifier = identifier;
3628
+ this.args = args;
3629
+ }
3630
+ accept(visitor) {
3631
+ return this.dispatchVisit(visitor, visitor.visitGoal);
3632
+ }
3633
+ toJSON() {
3634
+ return {
3635
+ type: "Goal",
3636
+ identifier: this.identifier.toJSON(),
3637
+ arguments: this.args.map((arg) => arg.toJSON())
3638
+ };
3639
+ }
3640
+ };
3641
+ LogicConstraint = class extends ASTNode {
3642
+ /** @hidden */
3643
+ expression;
3644
+ constructor(expression, loc) {
3645
+ super(loc);
3646
+ this.expression = expression;
3647
+ }
3648
+ accept(visitor) {
3649
+ return this.dispatchVisit(visitor, visitor.visitLogicConstraint);
3650
+ }
3651
+ toJSON() {
3652
+ return {
3653
+ type: "LogicConstraint",
3654
+ expression: this.expression.toJSON()
3655
+ };
3656
+ }
3657
+ };
3658
+ }
3659
+ });
3660
+
3661
+ // ../yukigo-ast/dist/paradigms/typeclasses.js
3662
+ var TypeClass, Instance;
3663
+ var init_typeclasses = __esm({
3664
+ "../yukigo-ast/dist/paradigms/typeclasses.js"() {
3665
+ init_generics();
3666
+ TypeClass = class extends ASTNode {
3667
+ /** @hidden */
3668
+ name;
3669
+ /** @hidden */
3670
+ variable;
3671
+ /** @hidden */
3672
+ signatures;
3673
+ constructor(name, variable2, signatures, loc) {
3674
+ super(loc);
3675
+ this.name = name;
3676
+ this.variable = variable2;
3677
+ this.signatures = signatures;
3678
+ }
3679
+ accept(visitor) {
3680
+ return this.dispatchVisit(visitor, visitor.visitTypeClass);
3681
+ }
3682
+ toJSON() {
3683
+ return {
3684
+ type: "TypeClass",
3685
+ name: this.name.toJSON(),
3686
+ variable: this.variable.toJSON(),
3687
+ signatures: this.signatures.map((sig) => sig.toJSON())
3688
+ };
3689
+ }
3690
+ };
3691
+ Instance = class extends ASTNode {
3692
+ /** @hidden */
3693
+ className;
3694
+ /** @hidden */
3695
+ type;
3696
+ /** @hidden */
3697
+ functions;
3698
+ constructor(className, type, functions, loc) {
3699
+ super(loc);
3700
+ this.className = className;
3701
+ this.type = type;
3702
+ this.functions = functions;
3703
+ }
3704
+ accept(visitor) {
3705
+ return this.dispatchVisit(visitor, visitor.visitInstance);
3706
+ }
3707
+ toJSON() {
3708
+ return {
3709
+ type: "Instance",
3710
+ className: this.className.toJSON(),
3711
+ targetType: this.type.toJSON(),
3712
+ functions: this.functions.map((func) => func.toJSON())
3713
+ };
3714
+ }
3715
+ };
3716
+ }
3717
+ });
3718
+
3719
+ // ../yukigo-ast/dist/visitor/base.js
3720
+ var TraverseBase;
3721
+ var init_base = __esm({
3722
+ "../yukigo-ast/dist/visitor/base.js"() {
3723
+ TraverseBase = class {
3724
+ visit(node) {
3725
+ node.accept(this);
3726
+ }
3727
+ traverseCollection(nodes) {
3728
+ nodes.forEach((node) => node.accept(this));
3729
+ }
3730
+ };
3731
+ }
3732
+ });
3733
+
3734
+ // ../yukigo-ast/dist/visitor/expressions.js
3735
+ function ExpressionTraverser(Base) {
3736
+ class ExpressionTraverser2 extends Base {
3737
+ visitTupleExpr(node) {
3738
+ this.traverseCollection(node.elements);
3739
+ }
3740
+ visitFieldExpr(node) {
3741
+ node.name.accept(this);
3742
+ node.expression.accept(this);
3743
+ }
3744
+ visitDataExpr(node) {
3745
+ node.name.accept(this);
3746
+ this.traverseCollection(node.contents);
3747
+ }
3748
+ visitConsExpr(node) {
3749
+ node.head.accept(this);
3750
+ node.tail.accept(this);
3751
+ }
3752
+ visitLetInExpr(node) {
3753
+ node.expression.accept(this);
3754
+ node.declarations.accept(this);
3755
+ }
3756
+ visitGuardedExpression(node) {
3757
+ this.traverseCollection(node.guards);
3758
+ }
3759
+ visitGuard(node) {
3760
+ node.condition.accept(this);
3761
+ node.body.accept(this);
3762
+ }
3763
+ visitCall(node) {
3764
+ node.callee.accept(this);
3765
+ this.traverseCollection(node.args);
3766
+ }
3767
+ visitOtherwise(node) {
3768
+ }
3769
+ visitCompositionExpression(node) {
3770
+ node.left.accept(this);
3771
+ node.right.accept(this);
3772
+ }
3773
+ visitLambda(node) {
3774
+ node.body.accept(this);
3775
+ this.traverseCollection(node.parameters);
3776
+ }
3777
+ visitApplication(node) {
3778
+ node.functionExpr.accept(this);
3779
+ node.parameter.accept(this);
3780
+ }
3781
+ visitExist(node) {
3782
+ node.identifier.accept(this);
3783
+ this.traverseCollection(node.patterns);
3784
+ }
3785
+ visitNot(node) {
3786
+ node.expression.accept(this);
3787
+ }
3788
+ visitFindall(node) {
3789
+ node.template.accept(this);
3790
+ node.goal.accept(this);
3791
+ node.bag.accept(this);
3792
+ }
3793
+ visitForall(node) {
3794
+ node.condition.accept(this);
3795
+ node.action.accept(this);
3796
+ }
3797
+ visitGoal(node) {
3798
+ node.identifier.accept(this);
3799
+ this.traverseCollection(node.args);
3800
+ }
3801
+ visitSend(node) {
3802
+ node.selector.accept(this);
3803
+ node.receiver.accept(this);
3804
+ this.traverseCollection(node.args);
3805
+ }
3806
+ visitNew(node) {
3807
+ node.identifier.accept(this);
3808
+ this.traverseCollection(node.args);
3809
+ }
3810
+ visitImplement(node) {
3811
+ node.identifier.accept(this);
3812
+ }
3813
+ visitListComprehension(node) {
3814
+ node.projection.accept(this);
3815
+ this.traverseCollection(node.generators);
3816
+ }
3817
+ visitGenerator(node) {
3818
+ node.variable.accept(this);
3819
+ node.expression.accept(this);
3820
+ }
3821
+ visitRangeExpression(node) {
3822
+ node.start.accept(this);
3823
+ node.step?.accept(this);
3824
+ node.end?.accept(this);
3825
+ }
3826
+ visitNamedArgument(node) {
3827
+ node.identifier.accept(this);
3828
+ node.expression.accept(this);
3829
+ }
3830
+ visitYield(node) {
3831
+ node.expression.accept(this);
3832
+ }
3833
+ }
3834
+ ;
3835
+ return ExpressionTraverser2;
3836
+ }
3837
+ var init_expressions2 = __esm({
3838
+ "../yukigo-ast/dist/visitor/expressions.js"() {
3839
+ }
3840
+ });
3841
+
3842
+ // ../yukigo-ast/dist/visitor/operations.js
3843
+ function OperationTraverser(Base) {
3844
+ class OperationTraverser2 extends Base {
3845
+ traverseBinary(node) {
3846
+ node.left.accept(this);
3847
+ node.right.accept(this);
3848
+ }
3849
+ traverseUnary(node) {
3850
+ node.operand.accept(this);
3851
+ }
3852
+ visitArithmeticUnaryOperation(node) {
3853
+ this.traverseUnary(node);
3854
+ }
3855
+ visitArithmeticBinaryOperation(node) {
3856
+ this.traverseBinary(node);
3857
+ }
3858
+ visitListUnaryOperation(node) {
3859
+ this.traverseUnary(node);
3860
+ }
3861
+ visitListBinaryOperation(node) {
3862
+ this.traverseBinary(node);
3863
+ }
3864
+ visitComparisonOperation(node) {
3865
+ this.traverseBinary(node);
3866
+ }
3867
+ visitLogicalBinaryOperation(node) {
3868
+ this.traverseBinary(node);
3869
+ }
3870
+ visitLogicalUnaryOperation(node) {
3871
+ this.traverseUnary(node);
3872
+ }
3873
+ visitBitwiseBinaryOperation(node) {
3874
+ this.traverseBinary(node);
3875
+ }
3876
+ visitBitwiseUnaryOperation(node) {
3877
+ this.traverseUnary(node);
3878
+ }
3879
+ visitStringOperation(node) {
3880
+ this.traverseBinary(node);
3881
+ }
3882
+ visitUnifyOperation(node) {
3883
+ this.traverseBinary(node);
3884
+ }
3885
+ visitAssignOperation(node) {
3886
+ this.traverseBinary(node);
3887
+ }
3888
+ }
3889
+ return OperationTraverser2;
3890
+ }
3891
+ var init_operations = __esm({
3892
+ "../yukigo-ast/dist/visitor/operations.js"() {
3893
+ }
3894
+ });
3895
+
3896
+ // ../yukigo-ast/dist/visitor/patterns.js
3897
+ function PatternTraverser(Base) {
3898
+ class PatternTraverser2 extends Base {
3899
+ visitVariablePattern(node) {
3900
+ node.name.accept(this);
3901
+ }
3902
+ visitLiteralPattern(node) {
3903
+ node.name.accept(this);
3904
+ }
3905
+ visitApplicationPattern(node) {
3906
+ node.identifier.accept(this);
3907
+ this.traverseCollection(node.args);
3908
+ }
3909
+ visitTuplePattern(node) {
3910
+ this.traverseCollection(node.elements);
3911
+ }
3912
+ visitListPattern(node) {
3913
+ this.traverseCollection(node.elements);
3914
+ }
3915
+ visitFunctorPattern(node) {
3916
+ node.identifier.accept(this);
3917
+ this.traverseCollection(node.args);
3918
+ }
3919
+ visitAsPattern(node) {
3920
+ node.left.accept(this);
3921
+ node.right.accept(this);
3922
+ }
3923
+ visitWildcardPattern(node) {
3924
+ }
3925
+ visitUnionPattern(node) {
3926
+ this.traverseCollection(node.elements);
3927
+ }
3928
+ visitConstructorPattern(node) {
3929
+ this.traverseCollection(node.args);
3930
+ }
3931
+ visitConsPattern(node) {
3932
+ node.left.accept(this);
3933
+ node.right.accept(this);
3934
+ }
3935
+ visitTypePattern(node) {
3936
+ node.targetType.accept(this);
3937
+ node.innerPattern?.accept(this);
3938
+ }
3939
+ }
3940
+ ;
3941
+ return PatternTraverser2;
3942
+ }
3943
+ var init_patterns2 = __esm({
3944
+ "../yukigo-ast/dist/visitor/patterns.js"() {
3945
+ }
3946
+ });
3947
+
3948
+ // ../yukigo-ast/dist/visitor/primitives.js
3949
+ function PrimitiveTraverser(Base) {
3950
+ class PrimitiveTraverser2 extends Base {
3951
+ visitNumberPrimitive(node) {
3952
+ }
3953
+ visitBooleanPrimitive(node) {
3954
+ }
3955
+ visitStringPrimitive(node) {
3956
+ }
3957
+ visitListPrimitive(node) {
3958
+ this.traverseCollection(node.value);
3959
+ }
3960
+ visitNilPrimitive(node) {
3961
+ }
3962
+ visitSymbolPrimitive(node) {
3963
+ }
3964
+ visitCharPrimitive(node) {
3965
+ }
3966
+ }
3967
+ return PrimitiveTraverser2;
3968
+ }
3969
+ var init_primitives2 = __esm({
3970
+ "../yukigo-ast/dist/visitor/primitives.js"() {
3971
+ }
3972
+ });
3973
+
3974
+ // ../yukigo-ast/dist/visitor/statements.js
3975
+ function StatementTraverser(Base) {
3976
+ class StatementTraverser2 extends Base {
3977
+ visitSequence(node) {
3978
+ this.traverseCollection(node.statements);
3979
+ }
3980
+ visitSelf(node) {
3981
+ }
3982
+ visitSuper(node) {
3983
+ }
3984
+ visitIf(node) {
3985
+ node.condition.accept(this);
3986
+ node.then.accept(this);
3987
+ node.elseExpr.accept(this);
3988
+ }
3989
+ visitReturn(node) {
3990
+ node.body?.accept(this);
3991
+ }
3992
+ visitFunction(node) {
3993
+ node.identifier.accept(this);
3994
+ this.traverseCollection(node.equations);
3995
+ }
3996
+ visitField(node) {
3997
+ node.name?.accept(this);
3998
+ node.value.accept(this);
3999
+ }
4000
+ visitConstructor(node) {
4001
+ node.name.accept(this);
4002
+ this.traverseCollection(node.fields);
4003
+ }
4004
+ visitRecord(node) {
4005
+ node.name.accept(this);
4006
+ this.traverseCollection(node.contents);
4007
+ if (node.deriving)
4008
+ this.traverseCollection(node.deriving);
4009
+ }
4010
+ visitUnguardedBody(node) {
4011
+ node.sequence.accept(this);
4012
+ }
4013
+ visitNativeBody(node) {
4014
+ }
4015
+ visitEquation(node) {
4016
+ if (Array.isArray(node.body)) {
4017
+ this.traverseCollection(node.body);
4018
+ } else {
4019
+ node.body.accept(this);
4020
+ }
4021
+ this.traverseCollection(node.patterns);
4022
+ node.returnExpr?.accept(this);
4023
+ }
4024
+ visitSwitch(node) {
4025
+ node.value.accept(this);
4026
+ this.traverseCollection(node.cases);
4027
+ }
4028
+ visitCase(node) {
4029
+ node.condition.accept(this);
4030
+ node.body.accept(this);
4031
+ }
4032
+ visitTry(node) {
4033
+ node.body.accept(this);
4034
+ this.traverseCollection(node.catchExpr);
4035
+ node.finallyExpr.accept(this);
4036
+ }
4037
+ visitCatch(node) {
4038
+ node.body.accept(this);
4039
+ this.traverseCollection(node.patterns);
4040
+ }
4041
+ visitRaise(node) {
4042
+ node.body.accept(this);
4043
+ }
4044
+ visitPrint(node) {
4045
+ node.expression.accept(this);
4046
+ }
4047
+ visitInput(node) {
4048
+ node.message.accept(this);
4049
+ }
4050
+ visitFor(node) {
4051
+ node.body.accept(this);
4052
+ this.traverseCollection(node.statements);
4053
+ }
4054
+ visitBreak(node) {
4055
+ node.body?.accept(this);
4056
+ }
4057
+ visitContinue(node) {
4058
+ node.body?.accept(this);
4059
+ }
4060
+ visitVariable(node) {
4061
+ node.identifier.accept(this);
4062
+ node.expression.accept(this);
4063
+ node.variableType?.accept(this);
4064
+ }
4065
+ visitAssignment(node) {
4066
+ node.identifier.accept(this);
4067
+ node.expression.accept(this);
4068
+ }
4069
+ visitStructure(node) {
4070
+ this.traverseCollection(node.elements);
4071
+ }
4072
+ visitEntryPoint(node) {
4073
+ node.identifier.accept(this);
4074
+ node.expression.accept(this);
4075
+ }
4076
+ visitProcedure(node) {
4077
+ node.identifier.accept(this);
4078
+ this.traverseCollection(node.equations);
4079
+ }
4080
+ visitEnumeration(node) {
4081
+ node.identifier.accept(this);
4082
+ this.traverseCollection(node.contents);
4083
+ }
4084
+ visitWhile(node) {
4085
+ node.condition.accept(this);
4086
+ node.body.accept(this);
4087
+ }
4088
+ visitRepeat(node) {
4089
+ node.body.accept(this);
4090
+ node.count.accept(this);
4091
+ }
4092
+ visitForLoop(node) {
4093
+ node.initialization.accept(this);
4094
+ node.condition.accept(this);
4095
+ node.update.accept(this);
4096
+ node.body.accept(this);
4097
+ }
4098
+ visitRule(node) {
4099
+ node.identifier.accept(this);
4100
+ this.traverseCollection(node.equations);
4101
+ }
4102
+ visitFact(node) {
4103
+ node.identifier.accept(this);
4104
+ this.traverseCollection(node.patterns);
4105
+ }
4106
+ visitQuery(node) {
4107
+ this.traverseCollection(node.expressions);
4108
+ }
4109
+ visitMethod(node) {
4110
+ node.identifier.accept(this);
4111
+ this.traverseCollection(node.equations);
4112
+ }
4113
+ visitPrimitiveMethod(node) {
4114
+ this.traverseCollection(node.equations);
4115
+ }
4116
+ visitAttribute(node) {
4117
+ node.identifier.accept(this);
4118
+ node.expression.accept(this);
4119
+ }
4120
+ visitObject(node) {
4121
+ node.identifier.accept(this);
4122
+ node.expression.accept(this);
4123
+ node.extendsSymbol?.accept(this);
4124
+ if (node.extendsArgs) {
4125
+ this.traverseCollection(node.extendsArgs);
4126
+ }
4127
+ }
4128
+ visitClass(node) {
4129
+ node.identifier.accept(this);
4130
+ node.expression.accept(this);
4131
+ node.extendsSymbol?.accept(this);
4132
+ node.implementsNode?.accept(this);
4133
+ }
4134
+ visitInterface(node) {
4135
+ node.identifier.accept(this);
4136
+ this.traverseCollection(node.extendsSymbol);
4137
+ node.expression.accept(this);
4138
+ }
4139
+ visitLogicConstraint(node) {
4140
+ node.expression.accept(this);
4141
+ }
4142
+ }
4143
+ ;
4144
+ return StatementTraverser2;
4145
+ }
4146
+ var init_statements2 = __esm({
4147
+ "../yukigo-ast/dist/visitor/statements.js"() {
4148
+ }
4149
+ });
4150
+
4151
+ // ../yukigo-ast/dist/visitor/types.js
4152
+ function TypeTraverser(Base) {
4153
+ class TypeTraverser2 extends Base {
4154
+ visitSimpleType(node) {
4155
+ this.traverseCollection(node.constraints);
4156
+ }
4157
+ visitTypeVar(node) {
4158
+ this.traverseCollection(node.constraints);
4159
+ }
4160
+ visitTypeApplication(node) {
4161
+ node.functionType.accept(this);
4162
+ node.argument.accept(this);
4163
+ }
4164
+ visitListType(node) {
4165
+ this.traverseCollection(node.constraints);
4166
+ }
4167
+ visitTupleType(node) {
4168
+ this.traverseCollection(node.constraints);
4169
+ this.traverseCollection(node.values);
4170
+ }
4171
+ visitConstraint(node) {
4172
+ this.traverseCollection(node.parameters);
4173
+ }
4174
+ visitParameterizedType(node) {
4175
+ this.traverseCollection(node.inputs);
4176
+ this.traverseCollection(node.constraints);
4177
+ node.returnType.accept(this);
4178
+ }
4179
+ visitConstrainedType(node) {
4180
+ this.traverseCollection(node.constraints);
4181
+ }
4182
+ visitTypeAlias(node) {
4183
+ node.identifier.accept(this);
4184
+ node.value.accept(this);
4185
+ }
4186
+ visitTypeSignature(node) {
4187
+ node.body.accept(this);
4188
+ node.identifier.accept(this);
4189
+ }
4190
+ visitTypeCast(node) {
4191
+ node.body.accept(this);
4192
+ node.expression.accept(this);
4193
+ }
4194
+ }
4195
+ return TypeTraverser2;
4196
+ }
4197
+ var init_types2 = __esm({
4198
+ "../yukigo-ast/dist/visitor/types.js"() {
4199
+ }
4200
+ });
4201
+
4202
+ // ../yukigo-ast/dist/visitor/testing.js
4203
+ function TestingTraverser(Base) {
4204
+ class TestingTraverser2 extends Base {
4205
+ visitTestGroup(node) {
4206
+ node.name.accept(this);
4207
+ node.group.accept(this);
4208
+ }
4209
+ visitTest(node) {
4210
+ node.name.accept(this);
4211
+ this.traverseCollection(node.args);
4212
+ node.body.accept(this);
4213
+ }
4214
+ visitAssert(node) {
4215
+ node.negated.accept(this);
4216
+ node.body.accept(this);
4217
+ }
4218
+ visitTruth(node) {
4219
+ node.body.accept(this);
4220
+ }
4221
+ visitEquality(node) {
4222
+ node.expected.accept(this);
4223
+ node.value.accept(this);
4224
+ }
4225
+ visitFailure(node) {
4226
+ node.func.accept(this);
4227
+ node.message.accept(this);
4228
+ }
4229
+ }
4230
+ ;
4231
+ return TestingTraverser2;
4232
+ }
4233
+ var init_testing2 = __esm({
4234
+ "../yukigo-ast/dist/visitor/testing.js"() {
4235
+ }
4236
+ });
4237
+
4238
+ // ../yukigo-ast/dist/visitor/typeclasses.js
4239
+ function TypeClassTraverser(Base) {
4240
+ class TypeClassTraverser2 extends Base {
4241
+ visitTypeClass(node) {
4242
+ this.traverseCollection(node.signatures);
4243
+ }
4244
+ visitInstance(node) {
4245
+ this.traverseCollection(node.functions);
4246
+ }
4247
+ }
4248
+ ;
4249
+ return TypeClassTraverser2;
4250
+ }
4251
+ var init_typeclasses2 = __esm({
4252
+ "../yukigo-ast/dist/visitor/typeclasses.js"() {
4253
+ }
4254
+ });
4255
+
4256
+ // ../yukigo-ast/dist/visitor/index.js
4257
+ var StopTraversalException, TraverseVisitor;
4258
+ var init_visitor = __esm({
4259
+ "../yukigo-ast/dist/visitor/index.js"() {
4260
+ init_base();
4261
+ init_expressions2();
4262
+ init_operations();
4263
+ init_patterns2();
4264
+ init_primitives2();
4265
+ init_statements2();
4266
+ init_types2();
4267
+ init_testing2();
4268
+ init_typeclasses2();
4269
+ init_base();
4270
+ init_expressions2();
4271
+ init_operations();
4272
+ init_patterns2();
4273
+ init_primitives2();
4274
+ init_statements2();
4275
+ init_types2();
4276
+ init_testing2();
4277
+ init_typeclasses2();
4278
+ StopTraversalException = class extends Error {
4279
+ constructor() {
4280
+ super("Inspection found, aborting traversal.");
4281
+ }
4282
+ };
4283
+ TraverseVisitor = class extends TypeClassTraverser(TestingTraverser(TypeTraverser(StatementTraverser(PatternTraverser(OperationTraverser(PrimitiveTraverser(ExpressionTraverser(TraverseBase)))))))) {
4284
+ };
4285
+ }
4286
+ });
4287
+
4288
+ // ../yukigo-ast/dist/index.js
4289
+ var dist_exports = {};
4290
+ __export(dist_exports, {
4291
+ ASTNode: () => ASTNode,
4292
+ Application: () => Application,
4293
+ ApplicationPattern: () => ApplicationPattern,
4294
+ ArithmeticBinaryOperation: () => ArithmeticBinaryOperation,
4295
+ ArithmeticUnaryOperation: () => ArithmeticUnaryOperation,
4296
+ AsPattern: () => AsPattern,
4297
+ Assert: () => Assert,
4298
+ AssignOperation: () => AssignOperation,
4299
+ Assignment: () => Assignment,
4300
+ Attribute: () => Attribute,
4301
+ BitwiseBinaryOperation: () => BitwiseBinaryOperation,
4302
+ BitwiseUnaryOperation: () => BitwiseUnaryOperation,
4303
+ BooleanPrimitive: () => BooleanPrimitive,
4304
+ Break: () => Break,
4305
+ Call: () => Call,
4306
+ Case: () => Case,
4307
+ Catch: () => Catch,
4308
+ CharPrimitive: () => CharPrimitive,
4309
+ Class: () => Class,
4310
+ ComparisonOperation: () => ComparisonOperation,
4311
+ CompositionExpression: () => CompositionExpression,
4312
+ ConsExpression: () => ConsExpression,
4313
+ ConsPattern: () => ConsPattern,
4314
+ ConstrainedType: () => ConstrainedType,
4315
+ Constraint: () => Constraint,
4316
+ Constructor: () => Constructor,
4317
+ ConstructorPattern: () => ConstructorPattern,
4318
+ Continue: () => Continue,
4319
+ DataExpression: () => DataExpression,
4320
+ EntryPoint: () => EntryPoint,
4321
+ Enumeration: () => Enumeration,
4322
+ Equality: () => Equality,
4323
+ Equation: () => Equation,
4324
+ Exist: () => Exist,
4325
+ ExpressionTraverser: () => ExpressionTraverser,
4326
+ Fact: () => Fact,
4327
+ Failure: () => Failure,
4328
+ Field: () => Field,
4329
+ FieldExpression: () => FieldExpression,
4330
+ Findall: () => Findall,
4331
+ For: () => For,
4332
+ ForLoop: () => ForLoop,
4333
+ Forall: () => Forall,
4334
+ Function: () => Function,
4335
+ FunctorPattern: () => FunctorPattern,
4336
+ Generator: () => Generator,
4337
+ Goal: () => Goal,
4338
+ Guard: () => Guard,
4339
+ GuardedExpression: () => GuardedExpression,
4340
+ If: () => If,
4341
+ Implement: () => Implement,
4342
+ Input: () => Input,
4343
+ Instance: () => Instance,
4344
+ Interface: () => Interface,
4345
+ Lambda: () => Lambda,
4346
+ LetInExpression: () => LetInExpression,
4347
+ ListBinaryOperation: () => ListBinaryOperation,
4348
+ ListComprehension: () => ListComprehension,
4349
+ ListPattern: () => ListPattern,
4350
+ ListPrimitive: () => ListPrimitive,
4351
+ ListType: () => ListType,
4352
+ ListUnaryOperation: () => ListUnaryOperation,
4353
+ LiteralPattern: () => LiteralPattern,
4354
+ LogicConstraint: () => LogicConstraint,
4355
+ LogicalBinaryOperation: () => LogicalBinaryOperation,
4356
+ LogicalUnaryOperation: () => LogicalUnaryOperation,
4357
+ Method: () => Method,
4358
+ NamedArgument: () => NamedArgument,
4359
+ NativeBody: () => NativeBody,
4360
+ New: () => New,
4361
+ NilPrimitive: () => NilPrimitive,
4362
+ Not: () => Not,
4363
+ NumberPrimitive: () => NumberPrimitive,
4364
+ Object: () => Object2,
4365
+ OperationTraverser: () => OperationTraverser,
4366
+ Otherwise: () => Otherwise,
4367
+ ParameterizedType: () => ParameterizedType,
4368
+ PatternTraverser: () => PatternTraverser,
4369
+ PrimitiveMethod: () => PrimitiveMethod,
4370
+ PrimitiveTraverser: () => PrimitiveTraverser,
4371
+ Print: () => Print,
4372
+ Procedure: () => Procedure,
4373
+ Query: () => Query,
4374
+ Raise: () => Raise,
4375
+ RangeExpression: () => RangeExpression,
4376
+ Record: () => Record,
4377
+ Repeat: () => Repeat,
4378
+ Return: () => Return,
4379
+ Rule: () => Rule,
4380
+ Self: () => Self,
4381
+ Send: () => Send,
4382
+ Sequence: () => Sequence,
4383
+ SimpleType: () => SimpleType,
4384
+ SourceLocation: () => SourceLocation,
4385
+ StatementTraverser: () => StatementTraverser,
4386
+ StopTraversalException: () => StopTraversalException,
4387
+ StringOperation: () => StringOperation,
4388
+ StringPrimitive: () => StringPrimitive,
4389
+ Structure: () => Structure,
4390
+ Super: () => Super,
4391
+ Switch: () => Switch,
4392
+ SymbolPrimitive: () => SymbolPrimitive,
4393
+ Test: () => Test,
4394
+ TestGroup: () => TestGroup,
4395
+ TestingTraverser: () => TestingTraverser,
4396
+ TraverseBase: () => TraverseBase,
4397
+ TraverseVisitor: () => TraverseVisitor,
4398
+ Truth: () => Truth,
4399
+ Try: () => Try,
4400
+ TupleExpression: () => TupleExpression,
4401
+ TuplePattern: () => TuplePattern,
4402
+ TupleType: () => TupleType,
4403
+ TypeAlias: () => TypeAlias,
4404
+ TypeApplication: () => TypeApplication,
4405
+ TypeCast: () => TypeCast,
4406
+ TypeClass: () => TypeClass,
4407
+ TypeClassTraverser: () => TypeClassTraverser,
4408
+ TypePattern: () => TypePattern,
4409
+ TypeSignature: () => TypeSignature,
4410
+ TypeTraverser: () => TypeTraverser,
4411
+ TypeVar: () => TypeVar,
4412
+ UnguardedBody: () => UnguardedBody,
4413
+ UnifyOperation: () => UnifyOperation,
4414
+ UnionPattern: () => UnionPattern,
4415
+ Variable: () => Variable,
4416
+ VariablePattern: () => VariablePattern,
4417
+ While: () => While,
4418
+ WildcardPattern: () => WildcardPattern,
4419
+ Yield: () => Yield,
4420
+ isPattern: () => isPattern,
4421
+ isYukigoPrimitive: () => isYukigoPrimitive
4422
+ });
4423
+ var init_dist = __esm({
4424
+ "../yukigo-ast/dist/index.js"() {
4425
+ init_generics();
4426
+ init_expressions();
4427
+ init_statements();
4428
+ init_primitives();
4429
+ init_operators();
4430
+ init_patterns();
4431
+ init_types();
4432
+ init_testing();
4433
+ init_functional();
4434
+ init_object();
4435
+ init_imperative();
4436
+ init_logic();
4437
+ init_typeclasses();
4438
+ init_visitor();
4439
+ }
4440
+ });
4441
+
4442
+ // src/grammar.cjs
4443
+ var require_grammar = __commonJS({
4444
+ "src/grammar.cjs"(exports, module) {
4445
+ (function() {
4446
+ function id(x) {
4447
+ return x[0];
4448
+ }
4449
+ const { MiniLexer: MiniLexer2 } = (init_lexer(), __toCommonJS(lexer_exports));
4450
+ const {
4451
+ SimpleType: SimpleType2,
4452
+ Assignment: Assignment2,
4453
+ Variable: Variable2,
4454
+ ListPrimitive: ListPrimitive2,
4455
+ ListType: ListType2,
4456
+ ArithmeticBinaryOperation: ArithmeticBinaryOperation2,
4457
+ SymbolPrimitive: SymbolPrimitive2,
4458
+ NumberPrimitive: NumberPrimitive2,
4459
+ ComparisonOperation: ComparisonOperation2,
4460
+ BooleanPrimitive: BooleanPrimitive2,
4461
+ StringPrimitive: StringPrimitive2,
4462
+ ParameterizedType: ParameterizedType2,
4463
+ Sequence: Sequence2,
4464
+ UnguardedBody: UnguardedBody2,
4465
+ If: If2,
4466
+ While: While2,
4467
+ VariablePattern: VariablePattern2,
4468
+ Equation: Equation2,
4469
+ Procedure: Procedure2,
4470
+ TypeSignature: TypeSignature2,
4471
+ CharPrimitive: CharPrimitive2,
4472
+ NilPrimitive: NilPrimitive2,
4473
+ Return: Return2
4474
+ } = (init_dist(), __toCommonJS(dist_exports));
4475
+ var grammar2 = {
4476
+ Lexer: MiniLexer2,
4477
+ ParserRules: [
4478
+ { "name": "program", "symbols": ["_", "statements", "_", MiniLexer2.has("EOF") ? { type: "EOF" } : EOF], "postprocess": (d) => d[1].flat(Infinity) },
4479
+ { "name": "statements", "symbols": ["statement"], "postprocess": (d) => [d[0]] },
4480
+ { "name": "statements", "symbols": ["statements", "_", "statement"], "postprocess": (d) => [...d[0], d[2]] },
4481
+ { "name": "statement$subexpression$1", "symbols": ["assignment"] },
4482
+ { "name": "statement$subexpression$1", "symbols": ["variable_statement"] },
4483
+ { "name": "statement$subexpression$1", "symbols": ["function_statement"] },
4484
+ { "name": "statement$subexpression$1", "symbols": ["return_statement"] },
4485
+ { "name": "statement$subexpression$1", "symbols": ["if_statement"] },
4486
+ { "name": "statement$subexpression$1", "symbols": ["while_statement"] },
4487
+ { "name": "statement", "symbols": ["statement$subexpression$1", "_", { "literal": ";" }], "postprocess": (d) => d[0][0] },
4488
+ { "name": "variable_statement$ebnf$1$subexpression$1", "symbols": ["_", { "literal": ":=" }, "_", "expression"] },
4489
+ { "name": "variable_statement$ebnf$1", "symbols": ["variable_statement$ebnf$1$subexpression$1"], "postprocess": id },
4490
+ { "name": "variable_statement$ebnf$1", "symbols": [], "postprocess": function(d) {
4491
+ return null;
4492
+ } },
4493
+ { "name": "variable_statement", "symbols": ["type", "__", "variable", "variable_statement$ebnf$1"], "postprocess": (d) => new Variable2(d[2], d[3] ? d[3][3] : new NilPrimitive2(null), d[0]) },
4494
+ { "name": "return_statement", "symbols": [{ "literal": "return" }, "_", "expression"], "postprocess": (d) => new Return2(d[2]) },
4495
+ { "name": "while_statement", "symbols": [{ "literal": "while" }, "_", "condition", "_", "statement_list"], "postprocess": (d) => new While2(d[2], d[4]) },
4496
+ { "name": "if_statement", "symbols": [{ "literal": "if" }, "_", "condition", "_", "statement_list", "_", { "literal": "else" }, "_", "statement_list"], "postprocess": (d) => new If2(d[2], d[4], d[8]) },
4497
+ { "name": "condition", "symbols": [{ "literal": "(" }, "_", "expression", "_", { "literal": ")" }], "postprocess": (d) => d[2] },
4498
+ { "name": "statement_list", "symbols": [{ "literal": "{" }, "_", "body", "_", { "literal": "}" }], "postprocess": (d) => d[2] },
4499
+ { "name": "body", "symbols": ["statements"], "postprocess": (d) => new Sequence2(d[0].flat(Infinity)) },
4500
+ { "name": "body", "symbols": [], "postprocess": () => new Sequence2([]) },
4501
+ { "name": "assignment", "symbols": ["variable", "_", { "literal": ":=" }, "_", "expression"], "postprocess": (d) => new Assignment2(d[0], d[4]) },
4502
+ { "name": "function_statement$subexpression$1$ebnf$1", "symbols": ["param_list"], "postprocess": id },
4503
+ { "name": "function_statement$subexpression$1$ebnf$1", "symbols": [], "postprocess": function(d) {
4504
+ return null;
4505
+ } },
4506
+ { "name": "function_statement$subexpression$1", "symbols": [{ "literal": "(" }, "_", "function_statement$subexpression$1$ebnf$1", "_", { "literal": ")" }, "_", "statement_list"] },
4507
+ { "name": "function_statement", "symbols": ["type", "__", "variable", "function_statement$subexpression$1"], "postprocess": (d) => {
4508
+ const paramTypeList = [];
4509
+ const patternList = [];
4510
+ if (d[3][2]) {
4511
+ for (const [paramType, paramPattern] of d[3][2]) {
4512
+ paramTypeList.push(paramType);
4513
+ patternList.push(paramPattern);
4514
+ }
4515
+ }
4516
+ const signatureType = new ParameterizedType2(paramTypeList, d[0], []);
4517
+ const signature = new TypeSignature2(d[2], signatureType);
4518
+ const procedure = new Procedure2(d[2], [new Equation2(patternList, new UnguardedBody2(d[3][6]))]);
4519
+ return [signature, procedure];
4520
+ } },
4521
+ { "name": "param_list$ebnf$1", "symbols": [] },
4522
+ { "name": "param_list$ebnf$1$subexpression$1", "symbols": ["_", { "literal": "," }, "_", "param"] },
4523
+ { "name": "param_list$ebnf$1", "symbols": ["param_list$ebnf$1", "param_list$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {
4524
+ return d[0].concat([d[1]]);
4525
+ } },
4526
+ { "name": "param_list", "symbols": ["param", "param_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[1].map((x) => x[3])] },
4527
+ { "name": "param", "symbols": ["type", "__", "variable"], "postprocess": (d) => [d[0], new VariablePattern2(d[2])] },
4528
+ { "name": "expression", "symbols": ["comparison"], "postprocess": (d) => d[0] },
4529
+ { "name": "comparison", "symbols": ["addition", "_", "comparison_operator", "_", "addition"], "postprocess": (d) => new ComparisonOperation2(d[2], d[0], d[4]) },
4530
+ { "name": "comparison", "symbols": ["addition"], "postprocess": (d) => d[0] },
4531
+ { "name": "addition", "symbols": ["addition", "_", { "literal": "+" }, "_", "multiplication"], "postprocess": (d) => new ArithmeticBinaryOperation2("Plus", d[0], d[4]) },
4532
+ { "name": "addition", "symbols": ["addition", "_", { "literal": "-" }, "_", "multiplication"], "postprocess": (d) => new ArithmeticBinaryOperation2("Minus", d[0], d[4]) },
4533
+ { "name": "addition", "symbols": ["multiplication"], "postprocess": (d) => d[0] },
4534
+ { "name": "multiplication", "symbols": ["multiplication", "_", { "literal": "*" }, "_", "primary"], "postprocess": (d) => new ArithmeticBinaryOperation2("Multiply", d[0], d[4]) },
4535
+ { "name": "multiplication", "symbols": ["multiplication", "_", { "literal": "/" }, "_", "primary"], "postprocess": (d) => new ArithmeticBinaryOperation2("Divide", d[0], d[4]) },
4536
+ { "name": "multiplication", "symbols": ["primary"], "postprocess": (d) => d[0] },
4537
+ { "name": "primary", "symbols": [{ "literal": "(" }, "_", "expression", "_", { "literal": ")" }], "postprocess": (d) => d[2] },
4538
+ { "name": "primary", "symbols": ["primitive"], "postprocess": (d) => d[0] },
4539
+ { "name": "primitive", "symbols": [MiniLexer2.has("number") ? { type: "number" } : number], "postprocess": (d) => new NumberPrimitive2(Number(d[0].value)) },
4540
+ { "name": "primitive", "symbols": [MiniLexer2.has("char") ? { type: "char" } : char], "postprocess": (d) => new CharPrimitive2(d[0].value) },
4541
+ { "name": "primitive", "symbols": [MiniLexer2.has("string") ? { type: "string" } : string], "postprocess": (d) => new StringPrimitive2(d[0].value) },
4542
+ { "name": "primitive", "symbols": [MiniLexer2.has("bool") ? { type: "bool" } : bool], "postprocess": (d) => new BooleanPrimitive2(d[0].value) },
4543
+ { "name": "primitive", "symbols": ["variable"], "postprocess": (d) => d[0] },
4544
+ { "name": "primitive", "symbols": ["list_primitive"], "postprocess": (d) => d[0] },
4545
+ { "name": "type", "symbols": ["variable"], "postprocess": (d) => new SimpleType2(d[0].value, []) },
4546
+ { "name": "type", "symbols": ["type", { "literal": "[" }, { "literal": "]" }], "postprocess": (d) => new ListType2(d[0], []) },
4547
+ { "name": "list_primitive", "symbols": [{ "literal": "[" }, "_", "expression_list", "_", { "literal": "]" }], "postprocess": (d) => new ListPrimitive2(d[2]) },
4548
+ { "name": "expression_list$ebnf$1", "symbols": [] },
4549
+ { "name": "expression_list$ebnf$1$subexpression$1", "symbols": [{ "literal": "," }, "_", "expression"] },
4550
+ { "name": "expression_list$ebnf$1", "symbols": ["expression_list$ebnf$1", "expression_list$ebnf$1$subexpression$1"], "postprocess": function arrpush(d) {
4551
+ return d[0].concat([d[1]]);
4552
+ } },
4553
+ { "name": "expression_list", "symbols": ["expression", "_", "expression_list$ebnf$1"], "postprocess": (d) => [d[0], ...d[2].map((x) => x[2])] },
4554
+ { "name": "variable", "symbols": [MiniLexer2.has("variable") ? { type: "variable" } : variable], "postprocess": (d) => new SymbolPrimitive2(d[0].value) },
4555
+ { "name": "comparison_operator", "symbols": [MiniLexer2.has("equal") ? { type: "equal" } : equal], "postprocess": (d) => "Equal" },
4556
+ { "name": "comparison_operator", "symbols": [MiniLexer2.has("notEqual") ? { type: "notEqual" } : notEqual], "postprocess": (d) => "NotEqual" },
4557
+ { "name": "comparison_operator", "symbols": [MiniLexer2.has("lt") ? { type: "lt" } : lt], "postprocess": (d) => "LessThan" },
4558
+ { "name": "comparison_operator", "symbols": [MiniLexer2.has("lte") ? { type: "lte" } : lte], "postprocess": (d) => "LessOrEqualThan" },
4559
+ { "name": "comparison_operator", "symbols": [MiniLexer2.has("gt") ? { type: "gt" } : gt], "postprocess": (d) => "GreaterThan" },
4560
+ { "name": "comparison_operator", "symbols": [MiniLexer2.has("gte") ? { type: "gte" } : gte], "postprocess": (d) => "GreaterOrEqualThan" },
4561
+ { "name": "_$ebnf$1", "symbols": [] },
4562
+ { "name": "_$ebnf$1", "symbols": ["_$ebnf$1", MiniLexer2.has("WS") ? { type: "WS" } : WS], "postprocess": function arrpush(d) {
4563
+ return d[0].concat([d[1]]);
4564
+ } },
4565
+ { "name": "_", "symbols": ["_$ebnf$1"], "postprocess": (d) => null },
4566
+ { "name": "__$ebnf$1", "symbols": [MiniLexer2.has("WS") ? { type: "WS" } : WS] },
4567
+ { "name": "__$ebnf$1", "symbols": ["__$ebnf$1", MiniLexer2.has("WS") ? { type: "WS" } : WS], "postprocess": function arrpush(d) {
4568
+ return d[0].concat([d[1]]);
4569
+ } },
4570
+ { "name": "__", "symbols": ["__$ebnf$1"], "postprocess": (d) => null }
4571
+ ],
4572
+ ParserStart: "program"
4573
+ };
4574
+ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
4575
+ module.exports = grammar2;
4576
+ } else {
4577
+ window.grammar = grammar2;
4578
+ }
4579
+ })();
4580
+ }
4581
+ });
4582
+
4583
+ // src/index.ts
4584
+ var index_exports = {};
4585
+ __export(index_exports, {
4586
+ YukigoMiniParser: () => YukigoMiniParser
4587
+ });
4588
+ var import_nearley = __toESM(require_nearley(), 1);
4589
+ var import_grammar = __toESM(require_grammar(), 1);
4590
+ var UnexpectedToken = class extends Error {
4591
+ constructor(token) {
4592
+ super(
4593
+ `Parser: Unexpected '${token.type}' token '${token.value}' at line ${token.line} col ${token.col}.`
4594
+ );
4595
+ }
4596
+ };
4597
+ var YukigoMiniParser = class {
4598
+ errors = [];
4599
+ parse(code) {
4600
+ return this.feedParser(code);
4601
+ }
4602
+ parseExpression(code) {
4603
+ return this.feedParser(code);
4604
+ }
4605
+ feedParser(code) {
4606
+ const parser = new import_nearley.default.Parser(
4607
+ import_nearley.default.Grammar.fromCompiled(import_grammar.default)
4608
+ );
4609
+ try {
4610
+ parser.feed(code);
4611
+ parser.finish();
4612
+ } catch (e) {
4613
+ const error = e;
4614
+ if (error.token) {
4615
+ throw new UnexpectedToken(error.token);
4616
+ }
4617
+ throw error;
4618
+ }
4619
+ const results = parser.results;
4620
+ if (results.length > 1)
4621
+ throw Error(
4622
+ `Ambiguous grammar. The parser generated ${results.length} ASTs`
4623
+ );
4624
+ return results[0];
4625
+ }
4626
+ };
4627
+ return __toCommonJS(index_exports);
4628
+ })();