@dbml/parse 3.4.2 → 3.5.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 +5 -5
- package/dist/dbml-parse.mjs +330 -328
- 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 jt(t) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function it(t) {
|
|
16
16
|
if (!t)
|
|
17
17
|
return !1;
|
|
18
18
|
switch (t) {
|
|
@@ -33,7 +33,7 @@ function rt(t) {
|
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function rt(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
39
|
class F {
|
|
@@ -44,22 +44,22 @@ class F {
|
|
|
44
44
|
return new F(e, n, s, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Tt(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 at(t, e) {
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || Tt(t);
|
|
52
52
|
}
|
|
53
53
|
function Ce(t) {
|
|
54
54
|
return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return t.trailingTrivia.length === 0 ? t.end :
|
|
56
|
+
function bt(t) {
|
|
57
|
+
return t.trailingTrivia.length === 0 ? t.end : bt(I.last(t.trailingTrivia));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return t.leadingTrivia.length === 0 ? t.start :
|
|
59
|
+
function It(t) {
|
|
60
|
+
return t.leadingTrivia.length === 0 ? t.start : It(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function jt(t) {
|
|
63
63
|
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
@@ -81,20 +81,20 @@ class x {
|
|
|
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 F ?
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ? It(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 F ?
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ? bt(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
94
94
|
}, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
var
|
|
97
|
+
var Ee = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(Ee || {});
|
|
98
98
|
class G extends x {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
@@ -118,7 +118,7 @@ class A extends x {
|
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
120
|
c
|
|
121
|
-
]), c && a && !(c instanceof
|
|
121
|
+
]), c && a && !(c instanceof y || c instanceof A))
|
|
122
122
|
throw new Error("If an element has a simple body, it must be a function application node");
|
|
123
123
|
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = c;
|
|
124
124
|
}
|
|
@@ -151,7 +151,7 @@ class q extends x {
|
|
|
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 Ue extends x {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
@@ -161,7 +161,7 @@ class te extends x {
|
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class
|
|
164
|
+
class y extends x {
|
|
165
165
|
constructor({ callee: e, args: n = [] }, s) {
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
@@ -184,7 +184,7 @@ class D extends x {
|
|
|
184
184
|
}, r) {
|
|
185
185
|
super(r, "<list-expression>", [
|
|
186
186
|
e,
|
|
187
|
-
...
|
|
187
|
+
...Lt(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 J extends x {
|
|
|
198
198
|
}, r) {
|
|
199
199
|
super(r, "<tuple-expression>", [
|
|
200
200
|
e,
|
|
201
|
-
...
|
|
201
|
+
...Lt(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 J {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -228,7 +228,7 @@ class H extends x {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class be extends x {
|
|
232
232
|
constructor({ literal: e }, n) {
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
@@ -243,18 +243,18 @@ class U extends x {
|
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class xe extends x {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
248
|
const s = F.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
252
|
+
class ue extends x {
|
|
253
253
|
constructor({ expression: e, indexer: n }, s) {
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function Lt(t, e) {
|
|
258
258
|
if (!t || t.length === 0)
|
|
259
259
|
return e || [];
|
|
260
260
|
if (!e || e.length === 0)
|
|
@@ -312,7 +312,7 @@ class S {
|
|
|
312
312
|
return !0;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class w {
|
|
316
316
|
// eslint-disable-next-line class-methods-use-this
|
|
317
317
|
unwrap() {
|
|
318
318
|
throw new Error("Trying to unwrap a None value");
|
|
@@ -323,11 +323,11 @@ class v {
|
|
|
323
323
|
}
|
|
324
324
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
|
325
325
|
and_then(e) {
|
|
326
|
-
return new
|
|
326
|
+
return new w();
|
|
327
327
|
}
|
|
328
328
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
|
329
329
|
map(e) {
|
|
330
|
-
return new
|
|
330
|
+
return new w();
|
|
331
331
|
}
|
|
332
332
|
// eslint-disable-next-line class-methods-use-this
|
|
333
333
|
isOk() {
|
|
@@ -335,10 +335,10 @@ 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 Oe(t) {
|
|
342
342
|
return `Table:${t}`;
|
|
343
343
|
}
|
|
344
344
|
function Ye(t) {
|
|
@@ -368,9 +368,9 @@ function Ve(t, e) {
|
|
|
368
368
|
case "Enum field":
|
|
369
369
|
return Qe(t);
|
|
370
370
|
case "Schema":
|
|
371
|
-
return
|
|
371
|
+
return je(t);
|
|
372
372
|
case "Table":
|
|
373
|
-
return
|
|
373
|
+
return Oe(t);
|
|
374
374
|
case "TableGroup":
|
|
375
375
|
return qe(t);
|
|
376
376
|
case "TableGroup field":
|
|
@@ -384,7 +384,7 @@ function ie(t) {
|
|
|
384
384
|
return Object.values(m).includes(e) ? new S({
|
|
385
385
|
name: n,
|
|
386
386
|
kind: e
|
|
387
|
-
}) : new
|
|
387
|
+
}) : new w();
|
|
388
388
|
}
|
|
389
389
|
function Qt(t) {
|
|
390
390
|
const e = ie(t).unwrap_or(void 0);
|
|
@@ -395,8 +395,8 @@ function Qt(t) {
|
|
|
395
395
|
}
|
|
396
396
|
function qt(t) {
|
|
397
397
|
return [
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
je,
|
|
399
|
+
Oe,
|
|
400
400
|
ze,
|
|
401
401
|
qe,
|
|
402
402
|
Ye,
|
|
@@ -404,21 +404,21 @@ function qt(t) {
|
|
|
404
404
|
He
|
|
405
405
|
].map((e) => e(t));
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function Me(t) {
|
|
408
408
|
return !!t.match(/(\p{L}|_|\p{M})/gu);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function Re(t) {
|
|
411
411
|
const [e] = t;
|
|
412
412
|
return e >= "0" && e <= "9";
|
|
413
413
|
}
|
|
414
414
|
function Ht(t) {
|
|
415
415
|
const [e] = t;
|
|
416
|
-
return
|
|
416
|
+
return Re(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
417
417
|
}
|
|
418
|
-
function
|
|
419
|
-
return
|
|
418
|
+
function de(t) {
|
|
419
|
+
return Me(t) || Re(t);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function ot(t, e) {
|
|
422
422
|
const n = [], s = Math.min(t.length, e.length);
|
|
423
423
|
for (let i = 0; i < s; i += 1)
|
|
424
424
|
n.push(t[i], e[i]);
|
|
@@ -438,7 +438,7 @@ class Jt {
|
|
|
438
438
|
return this.id++;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
class
|
|
441
|
+
class gt {
|
|
442
442
|
constructor({ symbolTable: e }, n) {
|
|
443
443
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
444
444
|
}
|
|
@@ -453,7 +453,7 @@ class Kt {
|
|
|
453
453
|
this.references = [], this.id = n, this.declaration = e;
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
|
-
class
|
|
456
|
+
class _t {
|
|
457
457
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
458
458
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
459
459
|
}
|
|
@@ -498,11 +498,11 @@ class B {
|
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
function sn(t, e, n) {
|
|
501
|
-
if (!t || !
|
|
502
|
-
return new
|
|
501
|
+
if (!t || !me(t) || e.length === 0)
|
|
502
|
+
return new w();
|
|
503
503
|
const s = [...e], i = Ge(t).unwrap(), r = s.pop();
|
|
504
504
|
if (!(r instanceof ne))
|
|
505
|
-
return new
|
|
505
|
+
return new w();
|
|
506
506
|
const a = I.last(s) instanceof D ? s.pop() : void 0;
|
|
507
507
|
return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new S(
|
|
508
508
|
n.create(A, {
|
|
@@ -526,9 +526,9 @@ function sn(t, e, n) {
|
|
|
526
526
|
attributeList: a,
|
|
527
527
|
body: r
|
|
528
528
|
})
|
|
529
|
-
) : new
|
|
529
|
+
) : new w();
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function ct(t) {
|
|
532
532
|
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
533
533
|
}
|
|
534
534
|
function E(t) {
|
|
@@ -548,7 +548,7 @@ function an(t) {
|
|
|
548
548
|
E(t.op), E(t.expression);
|
|
549
549
|
else if (t instanceof q)
|
|
550
550
|
E(t.leftExpression), E(t.op), E(t.rightExpression);
|
|
551
|
-
else if (t instanceof
|
|
551
|
+
else if (t instanceof Ue)
|
|
552
552
|
E(t.op), E(t.expression);
|
|
553
553
|
else if (t instanceof ne)
|
|
554
554
|
E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
|
|
@@ -558,7 +558,7 @@ function an(t) {
|
|
|
558
558
|
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
559
559
|
else if (t instanceof H)
|
|
560
560
|
E(t.callee), E(t.argumentList);
|
|
561
|
-
else if (t instanceof
|
|
561
|
+
else if (t instanceof y)
|
|
562
562
|
E(t.callee), t.args.forEach(E);
|
|
563
563
|
else if (t instanceof U)
|
|
564
564
|
E(t.expression);
|
|
@@ -566,12 +566,12 @@ function an(t) {
|
|
|
566
566
|
E(t.value);
|
|
567
567
|
else if (t instanceof Z)
|
|
568
568
|
E(t.variable);
|
|
569
|
-
else if (t instanceof
|
|
569
|
+
else if (t instanceof be)
|
|
570
570
|
E(t.literal);
|
|
571
571
|
else
|
|
572
|
-
throw t instanceof
|
|
572
|
+
throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
573
573
|
}
|
|
574
|
-
function
|
|
574
|
+
function At(t) {
|
|
575
575
|
return !!(t != null && t.isInvalid);
|
|
576
576
|
}
|
|
577
577
|
function P(...t) {
|
|
@@ -594,7 +594,7 @@ function on(t) {
|
|
|
594
594
|
return P(t.name, t.colon, t.value);
|
|
595
595
|
if (t instanceof $)
|
|
596
596
|
return t.identifiers;
|
|
597
|
-
if (t instanceof
|
|
597
|
+
if (t instanceof be)
|
|
598
598
|
return t.literal ? [t.literal] : [];
|
|
599
599
|
if (t instanceof Z)
|
|
600
600
|
return P(t.variable);
|
|
@@ -602,48 +602,48 @@ function on(t) {
|
|
|
602
602
|
return P(t.op, t.expression);
|
|
603
603
|
if (t instanceof q)
|
|
604
604
|
return P(t.leftExpression, t.op, t.rightExpression);
|
|
605
|
-
if (t instanceof
|
|
605
|
+
if (t instanceof Ue)
|
|
606
606
|
return P(t.expression, t.op);
|
|
607
607
|
if (t instanceof te)
|
|
608
608
|
return P(t.value);
|
|
609
|
-
if (t instanceof
|
|
609
|
+
if (t instanceof y)
|
|
610
610
|
return P(t.callee, ...t.args);
|
|
611
611
|
if (t instanceof ne)
|
|
612
612
|
return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
613
613
|
if (t instanceof D)
|
|
614
614
|
return P(
|
|
615
615
|
t.listOpenBracket,
|
|
616
|
-
...
|
|
616
|
+
...ot(t.elementList, t.commaList),
|
|
617
617
|
t.listCloseBracket
|
|
618
618
|
);
|
|
619
619
|
if (t instanceof J)
|
|
620
620
|
return P(
|
|
621
621
|
t.tupleOpenParen,
|
|
622
|
-
...
|
|
622
|
+
...ot(t.elementList, t.commaList),
|
|
623
623
|
t.tupleCloseParen
|
|
624
624
|
);
|
|
625
625
|
if (t instanceof H)
|
|
626
626
|
return P(t.callee, t.argumentList);
|
|
627
627
|
if (t instanceof U)
|
|
628
628
|
return P(t.expression);
|
|
629
|
-
if (t instanceof
|
|
629
|
+
if (t instanceof ue)
|
|
630
630
|
return P(
|
|
631
631
|
t.array,
|
|
632
632
|
t.indexer
|
|
633
633
|
);
|
|
634
|
-
throw t instanceof
|
|
634
|
+
throw t instanceof We ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
635
635
|
}
|
|
636
636
|
function Ge(t) {
|
|
637
|
-
return M(t) ? new S(t.expression.variable) : new
|
|
637
|
+
return M(t) ? new S(t.expression.variable) : new w();
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function j(t) {
|
|
640
640
|
var e;
|
|
641
|
-
return t instanceof U && (t.expression instanceof Z && t.expression.variable instanceof F && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof
|
|
641
|
+
return t instanceof U && (t.expression instanceof Z && t.expression.variable instanceof F && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
642
642
|
}
|
|
643
643
|
function M(t) {
|
|
644
644
|
return t instanceof U && t.expression instanceof Z && t.expression.variable instanceof F;
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function me(t) {
|
|
647
647
|
var e;
|
|
648
648
|
return t instanceof U && t.expression instanceof Z && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
649
649
|
}
|
|
@@ -651,11 +651,11 @@ function Je(t) {
|
|
|
651
651
|
var e;
|
|
652
652
|
return t instanceof q && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
653
653
|
}
|
|
654
|
-
function
|
|
654
|
+
function Te(t) {
|
|
655
655
|
if (t === void 0)
|
|
656
|
-
return new
|
|
656
|
+
return new w();
|
|
657
657
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
658
|
-
return e === "" ? new
|
|
658
|
+
return e === "" ? new w() : new S(e);
|
|
659
659
|
}
|
|
660
660
|
class cn {
|
|
661
661
|
// list of errors during lexing
|
|
@@ -767,15 +767,15 @@ class cn {
|
|
|
767
767
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
|
|
768
768
|
break;
|
|
769
769
|
default:
|
|
770
|
-
if (
|
|
770
|
+
if (it(e)) {
|
|
771
771
|
this.operator();
|
|
772
772
|
break;
|
|
773
773
|
}
|
|
774
|
-
if (
|
|
774
|
+
if (Me(e)) {
|
|
775
775
|
this.identifier();
|
|
776
776
|
break;
|
|
777
777
|
}
|
|
778
|
-
if (
|
|
778
|
+
if (Re(e)) {
|
|
779
779
|
this.numericLiteralOrIdentifier();
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
@@ -795,13 +795,13 @@ class cn {
|
|
|
795
795
|
let e = !0, n = [], s;
|
|
796
796
|
const i = [];
|
|
797
797
|
for (const r of this.tokens)
|
|
798
|
-
|
|
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);
|
|
799
799
|
this.tokens = i;
|
|
800
800
|
}
|
|
801
801
|
gatherInvalid() {
|
|
802
802
|
let e;
|
|
803
803
|
const n = [], s = [];
|
|
804
|
-
for (e = 0; e < this.tokens.length &&
|
|
804
|
+
for (e = 0; e < this.tokens.length && At(this.tokens[e]); e += 1)
|
|
805
805
|
s.push(this.tokens[e]);
|
|
806
806
|
let i = this.tokens[e];
|
|
807
807
|
for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
@@ -890,12 +890,12 @@ class cn {
|
|
|
890
890
|
});
|
|
891
891
|
}
|
|
892
892
|
identifier() {
|
|
893
|
-
for (; !this.isAtEnd() &&
|
|
893
|
+
for (; !this.isAtEnd() && de(this.peek()); )
|
|
894
894
|
this.advance();
|
|
895
895
|
this.addToken(u.IDENTIFIER);
|
|
896
896
|
}
|
|
897
897
|
operator() {
|
|
898
|
-
for (;
|
|
898
|
+
for (; it(this.peek()); )
|
|
899
899
|
this.advance();
|
|
900
900
|
this.addToken(u.OP);
|
|
901
901
|
}
|
|
@@ -910,26 +910,26 @@ class cn {
|
|
|
910
910
|
break;
|
|
911
911
|
if (!n && this.current.offset === this.text.length - 1)
|
|
912
912
|
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
913
|
-
if (!n && !
|
|
913
|
+
if (!n && !de(this.peek()))
|
|
914
914
|
return this.addToken(u.NUMERIC_LITERAL);
|
|
915
|
-
if (!n && !
|
|
915
|
+
if (!n && !Re(this.peek()))
|
|
916
916
|
break;
|
|
917
917
|
this.advance();
|
|
918
918
|
}
|
|
919
919
|
if (e > 0) {
|
|
920
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
920
|
+
for (; !this.isAtEnd() && (this.check(".") || de(this.peek())); )
|
|
921
921
|
this.advance();
|
|
922
922
|
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
923
923
|
this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
924
924
|
} else {
|
|
925
|
-
for (; !this.isAtEnd() &&
|
|
925
|
+
for (; !this.isAtEnd() && de(this.peek()); )
|
|
926
926
|
this.advance();
|
|
927
927
|
const n = this.createToken(u.IDENTIFIER, !1);
|
|
928
928
|
this.tokens.push(n);
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
colorLiteral() {
|
|
932
|
-
for (; !this.isAtEnd() &&
|
|
932
|
+
for (; !this.isAtEnd() && de(this.peek()); )
|
|
933
933
|
this.advance();
|
|
934
934
|
this.addToken(u.COLOR_LITERAL);
|
|
935
935
|
}
|
|
@@ -970,7 +970,7 @@ class cn {
|
|
|
970
970
|
case "u": {
|
|
971
971
|
let n = "";
|
|
972
972
|
for (let s = 0; s <= 3; s += 1) {
|
|
973
|
-
if (this.isAtEnd() || !
|
|
973
|
+
if (this.isAtEnd() || !de(this.peek()))
|
|
974
974
|
return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
|
|
975
975
|
n += this.advance();
|
|
976
976
|
}
|
|
@@ -981,7 +981,7 @@ class cn {
|
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
|
-
var
|
|
984
|
+
var Se = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Se || {});
|
|
985
985
|
class ln {
|
|
986
986
|
constructor() {
|
|
987
987
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
@@ -1069,7 +1069,7 @@ class hn {
|
|
|
1069
1069
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1070
1070
|
for (; !this.isAtEnd(); ) {
|
|
1071
1071
|
const s = this.peek();
|
|
1072
|
-
if (
|
|
1072
|
+
if (ct(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1073
1073
|
break;
|
|
1074
1074
|
E(s), this.advance();
|
|
1075
1075
|
}
|
|
@@ -1080,7 +1080,7 @@ class hn {
|
|
|
1080
1080
|
break;
|
|
1081
1081
|
E(s), this.advance();
|
|
1082
1082
|
}
|
|
1083
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1083
|
+
}, this.blockExpression = this.contextStack.withContextDo(Se.BlockExpression, () => {
|
|
1084
1084
|
const s = { body: [] }, i = () => this.nodeFactory.create(ne, s);
|
|
1085
1085
|
try {
|
|
1086
1086
|
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
@@ -1115,12 +1115,12 @@ class hn {
|
|
|
1115
1115
|
if (!this.check(u.RBRACE))
|
|
1116
1116
|
for (E(this.advance()); !this.isAtEnd(); ) {
|
|
1117
1117
|
const s = this.peek();
|
|
1118
|
-
if (this.check(u.RBRACE) ||
|
|
1118
|
+
if (this.check(u.RBRACE) || at(this.previous(), s))
|
|
1119
1119
|
break;
|
|
1120
1120
|
E(s), this.advance();
|
|
1121
1121
|
}
|
|
1122
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1123
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1122
|
+
}, this.tupleExpression = this.contextStack.withContextDo(Se.GroupExpression, () => {
|
|
1123
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(We, {
|
|
1124
1124
|
groupOpenParen: s.tupleOpenParen,
|
|
1125
1125
|
groupCloseParen: s.tupleCloseParen,
|
|
1126
1126
|
expression: s.elementList[0]
|
|
@@ -1171,7 +1171,7 @@ class hn {
|
|
|
1171
1171
|
break;
|
|
1172
1172
|
E(s), this.advance();
|
|
1173
1173
|
}
|
|
1174
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
1174
|
+
}, this.listExpression = this.contextStack.withContextDo(Se.ListExpression, () => {
|
|
1175
1175
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(D, s);
|
|
1176
1176
|
try {
|
|
1177
1177
|
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
@@ -1324,7 +1324,7 @@ class hn {
|
|
|
1324
1324
|
throw new d(s.token, n(), s.handlerContext);
|
|
1325
1325
|
this.synchronizeElementDeclarationName();
|
|
1326
1326
|
}
|
|
1327
|
-
if (
|
|
1327
|
+
if (ct(this.peek()))
|
|
1328
1328
|
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1329
1329
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1330
1330
|
else
|
|
@@ -1389,7 +1389,7 @@ class hn {
|
|
|
1389
1389
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1390
1390
|
expression() {
|
|
1391
1391
|
const e = { args: [] }, n = () => sn(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1392
|
-
this.nodeFactory.create(
|
|
1392
|
+
this.nodeFactory.create(y, e)
|
|
1393
1393
|
);
|
|
1394
1394
|
try {
|
|
1395
1395
|
e.callee = this.normalExpression();
|
|
@@ -1410,7 +1410,7 @@ class hn {
|
|
|
1410
1410
|
return n();
|
|
1411
1411
|
}
|
|
1412
1412
|
shouldStopExpression() {
|
|
1413
|
-
if (this.isAtEnd() ||
|
|
1413
|
+
if (this.isAtEnd() || Tt(this.previous()))
|
|
1414
1414
|
return !0;
|
|
1415
1415
|
const e = this.peek().kind;
|
|
1416
1416
|
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
@@ -1424,12 +1424,12 @@ class hn {
|
|
|
1424
1424
|
for (; !this.isAtEnd(); ) {
|
|
1425
1425
|
const s = this.peek();
|
|
1426
1426
|
if (s.kind === u.LPAREN) {
|
|
1427
|
-
const { left: i } =
|
|
1427
|
+
const { left: i } = lt(s);
|
|
1428
1428
|
if (i < e || // When '(' is encountered,
|
|
1429
1429
|
// consider it part of another expression if
|
|
1430
1430
|
// it's at the start of a new line
|
|
1431
1431
|
// and we're currently not having unmatched '(' or '['
|
|
1432
|
-
|
|
1432
|
+
at(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1433
1433
|
break;
|
|
1434
1434
|
try {
|
|
1435
1435
|
n = this.nodeFactory.create(H, {
|
|
@@ -1446,22 +1446,22 @@ class hn {
|
|
|
1446
1446
|
if (Ce(this.previous()))
|
|
1447
1447
|
break;
|
|
1448
1448
|
try {
|
|
1449
|
-
n = this.nodeFactory.create(
|
|
1449
|
+
n = this.nodeFactory.create(ue, {
|
|
1450
1450
|
expression: n,
|
|
1451
1451
|
indexer: this.listExpression()
|
|
1452
1452
|
});
|
|
1453
1453
|
} catch (i) {
|
|
1454
|
-
throw i instanceof d ? (n = this.nodeFactory.create(
|
|
1454
|
+
throw i instanceof d ? (n = this.nodeFactory.create(ue, {
|
|
1455
1455
|
expression: n,
|
|
1456
1456
|
indexer: i.partialNode
|
|
1457
1457
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
1458
1458
|
}
|
|
1459
|
-
} else if (
|
|
1460
|
-
const i = s, r =
|
|
1459
|
+
} else if (rt(s)) {
|
|
1460
|
+
const i = s, r = lt(i);
|
|
1461
1461
|
if (r.left !== null) {
|
|
1462
1462
|
if (r.left <= e)
|
|
1463
1463
|
break;
|
|
1464
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1464
|
+
this.advance(), n = this.nodeFactory.create(Ue, {
|
|
1465
1465
|
expression: n,
|
|
1466
1466
|
op: i
|
|
1467
1467
|
});
|
|
@@ -1491,7 +1491,7 @@ class hn {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
leftExpression_bp() {
|
|
1493
1493
|
let e;
|
|
1494
|
-
if (
|
|
1494
|
+
if (rt(this.peek())) {
|
|
1495
1495
|
const n = {};
|
|
1496
1496
|
n.op = this.peek();
|
|
1497
1497
|
const s = En(n.op);
|
|
@@ -1502,7 +1502,7 @@ class hn {
|
|
|
1502
1502
|
`Unexpected '${n.op.value}' in an expression`
|
|
1503
1503
|
), new d(
|
|
1504
1504
|
n.op,
|
|
1505
|
-
this.nodeFactory.create(
|
|
1505
|
+
this.nodeFactory.create(xe, { pre: n.op }),
|
|
1506
1506
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1507
1507
|
);
|
|
1508
1508
|
this.advance();
|
|
@@ -1516,10 +1516,10 @@ class hn {
|
|
|
1516
1516
|
)) : i;
|
|
1517
1517
|
}
|
|
1518
1518
|
e = this.nodeFactory.create(Q, n);
|
|
1519
|
-
} else if (e = this.extractOperand(), e instanceof
|
|
1519
|
+
} else if (e = this.extractOperand(), e instanceof xe)
|
|
1520
1520
|
throw new d(
|
|
1521
1521
|
this.peek(),
|
|
1522
|
-
this.nodeFactory.create(
|
|
1522
|
+
this.nodeFactory.create(xe, { pre: this.peek() }),
|
|
1523
1523
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1524
1524
|
);
|
|
1525
1525
|
return e;
|
|
@@ -1543,7 +1543,7 @@ class hn {
|
|
|
1543
1543
|
this.peek(),
|
|
1544
1544
|
o.INVALID_OPERAND,
|
|
1545
1545
|
`Invalid start of operand "${this.peek().value}"`
|
|
1546
|
-
), this.nodeFactory.create(
|
|
1546
|
+
), this.nodeFactory.create(xe, { pre: this.previous() }));
|
|
1547
1547
|
}
|
|
1548
1548
|
/* Parsing FunctionExpression */
|
|
1549
1549
|
functionExpression() {
|
|
@@ -1570,7 +1570,7 @@ class hn {
|
|
|
1570
1570
|
u.NUMERIC_LITERAL
|
|
1571
1571
|
))
|
|
1572
1572
|
return this.nodeFactory.create(U, {
|
|
1573
|
-
expression: this.nodeFactory.create(
|
|
1573
|
+
expression: this.nodeFactory.create(be, { literal: this.previous() })
|
|
1574
1574
|
});
|
|
1575
1575
|
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1576
1576
|
return this.nodeFactory.create(U, {
|
|
@@ -1671,7 +1671,7 @@ function En(t) {
|
|
|
1671
1671
|
const Nn = {
|
|
1672
1672
|
"(": { left: 14, right: null }
|
|
1673
1673
|
};
|
|
1674
|
-
function
|
|
1674
|
+
function lt(t) {
|
|
1675
1675
|
return Nn[t.value] || { left: null, right: null };
|
|
1676
1676
|
}
|
|
1677
1677
|
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 || {});
|
|
@@ -1688,36 +1688,36 @@ function ve(t) {
|
|
|
1688
1688
|
case b.TableGroup:
|
|
1689
1689
|
return new S(e);
|
|
1690
1690
|
default:
|
|
1691
|
-
return new
|
|
1691
|
+
return new w();
|
|
1692
1692
|
}
|
|
1693
1693
|
}
|
|
1694
|
-
function
|
|
1694
|
+
function fe(t) {
|
|
1695
1695
|
if (!Je(t))
|
|
1696
1696
|
return new S([t]);
|
|
1697
|
-
const e =
|
|
1698
|
-
return e ? (e.push(t.rightExpression), new S(e)) : new
|
|
1697
|
+
const e = fe(t.leftExpression).unwrap_or(void 0);
|
|
1698
|
+
return e ? (e.push(t.rightExpression), new S(e)) : new w();
|
|
1699
1699
|
}
|
|
1700
1700
|
function C(t) {
|
|
1701
1701
|
if (t === void 0)
|
|
1702
|
-
return new
|
|
1703
|
-
const e =
|
|
1702
|
+
return new w();
|
|
1703
|
+
const e = fe(t).unwrap_or(void 0);
|
|
1704
1704
|
if (!e)
|
|
1705
|
-
return new
|
|
1705
|
+
return new w();
|
|
1706
1706
|
const n = [];
|
|
1707
1707
|
for (const s of e) {
|
|
1708
1708
|
const i = X(s).unwrap_or(void 0);
|
|
1709
1709
|
if (!i)
|
|
1710
|
-
return new
|
|
1710
|
+
return new w();
|
|
1711
1711
|
n.push(i);
|
|
1712
1712
|
}
|
|
1713
1713
|
return new S(n);
|
|
1714
1714
|
}
|
|
1715
1715
|
function _e(t) {
|
|
1716
1716
|
if (t === void 0)
|
|
1717
|
-
return new
|
|
1718
|
-
const e =
|
|
1717
|
+
return new w();
|
|
1718
|
+
const e = fe(t).unwrap_or(void 0);
|
|
1719
1719
|
if (!e || e.length === 0)
|
|
1720
|
-
return new
|
|
1720
|
+
return new w();
|
|
1721
1721
|
const n = [];
|
|
1722
1722
|
let s;
|
|
1723
1723
|
if (!M(I.last(e))) {
|
|
@@ -1727,12 +1727,12 @@ function _e(t) {
|
|
|
1727
1727
|
(r) => V(r).unwrap()
|
|
1728
1728
|
);
|
|
1729
1729
|
else
|
|
1730
|
-
return new
|
|
1730
|
+
return new w();
|
|
1731
1731
|
}
|
|
1732
1732
|
for (const i of e) {
|
|
1733
1733
|
const r = X(i).unwrap_or(void 0);
|
|
1734
1734
|
if (!r)
|
|
1735
|
-
return new
|
|
1735
|
+
return new w();
|
|
1736
1736
|
n.push(r);
|
|
1737
1737
|
}
|
|
1738
1738
|
return new S({
|
|
@@ -1741,26 +1741,26 @@ function _e(t) {
|
|
|
1741
1741
|
});
|
|
1742
1742
|
}
|
|
1743
1743
|
function X(t) {
|
|
1744
|
-
return M(t) ? new S(t.expression.variable.value) : new
|
|
1744
|
+
return M(t) ? new S(t.expression.variable.value) : new w();
|
|
1745
1745
|
}
|
|
1746
1746
|
function Xe(t) {
|
|
1747
|
-
if (
|
|
1747
|
+
if (ut(t))
|
|
1748
1748
|
return t instanceof te ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1749
|
-
if (t instanceof J && t.elementList.every(
|
|
1749
|
+
if (t instanceof J && t.elementList.every(ut)) {
|
|
1750
1750
|
const e = t.elementList.filter(
|
|
1751
1751
|
(s) => s instanceof te
|
|
1752
1752
|
), n = t.elementList.filter(M);
|
|
1753
1753
|
return new S({ functional: e, nonFunctional: n });
|
|
1754
1754
|
}
|
|
1755
|
-
return new
|
|
1755
|
+
return new w();
|
|
1756
1756
|
}
|
|
1757
1757
|
function V(t) {
|
|
1758
1758
|
var n;
|
|
1759
1759
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1760
|
-
return e === void 0 ? new
|
|
1760
|
+
return e === void 0 ? new w() : new S(e);
|
|
1761
1761
|
}
|
|
1762
1762
|
function z(t) {
|
|
1763
|
-
return
|
|
1763
|
+
return j(t) ? t.expression instanceof Z ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new w();
|
|
1764
1764
|
}
|
|
1765
1765
|
function mn(t) {
|
|
1766
1766
|
var e;
|
|
@@ -1773,7 +1773,7 @@ function Tn(t) {
|
|
|
1773
1773
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1774
1774
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1775
1775
|
}
|
|
1776
|
-
function
|
|
1776
|
+
function ut(t) {
|
|
1777
1777
|
return t instanceof U && t.expression instanceof Z || t instanceof te;
|
|
1778
1778
|
}
|
|
1779
1779
|
function bn(t, e) {
|
|
@@ -1815,7 +1815,7 @@ class In {
|
|
|
1815
1815
|
if (e instanceof ne)
|
|
1816
1816
|
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1817
1817
|
const n = [];
|
|
1818
|
-
return
|
|
1818
|
+
return j(e.callee) || n.push(new l(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 l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
1821
|
class we {
|
|
@@ -1846,7 +1846,7 @@ class Ln {
|
|
|
1846
1846
|
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1847
1847
|
}
|
|
1848
1848
|
validateName(e) {
|
|
1849
|
-
return e ?
|
|
1849
|
+
return e ? wt(e) ? [] : [new l(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new l(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
1850
1850
|
}
|
|
1851
1851
|
validateAlias(e) {
|
|
1852
1852
|
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
@@ -1856,7 +1856,7 @@ class Ln {
|
|
|
1856
1856
|
this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new we() });
|
|
1857
1857
|
const { name: n } = this.declarationNode, s = C(n);
|
|
1858
1858
|
if (s.isOk()) {
|
|
1859
|
-
const i = s.unwrap(), r = i.pop(), a =
|
|
1859
|
+
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = ze(r);
|
|
1860
1860
|
a.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(c, this.declarationNode.symbol);
|
|
1861
1861
|
}
|
|
1862
1862
|
return e;
|
|
@@ -1867,9 +1867,9 @@ class Ln {
|
|
|
1867
1867
|
validateBody(e) {
|
|
1868
1868
|
if (!e)
|
|
1869
1869
|
return [];
|
|
1870
|
-
if (e instanceof
|
|
1870
|
+
if (e instanceof y)
|
|
1871
1871
|
return this.validateFields([e]);
|
|
1872
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1872
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
1873
1873
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1874
1874
|
}
|
|
1875
1875
|
validateFields(e) {
|
|
@@ -1881,13 +1881,13 @@ class Ln {
|
|
|
1881
1881
|
});
|
|
1882
1882
|
}
|
|
1883
1883
|
validateFieldSettings(e) {
|
|
1884
|
-
const n =
|
|
1884
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
1885
1885
|
for (const r in i) {
|
|
1886
1886
|
const a = i[r];
|
|
1887
1887
|
switch (r) {
|
|
1888
1888
|
case "note":
|
|
1889
1889
|
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
1890
|
-
|
|
1890
|
+
j(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1891
1891
|
});
|
|
1892
1892
|
break;
|
|
1893
1893
|
default:
|
|
@@ -1943,9 +1943,9 @@ class gn {
|
|
|
1943
1943
|
validateBody(e) {
|
|
1944
1944
|
if (!e)
|
|
1945
1945
|
return [];
|
|
1946
|
-
if (e instanceof
|
|
1946
|
+
if (e instanceof y)
|
|
1947
1947
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1948
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1948
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
1949
1949
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1950
1950
|
}
|
|
1951
1951
|
validateFields(e) {
|
|
@@ -1961,20 +1961,20 @@ class gn {
|
|
|
1961
1961
|
});
|
|
1962
1962
|
}
|
|
1963
1963
|
validateFieldSetting(e) {
|
|
1964
|
-
const n =
|
|
1964
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
1965
1965
|
for (const r in i) {
|
|
1966
1966
|
const a = i[r];
|
|
1967
1967
|
switch (r) {
|
|
1968
1968
|
case "note":
|
|
1969
1969
|
case "name":
|
|
1970
1970
|
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1971
|
-
|
|
1971
|
+
j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
|
|
1972
1972
|
});
|
|
1973
1973
|
break;
|
|
1974
1974
|
case "unique":
|
|
1975
1975
|
case "pk":
|
|
1976
1976
|
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1977
|
-
|
|
1977
|
+
le(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
|
|
1978
1978
|
});
|
|
1979
1979
|
break;
|
|
1980
1980
|
case "type":
|
|
@@ -2027,14 +2027,14 @@ class _n {
|
|
|
2027
2027
|
validateBody(e) {
|
|
2028
2028
|
if (!e)
|
|
2029
2029
|
return [];
|
|
2030
|
-
if (e instanceof
|
|
2030
|
+
if (e instanceof y)
|
|
2031
2031
|
return this.validateFields([e]);
|
|
2032
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2032
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2033
2033
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2034
2034
|
}
|
|
2035
2035
|
validateFields(e) {
|
|
2036
2036
|
const n = [];
|
|
2037
|
-
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))),
|
|
2037
|
+
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), j(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2038
2038
|
}
|
|
2039
2039
|
validateSubElements(e) {
|
|
2040
2040
|
return e.flatMap((n) => {
|
|
@@ -2056,7 +2056,7 @@ class An {
|
|
|
2056
2056
|
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2057
2057
|
}
|
|
2058
2058
|
validateName(e) {
|
|
2059
|
-
return e ?
|
|
2059
|
+
return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2060
2060
|
}
|
|
2061
2061
|
validateAlias(e) {
|
|
2062
2062
|
return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
@@ -2067,9 +2067,9 @@ class An {
|
|
|
2067
2067
|
validateBody(e) {
|
|
2068
2068
|
if (!e)
|
|
2069
2069
|
return [];
|
|
2070
|
-
if (e instanceof
|
|
2070
|
+
if (e instanceof y)
|
|
2071
2071
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2072
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2072
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2073
2073
|
return [
|
|
2074
2074
|
...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2075
2075
|
...this.validateSubElements(s)
|
|
@@ -2095,7 +2095,7 @@ class vn {
|
|
|
2095
2095
|
return this.declarationNode.parent instanceof G ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2096
2096
|
}
|
|
2097
2097
|
validateName(e) {
|
|
2098
|
-
return e ?
|
|
2098
|
+
return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2099
2099
|
}
|
|
2100
2100
|
validateAlias(e) {
|
|
2101
2101
|
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
@@ -2106,9 +2106,9 @@ class vn {
|
|
|
2106
2106
|
validateBody(e) {
|
|
2107
2107
|
if (!e)
|
|
2108
2108
|
return [];
|
|
2109
|
-
if (e instanceof
|
|
2109
|
+
if (e instanceof y)
|
|
2110
2110
|
return this.validateFields([e]);
|
|
2111
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2111
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2112
2112
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2113
2113
|
}
|
|
2114
2114
|
validateFields(e) {
|
|
@@ -2122,7 +2122,7 @@ class vn {
|
|
|
2122
2122
|
}), n;
|
|
2123
2123
|
}
|
|
2124
2124
|
validateFieldSettings(e) {
|
|
2125
|
-
const n =
|
|
2125
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
2126
2126
|
for (const r in i) {
|
|
2127
2127
|
const a = i[r];
|
|
2128
2128
|
switch (r) {
|
|
@@ -2151,7 +2151,7 @@ function wn(t) {
|
|
|
2151
2151
|
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
|
|
2152
2152
|
return !1;
|
|
2153
2153
|
let e;
|
|
2154
|
-
if (t instanceof $ ? e =
|
|
2154
|
+
if (t instanceof $ ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2155
2155
|
switch (e.toLowerCase()) {
|
|
2156
2156
|
case "cascade":
|
|
2157
2157
|
case "no action":
|
|
@@ -2175,13 +2175,13 @@ class yn {
|
|
|
2175
2175
|
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2176
2176
|
}
|
|
2177
2177
|
validateName(e) {
|
|
2178
|
-
return e ? e instanceof
|
|
2178
|
+
return e ? e instanceof ue ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : wt(e) ? [] : [new l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2179
2179
|
}
|
|
2180
2180
|
validateAlias(e) {
|
|
2181
2181
|
return e ? On(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2182
2182
|
}
|
|
2183
2183
|
validateSettingList(e) {
|
|
2184
|
-
const n =
|
|
2184
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
2185
2185
|
for (const r in i) {
|
|
2186
2186
|
const a = i[r];
|
|
2187
2187
|
switch (r) {
|
|
@@ -2192,7 +2192,7 @@ class yn {
|
|
|
2192
2192
|
break;
|
|
2193
2193
|
case "note":
|
|
2194
2194
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
2195
|
-
|
|
2195
|
+
j(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2196
2196
|
});
|
|
2197
2197
|
break;
|
|
2198
2198
|
default:
|
|
@@ -2203,14 +2203,14 @@ class yn {
|
|
|
2203
2203
|
}
|
|
2204
2204
|
registerElement() {
|
|
2205
2205
|
const e = [];
|
|
2206
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2206
|
+
this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2207
2207
|
const { name: n, alias: s } = this.declarationNode, i = C(n);
|
|
2208
2208
|
if (i.isOk()) {
|
|
2209
|
-
const r = [...i.unwrap()], a = r.pop(), c =
|
|
2209
|
+
const r = [...i.unwrap()], a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
|
|
2210
2210
|
c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), c.set(p, this.declarationNode.symbol);
|
|
2211
2211
|
}
|
|
2212
|
-
if (s &&
|
|
2213
|
-
const r = V(s).unwrap(), a =
|
|
2212
|
+
if (s && ye(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2213
|
+
const r = V(s).unwrap(), a = Oe(r);
|
|
2214
2214
|
this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2215
2215
|
}
|
|
2216
2216
|
return e;
|
|
@@ -2218,9 +2218,9 @@ class yn {
|
|
|
2218
2218
|
validateBody(e) {
|
|
2219
2219
|
if (!e)
|
|
2220
2220
|
return [];
|
|
2221
|
-
if (e instanceof
|
|
2221
|
+
if (e instanceof y)
|
|
2222
2222
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2223
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2223
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2224
2224
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2225
2225
|
}
|
|
2226
2226
|
validateFields(e) {
|
|
@@ -2251,13 +2251,13 @@ class yn {
|
|
|
2251
2251
|
}
|
|
2252
2252
|
// This is needed to support legacy inline settings
|
|
2253
2253
|
validateFieldSetting(e) {
|
|
2254
|
-
if (!e.slice(0, -1).every(
|
|
2254
|
+
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof D))
|
|
2255
2255
|
return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2256
2256
|
if (e.length === 0)
|
|
2257
2257
|
return [];
|
|
2258
2258
|
let n;
|
|
2259
2259
|
I.last(e) instanceof D && (n = e.pop());
|
|
2260
|
-
const s =
|
|
2260
|
+
const s = W(n), i = s.getErrors(), r = s.getValue();
|
|
2261
2261
|
for (const p of e) {
|
|
2262
2262
|
const h = V(p).unwrap_or("").toLowerCase();
|
|
2263
2263
|
if (h !== "pk" && h !== "unique") {
|
|
@@ -2273,7 +2273,7 @@ class yn {
|
|
|
2273
2273
|
switch (p) {
|
|
2274
2274
|
case "note":
|
|
2275
2275
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2276
|
-
|
|
2276
|
+
j(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2277
2277
|
});
|
|
2278
2278
|
break;
|
|
2279
2279
|
case "ref":
|
|
@@ -2283,34 +2283,34 @@ class yn {
|
|
|
2283
2283
|
break;
|
|
2284
2284
|
case "primary key":
|
|
2285
2285
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
|
|
2286
|
-
|
|
2286
|
+
le(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
|
|
2287
2287
|
});
|
|
2288
2288
|
break;
|
|
2289
2289
|
case "pk":
|
|
2290
2290
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
|
|
2291
|
-
f instanceof se && !
|
|
2291
|
+
f instanceof se && !le(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
|
|
2292
2292
|
});
|
|
2293
2293
|
break;
|
|
2294
2294
|
case "not null":
|
|
2295
2295
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
|
|
2296
2296
|
const T = r.null || [];
|
|
2297
2297
|
h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
|
|
2298
|
-
|
|
2298
|
+
le(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
|
|
2299
2299
|
});
|
|
2300
2300
|
break;
|
|
2301
2301
|
case "null":
|
|
2302
2302
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
|
|
2303
|
-
|
|
2303
|
+
le(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
|
|
2304
2304
|
});
|
|
2305
2305
|
break;
|
|
2306
2306
|
case "unique":
|
|
2307
2307
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
|
|
2308
|
-
f instanceof se && !
|
|
2308
|
+
f instanceof se && !le(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
|
|
2309
2309
|
});
|
|
2310
2310
|
break;
|
|
2311
2311
|
case "increment":
|
|
2312
2312
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
|
|
2313
|
-
f instanceof se && !
|
|
2313
|
+
f instanceof se && !le(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
|
|
2314
2314
|
});
|
|
2315
2315
|
break;
|
|
2316
2316
|
case "default":
|
|
@@ -2338,15 +2338,15 @@ class yn {
|
|
|
2338
2338
|
}
|
|
2339
2339
|
}
|
|
2340
2340
|
function kn(t) {
|
|
2341
|
-
if (!(t instanceof H || Je(t) || t instanceof U || t instanceof
|
|
2341
|
+
if (!(t instanceof H || Je(t) || t instanceof U || t instanceof ue))
|
|
2342
2342
|
return !1;
|
|
2343
2343
|
if (t instanceof H) {
|
|
2344
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2344
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => he(n) || j(n) || me(n)))
|
|
2345
2345
|
return !1;
|
|
2346
2346
|
t = t.callee;
|
|
2347
2347
|
}
|
|
2348
|
-
for (; t instanceof
|
|
2349
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value &&
|
|
2348
|
+
for (; t instanceof ue; ) {
|
|
2349
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && he(n.name)))
|
|
2350
2350
|
return !1;
|
|
2351
2351
|
t = t.array;
|
|
2352
2352
|
}
|
|
@@ -2367,7 +2367,7 @@ class Sn {
|
|
|
2367
2367
|
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
2368
2368
|
}
|
|
2369
2369
|
validateName(e) {
|
|
2370
|
-
return e ?
|
|
2370
|
+
return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A TableGroup name must be a single identifier", e)] : [new l(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
2371
2371
|
}
|
|
2372
2372
|
validateAlias(e) {
|
|
2373
2373
|
return e ? [new l(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
|
|
@@ -2377,9 +2377,9 @@ class Sn {
|
|
|
2377
2377
|
this.declarationNode.symbol = this.symbolFactory.create(tn, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2378
2378
|
const n = C(e);
|
|
2379
2379
|
if (n.isOk()) {
|
|
2380
|
-
const s = n.unwrap(), i = s.pop(), r =
|
|
2380
|
+
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
|
|
2381
2381
|
if (r.has(a))
|
|
2382
|
-
return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists
|
|
2382
|
+
return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
|
|
2383
2383
|
r.set(a, this.declarationNode.symbol);
|
|
2384
2384
|
}
|
|
2385
2385
|
return [];
|
|
@@ -2390,9 +2390,9 @@ class Sn {
|
|
|
2390
2390
|
validateBody(e) {
|
|
2391
2391
|
if (!e)
|
|
2392
2392
|
return [];
|
|
2393
|
-
if (e instanceof
|
|
2393
|
+
if (e instanceof y)
|
|
2394
2394
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2395
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2395
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2396
2396
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2397
2397
|
}
|
|
2398
2398
|
validateFields(e) {
|
|
@@ -2426,7 +2426,7 @@ class Sn {
|
|
|
2426
2426
|
return [];
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
2429
|
-
const
|
|
2429
|
+
const vt = ["-", "+"];
|
|
2430
2430
|
function re(t) {
|
|
2431
2431
|
switch (t.type.value.toLowerCase()) {
|
|
2432
2432
|
case b.Enum:
|
|
@@ -2447,28 +2447,28 @@ function re(t) {
|
|
|
2447
2447
|
return In;
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
function
|
|
2450
|
+
function wt(t) {
|
|
2451
2451
|
return !!C(t).unwrap_or(!1);
|
|
2452
2452
|
}
|
|
2453
2453
|
function On(t) {
|
|
2454
|
-
return
|
|
2454
|
+
return ye(t);
|
|
2455
2455
|
}
|
|
2456
|
-
function
|
|
2456
|
+
function ye(t) {
|
|
2457
2457
|
return t instanceof U && t.expression instanceof Z;
|
|
2458
2458
|
}
|
|
2459
|
-
function
|
|
2459
|
+
function Ze(t, e, n) {
|
|
2460
2460
|
var i;
|
|
2461
2461
|
t[0] === "public" && (t = t.slice(1));
|
|
2462
2462
|
let s = e;
|
|
2463
2463
|
for (const r of t) {
|
|
2464
2464
|
let a;
|
|
2465
|
-
const c =
|
|
2465
|
+
const c = je(r);
|
|
2466
2466
|
if (s.has(c)) {
|
|
2467
2467
|
if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
|
|
2468
2468
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2469
2469
|
} else {
|
|
2470
2470
|
a = new we();
|
|
2471
|
-
const p = n.create(
|
|
2471
|
+
const p = n.create(gt, { symbolTable: a });
|
|
2472
2472
|
s.set(c, p);
|
|
2473
2473
|
}
|
|
2474
2474
|
s = a;
|
|
@@ -2480,7 +2480,7 @@ function yt(t) {
|
|
|
2480
2480
|
}
|
|
2481
2481
|
function Rn(t) {
|
|
2482
2482
|
var n;
|
|
2483
|
-
if (!(t instanceof U) || !(t.expression instanceof
|
|
2483
|
+
if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2484
2484
|
return !1;
|
|
2485
2485
|
const e = t.expression.literal.value;
|
|
2486
2486
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
@@ -2490,16 +2490,16 @@ function Rn(t) {
|
|
|
2490
2490
|
return !1;
|
|
2491
2491
|
return !0;
|
|
2492
2492
|
}
|
|
2493
|
-
function
|
|
2493
|
+
function le(t) {
|
|
2494
2494
|
return t === void 0;
|
|
2495
2495
|
}
|
|
2496
2496
|
function Dn(t) {
|
|
2497
2497
|
var e;
|
|
2498
|
-
return !!(
|
|
2498
|
+
return !!(j(t) || he(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && vt.includes((e = t.op) == null ? void 0 : e.value) && he(t.expression) || t instanceof te);
|
|
2499
2499
|
}
|
|
2500
|
-
function
|
|
2500
|
+
function he(t) {
|
|
2501
2501
|
var e;
|
|
2502
|
-
return t instanceof U && t.expression instanceof
|
|
2502
|
+
return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
|
|
2503
2503
|
}
|
|
2504
2504
|
function Pn(t) {
|
|
2505
2505
|
var n;
|
|
@@ -2511,7 +2511,7 @@ function Pn(t) {
|
|
|
2511
2511
|
function kt(t) {
|
|
2512
2512
|
return t instanceof J && t.elementList.every(M);
|
|
2513
2513
|
}
|
|
2514
|
-
function
|
|
2514
|
+
function W(t) {
|
|
2515
2515
|
var s;
|
|
2516
2516
|
const e = {}, n = [];
|
|
2517
2517
|
if (!t)
|
|
@@ -2523,14 +2523,14 @@ function j(t) {
|
|
|
2523
2523
|
n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2524
2524
|
continue;
|
|
2525
2525
|
}
|
|
2526
|
-
const r = (s =
|
|
2526
|
+
const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2527
2527
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2528
2528
|
}
|
|
2529
2529
|
return new B(e, n);
|
|
2530
2530
|
}
|
|
2531
|
-
class
|
|
2531
|
+
class ht {
|
|
2532
2532
|
constructor(e, n) {
|
|
2533
|
-
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(
|
|
2533
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(gt, {
|
|
2534
2534
|
symbolTable: new we()
|
|
2535
2535
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2536
2536
|
}
|
|
@@ -2562,7 +2562,7 @@ class ae {
|
|
|
2562
2562
|
for (const s of e.elementList) {
|
|
2563
2563
|
if (s.name instanceof U)
|
|
2564
2564
|
continue;
|
|
2565
|
-
const i =
|
|
2565
|
+
const i = Te(s.name).unwrap_or(void 0);
|
|
2566
2566
|
if (!i)
|
|
2567
2567
|
continue;
|
|
2568
2568
|
const r = n[i.toLowerCase()];
|
|
@@ -2602,7 +2602,7 @@ class ae {
|
|
|
2602
2602
|
return;
|
|
2603
2603
|
this.bindFragments([e], n);
|
|
2604
2604
|
} else
|
|
2605
|
-
e instanceof q ? Je(e) ? this.bindFragments(
|
|
2605
|
+
e instanceof q ? Je(e) ? this.bindFragments(fe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2606
2606
|
}
|
|
2607
2607
|
// Bind the fragments of a member access expression
|
|
2608
2608
|
// which can be a simple expression like v1.User,
|
|
@@ -2849,7 +2849,7 @@ class $n {
|
|
|
2849
2849
|
return new B(this.ast, this.errors);
|
|
2850
2850
|
}
|
|
2851
2851
|
}
|
|
2852
|
-
class
|
|
2852
|
+
class Wn {
|
|
2853
2853
|
constructor(e) {
|
|
2854
2854
|
this.generator = e;
|
|
2855
2855
|
}
|
|
@@ -2857,20 +2857,20 @@ class jn {
|
|
|
2857
2857
|
return new e(n, this.generator.nextId());
|
|
2858
2858
|
}
|
|
2859
2859
|
}
|
|
2860
|
-
class
|
|
2860
|
+
class jn {
|
|
2861
2861
|
constructor(e, n) {
|
|
2862
|
-
this.ast = e, this.symbolFactory = new
|
|
2862
|
+
this.ast = e, this.symbolFactory = new Wn(n);
|
|
2863
2863
|
}
|
|
2864
2864
|
// Analyzing: Invoking both the validator and binder
|
|
2865
2865
|
analyze() {
|
|
2866
|
-
return new
|
|
2866
|
+
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new $n(n).resolve());
|
|
2867
2867
|
}
|
|
2868
2868
|
// For invoking the validator only
|
|
2869
2869
|
validate() {
|
|
2870
|
-
return new
|
|
2870
|
+
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
|
|
2871
2871
|
}
|
|
2872
2872
|
}
|
|
2873
|
-
function
|
|
2873
|
+
function ft(t, e) {
|
|
2874
2874
|
const { variables: n, tupleElements: s } = _e(t).unwrap();
|
|
2875
2875
|
return s ? n.length === 0 ? {
|
|
2876
2876
|
schemaName: e.schemaName,
|
|
@@ -2903,7 +2903,7 @@ function St(t) {
|
|
|
2903
2903
|
}
|
|
2904
2904
|
throw new Error("Invalid relation op");
|
|
2905
2905
|
}
|
|
2906
|
-
function
|
|
2906
|
+
function v(t) {
|
|
2907
2907
|
return {
|
|
2908
2908
|
start: {
|
|
2909
2909
|
offset: t.startPos.offset,
|
|
@@ -2915,10 +2915,10 @@ function y(t) {
|
|
|
2915
2915
|
}
|
|
2916
2916
|
function $e(t) {
|
|
2917
2917
|
var n;
|
|
2918
|
-
const e = (n =
|
|
2918
|
+
const e = (n = fe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2919
2919
|
return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2920
2920
|
}
|
|
2921
|
-
function
|
|
2921
|
+
function Ie(t) {
|
|
2922
2922
|
const e = C(t).unwrap();
|
|
2923
2923
|
return {
|
|
2924
2924
|
name: e.pop(),
|
|
@@ -2944,7 +2944,7 @@ function Dt(t, e) {
|
|
|
2944
2944
|
const n = t.id, s = e.id;
|
|
2945
2945
|
return n === s;
|
|
2946
2946
|
}
|
|
2947
|
-
function
|
|
2947
|
+
function Ne(t) {
|
|
2948
2948
|
const e = t.split(`
|
|
2949
2949
|
`), n = e.slice(e.findIndex((r) => r.trimStart() !== "")), s = n.filter((r) => r.trimStart()), i = Math.min(...s.map((r) => r.length - r.trimStart().length));
|
|
2950
2950
|
return n.map((r) => r.slice(i)).join(`
|
|
@@ -2955,7 +2955,7 @@ class Pt {
|
|
|
2955
2955
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2956
2956
|
}
|
|
2957
2957
|
interpret() {
|
|
2958
|
-
this.table.token =
|
|
2958
|
+
this.table.token = v(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
|
|
2959
2959
|
const e = [
|
|
2960
2960
|
...this.interpretName(this.declarationNode.name),
|
|
2961
2961
|
...this.interpretAlias(this.declarationNode.alias),
|
|
@@ -2974,7 +2974,7 @@ class Pt {
|
|
|
2974
2974
|
}), this.pkColumns.forEach((n) => n.pk = !1)), e;
|
|
2975
2975
|
}
|
|
2976
2976
|
interpretName(e) {
|
|
2977
|
-
const { name: n, schemaName: s } =
|
|
2977
|
+
const { name: n, schemaName: s } = Ie(e);
|
|
2978
2978
|
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
2979
2979
|
}
|
|
2980
2980
|
interpretAlias(e) {
|
|
@@ -2992,16 +2992,16 @@ class Pt {
|
|
|
2992
2992
|
}
|
|
2993
2993
|
interpretSettingList(e) {
|
|
2994
2994
|
var i, r, a;
|
|
2995
|
-
const n =
|
|
2995
|
+
const n = W(e).getValue();
|
|
2996
2996
|
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;
|
|
2997
2997
|
const [s] = n.note || [];
|
|
2998
2998
|
return this.table.note = s && {
|
|
2999
|
-
value: z(s == null ? void 0 : s.value).map(
|
|
3000
|
-
token:
|
|
2999
|
+
value: z(s == null ? void 0 : s.value).map(Ne).unwrap(),
|
|
3000
|
+
token: v(s)
|
|
3001
3001
|
}, [];
|
|
3002
3002
|
}
|
|
3003
3003
|
interpretBody(e) {
|
|
3004
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
3004
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
3005
3005
|
return [...this.interpretFields(n), ...this.interpretSubElements(s)];
|
|
3006
3006
|
}
|
|
3007
3007
|
interpretSubElements(e) {
|
|
@@ -3010,8 +3010,8 @@ class Pt {
|
|
|
3010
3010
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3011
3011
|
case "note":
|
|
3012
3012
|
return this.table.note = {
|
|
3013
|
-
value: z(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(
|
|
3014
|
-
token:
|
|
3013
|
+
value: z(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(Ne).unwrap(),
|
|
3014
|
+
token: v(n)
|
|
3015
3015
|
}, [];
|
|
3016
3016
|
case "indexes":
|
|
3017
3017
|
return this.interpretIndexes(n);
|
|
@@ -3027,63 +3027,63 @@ class Pt {
|
|
|
3027
3027
|
const n = [], s = {};
|
|
3028
3028
|
s.name = V(e.callee).unwrap();
|
|
3029
3029
|
const i = Yn(e.args[0]);
|
|
3030
|
-
s.type = i.getValue(), n.push(...i.getErrors()), s.token =
|
|
3030
|
+
s.type = i.getValue(), n.push(...i.getErrors()), s.token = v(e), s.inline_refs = [];
|
|
3031
3031
|
const r = e.args.slice(1);
|
|
3032
3032
|
if (I.last(r) instanceof D) {
|
|
3033
|
-
const _ =
|
|
3033
|
+
const _ = W(r.pop()).getValue();
|
|
3034
3034
|
s.pk = !!((a = _.pk) != null && a.length) || !!((c = _["primary key"]) != null && c.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);
|
|
3035
3035
|
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3036
3036
|
s.note = K && {
|
|
3037
|
-
value: z(K.value).map(
|
|
3038
|
-
token:
|
|
3037
|
+
value: z(K.value).map(Ne).unwrap(),
|
|
3038
|
+
token: v(K)
|
|
3039
3039
|
};
|
|
3040
|
-
const
|
|
3041
|
-
s.inline_refs =
|
|
3042
|
-
const [
|
|
3043
|
-
if (Dt(
|
|
3040
|
+
const oe = _.ref || [];
|
|
3041
|
+
s.inline_refs = oe.flatMap((Y) => {
|
|
3042
|
+
const [tt] = $e(Y.value.expression);
|
|
3043
|
+
if (Dt(tt, e.symbol))
|
|
3044
3044
|
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
|
|
3045
|
-
const
|
|
3046
|
-
let
|
|
3045
|
+
const ke = Y.value.op, ee = C(Y.value.expression).unwrap();
|
|
3046
|
+
let pe;
|
|
3047
3047
|
if (ee.length === 1) {
|
|
3048
|
-
const [
|
|
3049
|
-
|
|
3048
|
+
const [ce] = ee;
|
|
3049
|
+
pe = {
|
|
3050
3050
|
schemaName: this.table.schemaName,
|
|
3051
3051
|
tableName: this.table.name,
|
|
3052
|
-
fieldNames: [
|
|
3053
|
-
relation:
|
|
3054
|
-
token:
|
|
3052
|
+
fieldNames: [ce],
|
|
3053
|
+
relation: ke.value,
|
|
3054
|
+
token: v(Y)
|
|
3055
3055
|
};
|
|
3056
3056
|
} else if (ee.length === 2) {
|
|
3057
|
-
const [
|
|
3058
|
-
|
|
3057
|
+
const [ce, Le] = ee;
|
|
3058
|
+
pe = {
|
|
3059
3059
|
schemaName: null,
|
|
3060
|
-
tableName:
|
|
3060
|
+
tableName: ce,
|
|
3061
3061
|
fieldNames: [Le],
|
|
3062
|
-
relation:
|
|
3063
|
-
token:
|
|
3062
|
+
relation: ke.value,
|
|
3063
|
+
token: v(Y)
|
|
3064
3064
|
};
|
|
3065
3065
|
} else if (ee.length === 3) {
|
|
3066
|
-
const [
|
|
3067
|
-
|
|
3068
|
-
schemaName:
|
|
3066
|
+
const [ce, Le, st] = ee;
|
|
3067
|
+
pe = {
|
|
3068
|
+
schemaName: ce,
|
|
3069
3069
|
tableName: Le,
|
|
3070
|
-
fieldNames: [
|
|
3071
|
-
relation:
|
|
3072
|
-
token:
|
|
3070
|
+
fieldNames: [st],
|
|
3071
|
+
relation: ke.value,
|
|
3072
|
+
token: v(Y)
|
|
3073
3073
|
};
|
|
3074
3074
|
} else {
|
|
3075
3075
|
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", Y));
|
|
3076
|
-
const
|
|
3077
|
-
|
|
3076
|
+
const ce = ee.pop(), Le = ee.pop();
|
|
3077
|
+
pe = {
|
|
3078
3078
|
schemaName: ee.join("."),
|
|
3079
3079
|
tableName: Le,
|
|
3080
|
-
fieldNames: [
|
|
3081
|
-
relation:
|
|
3082
|
-
token:
|
|
3080
|
+
fieldNames: [ce],
|
|
3081
|
+
relation: ke.value,
|
|
3082
|
+
token: v(Y)
|
|
3083
3083
|
};
|
|
3084
3084
|
}
|
|
3085
|
-
const
|
|
3086
|
-
return n.push(...
|
|
3085
|
+
const nt = this.registerInlineRefToEnv(e, tt, pe, Y);
|
|
3086
|
+
return n.push(...nt), nt.length === 0 ? pe : [];
|
|
3087
3087
|
});
|
|
3088
3088
|
}
|
|
3089
3089
|
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;
|
|
@@ -3092,15 +3092,15 @@ class Pt {
|
|
|
3092
3092
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3093
3093
|
var a, c, p, h, T, f, N;
|
|
3094
3094
|
const s = { columns: [] }, i = n;
|
|
3095
|
-
s.token =
|
|
3095
|
+
s.token = v(e);
|
|
3096
3096
|
const r = [i.callee, ...i.args];
|
|
3097
3097
|
if (I.last(r) instanceof D) {
|
|
3098
|
-
const g =
|
|
3098
|
+
const g = W(r.pop()).getValue();
|
|
3099
3099
|
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3100
3100
|
const _ = (T = g.note) == null ? void 0 : T.at(0);
|
|
3101
3101
|
s.note = _ && {
|
|
3102
3102
|
value: z(_.value).unwrap(),
|
|
3103
|
-
token:
|
|
3103
|
+
token: v(_)
|
|
3104
3104
|
}, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3105
3105
|
}
|
|
3106
3106
|
return r.flatMap((g) => {
|
|
@@ -3113,13 +3113,15 @@ class Pt {
|
|
|
3113
3113
|
}).forEach((g) => {
|
|
3114
3114
|
const { functional: _, nonFunctional: K } = Xe(g).unwrap();
|
|
3115
3115
|
s.columns.push(
|
|
3116
|
-
..._.map((
|
|
3117
|
-
value:
|
|
3118
|
-
type: "expression"
|
|
3116
|
+
..._.map((oe) => ({
|
|
3117
|
+
value: oe.value.value,
|
|
3118
|
+
type: "expression",
|
|
3119
|
+
token: v(oe)
|
|
3119
3120
|
})),
|
|
3120
|
-
...K.map((
|
|
3121
|
-
value: V(
|
|
3122
|
-
type: "column"
|
|
3121
|
+
...K.map((oe) => ({
|
|
3122
|
+
value: V(oe).unwrap(),
|
|
3123
|
+
type: "column",
|
|
3124
|
+
token: v(oe)
|
|
3123
3125
|
}))
|
|
3124
3126
|
);
|
|
3125
3127
|
}), s;
|
|
@@ -3146,7 +3148,7 @@ class Pt {
|
|
|
3146
3148
|
schemaName: this.table.schemaName,
|
|
3147
3149
|
tableName: this.table.name,
|
|
3148
3150
|
fieldNames: [X(e.callee).unwrap()],
|
|
3149
|
-
token:
|
|
3151
|
+
token: v(e),
|
|
3150
3152
|
relation: a[0]
|
|
3151
3153
|
}
|
|
3152
3154
|
]
|
|
@@ -3155,11 +3157,11 @@ class Pt {
|
|
|
3155
3157
|
}
|
|
3156
3158
|
function Yn(t) {
|
|
3157
3159
|
let e = null;
|
|
3158
|
-
t instanceof H && (e = t.argumentList.elementList.map((r) =>
|
|
3160
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => he(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3159
3161
|
let n = "";
|
|
3160
|
-
for (; t instanceof
|
|
3162
|
+
for (; t instanceof ue; )
|
|
3161
3163
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3162
|
-
const { name: s, schemaName: i } =
|
|
3164
|
+
const { name: s, schemaName: i } = Ie(t);
|
|
3163
3165
|
return i.length > 1 ? new B(
|
|
3164
3166
|
{
|
|
3165
3167
|
schemaName: i.length === 0 ? null : i[0],
|
|
@@ -3176,22 +3178,22 @@ function Yn(t) {
|
|
|
3176
3178
|
function zn(t) {
|
|
3177
3179
|
var e, n, s;
|
|
3178
3180
|
if (t) {
|
|
3179
|
-
if (
|
|
3181
|
+
if (j(t))
|
|
3180
3182
|
return {
|
|
3181
3183
|
value: z(t).unwrap(),
|
|
3182
3184
|
type: "string"
|
|
3183
3185
|
};
|
|
3184
|
-
if (
|
|
3186
|
+
if (he(t))
|
|
3185
3187
|
return {
|
|
3186
3188
|
type: "number",
|
|
3187
3189
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3188
3190
|
};
|
|
3189
|
-
if (
|
|
3191
|
+
if (me(t))
|
|
3190
3192
|
return {
|
|
3191
3193
|
value: t.expression.variable.value.toLowerCase(),
|
|
3192
3194
|
type: "boolean"
|
|
3193
3195
|
};
|
|
3194
|
-
if (t instanceof Q &&
|
|
3196
|
+
if (t instanceof Q && vt.includes((e = t.op) == null ? void 0 : e.value) && he(t.expression)) {
|
|
3195
3197
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3196
3198
|
return {
|
|
3197
3199
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
@@ -3211,30 +3213,30 @@ class Qn {
|
|
|
3211
3213
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3212
3214
|
}
|
|
3213
3215
|
interpret() {
|
|
3214
|
-
return this.note.token =
|
|
3216
|
+
return this.note.token = v(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
|
|
3215
3217
|
...this.interpretName(this.declarationNode.name),
|
|
3216
3218
|
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3217
3219
|
...this.interpretBody(this.declarationNode.body)
|
|
3218
3220
|
];
|
|
3219
3221
|
}
|
|
3220
3222
|
interpretName(e) {
|
|
3221
|
-
const { name: n } =
|
|
3223
|
+
const { name: n } = Ie(e);
|
|
3222
3224
|
return this.note.name = n, [];
|
|
3223
3225
|
}
|
|
3224
3226
|
interpretSettingList(e) {
|
|
3225
3227
|
var s, i, r;
|
|
3226
|
-
const n =
|
|
3228
|
+
const n = W(e).getValue();
|
|
3227
3229
|
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, [];
|
|
3228
3230
|
}
|
|
3229
3231
|
interpretBody(e) {
|
|
3230
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
3232
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
3231
3233
|
return n.length !== 1 || s.length > 0 ? [
|
|
3232
3234
|
new l(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3233
3235
|
] : [...this.interpretNote(n[0])];
|
|
3234
3236
|
}
|
|
3235
3237
|
interpretNote(e) {
|
|
3236
3238
|
const n = I.get(e, "callee.expression.literal.value", "");
|
|
3237
|
-
return this.note.content =
|
|
3239
|
+
return this.note.content = Ne(n), [];
|
|
3238
3240
|
}
|
|
3239
3241
|
}
|
|
3240
3242
|
class Ut {
|
|
@@ -3242,14 +3244,14 @@ class Ut {
|
|
|
3242
3244
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3243
3245
|
}
|
|
3244
3246
|
interpret() {
|
|
3245
|
-
return this.ref.token =
|
|
3247
|
+
return this.ref.token = v(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3246
3248
|
}
|
|
3247
3249
|
interpretName(e) {
|
|
3248
3250
|
const n = [], s = C(this.declarationNode.name).unwrap_or([]);
|
|
3249
3251
|
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3250
3252
|
}
|
|
3251
3253
|
interpretBody(e) {
|
|
3252
|
-
return e instanceof
|
|
3254
|
+
return e instanceof y ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3253
3255
|
}
|
|
3254
3256
|
interpretField(e) {
|
|
3255
3257
|
var h, T, f, N;
|
|
@@ -3263,22 +3265,22 @@ class Ut {
|
|
|
3263
3265
|
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
|
|
3264
3266
|
];
|
|
3265
3267
|
if (e.args[0]) {
|
|
3266
|
-
const g =
|
|
3267
|
-
this.ref.onDelete = _ instanceof $ ?
|
|
3268
|
+
const g = W(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
|
|
3269
|
+
this.ref.onDelete = _ instanceof $ ? Te(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
|
|
3268
3270
|
const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
|
|
3269
|
-
this.ref.onUpdate = K instanceof $ ?
|
|
3271
|
+
this.ref.onUpdate = K instanceof $ ? Te(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
|
|
3270
3272
|
}
|
|
3271
3273
|
const p = St(n);
|
|
3272
3274
|
return this.ref.endpoints = [
|
|
3273
3275
|
{
|
|
3274
|
-
...
|
|
3276
|
+
...ft(s, this.container),
|
|
3275
3277
|
relation: p[0],
|
|
3276
|
-
token:
|
|
3278
|
+
token: v(s)
|
|
3277
3279
|
},
|
|
3278
3280
|
{
|
|
3279
|
-
...
|
|
3281
|
+
...ft(i, this.container),
|
|
3280
3282
|
relation: p[1],
|
|
3281
|
-
token:
|
|
3283
|
+
token: v(i)
|
|
3282
3284
|
}
|
|
3283
3285
|
], this.env.refIds[c] = this.declarationNode, [];
|
|
3284
3286
|
}
|
|
@@ -3289,13 +3291,13 @@ class Mt {
|
|
|
3289
3291
|
}
|
|
3290
3292
|
interpret() {
|
|
3291
3293
|
const e = [];
|
|
3292
|
-
return this.tableGroup.token =
|
|
3294
|
+
return this.tableGroup.token = v(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
|
|
3293
3295
|
...this.interpretName(this.declarationNode.name),
|
|
3294
3296
|
...this.interpretBody(this.declarationNode.body)
|
|
3295
3297
|
), e;
|
|
3296
3298
|
}
|
|
3297
3299
|
interpretName(e) {
|
|
3298
|
-
const n = [], { name: s, schemaName: i } =
|
|
3300
|
+
const n = [], { name: s, schemaName: i } = Ie(e);
|
|
3299
3301
|
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3300
3302
|
}
|
|
3301
3303
|
interpretBody(e) {
|
|
@@ -3303,7 +3305,7 @@ class Mt {
|
|
|
3303
3305
|
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3304
3306
|
const i = C(s.callee).unwrap();
|
|
3305
3307
|
i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3306
|
-
const r =
|
|
3308
|
+
const r = fe(s.callee).unwrap().pop().referee.id;
|
|
3307
3309
|
if (this.env.groupOfTable[r]) {
|
|
3308
3310
|
const a = this.env.groupOfTable[r], { schemaName: c, name: p } = this.env.tableGroups.get(a), h = c ? `${c}.${p}` : p;
|
|
3309
3311
|
n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
|
|
@@ -3321,21 +3323,21 @@ class Ft {
|
|
|
3321
3323
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3322
3324
|
}
|
|
3323
3325
|
interpret() {
|
|
3324
|
-
return this.enum.token =
|
|
3326
|
+
return this.enum.token = v(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3325
3327
|
}
|
|
3326
3328
|
interpretName(e) {
|
|
3327
|
-
const { name: n, schemaName: s } =
|
|
3329
|
+
const { name: n, schemaName: s } = Ie(e);
|
|
3328
3330
|
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3329
3331
|
}
|
|
3330
3332
|
interpretBody(e) {
|
|
3331
3333
|
return e.body.flatMap((n) => {
|
|
3332
3334
|
var c;
|
|
3333
3335
|
const s = n, i = {};
|
|
3334
|
-
i.token =
|
|
3335
|
-
const a = (c =
|
|
3336
|
+
i.token = v(s), i.name = X(s.callee).unwrap();
|
|
3337
|
+
const a = (c = W(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3336
3338
|
return i.note = a && {
|
|
3337
|
-
value: z(a.value).map(
|
|
3338
|
-
token:
|
|
3339
|
+
value: z(a.value).map(Ne).unwrap(),
|
|
3340
|
+
token: v(a)
|
|
3339
3341
|
}, this.enum.values.push(i), [];
|
|
3340
3342
|
});
|
|
3341
3343
|
}
|
|
@@ -3345,12 +3347,12 @@ class qn {
|
|
|
3345
3347
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3346
3348
|
}
|
|
3347
3349
|
interpret() {
|
|
3348
|
-
return this.env.project.set(this.declarationNode, this.project), this.project.token =
|
|
3350
|
+
return this.env.project.set(this.declarationNode, this.project), this.project.token = v(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3349
3351
|
}
|
|
3350
3352
|
interpretName(e) {
|
|
3351
3353
|
if (!e)
|
|
3352
3354
|
return this.project.name = null, [];
|
|
3353
|
-
const { name: n } =
|
|
3355
|
+
const { name: n } = Ie(e);
|
|
3354
3356
|
return this.project.name = n, [];
|
|
3355
3357
|
}
|
|
3356
3358
|
interpretBody(e) {
|
|
@@ -3376,8 +3378,8 @@ class qn {
|
|
|
3376
3378
|
}
|
|
3377
3379
|
case "note":
|
|
3378
3380
|
return this.project.note = {
|
|
3379
|
-
value: z(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(
|
|
3380
|
-
token:
|
|
3381
|
+
value: z(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(Ne).unwrap(),
|
|
3382
|
+
token: v(s)
|
|
3381
3383
|
}, [];
|
|
3382
3384
|
default:
|
|
3383
3385
|
return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
|
|
@@ -3455,7 +3457,7 @@ function Ae(t) {
|
|
|
3455
3457
|
return L.Text;
|
|
3456
3458
|
}
|
|
3457
3459
|
}
|
|
3458
|
-
function
|
|
3460
|
+
function De(t, e) {
|
|
3459
3461
|
if (!t || Ce(t))
|
|
3460
3462
|
return !1;
|
|
3461
3463
|
for (const n of t.trailingTrivia) {
|
|
@@ -3471,7 +3473,7 @@ function O() {
|
|
|
3471
3473
|
suggestions: []
|
|
3472
3474
|
};
|
|
3473
3475
|
}
|
|
3474
|
-
function
|
|
3476
|
+
function Pe(t) {
|
|
3475
3477
|
return {
|
|
3476
3478
|
...t,
|
|
3477
3479
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3485,11 +3487,11 @@ function Fe(t) {
|
|
|
3485
3487
|
...t,
|
|
3486
3488
|
suggestions: t.suggestions.map((e) => ({
|
|
3487
3489
|
...e,
|
|
3488
|
-
insertText: e.insertText.split("").every(
|
|
3490
|
+
insertText: e.insertText.split("").every(Me) ? e.insertText : `"${e.insertText}"`
|
|
3489
3491
|
}))
|
|
3490
3492
|
};
|
|
3491
3493
|
}
|
|
3492
|
-
function
|
|
3494
|
+
function Ke(t, e) {
|
|
3493
3495
|
return t.getOffsetAt(e);
|
|
3494
3496
|
}
|
|
3495
3497
|
class Bt {
|
|
@@ -3498,20 +3500,20 @@ class Bt {
|
|
|
3498
3500
|
}
|
|
3499
3501
|
provideCompletionItems(e, n) {
|
|
3500
3502
|
var T, f;
|
|
3501
|
-
const s =
|
|
3503
|
+
const s = Ke(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), c = a === void 0 ? i[0] : i[a + 1];
|
|
3502
3504
|
if ([
|
|
3503
3505
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3504
3506
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3505
3507
|
...(c == null ? void 0 : c.leadingTrivia) || []
|
|
3506
|
-
].find((N) =>
|
|
3508
|
+
].find((N) => jt(N) && ge(s, N)))
|
|
3507
3509
|
return O();
|
|
3508
3510
|
if (a === void 0)
|
|
3509
|
-
return
|
|
3511
|
+
return mt();
|
|
3510
3512
|
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
|
|
3511
3513
|
return O();
|
|
3512
3514
|
const p = this.compiler.container.element(s);
|
|
3513
3515
|
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
|
|
3514
|
-
return
|
|
3516
|
+
return mt();
|
|
3515
3517
|
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3516
3518
|
for (const N of h)
|
|
3517
3519
|
if (N instanceof Q)
|
|
@@ -3520,7 +3522,7 @@ class Bt {
|
|
|
3520
3522
|
case "<":
|
|
3521
3523
|
case "<>":
|
|
3522
3524
|
case "-":
|
|
3523
|
-
return
|
|
3525
|
+
return pt(
|
|
3524
3526
|
this.compiler,
|
|
3525
3527
|
s,
|
|
3526
3528
|
N
|
|
@@ -3532,7 +3534,7 @@ class Bt {
|
|
|
3532
3534
|
case "<":
|
|
3533
3535
|
case "<>":
|
|
3534
3536
|
case "-":
|
|
3535
|
-
return
|
|
3537
|
+
return pt(
|
|
3536
3538
|
this.compiler,
|
|
3537
3539
|
s,
|
|
3538
3540
|
N
|
|
@@ -3546,20 +3548,20 @@ class Bt {
|
|
|
3546
3548
|
}
|
|
3547
3549
|
else {
|
|
3548
3550
|
if (N instanceof se)
|
|
3549
|
-
return
|
|
3551
|
+
return dt(this.compiler, s, N);
|
|
3550
3552
|
if (N instanceof D)
|
|
3551
|
-
return
|
|
3553
|
+
return dt(this.compiler, s, N);
|
|
3552
3554
|
if (N instanceof J)
|
|
3553
3555
|
return Zn(this.compiler, s);
|
|
3554
|
-
if (N instanceof
|
|
3555
|
-
return
|
|
3556
|
+
if (N instanceof y)
|
|
3557
|
+
return Nt(this.compiler, s, N);
|
|
3556
3558
|
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && ge(s, N.body)))
|
|
3557
|
-
return
|
|
3559
|
+
return Nt(this.compiler, s, void 0);
|
|
3558
3560
|
}
|
|
3559
3561
|
return O();
|
|
3560
3562
|
}
|
|
3561
3563
|
}
|
|
3562
|
-
function
|
|
3564
|
+
function pt(t, e, n) {
|
|
3563
3565
|
const s = t.container.scopeKind(e);
|
|
3564
3566
|
if ([R.REF, R.TABLE].includes(s)) {
|
|
3565
3567
|
const i = Be(t, e, t.container.element(e), [
|
|
@@ -3567,7 +3569,7 @@ function dt(t, e, n) {
|
|
|
3567
3569
|
m.Schema,
|
|
3568
3570
|
m.Column
|
|
3569
3571
|
]);
|
|
3570
|
-
return
|
|
3572
|
+
return De(n.op, e) ? Pe(i) : i;
|
|
3571
3573
|
}
|
|
3572
3574
|
return O();
|
|
3573
3575
|
}
|
|
@@ -3617,25 +3619,25 @@ function Zn(t, e) {
|
|
|
3617
3619
|
}
|
|
3618
3620
|
return O();
|
|
3619
3621
|
}
|
|
3620
|
-
function
|
|
3622
|
+
function dt(t, e, n) {
|
|
3621
3623
|
const { token: s } = t.container.token(e);
|
|
3622
3624
|
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3623
|
-
const i =
|
|
3624
|
-
return (s == null ? void 0 : s.kind) === u.COMMA &&
|
|
3625
|
+
const i = Et(t, e);
|
|
3626
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && De(s, e) ? Pe(i) : i;
|
|
3625
3627
|
}
|
|
3626
3628
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3627
|
-
return
|
|
3629
|
+
return Et(t, e);
|
|
3628
3630
|
if (n.name instanceof $) {
|
|
3629
3631
|
const i = Kn(
|
|
3630
3632
|
t,
|
|
3631
3633
|
e,
|
|
3632
|
-
|
|
3634
|
+
Te(n.name).unwrap()
|
|
3633
3635
|
);
|
|
3634
|
-
return (s == null ? void 0 : s.kind) === u.COLON &&
|
|
3636
|
+
return (s == null ? void 0 : s.kind) === u.COLON && De(s, e) ? Pe(i) : i;
|
|
3635
3637
|
}
|
|
3636
3638
|
return O();
|
|
3637
3639
|
}
|
|
3638
|
-
function
|
|
3640
|
+
function Et(t, e) {
|
|
3639
3641
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3640
3642
|
if (n instanceof G)
|
|
3641
3643
|
return O();
|
|
@@ -3761,7 +3763,7 @@ function Kn(t, e, n) {
|
|
|
3761
3763
|
return O();
|
|
3762
3764
|
}
|
|
3763
3765
|
function Vt(t, e, n) {
|
|
3764
|
-
const s =
|
|
3766
|
+
const s = fe(n).unwrap_or([]);
|
|
3765
3767
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3766
3768
|
return O();
|
|
3767
3769
|
const i = s.map((r) => X(r).unwrap());
|
|
@@ -3774,7 +3776,7 @@ function Vt(t, e, n) {
|
|
|
3774
3776
|
}))
|
|
3775
3777
|
});
|
|
3776
3778
|
}
|
|
3777
|
-
function
|
|
3779
|
+
function Nt(t, e, n) {
|
|
3778
3780
|
var i;
|
|
3779
3781
|
switch (t.container.scopeKind(e)) {
|
|
3780
3782
|
case R.TABLE:
|
|
@@ -3787,7 +3789,7 @@ function mt(t, e, n) {
|
|
|
3787
3789
|
return es(t, e, n);
|
|
3788
3790
|
case R.REF: {
|
|
3789
3791
|
const r = Gt(t, e);
|
|
3790
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON &&
|
|
3792
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && De(t.container.token(e).token, e) ? Pe(r) : r;
|
|
3791
3793
|
}
|
|
3792
3794
|
case R.TABLEGROUP:
|
|
3793
3795
|
return ss(t);
|
|
@@ -3795,7 +3797,7 @@ function mt(t, e, n) {
|
|
|
3795
3797
|
return O();
|
|
3796
3798
|
}
|
|
3797
3799
|
}
|
|
3798
|
-
function
|
|
3800
|
+
function mt() {
|
|
3799
3801
|
return {
|
|
3800
3802
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3801
3803
|
label: t,
|
|
@@ -3807,7 +3809,7 @@ function Tt() {
|
|
|
3807
3809
|
};
|
|
3808
3810
|
}
|
|
3809
3811
|
function es(t, e, n) {
|
|
3810
|
-
return n != null && n.callee &&
|
|
3812
|
+
return n != null && n.callee && et(e, n) === 1 ? Be(t, e, t.container.element(e), [
|
|
3811
3813
|
m.Schema,
|
|
3812
3814
|
m.Table,
|
|
3813
3815
|
m.Column
|
|
@@ -3824,7 +3826,7 @@ function ts(t, e, n) {
|
|
|
3824
3826
|
range: void 0
|
|
3825
3827
|
}))
|
|
3826
3828
|
};
|
|
3827
|
-
const s =
|
|
3829
|
+
const s = et(e, n);
|
|
3828
3830
|
return s === 0 ? {
|
|
3829
3831
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3830
3832
|
label: i,
|
|
@@ -3836,7 +3838,7 @@ function ts(t, e, n) {
|
|
|
3836
3838
|
} : s === 1 ? rs(t, e) : O();
|
|
3837
3839
|
}
|
|
3838
3840
|
function ns(t, e, n) {
|
|
3839
|
-
return n != null && n.callee ?
|
|
3841
|
+
return n != null && n.callee ? et(e, n) === 0 ? {
|
|
3840
3842
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3841
3843
|
label: i,
|
|
3842
3844
|
insertText: i,
|
|
@@ -3958,7 +3960,7 @@ function rs(t, e) {
|
|
|
3958
3960
|
}
|
|
3959
3961
|
function Ct(t, e) {
|
|
3960
3962
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
3961
|
-
if (!((s == null ? void 0 : s.symbol) instanceof
|
|
3963
|
+
if (!((s == null ? void 0 : s.symbol) instanceof _t))
|
|
3962
3964
|
return O();
|
|
3963
3965
|
const { symbolTable: i } = s.symbol;
|
|
3964
3966
|
return Fe({
|
|
@@ -3977,7 +3979,7 @@ function Ct(t, e) {
|
|
|
3977
3979
|
})
|
|
3978
3980
|
});
|
|
3979
3981
|
}
|
|
3980
|
-
function
|
|
3982
|
+
function et(t, e) {
|
|
3981
3983
|
if (!e.callee)
|
|
3982
3984
|
return -1;
|
|
3983
3985
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
@@ -3989,10 +3991,10 @@ class Xt {
|
|
|
3989
3991
|
}
|
|
3990
3992
|
provideDefinition(e, n) {
|
|
3991
3993
|
var a;
|
|
3992
|
-
const { uri: s } = e, i =
|
|
3994
|
+
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
3993
3995
|
for (; r.length !== 0; ) {
|
|
3994
3996
|
const c = r.pop();
|
|
3995
|
-
if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [
|
|
3997
|
+
if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [Ee.PRIMARY_EXPRESSION, Ee.VARIABLE].includes(c == null ? void 0 : c.kind)) {
|
|
3996
3998
|
const { startPos: p, endPos: h } = c.referee.declaration;
|
|
3997
3999
|
return [
|
|
3998
4000
|
{
|
|
@@ -4015,13 +4017,13 @@ class $t {
|
|
|
4015
4017
|
this.compiler = e;
|
|
4016
4018
|
}
|
|
4017
4019
|
provideReferences(e, n) {
|
|
4018
|
-
const { uri: s } = e, i =
|
|
4020
|
+
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
4019
4021
|
for (; r.length !== 0; ) {
|
|
4020
4022
|
const a = r.pop();
|
|
4021
4023
|
if (a && [
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4024
|
+
Ee.ELEMENT_DECLARATION,
|
|
4025
|
+
Ee.FUNCTION_APPLICATION,
|
|
4026
|
+
Ee.PRIMARY_EXPRESSION
|
|
4025
4027
|
].includes(a == null ? void 0 : a.kind)) {
|
|
4026
4028
|
const { symbol: c } = a;
|
|
4027
4029
|
if (c != null && c.references.length)
|
|
@@ -4056,7 +4058,7 @@ class ls {
|
|
|
4056
4058
|
).fill(null), this.nodeIdGenerator = new Yt(), this.symbolIdGenerator = new Jt(), this.token = {
|
|
4057
4059
|
invalidStream: this.createQuery(
|
|
4058
4060
|
6,
|
|
4059
|
-
() => this.parse.tokens().filter(
|
|
4061
|
+
() => this.parse.tokens().filter(At)
|
|
4060
4062
|
),
|
|
4061
4063
|
// Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
|
|
4062
4064
|
flatStream: this.createQuery(
|
|
@@ -4068,7 +4070,7 @@ class ls {
|
|
|
4068
4070
|
_: this.createQuery(
|
|
4069
4071
|
0,
|
|
4070
4072
|
() => {
|
|
4071
|
-
const e = new cn(this.source).lex().chain((n) => new hn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new
|
|
4073
|
+
const e = new cn(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 })));
|
|
4072
4074
|
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Hn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4073
4075
|
}
|
|
4074
4076
|
),
|
|
@@ -4116,7 +4118,7 @@ class ls {
|
|
|
4116
4118
|
for (; c.length > 0; ) {
|
|
4117
4119
|
let p = !1;
|
|
4118
4120
|
const h = I.last(c);
|
|
4119
|
-
if (h instanceof
|
|
4121
|
+
if (h instanceof y) {
|
|
4120
4122
|
const T = this.parse.source();
|
|
4121
4123
|
for (let f = h.end; f < e; f += 1)
|
|
4122
4124
|
T[f] === `
|