@dbml/parse 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +7 -5
- package/dist/dbml-parse.mjs +442 -437
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import I from "lodash";
|
|
2
2
|
var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
|
-
function
|
|
3
|
+
function Wt(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -12,7 +12,7 @@ function $t(t) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function rt(t) {
|
|
16
16
|
if (!t)
|
|
17
17
|
return !1;
|
|
18
18
|
switch (t) {
|
|
@@ -33,7 +33,7 @@ function it(t) {
|
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function at(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
39
|
class B {
|
|
@@ -44,27 +44,27 @@ class B {
|
|
|
44
44
|
return new B(e, n, s, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function bt(t) {
|
|
48
48
|
return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 ||
|
|
50
|
+
function ot(t, e) {
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || bt(t);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Ce(t) {
|
|
54
54
|
return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
|
-
function bt(t) {
|
|
57
|
-
return t.trailingTrivia.length === 0 ? t.end : bt(I.last(t.trailingTrivia));
|
|
58
|
-
}
|
|
59
56
|
function It(t) {
|
|
60
|
-
return t.
|
|
57
|
+
return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
|
|
61
58
|
}
|
|
62
|
-
function
|
|
59
|
+
function Lt(t) {
|
|
60
|
+
return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
|
|
61
|
+
}
|
|
62
|
+
function jt(t) {
|
|
63
63
|
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class Yt {
|
|
68
68
|
constructor() {
|
|
69
69
|
this.id = 0;
|
|
70
70
|
}
|
|
@@ -81,13 +81,13 @@ class k {
|
|
|
81
81
|
constructor(e, n, s) {
|
|
82
82
|
this.id = e, this.kind = n;
|
|
83
83
|
const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ?
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? Lt(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ?
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? It(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
@@ -151,7 +151,7 @@ class H extends k {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class Pe extends k {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
@@ -184,7 +184,7 @@ class P extends k {
|
|
|
184
184
|
}, r) {
|
|
185
185
|
super(r, "<list-expression>", [
|
|
186
186
|
e,
|
|
187
|
-
...
|
|
187
|
+
...gt(n, s),
|
|
188
188
|
i
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
@@ -198,12 +198,12 @@ class Z extends k {
|
|
|
198
198
|
}, r) {
|
|
199
199
|
super(r, "<tuple-expression>", [
|
|
200
200
|
e,
|
|
201
|
-
...
|
|
201
|
+
...gt(n, s),
|
|
202
202
|
i
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class
|
|
206
|
+
class We extends Z {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -228,7 +228,7 @@ class J extends k {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class Te extends k {
|
|
232
232
|
constructor({ literal: e }, n) {
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
@@ -243,7 +243,7 @@ class D extends k {
|
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class ke extends k {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
248
|
const s = B.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
@@ -254,7 +254,7 @@ class ce extends k {
|
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function gt(t, e) {
|
|
258
258
|
if (!t || t.length === 0)
|
|
259
259
|
return e || [];
|
|
260
260
|
if (!e || e.length === 0)
|
|
@@ -264,7 +264,7 @@ function Lt(t, e) {
|
|
|
264
264
|
(i) => i !== null
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function os(t, e = !1) {
|
|
268
268
|
return JSON.stringify(
|
|
269
269
|
t,
|
|
270
270
|
function(n, s) {
|
|
@@ -335,46 +335,46 @@ class v {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t))(m || {});
|
|
338
|
-
function
|
|
338
|
+
function je(t) {
|
|
339
339
|
return `Schema:${t}`;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function Se(t) {
|
|
342
342
|
return `Table:${t}`;
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function Ye(t) {
|
|
345
345
|
return `Column:${t}`;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function ze(t) {
|
|
348
348
|
return `Enum:${t}`;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function Qe(t) {
|
|
351
351
|
return `Enum field:${t}`;
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function qe(t) {
|
|
354
354
|
return `TableGroup:${t}`;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function He(t) {
|
|
357
357
|
return `TableGroup field:${t}`;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function zt(t) {
|
|
360
360
|
return `Note:${t}`;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function Ve(t, e) {
|
|
363
363
|
switch (e) {
|
|
364
364
|
case "Column":
|
|
365
|
-
return
|
|
365
|
+
return Ye(t);
|
|
366
366
|
case "Enum":
|
|
367
|
-
return
|
|
367
|
+
return ze(t);
|
|
368
368
|
case "Enum field":
|
|
369
|
-
return
|
|
369
|
+
return Qe(t);
|
|
370
370
|
case "Schema":
|
|
371
|
-
return
|
|
371
|
+
return je(t);
|
|
372
372
|
case "Table":
|
|
373
|
-
return
|
|
373
|
+
return Se(t);
|
|
374
374
|
case "TableGroup":
|
|
375
|
-
return
|
|
375
|
+
return qe(t);
|
|
376
376
|
case "TableGroup field":
|
|
377
|
-
return
|
|
377
|
+
return He(t);
|
|
378
378
|
default:
|
|
379
379
|
throw new Error("Unreachable");
|
|
380
380
|
}
|
|
@@ -386,49 +386,48 @@ function ie(t) {
|
|
|
386
386
|
kind: e
|
|
387
387
|
}) : new v();
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function Qt(t) {
|
|
390
390
|
const e = ie(t).unwrap_or(void 0);
|
|
391
391
|
if (!e)
|
|
392
392
|
return !1;
|
|
393
393
|
const { kind: n, name: s } = e;
|
|
394
394
|
return n === "Schema" && s === "public";
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function qt(t) {
|
|
397
397
|
return [
|
|
398
|
-
$e,
|
|
399
|
-
xe,
|
|
400
398
|
je,
|
|
399
|
+
Se,
|
|
401
400
|
ze,
|
|
402
|
-
|
|
401
|
+
qe,
|
|
403
402
|
Ye,
|
|
404
|
-
Qe
|
|
403
|
+
Qe,
|
|
404
|
+
He
|
|
405
405
|
].map((e) => e(t));
|
|
406
406
|
}
|
|
407
|
-
function
|
|
408
|
-
|
|
409
|
-
return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
|
|
407
|
+
function Ue(t) {
|
|
408
|
+
return !!t.match(/(\p{L}|_|\p{M})/gu);
|
|
410
409
|
}
|
|
411
|
-
function
|
|
410
|
+
function Oe(t) {
|
|
412
411
|
const [e] = t;
|
|
413
412
|
return e >= "0" && e <= "9";
|
|
414
413
|
}
|
|
415
|
-
function
|
|
414
|
+
function Ht(t) {
|
|
416
415
|
const [e] = t;
|
|
417
|
-
return
|
|
416
|
+
return Oe(e) || Ue(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
418
417
|
}
|
|
419
418
|
function pe(t) {
|
|
420
|
-
return
|
|
419
|
+
return Ue(t) || Oe(t);
|
|
421
420
|
}
|
|
422
|
-
function
|
|
421
|
+
function lt(t, e) {
|
|
423
422
|
const n = [], s = Math.min(t.length, e.length);
|
|
424
423
|
for (let i = 0; i < s; i += 1)
|
|
425
424
|
n.push(t[i], e[i]);
|
|
426
425
|
return n.push(...t.slice(s), ...e.slice(s)), n;
|
|
427
426
|
}
|
|
428
|
-
function
|
|
427
|
+
function ge(t, e) {
|
|
429
428
|
return t >= e.start && t < e.end;
|
|
430
429
|
}
|
|
431
|
-
class
|
|
430
|
+
class Jt {
|
|
432
431
|
constructor() {
|
|
433
432
|
this.id = 0;
|
|
434
433
|
}
|
|
@@ -439,37 +438,37 @@ class Ht {
|
|
|
439
438
|
return this.id++;
|
|
440
439
|
}
|
|
441
440
|
}
|
|
442
|
-
class
|
|
441
|
+
class _t {
|
|
443
442
|
constructor({ symbolTable: e }, n) {
|
|
444
443
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
445
444
|
}
|
|
446
445
|
}
|
|
447
|
-
class
|
|
446
|
+
class Zt {
|
|
448
447
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
449
448
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
450
449
|
}
|
|
451
450
|
}
|
|
452
|
-
class
|
|
451
|
+
class Kt {
|
|
453
452
|
constructor({ declaration: e }, n) {
|
|
454
453
|
this.references = [], this.id = n, this.declaration = e;
|
|
455
454
|
}
|
|
456
455
|
}
|
|
457
|
-
class
|
|
456
|
+
class At {
|
|
458
457
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
459
458
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
460
459
|
}
|
|
461
460
|
}
|
|
462
|
-
class
|
|
461
|
+
class en {
|
|
463
462
|
constructor({ declaration: e }, n) {
|
|
464
463
|
this.references = [], this.id = n, this.declaration = e;
|
|
465
464
|
}
|
|
466
465
|
}
|
|
467
|
-
class
|
|
466
|
+
class tn {
|
|
468
467
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
469
468
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
470
469
|
}
|
|
471
470
|
}
|
|
472
|
-
class
|
|
471
|
+
class nn {
|
|
473
472
|
constructor({ declaration: e }, n) {
|
|
474
473
|
this.references = [], this.id = n, this.declaration = e;
|
|
475
474
|
}
|
|
@@ -498,18 +497,18 @@ class F {
|
|
|
498
497
|
return new F(e(this.value), this.errors);
|
|
499
498
|
}
|
|
500
499
|
}
|
|
501
|
-
function
|
|
502
|
-
if (!t || !
|
|
500
|
+
function sn(t, e, n) {
|
|
501
|
+
if (!t || !Ne(t) || e.length === 0)
|
|
503
502
|
return new v();
|
|
504
|
-
const s = [...e], i =
|
|
503
|
+
const s = [...e], i = Ge(t).unwrap(), r = s.pop();
|
|
505
504
|
if (!(r instanceof ne))
|
|
506
505
|
return new v();
|
|
507
506
|
const a = I.last(s) instanceof P ? s.pop() : void 0;
|
|
508
|
-
return s.length === 3 &&
|
|
507
|
+
return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new S(
|
|
509
508
|
n.create(A, {
|
|
510
509
|
type: i,
|
|
511
510
|
name: s[0],
|
|
512
|
-
as:
|
|
511
|
+
as: Ge(s[1]).unwrap(),
|
|
513
512
|
alias: s[2],
|
|
514
513
|
attributeList: a,
|
|
515
514
|
body: r
|
|
@@ -529,16 +528,16 @@ function nn(t, e, n) {
|
|
|
529
528
|
})
|
|
530
529
|
) : new v();
|
|
531
530
|
}
|
|
532
|
-
function
|
|
531
|
+
function ct(t) {
|
|
533
532
|
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
534
533
|
}
|
|
535
534
|
function E(t) {
|
|
536
|
-
t && (t instanceof B ?
|
|
535
|
+
t && (t instanceof B ? rn(t) : an(t));
|
|
537
536
|
}
|
|
538
|
-
function
|
|
537
|
+
function rn(t) {
|
|
539
538
|
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
540
539
|
}
|
|
541
|
-
function
|
|
540
|
+
function an(t) {
|
|
542
541
|
if (t instanceof A)
|
|
543
542
|
E(t.type), E(t.name), E(t.as), E(t.alias), E(t.bodyColon), E(t.attributeList), E(t.body);
|
|
544
543
|
else if (t instanceof $)
|
|
@@ -549,7 +548,7 @@ function rn(t) {
|
|
|
549
548
|
E(t.op), E(t.expression);
|
|
550
549
|
else if (t instanceof H)
|
|
551
550
|
E(t.leftExpression), E(t.op), E(t.rightExpression);
|
|
552
|
-
else if (t instanceof
|
|
551
|
+
else if (t instanceof Pe)
|
|
553
552
|
E(t.op), E(t.expression);
|
|
554
553
|
else if (t instanceof ne)
|
|
555
554
|
E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
|
|
@@ -567,18 +566,18 @@ function rn(t) {
|
|
|
567
566
|
E(t.value);
|
|
568
567
|
else if (t instanceof j)
|
|
569
568
|
E(t.variable);
|
|
570
|
-
else if (t instanceof
|
|
569
|
+
else if (t instanceof Te)
|
|
571
570
|
E(t.literal);
|
|
572
571
|
else
|
|
573
|
-
throw t instanceof
|
|
572
|
+
throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
574
573
|
}
|
|
575
|
-
function
|
|
574
|
+
function vt(t) {
|
|
576
575
|
return !!(t != null && t.isInvalid);
|
|
577
576
|
}
|
|
578
577
|
function U(...t) {
|
|
579
578
|
return t.filter((e) => e !== void 0);
|
|
580
579
|
}
|
|
581
|
-
function
|
|
580
|
+
function on(t) {
|
|
582
581
|
if (t instanceof G)
|
|
583
582
|
return U(...t.body, t.eof);
|
|
584
583
|
if (t instanceof A)
|
|
@@ -595,7 +594,7 @@ function an(t) {
|
|
|
595
594
|
return U(t.name, t.colon, t.value);
|
|
596
595
|
if (t instanceof $)
|
|
597
596
|
return t.identifiers;
|
|
598
|
-
if (t instanceof
|
|
597
|
+
if (t instanceof Te)
|
|
599
598
|
return t.literal ? [t.literal] : [];
|
|
600
599
|
if (t instanceof j)
|
|
601
600
|
return U(t.variable);
|
|
@@ -603,7 +602,7 @@ function an(t) {
|
|
|
603
602
|
return U(t.op, t.expression);
|
|
604
603
|
if (t instanceof H)
|
|
605
604
|
return U(t.leftExpression, t.op, t.rightExpression);
|
|
606
|
-
if (t instanceof
|
|
605
|
+
if (t instanceof Pe)
|
|
607
606
|
return U(t.expression, t.op);
|
|
608
607
|
if (t instanceof te)
|
|
609
608
|
return U(t.value);
|
|
@@ -614,13 +613,13 @@ function an(t) {
|
|
|
614
613
|
if (t instanceof P)
|
|
615
614
|
return U(
|
|
616
615
|
t.listOpenBracket,
|
|
617
|
-
...
|
|
616
|
+
...lt(t.elementList, t.commaList),
|
|
618
617
|
t.listCloseBracket
|
|
619
618
|
);
|
|
620
619
|
if (t instanceof Z)
|
|
621
620
|
return U(
|
|
622
621
|
t.tupleOpenParen,
|
|
623
|
-
...
|
|
622
|
+
...lt(t.elementList, t.commaList),
|
|
624
623
|
t.tupleCloseParen
|
|
625
624
|
);
|
|
626
625
|
if (t instanceof J)
|
|
@@ -632,33 +631,33 @@ function an(t) {
|
|
|
632
631
|
t.array,
|
|
633
632
|
t.indexer
|
|
634
633
|
);
|
|
635
|
-
throw t instanceof
|
|
634
|
+
throw t instanceof We ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
636
635
|
}
|
|
637
|
-
function
|
|
636
|
+
function Ge(t) {
|
|
638
637
|
return M(t) ? new S(t.expression.variable) : new v();
|
|
639
638
|
}
|
|
640
639
|
function Y(t) {
|
|
641
640
|
var e;
|
|
642
|
-
return t instanceof D && (t.expression instanceof j && t.expression.variable instanceof B && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof
|
|
641
|
+
return t instanceof D && (t.expression instanceof j && t.expression.variable instanceof B && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof Te && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
643
642
|
}
|
|
644
643
|
function M(t) {
|
|
645
644
|
return t instanceof D && t.expression instanceof j && t.expression.variable instanceof B;
|
|
646
645
|
}
|
|
647
|
-
function
|
|
646
|
+
function Ne(t) {
|
|
648
647
|
var e;
|
|
649
648
|
return t instanceof D && t.expression instanceof j && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
650
649
|
}
|
|
651
|
-
function
|
|
650
|
+
function Je(t) {
|
|
652
651
|
var e;
|
|
653
652
|
return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
654
653
|
}
|
|
655
|
-
function
|
|
654
|
+
function me(t) {
|
|
656
655
|
if (t === void 0)
|
|
657
656
|
return new v();
|
|
658
657
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
659
658
|
return e === "" ? new v() : new S(e);
|
|
660
659
|
}
|
|
661
|
-
class
|
|
660
|
+
class ln {
|
|
662
661
|
// list of errors during lexing
|
|
663
662
|
constructor(e) {
|
|
664
663
|
this.start = {
|
|
@@ -768,15 +767,15 @@ class on {
|
|
|
768
767
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
|
|
769
768
|
break;
|
|
770
769
|
default:
|
|
771
|
-
if (
|
|
770
|
+
if (rt(e)) {
|
|
772
771
|
this.operator();
|
|
773
772
|
break;
|
|
774
773
|
}
|
|
775
|
-
if (
|
|
774
|
+
if (Ue(e)) {
|
|
776
775
|
this.identifier();
|
|
777
776
|
break;
|
|
778
777
|
}
|
|
779
|
-
if (
|
|
778
|
+
if (Oe(e)) {
|
|
780
779
|
this.numericLiteralOrIdentifier();
|
|
781
780
|
break;
|
|
782
781
|
}
|
|
@@ -796,13 +795,13 @@ class on {
|
|
|
796
795
|
let e = !0, n = [], s;
|
|
797
796
|
const i = [];
|
|
798
797
|
for (const r of this.tokens)
|
|
799
|
-
|
|
798
|
+
Wt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
|
|
800
799
|
this.tokens = i;
|
|
801
800
|
}
|
|
802
801
|
gatherInvalid() {
|
|
803
802
|
let e;
|
|
804
803
|
const n = [], s = [];
|
|
805
|
-
for (e = 0; e < this.tokens.length &&
|
|
804
|
+
for (e = 0; e < this.tokens.length && vt(this.tokens[e]); e += 1)
|
|
806
805
|
s.push(this.tokens[e]);
|
|
807
806
|
let i = this.tokens[e];
|
|
808
807
|
for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
@@ -896,7 +895,7 @@ class on {
|
|
|
896
895
|
this.addToken(u.IDENTIFIER);
|
|
897
896
|
}
|
|
898
897
|
operator() {
|
|
899
|
-
for (;
|
|
898
|
+
for (; rt(this.peek()); )
|
|
900
899
|
this.advance();
|
|
901
900
|
this.addToken(u.OP);
|
|
902
901
|
}
|
|
@@ -913,7 +912,7 @@ class on {
|
|
|
913
912
|
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
914
913
|
if (!n && !pe(this.peek()))
|
|
915
914
|
return this.addToken(u.NUMERIC_LITERAL);
|
|
916
|
-
if (!n && !
|
|
915
|
+
if (!n && !Oe(this.peek()))
|
|
917
916
|
break;
|
|
918
917
|
this.advance();
|
|
919
918
|
}
|
|
@@ -973,8 +972,8 @@ class on {
|
|
|
973
972
|
}
|
|
974
973
|
}
|
|
975
974
|
}
|
|
976
|
-
var
|
|
977
|
-
class
|
|
975
|
+
var xe = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(xe || {});
|
|
976
|
+
class cn {
|
|
978
977
|
constructor() {
|
|
979
978
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
980
979
|
}
|
|
@@ -1040,7 +1039,7 @@ class ln {
|
|
|
1040
1039
|
}
|
|
1041
1040
|
}
|
|
1042
1041
|
}
|
|
1043
|
-
class
|
|
1042
|
+
class un {
|
|
1044
1043
|
constructor(e) {
|
|
1045
1044
|
this.generator = e;
|
|
1046
1045
|
}
|
|
@@ -1053,15 +1052,15 @@ class d {
|
|
|
1053
1052
|
this.token = e, this.partialNode = n, this.handlerContext = s;
|
|
1054
1053
|
}
|
|
1055
1054
|
}
|
|
1056
|
-
class
|
|
1055
|
+
class hn {
|
|
1057
1056
|
constructor(e, n) {
|
|
1058
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1057
|
+
this.current = 0, this.errors = [], this.contextStack = new cn(), this.synchronizeProgram = () => {
|
|
1059
1058
|
const s = this.peek();
|
|
1060
1059
|
s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1061
1060
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1062
1061
|
for (; !this.isAtEnd(); ) {
|
|
1063
1062
|
const s = this.peek();
|
|
1064
|
-
if (
|
|
1063
|
+
if (ct(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1065
1064
|
break;
|
|
1066
1065
|
E(s), this.advance();
|
|
1067
1066
|
}
|
|
@@ -1072,7 +1071,7 @@ class un {
|
|
|
1072
1071
|
break;
|
|
1073
1072
|
E(s), this.advance();
|
|
1074
1073
|
}
|
|
1075
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1074
|
+
}, this.blockExpression = this.contextStack.withContextDo(xe.BlockExpression, () => {
|
|
1076
1075
|
const s = { body: [] }, i = () => this.nodeFactory.create(ne, s);
|
|
1077
1076
|
try {
|
|
1078
1077
|
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
@@ -1107,12 +1106,12 @@ class un {
|
|
|
1107
1106
|
if (!this.check(u.RBRACE))
|
|
1108
1107
|
for (E(this.advance()); !this.isAtEnd(); ) {
|
|
1109
1108
|
const s = this.peek();
|
|
1110
|
-
if (this.check(u.RBRACE) ||
|
|
1109
|
+
if (this.check(u.RBRACE) || ot(this.previous(), s))
|
|
1111
1110
|
break;
|
|
1112
1111
|
E(s), this.advance();
|
|
1113
1112
|
}
|
|
1114
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1115
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1113
|
+
}, this.tupleExpression = this.contextStack.withContextDo(xe.GroupExpression, () => {
|
|
1114
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(We, {
|
|
1116
1115
|
groupOpenParen: s.tupleOpenParen,
|
|
1117
1116
|
groupCloseParen: s.tupleCloseParen,
|
|
1118
1117
|
expression: s.elementList[0]
|
|
@@ -1163,7 +1162,7 @@ class un {
|
|
|
1163
1162
|
break;
|
|
1164
1163
|
E(s), this.advance();
|
|
1165
1164
|
}
|
|
1166
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
1165
|
+
}, this.listExpression = this.contextStack.withContextDo(xe.ListExpression, () => {
|
|
1167
1166
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(P, s);
|
|
1168
1167
|
try {
|
|
1169
1168
|
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
@@ -1225,7 +1224,7 @@ class un {
|
|
|
1225
1224
|
break;
|
|
1226
1225
|
E(s), this.advance();
|
|
1227
1226
|
}
|
|
1228
|
-
}, this.tokens = e, this.nodeFactory = new
|
|
1227
|
+
}, this.tokens = e, this.nodeFactory = new un(n);
|
|
1229
1228
|
}
|
|
1230
1229
|
isAtEnd() {
|
|
1231
1230
|
return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
|
|
@@ -1316,7 +1315,7 @@ class un {
|
|
|
1316
1315
|
throw new d(s.token, n(), s.handlerContext);
|
|
1317
1316
|
this.synchronizeElementDeclarationName();
|
|
1318
1317
|
}
|
|
1319
|
-
if (
|
|
1318
|
+
if (ct(this.peek()))
|
|
1320
1319
|
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1321
1320
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1322
1321
|
else
|
|
@@ -1380,7 +1379,7 @@ class un {
|
|
|
1380
1379
|
}
|
|
1381
1380
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1382
1381
|
expression() {
|
|
1383
|
-
const e = { args: [] }, n = () =>
|
|
1382
|
+
const e = { args: [] }, n = () => sn(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1384
1383
|
this.nodeFactory.create(w, e)
|
|
1385
1384
|
);
|
|
1386
1385
|
try {
|
|
@@ -1392,7 +1391,7 @@ class un {
|
|
|
1392
1391
|
return n();
|
|
1393
1392
|
let s = e.callee;
|
|
1394
1393
|
for (; !this.shouldStopExpression(); ) {
|
|
1395
|
-
|
|
1394
|
+
Ce(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
|
|
1396
1395
|
try {
|
|
1397
1396
|
s = this.normalExpression(), e.args.push(s);
|
|
1398
1397
|
} catch (i) {
|
|
@@ -1402,7 +1401,7 @@ class un {
|
|
|
1402
1401
|
return n();
|
|
1403
1402
|
}
|
|
1404
1403
|
shouldStopExpression() {
|
|
1405
|
-
if (this.isAtEnd() ||
|
|
1404
|
+
if (this.isAtEnd() || bt(this.previous()))
|
|
1406
1405
|
return !0;
|
|
1407
1406
|
const e = this.peek().kind;
|
|
1408
1407
|
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
@@ -1416,12 +1415,12 @@ class un {
|
|
|
1416
1415
|
for (; !this.isAtEnd(); ) {
|
|
1417
1416
|
const s = this.peek();
|
|
1418
1417
|
if (s.kind === u.LPAREN) {
|
|
1419
|
-
const { left: i } =
|
|
1418
|
+
const { left: i } = ut(s);
|
|
1420
1419
|
if (i < e || // When '(' is encountered,
|
|
1421
1420
|
// consider it part of another expression if
|
|
1422
1421
|
// it's at the start of a new line
|
|
1423
1422
|
// and we're currently not having unmatched '(' or '['
|
|
1424
|
-
|
|
1423
|
+
ot(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1425
1424
|
break;
|
|
1426
1425
|
try {
|
|
1427
1426
|
n = this.nodeFactory.create(J, {
|
|
@@ -1435,7 +1434,7 @@ class un {
|
|
|
1435
1434
|
}), new d(r.token, n, r.handlerContext)) : r;
|
|
1436
1435
|
}
|
|
1437
1436
|
} else if (s.kind === u.LBRACKET) {
|
|
1438
|
-
if (
|
|
1437
|
+
if (Ce(this.previous()))
|
|
1439
1438
|
break;
|
|
1440
1439
|
try {
|
|
1441
1440
|
n = this.nodeFactory.create(ce, {
|
|
@@ -1448,17 +1447,17 @@ class un {
|
|
|
1448
1447
|
indexer: i.partialNode
|
|
1449
1448
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
1450
1449
|
}
|
|
1451
|
-
} else if (
|
|
1452
|
-
const i = s, r =
|
|
1450
|
+
} else if (at(s)) {
|
|
1451
|
+
const i = s, r = ut(i);
|
|
1453
1452
|
if (r.left !== null) {
|
|
1454
1453
|
if (r.left <= e)
|
|
1455
1454
|
break;
|
|
1456
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1455
|
+
this.advance(), n = this.nodeFactory.create(Pe, {
|
|
1457
1456
|
expression: n,
|
|
1458
1457
|
op: i
|
|
1459
1458
|
});
|
|
1460
1459
|
} else {
|
|
1461
|
-
const a =
|
|
1460
|
+
const a = pn(i);
|
|
1462
1461
|
if (a.left === null || a.left <= e)
|
|
1463
1462
|
break;
|
|
1464
1463
|
this.advance();
|
|
@@ -1483,10 +1482,10 @@ class un {
|
|
|
1483
1482
|
}
|
|
1484
1483
|
leftExpression_bp() {
|
|
1485
1484
|
let e;
|
|
1486
|
-
if (
|
|
1485
|
+
if (at(this.peek())) {
|
|
1487
1486
|
const n = {};
|
|
1488
1487
|
n.op = this.peek();
|
|
1489
|
-
const s =
|
|
1488
|
+
const s = En(n.op);
|
|
1490
1489
|
if (s.right === null)
|
|
1491
1490
|
throw this.logError(
|
|
1492
1491
|
n.op,
|
|
@@ -1494,7 +1493,7 @@ class un {
|
|
|
1494
1493
|
`Unexpected '${n.op.value}' in an expression`
|
|
1495
1494
|
), new d(
|
|
1496
1495
|
n.op,
|
|
1497
|
-
this.nodeFactory.create(
|
|
1496
|
+
this.nodeFactory.create(ke, { pre: n.op }),
|
|
1498
1497
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1499
1498
|
);
|
|
1500
1499
|
this.advance();
|
|
@@ -1508,10 +1507,10 @@ class un {
|
|
|
1508
1507
|
)) : i;
|
|
1509
1508
|
}
|
|
1510
1509
|
e = this.nodeFactory.create(q, n);
|
|
1511
|
-
} else if (e = this.extractOperand(), e instanceof
|
|
1510
|
+
} else if (e = this.extractOperand(), e instanceof ke)
|
|
1512
1511
|
throw new d(
|
|
1513
1512
|
this.peek(),
|
|
1514
|
-
this.nodeFactory.create(
|
|
1513
|
+
this.nodeFactory.create(ke, { pre: this.peek() }),
|
|
1515
1514
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1516
1515
|
);
|
|
1517
1516
|
return e;
|
|
@@ -1535,7 +1534,7 @@ class un {
|
|
|
1535
1534
|
this.peek(),
|
|
1536
1535
|
o.INVALID_OPERAND,
|
|
1537
1536
|
`Invalid start of operand "${this.peek().value}"`
|
|
1538
|
-
), this.nodeFactory.create(
|
|
1537
|
+
), this.nodeFactory.create(ke, { pre: this.previous() }));
|
|
1539
1538
|
}
|
|
1540
1539
|
/* Parsing FunctionExpression */
|
|
1541
1540
|
functionExpression() {
|
|
@@ -1562,7 +1561,7 @@ class un {
|
|
|
1562
1561
|
u.NUMERIC_LITERAL
|
|
1563
1562
|
))
|
|
1564
1563
|
return this.nodeFactory.create(D, {
|
|
1565
|
-
expression: this.nodeFactory.create(
|
|
1564
|
+
expression: this.nodeFactory.create(Te, { literal: this.previous() })
|
|
1566
1565
|
});
|
|
1567
1566
|
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1568
1567
|
return this.nodeFactory.create(D, {
|
|
@@ -1632,7 +1631,7 @@ class un {
|
|
|
1632
1631
|
this.errors.push(new c(n, s, e));
|
|
1633
1632
|
}
|
|
1634
1633
|
}
|
|
1635
|
-
const
|
|
1634
|
+
const fn = {
|
|
1636
1635
|
"+": { left: 9, right: 10 },
|
|
1637
1636
|
"*": { left: 11, right: 12 },
|
|
1638
1637
|
"-": { left: 9, right: 10 },
|
|
@@ -1648,10 +1647,10 @@ const hn = {
|
|
|
1648
1647
|
"!=": { left: 4, right: 5 },
|
|
1649
1648
|
".": { left: 16, right: 17 }
|
|
1650
1649
|
};
|
|
1651
|
-
function
|
|
1652
|
-
return
|
|
1650
|
+
function pn(t) {
|
|
1651
|
+
return fn[t.value] || { left: null, right: null };
|
|
1653
1652
|
}
|
|
1654
|
-
const
|
|
1653
|
+
const dn = {
|
|
1655
1654
|
"+": { left: null, right: 15 },
|
|
1656
1655
|
"-": { left: null, right: 15 },
|
|
1657
1656
|
"<": { left: null, right: 15 },
|
|
@@ -1659,17 +1658,17 @@ const pn = {
|
|
|
1659
1658
|
"<>": { left: null, right: 15 },
|
|
1660
1659
|
"!": { left: null, right: 15 }
|
|
1661
1660
|
};
|
|
1662
|
-
function
|
|
1663
|
-
return
|
|
1661
|
+
function En(t) {
|
|
1662
|
+
return dn[t.value] || { left: null, right: null };
|
|
1664
1663
|
}
|
|
1665
|
-
const
|
|
1664
|
+
const Nn = {
|
|
1666
1665
|
"(": { left: 14, right: null }
|
|
1667
1666
|
};
|
|
1668
|
-
function
|
|
1669
|
-
return
|
|
1667
|
+
function ut(t) {
|
|
1668
|
+
return Nn[t.value] || { left: null, right: null };
|
|
1670
1669
|
}
|
|
1671
1670
|
var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
|
|
1672
|
-
function
|
|
1671
|
+
function ve(t) {
|
|
1673
1672
|
var n;
|
|
1674
1673
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1675
1674
|
switch (e) {
|
|
@@ -1686,7 +1685,7 @@ function Ae(t) {
|
|
|
1686
1685
|
}
|
|
1687
1686
|
}
|
|
1688
1687
|
function he(t) {
|
|
1689
|
-
if (!
|
|
1688
|
+
if (!Je(t))
|
|
1690
1689
|
return new S([t]);
|
|
1691
1690
|
const e = he(t.leftExpression).unwrap_or(void 0);
|
|
1692
1691
|
return e ? (e.push(t.rightExpression), new S(e)) : new v();
|
|
@@ -1706,7 +1705,7 @@ function C(t) {
|
|
|
1706
1705
|
}
|
|
1707
1706
|
return new S(n);
|
|
1708
1707
|
}
|
|
1709
|
-
function
|
|
1708
|
+
function _e(t) {
|
|
1710
1709
|
if (t === void 0)
|
|
1711
1710
|
return new v();
|
|
1712
1711
|
const e = he(t).unwrap_or(void 0);
|
|
@@ -1716,7 +1715,7 @@ function ge(t) {
|
|
|
1716
1715
|
let s;
|
|
1717
1716
|
if (!M(I.last(e))) {
|
|
1718
1717
|
const i = e.pop();
|
|
1719
|
-
if (
|
|
1718
|
+
if (kt(i))
|
|
1720
1719
|
s = i.elementList.map(
|
|
1721
1720
|
(r) => V(r).unwrap()
|
|
1722
1721
|
);
|
|
@@ -1737,10 +1736,10 @@ function ge(t) {
|
|
|
1737
1736
|
function X(t) {
|
|
1738
1737
|
return M(t) ? new S(t.expression.variable.value) : new v();
|
|
1739
1738
|
}
|
|
1740
|
-
function
|
|
1741
|
-
if (
|
|
1739
|
+
function Xe(t) {
|
|
1740
|
+
if (ht(t))
|
|
1742
1741
|
return t instanceof te ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1743
|
-
if (t instanceof Z && t.elementList.every(
|
|
1742
|
+
if (t instanceof Z && t.elementList.every(ht)) {
|
|
1744
1743
|
const e = t.elementList.filter(
|
|
1745
1744
|
(s) => s instanceof te
|
|
1746
1745
|
), n = t.elementList.filter(M);
|
|
@@ -1756,24 +1755,24 @@ function V(t) {
|
|
|
1756
1755
|
function Q(t) {
|
|
1757
1756
|
return Y(t) ? t.expression instanceof j ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new v();
|
|
1758
1757
|
}
|
|
1759
|
-
function
|
|
1758
|
+
function mn(t) {
|
|
1760
1759
|
var e;
|
|
1761
|
-
return !(t instanceof H) || !
|
|
1760
|
+
return !(t instanceof H) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1762
1761
|
}
|
|
1763
|
-
function
|
|
1764
|
-
const e =
|
|
1762
|
+
function Tn(t) {
|
|
1763
|
+
const e = _e(t.leftExpression), n = _e(t.rightExpression);
|
|
1765
1764
|
if (!e.isOk() || !n.isOk())
|
|
1766
1765
|
return !1;
|
|
1767
1766
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1768
1767
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1769
1768
|
}
|
|
1770
|
-
function
|
|
1769
|
+
function ht(t) {
|
|
1771
1770
|
return t instanceof D && t.expression instanceof j || t instanceof te;
|
|
1772
1771
|
}
|
|
1773
|
-
function
|
|
1772
|
+
function bn(t, e) {
|
|
1774
1773
|
var i, r, a, l;
|
|
1775
1774
|
let n = e;
|
|
1776
|
-
const s =
|
|
1775
|
+
const s = Qt(t);
|
|
1777
1776
|
for (; n; ) {
|
|
1778
1777
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1779
1778
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
@@ -1784,7 +1783,7 @@ function Tn(t, e) {
|
|
|
1784
1783
|
n = n.parent;
|
|
1785
1784
|
}
|
|
1786
1785
|
}
|
|
1787
|
-
class
|
|
1786
|
+
class In {
|
|
1788
1787
|
constructor(e, n, s) {
|
|
1789
1788
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1790
1789
|
}
|
|
@@ -1792,7 +1791,7 @@ class bn {
|
|
|
1792
1791
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1793
1792
|
}
|
|
1794
1793
|
validateContext() {
|
|
1795
|
-
return this.declarationNode.parent instanceof G ||
|
|
1794
|
+
return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1796
1795
|
}
|
|
1797
1796
|
validateName(e) {
|
|
1798
1797
|
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1812,7 +1811,7 @@ class bn {
|
|
|
1812
1811
|
return Y(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1813
1812
|
}
|
|
1814
1813
|
}
|
|
1815
|
-
class
|
|
1814
|
+
class we {
|
|
1816
1815
|
constructor() {
|
|
1817
1816
|
this.table = /* @__PURE__ */ new Map();
|
|
1818
1817
|
}
|
|
@@ -1829,7 +1828,7 @@ class ve {
|
|
|
1829
1828
|
return this.table.entries();
|
|
1830
1829
|
}
|
|
1831
1830
|
}
|
|
1832
|
-
class
|
|
1831
|
+
class Ln {
|
|
1833
1832
|
constructor(e, n, s) {
|
|
1834
1833
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1835
1834
|
}
|
|
@@ -1840,17 +1839,17 @@ class In {
|
|
|
1840
1839
|
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1841
1840
|
}
|
|
1842
1841
|
validateName(e) {
|
|
1843
|
-
return e ?
|
|
1842
|
+
return e ? Ze(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
1844
1843
|
}
|
|
1845
1844
|
validateAlias(e) {
|
|
1846
1845
|
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1847
1846
|
}
|
|
1848
1847
|
registerElement() {
|
|
1849
1848
|
const e = [];
|
|
1850
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1849
|
+
this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new we() });
|
|
1851
1850
|
const { name: n } = this.declarationNode, s = C(n);
|
|
1852
1851
|
if (s.isOk()) {
|
|
1853
|
-
const i = s.unwrap(), r = i.pop(), a =
|
|
1852
|
+
const i = s.unwrap(), r = i.pop(), a = Ke(i, this.publicSymbolTable, this.symbolFactory), l = ze(r);
|
|
1854
1853
|
a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
|
|
1855
1854
|
}
|
|
1856
1855
|
return e;
|
|
@@ -1900,7 +1899,7 @@ class In {
|
|
|
1900
1899
|
}
|
|
1901
1900
|
registerField(e) {
|
|
1902
1901
|
if (e.callee && M(e.callee)) {
|
|
1903
|
-
const n = V(e.callee).unwrap(), s =
|
|
1902
|
+
const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(Kt, { declaration: e });
|
|
1904
1903
|
e.symbol = i;
|
|
1905
1904
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1906
1905
|
if (r.has(s)) {
|
|
@@ -1915,7 +1914,7 @@ class In {
|
|
|
1915
1914
|
return [];
|
|
1916
1915
|
}
|
|
1917
1916
|
}
|
|
1918
|
-
class
|
|
1917
|
+
class gn {
|
|
1919
1918
|
constructor(e, n, s) {
|
|
1920
1919
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1921
1920
|
}
|
|
@@ -1923,7 +1922,7 @@ class Ln {
|
|
|
1923
1922
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1924
1923
|
}
|
|
1925
1924
|
validateContext() {
|
|
1926
|
-
return this.declarationNode.parent instanceof G ||
|
|
1925
|
+
return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1927
1926
|
}
|
|
1928
1927
|
validateName(e) {
|
|
1929
1928
|
return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
@@ -1949,8 +1948,8 @@ class Ln {
|
|
|
1949
1948
|
const s = [], i = [n.callee, ...n.args];
|
|
1950
1949
|
return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1951
1950
|
for (; r instanceof J; )
|
|
1952
|
-
r.argumentList && !
|
|
1953
|
-
|
|
1951
|
+
r.argumentList && !Xe(r.argumentList).isOk() && s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
|
|
1952
|
+
Xe(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
1954
1953
|
}), s;
|
|
1955
1954
|
});
|
|
1956
1955
|
}
|
|
@@ -1991,7 +1990,7 @@ class Ln {
|
|
|
1991
1990
|
});
|
|
1992
1991
|
}
|
|
1993
1992
|
}
|
|
1994
|
-
class
|
|
1993
|
+
class _n {
|
|
1995
1994
|
constructor(e, n, s) {
|
|
1996
1995
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1997
1996
|
}
|
|
@@ -1999,7 +1998,7 @@ class gn {
|
|
|
1999
1998
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2000
1999
|
}
|
|
2001
2000
|
validateContext() {
|
|
2002
|
-
return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(
|
|
2001
|
+
return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
|
|
2003
2002
|
}
|
|
2004
2003
|
validateName(e) {
|
|
2005
2004
|
if (!(this.declarationNode.parent instanceof G))
|
|
@@ -2009,7 +2008,7 @@ class gn {
|
|
|
2009
2008
|
const n = C(e);
|
|
2010
2009
|
if (!n.isOk())
|
|
2011
2010
|
return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2012
|
-
const i = n.unwrap().join("."), r =
|
|
2011
|
+
const i = n.unwrap().join("."), r = zt(i);
|
|
2013
2012
|
return this.publicSymbolTable.has(r) ? [new c(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
|
|
2014
2013
|
}
|
|
2015
2014
|
validateAlias(e) {
|
|
@@ -2039,7 +2038,7 @@ class gn {
|
|
|
2039
2038
|
});
|
|
2040
2039
|
}
|
|
2041
2040
|
}
|
|
2042
|
-
class
|
|
2041
|
+
class An {
|
|
2043
2042
|
constructor(e, n, s) {
|
|
2044
2043
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2045
2044
|
}
|
|
@@ -2050,7 +2049,7 @@ class _n {
|
|
|
2050
2049
|
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2051
2050
|
}
|
|
2052
2051
|
validateName(e) {
|
|
2053
|
-
return e ?
|
|
2052
|
+
return e ? Me(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2054
2053
|
}
|
|
2055
2054
|
validateAlias(e) {
|
|
2056
2055
|
return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
@@ -2078,7 +2077,7 @@ class _n {
|
|
|
2078
2077
|
});
|
|
2079
2078
|
}
|
|
2080
2079
|
}
|
|
2081
|
-
class
|
|
2080
|
+
class vn {
|
|
2082
2081
|
constructor(e, n, s) {
|
|
2083
2082
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2084
2083
|
}
|
|
@@ -2089,7 +2088,7 @@ class An {
|
|
|
2089
2088
|
return this.declarationNode.parent instanceof G ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2090
2089
|
}
|
|
2091
2090
|
validateName(e) {
|
|
2092
|
-
return e ?
|
|
2091
|
+
return e ? Me(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2093
2092
|
}
|
|
2094
2093
|
validateAlias(e) {
|
|
2095
2094
|
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
@@ -2110,7 +2109,7 @@ class An {
|
|
|
2110
2109
|
return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2111
2110
|
const n = [];
|
|
2112
2111
|
return e.length > 1 && n.push(...e.slice(1).map((s) => new c(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2113
|
-
s.callee && !
|
|
2112
|
+
s.callee && !mn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Tn(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2114
2113
|
const i = [...s.args];
|
|
2115
2114
|
I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2116
2115
|
}), n;
|
|
@@ -2123,7 +2122,7 @@ class An {
|
|
|
2123
2122
|
case "delete":
|
|
2124
2123
|
case "update":
|
|
2125
2124
|
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
2126
|
-
|
|
2125
|
+
wn(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
|
|
2127
2126
|
});
|
|
2128
2127
|
break;
|
|
2129
2128
|
default:
|
|
@@ -2141,11 +2140,11 @@ class An {
|
|
|
2141
2140
|
});
|
|
2142
2141
|
}
|
|
2143
2142
|
}
|
|
2144
|
-
function
|
|
2143
|
+
function wn(t) {
|
|
2145
2144
|
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
|
|
2146
2145
|
return !1;
|
|
2147
2146
|
let e;
|
|
2148
|
-
if (t instanceof $ ? e =
|
|
2147
|
+
if (t instanceof $ ? e = me(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2149
2148
|
switch (e.toLowerCase()) {
|
|
2150
2149
|
case "cascade":
|
|
2151
2150
|
case "no action":
|
|
@@ -2158,7 +2157,7 @@ function vn(t) {
|
|
|
2158
2157
|
}
|
|
2159
2158
|
return !1;
|
|
2160
2159
|
}
|
|
2161
|
-
class
|
|
2160
|
+
class yn {
|
|
2162
2161
|
constructor(e, n, s) {
|
|
2163
2162
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2164
2163
|
}
|
|
@@ -2169,10 +2168,10 @@ class wn {
|
|
|
2169
2168
|
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2170
2169
|
}
|
|
2171
2170
|
validateName(e) {
|
|
2172
|
-
return e ? e instanceof ce ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] :
|
|
2171
|
+
return e ? e instanceof ce ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Ze(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2173
2172
|
}
|
|
2174
2173
|
validateAlias(e) {
|
|
2175
|
-
return e ?
|
|
2174
|
+
return e ? On(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2176
2175
|
}
|
|
2177
2176
|
validateSettingList(e) {
|
|
2178
2177
|
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
@@ -2181,7 +2180,7 @@ class wn {
|
|
|
2181
2180
|
switch (r) {
|
|
2182
2181
|
case "headercolor":
|
|
2183
2182
|
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
|
|
2184
|
-
|
|
2183
|
+
Rn(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
|
|
2185
2184
|
});
|
|
2186
2185
|
break;
|
|
2187
2186
|
case "note":
|
|
@@ -2197,14 +2196,14 @@ class wn {
|
|
|
2197
2196
|
}
|
|
2198
2197
|
registerElement() {
|
|
2199
2198
|
const e = [];
|
|
2200
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2199
|
+
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2201
2200
|
const { name: n, alias: s } = this.declarationNode, i = C(n);
|
|
2202
2201
|
if (i.isOk()) {
|
|
2203
|
-
const r = [...i.unwrap()], a = r.pop(), l =
|
|
2202
|
+
const r = [...i.unwrap()], a = r.pop(), l = Ke(r, this.publicSymbolTable, this.symbolFactory), p = Se(a);
|
|
2204
2203
|
l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
|
|
2205
2204
|
}
|
|
2206
|
-
if (s &&
|
|
2207
|
-
const r = V(s).unwrap(), a =
|
|
2205
|
+
if (s && Me(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2206
|
+
const r = V(s).unwrap(), a = Se(r);
|
|
2208
2207
|
this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2209
2208
|
}
|
|
2210
2209
|
return e;
|
|
@@ -2222,14 +2221,14 @@ class wn {
|
|
|
2222
2221
|
if (!n.callee)
|
|
2223
2222
|
return [];
|
|
2224
2223
|
const s = [];
|
|
2225
|
-
n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !
|
|
2224
|
+
n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !kn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2226
2225
|
const i = n.args.slice(1);
|
|
2227
2226
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2228
2227
|
});
|
|
2229
2228
|
}
|
|
2230
2229
|
registerField(e) {
|
|
2231
2230
|
if (e.callee && M(e.callee)) {
|
|
2232
|
-
const n = V(e.callee).unwrap(), s =
|
|
2231
|
+
const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(en, { declaration: e });
|
|
2233
2232
|
e.symbol = i;
|
|
2234
2233
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2235
2234
|
if (r.has(s)) {
|
|
@@ -2245,7 +2244,7 @@ class wn {
|
|
|
2245
2244
|
}
|
|
2246
2245
|
// This is needed to support legacy inline settings
|
|
2247
2246
|
validateFieldSetting(e) {
|
|
2248
|
-
if (!e.slice(0, -1).every(
|
|
2247
|
+
if (!e.slice(0, -1).every(Ne) || !e.slice(-1).every((p) => Ne(p) || p instanceof P))
|
|
2249
2248
|
return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2250
2249
|
if (e.length === 0)
|
|
2251
2250
|
return [];
|
|
@@ -2272,7 +2271,7 @@ class wn {
|
|
|
2272
2271
|
break;
|
|
2273
2272
|
case "ref":
|
|
2274
2273
|
h.forEach((f) => {
|
|
2275
|
-
|
|
2274
|
+
Pn(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
|
|
2276
2275
|
});
|
|
2277
2276
|
break;
|
|
2278
2277
|
case "primary key":
|
|
@@ -2309,7 +2308,7 @@ class wn {
|
|
|
2309
2308
|
break;
|
|
2310
2309
|
case "default":
|
|
2311
2310
|
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
|
|
2312
|
-
|
|
2311
|
+
Dn(f.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
|
|
2313
2312
|
});
|
|
2314
2313
|
break;
|
|
2315
2314
|
default:
|
|
@@ -2331,11 +2330,11 @@ class wn {
|
|
|
2331
2330
|
return s.length > 1 && (n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
|
|
2332
2331
|
}
|
|
2333
2332
|
}
|
|
2334
|
-
function
|
|
2335
|
-
if (!(t instanceof J ||
|
|
2333
|
+
function kn(t) {
|
|
2334
|
+
if (!(t instanceof J || Je(t) || t instanceof D || t instanceof ce))
|
|
2336
2335
|
return !1;
|
|
2337
2336
|
if (t instanceof J) {
|
|
2338
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || Y(n) ||
|
|
2337
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || Y(n) || Ne(n)))
|
|
2339
2338
|
return !1;
|
|
2340
2339
|
t = t.callee;
|
|
2341
2340
|
}
|
|
@@ -2347,10 +2346,10 @@ function yn(t) {
|
|
|
2347
2346
|
const e = C(t).unwrap_or(void 0);
|
|
2348
2347
|
return e !== void 0 && e.length > 0;
|
|
2349
2348
|
}
|
|
2350
|
-
function
|
|
2349
|
+
function xn(t, e) {
|
|
2351
2350
|
return e.length === 1 && t === e[0];
|
|
2352
2351
|
}
|
|
2353
|
-
class
|
|
2352
|
+
class Sn {
|
|
2354
2353
|
constructor(e, n, s) {
|
|
2355
2354
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2356
2355
|
}
|
|
@@ -2361,17 +2360,17 @@ class xn {
|
|
|
2361
2360
|
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
2362
2361
|
}
|
|
2363
2362
|
validateName(e) {
|
|
2364
|
-
return e ?
|
|
2363
|
+
return e ? Ze(e) ? [] : [new c(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new c(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
2365
2364
|
}
|
|
2366
2365
|
validateAlias(e) {
|
|
2367
2366
|
return e ? [new c(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
|
|
2368
2367
|
}
|
|
2369
2368
|
registerElement() {
|
|
2370
2369
|
const { name: e } = this.declarationNode;
|
|
2371
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2370
|
+
this.declarationNode.symbol = this.symbolFactory.create(tn, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2372
2371
|
const n = C(e);
|
|
2373
2372
|
if (n.isOk()) {
|
|
2374
|
-
const s = n.unwrap(), i = s.pop(), r =
|
|
2373
|
+
const s = n.unwrap(), i = s.pop(), r = Ke(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
|
|
2375
2374
|
if (r.has(a))
|
|
2376
2375
|
return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
|
|
2377
2376
|
r.set(a, this.declarationNode.symbol);
|
|
@@ -2405,7 +2404,7 @@ class xn {
|
|
|
2405
2404
|
}
|
|
2406
2405
|
registerField(e) {
|
|
2407
2406
|
if (e.callee && M(e.callee)) {
|
|
2408
|
-
const n = V(e.callee).unwrap(), s =
|
|
2407
|
+
const n = V(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(nn, { declaration: e });
|
|
2409
2408
|
e.symbol = i;
|
|
2410
2409
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2411
2410
|
if (r.has(s)) {
|
|
@@ -2420,89 +2419,89 @@ class xn {
|
|
|
2420
2419
|
return [];
|
|
2421
2420
|
}
|
|
2422
2421
|
}
|
|
2423
|
-
const
|
|
2422
|
+
const wt = ["-", "+"];
|
|
2424
2423
|
function re(t) {
|
|
2425
2424
|
switch (t.type.value.toLowerCase()) {
|
|
2426
2425
|
case b.Enum:
|
|
2427
|
-
return
|
|
2426
|
+
return Ln;
|
|
2428
2427
|
case b.Table:
|
|
2429
|
-
return
|
|
2428
|
+
return yn;
|
|
2430
2429
|
case b.TableGroup:
|
|
2431
|
-
return
|
|
2430
|
+
return Sn;
|
|
2432
2431
|
case b.Project:
|
|
2433
|
-
return _n;
|
|
2434
|
-
case b.Ref:
|
|
2435
2432
|
return An;
|
|
2433
|
+
case b.Ref:
|
|
2434
|
+
return vn;
|
|
2436
2435
|
case b.Note:
|
|
2437
|
-
return
|
|
2436
|
+
return _n;
|
|
2438
2437
|
case b.Indexes:
|
|
2439
|
-
return
|
|
2438
|
+
return gn;
|
|
2440
2439
|
default:
|
|
2441
|
-
return
|
|
2440
|
+
return In;
|
|
2442
2441
|
}
|
|
2443
2442
|
}
|
|
2444
|
-
function
|
|
2443
|
+
function Ze(t) {
|
|
2445
2444
|
return !!C(t).unwrap_or(!1);
|
|
2446
2445
|
}
|
|
2447
|
-
function
|
|
2448
|
-
return
|
|
2446
|
+
function On(t) {
|
|
2447
|
+
return Me(t);
|
|
2449
2448
|
}
|
|
2450
|
-
function
|
|
2449
|
+
function Me(t) {
|
|
2451
2450
|
return t instanceof D && t.expression instanceof j;
|
|
2452
2451
|
}
|
|
2453
|
-
function
|
|
2452
|
+
function Ke(t, e, n) {
|
|
2454
2453
|
var i;
|
|
2455
2454
|
t[0] === "public" && (t = t.slice(1));
|
|
2456
2455
|
let s = e;
|
|
2457
2456
|
for (const r of t) {
|
|
2458
2457
|
let a;
|
|
2459
|
-
const l =
|
|
2458
|
+
const l = je(r);
|
|
2460
2459
|
if (s.has(l)) {
|
|
2461
2460
|
if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
|
|
2462
2461
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2463
2462
|
} else {
|
|
2464
|
-
a = new
|
|
2465
|
-
const p = n.create(
|
|
2463
|
+
a = new we();
|
|
2464
|
+
const p = n.create(_t, { symbolTable: a });
|
|
2466
2465
|
s.set(l, p);
|
|
2467
2466
|
}
|
|
2468
2467
|
s = a;
|
|
2469
2468
|
}
|
|
2470
2469
|
return s;
|
|
2471
2470
|
}
|
|
2472
|
-
function
|
|
2471
|
+
function yt(t) {
|
|
2473
2472
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2474
2473
|
}
|
|
2475
|
-
function
|
|
2474
|
+
function Rn(t) {
|
|
2476
2475
|
var n;
|
|
2477
|
-
if (!(t instanceof D) || !(t.expression instanceof
|
|
2476
|
+
if (!(t instanceof D) || !(t.expression instanceof Te) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2478
2477
|
return !1;
|
|
2479
2478
|
const e = t.expression.literal.value;
|
|
2480
2479
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2481
2480
|
return !1;
|
|
2482
2481
|
for (let s = 1; s < e.length; s += 1)
|
|
2483
|
-
if (!
|
|
2482
|
+
if (!Ht(e[s]))
|
|
2484
2483
|
return !1;
|
|
2485
2484
|
return !0;
|
|
2486
2485
|
}
|
|
2487
2486
|
function le(t) {
|
|
2488
2487
|
return t === void 0;
|
|
2489
2488
|
}
|
|
2490
|
-
function
|
|
2489
|
+
function Dn(t) {
|
|
2491
2490
|
var e;
|
|
2492
|
-
return !!(Y(t) || ue(t) ||
|
|
2491
|
+
return !!(Y(t) || ue(t) || Ne(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && wt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression) || t instanceof te);
|
|
2493
2492
|
}
|
|
2494
2493
|
function ue(t) {
|
|
2495
2494
|
var e;
|
|
2496
|
-
return t instanceof D && t.expression instanceof
|
|
2495
|
+
return t instanceof D && t.expression instanceof Te && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
|
|
2497
2496
|
}
|
|
2498
|
-
function
|
|
2497
|
+
function Pn(t) {
|
|
2499
2498
|
var n;
|
|
2500
|
-
if (!(t instanceof q) || !
|
|
2499
|
+
if (!(t instanceof q) || !yt((n = t.op) == null ? void 0 : n.value))
|
|
2501
2500
|
return !1;
|
|
2502
2501
|
const e = C(t.expression).unwrap_or(void 0);
|
|
2503
2502
|
return e !== void 0 && e.length > 0;
|
|
2504
2503
|
}
|
|
2505
|
-
function
|
|
2504
|
+
function kt(t) {
|
|
2506
2505
|
return t instanceof Z && t.elementList.every(M);
|
|
2507
2506
|
}
|
|
2508
2507
|
function W(t) {
|
|
@@ -2517,15 +2516,15 @@ function W(t) {
|
|
|
2517
2516
|
n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2518
2517
|
continue;
|
|
2519
2518
|
}
|
|
2520
|
-
const r = (s =
|
|
2519
|
+
const r = (s = me(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2521
2520
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2522
2521
|
}
|
|
2523
2522
|
return new F(e, n);
|
|
2524
2523
|
}
|
|
2525
|
-
class
|
|
2524
|
+
class ft {
|
|
2526
2525
|
constructor(e, n) {
|
|
2527
|
-
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(
|
|
2528
|
-
symbolTable: new
|
|
2526
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
|
|
2527
|
+
symbolTable: new we()
|
|
2529
2528
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2530
2529
|
}
|
|
2531
2530
|
validate() {
|
|
@@ -2540,7 +2539,7 @@ class ht {
|
|
|
2540
2539
|
);
|
|
2541
2540
|
e.push(...r.validate());
|
|
2542
2541
|
});
|
|
2543
|
-
const n = this.ast.body.filter((s) =>
|
|
2542
|
+
const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
|
|
2544
2543
|
return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
|
|
2545
2544
|
}
|
|
2546
2545
|
}
|
|
@@ -2556,7 +2555,7 @@ class ae {
|
|
|
2556
2555
|
for (const s of e.elementList) {
|
|
2557
2556
|
if (s.name instanceof D)
|
|
2558
2557
|
continue;
|
|
2559
|
-
const i =
|
|
2558
|
+
const i = me(s.name).unwrap_or(void 0);
|
|
2560
2559
|
if (!i)
|
|
2561
2560
|
continue;
|
|
2562
2561
|
const r = n[i.toLowerCase()];
|
|
@@ -2573,7 +2572,7 @@ class ae {
|
|
|
2573
2572
|
if (s instanceof A) {
|
|
2574
2573
|
if (!s.type)
|
|
2575
2574
|
continue;
|
|
2576
|
-
const i =
|
|
2575
|
+
const i = xt(s);
|
|
2577
2576
|
new i(s, this.errors).bind();
|
|
2578
2577
|
} else
|
|
2579
2578
|
this.bindSubfield(s);
|
|
@@ -2596,7 +2595,7 @@ class ae {
|
|
|
2596
2595
|
return;
|
|
2597
2596
|
this.bindFragments([e], n);
|
|
2598
2597
|
} else
|
|
2599
|
-
e instanceof H ?
|
|
2598
|
+
e instanceof H ? Je(e) ? this.bindFragments(he(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof q ? this.scanAndBind(e.expression, n) : e instanceof Pe ? this.scanAndBind(e.expression, n) : e instanceof Z && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2600
2599
|
}
|
|
2601
2600
|
// Bind the fragments of a member access expression
|
|
2602
2601
|
// which can be a simple expression like v1.User,
|
|
@@ -2604,7 +2603,7 @@ class ae {
|
|
|
2604
2603
|
bindFragments(e, n) {
|
|
2605
2604
|
if (e.length === 0)
|
|
2606
2605
|
return;
|
|
2607
|
-
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 &&
|
|
2606
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 && kt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
|
|
2608
2607
|
0,
|
|
2609
2608
|
r === -1 ? void 0 : r
|
|
2610
2609
|
);
|
|
@@ -2614,14 +2613,14 @@ class ae {
|
|
|
2614
2613
|
for (; s.length && h.length; ) {
|
|
2615
2614
|
const f = s.pop(), N = h.pop(), g = V(N).unwrap();
|
|
2616
2615
|
T.unshift({
|
|
2617
|
-
index:
|
|
2616
|
+
index: Ve(g, f),
|
|
2618
2617
|
referrer: N
|
|
2619
2618
|
});
|
|
2620
2619
|
}
|
|
2621
2620
|
for (; h.length; ) {
|
|
2622
2621
|
const f = h.pop(), N = V(f).unwrap();
|
|
2623
2622
|
T.unshift({
|
|
2624
|
-
index:
|
|
2623
|
+
index: Ve(N, i),
|
|
2625
2624
|
referrer: f
|
|
2626
2625
|
});
|
|
2627
2626
|
}
|
|
@@ -2630,7 +2629,7 @@ class ae {
|
|
|
2630
2629
|
[
|
|
2631
2630
|
...T,
|
|
2632
2631
|
{
|
|
2633
|
-
index:
|
|
2632
|
+
index: Ve(
|
|
2634
2633
|
V(f).unwrap(),
|
|
2635
2634
|
p
|
|
2636
2635
|
),
|
|
@@ -2646,7 +2645,7 @@ class ae {
|
|
|
2646
2645
|
resolveIndexStack(e, n) {
|
|
2647
2646
|
if (e.length === 0)
|
|
2648
2647
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
2649
|
-
const [s, ...i] = e, r =
|
|
2648
|
+
const [s, ...i] = e, r = bn(s.index, this.declarationNode);
|
|
2650
2649
|
if (r === void 0) {
|
|
2651
2650
|
const { kind: h, name: T } = ie(s.index).unwrap();
|
|
2652
2651
|
this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
|
|
@@ -2673,7 +2672,7 @@ class ae {
|
|
|
2673
2672
|
s || this.errors.push(new c(o.BINDING_ERROR, n, e));
|
|
2674
2673
|
}
|
|
2675
2674
|
}
|
|
2676
|
-
class
|
|
2675
|
+
class Un extends ae {
|
|
2677
2676
|
constructor() {
|
|
2678
2677
|
super(...arguments), this.subfield = {
|
|
2679
2678
|
arg: {
|
|
@@ -2683,7 +2682,7 @@ class Pn extends ae {
|
|
|
2683
2682
|
}, this.settingList = {};
|
|
2684
2683
|
}
|
|
2685
2684
|
}
|
|
2686
|
-
class
|
|
2685
|
+
class Mn extends ae {
|
|
2687
2686
|
constructor() {
|
|
2688
2687
|
super(...arguments), this.subfield = {
|
|
2689
2688
|
arg: {
|
|
@@ -2693,7 +2692,7 @@ class Un extends ae {
|
|
|
2693
2692
|
}, this.settingList = {};
|
|
2694
2693
|
}
|
|
2695
2694
|
}
|
|
2696
|
-
class
|
|
2695
|
+
class Fn extends ae {
|
|
2697
2696
|
constructor() {
|
|
2698
2697
|
super(...arguments), this.subfield = {
|
|
2699
2698
|
arg: {
|
|
@@ -2728,7 +2727,7 @@ class Mn extends ae {
|
|
|
2728
2727
|
}, this.settingList = {};
|
|
2729
2728
|
}
|
|
2730
2729
|
}
|
|
2731
|
-
class
|
|
2730
|
+
class Bn extends ae {
|
|
2732
2731
|
constructor() {
|
|
2733
2732
|
super(...arguments), this.subfield = {
|
|
2734
2733
|
arg: {
|
|
@@ -2738,7 +2737,7 @@ class Fn extends ae {
|
|
|
2738
2737
|
}, this.settingList = {};
|
|
2739
2738
|
}
|
|
2740
2739
|
}
|
|
2741
|
-
class
|
|
2740
|
+
class Vn extends ae {
|
|
2742
2741
|
constructor() {
|
|
2743
2742
|
super(...arguments), this.subfield = {
|
|
2744
2743
|
arg: {
|
|
@@ -2748,7 +2747,7 @@ class Bn extends ae {
|
|
|
2748
2747
|
}, this.settingList = {};
|
|
2749
2748
|
}
|
|
2750
2749
|
}
|
|
2751
|
-
class
|
|
2750
|
+
class Gn extends ae {
|
|
2752
2751
|
constructor() {
|
|
2753
2752
|
super(...arguments), this.subfield = {
|
|
2754
2753
|
arg: {
|
|
@@ -2765,7 +2764,7 @@ class Vn extends ae {
|
|
|
2765
2764
|
}, this.settingList = {};
|
|
2766
2765
|
}
|
|
2767
2766
|
}
|
|
2768
|
-
class
|
|
2767
|
+
class Cn extends ae {
|
|
2769
2768
|
constructor() {
|
|
2770
2769
|
super(...arguments), this.subfield = {
|
|
2771
2770
|
arg: {
|
|
@@ -2793,7 +2792,7 @@ class Gn extends ae {
|
|
|
2793
2792
|
}, this.settingList = {};
|
|
2794
2793
|
}
|
|
2795
2794
|
}
|
|
2796
|
-
class
|
|
2795
|
+
class Xn extends ae {
|
|
2797
2796
|
constructor() {
|
|
2798
2797
|
super(...arguments), this.subfield = {
|
|
2799
2798
|
arg: {
|
|
@@ -2810,40 +2809,40 @@ class Cn extends ae {
|
|
|
2810
2809
|
}, this.settingList = {};
|
|
2811
2810
|
}
|
|
2812
2811
|
}
|
|
2813
|
-
function
|
|
2812
|
+
function xt(t) {
|
|
2814
2813
|
switch (t.type.value.toLowerCase()) {
|
|
2815
2814
|
case b.Enum:
|
|
2816
|
-
return
|
|
2815
|
+
return Mn;
|
|
2817
2816
|
case b.Table:
|
|
2818
|
-
return Gn;
|
|
2819
|
-
case b.TableGroup:
|
|
2820
2817
|
return Cn;
|
|
2818
|
+
case b.TableGroup:
|
|
2819
|
+
return Xn;
|
|
2821
2820
|
case b.Project:
|
|
2822
|
-
return Bn;
|
|
2823
|
-
case b.Ref:
|
|
2824
2821
|
return Vn;
|
|
2822
|
+
case b.Ref:
|
|
2823
|
+
return Gn;
|
|
2825
2824
|
case b.Note:
|
|
2826
|
-
return
|
|
2825
|
+
return Bn;
|
|
2827
2826
|
case b.Indexes:
|
|
2828
|
-
return
|
|
2827
|
+
return Fn;
|
|
2829
2828
|
default:
|
|
2830
|
-
return
|
|
2829
|
+
return Un;
|
|
2831
2830
|
}
|
|
2832
2831
|
}
|
|
2833
|
-
class
|
|
2832
|
+
class $n {
|
|
2834
2833
|
constructor(e) {
|
|
2835
2834
|
this.ast = e, this.errors = [];
|
|
2836
2835
|
}
|
|
2837
2836
|
resolve() {
|
|
2838
2837
|
for (const e of this.ast.body)
|
|
2839
2838
|
if (e.type) {
|
|
2840
|
-
const n =
|
|
2839
|
+
const n = xt(e);
|
|
2841
2840
|
new n(e, this.errors).bind();
|
|
2842
2841
|
}
|
|
2843
2842
|
return new F(this.ast, this.errors);
|
|
2844
2843
|
}
|
|
2845
2844
|
}
|
|
2846
|
-
class
|
|
2845
|
+
class Wn {
|
|
2847
2846
|
constructor(e) {
|
|
2848
2847
|
this.generator = e;
|
|
2849
2848
|
}
|
|
@@ -2851,21 +2850,21 @@ class $n {
|
|
|
2851
2850
|
return new e(n, this.generator.nextId());
|
|
2852
2851
|
}
|
|
2853
2852
|
}
|
|
2854
|
-
class
|
|
2853
|
+
class jn {
|
|
2855
2854
|
constructor(e, n) {
|
|
2856
|
-
this.ast = e, this.symbolFactory = new
|
|
2855
|
+
this.ast = e, this.symbolFactory = new Wn(n);
|
|
2857
2856
|
}
|
|
2858
2857
|
// Analyzing: Invoking both the validator and binder
|
|
2859
2858
|
analyze() {
|
|
2860
|
-
return new
|
|
2859
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new $n(n).resolve());
|
|
2861
2860
|
}
|
|
2862
2861
|
// For invoking the validator only
|
|
2863
2862
|
validate() {
|
|
2864
|
-
return new
|
|
2863
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new F(n, []));
|
|
2865
2864
|
}
|
|
2866
2865
|
}
|
|
2867
|
-
function
|
|
2868
|
-
const { variables: n, tupleElements: s } =
|
|
2866
|
+
function pt(t, e) {
|
|
2867
|
+
const { variables: n, tupleElements: s } = _e(t).unwrap();
|
|
2869
2868
|
return s ? n.length === 0 ? {
|
|
2870
2869
|
schemaName: e.schemaName,
|
|
2871
2870
|
tableName: e.name,
|
|
@@ -2884,7 +2883,7 @@ function ft(t, e) {
|
|
|
2884
2883
|
schemaName: n.pop() || null
|
|
2885
2884
|
};
|
|
2886
2885
|
}
|
|
2887
|
-
function
|
|
2886
|
+
function St(t) {
|
|
2888
2887
|
switch (t) {
|
|
2889
2888
|
case "<":
|
|
2890
2889
|
return ["1", "*"];
|
|
@@ -2907,30 +2906,30 @@ function x(t) {
|
|
|
2907
2906
|
end: { offset: t.endPos.offset, line: t.endPos.line + 1, column: t.endPos.column + 1 }
|
|
2908
2907
|
};
|
|
2909
2908
|
}
|
|
2910
|
-
function
|
|
2909
|
+
function $e(t) {
|
|
2911
2910
|
var n;
|
|
2912
2911
|
const e = (n = he(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2913
2912
|
return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2914
2913
|
}
|
|
2915
|
-
function
|
|
2914
|
+
function be(t) {
|
|
2916
2915
|
const e = C(t).unwrap();
|
|
2917
2916
|
return {
|
|
2918
2917
|
name: e.pop(),
|
|
2919
2918
|
schemaName: e
|
|
2920
2919
|
};
|
|
2921
2920
|
}
|
|
2922
|
-
function
|
|
2921
|
+
function Ot(t) {
|
|
2923
2922
|
return t.expression.literal.value;
|
|
2924
2923
|
}
|
|
2925
|
-
function
|
|
2924
|
+
function Rt(t, e) {
|
|
2926
2925
|
if (Array.isArray(t)) {
|
|
2927
2926
|
const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
|
|
2928
2927
|
return i < r ? `${i}-${r}` : `${r}-${i}`;
|
|
2929
2928
|
}
|
|
2930
|
-
const n = t.id, s = e.id;
|
|
2929
|
+
const n = t.id.toString(), s = e.id.toString();
|
|
2931
2930
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
2932
2931
|
}
|
|
2933
|
-
function
|
|
2932
|
+
function Dt(t, e) {
|
|
2934
2933
|
if (Array.isArray(t)) {
|
|
2935
2934
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2936
2935
|
return I.zip(i, r).every(([a, l]) => a === l);
|
|
@@ -2938,7 +2937,13 @@ function Rt(t, e) {
|
|
|
2938
2937
|
const n = t.id, s = e.id;
|
|
2939
2938
|
return n === s;
|
|
2940
2939
|
}
|
|
2941
|
-
|
|
2940
|
+
function Ee(t) {
|
|
2941
|
+
const e = t.split(`
|
|
2942
|
+
`), n = e.filter((i) => i.trimStart()), s = Math.min(...n.map((i) => i.length - i.trimStart().length));
|
|
2943
|
+
return e.map((i) => i.slice(s)).join(`
|
|
2944
|
+
`);
|
|
2945
|
+
}
|
|
2946
|
+
class Pt {
|
|
2942
2947
|
constructor(e, n) {
|
|
2943
2948
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2944
2949
|
}
|
|
@@ -2962,7 +2967,7 @@ class Dt {
|
|
|
2962
2967
|
}), this.pkColumns.forEach((n) => n.pk = !1)), e;
|
|
2963
2968
|
}
|
|
2964
2969
|
interpretName(e) {
|
|
2965
|
-
const { name: n, schemaName: s } =
|
|
2970
|
+
const { name: n, schemaName: s } = be(e);
|
|
2966
2971
|
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
2967
2972
|
}
|
|
2968
2973
|
interpretAlias(e) {
|
|
@@ -2979,12 +2984,12 @@ class Dt {
|
|
|
2979
2984
|
}), this.table.alias = n), [];
|
|
2980
2985
|
}
|
|
2981
2986
|
interpretSettingList(e) {
|
|
2982
|
-
var r, a
|
|
2987
|
+
var i, r, a;
|
|
2983
2988
|
const n = W(e).getValue();
|
|
2984
|
-
this.table.headerColor = (
|
|
2985
|
-
const [s] = n.note || []
|
|
2989
|
+
this.table.headerColor = (i = n.headercolor) != null && i.length ? Ot((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
|
|
2990
|
+
const [s] = n.note || [];
|
|
2986
2991
|
return this.table.note = s && {
|
|
2987
|
-
value:
|
|
2992
|
+
value: Q(s == null ? void 0 : s.value).map(Ee).unwrap(),
|
|
2988
2993
|
token: x(s)
|
|
2989
2994
|
}, [];
|
|
2990
2995
|
}
|
|
@@ -2998,7 +3003,7 @@ class Dt {
|
|
|
2998
3003
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
2999
3004
|
case "note":
|
|
3000
3005
|
return this.table.note = {
|
|
3001
|
-
value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).unwrap(),
|
|
3006
|
+
value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(Ee).unwrap(),
|
|
3002
3007
|
token: x(n)
|
|
3003
3008
|
}, [];
|
|
3004
3009
|
case "indexes":
|
|
@@ -3014,23 +3019,23 @@ class Dt {
|
|
|
3014
3019
|
var a, l, p, h, T, f, N, g;
|
|
3015
3020
|
const n = [], s = {};
|
|
3016
3021
|
s.name = V(e.callee).unwrap();
|
|
3017
|
-
const i =
|
|
3022
|
+
const i = Yn(e.args[0]);
|
|
3018
3023
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
|
|
3019
3024
|
const r = e.args.slice(1);
|
|
3020
3025
|
if (I.last(r) instanceof P) {
|
|
3021
3026
|
const _ = W(r.pop()).getValue();
|
|
3022
|
-
s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault =
|
|
3027
|
+
s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault = zn((N = (f = _.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3023
3028
|
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3024
3029
|
s.note = K && {
|
|
3025
|
-
value: Q(K.value).unwrap(),
|
|
3030
|
+
value: Q(K.value).map(Ee).unwrap(),
|
|
3026
3031
|
token: x(K)
|
|
3027
3032
|
};
|
|
3028
|
-
const
|
|
3029
|
-
s.inline_refs =
|
|
3030
|
-
const [
|
|
3031
|
-
if (
|
|
3033
|
+
const Ie = _.ref || [];
|
|
3034
|
+
s.inline_refs = Ie.flatMap((z) => {
|
|
3035
|
+
const [nt] = $e(z.value.expression);
|
|
3036
|
+
if (Dt(nt, e.symbol))
|
|
3032
3037
|
return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
|
|
3033
|
-
const
|
|
3038
|
+
const ye = z.value.op, ee = C(z.value.expression).unwrap();
|
|
3034
3039
|
let fe;
|
|
3035
3040
|
if (ee.length === 1) {
|
|
3036
3041
|
const [oe] = ee;
|
|
@@ -3038,40 +3043,40 @@ class Dt {
|
|
|
3038
3043
|
schemaName: this.table.schemaName,
|
|
3039
3044
|
tableName: this.table.name,
|
|
3040
3045
|
fieldNames: [oe],
|
|
3041
|
-
relation:
|
|
3046
|
+
relation: ye.value,
|
|
3042
3047
|
token: x(z)
|
|
3043
3048
|
};
|
|
3044
3049
|
} else if (ee.length === 2) {
|
|
3045
|
-
const [oe,
|
|
3050
|
+
const [oe, Le] = ee;
|
|
3046
3051
|
fe = {
|
|
3047
3052
|
schemaName: null,
|
|
3048
3053
|
tableName: oe,
|
|
3049
|
-
fieldNames: [
|
|
3050
|
-
relation:
|
|
3054
|
+
fieldNames: [Le],
|
|
3055
|
+
relation: ye.value,
|
|
3051
3056
|
token: x(z)
|
|
3052
3057
|
};
|
|
3053
3058
|
} else if (ee.length === 3) {
|
|
3054
|
-
const [oe,
|
|
3059
|
+
const [oe, Le, it] = ee;
|
|
3055
3060
|
fe = {
|
|
3056
3061
|
schemaName: oe,
|
|
3057
|
-
tableName:
|
|
3058
|
-
fieldNames: [
|
|
3059
|
-
relation:
|
|
3062
|
+
tableName: Le,
|
|
3063
|
+
fieldNames: [it],
|
|
3064
|
+
relation: ye.value,
|
|
3060
3065
|
token: x(z)
|
|
3061
3066
|
};
|
|
3062
3067
|
} else {
|
|
3063
3068
|
n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
|
|
3064
|
-
const oe = ee.pop(),
|
|
3069
|
+
const oe = ee.pop(), Le = ee.pop();
|
|
3065
3070
|
fe = {
|
|
3066
3071
|
schemaName: ee.join("."),
|
|
3067
|
-
tableName:
|
|
3072
|
+
tableName: Le,
|
|
3068
3073
|
fieldNames: [oe],
|
|
3069
|
-
relation:
|
|
3074
|
+
relation: ye.value,
|
|
3070
3075
|
token: x(z)
|
|
3071
3076
|
};
|
|
3072
3077
|
}
|
|
3073
|
-
const
|
|
3074
|
-
return n.push(...
|
|
3078
|
+
const st = this.registerInlineRefToEnv(e, nt, fe, z);
|
|
3079
|
+
return n.push(...st), st.length === 0 ? fe : [];
|
|
3075
3080
|
});
|
|
3076
3081
|
}
|
|
3077
3082
|
return s.pk || (s.pk = r.some((_) => X(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => X(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
@@ -3099,14 +3104,14 @@ class Dt {
|
|
|
3099
3104
|
_.push(g.argumentList), g = g.callee;
|
|
3100
3105
|
return _.push(g), _;
|
|
3101
3106
|
}).forEach((g) => {
|
|
3102
|
-
const { functional: _, nonFunctional: K } =
|
|
3107
|
+
const { functional: _, nonFunctional: K } = Xe(g).unwrap();
|
|
3103
3108
|
s.columns.push(
|
|
3104
|
-
..._.map((
|
|
3105
|
-
value:
|
|
3109
|
+
..._.map((Ie) => ({
|
|
3110
|
+
value: Ie.value.value,
|
|
3106
3111
|
type: "expression"
|
|
3107
3112
|
})),
|
|
3108
|
-
...K.map((
|
|
3109
|
-
value: V(
|
|
3113
|
+
...K.map((Ie) => ({
|
|
3114
|
+
value: V(Ie).unwrap(),
|
|
3110
3115
|
type: "column"
|
|
3111
3116
|
}))
|
|
3112
3117
|
);
|
|
@@ -3114,13 +3119,13 @@ class Dt {
|
|
|
3114
3119
|
})), [];
|
|
3115
3120
|
}
|
|
3116
3121
|
registerInlineRefToEnv(e, n, s, i) {
|
|
3117
|
-
const r =
|
|
3122
|
+
const r = Rt(e.symbol, n);
|
|
3118
3123
|
if (this.env.refIds[r])
|
|
3119
3124
|
return [
|
|
3120
3125
|
new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3121
3126
|
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3122
3127
|
];
|
|
3123
|
-
const a =
|
|
3128
|
+
const a = St(s.relation);
|
|
3124
3129
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
3125
3130
|
name: null,
|
|
3126
3131
|
schemaName: null,
|
|
@@ -3141,13 +3146,13 @@ class Dt {
|
|
|
3141
3146
|
}), [];
|
|
3142
3147
|
}
|
|
3143
3148
|
}
|
|
3144
|
-
function
|
|
3149
|
+
function Yn(t) {
|
|
3145
3150
|
let e = null;
|
|
3146
3151
|
t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value : Y(r) ? Q(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3147
3152
|
let n = "";
|
|
3148
3153
|
for (; t instanceof ce; )
|
|
3149
3154
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3150
|
-
const { name: s, schemaName: i } =
|
|
3155
|
+
const { name: s, schemaName: i } = be(t);
|
|
3151
3156
|
return i.length > 1 ? new F(
|
|
3152
3157
|
{
|
|
3153
3158
|
schemaName: i.length === 0 ? null : i[0],
|
|
@@ -3161,7 +3166,7 @@ function jn(t) {
|
|
|
3161
3166
|
args: e
|
|
3162
3167
|
});
|
|
3163
3168
|
}
|
|
3164
|
-
function
|
|
3169
|
+
function zn(t) {
|
|
3165
3170
|
var e, n, s;
|
|
3166
3171
|
if (t) {
|
|
3167
3172
|
if (Y(t))
|
|
@@ -3174,12 +3179,12 @@ function Yn(t) {
|
|
|
3174
3179
|
type: "number",
|
|
3175
3180
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3176
3181
|
};
|
|
3177
|
-
if (
|
|
3182
|
+
if (Ne(t))
|
|
3178
3183
|
return {
|
|
3179
3184
|
value: t.expression.variable.value.toLowerCase(),
|
|
3180
3185
|
type: "boolean"
|
|
3181
3186
|
};
|
|
3182
|
-
if (t instanceof q &&
|
|
3187
|
+
if (t instanceof q && wt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression)) {
|
|
3183
3188
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3184
3189
|
return {
|
|
3185
3190
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
@@ -3194,7 +3199,7 @@ function Yn(t) {
|
|
|
3194
3199
|
throw new Error("Unreachable");
|
|
3195
3200
|
}
|
|
3196
3201
|
}
|
|
3197
|
-
class
|
|
3202
|
+
class Qn {
|
|
3198
3203
|
constructor(e, n) {
|
|
3199
3204
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3200
3205
|
}
|
|
@@ -3206,13 +3211,13 @@ class zn {
|
|
|
3206
3211
|
];
|
|
3207
3212
|
}
|
|
3208
3213
|
interpretName(e) {
|
|
3209
|
-
const { name: n } =
|
|
3214
|
+
const { name: n } = be(e);
|
|
3210
3215
|
return this.note.name = n, [];
|
|
3211
3216
|
}
|
|
3212
3217
|
interpretSettingList(e) {
|
|
3213
3218
|
var s, i, r;
|
|
3214
3219
|
const n = W(e).getValue();
|
|
3215
|
-
return this.note.headerColor = (s = n.headercolor) != null && s.length ?
|
|
3220
|
+
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ot((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
|
|
3216
3221
|
}
|
|
3217
3222
|
interpretBody(e) {
|
|
3218
3223
|
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
@@ -3222,10 +3227,10 @@ class zn {
|
|
|
3222
3227
|
}
|
|
3223
3228
|
interpretNote(e) {
|
|
3224
3229
|
const n = I.get(e, "callee.expression.literal.value", "");
|
|
3225
|
-
return this.note.content = n, [];
|
|
3230
|
+
return this.note.content = Ee(n), [];
|
|
3226
3231
|
}
|
|
3227
3232
|
}
|
|
3228
|
-
class
|
|
3233
|
+
class Ut {
|
|
3229
3234
|
constructor(e, n) {
|
|
3230
3235
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3231
3236
|
}
|
|
@@ -3241,10 +3246,10 @@ class Pt {
|
|
|
3241
3246
|
}
|
|
3242
3247
|
interpretField(e) {
|
|
3243
3248
|
var h, T, f, N;
|
|
3244
|
-
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r =
|
|
3245
|
-
if (
|
|
3249
|
+
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
|
|
3250
|
+
if (Dt(r, a))
|
|
3246
3251
|
return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3247
|
-
const l =
|
|
3252
|
+
const l = Rt(r, a);
|
|
3248
3253
|
if (this.env.refIds[l])
|
|
3249
3254
|
return [
|
|
3250
3255
|
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
@@ -3252,26 +3257,26 @@ class Pt {
|
|
|
3252
3257
|
];
|
|
3253
3258
|
if (e.args[0]) {
|
|
3254
3259
|
const g = W(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
|
|
3255
|
-
this.ref.onDelete = _ instanceof $ ?
|
|
3260
|
+
this.ref.onDelete = _ instanceof $ ? me(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
|
|
3256
3261
|
const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
|
|
3257
|
-
this.ref.onUpdate = K instanceof $ ?
|
|
3262
|
+
this.ref.onUpdate = K instanceof $ ? me(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
|
|
3258
3263
|
}
|
|
3259
|
-
const p =
|
|
3264
|
+
const p = St(n);
|
|
3260
3265
|
return this.ref.endpoints = [
|
|
3261
3266
|
{
|
|
3262
|
-
...
|
|
3267
|
+
...pt(s, this.container),
|
|
3263
3268
|
relation: p[0],
|
|
3264
3269
|
token: x(s)
|
|
3265
3270
|
},
|
|
3266
3271
|
{
|
|
3267
|
-
...
|
|
3272
|
+
...pt(i, this.container),
|
|
3268
3273
|
relation: p[1],
|
|
3269
3274
|
token: x(i)
|
|
3270
3275
|
}
|
|
3271
3276
|
], this.env.refIds[l] = this.declarationNode, [];
|
|
3272
3277
|
}
|
|
3273
3278
|
}
|
|
3274
|
-
class
|
|
3279
|
+
class Mt {
|
|
3275
3280
|
constructor(e, n) {
|
|
3276
3281
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3277
3282
|
}
|
|
@@ -3283,7 +3288,7 @@ class Ut {
|
|
|
3283
3288
|
), e;
|
|
3284
3289
|
}
|
|
3285
3290
|
interpretName(e) {
|
|
3286
|
-
const n = [], { name: s, schemaName: i } =
|
|
3291
|
+
const n = [], { name: s, schemaName: i } = be(e);
|
|
3287
3292
|
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3288
3293
|
}
|
|
3289
3294
|
interpretBody(e) {
|
|
@@ -3304,7 +3309,7 @@ class Ut {
|
|
|
3304
3309
|
}), n;
|
|
3305
3310
|
}
|
|
3306
3311
|
}
|
|
3307
|
-
class
|
|
3312
|
+
class Ft {
|
|
3308
3313
|
constructor(e, n) {
|
|
3309
3314
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3310
3315
|
}
|
|
@@ -3312,7 +3317,7 @@ class Mt {
|
|
|
3312
3317
|
return this.enum.token = x(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3313
3318
|
}
|
|
3314
3319
|
interpretName(e) {
|
|
3315
|
-
const { name: n, schemaName: s } =
|
|
3320
|
+
const { name: n, schemaName: s } = be(e);
|
|
3316
3321
|
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3317
3322
|
}
|
|
3318
3323
|
interpretBody(e) {
|
|
@@ -3322,13 +3327,13 @@ class Mt {
|
|
|
3322
3327
|
i.token = x(s), i.name = X(s.callee).unwrap();
|
|
3323
3328
|
const a = (l = W(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
|
|
3324
3329
|
return i.note = a && {
|
|
3325
|
-
value: Q(a.value).unwrap(),
|
|
3330
|
+
value: Q(a.value).map(Ee).unwrap(),
|
|
3326
3331
|
token: x(a)
|
|
3327
3332
|
}, this.enum.values.push(i), [];
|
|
3328
3333
|
});
|
|
3329
3334
|
}
|
|
3330
3335
|
}
|
|
3331
|
-
class
|
|
3336
|
+
class qn {
|
|
3332
3337
|
constructor(e, n) {
|
|
3333
3338
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3334
3339
|
}
|
|
@@ -3338,7 +3343,7 @@ class Qn {
|
|
|
3338
3343
|
interpretName(e) {
|
|
3339
3344
|
if (!e)
|
|
3340
3345
|
return this.project.name = null, [];
|
|
3341
|
-
const { name: n } =
|
|
3346
|
+
const { name: n } = be(e);
|
|
3342
3347
|
return this.project.name = n, [];
|
|
3343
3348
|
}
|
|
3344
3349
|
interpretBody(e) {
|
|
@@ -3347,24 +3352,24 @@ class Qn {
|
|
|
3347
3352
|
const s = n;
|
|
3348
3353
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
3349
3354
|
case "table": {
|
|
3350
|
-
const r = new
|
|
3355
|
+
const r = new Pt(s, this.env).interpret();
|
|
3351
3356
|
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3352
3357
|
}
|
|
3353
3358
|
case "ref": {
|
|
3354
|
-
const r = new
|
|
3359
|
+
const r = new Ut(s, this.env).interpret();
|
|
3355
3360
|
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3356
3361
|
}
|
|
3357
3362
|
case "tablegroup": {
|
|
3358
|
-
const r = new
|
|
3363
|
+
const r = new Mt(s, this.env).interpret();
|
|
3359
3364
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
|
|
3360
3365
|
}
|
|
3361
3366
|
case "enum": {
|
|
3362
|
-
const r = new
|
|
3367
|
+
const r = new Ft(s, this.env).interpret();
|
|
3363
3368
|
return this.project.enums.push(this.env.enums.get(s)), r;
|
|
3364
3369
|
}
|
|
3365
3370
|
case "note":
|
|
3366
3371
|
return this.project.note = {
|
|
3367
|
-
value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).unwrap(),
|
|
3372
|
+
value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(Ee).unwrap(),
|
|
3368
3373
|
token: x(s)
|
|
3369
3374
|
}, [];
|
|
3370
3375
|
default:
|
|
@@ -3373,7 +3378,7 @@ class Qn {
|
|
|
3373
3378
|
});
|
|
3374
3379
|
}
|
|
3375
3380
|
}
|
|
3376
|
-
class
|
|
3381
|
+
class Hn {
|
|
3377
3382
|
constructor(e) {
|
|
3378
3383
|
this.ast = e, this.env = {
|
|
3379
3384
|
schema: [],
|
|
@@ -3390,27 +3395,27 @@ class qn {
|
|
|
3390
3395
|
}
|
|
3391
3396
|
interpret() {
|
|
3392
3397
|
const e = this.ast.body.flatMap((n) => {
|
|
3393
|
-
switch (
|
|
3398
|
+
switch (ve(n).unwrap_or(void 0)) {
|
|
3394
3399
|
case b.Table:
|
|
3395
|
-
return new
|
|
3400
|
+
return new Pt(n, this.env).interpret();
|
|
3396
3401
|
case b.Note:
|
|
3397
|
-
return new
|
|
3402
|
+
return new Qn(n, this.env).interpret();
|
|
3398
3403
|
case b.Ref:
|
|
3399
|
-
return new Pt(n, this.env).interpret();
|
|
3400
|
-
case b.TableGroup:
|
|
3401
3404
|
return new Ut(n, this.env).interpret();
|
|
3402
|
-
case b.
|
|
3405
|
+
case b.TableGroup:
|
|
3403
3406
|
return new Mt(n, this.env).interpret();
|
|
3407
|
+
case b.Enum:
|
|
3408
|
+
return new Ft(n, this.env).interpret();
|
|
3404
3409
|
case b.Project:
|
|
3405
|
-
return new
|
|
3410
|
+
return new qn(n, this.env).interpret();
|
|
3406
3411
|
default:
|
|
3407
3412
|
return [];
|
|
3408
3413
|
}
|
|
3409
3414
|
});
|
|
3410
|
-
return new F(
|
|
3415
|
+
return new F(Jn(this.env), e);
|
|
3411
3416
|
}
|
|
3412
3417
|
}
|
|
3413
|
-
function
|
|
3418
|
+
function Jn(t) {
|
|
3414
3419
|
return {
|
|
3415
3420
|
schemas: [],
|
|
3416
3421
|
tables: Array.from(t.tables.values()),
|
|
@@ -3423,7 +3428,7 @@ function Hn(t) {
|
|
|
3423
3428
|
};
|
|
3424
3429
|
}
|
|
3425
3430
|
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
|
|
3426
|
-
function
|
|
3431
|
+
function Ae(t) {
|
|
3427
3432
|
switch (t) {
|
|
3428
3433
|
case m.Schema:
|
|
3429
3434
|
return L.Module;
|
|
@@ -3443,8 +3448,8 @@ function _e(t) {
|
|
|
3443
3448
|
return L.Text;
|
|
3444
3449
|
}
|
|
3445
3450
|
}
|
|
3446
|
-
function
|
|
3447
|
-
if (!t ||
|
|
3451
|
+
function Re(t, e) {
|
|
3452
|
+
if (!t || Ce(t))
|
|
3448
3453
|
return !1;
|
|
3449
3454
|
for (const n of t.trailingTrivia) {
|
|
3450
3455
|
if (n.start > e)
|
|
@@ -3459,7 +3464,7 @@ function O() {
|
|
|
3459
3464
|
suggestions: []
|
|
3460
3465
|
};
|
|
3461
3466
|
}
|
|
3462
|
-
function
|
|
3467
|
+
function De(t) {
|
|
3463
3468
|
return {
|
|
3464
3469
|
...t,
|
|
3465
3470
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3468,38 +3473,38 @@ function Re(t) {
|
|
|
3468
3473
|
}))
|
|
3469
3474
|
};
|
|
3470
3475
|
}
|
|
3471
|
-
function
|
|
3476
|
+
function Fe(t) {
|
|
3472
3477
|
return {
|
|
3473
3478
|
...t,
|
|
3474
3479
|
suggestions: t.suggestions.map((e) => ({
|
|
3475
3480
|
...e,
|
|
3476
|
-
insertText: e.insertText.
|
|
3481
|
+
insertText: e.insertText.split("").every(Ue) ? e.insertText : `"${e.insertText}"`
|
|
3477
3482
|
}))
|
|
3478
3483
|
};
|
|
3479
3484
|
}
|
|
3480
|
-
function
|
|
3485
|
+
function et(t, e) {
|
|
3481
3486
|
return t.getOffsetAt(e);
|
|
3482
3487
|
}
|
|
3483
|
-
class
|
|
3488
|
+
class Bt {
|
|
3484
3489
|
constructor(e, n = []) {
|
|
3485
3490
|
this.compiler = e, this.triggerCharacters = n;
|
|
3486
3491
|
}
|
|
3487
3492
|
provideCompletionItems(e, n) {
|
|
3488
3493
|
var T, f;
|
|
3489
|
-
const s =
|
|
3494
|
+
const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
|
|
3490
3495
|
if ([
|
|
3491
3496
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3492
3497
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3493
3498
|
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3494
|
-
].find((N) =>
|
|
3499
|
+
].find((N) => jt(N) && ge(s, N)))
|
|
3495
3500
|
return O();
|
|
3496
3501
|
if (a === void 0)
|
|
3497
|
-
return
|
|
3498
|
-
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) &&
|
|
3502
|
+
return Tt();
|
|
3503
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
|
|
3499
3504
|
return O();
|
|
3500
3505
|
const p = this.compiler.container.element(s);
|
|
3501
3506
|
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
|
|
3502
|
-
return
|
|
3507
|
+
return Tt();
|
|
3503
3508
|
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3504
3509
|
for (const N of h)
|
|
3505
3510
|
if (N instanceof q)
|
|
@@ -3508,7 +3513,7 @@ class Ft {
|
|
|
3508
3513
|
case "<":
|
|
3509
3514
|
case "<>":
|
|
3510
3515
|
case "-":
|
|
3511
|
-
return
|
|
3516
|
+
return dt(
|
|
3512
3517
|
this.compiler,
|
|
3513
3518
|
s,
|
|
3514
3519
|
N
|
|
@@ -3520,13 +3525,13 @@ class Ft {
|
|
|
3520
3525
|
case "<":
|
|
3521
3526
|
case "<>":
|
|
3522
3527
|
case "-":
|
|
3523
|
-
return
|
|
3528
|
+
return dt(
|
|
3524
3529
|
this.compiler,
|
|
3525
3530
|
s,
|
|
3526
3531
|
N
|
|
3527
3532
|
);
|
|
3528
3533
|
case ".":
|
|
3529
|
-
return
|
|
3534
|
+
return Vt(
|
|
3530
3535
|
this.compiler,
|
|
3531
3536
|
s,
|
|
3532
3537
|
N
|
|
@@ -3534,32 +3539,32 @@ class Ft {
|
|
|
3534
3539
|
}
|
|
3535
3540
|
else {
|
|
3536
3541
|
if (N instanceof se)
|
|
3537
|
-
return
|
|
3542
|
+
return Et(this.compiler, s, N);
|
|
3538
3543
|
if (N instanceof P)
|
|
3539
|
-
return
|
|
3544
|
+
return Et(this.compiler, s, N);
|
|
3540
3545
|
if (N instanceof Z)
|
|
3541
|
-
return
|
|
3546
|
+
return Zn(this.compiler, s);
|
|
3542
3547
|
if (N instanceof w)
|
|
3543
|
-
return
|
|
3544
|
-
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body &&
|
|
3545
|
-
return
|
|
3548
|
+
return mt(this.compiler, s, N);
|
|
3549
|
+
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && ge(s, N.body)))
|
|
3550
|
+
return mt(this.compiler, s, void 0);
|
|
3546
3551
|
}
|
|
3547
3552
|
return O();
|
|
3548
3553
|
}
|
|
3549
3554
|
}
|
|
3550
|
-
function
|
|
3555
|
+
function dt(t, e, n) {
|
|
3551
3556
|
const s = t.container.scopeKind(e);
|
|
3552
3557
|
if ([R.REF, R.TABLE].includes(s)) {
|
|
3553
|
-
const i =
|
|
3558
|
+
const i = Be(t, e, t.container.element(e), [
|
|
3554
3559
|
m.Table,
|
|
3555
3560
|
m.Schema,
|
|
3556
3561
|
m.Column
|
|
3557
3562
|
]);
|
|
3558
|
-
return
|
|
3563
|
+
return Re(n.op, e) ? De(i) : i;
|
|
3559
3564
|
}
|
|
3560
3565
|
return O();
|
|
3561
3566
|
}
|
|
3562
|
-
function
|
|
3567
|
+
function Be(t, e, n, s) {
|
|
3563
3568
|
var a;
|
|
3564
3569
|
if (n === void 0)
|
|
3565
3570
|
return O();
|
|
@@ -3573,61 +3578,61 @@ function Me(t, e, n, s) {
|
|
|
3573
3578
|
label: p,
|
|
3574
3579
|
insertText: p,
|
|
3575
3580
|
insertTextRules: y.KeepWhitespace,
|
|
3576
|
-
kind:
|
|
3577
|
-
sortText:
|
|
3581
|
+
kind: Ae(h),
|
|
3582
|
+
sortText: Ae(h).toString().padStart(2, "0"),
|
|
3578
3583
|
range: void 0
|
|
3579
3584
|
}))
|
|
3580
3585
|
);
|
|
3581
3586
|
}
|
|
3582
3587
|
i = i instanceof A ? i.parent : void 0;
|
|
3583
3588
|
}
|
|
3584
|
-
return
|
|
3589
|
+
return Fe(r);
|
|
3585
3590
|
}
|
|
3586
|
-
function
|
|
3591
|
+
function Zn(t, e) {
|
|
3587
3592
|
var s;
|
|
3588
3593
|
switch (t.container.scopeKind(e)) {
|
|
3589
3594
|
case R.INDEXES:
|
|
3590
|
-
return
|
|
3595
|
+
return Ct(t, e);
|
|
3591
3596
|
case R.REF:
|
|
3592
3597
|
{
|
|
3593
3598
|
const i = [...t.container.stack(e)];
|
|
3594
3599
|
for (; i.length > 0; ) {
|
|
3595
3600
|
const r = i.pop();
|
|
3596
3601
|
if (r instanceof H && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3597
|
-
return
|
|
3602
|
+
return Vt(
|
|
3598
3603
|
t,
|
|
3599
3604
|
e,
|
|
3600
3605
|
r
|
|
3601
3606
|
);
|
|
3602
3607
|
}
|
|
3603
3608
|
}
|
|
3604
|
-
return
|
|
3609
|
+
return Gt(t, e);
|
|
3605
3610
|
}
|
|
3606
3611
|
return O();
|
|
3607
3612
|
}
|
|
3608
|
-
function
|
|
3613
|
+
function Et(t, e, n) {
|
|
3609
3614
|
const { token: s } = t.container.token(e);
|
|
3610
3615
|
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3611
|
-
const i =
|
|
3612
|
-
return (s == null ? void 0 : s.kind) === u.COMMA &&
|
|
3616
|
+
const i = Nt(t, e);
|
|
3617
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && Re(s, e) ? De(i) : i;
|
|
3613
3618
|
}
|
|
3614
3619
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3615
|
-
return
|
|
3620
|
+
return Nt(t, e);
|
|
3616
3621
|
if (n.name instanceof $) {
|
|
3617
|
-
const i =
|
|
3622
|
+
const i = Kn(
|
|
3618
3623
|
t,
|
|
3619
3624
|
e,
|
|
3620
|
-
|
|
3625
|
+
me(n.name).unwrap()
|
|
3621
3626
|
);
|
|
3622
|
-
return (s == null ? void 0 : s.kind) === u.COLON &&
|
|
3627
|
+
return (s == null ? void 0 : s.kind) === u.COLON && Re(s, e) ? De(i) : i;
|
|
3623
3628
|
}
|
|
3624
3629
|
return O();
|
|
3625
3630
|
}
|
|
3626
|
-
function
|
|
3631
|
+
function Nt(t, e) {
|
|
3627
3632
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3628
3633
|
if (n instanceof G)
|
|
3629
3634
|
return O();
|
|
3630
|
-
if (n.body && !
|
|
3635
|
+
if (n.body && !ge(e, n.body))
|
|
3631
3636
|
switch (s) {
|
|
3632
3637
|
case R.TABLE:
|
|
3633
3638
|
return {
|
|
@@ -3722,7 +3727,7 @@ function Et(t, e) {
|
|
|
3722
3727
|
}
|
|
3723
3728
|
return O();
|
|
3724
3729
|
}
|
|
3725
|
-
function
|
|
3730
|
+
function Kn(t, e, n) {
|
|
3726
3731
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
3727
3732
|
case "update":
|
|
3728
3733
|
case "delete":
|
|
@@ -3748,42 +3753,42 @@ function Zn(t, e, n) {
|
|
|
3748
3753
|
}
|
|
3749
3754
|
return O();
|
|
3750
3755
|
}
|
|
3751
|
-
function
|
|
3756
|
+
function Vt(t, e, n) {
|
|
3752
3757
|
const s = he(n).unwrap_or([]);
|
|
3753
3758
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3754
3759
|
return O();
|
|
3755
3760
|
const i = s.map((r) => X(r).unwrap());
|
|
3756
|
-
return
|
|
3761
|
+
return Fe({
|
|
3757
3762
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3758
3763
|
label: a,
|
|
3759
3764
|
insertText: a,
|
|
3760
|
-
kind:
|
|
3765
|
+
kind: Ae(r),
|
|
3761
3766
|
range: void 0
|
|
3762
3767
|
}))
|
|
3763
3768
|
});
|
|
3764
3769
|
}
|
|
3765
|
-
function
|
|
3770
|
+
function mt(t, e, n) {
|
|
3766
3771
|
var i;
|
|
3767
3772
|
switch (t.container.scopeKind(e)) {
|
|
3768
3773
|
case R.TABLE:
|
|
3769
|
-
return es(t, e, n);
|
|
3770
|
-
case R.PROJECT:
|
|
3771
3774
|
return ts(t, e, n);
|
|
3775
|
+
case R.PROJECT:
|
|
3776
|
+
return ns(t, e, n);
|
|
3772
3777
|
case R.INDEXES:
|
|
3773
|
-
return
|
|
3778
|
+
return is(t, e);
|
|
3774
3779
|
case R.ENUM:
|
|
3775
|
-
return
|
|
3780
|
+
return es(t, e, n);
|
|
3776
3781
|
case R.REF: {
|
|
3777
|
-
const r =
|
|
3778
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON &&
|
|
3782
|
+
const r = Gt(t, e);
|
|
3783
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Re(t.container.token(e).token, e) ? De(r) : r;
|
|
3779
3784
|
}
|
|
3780
3785
|
case R.TABLEGROUP:
|
|
3781
|
-
return
|
|
3786
|
+
return ss(t);
|
|
3782
3787
|
default:
|
|
3783
3788
|
return O();
|
|
3784
3789
|
}
|
|
3785
3790
|
}
|
|
3786
|
-
function
|
|
3791
|
+
function Tt() {
|
|
3787
3792
|
return {
|
|
3788
3793
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3789
3794
|
label: t,
|
|
@@ -3794,14 +3799,14 @@ function mt() {
|
|
|
3794
3799
|
}))
|
|
3795
3800
|
};
|
|
3796
3801
|
}
|
|
3797
|
-
function
|
|
3798
|
-
return n != null && n.callee &&
|
|
3802
|
+
function es(t, e, n) {
|
|
3803
|
+
return n != null && n.callee && tt(e, n) === 1 ? Be(t, e, t.container.element(e), [
|
|
3799
3804
|
m.Schema,
|
|
3800
3805
|
m.Table,
|
|
3801
3806
|
m.Column
|
|
3802
3807
|
]) : O();
|
|
3803
3808
|
}
|
|
3804
|
-
function
|
|
3809
|
+
function ts(t, e, n) {
|
|
3805
3810
|
if (!(n != null && n.callee))
|
|
3806
3811
|
return {
|
|
3807
3812
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
@@ -3812,7 +3817,7 @@ function es(t, e, n) {
|
|
|
3812
3817
|
range: void 0
|
|
3813
3818
|
}))
|
|
3814
3819
|
};
|
|
3815
|
-
const s =
|
|
3820
|
+
const s = tt(e, n);
|
|
3816
3821
|
return s === 0 ? {
|
|
3817
3822
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3818
3823
|
label: i,
|
|
@@ -3821,10 +3826,10 @@ function es(t, e, n) {
|
|
|
3821
3826
|
kind: L.Keyword,
|
|
3822
3827
|
range: void 0
|
|
3823
3828
|
}))
|
|
3824
|
-
} : s === 1 ?
|
|
3829
|
+
} : s === 1 ? rs(t, e) : O();
|
|
3825
3830
|
}
|
|
3826
|
-
function
|
|
3827
|
-
return n != null && n.callee ?
|
|
3831
|
+
function ns(t, e, n) {
|
|
3832
|
+
return n != null && n.callee ? tt(e, n) === 0 ? {
|
|
3828
3833
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3829
3834
|
label: i,
|
|
3830
3835
|
insertText: i,
|
|
@@ -3842,15 +3847,15 @@ function ts(t, e, n) {
|
|
|
3842
3847
|
}))
|
|
3843
3848
|
};
|
|
3844
3849
|
}
|
|
3845
|
-
function
|
|
3846
|
-
return
|
|
3850
|
+
function Gt(t, e) {
|
|
3851
|
+
return Be(t, e, t.container.element(e), [
|
|
3847
3852
|
m.Schema,
|
|
3848
3853
|
m.Table,
|
|
3849
3854
|
m.Column
|
|
3850
3855
|
]);
|
|
3851
3856
|
}
|
|
3852
|
-
function
|
|
3853
|
-
return
|
|
3857
|
+
function ss(t) {
|
|
3858
|
+
return Fe({
|
|
3854
3859
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3855
3860
|
const n = ie(e).unwrap_or(void 0);
|
|
3856
3861
|
if (n === void 0)
|
|
@@ -3860,16 +3865,16 @@ function ns(t) {
|
|
|
3860
3865
|
label: i,
|
|
3861
3866
|
insertText: i,
|
|
3862
3867
|
insertTextRules: y.KeepWhitespace,
|
|
3863
|
-
kind:
|
|
3868
|
+
kind: Ae(s),
|
|
3864
3869
|
range: void 0
|
|
3865
3870
|
};
|
|
3866
3871
|
})
|
|
3867
3872
|
});
|
|
3868
3873
|
}
|
|
3869
|
-
function ss(t, e) {
|
|
3870
|
-
return Gt(t, e);
|
|
3871
|
-
}
|
|
3872
3874
|
function is(t, e) {
|
|
3875
|
+
return Ct(t, e);
|
|
3876
|
+
}
|
|
3877
|
+
function rs(t, e) {
|
|
3873
3878
|
return {
|
|
3874
3879
|
suggestions: [
|
|
3875
3880
|
...[
|
|
@@ -3937,19 +3942,19 @@ function is(t, e) {
|
|
|
3937
3942
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3938
3943
|
range: void 0
|
|
3939
3944
|
})),
|
|
3940
|
-
...
|
|
3945
|
+
...Be(t, e, t.container.element(e), [
|
|
3941
3946
|
m.Enum,
|
|
3942
3947
|
m.Schema
|
|
3943
3948
|
]).suggestions
|
|
3944
3949
|
]
|
|
3945
3950
|
};
|
|
3946
3951
|
}
|
|
3947
|
-
function
|
|
3952
|
+
function Ct(t, e) {
|
|
3948
3953
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
3949
|
-
if (!((s == null ? void 0 : s.symbol) instanceof
|
|
3954
|
+
if (!((s == null ? void 0 : s.symbol) instanceof At))
|
|
3950
3955
|
return O();
|
|
3951
3956
|
const { symbolTable: i } = s.symbol;
|
|
3952
|
-
return
|
|
3957
|
+
return Fe({
|
|
3953
3958
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
3954
3959
|
const a = ie(r).unwrap_or(void 0);
|
|
3955
3960
|
if (a === void 0)
|
|
@@ -3959,25 +3964,25 @@ function Gt(t, e) {
|
|
|
3959
3964
|
label: l,
|
|
3960
3965
|
insertText: l,
|
|
3961
3966
|
insertTextRules: y.KeepWhitespace,
|
|
3962
|
-
kind:
|
|
3967
|
+
kind: Ae(m.Column),
|
|
3963
3968
|
range: void 0
|
|
3964
3969
|
};
|
|
3965
3970
|
})
|
|
3966
3971
|
});
|
|
3967
3972
|
}
|
|
3968
|
-
function
|
|
3973
|
+
function tt(t, e) {
|
|
3969
3974
|
if (!e.callee)
|
|
3970
3975
|
return -1;
|
|
3971
3976
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
3972
3977
|
return s === -1 ? n.length : s;
|
|
3973
3978
|
}
|
|
3974
|
-
class
|
|
3979
|
+
class Xt {
|
|
3975
3980
|
constructor(e) {
|
|
3976
3981
|
this.compiler = e;
|
|
3977
3982
|
}
|
|
3978
3983
|
provideDefinition(e, n) {
|
|
3979
3984
|
var a;
|
|
3980
|
-
const { uri: s } = e, i =
|
|
3985
|
+
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
3981
3986
|
for (; r.length !== 0; ) {
|
|
3982
3987
|
const l = r.pop();
|
|
3983
3988
|
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [de.PRIMARY_EXPRESSION, de.VARIABLE].includes(l == null ? void 0 : l.kind)) {
|
|
@@ -3998,12 +4003,12 @@ class Ct {
|
|
|
3998
4003
|
return [];
|
|
3999
4004
|
}
|
|
4000
4005
|
}
|
|
4001
|
-
class
|
|
4006
|
+
class $t {
|
|
4002
4007
|
constructor(e) {
|
|
4003
4008
|
this.compiler = e;
|
|
4004
4009
|
}
|
|
4005
4010
|
provideReferences(e, n) {
|
|
4006
|
-
const { uri: s } = e, i =
|
|
4011
|
+
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
4007
4012
|
for (; r.length !== 0; ) {
|
|
4008
4013
|
const a = r.pop();
|
|
4009
4014
|
if (a && [
|
|
@@ -4027,24 +4032,24 @@ class Xt {
|
|
|
4027
4032
|
return [];
|
|
4028
4033
|
}
|
|
4029
4034
|
}
|
|
4030
|
-
const
|
|
4035
|
+
const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4031
4036
|
__proto__: null,
|
|
4032
4037
|
CompletionItemInsertTextRule: y,
|
|
4033
4038
|
CompletionItemKind: L,
|
|
4034
|
-
DBMLCompletionItemProvider:
|
|
4035
|
-
DBMLDefinitionProvider:
|
|
4036
|
-
DBMLReferencesProvider:
|
|
4039
|
+
DBMLCompletionItemProvider: Bt,
|
|
4040
|
+
DBMLDefinitionProvider: Xt,
|
|
4041
|
+
DBMLReferencesProvider: $t
|
|
4037
4042
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4038
4043
|
var R = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(R || {});
|
|
4039
|
-
class
|
|
4044
|
+
class cs {
|
|
4040
4045
|
constructor() {
|
|
4041
4046
|
this.source = "", this.cache = new Array(
|
|
4042
4047
|
16
|
|
4043
4048
|
/* TOTAL_QUERY_COUNT */
|
|
4044
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4049
|
+
).fill(null), this.nodeIdGenerator = new Yt(), this.symbolIdGenerator = new Jt(), this.token = {
|
|
4045
4050
|
invalidStream: this.createQuery(
|
|
4046
4051
|
6,
|
|
4047
|
-
() => this.parse.tokens().filter(
|
|
4052
|
+
() => this.parse.tokens().filter(vt)
|
|
4048
4053
|
),
|
|
4049
4054
|
// Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
|
|
4050
4055
|
flatStream: this.createQuery(
|
|
@@ -4056,8 +4061,8 @@ class ls {
|
|
|
4056
4061
|
_: this.createQuery(
|
|
4057
4062
|
0,
|
|
4058
4063
|
() => {
|
|
4059
|
-
const e = new
|
|
4060
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new
|
|
4064
|
+
const e = new ln(this.source).lex().chain((n) => new hn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new jn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4065
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Hn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4061
4066
|
}
|
|
4062
4067
|
),
|
|
4063
4068
|
ast: this.createQuery(
|
|
@@ -4094,7 +4099,7 @@ class ls {
|
|
|
4094
4099
|
let a = this.parse.ast();
|
|
4095
4100
|
const l = [a];
|
|
4096
4101
|
for (; ; ) {
|
|
4097
|
-
const h =
|
|
4102
|
+
const h = on(a).find((T) => ge(r, T));
|
|
4098
4103
|
if (h === void 0 || h instanceof B)
|
|
4099
4104
|
break;
|
|
4100
4105
|
l.push(h), a = h;
|
|
@@ -4193,7 +4198,7 @@ class ls {
|
|
|
4193
4198
|
let l = [a], p = [];
|
|
4194
4199
|
for (const h of e)
|
|
4195
4200
|
p = l.flatMap(
|
|
4196
|
-
(T) =>
|
|
4201
|
+
(T) => qt(h).flatMap((f) => {
|
|
4197
4202
|
const N = T.get(f), g = ie(f).unwrap_or(void 0);
|
|
4198
4203
|
return !N || !g ? [] : { ...g, symbol: N };
|
|
4199
4204
|
})
|
|
@@ -4236,14 +4241,14 @@ class ls {
|
|
|
4236
4241
|
}
|
|
4237
4242
|
initMonacoServices() {
|
|
4238
4243
|
return {
|
|
4239
|
-
definitionProvider: new
|
|
4240
|
-
referenceProvider: new
|
|
4241
|
-
autocompletionProvider: new
|
|
4244
|
+
definitionProvider: new Xt(this),
|
|
4245
|
+
referenceProvider: new $t(this),
|
|
4246
|
+
autocompletionProvider: new Bt(this)
|
|
4242
4247
|
};
|
|
4243
4248
|
}
|
|
4244
4249
|
}
|
|
4245
4250
|
export {
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4251
|
+
cs as Compiler,
|
|
4252
|
+
os as serialize,
|
|
4253
|
+
ls as services
|
|
4249
4254
|
};
|