@dbml/parse 3.4.1 → 3.4.3
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 +268 -268
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -94,7 +94,7 @@ class x {
|
|
|
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
|
}
|
|
@@ -137,12 +137,12 @@ class se extends x {
|
|
|
137
137
|
super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class
|
|
140
|
+
class Q extends x {
|
|
141
141
|
constructor({ op: e, expression: n }, s) {
|
|
142
142
|
super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class
|
|
145
|
+
class q extends x {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -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
|
}
|
|
@@ -175,7 +175,7 @@ class ne extends x {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class
|
|
178
|
+
class D extends x {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: n = [],
|
|
@@ -189,7 +189,7 @@ class P extends x {
|
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class
|
|
192
|
+
class J extends x {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -203,7 +203,7 @@ class Z extends x {
|
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class je extends
|
|
206
|
+
class je extends J {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -220,7 +220,7 @@ class je extends Z {
|
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class
|
|
223
|
+
class H extends x {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: n
|
|
@@ -228,17 +228,17 @@ class J 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
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class Z extends x {
|
|
237
237
|
constructor({ variable: e }, n) {
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class
|
|
241
|
+
class U extends x {
|
|
242
242
|
constructor({ expression: e }, n) {
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
@@ -249,7 +249,7 @@ class ke extends x {
|
|
|
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
|
}
|
|
@@ -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() {
|
|
@@ -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);
|
|
@@ -415,7 +415,7 @@ function Ht(t) {
|
|
|
415
415
|
const [e] = t;
|
|
416
416
|
return Oe(e) || Ue(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function de(t) {
|
|
419
419
|
return Ue(t) || Oe(t);
|
|
420
420
|
}
|
|
421
421
|
function ct(t, e) {
|
|
@@ -498,12 +498,12 @@ 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
|
|
506
|
-
const a = I.last(s) instanceof
|
|
505
|
+
return new w();
|
|
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, {
|
|
509
509
|
type: i,
|
|
@@ -526,7 +526,7 @@ function sn(t, e, n) {
|
|
|
526
526
|
attributeList: a,
|
|
527
527
|
body: r
|
|
528
528
|
})
|
|
529
|
-
) : new
|
|
529
|
+
) : new w();
|
|
530
530
|
}
|
|
531
531
|
function lt(t) {
|
|
532
532
|
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
@@ -544,29 +544,29 @@ function an(t) {
|
|
|
544
544
|
t.identifiers.forEach(E);
|
|
545
545
|
else if (t instanceof se)
|
|
546
546
|
E(t.name), E(t.colon), E(t.value);
|
|
547
|
-
else if (t instanceof
|
|
547
|
+
else if (t instanceof Q)
|
|
548
548
|
E(t.op), E(t.expression);
|
|
549
|
-
else if (t instanceof
|
|
549
|
+
else if (t instanceof q)
|
|
550
550
|
E(t.leftExpression), E(t.op), E(t.rightExpression);
|
|
551
551
|
else if (t instanceof Pe)
|
|
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);
|
|
555
|
-
else if (t instanceof
|
|
555
|
+
else if (t instanceof D)
|
|
556
556
|
E(t.listOpenBracket), t.commaList.forEach(E), t.elementList.forEach(E), E(t.listCloseBracket);
|
|
557
|
-
else if (t instanceof Z)
|
|
558
|
-
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
559
557
|
else if (t instanceof J)
|
|
558
|
+
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
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
|
-
else if (t instanceof
|
|
563
|
+
else if (t instanceof U)
|
|
564
564
|
E(t.expression);
|
|
565
565
|
else if (t instanceof te)
|
|
566
566
|
E(t.value);
|
|
567
|
-
else if (t instanceof
|
|
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
572
|
throw t instanceof je ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
@@ -574,14 +574,14 @@ function an(t) {
|
|
|
574
574
|
function vt(t) {
|
|
575
575
|
return !!(t != null && t.isInvalid);
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function P(...t) {
|
|
578
578
|
return t.filter((e) => e !== void 0);
|
|
579
579
|
}
|
|
580
580
|
function on(t) {
|
|
581
581
|
if (t instanceof G)
|
|
582
|
-
return
|
|
582
|
+
return P(...t.body, t.eof);
|
|
583
583
|
if (t instanceof A)
|
|
584
|
-
return
|
|
584
|
+
return P(
|
|
585
585
|
t.type,
|
|
586
586
|
t.name,
|
|
587
587
|
t.as,
|
|
@@ -591,71 +591,71 @@ function on(t) {
|
|
|
591
591
|
t.body
|
|
592
592
|
);
|
|
593
593
|
if (t instanceof se)
|
|
594
|
-
return
|
|
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
|
-
if (t instanceof
|
|
600
|
-
return
|
|
599
|
+
if (t instanceof Z)
|
|
600
|
+
return P(t.variable);
|
|
601
|
+
if (t instanceof Q)
|
|
602
|
+
return P(t.op, t.expression);
|
|
601
603
|
if (t instanceof q)
|
|
602
|
-
return
|
|
603
|
-
if (t instanceof H)
|
|
604
|
-
return U(t.leftExpression, t.op, t.rightExpression);
|
|
604
|
+
return P(t.leftExpression, t.op, t.rightExpression);
|
|
605
605
|
if (t instanceof Pe)
|
|
606
|
-
return
|
|
606
|
+
return P(t.expression, t.op);
|
|
607
607
|
if (t instanceof te)
|
|
608
|
-
return
|
|
609
|
-
if (t instanceof
|
|
610
|
-
return
|
|
608
|
+
return P(t.value);
|
|
609
|
+
if (t instanceof y)
|
|
610
|
+
return P(t.callee, ...t.args);
|
|
611
611
|
if (t instanceof ne)
|
|
612
|
-
return
|
|
613
|
-
if (t instanceof
|
|
614
|
-
return
|
|
612
|
+
return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
613
|
+
if (t instanceof D)
|
|
614
|
+
return P(
|
|
615
615
|
t.listOpenBracket,
|
|
616
616
|
...ct(t.elementList, t.commaList),
|
|
617
617
|
t.listCloseBracket
|
|
618
618
|
);
|
|
619
|
-
if (t instanceof
|
|
620
|
-
return
|
|
619
|
+
if (t instanceof J)
|
|
620
|
+
return P(
|
|
621
621
|
t.tupleOpenParen,
|
|
622
622
|
...ct(t.elementList, t.commaList),
|
|
623
623
|
t.tupleCloseParen
|
|
624
624
|
);
|
|
625
|
-
if (t instanceof
|
|
626
|
-
return
|
|
627
|
-
if (t instanceof
|
|
628
|
-
return
|
|
629
|
-
if (t instanceof
|
|
630
|
-
return
|
|
625
|
+
if (t instanceof H)
|
|
626
|
+
return P(t.callee, t.argumentList);
|
|
627
|
+
if (t instanceof U)
|
|
628
|
+
return P(t.expression);
|
|
629
|
+
if (t instanceof ue)
|
|
630
|
+
return P(
|
|
631
631
|
t.array,
|
|
632
632
|
t.indexer
|
|
633
633
|
);
|
|
634
634
|
throw t instanceof je ? 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 W(t) {
|
|
640
640
|
var e;
|
|
641
|
-
return t 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
|
-
return t instanceof
|
|
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
|
-
return t instanceof
|
|
648
|
+
return t instanceof U && t.expression instanceof Z && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
649
649
|
}
|
|
650
650
|
function Je(t) {
|
|
651
651
|
var e;
|
|
652
|
-
return t instanceof
|
|
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
|
|
@@ -890,7 +890,7 @@ 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
|
}
|
|
@@ -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
915
|
if (!n && !Oe(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
|
}
|
|
@@ -1124,7 +1124,7 @@ class hn {
|
|
|
1124
1124
|
groupOpenParen: s.tupleOpenParen,
|
|
1125
1125
|
groupCloseParen: s.tupleCloseParen,
|
|
1126
1126
|
expression: s.elementList[0]
|
|
1127
|
-
}), r = () => this.nodeFactory.create(
|
|
1127
|
+
}), r = () => this.nodeFactory.create(J, s);
|
|
1128
1128
|
try {
|
|
1129
1129
|
this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
|
|
1130
1130
|
} catch (a) {
|
|
@@ -1172,7 +1172,7 @@ class hn {
|
|
|
1172
1172
|
E(s), this.advance();
|
|
1173
1173
|
}
|
|
1174
1174
|
}, this.listExpression = this.contextStack.withContextDo(xe.ListExpression, () => {
|
|
1175
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
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();
|
|
1178
1178
|
} catch (r) {
|
|
@@ -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();
|
|
@@ -1432,12 +1432,12 @@ class hn {
|
|
|
1432
1432
|
ot(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1433
1433
|
break;
|
|
1434
1434
|
try {
|
|
1435
|
-
n = this.nodeFactory.create(
|
|
1435
|
+
n = this.nodeFactory.create(H, {
|
|
1436
1436
|
callee: n,
|
|
1437
1437
|
argumentList: this.tupleExpression()
|
|
1438
1438
|
});
|
|
1439
1439
|
} catch (r) {
|
|
1440
|
-
throw r instanceof d ? (n = this.nodeFactory.create(
|
|
1440
|
+
throw r instanceof d ? (n = this.nodeFactory.create(H, {
|
|
1441
1441
|
callee: n,
|
|
1442
1442
|
argumentList: r.partialNode
|
|
1443
1443
|
}), new d(r.token, n, r.handlerContext)) : r;
|
|
@@ -1446,12 +1446,12 @@ 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;
|
|
@@ -1471,13 +1471,13 @@ class hn {
|
|
|
1471
1471
|
break;
|
|
1472
1472
|
this.advance();
|
|
1473
1473
|
try {
|
|
1474
|
-
n = this.nodeFactory.create(
|
|
1474
|
+
n = this.nodeFactory.create(q, {
|
|
1475
1475
|
leftExpression: n,
|
|
1476
1476
|
op: i,
|
|
1477
1477
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1478
1478
|
});
|
|
1479
1479
|
} catch (c) {
|
|
1480
|
-
throw c instanceof d ? (n = this.nodeFactory.create(
|
|
1480
|
+
throw c instanceof d ? (n = this.nodeFactory.create(q, {
|
|
1481
1481
|
leftExpression: n,
|
|
1482
1482
|
op: i,
|
|
1483
1483
|
rightExpression: c.partialNode
|
|
@@ -1511,11 +1511,11 @@ class hn {
|
|
|
1511
1511
|
} catch (i) {
|
|
1512
1512
|
throw i instanceof d ? (n.expression = i.partialNode, new d(
|
|
1513
1513
|
i.token,
|
|
1514
|
-
this.nodeFactory.create(
|
|
1514
|
+
this.nodeFactory.create(Q, n),
|
|
1515
1515
|
i.handlerContext
|
|
1516
1516
|
)) : i;
|
|
1517
1517
|
}
|
|
1518
|
-
e = this.nodeFactory.create(
|
|
1518
|
+
e = this.nodeFactory.create(Q, n);
|
|
1519
1519
|
} else if (e = this.extractOperand(), e instanceof ke)
|
|
1520
1520
|
throw new d(
|
|
1521
1521
|
this.peek(),
|
|
@@ -1569,18 +1569,16 @@ class hn {
|
|
|
1569
1569
|
u.STRING_LITERAL,
|
|
1570
1570
|
u.NUMERIC_LITERAL
|
|
1571
1571
|
))
|
|
1572
|
-
return this.nodeFactory.create(
|
|
1573
|
-
expression: this.nodeFactory.create(
|
|
1572
|
+
return this.nodeFactory.create(U, {
|
|
1573
|
+
expression: this.nodeFactory.create(be, { literal: this.previous() })
|
|
1574
1574
|
});
|
|
1575
1575
|
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1576
|
-
return this.nodeFactory.create(
|
|
1577
|
-
expression: this.nodeFactory.create(
|
|
1576
|
+
return this.nodeFactory.create(U, {
|
|
1577
|
+
expression: this.nodeFactory.create(Z, { variable: this.previous() })
|
|
1578
1578
|
});
|
|
1579
1579
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1580
1580
|
this.peek(),
|
|
1581
|
-
|
|
1582
|
-
expression: this.nodeFactory.create(W, {})
|
|
1583
|
-
}),
|
|
1581
|
+
void 0,
|
|
1584
1582
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1585
1583
|
);
|
|
1586
1584
|
}
|
|
@@ -1690,36 +1688,36 @@ function ve(t) {
|
|
|
1690
1688
|
case b.TableGroup:
|
|
1691
1689
|
return new S(e);
|
|
1692
1690
|
default:
|
|
1693
|
-
return new
|
|
1691
|
+
return new w();
|
|
1694
1692
|
}
|
|
1695
1693
|
}
|
|
1696
|
-
function
|
|
1694
|
+
function fe(t) {
|
|
1697
1695
|
if (!Je(t))
|
|
1698
1696
|
return new S([t]);
|
|
1699
|
-
const e =
|
|
1700
|
-
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();
|
|
1701
1699
|
}
|
|
1702
1700
|
function C(t) {
|
|
1703
1701
|
if (t === void 0)
|
|
1704
|
-
return new
|
|
1705
|
-
const e =
|
|
1702
|
+
return new w();
|
|
1703
|
+
const e = fe(t).unwrap_or(void 0);
|
|
1706
1704
|
if (!e)
|
|
1707
|
-
return new
|
|
1705
|
+
return new w();
|
|
1708
1706
|
const n = [];
|
|
1709
1707
|
for (const s of e) {
|
|
1710
1708
|
const i = X(s).unwrap_or(void 0);
|
|
1711
1709
|
if (!i)
|
|
1712
|
-
return new
|
|
1710
|
+
return new w();
|
|
1713
1711
|
n.push(i);
|
|
1714
1712
|
}
|
|
1715
1713
|
return new S(n);
|
|
1716
1714
|
}
|
|
1717
1715
|
function _e(t) {
|
|
1718
1716
|
if (t === void 0)
|
|
1719
|
-
return new
|
|
1720
|
-
const e =
|
|
1717
|
+
return new w();
|
|
1718
|
+
const e = fe(t).unwrap_or(void 0);
|
|
1721
1719
|
if (!e || e.length === 0)
|
|
1722
|
-
return new
|
|
1720
|
+
return new w();
|
|
1723
1721
|
const n = [];
|
|
1724
1722
|
let s;
|
|
1725
1723
|
if (!M(I.last(e))) {
|
|
@@ -1729,12 +1727,12 @@ function _e(t) {
|
|
|
1729
1727
|
(r) => V(r).unwrap()
|
|
1730
1728
|
);
|
|
1731
1729
|
else
|
|
1732
|
-
return new
|
|
1730
|
+
return new w();
|
|
1733
1731
|
}
|
|
1734
1732
|
for (const i of e) {
|
|
1735
1733
|
const r = X(i).unwrap_or(void 0);
|
|
1736
1734
|
if (!r)
|
|
1737
|
-
return new
|
|
1735
|
+
return new w();
|
|
1738
1736
|
n.push(r);
|
|
1739
1737
|
}
|
|
1740
1738
|
return new S({
|
|
@@ -1743,30 +1741,30 @@ function _e(t) {
|
|
|
1743
1741
|
});
|
|
1744
1742
|
}
|
|
1745
1743
|
function X(t) {
|
|
1746
|
-
return M(t) ? new S(t.expression.variable.value) : new
|
|
1744
|
+
return M(t) ? new S(t.expression.variable.value) : new w();
|
|
1747
1745
|
}
|
|
1748
1746
|
function Xe(t) {
|
|
1749
1747
|
if (ht(t))
|
|
1750
1748
|
return t instanceof te ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1751
|
-
if (t instanceof
|
|
1749
|
+
if (t instanceof J && t.elementList.every(ht)) {
|
|
1752
1750
|
const e = t.elementList.filter(
|
|
1753
1751
|
(s) => s instanceof te
|
|
1754
1752
|
), n = t.elementList.filter(M);
|
|
1755
1753
|
return new S({ functional: e, nonFunctional: n });
|
|
1756
1754
|
}
|
|
1757
|
-
return new
|
|
1755
|
+
return new w();
|
|
1758
1756
|
}
|
|
1759
1757
|
function V(t) {
|
|
1760
1758
|
var n;
|
|
1761
1759
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1762
|
-
return e === void 0 ? new
|
|
1760
|
+
return e === void 0 ? new w() : new S(e);
|
|
1763
1761
|
}
|
|
1764
|
-
function
|
|
1765
|
-
return
|
|
1762
|
+
function z(t) {
|
|
1763
|
+
return W(t) ? t.expression instanceof Z ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new w();
|
|
1766
1764
|
}
|
|
1767
1765
|
function mn(t) {
|
|
1768
1766
|
var e;
|
|
1769
|
-
return !(t instanceof
|
|
1767
|
+
return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1770
1768
|
}
|
|
1771
1769
|
function Tn(t) {
|
|
1772
1770
|
const e = _e(t.leftExpression), n = _e(t.rightExpression);
|
|
@@ -1776,7 +1774,7 @@ function Tn(t) {
|
|
|
1776
1774
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1777
1775
|
}
|
|
1778
1776
|
function ht(t) {
|
|
1779
|
-
return t instanceof
|
|
1777
|
+
return t instanceof U && t.expression instanceof Z || t instanceof te;
|
|
1780
1778
|
}
|
|
1781
1779
|
function bn(t, e) {
|
|
1782
1780
|
var i, r, a, c;
|
|
@@ -1817,7 +1815,7 @@ class In {
|
|
|
1817
1815
|
if (e instanceof ne)
|
|
1818
1816
|
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1819
1817
|
const n = [];
|
|
1820
|
-
return
|
|
1818
|
+
return W(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;
|
|
1821
1819
|
}
|
|
1822
1820
|
}
|
|
1823
1821
|
class we {
|
|
@@ -1869,9 +1867,9 @@ class Ln {
|
|
|
1869
1867
|
validateBody(e) {
|
|
1870
1868
|
if (!e)
|
|
1871
1869
|
return [];
|
|
1872
|
-
if (e instanceof
|
|
1870
|
+
if (e instanceof y)
|
|
1873
1871
|
return this.validateFields([e]);
|
|
1874
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1872
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
1875
1873
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1876
1874
|
}
|
|
1877
1875
|
validateFields(e) {
|
|
@@ -1879,7 +1877,7 @@ class Ln {
|
|
|
1879
1877
|
const s = [];
|
|
1880
1878
|
n.callee && !M(n.callee) && s.push(new l(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1881
1879
|
const i = [...n.args];
|
|
1882
|
-
return I.last(i) instanceof
|
|
1880
|
+
return I.last(i) instanceof D ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof D && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1883
1881
|
});
|
|
1884
1882
|
}
|
|
1885
1883
|
validateFieldSettings(e) {
|
|
@@ -1889,7 +1887,7 @@ class Ln {
|
|
|
1889
1887
|
switch (r) {
|
|
1890
1888
|
case "note":
|
|
1891
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) => {
|
|
1892
|
-
|
|
1890
|
+
W(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1893
1891
|
});
|
|
1894
1892
|
break;
|
|
1895
1893
|
default:
|
|
@@ -1945,9 +1943,9 @@ class gn {
|
|
|
1945
1943
|
validateBody(e) {
|
|
1946
1944
|
if (!e)
|
|
1947
1945
|
return [];
|
|
1948
|
-
if (e instanceof
|
|
1946
|
+
if (e instanceof y)
|
|
1949
1947
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1950
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1948
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
1951
1949
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1952
1950
|
}
|
|
1953
1951
|
validateFields(e) {
|
|
@@ -1955,8 +1953,8 @@ class gn {
|
|
|
1955
1953
|
if (!n.callee)
|
|
1956
1954
|
return [];
|
|
1957
1955
|
const s = [], i = [n.callee, ...n.args];
|
|
1958
|
-
return I.last(i) instanceof
|
|
1959
|
-
for (; r instanceof
|
|
1956
|
+
return I.last(i) instanceof D && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1957
|
+
for (; r instanceof H; )
|
|
1960
1958
|
r.argumentList && !Xe(r.argumentList).isOk() && s.push(new l(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;
|
|
1961
1959
|
Xe(r).isOk() || s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
1962
1960
|
}), s;
|
|
@@ -1970,13 +1968,13 @@ class gn {
|
|
|
1970
1968
|
case "note":
|
|
1971
1969
|
case "name":
|
|
1972
1970
|
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1973
|
-
|
|
1971
|
+
W(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
|
|
1974
1972
|
});
|
|
1975
1973
|
break;
|
|
1976
1974
|
case "unique":
|
|
1977
1975
|
case "pk":
|
|
1978
1976
|
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1979
|
-
|
|
1977
|
+
le(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
|
|
1980
1978
|
});
|
|
1981
1979
|
break;
|
|
1982
1980
|
case "type":
|
|
@@ -2029,14 +2027,14 @@ class _n {
|
|
|
2029
2027
|
validateBody(e) {
|
|
2030
2028
|
if (!e)
|
|
2031
2029
|
return [];
|
|
2032
|
-
if (e instanceof
|
|
2030
|
+
if (e instanceof y)
|
|
2033
2031
|
return this.validateFields([e]);
|
|
2034
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2032
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2035
2033
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2036
2034
|
}
|
|
2037
2035
|
validateFields(e) {
|
|
2038
2036
|
const n = [];
|
|
2039
|
-
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))), W(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);
|
|
2040
2038
|
}
|
|
2041
2039
|
validateSubElements(e) {
|
|
2042
2040
|
return e.flatMap((n) => {
|
|
@@ -2069,9 +2067,9 @@ class An {
|
|
|
2069
2067
|
validateBody(e) {
|
|
2070
2068
|
if (!e)
|
|
2071
2069
|
return [];
|
|
2072
|
-
if (e instanceof
|
|
2070
|
+
if (e instanceof y)
|
|
2073
2071
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2074
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2072
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2075
2073
|
return [
|
|
2076
2074
|
...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2077
2075
|
...this.validateSubElements(s)
|
|
@@ -2108,9 +2106,9 @@ class vn {
|
|
|
2108
2106
|
validateBody(e) {
|
|
2109
2107
|
if (!e)
|
|
2110
2108
|
return [];
|
|
2111
|
-
if (e instanceof
|
|
2109
|
+
if (e instanceof y)
|
|
2112
2110
|
return this.validateFields([e]);
|
|
2113
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2111
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2114
2112
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2115
2113
|
}
|
|
2116
2114
|
validateFields(e) {
|
|
@@ -2120,7 +2118,7 @@ class vn {
|
|
|
2120
2118
|
return e.length > 1 && n.push(...e.slice(1).map((s) => new l(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2121
2119
|
s.callee && !mn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Tn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2122
2120
|
const i = [...s.args];
|
|
2123
|
-
I.last(i) instanceof
|
|
2121
|
+
I.last(i) instanceof D ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof D && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2124
2122
|
}), n;
|
|
2125
2123
|
}
|
|
2126
2124
|
validateFieldSettings(e) {
|
|
@@ -2153,7 +2151,7 @@ function wn(t) {
|
|
|
2153
2151
|
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
|
|
2154
2152
|
return !1;
|
|
2155
2153
|
let e;
|
|
2156
|
-
if (t instanceof $ ? e =
|
|
2154
|
+
if (t instanceof $ ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2157
2155
|
switch (e.toLowerCase()) {
|
|
2158
2156
|
case "cascade":
|
|
2159
2157
|
case "no action":
|
|
@@ -2177,7 +2175,7 @@ class yn {
|
|
|
2177
2175
|
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2178
2176
|
}
|
|
2179
2177
|
validateName(e) {
|
|
2180
|
-
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)] : Ze(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)];
|
|
2181
2179
|
}
|
|
2182
2180
|
validateAlias(e) {
|
|
2183
2181
|
return e ? On(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
@@ -2194,7 +2192,7 @@ class yn {
|
|
|
2194
2192
|
break;
|
|
2195
2193
|
case "note":
|
|
2196
2194
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
2197
|
-
|
|
2195
|
+
W(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2198
2196
|
});
|
|
2199
2197
|
break;
|
|
2200
2198
|
default:
|
|
@@ -2220,9 +2218,9 @@ class yn {
|
|
|
2220
2218
|
validateBody(e) {
|
|
2221
2219
|
if (!e)
|
|
2222
2220
|
return [];
|
|
2223
|
-
if (e instanceof
|
|
2221
|
+
if (e instanceof y)
|
|
2224
2222
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2225
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2223
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2226
2224
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2227
2225
|
}
|
|
2228
2226
|
validateFields(e) {
|
|
@@ -2253,12 +2251,12 @@ class yn {
|
|
|
2253
2251
|
}
|
|
2254
2252
|
// This is needed to support legacy inline settings
|
|
2255
2253
|
validateFieldSetting(e) {
|
|
2256
|
-
if (!e.slice(0, -1).every(
|
|
2254
|
+
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof D))
|
|
2257
2255
|
return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2258
2256
|
if (e.length === 0)
|
|
2259
2257
|
return [];
|
|
2260
2258
|
let n;
|
|
2261
|
-
I.last(e) instanceof
|
|
2259
|
+
I.last(e) instanceof D && (n = e.pop());
|
|
2262
2260
|
const s = j(n), i = s.getErrors(), r = s.getValue();
|
|
2263
2261
|
for (const p of e) {
|
|
2264
2262
|
const h = V(p).unwrap_or("").toLowerCase();
|
|
@@ -2275,7 +2273,7 @@ class yn {
|
|
|
2275
2273
|
switch (p) {
|
|
2276
2274
|
case "note":
|
|
2277
2275
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2278
|
-
|
|
2276
|
+
W(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2279
2277
|
});
|
|
2280
2278
|
break;
|
|
2281
2279
|
case "ref":
|
|
@@ -2285,34 +2283,34 @@ class yn {
|
|
|
2285
2283
|
break;
|
|
2286
2284
|
case "primary key":
|
|
2287
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) => {
|
|
2288
|
-
|
|
2286
|
+
le(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
|
|
2289
2287
|
});
|
|
2290
2288
|
break;
|
|
2291
2289
|
case "pk":
|
|
2292
2290
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
|
|
2293
|
-
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));
|
|
2294
2292
|
});
|
|
2295
2293
|
break;
|
|
2296
2294
|
case "not null":
|
|
2297
2295
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
|
|
2298
2296
|
const T = r.null || [];
|
|
2299
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) => {
|
|
2300
|
-
|
|
2298
|
+
le(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
|
|
2301
2299
|
});
|
|
2302
2300
|
break;
|
|
2303
2301
|
case "null":
|
|
2304
2302
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
|
|
2305
|
-
|
|
2303
|
+
le(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
|
|
2306
2304
|
});
|
|
2307
2305
|
break;
|
|
2308
2306
|
case "unique":
|
|
2309
2307
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
|
|
2310
|
-
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));
|
|
2311
2309
|
});
|
|
2312
2310
|
break;
|
|
2313
2311
|
case "increment":
|
|
2314
2312
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
|
|
2315
|
-
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));
|
|
2316
2314
|
});
|
|
2317
2315
|
break;
|
|
2318
2316
|
case "default":
|
|
@@ -2340,15 +2338,15 @@ class yn {
|
|
|
2340
2338
|
}
|
|
2341
2339
|
}
|
|
2342
2340
|
function kn(t) {
|
|
2343
|
-
if (!(t instanceof
|
|
2341
|
+
if (!(t instanceof H || Je(t) || t instanceof U || t instanceof ue))
|
|
2344
2342
|
return !1;
|
|
2345
|
-
if (t instanceof
|
|
2346
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2343
|
+
if (t instanceof H) {
|
|
2344
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => he(n) || W(n) || me(n)))
|
|
2347
2345
|
return !1;
|
|
2348
2346
|
t = t.callee;
|
|
2349
2347
|
}
|
|
2350
|
-
for (; t instanceof
|
|
2351
|
-
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)))
|
|
2352
2350
|
return !1;
|
|
2353
2351
|
t = t.array;
|
|
2354
2352
|
}
|
|
@@ -2392,9 +2390,9 @@ class Sn {
|
|
|
2392
2390
|
validateBody(e) {
|
|
2393
2391
|
if (!e)
|
|
2394
2392
|
return [];
|
|
2395
|
-
if (e instanceof
|
|
2393
|
+
if (e instanceof y)
|
|
2396
2394
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2397
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2395
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2398
2396
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2399
2397
|
}
|
|
2400
2398
|
validateFields(e) {
|
|
@@ -2456,7 +2454,7 @@ function On(t) {
|
|
|
2456
2454
|
return Me(t);
|
|
2457
2455
|
}
|
|
2458
2456
|
function Me(t) {
|
|
2459
|
-
return t instanceof
|
|
2457
|
+
return t instanceof U && t.expression instanceof Z;
|
|
2460
2458
|
}
|
|
2461
2459
|
function Ke(t, e, n) {
|
|
2462
2460
|
var i;
|
|
@@ -2482,7 +2480,7 @@ function yt(t) {
|
|
|
2482
2480
|
}
|
|
2483
2481
|
function Rn(t) {
|
|
2484
2482
|
var n;
|
|
2485
|
-
if (!(t instanceof
|
|
2483
|
+
if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2486
2484
|
return !1;
|
|
2487
2485
|
const e = t.expression.literal.value;
|
|
2488
2486
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
@@ -2492,26 +2490,26 @@ function Rn(t) {
|
|
|
2492
2490
|
return !1;
|
|
2493
2491
|
return !0;
|
|
2494
2492
|
}
|
|
2495
|
-
function
|
|
2493
|
+
function le(t) {
|
|
2496
2494
|
return t === void 0;
|
|
2497
2495
|
}
|
|
2498
2496
|
function Dn(t) {
|
|
2499
2497
|
var e;
|
|
2500
|
-
return !!(
|
|
2498
|
+
return !!(W(t) || he(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && he(t.expression) || t instanceof te);
|
|
2501
2499
|
}
|
|
2502
|
-
function
|
|
2500
|
+
function he(t) {
|
|
2503
2501
|
var e;
|
|
2504
|
-
return t instanceof
|
|
2502
|
+
return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
|
|
2505
2503
|
}
|
|
2506
2504
|
function Pn(t) {
|
|
2507
2505
|
var n;
|
|
2508
|
-
if (!(t instanceof
|
|
2506
|
+
if (!(t instanceof Q) || !yt((n = t.op) == null ? void 0 : n.value))
|
|
2509
2507
|
return !1;
|
|
2510
2508
|
const e = C(t.expression).unwrap_or(void 0);
|
|
2511
2509
|
return e !== void 0 && e.length > 0;
|
|
2512
2510
|
}
|
|
2513
2511
|
function kt(t) {
|
|
2514
|
-
return t instanceof
|
|
2512
|
+
return t instanceof J && t.elementList.every(M);
|
|
2515
2513
|
}
|
|
2516
2514
|
function j(t) {
|
|
2517
2515
|
var s;
|
|
@@ -2521,11 +2519,11 @@ function j(t) {
|
|
|
2521
2519
|
for (const i of t.elementList) {
|
|
2522
2520
|
if (!i.name)
|
|
2523
2521
|
continue;
|
|
2524
|
-
if (i.name instanceof
|
|
2522
|
+
if (i.name instanceof U) {
|
|
2525
2523
|
n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2526
2524
|
continue;
|
|
2527
2525
|
}
|
|
2528
|
-
const r = (s =
|
|
2526
|
+
const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2529
2527
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2530
2528
|
}
|
|
2531
2529
|
return new B(e, n);
|
|
@@ -2562,9 +2560,9 @@ class ae {
|
|
|
2562
2560
|
bindSettingList(e, n) {
|
|
2563
2561
|
if (e)
|
|
2564
2562
|
for (const s of e.elementList) {
|
|
2565
|
-
if (s.name instanceof
|
|
2563
|
+
if (s.name instanceof U)
|
|
2566
2564
|
continue;
|
|
2567
|
-
const i =
|
|
2565
|
+
const i = Te(s.name).unwrap_or(void 0);
|
|
2568
2566
|
if (!i)
|
|
2569
2567
|
continue;
|
|
2570
2568
|
const r = n[i.toLowerCase()];
|
|
@@ -2590,7 +2588,7 @@ class ae {
|
|
|
2590
2588
|
}
|
|
2591
2589
|
bindSubfield(e) {
|
|
2592
2590
|
const n = [e.callee, ...e.args], s = I.last(n);
|
|
2593
|
-
s instanceof
|
|
2591
|
+
s instanceof D && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
|
|
2594
2592
|
const { argBinderRules: i } = this.subfield.arg;
|
|
2595
2593
|
for (let r = 0; r < Math.min(n.length, i.length); r += 1)
|
|
2596
2594
|
i[r].shouldBind && this.scanAndBind(n[r], i[r]);
|
|
@@ -2599,12 +2597,12 @@ class ae {
|
|
|
2599
2597
|
scanAndBind(e, n) {
|
|
2600
2598
|
var s, i;
|
|
2601
2599
|
if (e)
|
|
2602
|
-
if (e instanceof
|
|
2603
|
-
if (e.expression instanceof
|
|
2600
|
+
if (e instanceof U) {
|
|
2601
|
+
if (e.expression instanceof Z && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2604
2602
|
return;
|
|
2605
2603
|
this.bindFragments([e], n);
|
|
2606
2604
|
} else
|
|
2607
|
-
e instanceof
|
|
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 Pe ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2608
2606
|
}
|
|
2609
2607
|
// Bind the fragments of a member access expression
|
|
2610
2608
|
// which can be a simple expression like v1.User,
|
|
@@ -2905,7 +2903,7 @@ function St(t) {
|
|
|
2905
2903
|
}
|
|
2906
2904
|
throw new Error("Invalid relation op");
|
|
2907
2905
|
}
|
|
2908
|
-
function
|
|
2906
|
+
function v(t) {
|
|
2909
2907
|
return {
|
|
2910
2908
|
start: {
|
|
2911
2909
|
offset: t.startPos.offset,
|
|
@@ -2917,10 +2915,10 @@ function y(t) {
|
|
|
2917
2915
|
}
|
|
2918
2916
|
function $e(t) {
|
|
2919
2917
|
var n;
|
|
2920
|
-
const e = (n =
|
|
2921
|
-
return e instanceof
|
|
2918
|
+
const e = (n = fe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2919
|
+
return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2922
2920
|
}
|
|
2923
|
-
function
|
|
2921
|
+
function Ie(t) {
|
|
2924
2922
|
const e = C(t).unwrap();
|
|
2925
2923
|
return {
|
|
2926
2924
|
name: e.pop(),
|
|
@@ -2946,7 +2944,7 @@ function Dt(t, e) {
|
|
|
2946
2944
|
const n = t.id, s = e.id;
|
|
2947
2945
|
return n === s;
|
|
2948
2946
|
}
|
|
2949
|
-
function
|
|
2947
|
+
function Ne(t) {
|
|
2950
2948
|
const e = t.split(`
|
|
2951
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));
|
|
2952
2950
|
return n.map((r) => r.slice(i)).join(`
|
|
@@ -2957,7 +2955,7 @@ class Pt {
|
|
|
2957
2955
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2958
2956
|
}
|
|
2959
2957
|
interpret() {
|
|
2960
|
-
this.table.token =
|
|
2958
|
+
this.table.token = v(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
|
|
2961
2959
|
const e = [
|
|
2962
2960
|
...this.interpretName(this.declarationNode.name),
|
|
2963
2961
|
...this.interpretAlias(this.declarationNode.alias),
|
|
@@ -2976,7 +2974,7 @@ class Pt {
|
|
|
2976
2974
|
}), this.pkColumns.forEach((n) => n.pk = !1)), e;
|
|
2977
2975
|
}
|
|
2978
2976
|
interpretName(e) {
|
|
2979
|
-
const { name: n, schemaName: s } =
|
|
2977
|
+
const { name: n, schemaName: s } = Ie(e);
|
|
2980
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, []);
|
|
2981
2979
|
}
|
|
2982
2980
|
interpretAlias(e) {
|
|
@@ -2998,12 +2996,12 @@ class Pt {
|
|
|
2998
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;
|
|
2999
2997
|
const [s] = n.note || [];
|
|
3000
2998
|
return this.table.note = s && {
|
|
3001
|
-
value:
|
|
3002
|
-
token:
|
|
2999
|
+
value: z(s == null ? void 0 : s.value).map(Ne).unwrap(),
|
|
3000
|
+
token: v(s)
|
|
3003
3001
|
}, [];
|
|
3004
3002
|
}
|
|
3005
3003
|
interpretBody(e) {
|
|
3006
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
3004
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
3007
3005
|
return [...this.interpretFields(n), ...this.interpretSubElements(s)];
|
|
3008
3006
|
}
|
|
3009
3007
|
interpretSubElements(e) {
|
|
@@ -3012,8 +3010,8 @@ class Pt {
|
|
|
3012
3010
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3013
3011
|
case "note":
|
|
3014
3012
|
return this.table.note = {
|
|
3015
|
-
value:
|
|
3016
|
-
token:
|
|
3013
|
+
value: z(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(Ne).unwrap(),
|
|
3014
|
+
token: v(n)
|
|
3017
3015
|
}, [];
|
|
3018
3016
|
case "indexes":
|
|
3019
3017
|
return this.interpretIndexes(n);
|
|
@@ -3029,63 +3027,63 @@ class Pt {
|
|
|
3029
3027
|
const n = [], s = {};
|
|
3030
3028
|
s.name = V(e.callee).unwrap();
|
|
3031
3029
|
const i = Yn(e.args[0]);
|
|
3032
|
-
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 = [];
|
|
3033
3031
|
const r = e.args.slice(1);
|
|
3034
|
-
if (I.last(r) instanceof
|
|
3032
|
+
if (I.last(r) instanceof D) {
|
|
3035
3033
|
const _ = j(r.pop()).getValue();
|
|
3036
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);
|
|
3037
3035
|
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3038
3036
|
s.note = K && {
|
|
3039
|
-
value:
|
|
3040
|
-
token:
|
|
3037
|
+
value: z(K.value).map(Ne).unwrap(),
|
|
3038
|
+
token: v(K)
|
|
3041
3039
|
};
|
|
3042
|
-
const
|
|
3043
|
-
s.inline_refs =
|
|
3044
|
-
const [nt] = $e(
|
|
3040
|
+
const oe = _.ref || [];
|
|
3041
|
+
s.inline_refs = oe.flatMap((Y) => {
|
|
3042
|
+
const [nt] = $e(Y.value.expression);
|
|
3045
3043
|
if (Dt(nt, e.symbol))
|
|
3046
|
-
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
3047
|
-
const ye =
|
|
3048
|
-
let
|
|
3044
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
|
|
3045
|
+
const ye = Y.value.op, ee = C(Y.value.expression).unwrap();
|
|
3046
|
+
let pe;
|
|
3049
3047
|
if (ee.length === 1) {
|
|
3050
|
-
const [
|
|
3051
|
-
|
|
3048
|
+
const [ce] = ee;
|
|
3049
|
+
pe = {
|
|
3052
3050
|
schemaName: this.table.schemaName,
|
|
3053
3051
|
tableName: this.table.name,
|
|
3054
|
-
fieldNames: [
|
|
3052
|
+
fieldNames: [ce],
|
|
3055
3053
|
relation: ye.value,
|
|
3056
|
-
token:
|
|
3054
|
+
token: v(Y)
|
|
3057
3055
|
};
|
|
3058
3056
|
} else if (ee.length === 2) {
|
|
3059
|
-
const [
|
|
3060
|
-
|
|
3057
|
+
const [ce, Le] = ee;
|
|
3058
|
+
pe = {
|
|
3061
3059
|
schemaName: null,
|
|
3062
|
-
tableName:
|
|
3060
|
+
tableName: ce,
|
|
3063
3061
|
fieldNames: [Le],
|
|
3064
3062
|
relation: ye.value,
|
|
3065
|
-
token:
|
|
3063
|
+
token: v(Y)
|
|
3066
3064
|
};
|
|
3067
3065
|
} else if (ee.length === 3) {
|
|
3068
|
-
const [
|
|
3069
|
-
|
|
3070
|
-
schemaName:
|
|
3066
|
+
const [ce, Le, it] = ee;
|
|
3067
|
+
pe = {
|
|
3068
|
+
schemaName: ce,
|
|
3071
3069
|
tableName: Le,
|
|
3072
3070
|
fieldNames: [it],
|
|
3073
3071
|
relation: ye.value,
|
|
3074
|
-
token:
|
|
3072
|
+
token: v(Y)
|
|
3075
3073
|
};
|
|
3076
3074
|
} else {
|
|
3077
|
-
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported",
|
|
3078
|
-
const
|
|
3079
|
-
|
|
3075
|
+
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", Y));
|
|
3076
|
+
const ce = ee.pop(), Le = ee.pop();
|
|
3077
|
+
pe = {
|
|
3080
3078
|
schemaName: ee.join("."),
|
|
3081
3079
|
tableName: Le,
|
|
3082
|
-
fieldNames: [
|
|
3080
|
+
fieldNames: [ce],
|
|
3083
3081
|
relation: ye.value,
|
|
3084
|
-
token:
|
|
3082
|
+
token: v(Y)
|
|
3085
3083
|
};
|
|
3086
3084
|
}
|
|
3087
|
-
const st = this.registerInlineRefToEnv(e, nt,
|
|
3088
|
-
return n.push(...st), st.length === 0 ?
|
|
3085
|
+
const st = this.registerInlineRefToEnv(e, nt, pe, Y);
|
|
3086
|
+
return n.push(...st), st.length === 0 ? pe : [];
|
|
3089
3087
|
});
|
|
3090
3088
|
}
|
|
3091
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;
|
|
@@ -3094,34 +3092,36 @@ class Pt {
|
|
|
3094
3092
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3095
3093
|
var a, c, p, h, T, f, N;
|
|
3096
3094
|
const s = { columns: [] }, i = n;
|
|
3097
|
-
s.token =
|
|
3095
|
+
s.token = v(e);
|
|
3098
3096
|
const r = [i.callee, ...i.args];
|
|
3099
|
-
if (I.last(r) instanceof
|
|
3097
|
+
if (I.last(r) instanceof D) {
|
|
3100
3098
|
const g = j(r.pop()).getValue();
|
|
3101
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name =
|
|
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);
|
|
3102
3100
|
const _ = (T = g.note) == null ? void 0 : T.at(0);
|
|
3103
3101
|
s.note = _ && {
|
|
3104
|
-
value:
|
|
3105
|
-
token:
|
|
3102
|
+
value: z(_.value).unwrap(),
|
|
3103
|
+
token: v(_)
|
|
3106
3104
|
}, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3107
3105
|
}
|
|
3108
3106
|
return r.flatMap((g) => {
|
|
3109
|
-
if (!(g instanceof
|
|
3107
|
+
if (!(g instanceof H))
|
|
3110
3108
|
return g;
|
|
3111
3109
|
const _ = [];
|
|
3112
|
-
for (; g instanceof
|
|
3110
|
+
for (; g instanceof H; )
|
|
3113
3111
|
_.push(g.argumentList), g = g.callee;
|
|
3114
3112
|
return _.push(g), _;
|
|
3115
3113
|
}).forEach((g) => {
|
|
3116
3114
|
const { functional: _, nonFunctional: K } = Xe(g).unwrap();
|
|
3117
3115
|
s.columns.push(
|
|
3118
|
-
..._.map((
|
|
3119
|
-
value:
|
|
3120
|
-
type: "expression"
|
|
3116
|
+
..._.map((oe) => ({
|
|
3117
|
+
value: oe.value.value,
|
|
3118
|
+
type: "expression",
|
|
3119
|
+
token: v(oe)
|
|
3121
3120
|
})),
|
|
3122
|
-
...K.map((
|
|
3123
|
-
value: V(
|
|
3124
|
-
type: "column"
|
|
3121
|
+
...K.map((oe) => ({
|
|
3122
|
+
value: V(oe).unwrap(),
|
|
3123
|
+
type: "column",
|
|
3124
|
+
token: v(oe)
|
|
3125
3125
|
}))
|
|
3126
3126
|
);
|
|
3127
3127
|
}), s;
|
|
@@ -3148,7 +3148,7 @@ class Pt {
|
|
|
3148
3148
|
schemaName: this.table.schemaName,
|
|
3149
3149
|
tableName: this.table.name,
|
|
3150
3150
|
fieldNames: [X(e.callee).unwrap()],
|
|
3151
|
-
token:
|
|
3151
|
+
token: v(e),
|
|
3152
3152
|
relation: a[0]
|
|
3153
3153
|
}
|
|
3154
3154
|
]
|
|
@@ -3157,11 +3157,11 @@ class Pt {
|
|
|
3157
3157
|
}
|
|
3158
3158
|
function Yn(t) {
|
|
3159
3159
|
let e = null;
|
|
3160
|
-
t instanceof
|
|
3160
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => he(r) ? r.expression.literal.value : W(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3161
3161
|
let n = "";
|
|
3162
|
-
for (; t instanceof
|
|
3162
|
+
for (; t instanceof ue; )
|
|
3163
3163
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3164
|
-
const { name: s, schemaName: i } =
|
|
3164
|
+
const { name: s, schemaName: i } = Ie(t);
|
|
3165
3165
|
return i.length > 1 ? new B(
|
|
3166
3166
|
{
|
|
3167
3167
|
schemaName: i.length === 0 ? null : i[0],
|
|
@@ -3178,22 +3178,22 @@ function Yn(t) {
|
|
|
3178
3178
|
function zn(t) {
|
|
3179
3179
|
var e, n, s;
|
|
3180
3180
|
if (t) {
|
|
3181
|
-
if (
|
|
3181
|
+
if (W(t))
|
|
3182
3182
|
return {
|
|
3183
|
-
value:
|
|
3183
|
+
value: z(t).unwrap(),
|
|
3184
3184
|
type: "string"
|
|
3185
3185
|
};
|
|
3186
|
-
if (
|
|
3186
|
+
if (he(t))
|
|
3187
3187
|
return {
|
|
3188
3188
|
type: "number",
|
|
3189
3189
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3190
3190
|
};
|
|
3191
|
-
if (
|
|
3191
|
+
if (me(t))
|
|
3192
3192
|
return {
|
|
3193
3193
|
value: t.expression.variable.value.toLowerCase(),
|
|
3194
3194
|
type: "boolean"
|
|
3195
3195
|
};
|
|
3196
|
-
if (t instanceof
|
|
3196
|
+
if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && he(t.expression)) {
|
|
3197
3197
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3198
3198
|
return {
|
|
3199
3199
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
@@ -3213,14 +3213,14 @@ class Qn {
|
|
|
3213
3213
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3214
3214
|
}
|
|
3215
3215
|
interpret() {
|
|
3216
|
-
return this.note.token =
|
|
3216
|
+
return this.note.token = v(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
|
|
3217
3217
|
...this.interpretName(this.declarationNode.name),
|
|
3218
3218
|
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3219
3219
|
...this.interpretBody(this.declarationNode.body)
|
|
3220
3220
|
];
|
|
3221
3221
|
}
|
|
3222
3222
|
interpretName(e) {
|
|
3223
|
-
const { name: n } =
|
|
3223
|
+
const { name: n } = Ie(e);
|
|
3224
3224
|
return this.note.name = n, [];
|
|
3225
3225
|
}
|
|
3226
3226
|
interpretSettingList(e) {
|
|
@@ -3229,14 +3229,14 @@ class Qn {
|
|
|
3229
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, [];
|
|
3230
3230
|
}
|
|
3231
3231
|
interpretBody(e) {
|
|
3232
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
3232
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
3233
3233
|
return n.length !== 1 || s.length > 0 ? [
|
|
3234
3234
|
new l(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3235
3235
|
] : [...this.interpretNote(n[0])];
|
|
3236
3236
|
}
|
|
3237
3237
|
interpretNote(e) {
|
|
3238
3238
|
const n = I.get(e, "callee.expression.literal.value", "");
|
|
3239
|
-
return this.note.content =
|
|
3239
|
+
return this.note.content = Ne(n), [];
|
|
3240
3240
|
}
|
|
3241
3241
|
}
|
|
3242
3242
|
class Ut {
|
|
@@ -3244,14 +3244,14 @@ class Ut {
|
|
|
3244
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 = {};
|
|
3245
3245
|
}
|
|
3246
3246
|
interpret() {
|
|
3247
|
-
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)];
|
|
3248
3248
|
}
|
|
3249
3249
|
interpretName(e) {
|
|
3250
3250
|
const n = [], s = C(this.declarationNode.name).unwrap_or([]);
|
|
3251
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;
|
|
3252
3252
|
}
|
|
3253
3253
|
interpretBody(e) {
|
|
3254
|
-
return e instanceof
|
|
3254
|
+
return e instanceof y ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3255
3255
|
}
|
|
3256
3256
|
interpretField(e) {
|
|
3257
3257
|
var h, T, f, N;
|
|
@@ -3266,21 +3266,21 @@ class Ut {
|
|
|
3266
3266
|
];
|
|
3267
3267
|
if (e.args[0]) {
|
|
3268
3268
|
const g = j(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
|
|
3269
|
-
this.ref.onDelete = _ instanceof $ ?
|
|
3269
|
+
this.ref.onDelete = _ instanceof $ ? Te(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
|
|
3270
3270
|
const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
|
|
3271
|
-
this.ref.onUpdate = K instanceof $ ?
|
|
3271
|
+
this.ref.onUpdate = K instanceof $ ? Te(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
|
|
3272
3272
|
}
|
|
3273
3273
|
const p = St(n);
|
|
3274
3274
|
return this.ref.endpoints = [
|
|
3275
3275
|
{
|
|
3276
3276
|
...pt(s, this.container),
|
|
3277
3277
|
relation: p[0],
|
|
3278
|
-
token:
|
|
3278
|
+
token: v(s)
|
|
3279
3279
|
},
|
|
3280
3280
|
{
|
|
3281
3281
|
...pt(i, this.container),
|
|
3282
3282
|
relation: p[1],
|
|
3283
|
-
token:
|
|
3283
|
+
token: v(i)
|
|
3284
3284
|
}
|
|
3285
3285
|
], this.env.refIds[c] = this.declarationNode, [];
|
|
3286
3286
|
}
|
|
@@ -3291,13 +3291,13 @@ class Mt {
|
|
|
3291
3291
|
}
|
|
3292
3292
|
interpret() {
|
|
3293
3293
|
const e = [];
|
|
3294
|
-
return this.tableGroup.token =
|
|
3294
|
+
return this.tableGroup.token = v(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
|
|
3295
3295
|
...this.interpretName(this.declarationNode.name),
|
|
3296
3296
|
...this.interpretBody(this.declarationNode.body)
|
|
3297
3297
|
), e;
|
|
3298
3298
|
}
|
|
3299
3299
|
interpretName(e) {
|
|
3300
|
-
const n = [], { name: s, schemaName: i } =
|
|
3300
|
+
const n = [], { name: s, schemaName: i } = Ie(e);
|
|
3301
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;
|
|
3302
3302
|
}
|
|
3303
3303
|
interpretBody(e) {
|
|
@@ -3305,7 +3305,7 @@ class Mt {
|
|
|
3305
3305
|
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3306
3306
|
const i = C(s.callee).unwrap();
|
|
3307
3307
|
i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3308
|
-
const r =
|
|
3308
|
+
const r = fe(s.callee).unwrap().pop().referee.id;
|
|
3309
3309
|
if (this.env.groupOfTable[r]) {
|
|
3310
3310
|
const a = this.env.groupOfTable[r], { schemaName: c, name: p } = this.env.tableGroups.get(a), h = c ? `${c}.${p}` : p;
|
|
3311
3311
|
n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
|
|
@@ -3323,21 +3323,21 @@ class Ft {
|
|
|
3323
3323
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3324
3324
|
}
|
|
3325
3325
|
interpret() {
|
|
3326
|
-
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)];
|
|
3327
3327
|
}
|
|
3328
3328
|
interpretName(e) {
|
|
3329
|
-
const { name: n, schemaName: s } =
|
|
3329
|
+
const { name: n, schemaName: s } = Ie(e);
|
|
3330
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, []);
|
|
3331
3331
|
}
|
|
3332
3332
|
interpretBody(e) {
|
|
3333
3333
|
return e.body.flatMap((n) => {
|
|
3334
3334
|
var c;
|
|
3335
3335
|
const s = n, i = {};
|
|
3336
|
-
i.token =
|
|
3336
|
+
i.token = v(s), i.name = X(s.callee).unwrap();
|
|
3337
3337
|
const a = (c = j(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3338
3338
|
return i.note = a && {
|
|
3339
|
-
value:
|
|
3340
|
-
token:
|
|
3339
|
+
value: z(a.value).map(Ne).unwrap(),
|
|
3340
|
+
token: v(a)
|
|
3341
3341
|
}, this.enum.values.push(i), [];
|
|
3342
3342
|
});
|
|
3343
3343
|
}
|
|
@@ -3347,12 +3347,12 @@ class qn {
|
|
|
3347
3347
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3348
3348
|
}
|
|
3349
3349
|
interpret() {
|
|
3350
|
-
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)];
|
|
3351
3351
|
}
|
|
3352
3352
|
interpretName(e) {
|
|
3353
3353
|
if (!e)
|
|
3354
3354
|
return this.project.name = null, [];
|
|
3355
|
-
const { name: n } =
|
|
3355
|
+
const { name: n } = Ie(e);
|
|
3356
3356
|
return this.project.name = n, [];
|
|
3357
3357
|
}
|
|
3358
3358
|
interpretBody(e) {
|
|
@@ -3378,11 +3378,11 @@ class qn {
|
|
|
3378
3378
|
}
|
|
3379
3379
|
case "note":
|
|
3380
3380
|
return this.project.note = {
|
|
3381
|
-
value:
|
|
3382
|
-
token:
|
|
3381
|
+
value: z(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(Ne).unwrap(),
|
|
3382
|
+
token: v(s)
|
|
3383
3383
|
}, [];
|
|
3384
3384
|
default:
|
|
3385
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
3385
|
+
return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
|
|
3386
3386
|
}
|
|
3387
3387
|
});
|
|
3388
3388
|
}
|
|
@@ -3516,7 +3516,7 @@ class Bt {
|
|
|
3516
3516
|
return Tt();
|
|
3517
3517
|
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3518
3518
|
for (const N of h)
|
|
3519
|
-
if (N instanceof
|
|
3519
|
+
if (N instanceof Q)
|
|
3520
3520
|
switch ((T = N.op) == null ? void 0 : T.value) {
|
|
3521
3521
|
case ">":
|
|
3522
3522
|
case "<":
|
|
@@ -3528,7 +3528,7 @@ class Bt {
|
|
|
3528
3528
|
N
|
|
3529
3529
|
);
|
|
3530
3530
|
}
|
|
3531
|
-
else if (N instanceof
|
|
3531
|
+
else if (N instanceof q)
|
|
3532
3532
|
switch ((f = N.op) == null ? void 0 : f.value) {
|
|
3533
3533
|
case ">":
|
|
3534
3534
|
case "<":
|
|
@@ -3549,11 +3549,11 @@ class Bt {
|
|
|
3549
3549
|
else {
|
|
3550
3550
|
if (N instanceof se)
|
|
3551
3551
|
return Et(this.compiler, s, N);
|
|
3552
|
-
if (N instanceof
|
|
3552
|
+
if (N instanceof D)
|
|
3553
3553
|
return Et(this.compiler, s, N);
|
|
3554
|
-
if (N instanceof
|
|
3554
|
+
if (N instanceof J)
|
|
3555
3555
|
return Zn(this.compiler, s);
|
|
3556
|
-
if (N instanceof
|
|
3556
|
+
if (N instanceof y)
|
|
3557
3557
|
return mt(this.compiler, s, N);
|
|
3558
3558
|
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && ge(s, N.body)))
|
|
3559
3559
|
return mt(this.compiler, s, void 0);
|
|
@@ -3607,7 +3607,7 @@ function Zn(t, e) {
|
|
|
3607
3607
|
const i = [...t.container.stack(e)];
|
|
3608
3608
|
for (; i.length > 0; ) {
|
|
3609
3609
|
const r = i.pop();
|
|
3610
|
-
if (r instanceof
|
|
3610
|
+
if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3611
3611
|
return Vt(
|
|
3612
3612
|
t,
|
|
3613
3613
|
e,
|
|
@@ -3631,7 +3631,7 @@ function Et(t, e, n) {
|
|
|
3631
3631
|
const i = Kn(
|
|
3632
3632
|
t,
|
|
3633
3633
|
e,
|
|
3634
|
-
|
|
3634
|
+
Te(n.name).unwrap()
|
|
3635
3635
|
);
|
|
3636
3636
|
return (s == null ? void 0 : s.kind) === u.COLON && Re(s, e) ? De(i) : i;
|
|
3637
3637
|
}
|
|
@@ -3763,7 +3763,7 @@ function Kn(t, e, n) {
|
|
|
3763
3763
|
return O();
|
|
3764
3764
|
}
|
|
3765
3765
|
function Vt(t, e, n) {
|
|
3766
|
-
const s =
|
|
3766
|
+
const s = fe(n).unwrap_or([]);
|
|
3767
3767
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3768
3768
|
return O();
|
|
3769
3769
|
const i = s.map((r) => X(r).unwrap());
|
|
@@ -3994,7 +3994,7 @@ class Xt {
|
|
|
3994
3994
|
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
3995
3995
|
for (; r.length !== 0; ) {
|
|
3996
3996
|
const c = r.pop();
|
|
3997
|
-
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)) {
|
|
3998
3998
|
const { startPos: p, endPos: h } = c.referee.declaration;
|
|
3999
3999
|
return [
|
|
4000
4000
|
{
|
|
@@ -4021,9 +4021,9 @@ class $t {
|
|
|
4021
4021
|
for (; r.length !== 0; ) {
|
|
4022
4022
|
const a = r.pop();
|
|
4023
4023
|
if (a && [
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4024
|
+
Ee.ELEMENT_DECLARATION,
|
|
4025
|
+
Ee.FUNCTION_APPLICATION,
|
|
4026
|
+
Ee.PRIMARY_EXPRESSION
|
|
4027
4027
|
].includes(a == null ? void 0 : a.kind)) {
|
|
4028
4028
|
const { symbol: c } = a;
|
|
4029
4029
|
if (c != null && c.references.length)
|
|
@@ -4118,13 +4118,13 @@ class ls {
|
|
|
4118
4118
|
for (; c.length > 0; ) {
|
|
4119
4119
|
let p = !1;
|
|
4120
4120
|
const h = I.last(c);
|
|
4121
|
-
if (h instanceof
|
|
4121
|
+
if (h instanceof y) {
|
|
4122
4122
|
const T = this.parse.source();
|
|
4123
4123
|
for (let f = h.end; f < e; f += 1)
|
|
4124
4124
|
T[f] === `
|
|
4125
4125
|
` && (c.pop(), p = !0);
|
|
4126
4126
|
} else
|
|
4127
|
-
h instanceof
|
|
4127
|
+
h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof D ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof $ || h.end < e && (c.pop(), p = !0);
|
|
4128
4128
|
if (p) {
|
|
4129
4129
|
const T = I.last(c);
|
|
4130
4130
|
T instanceof A && T.end <= e && c.pop();
|