@dbml/parse 3.1.7 → 3.1.8
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 +373 -371
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -94,13 +94,13 @@ class y {
|
|
|
94
94
|
}, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
var
|
|
98
|
-
class
|
|
97
|
+
var de = /* @__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))(de || {});
|
|
98
|
+
class X extends y {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class A extends y {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -118,17 +118,17 @@ class _ extends y {
|
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
120
|
l
|
|
121
|
-
]), l && a && !(l instanceof k || l instanceof
|
|
121
|
+
]), l && a && !(l instanceof k || l 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 = l;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class
|
|
126
|
+
class C extends y {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class
|
|
131
|
+
class se extends y {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: n,
|
|
@@ -137,12 +137,12 @@ class ne extends y {
|
|
|
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 y {
|
|
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 H extends y {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,12 +151,12 @@ class q extends y {
|
|
|
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 De extends y {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class
|
|
159
|
+
class te extends y {
|
|
160
160
|
constructor({ value: e }, n) {
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
@@ -166,7 +166,7 @@ class k extends y {
|
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class
|
|
169
|
+
class ne extends y {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -189,7 +189,7 @@ class P extends y {
|
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class
|
|
192
|
+
class Z extends y {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -203,7 +203,7 @@ class J extends y {
|
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class Xe extends
|
|
206
|
+
class Xe extends Z {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -220,7 +220,7 @@ class Xe extends J {
|
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class
|
|
223
|
+
class J extends y {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: n
|
|
@@ -228,12 +228,12 @@ class H extends y {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class me extends y {
|
|
232
232
|
constructor({ literal: e }, n) {
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class $ extends y {
|
|
237
237
|
constructor({ variable: e }, n) {
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
@@ -243,13 +243,13 @@ class D extends y {
|
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class ye extends y {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
248
|
const s = B.create(c.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
252
|
+
class ce extends y {
|
|
253
253
|
constructor({ expression: e, indexer: n }, s) {
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
@@ -269,7 +269,7 @@ function is(t, e = !1) {
|
|
|
269
269
|
t,
|
|
270
270
|
function(n, s) {
|
|
271
271
|
var i;
|
|
272
|
-
return !(this instanceof
|
|
272
|
+
return !(this instanceof X) && n === "symbol" ? s == null ? void 0 : s.id : (
|
|
273
273
|
/* this instanceof SyntaxNode && */
|
|
274
274
|
n === "symbol" ? {
|
|
275
275
|
symbolTable: s == null ? void 0 : s.symbolTable,
|
|
@@ -312,7 +312,7 @@ class O {
|
|
|
312
312
|
return !0;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class v {
|
|
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 A {
|
|
|
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 v();
|
|
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 v();
|
|
331
331
|
}
|
|
332
332
|
// eslint-disable-next-line class-methods-use-this
|
|
333
333
|
isOk() {
|
|
@@ -338,7 +338,7 @@ var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Colum
|
|
|
338
338
|
function $e(t) {
|
|
339
339
|
return `Schema:${t}`;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function xe(t) {
|
|
342
342
|
return `Table:${t}`;
|
|
343
343
|
}
|
|
344
344
|
function We(t) {
|
|
@@ -367,7 +367,7 @@ function Fe(t, e) {
|
|
|
367
367
|
case "Schema":
|
|
368
368
|
return $e(t);
|
|
369
369
|
case "Table":
|
|
370
|
-
return
|
|
370
|
+
return xe(t);
|
|
371
371
|
case "TableGroup":
|
|
372
372
|
return ze(t);
|
|
373
373
|
case "TableGroup field":
|
|
@@ -376,15 +376,15 @@ function Fe(t, e) {
|
|
|
376
376
|
throw new Error("Unreachable");
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function ie(t) {
|
|
380
380
|
const [e, n] = t.split(":");
|
|
381
381
|
return Object.values(m).includes(e) ? new O({
|
|
382
382
|
name: n,
|
|
383
383
|
kind: e
|
|
384
|
-
}) : new
|
|
384
|
+
}) : new v();
|
|
385
385
|
}
|
|
386
386
|
function jt(t) {
|
|
387
|
-
const e =
|
|
387
|
+
const e = ie(t).unwrap_or(void 0);
|
|
388
388
|
if (!e)
|
|
389
389
|
return !1;
|
|
390
390
|
const { kind: n, name: s } = e;
|
|
@@ -393,7 +393,7 @@ function jt(t) {
|
|
|
393
393
|
function Yt(t) {
|
|
394
394
|
return [
|
|
395
395
|
$e,
|
|
396
|
-
|
|
396
|
+
xe,
|
|
397
397
|
je,
|
|
398
398
|
ze,
|
|
399
399
|
We,
|
|
@@ -405,16 +405,16 @@ function qe(t) {
|
|
|
405
405
|
const [e] = t;
|
|
406
406
|
return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
|
|
407
407
|
}
|
|
408
|
-
function
|
|
408
|
+
function Oe(t) {
|
|
409
409
|
const [e] = t;
|
|
410
410
|
return e >= "0" && e <= "9";
|
|
411
411
|
}
|
|
412
412
|
function zt(t) {
|
|
413
413
|
const [e] = t;
|
|
414
|
-
return
|
|
414
|
+
return Oe(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
return qe(t) ||
|
|
416
|
+
function pe(t) {
|
|
417
|
+
return qe(t) || Oe(t);
|
|
418
418
|
}
|
|
419
419
|
function ot(t, e) {
|
|
420
420
|
const n = [], s = Math.min(t.length, e.length);
|
|
@@ -422,7 +422,7 @@ function ot(t, e) {
|
|
|
422
422
|
n.push(t[i], e[i]);
|
|
423
423
|
return n.push(...t.slice(s), ...e.slice(s)), n;
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function Ie(t, e) {
|
|
426
426
|
return t >= e.start && t < e.end;
|
|
427
427
|
}
|
|
428
428
|
class Qt {
|
|
@@ -496,14 +496,14 @@ class F {
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
function en(t, e, n) {
|
|
499
|
-
if (!t || !
|
|
500
|
-
return new
|
|
499
|
+
if (!t || !Ee(t) || e.length === 0)
|
|
500
|
+
return new v();
|
|
501
501
|
const s = [...e], i = Be(t).unwrap(), r = s.pop();
|
|
502
|
-
if (!(r instanceof
|
|
503
|
-
return new
|
|
502
|
+
if (!(r instanceof ne))
|
|
503
|
+
return new v();
|
|
504
504
|
const a = I.last(s) instanceof P ? s.pop() : void 0;
|
|
505
505
|
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new O(
|
|
506
|
-
n.create(
|
|
506
|
+
n.create(A, {
|
|
507
507
|
type: i,
|
|
508
508
|
name: s[0],
|
|
509
509
|
as: Be(s[1]).unwrap(),
|
|
@@ -512,19 +512,19 @@ function en(t, e, n) {
|
|
|
512
512
|
body: r
|
|
513
513
|
})
|
|
514
514
|
) : s.length === 1 ? new O(
|
|
515
|
-
n.create(
|
|
515
|
+
n.create(A, {
|
|
516
516
|
type: i,
|
|
517
517
|
name: s[0],
|
|
518
518
|
attributeList: a,
|
|
519
519
|
body: r
|
|
520
520
|
})
|
|
521
521
|
) : s.length === 0 ? new O(
|
|
522
|
-
n.create(
|
|
522
|
+
n.create(A, {
|
|
523
523
|
type: i,
|
|
524
524
|
attributeList: a,
|
|
525
525
|
body: r
|
|
526
526
|
})
|
|
527
|
-
) : new
|
|
527
|
+
) : new v();
|
|
528
528
|
}
|
|
529
529
|
function lt(t) {
|
|
530
530
|
return t.kind === c.IDENTIFIER && t.value === "as";
|
|
@@ -536,35 +536,35 @@ function tn(t) {
|
|
|
536
536
|
t.kind !== c.EOF && (t.isInvalid = !0);
|
|
537
537
|
}
|
|
538
538
|
function nn(t) {
|
|
539
|
-
if (t instanceof
|
|
539
|
+
if (t instanceof A)
|
|
540
540
|
E(t.type), E(t.name), E(t.as), E(t.alias), E(t.bodyColon), E(t.attributeList), E(t.body);
|
|
541
|
-
else if (t instanceof
|
|
541
|
+
else if (t instanceof C)
|
|
542
542
|
t.identifiers.forEach(E);
|
|
543
|
-
else if (t instanceof
|
|
543
|
+
else if (t instanceof se)
|
|
544
544
|
E(t.name), E(t.colon), E(t.value);
|
|
545
|
-
else if (t instanceof Q)
|
|
546
|
-
E(t.op), E(t.expression);
|
|
547
545
|
else if (t instanceof q)
|
|
546
|
+
E(t.op), E(t.expression);
|
|
547
|
+
else if (t instanceof H)
|
|
548
548
|
E(t.leftExpression), E(t.op), E(t.rightExpression);
|
|
549
|
-
else if (t instanceof
|
|
549
|
+
else if (t instanceof De)
|
|
550
550
|
E(t.op), E(t.expression);
|
|
551
|
-
else if (t instanceof
|
|
551
|
+
else if (t instanceof ne)
|
|
552
552
|
E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
|
|
553
553
|
else if (t instanceof P)
|
|
554
554
|
E(t.listOpenBracket), t.commaList.forEach(E), t.elementList.forEach(E), E(t.listCloseBracket);
|
|
555
|
-
else if (t instanceof
|
|
555
|
+
else if (t instanceof Z)
|
|
556
556
|
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
557
|
-
else if (t instanceof
|
|
557
|
+
else if (t instanceof J)
|
|
558
558
|
E(t.callee), E(t.argumentList);
|
|
559
559
|
else if (t instanceof k)
|
|
560
560
|
E(t.callee), t.args.forEach(E);
|
|
561
561
|
else if (t instanceof D)
|
|
562
562
|
E(t.expression);
|
|
563
|
-
else if (t instanceof
|
|
563
|
+
else if (t instanceof te)
|
|
564
564
|
E(t.value);
|
|
565
|
-
else if (t instanceof
|
|
565
|
+
else if (t instanceof $)
|
|
566
566
|
E(t.variable);
|
|
567
|
-
else if (t instanceof
|
|
567
|
+
else if (t instanceof me)
|
|
568
568
|
E(t.literal);
|
|
569
569
|
else
|
|
570
570
|
throw t instanceof Xe ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
@@ -576,9 +576,9 @@ function U(...t) {
|
|
|
576
576
|
return t.filter((e) => e !== void 0);
|
|
577
577
|
}
|
|
578
578
|
function sn(t) {
|
|
579
|
-
if (t instanceof
|
|
579
|
+
if (t instanceof X)
|
|
580
580
|
return U(...t.body, t.eof);
|
|
581
|
-
if (t instanceof
|
|
581
|
+
if (t instanceof A)
|
|
582
582
|
return U(
|
|
583
583
|
t.type,
|
|
584
584
|
t.name,
|
|
@@ -588,25 +588,25 @@ function sn(t) {
|
|
|
588
588
|
t.bodyColon,
|
|
589
589
|
t.body
|
|
590
590
|
);
|
|
591
|
-
if (t instanceof
|
|
591
|
+
if (t instanceof se)
|
|
592
592
|
return U(t.name, t.colon, t.value);
|
|
593
|
-
if (t instanceof
|
|
593
|
+
if (t instanceof C)
|
|
594
594
|
return t.identifiers;
|
|
595
|
-
if (t instanceof
|
|
595
|
+
if (t instanceof me)
|
|
596
596
|
return t.literal ? [t.literal] : [];
|
|
597
|
-
if (t instanceof
|
|
597
|
+
if (t instanceof $)
|
|
598
598
|
return U(t.variable);
|
|
599
|
-
if (t instanceof Q)
|
|
600
|
-
return U(t.op, t.expression);
|
|
601
599
|
if (t instanceof q)
|
|
600
|
+
return U(t.op, t.expression);
|
|
601
|
+
if (t instanceof H)
|
|
602
602
|
return U(t.leftExpression, t.op, t.rightExpression);
|
|
603
|
-
if (t instanceof
|
|
603
|
+
if (t instanceof De)
|
|
604
604
|
return U(t.expression, t.op);
|
|
605
|
-
if (t instanceof
|
|
605
|
+
if (t instanceof te)
|
|
606
606
|
return U(t.value);
|
|
607
607
|
if (t instanceof k)
|
|
608
608
|
return U(t.callee, ...t.args);
|
|
609
|
-
if (t instanceof
|
|
609
|
+
if (t instanceof ne)
|
|
610
610
|
return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
611
611
|
if (t instanceof P)
|
|
612
612
|
return U(
|
|
@@ -614,17 +614,17 @@ function sn(t) {
|
|
|
614
614
|
...ot(t.elementList, t.commaList),
|
|
615
615
|
t.listCloseBracket
|
|
616
616
|
);
|
|
617
|
-
if (t instanceof
|
|
617
|
+
if (t instanceof Z)
|
|
618
618
|
return U(
|
|
619
619
|
t.tupleOpenParen,
|
|
620
620
|
...ot(t.elementList, t.commaList),
|
|
621
621
|
t.tupleCloseParen
|
|
622
622
|
);
|
|
623
|
-
if (t instanceof
|
|
623
|
+
if (t instanceof J)
|
|
624
624
|
return U(t.callee, t.argumentList);
|
|
625
625
|
if (t instanceof D)
|
|
626
626
|
return U(t.expression);
|
|
627
|
-
if (t instanceof
|
|
627
|
+
if (t instanceof ce)
|
|
628
628
|
return U(
|
|
629
629
|
t.array,
|
|
630
630
|
t.indexer
|
|
@@ -632,28 +632,28 @@ function sn(t) {
|
|
|
632
632
|
throw t instanceof Xe ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
633
633
|
}
|
|
634
634
|
function Be(t) {
|
|
635
|
-
return M(t) ? new O(t.expression.variable) : new
|
|
635
|
+
return M(t) ? new O(t.expression.variable) : new v();
|
|
636
636
|
}
|
|
637
|
-
function
|
|
637
|
+
function W(t) {
|
|
638
638
|
var e;
|
|
639
|
-
return t instanceof D && (t.expression instanceof
|
|
639
|
+
return t instanceof D && (t.expression instanceof $ && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
|
|
640
640
|
}
|
|
641
641
|
function M(t) {
|
|
642
|
-
return t instanceof D && t.expression instanceof
|
|
642
|
+
return t instanceof D && t.expression instanceof $ && t.expression.variable instanceof B;
|
|
643
643
|
}
|
|
644
|
-
function
|
|
644
|
+
function Ee(t) {
|
|
645
645
|
var e;
|
|
646
|
-
return t instanceof D && t.expression instanceof
|
|
646
|
+
return t instanceof D && t.expression instanceof $ && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
|
|
647
647
|
}
|
|
648
648
|
function He(t) {
|
|
649
649
|
var e;
|
|
650
|
-
return t instanceof
|
|
650
|
+
return t instanceof H && t.leftExpression instanceof y && t.rightExpression instanceof y && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Ne(t) {
|
|
653
653
|
if (t === void 0)
|
|
654
|
-
return new
|
|
654
|
+
return new v();
|
|
655
655
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
656
|
-
return e === "" ? new
|
|
656
|
+
return e === "" ? new v() : new O(e);
|
|
657
657
|
}
|
|
658
658
|
class rn {
|
|
659
659
|
// list of errors during lexing
|
|
@@ -773,7 +773,7 @@ class rn {
|
|
|
773
773
|
this.identifier();
|
|
774
774
|
break;
|
|
775
775
|
}
|
|
776
|
-
if (
|
|
776
|
+
if (Oe(e)) {
|
|
777
777
|
this.numericLiteralOrIdentifier();
|
|
778
778
|
break;
|
|
779
779
|
}
|
|
@@ -888,7 +888,7 @@ class rn {
|
|
|
888
888
|
});
|
|
889
889
|
}
|
|
890
890
|
identifier() {
|
|
891
|
-
for (; !this.isAtEnd() &&
|
|
891
|
+
for (; !this.isAtEnd() && pe(this.peek()); )
|
|
892
892
|
this.advance();
|
|
893
893
|
this.addToken(c.IDENTIFIER);
|
|
894
894
|
}
|
|
@@ -908,26 +908,26 @@ class rn {
|
|
|
908
908
|
break;
|
|
909
909
|
if (!n && this.current.offset === this.text.length - 1)
|
|
910
910
|
return this.advance(), this.addToken(c.NUMERIC_LITERAL);
|
|
911
|
-
if (!n && !
|
|
911
|
+
if (!n && !pe(this.peek()))
|
|
912
912
|
return this.addToken(c.NUMERIC_LITERAL);
|
|
913
|
-
if (!n && !
|
|
913
|
+
if (!n && !Oe(this.peek()))
|
|
914
914
|
break;
|
|
915
915
|
this.advance();
|
|
916
916
|
}
|
|
917
917
|
if (e > 0) {
|
|
918
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
918
|
+
for (; !this.isAtEnd() && (this.check(".") || pe(this.peek())); )
|
|
919
919
|
this.advance();
|
|
920
920
|
const n = this.createToken(c.NUMERIC_LITERAL, !0);
|
|
921
921
|
this.tokens.push(n), this.errors.push(new u(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
922
922
|
} else {
|
|
923
|
-
for (; !this.isAtEnd() &&
|
|
923
|
+
for (; !this.isAtEnd() && pe(this.peek()); )
|
|
924
924
|
this.advance();
|
|
925
925
|
const n = this.createToken(c.IDENTIFIER, !1);
|
|
926
926
|
this.tokens.push(n);
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
929
|
colorLiteral() {
|
|
930
|
-
for (; !this.isAtEnd() &&
|
|
930
|
+
for (; !this.isAtEnd() && pe(this.peek()); )
|
|
931
931
|
this.advance();
|
|
932
932
|
this.addToken(c.COLOR_LITERAL);
|
|
933
933
|
}
|
|
@@ -959,7 +959,7 @@ class rn {
|
|
|
959
959
|
case "u": {
|
|
960
960
|
let e = "";
|
|
961
961
|
for (let n = 0; n <= 3; n += 1) {
|
|
962
|
-
if (this.isAtEnd() || !
|
|
962
|
+
if (this.isAtEnd() || !pe(this.peek()))
|
|
963
963
|
return `\\u${e}`;
|
|
964
964
|
e += this.advance();
|
|
965
965
|
}
|
|
@@ -970,7 +970,7 @@ class rn {
|
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
-
var
|
|
973
|
+
var ke = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ke || {});
|
|
974
974
|
class an {
|
|
975
975
|
constructor() {
|
|
976
976
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
@@ -1069,8 +1069,8 @@ class ln {
|
|
|
1069
1069
|
break;
|
|
1070
1070
|
E(s), this.advance();
|
|
1071
1071
|
}
|
|
1072
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1073
|
-
const s = { body: [] }, i = () => this.nodeFactory.create(
|
|
1072
|
+
}, this.blockExpression = this.contextStack.withContextDo(ke.BlockExpression, () => {
|
|
1073
|
+
const s = { body: [] }, i = () => this.nodeFactory.create(ne, s);
|
|
1074
1074
|
try {
|
|
1075
1075
|
this.consume("Expect an opening brace '{'", c.LBRACE), s.blockOpenBrace = this.previous();
|
|
1076
1076
|
} catch (r) {
|
|
@@ -1108,12 +1108,12 @@ class ln {
|
|
|
1108
1108
|
break;
|
|
1109
1109
|
E(s), this.advance();
|
|
1110
1110
|
}
|
|
1111
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1111
|
+
}, this.tupleExpression = this.contextStack.withContextDo(ke.GroupExpression, () => {
|
|
1112
1112
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Xe, {
|
|
1113
1113
|
groupOpenParen: s.tupleOpenParen,
|
|
1114
1114
|
groupCloseParen: s.tupleCloseParen,
|
|
1115
1115
|
expression: s.elementList[0]
|
|
1116
|
-
}), r = () => this.nodeFactory.create(
|
|
1116
|
+
}), r = () => this.nodeFactory.create(Z, s);
|
|
1117
1117
|
try {
|
|
1118
1118
|
this.consume("Expect an opening parenthesis '('", c.LPAREN), s.tupleOpenParen = this.previous();
|
|
1119
1119
|
} catch (a) {
|
|
@@ -1160,7 +1160,7 @@ class ln {
|
|
|
1160
1160
|
break;
|
|
1161
1161
|
E(s), this.advance();
|
|
1162
1162
|
}
|
|
1163
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
1163
|
+
}, this.listExpression = this.contextStack.withContextDo(ke.ListExpression, () => {
|
|
1164
1164
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(P, s);
|
|
1165
1165
|
try {
|
|
1166
1166
|
this.consume("Expect an opening bracket '['", c.LBRACKET), s.listOpenBracket = this.previous();
|
|
@@ -1278,7 +1278,7 @@ class ln {
|
|
|
1278
1278
|
this.tokens = e;
|
|
1279
1279
|
}
|
|
1280
1280
|
parse() {
|
|
1281
|
-
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(
|
|
1281
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(X, { body: e, eof: n });
|
|
1282
1282
|
return this.gatherInvalid(), new F({ ast: s, tokens: this.tokens }, this.errors);
|
|
1283
1283
|
}
|
|
1284
1284
|
/* Parsing and synchronizing ProgramNode */
|
|
@@ -1297,7 +1297,7 @@ class ln {
|
|
|
1297
1297
|
}
|
|
1298
1298
|
/* Parsing and synchronizing top-level ElementDeclarationNode */
|
|
1299
1299
|
elementDeclaration() {
|
|
1300
|
-
const e = {}, n = () => this.nodeFactory.create(
|
|
1300
|
+
const e = {}, n = () => this.nodeFactory.create(A, e);
|
|
1301
1301
|
try {
|
|
1302
1302
|
this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
|
|
1303
1303
|
} catch (s) {
|
|
@@ -1341,13 +1341,13 @@ class ln {
|
|
|
1341
1341
|
if (this.match(c.COLON)) {
|
|
1342
1342
|
e.bodyColon = this.previous();
|
|
1343
1343
|
const s = this.expression();
|
|
1344
|
-
s instanceof
|
|
1344
|
+
s instanceof A ? (E(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
|
|
1345
1345
|
} else
|
|
1346
1346
|
e.body = this.blockExpression();
|
|
1347
1347
|
} catch (s) {
|
|
1348
1348
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1349
1349
|
}
|
|
1350
|
-
return this.nodeFactory.create(
|
|
1350
|
+
return this.nodeFactory.create(A, e);
|
|
1351
1351
|
}
|
|
1352
1352
|
/* Parsing nested element declarations with simple body */
|
|
1353
1353
|
// e.g
|
|
@@ -1356,7 +1356,7 @@ class ln {
|
|
|
1356
1356
|
// Note: 'This is a note' // fieldDeclaration() handles this
|
|
1357
1357
|
// }
|
|
1358
1358
|
fieldDeclaration() {
|
|
1359
|
-
const e = {}, n = () => this.nodeFactory.create(
|
|
1359
|
+
const e = {}, n = () => this.nodeFactory.create(A, e);
|
|
1360
1360
|
try {
|
|
1361
1361
|
this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
|
|
1362
1362
|
} catch (s) {
|
|
@@ -1369,11 +1369,11 @@ class ln {
|
|
|
1369
1369
|
}
|
|
1370
1370
|
try {
|
|
1371
1371
|
const s = this.expression();
|
|
1372
|
-
s instanceof
|
|
1372
|
+
s instanceof A ? this.errors.push(new u(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1373
1373
|
} catch (s) {
|
|
1374
1374
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1375
1375
|
}
|
|
1376
|
-
return this.nodeFactory.create(
|
|
1376
|
+
return this.nodeFactory.create(A, e);
|
|
1377
1377
|
}
|
|
1378
1378
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1379
1379
|
expression() {
|
|
@@ -1421,12 +1421,12 @@ class ln {
|
|
|
1421
1421
|
at(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1422
1422
|
break;
|
|
1423
1423
|
try {
|
|
1424
|
-
n = this.nodeFactory.create(
|
|
1424
|
+
n = this.nodeFactory.create(J, {
|
|
1425
1425
|
callee: n,
|
|
1426
1426
|
argumentList: this.tupleExpression()
|
|
1427
1427
|
});
|
|
1428
1428
|
} catch (r) {
|
|
1429
|
-
throw r instanceof d ? (n = this.nodeFactory.create(
|
|
1429
|
+
throw r instanceof d ? (n = this.nodeFactory.create(J, {
|
|
1430
1430
|
callee: n,
|
|
1431
1431
|
argumentList: r.partialNode
|
|
1432
1432
|
}), new d(r.token, n, r.handlerContext)) : r;
|
|
@@ -1435,12 +1435,12 @@ class ln {
|
|
|
1435
1435
|
if (Ve(this.previous()))
|
|
1436
1436
|
break;
|
|
1437
1437
|
try {
|
|
1438
|
-
n = this.nodeFactory.create(
|
|
1438
|
+
n = this.nodeFactory.create(ce, {
|
|
1439
1439
|
expression: n,
|
|
1440
1440
|
indexer: this.listExpression()
|
|
1441
1441
|
});
|
|
1442
1442
|
} catch (i) {
|
|
1443
|
-
throw i instanceof d ? (n = this.nodeFactory.create(
|
|
1443
|
+
throw i instanceof d ? (n = this.nodeFactory.create(ce, {
|
|
1444
1444
|
expression: n,
|
|
1445
1445
|
indexer: i.partialNode
|
|
1446
1446
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
@@ -1450,7 +1450,7 @@ class ln {
|
|
|
1450
1450
|
if (r.left !== null) {
|
|
1451
1451
|
if (r.left <= e)
|
|
1452
1452
|
break;
|
|
1453
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1453
|
+
this.advance(), n = this.nodeFactory.create(De, {
|
|
1454
1454
|
expression: n,
|
|
1455
1455
|
op: i
|
|
1456
1456
|
});
|
|
@@ -1460,13 +1460,13 @@ class ln {
|
|
|
1460
1460
|
break;
|
|
1461
1461
|
this.advance();
|
|
1462
1462
|
try {
|
|
1463
|
-
n = this.nodeFactory.create(
|
|
1463
|
+
n = this.nodeFactory.create(H, {
|
|
1464
1464
|
leftExpression: n,
|
|
1465
1465
|
op: i,
|
|
1466
1466
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1467
1467
|
});
|
|
1468
1468
|
} catch (l) {
|
|
1469
|
-
throw l instanceof d ? (n = this.nodeFactory.create(
|
|
1469
|
+
throw l instanceof d ? (n = this.nodeFactory.create(H, {
|
|
1470
1470
|
leftExpression: n,
|
|
1471
1471
|
op: i,
|
|
1472
1472
|
rightExpression: l.partialNode
|
|
@@ -1491,7 +1491,7 @@ class ln {
|
|
|
1491
1491
|
`Unexpected '${n.op.value}' in an expression`
|
|
1492
1492
|
), new d(
|
|
1493
1493
|
n.op,
|
|
1494
|
-
this.nodeFactory.create(
|
|
1494
|
+
this.nodeFactory.create(ye, { pre: n.op }),
|
|
1495
1495
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1496
1496
|
);
|
|
1497
1497
|
this.advance();
|
|
@@ -1500,15 +1500,15 @@ class ln {
|
|
|
1500
1500
|
} catch (i) {
|
|
1501
1501
|
throw i instanceof d ? (n.expression = i.partialNode, new d(
|
|
1502
1502
|
i.token,
|
|
1503
|
-
this.nodeFactory.create(
|
|
1503
|
+
this.nodeFactory.create(q, n),
|
|
1504
1504
|
i.handlerContext
|
|
1505
1505
|
)) : i;
|
|
1506
1506
|
}
|
|
1507
|
-
e = this.nodeFactory.create(
|
|
1508
|
-
} else if (e = this.extractOperand(), e instanceof
|
|
1507
|
+
e = this.nodeFactory.create(q, n);
|
|
1508
|
+
} else if (e = this.extractOperand(), e instanceof ye)
|
|
1509
1509
|
throw new d(
|
|
1510
1510
|
this.peek(),
|
|
1511
|
-
this.nodeFactory.create(
|
|
1511
|
+
this.nodeFactory.create(ye, { pre: this.peek() }),
|
|
1512
1512
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1513
1513
|
);
|
|
1514
1514
|
return e;
|
|
@@ -1532,7 +1532,7 @@ class ln {
|
|
|
1532
1532
|
this.peek(),
|
|
1533
1533
|
o.INVALID_OPERAND,
|
|
1534
1534
|
`Invalid start of operand "${this.peek().value}"`
|
|
1535
|
-
), this.nodeFactory.create(
|
|
1535
|
+
), this.nodeFactory.create(ye, { pre: this.previous() }));
|
|
1536
1536
|
}
|
|
1537
1537
|
/* Parsing FunctionExpression */
|
|
1538
1538
|
functionExpression() {
|
|
@@ -1542,11 +1542,11 @@ class ln {
|
|
|
1542
1542
|
} catch (n) {
|
|
1543
1543
|
throw n instanceof d ? (e.value = n.partialNode, new d(
|
|
1544
1544
|
n.token,
|
|
1545
|
-
this.nodeFactory.create(
|
|
1545
|
+
this.nodeFactory.create(te, e),
|
|
1546
1546
|
n.handlerContext
|
|
1547
1547
|
)) : n;
|
|
1548
1548
|
}
|
|
1549
|
-
return this.nodeFactory.create(
|
|
1549
|
+
return this.nodeFactory.create(te, e);
|
|
1550
1550
|
}
|
|
1551
1551
|
canBeField() {
|
|
1552
1552
|
return this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.COLON;
|
|
@@ -1559,16 +1559,16 @@ class ln {
|
|
|
1559
1559
|
c.NUMERIC_LITERAL
|
|
1560
1560
|
))
|
|
1561
1561
|
return this.nodeFactory.create(D, {
|
|
1562
|
-
expression: this.nodeFactory.create(
|
|
1562
|
+
expression: this.nodeFactory.create(me, { literal: this.previous() })
|
|
1563
1563
|
});
|
|
1564
1564
|
if (this.match(c.QUOTED_STRING, c.IDENTIFIER))
|
|
1565
1565
|
return this.nodeFactory.create(D, {
|
|
1566
|
-
expression: this.nodeFactory.create(
|
|
1566
|
+
expression: this.nodeFactory.create($, { variable: this.previous() })
|
|
1567
1567
|
});
|
|
1568
1568
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1569
1569
|
this.peek(),
|
|
1570
1570
|
this.nodeFactory.create(D, {
|
|
1571
|
-
expression: this.nodeFactory.create(
|
|
1571
|
+
expression: this.nodeFactory.create($, {})
|
|
1572
1572
|
}),
|
|
1573
1573
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1574
1574
|
);
|
|
@@ -1581,7 +1581,7 @@ class ln {
|
|
|
1581
1581
|
n,
|
|
1582
1582
|
o.EMPTY_ATTRIBUTE_NAME,
|
|
1583
1583
|
"Expect a non-empty attribute name"
|
|
1584
|
-
), e.name = this.nodeFactory.create(
|
|
1584
|
+
), e.name = this.nodeFactory.create(C, { identifiers: [] });
|
|
1585
1585
|
} else
|
|
1586
1586
|
try {
|
|
1587
1587
|
e.name = this.attributeName();
|
|
@@ -1591,12 +1591,12 @@ class ln {
|
|
|
1591
1591
|
if (e.name = n.partialNode, !this.canHandle(n))
|
|
1592
1592
|
throw new d(
|
|
1593
1593
|
n.token,
|
|
1594
|
-
this.nodeFactory.create(
|
|
1594
|
+
this.nodeFactory.create(se, e),
|
|
1595
1595
|
n.handlerContext
|
|
1596
1596
|
);
|
|
1597
1597
|
this.synchronizeAttributeName();
|
|
1598
1598
|
}
|
|
1599
|
-
return this.match(c.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(
|
|
1599
|
+
return this.match(c.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
|
|
1600
1600
|
}
|
|
1601
1601
|
attributeValue() {
|
|
1602
1602
|
let e;
|
|
@@ -1619,11 +1619,11 @@ class ln {
|
|
|
1619
1619
|
} catch (n) {
|
|
1620
1620
|
throw n instanceof d ? new d(
|
|
1621
1621
|
n.token,
|
|
1622
|
-
this.nodeFactory.create(
|
|
1622
|
+
this.nodeFactory.create(C, { identifiers: e }),
|
|
1623
1623
|
n.handlerContext
|
|
1624
1624
|
) : n;
|
|
1625
1625
|
}
|
|
1626
|
-
return this.nodeFactory.create(
|
|
1626
|
+
return this.nodeFactory.create(C, { identifiers: e });
|
|
1627
1627
|
}
|
|
1628
1628
|
logError(e, n, s) {
|
|
1629
1629
|
this.errors.push(new u(n, s, e));
|
|
@@ -1666,7 +1666,7 @@ function ct(t) {
|
|
|
1666
1666
|
return pn[t.value] || { left: null, right: null };
|
|
1667
1667
|
}
|
|
1668
1668
|
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 || {});
|
|
1669
|
-
function
|
|
1669
|
+
function _e(t) {
|
|
1670
1670
|
var n;
|
|
1671
1671
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1672
1672
|
switch (e) {
|
|
@@ -1679,36 +1679,36 @@ function ge(t) {
|
|
|
1679
1679
|
case b.TableGroup:
|
|
1680
1680
|
return new O(e);
|
|
1681
1681
|
default:
|
|
1682
|
-
return new
|
|
1682
|
+
return new v();
|
|
1683
1683
|
}
|
|
1684
1684
|
}
|
|
1685
|
-
function
|
|
1685
|
+
function he(t) {
|
|
1686
1686
|
if (!He(t))
|
|
1687
1687
|
return new O([t]);
|
|
1688
|
-
const e =
|
|
1689
|
-
return e ? (e.push(t.rightExpression), new O(e)) : new
|
|
1688
|
+
const e = he(t.leftExpression).unwrap_or(void 0);
|
|
1689
|
+
return e ? (e.push(t.rightExpression), new O(e)) : new v();
|
|
1690
1690
|
}
|
|
1691
|
-
function
|
|
1691
|
+
function j(t) {
|
|
1692
1692
|
if (t === void 0)
|
|
1693
|
-
return new
|
|
1694
|
-
const e =
|
|
1693
|
+
return new v();
|
|
1694
|
+
const e = he(t).unwrap_or(void 0);
|
|
1695
1695
|
if (!e)
|
|
1696
|
-
return new
|
|
1696
|
+
return new v();
|
|
1697
1697
|
const n = [];
|
|
1698
1698
|
for (const s of e) {
|
|
1699
1699
|
const i = G(s).unwrap_or(void 0);
|
|
1700
1700
|
if (!i)
|
|
1701
|
-
return new
|
|
1701
|
+
return new v();
|
|
1702
1702
|
n.push(i);
|
|
1703
1703
|
}
|
|
1704
1704
|
return new O(n);
|
|
1705
1705
|
}
|
|
1706
|
-
function
|
|
1706
|
+
function Le(t) {
|
|
1707
1707
|
if (t === void 0)
|
|
1708
|
-
return new
|
|
1709
|
-
const e =
|
|
1708
|
+
return new v();
|
|
1709
|
+
const e = he(t).unwrap_or(void 0);
|
|
1710
1710
|
if (!e || e.length === 0)
|
|
1711
|
-
return new
|
|
1711
|
+
return new v();
|
|
1712
1712
|
const n = [];
|
|
1713
1713
|
let s;
|
|
1714
1714
|
if (!M(I.last(e))) {
|
|
@@ -1718,12 +1718,12 @@ function Ie(t) {
|
|
|
1718
1718
|
(r) => V(r).unwrap()
|
|
1719
1719
|
);
|
|
1720
1720
|
else
|
|
1721
|
-
return new
|
|
1721
|
+
return new v();
|
|
1722
1722
|
}
|
|
1723
1723
|
for (const i of e) {
|
|
1724
1724
|
const r = G(i).unwrap_or(void 0);
|
|
1725
1725
|
if (!r)
|
|
1726
|
-
return new
|
|
1726
|
+
return new v();
|
|
1727
1727
|
n.push(r);
|
|
1728
1728
|
}
|
|
1729
1729
|
return new O({
|
|
@@ -1732,40 +1732,40 @@ function Ie(t) {
|
|
|
1732
1732
|
});
|
|
1733
1733
|
}
|
|
1734
1734
|
function G(t) {
|
|
1735
|
-
return M(t) ? new O(t.expression.variable.value) : new
|
|
1735
|
+
return M(t) ? new O(t.expression.variable.value) : new v();
|
|
1736
1736
|
}
|
|
1737
1737
|
function Ge(t) {
|
|
1738
1738
|
if (ut(t))
|
|
1739
|
-
return t instanceof
|
|
1740
|
-
if (t instanceof
|
|
1739
|
+
return t instanceof te ? new O({ functional: [t], nonFunctional: [] }) : new O({ functional: [], nonFunctional: [t] });
|
|
1740
|
+
if (t instanceof Z && t.elementList.every(ut)) {
|
|
1741
1741
|
const e = t.elementList.filter(
|
|
1742
|
-
(s) => s instanceof
|
|
1742
|
+
(s) => s instanceof te
|
|
1743
1743
|
), n = t.elementList.filter(M);
|
|
1744
1744
|
return new O({ functional: e, nonFunctional: n });
|
|
1745
1745
|
}
|
|
1746
|
-
return new
|
|
1746
|
+
return new v();
|
|
1747
1747
|
}
|
|
1748
1748
|
function V(t) {
|
|
1749
1749
|
var n;
|
|
1750
1750
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1751
|
-
return e === void 0 ? new
|
|
1751
|
+
return e === void 0 ? new v() : new O(e);
|
|
1752
1752
|
}
|
|
1753
|
-
function
|
|
1754
|
-
return
|
|
1753
|
+
function z(t) {
|
|
1754
|
+
return W(t) ? t.expression instanceof $ ? new O(t.expression.variable.value) : new O(t.expression.literal.value) : new v();
|
|
1755
1755
|
}
|
|
1756
1756
|
function dn(t) {
|
|
1757
1757
|
var e;
|
|
1758
|
-
return !(t instanceof
|
|
1758
|
+
return !(t instanceof H) || !wt((e = t.op) == null ? void 0 : e.value) ? !1 : Le(t.leftExpression).and_then(() => Le(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1759
1759
|
}
|
|
1760
1760
|
function En(t) {
|
|
1761
|
-
const e =
|
|
1761
|
+
const e = Le(t.leftExpression), n = Le(t.rightExpression);
|
|
1762
1762
|
if (!e.isOk() || !n.isOk())
|
|
1763
1763
|
return !1;
|
|
1764
1764
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1765
1765
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1766
1766
|
}
|
|
1767
1767
|
function ut(t) {
|
|
1768
|
-
return t instanceof D && t.expression instanceof
|
|
1768
|
+
return t instanceof D && t.expression instanceof $ || t instanceof te;
|
|
1769
1769
|
}
|
|
1770
1770
|
function Nn(t, e) {
|
|
1771
1771
|
var i, r, a, l;
|
|
@@ -1774,9 +1774,9 @@ function Nn(t, e) {
|
|
|
1774
1774
|
for (; n; ) {
|
|
1775
1775
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1776
1776
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1777
|
-
if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof
|
|
1777
|
+
if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof X && s)
|
|
1778
1778
|
return n.symbol;
|
|
1779
|
-
if (n instanceof
|
|
1779
|
+
if (n instanceof X)
|
|
1780
1780
|
return;
|
|
1781
1781
|
n = n.parent;
|
|
1782
1782
|
}
|
|
@@ -1789,7 +1789,7 @@ class mn {
|
|
|
1789
1789
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1790
1790
|
}
|
|
1791
1791
|
validateContext() {
|
|
1792
|
-
return this.declarationNode.parent instanceof
|
|
1792
|
+
return this.declarationNode.parent instanceof X || _e(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new u(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1793
1793
|
}
|
|
1794
1794
|
validateName(e) {
|
|
1795
1795
|
return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1803,13 +1803,13 @@ class mn {
|
|
|
1803
1803
|
validateBody(e) {
|
|
1804
1804
|
if (!e)
|
|
1805
1805
|
return [];
|
|
1806
|
-
if (e instanceof
|
|
1806
|
+
if (e instanceof ne)
|
|
1807
1807
|
return [new u(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1808
1808
|
const n = [];
|
|
1809
|
-
return
|
|
1809
|
+
return W(e.callee) || n.push(new u(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 u(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1810
1810
|
}
|
|
1811
1811
|
}
|
|
1812
|
-
class
|
|
1812
|
+
class Ae {
|
|
1813
1813
|
constructor() {
|
|
1814
1814
|
this.table = /* @__PURE__ */ new Map();
|
|
1815
1815
|
}
|
|
@@ -1834,7 +1834,7 @@ class Tn {
|
|
|
1834
1834
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
1835
1835
|
}
|
|
1836
1836
|
validateContext() {
|
|
1837
|
-
return this.declarationNode.parent instanceof
|
|
1837
|
+
return this.declarationNode.parent instanceof A ? [new u(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1838
1838
|
}
|
|
1839
1839
|
validateName(e) {
|
|
1840
1840
|
return e ? Je(e) ? [] : [new u(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new u(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
@@ -1844,8 +1844,8 @@ class Tn {
|
|
|
1844
1844
|
}
|
|
1845
1845
|
registerElement() {
|
|
1846
1846
|
const e = [];
|
|
1847
|
-
this.declarationNode.symbol = this.symbolFactory.create(qt, { declaration: this.declarationNode, symbolTable: new
|
|
1848
|
-
const { name: n } = this.declarationNode, s =
|
|
1847
|
+
this.declarationNode.symbol = this.symbolFactory.create(qt, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
1848
|
+
const { name: n } = this.declarationNode, s = j(n);
|
|
1849
1849
|
if (s.isOk()) {
|
|
1850
1850
|
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = je(r);
|
|
1851
1851
|
a.has(l) && e.push(new u(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
|
|
@@ -1872,13 +1872,13 @@ class Tn {
|
|
|
1872
1872
|
});
|
|
1873
1873
|
}
|
|
1874
1874
|
validateFieldSettings(e) {
|
|
1875
|
-
const n =
|
|
1875
|
+
const n = Q(e), s = n.getErrors(), i = n.getValue();
|
|
1876
1876
|
for (const r in i) {
|
|
1877
1877
|
const a = i[r];
|
|
1878
1878
|
switch (r) {
|
|
1879
1879
|
case "note":
|
|
1880
1880
|
a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
1881
|
-
|
|
1881
|
+
W(l.value) || s.push(new u(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
|
|
1882
1882
|
});
|
|
1883
1883
|
break;
|
|
1884
1884
|
default:
|
|
@@ -1891,7 +1891,7 @@ class Tn {
|
|
|
1891
1891
|
return e.flatMap((n) => {
|
|
1892
1892
|
if (n.parent = this.declarationNode, !n.type)
|
|
1893
1893
|
return [];
|
|
1894
|
-
const s =
|
|
1894
|
+
const s = re(n);
|
|
1895
1895
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1896
1896
|
});
|
|
1897
1897
|
}
|
|
@@ -1920,7 +1920,7 @@ class bn {
|
|
|
1920
1920
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1921
1921
|
}
|
|
1922
1922
|
validateContext() {
|
|
1923
|
-
return this.declarationNode.parent instanceof
|
|
1923
|
+
return this.declarationNode.parent instanceof X || _e(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new u(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1924
1924
|
}
|
|
1925
1925
|
validateName(e) {
|
|
1926
1926
|
return e ? [new u(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
@@ -1945,27 +1945,27 @@ class bn {
|
|
|
1945
1945
|
return [];
|
|
1946
1946
|
const s = [], i = [n.callee, ...n.args];
|
|
1947
1947
|
return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1948
|
-
for (; r instanceof
|
|
1948
|
+
for (; r instanceof J; )
|
|
1949
1949
|
r.argumentList && !Ge(r.argumentList).isOk() && s.push(new u(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;
|
|
1950
1950
|
Ge(r).isOk() || s.push(new u(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
1951
1951
|
}), s;
|
|
1952
1952
|
});
|
|
1953
1953
|
}
|
|
1954
1954
|
validateFieldSetting(e) {
|
|
1955
|
-
const n =
|
|
1955
|
+
const n = Q(e), s = n.getErrors(), i = n.getValue();
|
|
1956
1956
|
for (const r in i) {
|
|
1957
1957
|
const a = i[r];
|
|
1958
1958
|
switch (r) {
|
|
1959
1959
|
case "note":
|
|
1960
1960
|
case "name":
|
|
1961
1961
|
a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1962
|
-
|
|
1962
|
+
W(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
|
|
1963
1963
|
});
|
|
1964
1964
|
break;
|
|
1965
1965
|
case "unique":
|
|
1966
1966
|
case "pk":
|
|
1967
1967
|
a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1968
|
-
|
|
1968
|
+
le(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
|
|
1969
1969
|
});
|
|
1970
1970
|
break;
|
|
1971
1971
|
case "type":
|
|
@@ -1983,7 +1983,7 @@ class bn {
|
|
|
1983
1983
|
return e.flatMap((n) => {
|
|
1984
1984
|
if (n.parent = this.declarationNode, !n.type)
|
|
1985
1985
|
return [];
|
|
1986
|
-
const s =
|
|
1986
|
+
const s = re(n);
|
|
1987
1987
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1988
1988
|
});
|
|
1989
1989
|
}
|
|
@@ -1996,7 +1996,7 @@ class In {
|
|
|
1996
1996
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1997
1997
|
}
|
|
1998
1998
|
validateContext() {
|
|
1999
|
-
return this.declarationNode.parent instanceof
|
|
1999
|
+
return this.declarationNode.parent instanceof X || ![b.Table, b.Project].includes(_e(this.declarationNode.parent).unwrap_or(void 0)) ? [new u(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project", this.declarationNode)] : [];
|
|
2000
2000
|
}
|
|
2001
2001
|
validateName(e) {
|
|
2002
2002
|
return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
@@ -2017,13 +2017,13 @@ class In {
|
|
|
2017
2017
|
}
|
|
2018
2018
|
validateFields(e) {
|
|
2019
2019
|
const n = [];
|
|
2020
|
-
return e.length === 0 ? [new u(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new u(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))),
|
|
2020
|
+
return e.length === 0 ? [new u(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new u(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), W(e[0].callee) || n.push(new u(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 u(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2021
2021
|
}
|
|
2022
2022
|
validateSubElements(e) {
|
|
2023
2023
|
return e.flatMap((n) => {
|
|
2024
2024
|
if (n.parent = this.declarationNode, !n.type)
|
|
2025
2025
|
return [];
|
|
2026
|
-
const s =
|
|
2026
|
+
const s = re(n);
|
|
2027
2027
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2028
2028
|
});
|
|
2029
2029
|
}
|
|
@@ -2036,7 +2036,7 @@ class Ln {
|
|
|
2036
2036
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2037
2037
|
}
|
|
2038
2038
|
validateContext() {
|
|
2039
|
-
return this.declarationNode.parent instanceof
|
|
2039
|
+
return this.declarationNode.parent instanceof A ? [new u(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2040
2040
|
}
|
|
2041
2041
|
validateName(e) {
|
|
2042
2042
|
return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
@@ -2062,7 +2062,7 @@ class Ln {
|
|
|
2062
2062
|
return e.flatMap((n) => {
|
|
2063
2063
|
if (n.parent = this.declarationNode, !n.type)
|
|
2064
2064
|
return [];
|
|
2065
|
-
const s =
|
|
2065
|
+
const s = re(n);
|
|
2066
2066
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2067
2067
|
});
|
|
2068
2068
|
}
|
|
@@ -2075,7 +2075,7 @@ class gn {
|
|
|
2075
2075
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2076
2076
|
}
|
|
2077
2077
|
validateContext() {
|
|
2078
|
-
return this.declarationNode.parent instanceof
|
|
2078
|
+
return this.declarationNode.parent instanceof X ? [] : [new u(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2079
2079
|
}
|
|
2080
2080
|
validateName(e) {
|
|
2081
2081
|
return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
@@ -2105,7 +2105,7 @@ class gn {
|
|
|
2105
2105
|
}), n;
|
|
2106
2106
|
}
|
|
2107
2107
|
validateFieldSettings(e) {
|
|
2108
|
-
const n =
|
|
2108
|
+
const n = Q(e), s = n.getErrors(), i = n.getValue();
|
|
2109
2109
|
for (const r in i) {
|
|
2110
2110
|
const a = i[r];
|
|
2111
2111
|
switch (r) {
|
|
@@ -2125,16 +2125,16 @@ class gn {
|
|
|
2125
2125
|
return e.flatMap((n) => {
|
|
2126
2126
|
if (n.parent = this.declarationNode, !n.type)
|
|
2127
2127
|
return [];
|
|
2128
|
-
const s =
|
|
2128
|
+
const s = re(n);
|
|
2129
2129
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2130
2130
|
});
|
|
2131
2131
|
}
|
|
2132
2132
|
}
|
|
2133
2133
|
function _n(t) {
|
|
2134
|
-
if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof
|
|
2134
|
+
if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof C))
|
|
2135
2135
|
return !1;
|
|
2136
2136
|
let e;
|
|
2137
|
-
if (t instanceof
|
|
2137
|
+
if (t instanceof C ? e = Ne(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2138
2138
|
switch (e.toLowerCase()) {
|
|
2139
2139
|
case "cascade":
|
|
2140
2140
|
case "no action":
|
|
@@ -2155,16 +2155,16 @@ class An {
|
|
|
2155
2155
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
2156
2156
|
}
|
|
2157
2157
|
validateContext() {
|
|
2158
|
-
return this.declarationNode.parent instanceof
|
|
2158
|
+
return this.declarationNode.parent instanceof A ? [new u(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2159
2159
|
}
|
|
2160
2160
|
validateName(e) {
|
|
2161
|
-
return e ? e instanceof
|
|
2161
|
+
return e ? e instanceof ce ? [new u(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new u(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new u(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2162
2162
|
}
|
|
2163
2163
|
validateAlias(e) {
|
|
2164
2164
|
return e ? kn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2165
2165
|
}
|
|
2166
2166
|
validateSettingList(e) {
|
|
2167
|
-
const n =
|
|
2167
|
+
const n = Q(e), s = n.getErrors(), i = n.getValue();
|
|
2168
2168
|
for (const r in i) {
|
|
2169
2169
|
const a = i[r];
|
|
2170
2170
|
switch (r) {
|
|
@@ -2175,7 +2175,7 @@ class An {
|
|
|
2175
2175
|
break;
|
|
2176
2176
|
case "note":
|
|
2177
2177
|
a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
2178
|
-
|
|
2178
|
+
W(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
|
|
2179
2179
|
});
|
|
2180
2180
|
break;
|
|
2181
2181
|
default:
|
|
@@ -2186,14 +2186,14 @@ class An {
|
|
|
2186
2186
|
}
|
|
2187
2187
|
registerElement() {
|
|
2188
2188
|
const e = [];
|
|
2189
|
-
this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new
|
|
2190
|
-
const { name: n, alias: s } = this.declarationNode, i =
|
|
2189
|
+
this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
2190
|
+
const { name: n, alias: s } = this.declarationNode, i = j(n);
|
|
2191
2191
|
if (i.isOk()) {
|
|
2192
|
-
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p =
|
|
2192
|
+
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
|
|
2193
2193
|
l.has(p) && e.push(new u(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
|
|
2194
2194
|
}
|
|
2195
2195
|
if (s && Pe(s) && !wn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2196
|
-
const r = V(s).unwrap(), a =
|
|
2196
|
+
const r = V(s).unwrap(), a = xe(r);
|
|
2197
2197
|
this.publicSymbolTable.has(a) && e.push(new u(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2198
2198
|
}
|
|
2199
2199
|
return e;
|
|
@@ -2234,13 +2234,13 @@ class An {
|
|
|
2234
2234
|
}
|
|
2235
2235
|
// This is needed to support legacy inline settings
|
|
2236
2236
|
validateFieldSetting(e) {
|
|
2237
|
-
if (!e.slice(0, -1).every(
|
|
2237
|
+
if (!e.slice(0, -1).every(Ee) || !e.slice(-1).every((p) => Ee(p) || p instanceof P))
|
|
2238
2238
|
return [...e.map((p) => new u(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2239
2239
|
if (e.length === 0)
|
|
2240
2240
|
return [];
|
|
2241
2241
|
let n;
|
|
2242
2242
|
I.last(e) instanceof P && (n = e.pop());
|
|
2243
|
-
const s =
|
|
2243
|
+
const s = Q(n), i = s.getErrors(), r = s.getValue();
|
|
2244
2244
|
for (const p of e) {
|
|
2245
2245
|
const h = V(p).unwrap_or("").toLowerCase();
|
|
2246
2246
|
if (h !== "pk" && h !== "unique") {
|
|
@@ -2256,7 +2256,7 @@ class An {
|
|
|
2256
2256
|
switch (p) {
|
|
2257
2257
|
case "note":
|
|
2258
2258
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2259
|
-
|
|
2259
|
+
W(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2260
2260
|
});
|
|
2261
2261
|
break;
|
|
2262
2262
|
case "ref":
|
|
@@ -2266,34 +2266,34 @@ class An {
|
|
|
2266
2266
|
break;
|
|
2267
2267
|
case "primary key":
|
|
2268
2268
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
|
|
2269
|
-
|
|
2269
|
+
le(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
|
|
2270
2270
|
});
|
|
2271
2271
|
break;
|
|
2272
2272
|
case "pk":
|
|
2273
2273
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
|
|
2274
|
-
f instanceof
|
|
2274
|
+
f instanceof se && !le(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
|
|
2275
2275
|
});
|
|
2276
2276
|
break;
|
|
2277
2277
|
case "not null":
|
|
2278
2278
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
|
|
2279
2279
|
const T = r.null || [];
|
|
2280
2280
|
h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new u(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
|
|
2281
|
-
|
|
2281
|
+
le(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
|
|
2282
2282
|
});
|
|
2283
2283
|
break;
|
|
2284
2284
|
case "null":
|
|
2285
2285
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
|
|
2286
|
-
|
|
2286
|
+
le(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
|
|
2287
2287
|
});
|
|
2288
2288
|
break;
|
|
2289
2289
|
case "unique":
|
|
2290
2290
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
|
|
2291
|
-
f instanceof
|
|
2291
|
+
f instanceof se && !le(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
|
|
2292
2292
|
});
|
|
2293
2293
|
break;
|
|
2294
2294
|
case "increment":
|
|
2295
2295
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
|
|
2296
|
-
f instanceof
|
|
2296
|
+
f instanceof se && !le(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
|
|
2297
2297
|
});
|
|
2298
2298
|
break;
|
|
2299
2299
|
case "default":
|
|
@@ -2311,7 +2311,7 @@ class An {
|
|
|
2311
2311
|
const n = e.flatMap((i) => {
|
|
2312
2312
|
if (i.parent = this.declarationNode, !i.type)
|
|
2313
2313
|
return [];
|
|
2314
|
-
const r =
|
|
2314
|
+
const r = re(i);
|
|
2315
2315
|
return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2316
2316
|
}), s = e.filter((i) => {
|
|
2317
2317
|
var r;
|
|
@@ -2321,19 +2321,19 @@ class An {
|
|
|
2321
2321
|
}
|
|
2322
2322
|
}
|
|
2323
2323
|
function vn(t) {
|
|
2324
|
-
if (!(t instanceof
|
|
2324
|
+
if (!(t instanceof J || He(t) || t instanceof D || t instanceof ce))
|
|
2325
2325
|
return !1;
|
|
2326
|
-
if (t instanceof
|
|
2327
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2326
|
+
if (t instanceof J) {
|
|
2327
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || W(n) || Ee(n)))
|
|
2328
2328
|
return !1;
|
|
2329
2329
|
t = t.callee;
|
|
2330
2330
|
}
|
|
2331
|
-
for (; t instanceof
|
|
2332
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value &&
|
|
2331
|
+
for (; t instanceof ce; ) {
|
|
2332
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ue(n.name)))
|
|
2333
2333
|
return !1;
|
|
2334
2334
|
t = t.array;
|
|
2335
2335
|
}
|
|
2336
|
-
const e =
|
|
2336
|
+
const e = j(t).unwrap_or(void 0);
|
|
2337
2337
|
return e !== void 0 && e.length > 0;
|
|
2338
2338
|
}
|
|
2339
2339
|
function wn(t, e) {
|
|
@@ -2347,7 +2347,7 @@ class yn {
|
|
|
2347
2347
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
2348
2348
|
}
|
|
2349
2349
|
validateContext() {
|
|
2350
|
-
return this.declarationNode.parent instanceof
|
|
2350
|
+
return this.declarationNode.parent instanceof A ? [new u(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
2351
2351
|
}
|
|
2352
2352
|
validateName(e) {
|
|
2353
2353
|
return e ? Je(e) ? [] : [new u(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new u(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
@@ -2357,8 +2357,8 @@ class yn {
|
|
|
2357
2357
|
}
|
|
2358
2358
|
registerElement() {
|
|
2359
2359
|
const { name: e } = this.declarationNode;
|
|
2360
|
-
this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new
|
|
2361
|
-
const n =
|
|
2360
|
+
this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
2361
|
+
const n = j(e);
|
|
2362
2362
|
if (n.isOk()) {
|
|
2363
2363
|
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
|
|
2364
2364
|
if (r.has(a))
|
|
@@ -2381,14 +2381,14 @@ class yn {
|
|
|
2381
2381
|
validateFields(e) {
|
|
2382
2382
|
return e.flatMap((n) => {
|
|
2383
2383
|
const s = [];
|
|
2384
|
-
return n.callee && !
|
|
2384
|
+
return n.callee && !j(n.callee).isOk() && s.push(new u(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new u(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2385
2385
|
});
|
|
2386
2386
|
}
|
|
2387
2387
|
validateSubElements(e) {
|
|
2388
2388
|
return e.flatMap((n) => {
|
|
2389
2389
|
if (n.parent = this.declarationNode, !n.type)
|
|
2390
2390
|
return [];
|
|
2391
|
-
const s =
|
|
2391
|
+
const s = re(n);
|
|
2392
2392
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2393
2393
|
});
|
|
2394
2394
|
}
|
|
@@ -2410,7 +2410,7 @@ class yn {
|
|
|
2410
2410
|
}
|
|
2411
2411
|
}
|
|
2412
2412
|
const vt = ["-", "+"];
|
|
2413
|
-
function
|
|
2413
|
+
function re(t) {
|
|
2414
2414
|
switch (t.type.value.toLowerCase()) {
|
|
2415
2415
|
case b.Enum:
|
|
2416
2416
|
return Tn;
|
|
@@ -2431,13 +2431,13 @@ function ie(t) {
|
|
|
2431
2431
|
}
|
|
2432
2432
|
}
|
|
2433
2433
|
function Je(t) {
|
|
2434
|
-
return !!
|
|
2434
|
+
return !!j(t).unwrap_or(!1);
|
|
2435
2435
|
}
|
|
2436
2436
|
function kn(t) {
|
|
2437
2437
|
return Pe(t);
|
|
2438
2438
|
}
|
|
2439
2439
|
function Pe(t) {
|
|
2440
|
-
return t instanceof D && t.expression instanceof
|
|
2440
|
+
return t instanceof D && t.expression instanceof $;
|
|
2441
2441
|
}
|
|
2442
2442
|
function Ze(t, e, n) {
|
|
2443
2443
|
var i;
|
|
@@ -2450,7 +2450,7 @@ function Ze(t, e, n) {
|
|
|
2450
2450
|
if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
|
|
2451
2451
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2452
2452
|
} else {
|
|
2453
|
-
a = new
|
|
2453
|
+
a = new Ae();
|
|
2454
2454
|
const p = n.create(gt, { symbolTable: a });
|
|
2455
2455
|
s.set(l, p);
|
|
2456
2456
|
}
|
|
@@ -2463,7 +2463,7 @@ function wt(t) {
|
|
|
2463
2463
|
}
|
|
2464
2464
|
function xn(t) {
|
|
2465
2465
|
var n;
|
|
2466
|
-
if (!(t instanceof D) || !(t.expression instanceof
|
|
2466
|
+
if (!(t instanceof D) || !(t.expression instanceof me) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== c.COLOR_LITERAL)
|
|
2467
2467
|
return !1;
|
|
2468
2468
|
const e = t.expression.literal.value;
|
|
2469
2469
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
@@ -2473,28 +2473,28 @@ function xn(t) {
|
|
|
2473
2473
|
return !1;
|
|
2474
2474
|
return !0;
|
|
2475
2475
|
}
|
|
2476
|
-
function
|
|
2476
|
+
function le(t) {
|
|
2477
2477
|
return t === void 0;
|
|
2478
2478
|
}
|
|
2479
2479
|
function On(t) {
|
|
2480
2480
|
var e;
|
|
2481
|
-
return !!(
|
|
2481
|
+
return !!(W(t) || ue(t) || Ee(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && vt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression) || t instanceof te);
|
|
2482
2482
|
}
|
|
2483
|
-
function
|
|
2483
|
+
function ue(t) {
|
|
2484
2484
|
var e;
|
|
2485
|
-
return t instanceof D && t.expression instanceof
|
|
2485
|
+
return t instanceof D && t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
|
|
2486
2486
|
}
|
|
2487
2487
|
function Sn(t) {
|
|
2488
2488
|
var n;
|
|
2489
|
-
if (!(t instanceof
|
|
2489
|
+
if (!(t instanceof q) || !wt((n = t.op) == null ? void 0 : n.value))
|
|
2490
2490
|
return !1;
|
|
2491
|
-
const e =
|
|
2491
|
+
const e = j(t.expression).unwrap_or(void 0);
|
|
2492
2492
|
return e !== void 0 && e.length > 0;
|
|
2493
2493
|
}
|
|
2494
2494
|
function yt(t) {
|
|
2495
|
-
return t instanceof
|
|
2495
|
+
return t instanceof Z && t.elementList.every(M);
|
|
2496
2496
|
}
|
|
2497
|
-
function
|
|
2497
|
+
function Q(t) {
|
|
2498
2498
|
var s;
|
|
2499
2499
|
const e = {}, n = [];
|
|
2500
2500
|
if (!t)
|
|
@@ -2506,7 +2506,7 @@ function z(t) {
|
|
|
2506
2506
|
n.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2507
2507
|
continue;
|
|
2508
2508
|
}
|
|
2509
|
-
const r = (s =
|
|
2509
|
+
const r = (s = Ne(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2510
2510
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2511
2511
|
}
|
|
2512
2512
|
return new F(e, n);
|
|
@@ -2514,7 +2514,7 @@ function z(t) {
|
|
|
2514
2514
|
class ht {
|
|
2515
2515
|
constructor(e, n) {
|
|
2516
2516
|
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(gt, {
|
|
2517
|
-
symbolTable: new
|
|
2517
|
+
symbolTable: new Ae()
|
|
2518
2518
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2519
2519
|
}
|
|
2520
2520
|
validate() {
|
|
@@ -2522,18 +2522,18 @@ class ht {
|
|
|
2522
2522
|
this.ast.body.forEach((s) => {
|
|
2523
2523
|
if (s.parent = this.ast, s.type === void 0)
|
|
2524
2524
|
return;
|
|
2525
|
-
const i =
|
|
2525
|
+
const i = re(s), r = new i(
|
|
2526
2526
|
s,
|
|
2527
2527
|
this.publicSchemaSymbol.symbolTable,
|
|
2528
2528
|
this.symbolFactory
|
|
2529
2529
|
);
|
|
2530
2530
|
e.push(...r.validate());
|
|
2531
2531
|
});
|
|
2532
|
-
const n = this.ast.body.filter((s) =>
|
|
2532
|
+
const n = this.ast.body.filter((s) => _e(s).unwrap_or(void 0) === b.Project);
|
|
2533
2533
|
return n.length > 1 && n.forEach((s) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
|
|
2534
2534
|
}
|
|
2535
2535
|
}
|
|
2536
|
-
class
|
|
2536
|
+
class ae {
|
|
2537
2537
|
constructor(e, n) {
|
|
2538
2538
|
this.declarationNode = e, this.errors = n;
|
|
2539
2539
|
}
|
|
@@ -2545,7 +2545,7 @@ class re {
|
|
|
2545
2545
|
for (const s of e.elementList) {
|
|
2546
2546
|
if (s.name instanceof D)
|
|
2547
2547
|
continue;
|
|
2548
|
-
const i =
|
|
2548
|
+
const i = Ne(s.name).unwrap_or(void 0);
|
|
2549
2549
|
if (!i)
|
|
2550
2550
|
continue;
|
|
2551
2551
|
const r = n[i.toLowerCase()];
|
|
@@ -2557,9 +2557,9 @@ class re {
|
|
|
2557
2557
|
if (!e.body)
|
|
2558
2558
|
return;
|
|
2559
2559
|
const { body: n } = e;
|
|
2560
|
-
if (n instanceof
|
|
2560
|
+
if (n instanceof ne)
|
|
2561
2561
|
for (const s of n.body)
|
|
2562
|
-
if (s instanceof
|
|
2562
|
+
if (s instanceof A) {
|
|
2563
2563
|
if (!s.type)
|
|
2564
2564
|
continue;
|
|
2565
2565
|
const i = kt(s);
|
|
@@ -2581,11 +2581,11 @@ class re {
|
|
|
2581
2581
|
var s, i;
|
|
2582
2582
|
if (e)
|
|
2583
2583
|
if (e instanceof D) {
|
|
2584
|
-
if (e.expression instanceof
|
|
2584
|
+
if (e.expression instanceof $ && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2585
2585
|
return;
|
|
2586
2586
|
this.bindFragments([e], n);
|
|
2587
2587
|
} else
|
|
2588
|
-
e instanceof
|
|
2588
|
+
e instanceof H ? He(e) ? this.bindFragments(he(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof Z && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2589
2589
|
}
|
|
2590
2590
|
// Bind the fragments of a member access expression
|
|
2591
2591
|
// which can be a simple expression like v1.User,
|
|
@@ -2637,14 +2637,14 @@ class re {
|
|
|
2637
2637
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
2638
2638
|
const [s, ...i] = e, r = Nn(s.index, this.declarationNode);
|
|
2639
2639
|
if (r === void 0) {
|
|
2640
|
-
const { kind: h, name: T } =
|
|
2640
|
+
const { kind: h, name: T } = ie(s.index).unwrap();
|
|
2641
2641
|
this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
|
|
2642
2642
|
return;
|
|
2643
2643
|
}
|
|
2644
2644
|
r.references.push(s.referrer), s.referrer.referee = r;
|
|
2645
|
-
let a = r.symbolTable, { kind: l, name: p } =
|
|
2645
|
+
let a = r.symbolTable, { kind: l, name: p } = ie(s.index).unwrap();
|
|
2646
2646
|
for (const h of i) {
|
|
2647
|
-
const { kind: T, name: f } =
|
|
2647
|
+
const { kind: T, name: f } = ie(h.index).unwrap(), N = a.get(h.index);
|
|
2648
2648
|
if (!N) {
|
|
2649
2649
|
this.logError(
|
|
2650
2650
|
h.referrer,
|
|
@@ -2662,7 +2662,7 @@ class re {
|
|
|
2662
2662
|
s || this.errors.push(new u(o.BINDING_ERROR, n, e));
|
|
2663
2663
|
}
|
|
2664
2664
|
}
|
|
2665
|
-
class Rn extends
|
|
2665
|
+
class Rn extends ae {
|
|
2666
2666
|
constructor() {
|
|
2667
2667
|
super(...arguments), this.subfield = {
|
|
2668
2668
|
arg: {
|
|
@@ -2672,7 +2672,7 @@ class Rn extends re {
|
|
|
2672
2672
|
}, this.settingList = {};
|
|
2673
2673
|
}
|
|
2674
2674
|
}
|
|
2675
|
-
class Dn extends
|
|
2675
|
+
class Dn extends ae {
|
|
2676
2676
|
constructor() {
|
|
2677
2677
|
super(...arguments), this.subfield = {
|
|
2678
2678
|
arg: {
|
|
@@ -2682,7 +2682,7 @@ class Dn extends re {
|
|
|
2682
2682
|
}, this.settingList = {};
|
|
2683
2683
|
}
|
|
2684
2684
|
}
|
|
2685
|
-
class Pn extends
|
|
2685
|
+
class Pn extends ae {
|
|
2686
2686
|
constructor() {
|
|
2687
2687
|
super(...arguments), this.subfield = {
|
|
2688
2688
|
arg: {
|
|
@@ -2717,7 +2717,7 @@ class Pn extends re {
|
|
|
2717
2717
|
}, this.settingList = {};
|
|
2718
2718
|
}
|
|
2719
2719
|
}
|
|
2720
|
-
class Un extends
|
|
2720
|
+
class Un extends ae {
|
|
2721
2721
|
constructor() {
|
|
2722
2722
|
super(...arguments), this.subfield = {
|
|
2723
2723
|
arg: {
|
|
@@ -2727,7 +2727,7 @@ class Un extends re {
|
|
|
2727
2727
|
}, this.settingList = {};
|
|
2728
2728
|
}
|
|
2729
2729
|
}
|
|
2730
|
-
class Mn extends
|
|
2730
|
+
class Mn extends ae {
|
|
2731
2731
|
constructor() {
|
|
2732
2732
|
super(...arguments), this.subfield = {
|
|
2733
2733
|
arg: {
|
|
@@ -2737,7 +2737,7 @@ class Mn extends re {
|
|
|
2737
2737
|
}, this.settingList = {};
|
|
2738
2738
|
}
|
|
2739
2739
|
}
|
|
2740
|
-
class Fn extends
|
|
2740
|
+
class Fn extends ae {
|
|
2741
2741
|
constructor() {
|
|
2742
2742
|
super(...arguments), this.subfield = {
|
|
2743
2743
|
arg: {
|
|
@@ -2754,7 +2754,7 @@ class Fn extends re {
|
|
|
2754
2754
|
}, this.settingList = {};
|
|
2755
2755
|
}
|
|
2756
2756
|
}
|
|
2757
|
-
class Bn extends
|
|
2757
|
+
class Bn extends ae {
|
|
2758
2758
|
constructor() {
|
|
2759
2759
|
super(...arguments), this.subfield = {
|
|
2760
2760
|
arg: {
|
|
@@ -2782,7 +2782,7 @@ class Bn extends re {
|
|
|
2782
2782
|
}, this.settingList = {};
|
|
2783
2783
|
}
|
|
2784
2784
|
}
|
|
2785
|
-
class Vn extends
|
|
2785
|
+
class Vn extends ae {
|
|
2786
2786
|
constructor() {
|
|
2787
2787
|
super(...arguments), this.subfield = {
|
|
2788
2788
|
arg: {
|
|
@@ -2854,7 +2854,7 @@ class Xn {
|
|
|
2854
2854
|
}
|
|
2855
2855
|
}
|
|
2856
2856
|
function ft(t, e) {
|
|
2857
|
-
const { variables: n, tupleElements: s } =
|
|
2857
|
+
const { variables: n, tupleElements: s } = Le(t).unwrap();
|
|
2858
2858
|
return s ? n.length === 0 ? {
|
|
2859
2859
|
schemaName: e.schemaName,
|
|
2860
2860
|
tableName: e.name,
|
|
@@ -2898,11 +2898,11 @@ function x(t) {
|
|
|
2898
2898
|
}
|
|
2899
2899
|
function Ce(t) {
|
|
2900
2900
|
var n;
|
|
2901
|
-
const e = (n =
|
|
2902
|
-
return e instanceof
|
|
2901
|
+
const e = (n = he(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2902
|
+
return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2903
2903
|
}
|
|
2904
|
-
function
|
|
2905
|
-
const e =
|
|
2904
|
+
function ve(t) {
|
|
2905
|
+
const e = j(t).unwrap();
|
|
2906
2906
|
return {
|
|
2907
2907
|
name: e.pop(),
|
|
2908
2908
|
schemaName: e
|
|
@@ -2951,7 +2951,7 @@ class Rt {
|
|
|
2951
2951
|
}), this.pkColumns.forEach((n) => n.pk = !1)), e;
|
|
2952
2952
|
}
|
|
2953
2953
|
interpretName(e) {
|
|
2954
|
-
const { name: n, schemaName: s } =
|
|
2954
|
+
const { name: n, schemaName: s } = ve(e);
|
|
2955
2955
|
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
2956
2956
|
}
|
|
2957
2957
|
interpretAlias(e) {
|
|
@@ -2969,9 +2969,9 @@ class Rt {
|
|
|
2969
2969
|
}
|
|
2970
2970
|
interpretSettingList(e) {
|
|
2971
2971
|
var r, a, l;
|
|
2972
|
-
const n =
|
|
2972
|
+
const n = Q(e).getValue();
|
|
2973
2973
|
this.table.headerColor = (r = n.headercolor) != null && r.length ? $n((l = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
|
|
2974
|
-
const [s] = n.note || [], i =
|
|
2974
|
+
const [s] = n.note || [], i = z(s == null ? void 0 : s.value).unwrap_or(void 0);
|
|
2975
2975
|
return this.table.note = s && {
|
|
2976
2976
|
value: i,
|
|
2977
2977
|
token: x(s)
|
|
@@ -2987,7 +2987,7 @@ class Rt {
|
|
|
2987
2987
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
2988
2988
|
case "note":
|
|
2989
2989
|
return this.table.note = {
|
|
2990
|
-
value:
|
|
2990
|
+
value: z(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).unwrap(),
|
|
2991
2991
|
token: x(n)
|
|
2992
2992
|
}, [];
|
|
2993
2993
|
case "indexes":
|
|
@@ -3007,63 +3007,63 @@ class Rt {
|
|
|
3007
3007
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
|
|
3008
3008
|
const r = e.args.slice(1);
|
|
3009
3009
|
if (I.last(r) instanceof P) {
|
|
3010
|
-
const
|
|
3011
|
-
s.pk = !!((a =
|
|
3012
|
-
const
|
|
3013
|
-
s.note =
|
|
3014
|
-
value:
|
|
3015
|
-
token: x(
|
|
3010
|
+
const _ = Q(r.pop()).getValue();
|
|
3011
|
+
s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault = jn((N = (f = _.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3012
|
+
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3013
|
+
s.note = K && {
|
|
3014
|
+
value: z(K.value).unwrap(),
|
|
3015
|
+
token: x(K)
|
|
3016
3016
|
};
|
|
3017
|
-
const
|
|
3018
|
-
s.inline_refs =
|
|
3019
|
-
const [tt] = Ce(
|
|
3017
|
+
const Te = _.ref || [];
|
|
3018
|
+
s.inline_refs = Te.flatMap((Y) => {
|
|
3019
|
+
const [tt] = Ce(Y.value.expression);
|
|
3020
3020
|
if (St(tt, e.symbol))
|
|
3021
|
-
return n.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
3022
|
-
const
|
|
3023
|
-
let
|
|
3024
|
-
if (
|
|
3025
|
-
const [
|
|
3026
|
-
|
|
3021
|
+
return n.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
|
|
3022
|
+
const we = Y.value.op, ee = j(Y.value.expression).unwrap();
|
|
3023
|
+
let fe;
|
|
3024
|
+
if (ee.length === 1) {
|
|
3025
|
+
const [oe] = ee;
|
|
3026
|
+
fe = {
|
|
3027
3027
|
schemaName: this.table.schemaName,
|
|
3028
3028
|
tableName: this.table.name,
|
|
3029
|
-
fieldNames: [
|
|
3030
|
-
relation:
|
|
3031
|
-
token: x(
|
|
3029
|
+
fieldNames: [oe],
|
|
3030
|
+
relation: we.value,
|
|
3031
|
+
token: x(Y)
|
|
3032
3032
|
};
|
|
3033
|
-
} else if (
|
|
3034
|
-
const [
|
|
3035
|
-
|
|
3033
|
+
} else if (ee.length === 2) {
|
|
3034
|
+
const [oe, be] = ee;
|
|
3035
|
+
fe = {
|
|
3036
3036
|
schemaName: null,
|
|
3037
|
-
tableName:
|
|
3038
|
-
fieldNames: [
|
|
3039
|
-
relation:
|
|
3040
|
-
token: x(
|
|
3037
|
+
tableName: oe,
|
|
3038
|
+
fieldNames: [be],
|
|
3039
|
+
relation: we.value,
|
|
3040
|
+
token: x(Y)
|
|
3041
3041
|
};
|
|
3042
|
-
} else if (
|
|
3043
|
-
const [
|
|
3044
|
-
|
|
3045
|
-
schemaName:
|
|
3046
|
-
tableName:
|
|
3042
|
+
} else if (ee.length === 3) {
|
|
3043
|
+
const [oe, be, st] = ee;
|
|
3044
|
+
fe = {
|
|
3045
|
+
schemaName: oe,
|
|
3046
|
+
tableName: be,
|
|
3047
3047
|
fieldNames: [st],
|
|
3048
|
-
relation:
|
|
3049
|
-
token: x(
|
|
3048
|
+
relation: we.value,
|
|
3049
|
+
token: x(Y)
|
|
3050
3050
|
};
|
|
3051
3051
|
} else {
|
|
3052
|
-
n.push(new u(o.UNSUPPORTED, "Nested schema is not supported",
|
|
3053
|
-
const
|
|
3054
|
-
|
|
3055
|
-
schemaName:
|
|
3056
|
-
tableName:
|
|
3057
|
-
fieldNames: [
|
|
3058
|
-
relation:
|
|
3059
|
-
token: x(
|
|
3052
|
+
n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", Y));
|
|
3053
|
+
const oe = ee.pop(), be = ee.pop();
|
|
3054
|
+
fe = {
|
|
3055
|
+
schemaName: ee.join("."),
|
|
3056
|
+
tableName: be,
|
|
3057
|
+
fieldNames: [oe],
|
|
3058
|
+
relation: we.value,
|
|
3059
|
+
token: x(Y)
|
|
3060
3060
|
};
|
|
3061
3061
|
}
|
|
3062
|
-
const nt = this.registerInlineRefToEnv(e, tt,
|
|
3063
|
-
return n.push(...nt), nt.length === 0 ?
|
|
3062
|
+
const nt = this.registerInlineRefToEnv(e, tt, fe, Y);
|
|
3063
|
+
return n.push(...nt), nt.length === 0 ? fe : [];
|
|
3064
3064
|
});
|
|
3065
3065
|
}
|
|
3066
|
-
return s.pk || (s.pk = r.some((
|
|
3066
|
+
return s.pk || (s.pk = r.some((_) => G(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => G(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3067
3067
|
}
|
|
3068
3068
|
interpretIndexes(e) {
|
|
3069
3069
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
@@ -3072,30 +3072,30 @@ class Rt {
|
|
|
3072
3072
|
s.token = x(e);
|
|
3073
3073
|
const r = [i.callee, ...i.args];
|
|
3074
3074
|
if (I.last(r) instanceof P) {
|
|
3075
|
-
const g =
|
|
3076
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name =
|
|
3077
|
-
const
|
|
3078
|
-
s.note =
|
|
3079
|
-
value:
|
|
3080
|
-
token: x(
|
|
3075
|
+
const g = Q(r.pop()).getValue();
|
|
3076
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3077
|
+
const _ = (T = g.note) == null ? void 0 : T.at(0);
|
|
3078
|
+
s.note = _ && {
|
|
3079
|
+
value: z(_.value).unwrap(),
|
|
3080
|
+
token: x(_)
|
|
3081
3081
|
}, s.type = G((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3082
3082
|
}
|
|
3083
3083
|
return r.flatMap((g) => {
|
|
3084
|
-
if (!(g instanceof
|
|
3084
|
+
if (!(g instanceof J))
|
|
3085
3085
|
return g;
|
|
3086
|
-
const
|
|
3087
|
-
for (; g instanceof
|
|
3088
|
-
|
|
3089
|
-
return
|
|
3086
|
+
const _ = [];
|
|
3087
|
+
for (; g instanceof J; )
|
|
3088
|
+
_.push(g.argumentList), g = g.callee;
|
|
3089
|
+
return _.push(g), _;
|
|
3090
3090
|
}).forEach((g) => {
|
|
3091
|
-
const { functional:
|
|
3091
|
+
const { functional: _, nonFunctional: K } = Ge(g).unwrap();
|
|
3092
3092
|
s.columns.push(
|
|
3093
|
-
...
|
|
3094
|
-
value:
|
|
3093
|
+
..._.map((Te) => ({
|
|
3094
|
+
value: Te.value.value,
|
|
3095
3095
|
type: "expression"
|
|
3096
3096
|
})),
|
|
3097
|
-
...
|
|
3098
|
-
value: V(
|
|
3097
|
+
...K.map((Te) => ({
|
|
3098
|
+
value: V(Te).unwrap(),
|
|
3099
3099
|
type: "column"
|
|
3100
3100
|
}))
|
|
3101
3101
|
);
|
|
@@ -3132,11 +3132,11 @@ class Rt {
|
|
|
3132
3132
|
}
|
|
3133
3133
|
function Wn(t) {
|
|
3134
3134
|
let e = null;
|
|
3135
|
-
t instanceof
|
|
3135
|
+
t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value : W(r) ? z(r).unwrap() : G(r).unwrap()).join(","), t = t.callee);
|
|
3136
3136
|
let n = "";
|
|
3137
|
-
for (; t instanceof
|
|
3137
|
+
for (; t instanceof ce; )
|
|
3138
3138
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3139
|
-
const { name: s, schemaName: i } =
|
|
3139
|
+
const { name: s, schemaName: i } = ve(t);
|
|
3140
3140
|
return i.length > 1 ? new F(
|
|
3141
3141
|
{
|
|
3142
3142
|
schemaName: i.length === 0 ? null : i[0],
|
|
@@ -3153,29 +3153,29 @@ function Wn(t) {
|
|
|
3153
3153
|
function jn(t) {
|
|
3154
3154
|
var e, n, s;
|
|
3155
3155
|
if (t) {
|
|
3156
|
-
if (
|
|
3156
|
+
if (W(t))
|
|
3157
3157
|
return {
|
|
3158
|
-
value:
|
|
3158
|
+
value: z(t).unwrap(),
|
|
3159
3159
|
type: "string"
|
|
3160
3160
|
};
|
|
3161
|
-
if (
|
|
3161
|
+
if (ue(t))
|
|
3162
3162
|
return {
|
|
3163
3163
|
type: "number",
|
|
3164
3164
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3165
3165
|
};
|
|
3166
|
-
if (
|
|
3166
|
+
if (Ee(t))
|
|
3167
3167
|
return {
|
|
3168
3168
|
value: t.expression.variable.value.toLowerCase(),
|
|
3169
3169
|
type: "boolean"
|
|
3170
3170
|
};
|
|
3171
|
-
if (t instanceof
|
|
3171
|
+
if (t instanceof q && vt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression)) {
|
|
3172
3172
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3173
3173
|
return {
|
|
3174
3174
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
3175
3175
|
type: "number"
|
|
3176
3176
|
};
|
|
3177
3177
|
}
|
|
3178
|
-
if (t instanceof
|
|
3178
|
+
if (t instanceof te)
|
|
3179
3179
|
return {
|
|
3180
3180
|
value: (s = t.value) == null ? void 0 : s.value,
|
|
3181
3181
|
type: "expression"
|
|
@@ -3185,13 +3185,13 @@ function jn(t) {
|
|
|
3185
3185
|
}
|
|
3186
3186
|
class Dt {
|
|
3187
3187
|
constructor(e, n) {
|
|
3188
|
-
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof
|
|
3188
|
+
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3189
3189
|
}
|
|
3190
3190
|
interpret() {
|
|
3191
3191
|
return this.ref.token = x(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3192
3192
|
}
|
|
3193
3193
|
interpretName(e) {
|
|
3194
|
-
const n = [], s =
|
|
3194
|
+
const n = [], s = j(this.declarationNode.name).unwrap_or([]);
|
|
3195
3195
|
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3196
3196
|
}
|
|
3197
3197
|
interpretBody(e) {
|
|
@@ -3209,8 +3209,10 @@ class Dt {
|
|
|
3209
3209
|
new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
|
|
3210
3210
|
];
|
|
3211
3211
|
if (e.args[0]) {
|
|
3212
|
-
const g =
|
|
3213
|
-
this.ref.onDelete =
|
|
3212
|
+
const g = Q(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
|
|
3213
|
+
this.ref.onDelete = _ instanceof C ? Ne(_).unwrap_or(void 0) : G(_).unwrap_or(void 0);
|
|
3214
|
+
const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
|
|
3215
|
+
this.ref.onUpdate = K instanceof C ? Ne(K).unwrap_or(void 0) : G(K).unwrap_or(void 0);
|
|
3214
3216
|
}
|
|
3215
3217
|
const p = xt(n);
|
|
3216
3218
|
return this.ref.endpoints = [
|
|
@@ -3239,15 +3241,15 @@ class Pt {
|
|
|
3239
3241
|
), e;
|
|
3240
3242
|
}
|
|
3241
3243
|
interpretName(e) {
|
|
3242
|
-
const n = [], { name: s, schemaName: i } =
|
|
3244
|
+
const n = [], { name: s, schemaName: i } = ve(e);
|
|
3243
3245
|
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3244
3246
|
}
|
|
3245
3247
|
interpretBody(e) {
|
|
3246
3248
|
const n = [];
|
|
3247
3249
|
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3248
|
-
const i =
|
|
3250
|
+
const i = j(s.callee).unwrap();
|
|
3249
3251
|
i.length > 2 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3250
|
-
const r =
|
|
3252
|
+
const r = he(s.callee).unwrap().pop().referee.id;
|
|
3251
3253
|
if (this.env.groupOfTable[r]) {
|
|
3252
3254
|
const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), h = l ? `${l}.${p}` : p;
|
|
3253
3255
|
n.push(new u(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
|
|
@@ -3268,7 +3270,7 @@ class Ut {
|
|
|
3268
3270
|
return this.enum.token = x(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3269
3271
|
}
|
|
3270
3272
|
interpretName(e) {
|
|
3271
|
-
const { name: n, schemaName: s } =
|
|
3273
|
+
const { name: n, schemaName: s } = ve(e);
|
|
3272
3274
|
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3273
3275
|
}
|
|
3274
3276
|
interpretBody(e) {
|
|
@@ -3276,9 +3278,9 @@ class Ut {
|
|
|
3276
3278
|
var l;
|
|
3277
3279
|
const s = n, i = {};
|
|
3278
3280
|
i.token = x(s), i.name = G(s.callee).unwrap();
|
|
3279
|
-
const a = (l =
|
|
3281
|
+
const a = (l = Q(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
|
|
3280
3282
|
return i.note = a && {
|
|
3281
|
-
value:
|
|
3283
|
+
value: z(a.value).unwrap(),
|
|
3282
3284
|
token: x(a)
|
|
3283
3285
|
}, this.enum.values.push(i), [];
|
|
3284
3286
|
});
|
|
@@ -3294,7 +3296,7 @@ class Yn {
|
|
|
3294
3296
|
interpretName(e) {
|
|
3295
3297
|
if (!e)
|
|
3296
3298
|
return this.project.name = null, [];
|
|
3297
|
-
const { name: n } =
|
|
3299
|
+
const { name: n } = ve(e);
|
|
3298
3300
|
return this.project.name = n, [];
|
|
3299
3301
|
}
|
|
3300
3302
|
interpretBody(e) {
|
|
@@ -3320,11 +3322,11 @@ class Yn {
|
|
|
3320
3322
|
}
|
|
3321
3323
|
case "note":
|
|
3322
3324
|
return this.project.note = {
|
|
3323
|
-
value:
|
|
3325
|
+
value: z(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).unwrap(),
|
|
3324
3326
|
token: x(s)
|
|
3325
3327
|
}, [];
|
|
3326
3328
|
default:
|
|
3327
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
3329
|
+
return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
|
|
3328
3330
|
}
|
|
3329
3331
|
});
|
|
3330
3332
|
}
|
|
@@ -3345,7 +3347,7 @@ class zn {
|
|
|
3345
3347
|
}
|
|
3346
3348
|
interpret() {
|
|
3347
3349
|
const e = this.ast.body.flatMap((n) => {
|
|
3348
|
-
switch (
|
|
3350
|
+
switch (_e(n).unwrap_or(void 0)) {
|
|
3349
3351
|
case b.Table:
|
|
3350
3352
|
return new Rt(n, this.env).interpret();
|
|
3351
3353
|
case b.Ref:
|
|
@@ -3375,7 +3377,7 @@ function Qn(t) {
|
|
|
3375
3377
|
};
|
|
3376
3378
|
}
|
|
3377
3379
|
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
|
|
3378
|
-
function
|
|
3380
|
+
function ge(t) {
|
|
3379
3381
|
switch (t) {
|
|
3380
3382
|
case m.Schema:
|
|
3381
3383
|
return L.Module;
|
|
@@ -3395,7 +3397,7 @@ function Le(t) {
|
|
|
3395
3397
|
return L.Text;
|
|
3396
3398
|
}
|
|
3397
3399
|
}
|
|
3398
|
-
function
|
|
3400
|
+
function Se(t, e) {
|
|
3399
3401
|
if (!t || Ve(t))
|
|
3400
3402
|
return !1;
|
|
3401
3403
|
for (const n of t.trailingTrivia) {
|
|
@@ -3411,7 +3413,7 @@ function S() {
|
|
|
3411
3413
|
suggestions: []
|
|
3412
3414
|
};
|
|
3413
3415
|
}
|
|
3414
|
-
function
|
|
3416
|
+
function Re(t) {
|
|
3415
3417
|
return {
|
|
3416
3418
|
...t,
|
|
3417
3419
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3443,18 +3445,18 @@ class Mt {
|
|
|
3443
3445
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3444
3446
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3445
3447
|
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3446
|
-
].find((N) => $t(N) &&
|
|
3448
|
+
].find((N) => $t(N) && Ie(s, N)))
|
|
3447
3449
|
return S();
|
|
3448
3450
|
if (a === void 0)
|
|
3449
3451
|
return mt();
|
|
3450
|
-
if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) &&
|
|
3452
|
+
if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && Ie(s, r))
|
|
3451
3453
|
return S();
|
|
3452
3454
|
const p = this.compiler.container.element(s);
|
|
3453
|
-
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof
|
|
3455
|
+
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
|
|
3454
3456
|
return mt();
|
|
3455
3457
|
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3456
3458
|
for (const N of h)
|
|
3457
|
-
if (N instanceof
|
|
3459
|
+
if (N instanceof q)
|
|
3458
3460
|
switch ((T = N.op) == null ? void 0 : T.value) {
|
|
3459
3461
|
case ">":
|
|
3460
3462
|
case "<":
|
|
@@ -3466,7 +3468,7 @@ class Mt {
|
|
|
3466
3468
|
N
|
|
3467
3469
|
);
|
|
3468
3470
|
}
|
|
3469
|
-
else if (N instanceof
|
|
3471
|
+
else if (N instanceof H)
|
|
3470
3472
|
switch ((f = N.op) == null ? void 0 : f.value) {
|
|
3471
3473
|
case ">":
|
|
3472
3474
|
case "<":
|
|
@@ -3485,15 +3487,15 @@ class Mt {
|
|
|
3485
3487
|
);
|
|
3486
3488
|
}
|
|
3487
3489
|
else {
|
|
3488
|
-
if (N instanceof
|
|
3490
|
+
if (N instanceof se)
|
|
3489
3491
|
return dt(this.compiler, s, N);
|
|
3490
3492
|
if (N instanceof P)
|
|
3491
3493
|
return dt(this.compiler, s, N);
|
|
3492
|
-
if (N instanceof
|
|
3494
|
+
if (N instanceof Z)
|
|
3493
3495
|
return qn(this.compiler, s);
|
|
3494
3496
|
if (N instanceof k)
|
|
3495
3497
|
return Nt(this.compiler, s, N);
|
|
3496
|
-
if (N instanceof
|
|
3498
|
+
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && Ie(s, N.body)))
|
|
3497
3499
|
return Nt(this.compiler, s, void 0);
|
|
3498
3500
|
}
|
|
3499
3501
|
return S();
|
|
@@ -3507,7 +3509,7 @@ function pt(t, e, n) {
|
|
|
3507
3509
|
m.Schema,
|
|
3508
3510
|
m.Column
|
|
3509
3511
|
]);
|
|
3510
|
-
return
|
|
3512
|
+
return Se(n.op, e) ? Re(i) : i;
|
|
3511
3513
|
}
|
|
3512
3514
|
return S();
|
|
3513
3515
|
}
|
|
@@ -3525,13 +3527,13 @@ function Me(t, e, n, s) {
|
|
|
3525
3527
|
label: p,
|
|
3526
3528
|
insertText: p,
|
|
3527
3529
|
insertTextRules: w.KeepWhitespace,
|
|
3528
|
-
kind:
|
|
3529
|
-
sortText:
|
|
3530
|
+
kind: ge(h),
|
|
3531
|
+
sortText: ge(h).toString().padStart(2, "0"),
|
|
3530
3532
|
range: void 0
|
|
3531
3533
|
}))
|
|
3532
3534
|
);
|
|
3533
3535
|
}
|
|
3534
|
-
i = i instanceof
|
|
3536
|
+
i = i instanceof A ? i.parent : void 0;
|
|
3535
3537
|
}
|
|
3536
3538
|
return Ue(r);
|
|
3537
3539
|
}
|
|
@@ -3545,7 +3547,7 @@ function qn(t, e) {
|
|
|
3545
3547
|
const i = [...t.container.stack(e)];
|
|
3546
3548
|
for (; i.length > 0; ) {
|
|
3547
3549
|
const r = i.pop();
|
|
3548
|
-
if (r instanceof
|
|
3550
|
+
if (r instanceof H && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3549
3551
|
return Ft(
|
|
3550
3552
|
t,
|
|
3551
3553
|
e,
|
|
@@ -3561,25 +3563,25 @@ function dt(t, e, n) {
|
|
|
3561
3563
|
const { token: s } = t.container.token(e);
|
|
3562
3564
|
if ([c.COMMA, c.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3563
3565
|
const i = Et(t, e);
|
|
3564
|
-
return (s == null ? void 0 : s.kind) === c.COMMA &&
|
|
3566
|
+
return (s == null ? void 0 : s.kind) === c.COMMA && Se(s, e) ? Re(i) : i;
|
|
3565
3567
|
}
|
|
3566
3568
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3567
3569
|
return Et(t, e);
|
|
3568
|
-
if (n.name instanceof
|
|
3570
|
+
if (n.name instanceof C) {
|
|
3569
3571
|
const i = Hn(
|
|
3570
3572
|
t,
|
|
3571
3573
|
e,
|
|
3572
|
-
|
|
3574
|
+
Ne(n.name).unwrap()
|
|
3573
3575
|
);
|
|
3574
|
-
return (s == null ? void 0 : s.kind) === c.COLON &&
|
|
3576
|
+
return (s == null ? void 0 : s.kind) === c.COLON && Se(s, e) ? Re(i) : i;
|
|
3575
3577
|
}
|
|
3576
3578
|
return S();
|
|
3577
3579
|
}
|
|
3578
3580
|
function Et(t, e) {
|
|
3579
3581
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3580
|
-
if (n instanceof
|
|
3582
|
+
if (n instanceof X)
|
|
3581
3583
|
return S();
|
|
3582
|
-
if (n.body && !
|
|
3584
|
+
if (n.body && !Ie(e, n.body))
|
|
3583
3585
|
switch (s) {
|
|
3584
3586
|
case R.TABLE:
|
|
3585
3587
|
return {
|
|
@@ -3701,7 +3703,7 @@ function Hn(t, e, n) {
|
|
|
3701
3703
|
return S();
|
|
3702
3704
|
}
|
|
3703
3705
|
function Ft(t, e, n) {
|
|
3704
|
-
const s =
|
|
3706
|
+
const s = he(n).unwrap_or([]);
|
|
3705
3707
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3706
3708
|
return S();
|
|
3707
3709
|
const i = s.map((r) => G(r).unwrap());
|
|
@@ -3709,7 +3711,7 @@ function Ft(t, e, n) {
|
|
|
3709
3711
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3710
3712
|
label: a,
|
|
3711
3713
|
insertText: a,
|
|
3712
|
-
kind:
|
|
3714
|
+
kind: ge(r),
|
|
3713
3715
|
range: void 0
|
|
3714
3716
|
}))
|
|
3715
3717
|
});
|
|
@@ -3727,7 +3729,7 @@ function Nt(t, e, n) {
|
|
|
3727
3729
|
return Jn(t, e, n);
|
|
3728
3730
|
case R.REF: {
|
|
3729
3731
|
const r = Bt(t, e);
|
|
3730
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON &&
|
|
3732
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Se(t.container.token(e).token, e) ? Re(r) : r;
|
|
3731
3733
|
}
|
|
3732
3734
|
case R.TABLEGROUP:
|
|
3733
3735
|
return es(t);
|
|
@@ -3804,7 +3806,7 @@ function Bt(t, e) {
|
|
|
3804
3806
|
function es(t) {
|
|
3805
3807
|
return Ue({
|
|
3806
3808
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3807
|
-
const n =
|
|
3809
|
+
const n = ie(e).unwrap_or(void 0);
|
|
3808
3810
|
if (n === void 0)
|
|
3809
3811
|
return [];
|
|
3810
3812
|
const { kind: s, name: i } = n;
|
|
@@ -3812,7 +3814,7 @@ function es(t) {
|
|
|
3812
3814
|
label: i,
|
|
3813
3815
|
insertText: i,
|
|
3814
3816
|
insertTextRules: w.KeepWhitespace,
|
|
3815
|
-
kind:
|
|
3817
|
+
kind: ge(s),
|
|
3816
3818
|
range: void 0
|
|
3817
3819
|
};
|
|
3818
3820
|
})
|
|
@@ -3903,7 +3905,7 @@ function Vt(t, e) {
|
|
|
3903
3905
|
const { symbolTable: i } = s.symbol;
|
|
3904
3906
|
return Ue({
|
|
3905
3907
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
3906
|
-
const a =
|
|
3908
|
+
const a = ie(r).unwrap_or(void 0);
|
|
3907
3909
|
if (a === void 0)
|
|
3908
3910
|
return [];
|
|
3909
3911
|
const { name: l } = a;
|
|
@@ -3911,7 +3913,7 @@ function Vt(t, e) {
|
|
|
3911
3913
|
label: l,
|
|
3912
3914
|
insertText: l,
|
|
3913
3915
|
insertTextRules: w.KeepWhitespace,
|
|
3914
|
-
kind:
|
|
3916
|
+
kind: ge(m.Column),
|
|
3915
3917
|
range: void 0
|
|
3916
3918
|
};
|
|
3917
3919
|
})
|
|
@@ -3932,7 +3934,7 @@ class Gt {
|
|
|
3932
3934
|
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
3933
3935
|
for (; r.length !== 0; ) {
|
|
3934
3936
|
const l = r.pop();
|
|
3935
|
-
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [
|
|
3937
|
+
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [de.PRIMARY_EXPRESSION, de.VARIABLE].includes(l == null ? void 0 : l.kind)) {
|
|
3936
3938
|
const { startPos: p, endPos: h } = l.referee.declaration;
|
|
3937
3939
|
return [
|
|
3938
3940
|
{
|
|
@@ -3959,9 +3961,9 @@ class Ct {
|
|
|
3959
3961
|
for (; r.length !== 0; ) {
|
|
3960
3962
|
const a = r.pop();
|
|
3961
3963
|
if (a && [
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3964
|
+
de.ELEMENT_DECLARATION,
|
|
3965
|
+
de.FUNCTION_APPLICATION,
|
|
3966
|
+
de.PRIMARY_EXPRESSION
|
|
3965
3967
|
].includes(a == null ? void 0 : a.kind)) {
|
|
3966
3968
|
const { symbol: l } = a;
|
|
3967
3969
|
if (l != null && l.references.length)
|
|
@@ -4046,7 +4048,7 @@ class as {
|
|
|
4046
4048
|
let a = this.parse.ast();
|
|
4047
4049
|
const l = [a];
|
|
4048
4050
|
for (; ; ) {
|
|
4049
|
-
const h = sn(a).find((T) =>
|
|
4051
|
+
const h = sn(a).find((T) => Ie(r, T));
|
|
4050
4052
|
if (h === void 0 || h instanceof B)
|
|
4051
4053
|
break;
|
|
4052
4054
|
l.push(h), a = h;
|
|
@@ -4062,10 +4064,10 @@ class as {
|
|
|
4062
4064
|
T[f] === `
|
|
4063
4065
|
` && (l.pop(), p = !0);
|
|
4064
4066
|
} else
|
|
4065
|
-
h instanceof
|
|
4067
|
+
h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof C || h.end < e && (l.pop(), p = !0);
|
|
4066
4068
|
if (p) {
|
|
4067
4069
|
const T = I.last(l);
|
|
4068
|
-
T instanceof
|
|
4070
|
+
T instanceof A && T.end <= e && l.pop();
|
|
4069
4071
|
}
|
|
4070
4072
|
if (!p)
|
|
4071
4073
|
break;
|
|
@@ -4088,7 +4090,7 @@ class as {
|
|
|
4088
4090
|
(e) => {
|
|
4089
4091
|
const n = this.container.stack(e);
|
|
4090
4092
|
for (let s = n.length - 1; s >= 0; s -= 1)
|
|
4091
|
-
if (n[s] instanceof
|
|
4093
|
+
if (n[s] instanceof A)
|
|
4092
4094
|
return n[s];
|
|
4093
4095
|
return this.parse.ast();
|
|
4094
4096
|
}
|
|
@@ -4102,7 +4104,7 @@ class as {
|
|
|
4102
4104
|
),
|
|
4103
4105
|
scopeKind: this.createQuery(15, (e) => {
|
|
4104
4106
|
var s;
|
|
4105
|
-
if (this.container.element(e) instanceof
|
|
4107
|
+
if (this.container.element(e) instanceof X)
|
|
4106
4108
|
return 8;
|
|
4107
4109
|
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4108
4110
|
case "table":
|
|
@@ -4138,7 +4140,7 @@ class as {
|
|
|
4138
4140
|
if (e.length === 0)
|
|
4139
4141
|
return [];
|
|
4140
4142
|
const s = [];
|
|
4141
|
-
for (let r = n; r; r = r instanceof
|
|
4143
|
+
for (let r = n; r; r = r instanceof A ? r.parent : void 0) {
|
|
4142
4144
|
if (!((i = r.symbol) != null && i.symbolTable))
|
|
4143
4145
|
continue;
|
|
4144
4146
|
const { symbolTable: a } = r.symbol;
|
|
@@ -4146,7 +4148,7 @@ class as {
|
|
|
4146
4148
|
for (const h of e)
|
|
4147
4149
|
p = l.flatMap(
|
|
4148
4150
|
(T) => Yt(h).flatMap((f) => {
|
|
4149
|
-
const N = T.get(f), g =
|
|
4151
|
+
const N = T.get(f), g = ie(f).unwrap_or(void 0);
|
|
4150
4152
|
return !N || !g ? [] : { ...g, symbol: N };
|
|
4151
4153
|
})
|
|
4152
4154
|
), l = p.flatMap(
|
|
@@ -4161,7 +4163,7 @@ class as {
|
|
|
4161
4163
|
members: this.createQuery(
|
|
4162
4164
|
9,
|
|
4163
4165
|
(e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
|
|
4164
|
-
...
|
|
4166
|
+
...ie(n).unwrap(),
|
|
4165
4167
|
symbol: s
|
|
4166
4168
|
})) : []
|
|
4167
4169
|
)
|