@dbml/parse 3.1.2 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +7 -9
- package/dist/dbml-parse.mjs +508 -510
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import I from "lodash";
|
|
2
2
|
var c = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(c || {});
|
|
3
3
|
function Xt(t) {
|
|
4
4
|
switch (t.kind) {
|
|
@@ -36,12 +36,12 @@ function rt(t) {
|
|
|
36
36
|
function at(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class B {
|
|
40
40
|
constructor(e, s, n, i, r) {
|
|
41
41
|
this.kind = e, this.startPos = s, this.endPos = n, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = s.offset, this.end = n.offset;
|
|
42
42
|
}
|
|
43
43
|
static create(e, s, n, i, r) {
|
|
44
|
-
return new
|
|
44
|
+
return new B(e, s, n, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function bt(t) {
|
|
@@ -54,7 +54,7 @@ function Ve(t) {
|
|
|
54
54
|
return t.trailingTrivia.find(({ kind: e }) => e === c.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
56
|
function It(t) {
|
|
57
|
-
return t.trailingTrivia.length === 0 ? t.end : It(
|
|
57
|
+
return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
|
|
58
58
|
}
|
|
59
59
|
function Lt(t) {
|
|
60
60
|
return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
|
|
@@ -75,32 +75,32 @@ class Wt {
|
|
|
75
75
|
return this.id++;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class y {
|
|
79
79
|
// The symbol that this syntax node refers to
|
|
80
80
|
// args must be passed in order of appearance in the node
|
|
81
81
|
constructor(e, s, n) {
|
|
82
82
|
this.id = e, this.kind = s;
|
|
83
83
|
const i = n.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? Lt(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const r = [...n].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? It(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
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 ue = /* @__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))(ue || {});
|
|
98
|
+
class C extends y {
|
|
99
99
|
constructor({ body: e = [], eof: s }, n) {
|
|
100
100
|
super(n, "<program>", [...e, s]), this.body = e, this.eof = s;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class _ extends
|
|
103
|
+
class _ extends y {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: s,
|
|
@@ -118,17 +118,17 @@ class _ extends v {
|
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
120
|
l
|
|
121
|
-
]), l && a && !(l instanceof
|
|
121
|
+
]), l && a && !(l instanceof x || l instanceof _))
|
|
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 = s, this.as = n, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = l;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class te extends
|
|
126
|
+
class te extends y {
|
|
127
127
|
constructor({ identifiers: e = [] }, s) {
|
|
128
128
|
super(s, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class ne extends
|
|
131
|
+
class ne extends y {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: s,
|
|
@@ -137,12 +137,12 @@ class ne extends v {
|
|
|
137
137
|
super(i, "<attribute>", [e, s, n]), this.name = e, this.value = n, this.colon = s;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class Q extends
|
|
140
|
+
class Q extends y {
|
|
141
141
|
constructor({ op: e, expression: s }, n) {
|
|
142
142
|
super(n, "<prefix-expression>", [e, s]), this.op = e, this.expression = s;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class q extends
|
|
145
|
+
class q extends y {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: s,
|
|
@@ -151,22 +151,22 @@ class q extends v {
|
|
|
151
151
|
super(i, "<infix-expression>", [s, e, n]), this.op = e, this.leftExpression = s, this.rightExpression = n;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class De extends y {
|
|
155
155
|
constructor({ op: e, expression: s }, n) {
|
|
156
156
|
super(n, "<postfix-expression>", [s, e]), this.op = e, this.expression = s;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class K extends
|
|
159
|
+
class K extends y {
|
|
160
160
|
constructor({ value: e }, s) {
|
|
161
161
|
super(s, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class
|
|
164
|
+
class x extends y {
|
|
165
165
|
constructor({ callee: e, args: s = [] }, n) {
|
|
166
166
|
super(n, "<function-application>", [e, ...s]), this.callee = e, this.args = s;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class ee extends
|
|
169
|
+
class ee extends y {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: s = [],
|
|
@@ -175,7 +175,7 @@ class ee extends v {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...s, n]), this.blockOpenBrace = e, this.body = s, this.blockCloseBrace = n;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class U extends
|
|
178
|
+
class U extends y {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: s = [],
|
|
@@ -189,7 +189,7 @@ class U extends v {
|
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = s, this.commaList = n, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class J extends
|
|
192
|
+
class J extends y {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: s = [],
|
|
@@ -220,7 +220,7 @@ class Xe extends J {
|
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class H extends
|
|
223
|
+
class H extends y {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: s
|
|
@@ -228,28 +228,28 @@ class H extends v {
|
|
|
228
228
|
super(n, "<call-expression>", [e, s]), this.callee = e, this.argumentList = s;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class pe extends y {
|
|
232
232
|
constructor({ literal: e }, s) {
|
|
233
233
|
super(s, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class X extends y {
|
|
237
237
|
constructor({ variable: e }, s) {
|
|
238
238
|
super(s, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class
|
|
241
|
+
class R extends y {
|
|
242
242
|
constructor({ expression: e }, s) {
|
|
243
243
|
super(s, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class we extends
|
|
246
|
+
class we extends y {
|
|
247
247
|
constructor({ pre: e }, s) {
|
|
248
|
-
const n =
|
|
248
|
+
const n = B.create(c.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(s, "<dummy>", [n]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
252
|
+
class he extends y {
|
|
253
253
|
constructor({ expression: e, indexer: s }, n) {
|
|
254
254
|
super(n, "<array>", [e, s]), this.array = e, this.indexer = s;
|
|
255
255
|
}
|
|
@@ -260,16 +260,16 @@ function gt(t, e) {
|
|
|
260
260
|
if (!e || e.length === 0)
|
|
261
261
|
return t || [];
|
|
262
262
|
const [s] = t, [n] = e;
|
|
263
|
-
return (s.start < n.start ?
|
|
263
|
+
return (s.start < n.start ? I.flatten(I.zip(t, e)) : I.flatten(I.zip(e, t))).filter(
|
|
264
264
|
(i) => i !== null
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function is(t, e = !1) {
|
|
268
268
|
return JSON.stringify(
|
|
269
269
|
t,
|
|
270
270
|
function(s, n) {
|
|
271
271
|
var i;
|
|
272
|
-
return !(this instanceof
|
|
272
|
+
return !(this instanceof C) && s === "symbol" ? n == null ? void 0 : n.id : (
|
|
273
273
|
/* this instanceof SyntaxNode && */
|
|
274
274
|
s === "symbol" ? {
|
|
275
275
|
symbolTable: n == null ? void 0 : n.symbolTable,
|
|
@@ -290,7 +290,7 @@ function ss(t, e = !1) {
|
|
|
290
290
|
e ? 2 : 0
|
|
291
291
|
);
|
|
292
292
|
}
|
|
293
|
-
class
|
|
293
|
+
class S {
|
|
294
294
|
constructor(e) {
|
|
295
295
|
this.value = e;
|
|
296
296
|
}
|
|
@@ -305,7 +305,7 @@ class k {
|
|
|
305
305
|
return e(this.value);
|
|
306
306
|
}
|
|
307
307
|
map(e) {
|
|
308
|
-
return new
|
|
308
|
+
return new S(e(this.value));
|
|
309
309
|
}
|
|
310
310
|
// eslint-disable-next-line class-methods-use-this
|
|
311
311
|
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":
|
|
@@ -378,7 +378,7 @@ function Fe(t, e) {
|
|
|
378
378
|
}
|
|
379
379
|
function se(t) {
|
|
380
380
|
const [e, s] = t.split(":");
|
|
381
|
-
return Object.values(m).includes(e) ? new
|
|
381
|
+
return Object.values(m).includes(e) ? new S({
|
|
382
382
|
name: s,
|
|
383
383
|
kind: e
|
|
384
384
|
}) : new A();
|
|
@@ -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 ke(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 ke(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
return qe(t) ||
|
|
416
|
+
function be(t) {
|
|
417
|
+
return qe(t) || ke(t);
|
|
418
418
|
}
|
|
419
419
|
function lt(t, e) {
|
|
420
420
|
const s = [], n = Math.min(t.length, e.length);
|
|
@@ -422,7 +422,7 @@ function lt(t, e) {
|
|
|
422
422
|
s.push(t[i], e[i]);
|
|
423
423
|
return s.push(...t.slice(n), ...e.slice(n)), s;
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function Ie(t, e) {
|
|
426
426
|
return t >= e.start && t < e.end;
|
|
427
427
|
}
|
|
428
428
|
class Qt {
|
|
@@ -477,7 +477,7 @@ class u extends Error {
|
|
|
477
477
|
super(s), this.code = e, this.diagnostic = s, this.nodeOrToken = n, this.start = n.start, this.end = n.end, this.name = this.constructor.name, Object.setPrototypeOf(this, u.prototype);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
class
|
|
480
|
+
class F {
|
|
481
481
|
constructor(e, s) {
|
|
482
482
|
this.value = e, this.errors = s === void 0 ? [] : s;
|
|
483
483
|
}
|
|
@@ -489,20 +489,20 @@ class B {
|
|
|
489
489
|
}
|
|
490
490
|
chain(e) {
|
|
491
491
|
const s = e(this.value), n = [...this.errors, ...s.errors];
|
|
492
|
-
return new
|
|
492
|
+
return new F(s.value, n);
|
|
493
493
|
}
|
|
494
494
|
map(e) {
|
|
495
|
-
return new
|
|
495
|
+
return new F(e(this.value), this.errors);
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
function en(t, e, s) {
|
|
499
|
-
if (!t || !
|
|
499
|
+
if (!t || !fe(t) || e.length === 0)
|
|
500
500
|
return new A();
|
|
501
501
|
const n = [...e], i = Be(t).unwrap(), r = n.pop();
|
|
502
502
|
if (!(r instanceof ee))
|
|
503
503
|
return new A();
|
|
504
|
-
const a =
|
|
505
|
-
return n.length === 3 && Be(n[1]).unwrap().value === "as" ? new
|
|
504
|
+
const a = I.last(n) instanceof U ? n.pop() : void 0;
|
|
505
|
+
return n.length === 3 && Be(n[1]).unwrap().value === "as" ? new S(
|
|
506
506
|
s.create(_, {
|
|
507
507
|
type: i,
|
|
508
508
|
name: n[0],
|
|
@@ -511,14 +511,14 @@ function en(t, e, s) {
|
|
|
511
511
|
attributeList: a,
|
|
512
512
|
body: r
|
|
513
513
|
})
|
|
514
|
-
) : n.length === 1 ? new
|
|
514
|
+
) : n.length === 1 ? new S(
|
|
515
515
|
s.create(_, {
|
|
516
516
|
type: i,
|
|
517
517
|
name: n[0],
|
|
518
518
|
attributeList: a,
|
|
519
519
|
body: r
|
|
520
520
|
})
|
|
521
|
-
) : n.length === 0 ? new
|
|
521
|
+
) : n.length === 0 ? new S(
|
|
522
522
|
s.create(_, {
|
|
523
523
|
type: i,
|
|
524
524
|
attributeList: a,
|
|
@@ -530,7 +530,7 @@ function ct(t) {
|
|
|
530
530
|
return t.kind === c.IDENTIFIER && t.value === "as";
|
|
531
531
|
}
|
|
532
532
|
function E(t) {
|
|
533
|
-
t && (t instanceof
|
|
533
|
+
t && (t instanceof B ? tn(t) : nn(t));
|
|
534
534
|
}
|
|
535
535
|
function tn(t) {
|
|
536
536
|
t.kind !== c.EOF && (t.isInvalid = !0);
|
|
@@ -546,7 +546,7 @@ function nn(t) {
|
|
|
546
546
|
E(t.op), E(t.expression);
|
|
547
547
|
else if (t instanceof q)
|
|
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
551
|
else if (t instanceof ee)
|
|
552
552
|
E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
|
|
@@ -556,27 +556,27 @@ function nn(t) {
|
|
|
556
556
|
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
557
557
|
else if (t instanceof H)
|
|
558
558
|
E(t.callee), E(t.argumentList);
|
|
559
|
-
else if (t instanceof
|
|
559
|
+
else if (t instanceof x)
|
|
560
560
|
E(t.callee), t.args.forEach(E);
|
|
561
|
-
else if (t instanceof
|
|
561
|
+
else if (t instanceof R)
|
|
562
562
|
E(t.expression);
|
|
563
563
|
else if (t instanceof K)
|
|
564
564
|
E(t.value);
|
|
565
|
-
else if (t instanceof
|
|
565
|
+
else if (t instanceof X)
|
|
566
566
|
E(t.variable);
|
|
567
|
-
else if (t instanceof
|
|
567
|
+
else if (t instanceof pe)
|
|
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");
|
|
571
571
|
}
|
|
572
|
-
function
|
|
572
|
+
function vt(t) {
|
|
573
573
|
return !!(t != null && t.isInvalid);
|
|
574
574
|
}
|
|
575
575
|
function P(...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 C)
|
|
580
580
|
return P(...t.body, t.eof);
|
|
581
581
|
if (t instanceof _)
|
|
582
582
|
return P(
|
|
@@ -592,19 +592,19 @@ function sn(t) {
|
|
|
592
592
|
return P(t.name, t.colon, t.value);
|
|
593
593
|
if (t instanceof te)
|
|
594
594
|
return t.identifiers;
|
|
595
|
-
if (t instanceof
|
|
595
|
+
if (t instanceof pe)
|
|
596
596
|
return t.literal ? [t.literal] : [];
|
|
597
|
-
if (t instanceof
|
|
597
|
+
if (t instanceof X)
|
|
598
598
|
return P(t.variable);
|
|
599
599
|
if (t instanceof Q)
|
|
600
600
|
return P(t.op, t.expression);
|
|
601
601
|
if (t instanceof q)
|
|
602
602
|
return P(t.leftExpression, t.op, t.rightExpression);
|
|
603
|
-
if (t instanceof
|
|
603
|
+
if (t instanceof De)
|
|
604
604
|
return P(t.expression, t.op);
|
|
605
605
|
if (t instanceof K)
|
|
606
606
|
return P(t.value);
|
|
607
|
-
if (t instanceof
|
|
607
|
+
if (t instanceof x)
|
|
608
608
|
return P(t.callee, ...t.args);
|
|
609
609
|
if (t instanceof ee)
|
|
610
610
|
return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
@@ -622,33 +622,33 @@ function sn(t) {
|
|
|
622
622
|
);
|
|
623
623
|
if (t instanceof H)
|
|
624
624
|
return P(t.callee, t.argumentList);
|
|
625
|
-
if (t instanceof
|
|
625
|
+
if (t instanceof R)
|
|
626
626
|
return P(t.expression);
|
|
627
627
|
throw t instanceof Xe ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
628
628
|
}
|
|
629
629
|
function Be(t) {
|
|
630
|
-
return M(t) ? new
|
|
630
|
+
return M(t) ? new S(t.expression.variable) : new A();
|
|
631
631
|
}
|
|
632
|
-
function
|
|
632
|
+
function $(t) {
|
|
633
633
|
var e;
|
|
634
|
-
return t instanceof
|
|
634
|
+
return t instanceof R && (t.expression instanceof X && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
|
|
635
635
|
}
|
|
636
636
|
function M(t) {
|
|
637
|
-
return t instanceof
|
|
637
|
+
return t instanceof R && t.expression instanceof X && t.expression.variable instanceof B;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function fe(t) {
|
|
640
640
|
var e;
|
|
641
|
-
return t instanceof
|
|
641
|
+
return t instanceof R && t.expression instanceof X && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
|
|
642
642
|
}
|
|
643
643
|
function He(t) {
|
|
644
644
|
var e;
|
|
645
|
-
return t instanceof q && t.leftExpression instanceof
|
|
645
|
+
return t instanceof q && t.leftExpression instanceof y && t.rightExpression instanceof y && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function Re(t) {
|
|
648
648
|
if (t === void 0)
|
|
649
649
|
return new A();
|
|
650
650
|
const e = t.identifiers.map((s) => s.value).join(" ");
|
|
651
|
-
return e === "" ? new A() : new
|
|
651
|
+
return e === "" ? new A() : new S(e);
|
|
652
652
|
}
|
|
653
653
|
class rn {
|
|
654
654
|
// list of errors during lexing
|
|
@@ -690,7 +690,7 @@ class rn {
|
|
|
690
690
|
this.tokens.push(this.createToken(e, s));
|
|
691
691
|
}
|
|
692
692
|
createToken(e, s = !1) {
|
|
693
|
-
return
|
|
693
|
+
return B.create(
|
|
694
694
|
e,
|
|
695
695
|
this.start,
|
|
696
696
|
this.current,
|
|
@@ -699,7 +699,7 @@ class rn {
|
|
|
699
699
|
);
|
|
700
700
|
}
|
|
701
701
|
lex() {
|
|
702
|
-
return this.scanTokens(), this.tokens.push(
|
|
702
|
+
return this.scanTokens(), this.tokens.push(B.create(c.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new F(this.tokens, this.errors);
|
|
703
703
|
}
|
|
704
704
|
scanTokens() {
|
|
705
705
|
for (; !this.isAtEnd(); ) {
|
|
@@ -768,7 +768,7 @@ class rn {
|
|
|
768
768
|
this.identifier();
|
|
769
769
|
break;
|
|
770
770
|
}
|
|
771
|
-
if (
|
|
771
|
+
if (ke(e)) {
|
|
772
772
|
this.numericLiteral();
|
|
773
773
|
break;
|
|
774
774
|
}
|
|
@@ -794,7 +794,7 @@ class rn {
|
|
|
794
794
|
gatherInvalid() {
|
|
795
795
|
let e;
|
|
796
796
|
const s = [], n = [];
|
|
797
|
-
for (e = 0; e < this.tokens.length &&
|
|
797
|
+
for (e = 0; e < this.tokens.length && vt(this.tokens[e]); e += 1)
|
|
798
798
|
n.push(this.tokens[e]);
|
|
799
799
|
let i = this.tokens[e];
|
|
800
800
|
for (i.leadingInvalid = [...n, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
@@ -836,7 +836,7 @@ class rn {
|
|
|
836
836
|
);
|
|
837
837
|
return;
|
|
838
838
|
}
|
|
839
|
-
a && this.match(s), this.tokens.push(
|
|
839
|
+
a && this.match(s), this.tokens.push(B.create(e, this.start, this.current, l, !1));
|
|
840
840
|
}
|
|
841
841
|
singleLineStringLiteral() {
|
|
842
842
|
this.consumeUntil(c.STRING_LITERAL, "'", {
|
|
@@ -883,7 +883,7 @@ class rn {
|
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
885
|
identifier() {
|
|
886
|
-
for (; !this.isAtEnd() &&
|
|
886
|
+
for (; !this.isAtEnd() && be(this.peek()); )
|
|
887
887
|
this.advance();
|
|
888
888
|
this.addToken(c.IDENTIFIER);
|
|
889
889
|
}
|
|
@@ -902,19 +902,19 @@ class rn {
|
|
|
902
902
|
break;
|
|
903
903
|
if (!n && this.current.offset === this.text.length - 1)
|
|
904
904
|
return this.advance(), this.addToken(c.NUMERIC_LITERAL);
|
|
905
|
-
if (!n && !
|
|
905
|
+
if (!n && !be(this.peek()))
|
|
906
906
|
return this.addToken(c.NUMERIC_LITERAL);
|
|
907
|
-
if (!n && !
|
|
907
|
+
if (!n && !ke(this.peek()))
|
|
908
908
|
break;
|
|
909
909
|
this.advance();
|
|
910
910
|
}
|
|
911
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
911
|
+
for (; !this.isAtEnd() && (this.check(".") || be(this.peek())); )
|
|
912
912
|
this.advance();
|
|
913
913
|
const s = this.createToken(c.NUMERIC_LITERAL, !0);
|
|
914
914
|
this.tokens.push(s), this.errors.push(new u(o.UNKNOWN_TOKEN, "Invalid number", s));
|
|
915
915
|
}
|
|
916
916
|
colorLiteral() {
|
|
917
|
-
for (; !this.isAtEnd() &&
|
|
917
|
+
for (; !this.isAtEnd() && be(this.peek()); )
|
|
918
918
|
this.advance();
|
|
919
919
|
this.addToken(c.COLOR_LITERAL);
|
|
920
920
|
}
|
|
@@ -946,7 +946,7 @@ class rn {
|
|
|
946
946
|
case "u": {
|
|
947
947
|
let e = "";
|
|
948
948
|
for (let s = 0; s <= 3; s += 1) {
|
|
949
|
-
if (this.isAtEnd() || !
|
|
949
|
+
if (this.isAtEnd() || !be(this.peek()))
|
|
950
950
|
return `\\u${e}`;
|
|
951
951
|
e += this.advance();
|
|
952
952
|
}
|
|
@@ -957,7 +957,7 @@ class rn {
|
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
|
-
var
|
|
960
|
+
var ye = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ye || {});
|
|
961
961
|
class an {
|
|
962
962
|
constructor() {
|
|
963
963
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
@@ -970,7 +970,7 @@ class an {
|
|
|
970
970
|
return e === 0 && (this.numberOfNestedLBrackets -= 1), e === 1 && (this.numberOfNestedLParens -= 1), e === 2 && (this.numberOfNestedLBraces -= 1), e;
|
|
971
971
|
}
|
|
972
972
|
top() {
|
|
973
|
-
return
|
|
973
|
+
return I.last(this.stack);
|
|
974
974
|
}
|
|
975
975
|
isWithinGroupExpressionContext() {
|
|
976
976
|
return this.numberOfNestedLParens > 0;
|
|
@@ -1056,7 +1056,7 @@ class ln {
|
|
|
1056
1056
|
break;
|
|
1057
1057
|
E(n), this.advance();
|
|
1058
1058
|
}
|
|
1059
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1059
|
+
}, this.blockExpression = this.contextStack.withContextDo(ye.BlockExpression, () => {
|
|
1060
1060
|
const n = { body: [] }, i = () => this.nodeFactory.create(ee, n);
|
|
1061
1061
|
try {
|
|
1062
1062
|
this.consume("Expect an opening brace '{'", c.LBRACE), n.blockOpenBrace = this.previous();
|
|
@@ -1095,7 +1095,7 @@ class ln {
|
|
|
1095
1095
|
break;
|
|
1096
1096
|
E(n), this.advance();
|
|
1097
1097
|
}
|
|
1098
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1098
|
+
}, this.tupleExpression = this.contextStack.withContextDo(ye.GroupExpression, () => {
|
|
1099
1099
|
const n = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Xe, {
|
|
1100
1100
|
groupOpenParen: n.tupleOpenParen,
|
|
1101
1101
|
groupCloseParen: n.tupleCloseParen,
|
|
@@ -1126,7 +1126,7 @@ class ln {
|
|
|
1126
1126
|
} catch (a) {
|
|
1127
1127
|
if (!(a instanceof d))
|
|
1128
1128
|
throw a;
|
|
1129
|
-
if (a.partialNode instanceof
|
|
1129
|
+
if (a.partialNode instanceof y && n.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1130
1130
|
throw new d(a.token, r(), a.handlerContext);
|
|
1131
1131
|
this.synchronizeTuple();
|
|
1132
1132
|
}
|
|
@@ -1147,7 +1147,7 @@ class ln {
|
|
|
1147
1147
|
break;
|
|
1148
1148
|
E(n), this.advance();
|
|
1149
1149
|
}
|
|
1150
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
1150
|
+
}, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
|
|
1151
1151
|
const n = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, n);
|
|
1152
1152
|
try {
|
|
1153
1153
|
this.consume("Expect an opening bracket '['", c.LBRACKET), n.listOpenBracket = this.previous();
|
|
@@ -1174,7 +1174,7 @@ class ln {
|
|
|
1174
1174
|
} catch (r) {
|
|
1175
1175
|
if (!(r instanceof d))
|
|
1176
1176
|
throw r;
|
|
1177
|
-
if (r.partialNode instanceof
|
|
1177
|
+
if (r.partialNode instanceof y && n.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1178
1178
|
throw new d(r.token, i(), r.handlerContext);
|
|
1179
1179
|
this.synchronizeList();
|
|
1180
1180
|
}
|
|
@@ -1215,10 +1215,10 @@ class ln {
|
|
|
1215
1215
|
return this.current >= this.tokens.length || this.tokens[this.current].kind === c.EOF;
|
|
1216
1216
|
}
|
|
1217
1217
|
advance() {
|
|
1218
|
-
return this.isAtEnd() ?
|
|
1218
|
+
return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
|
|
1219
1219
|
}
|
|
1220
1220
|
peek(e = 0) {
|
|
1221
|
-
return e + this.current >= this.tokens.length ?
|
|
1221
|
+
return e + this.current >= this.tokens.length ? I.last(this.tokens) : this.tokens[this.current + e];
|
|
1222
1222
|
}
|
|
1223
1223
|
match(...e) {
|
|
1224
1224
|
const s = this.check(...e);
|
|
@@ -1265,8 +1265,8 @@ class ln {
|
|
|
1265
1265
|
this.tokens = e;
|
|
1266
1266
|
}
|
|
1267
1267
|
parse() {
|
|
1268
|
-
const e = this.program(), s = this.advance(), n = this.nodeFactory.create(
|
|
1269
|
-
return this.gatherInvalid(), new
|
|
1268
|
+
const e = this.program(), s = this.advance(), n = this.nodeFactory.create(C, { body: e, eof: s });
|
|
1269
|
+
return this.gatherInvalid(), new F({ ast: n, tokens: this.tokens }, this.errors);
|
|
1270
1270
|
}
|
|
1271
1271
|
/* Parsing and synchronizing ProgramNode */
|
|
1272
1272
|
program() {
|
|
@@ -1365,7 +1365,7 @@ class ln {
|
|
|
1365
1365
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1366
1366
|
expression() {
|
|
1367
1367
|
const e = { args: [] }, s = () => en(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1368
|
-
this.nodeFactory.create(
|
|
1368
|
+
this.nodeFactory.create(x, e)
|
|
1369
1369
|
);
|
|
1370
1370
|
try {
|
|
1371
1371
|
e.callee = this.normalExpression();
|
|
@@ -1422,12 +1422,12 @@ class ln {
|
|
|
1422
1422
|
if (Ve(this.previous()))
|
|
1423
1423
|
break;
|
|
1424
1424
|
try {
|
|
1425
|
-
s = this.nodeFactory.create(
|
|
1425
|
+
s = this.nodeFactory.create(he, {
|
|
1426
1426
|
expression: s,
|
|
1427
1427
|
indexer: this.listExpression()
|
|
1428
1428
|
});
|
|
1429
1429
|
} catch (i) {
|
|
1430
|
-
throw i instanceof d ? (s = this.nodeFactory.create(
|
|
1430
|
+
throw i instanceof d ? (s = this.nodeFactory.create(he, {
|
|
1431
1431
|
expression: s,
|
|
1432
1432
|
indexer: i.partialNode
|
|
1433
1433
|
}), new d(i.token, s, i.handlerContext)) : i;
|
|
@@ -1437,7 +1437,7 @@ class ln {
|
|
|
1437
1437
|
if (r.left !== null) {
|
|
1438
1438
|
if (r.left <= e)
|
|
1439
1439
|
break;
|
|
1440
|
-
this.advance(), s = this.nodeFactory.create(
|
|
1440
|
+
this.advance(), s = this.nodeFactory.create(De, {
|
|
1441
1441
|
expression: s,
|
|
1442
1442
|
op: i
|
|
1443
1443
|
});
|
|
@@ -1545,17 +1545,17 @@ class ln {
|
|
|
1545
1545
|
c.STRING_LITERAL,
|
|
1546
1546
|
c.NUMERIC_LITERAL
|
|
1547
1547
|
))
|
|
1548
|
-
return this.nodeFactory.create(
|
|
1549
|
-
expression: this.nodeFactory.create(
|
|
1548
|
+
return this.nodeFactory.create(R, {
|
|
1549
|
+
expression: this.nodeFactory.create(pe, { literal: this.previous() })
|
|
1550
1550
|
});
|
|
1551
1551
|
if (this.match(c.QUOTED_STRING, c.IDENTIFIER))
|
|
1552
|
-
return this.nodeFactory.create(
|
|
1553
|
-
expression: this.nodeFactory.create(
|
|
1552
|
+
return this.nodeFactory.create(R, {
|
|
1553
|
+
expression: this.nodeFactory.create(X, { variable: this.previous() })
|
|
1554
1554
|
});
|
|
1555
1555
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1556
1556
|
this.peek(),
|
|
1557
|
-
this.nodeFactory.create(
|
|
1558
|
-
expression: this.nodeFactory.create(
|
|
1557
|
+
this.nodeFactory.create(R, {
|
|
1558
|
+
expression: this.nodeFactory.create(X, {})
|
|
1559
1559
|
}),
|
|
1560
1560
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1561
1561
|
);
|
|
@@ -1652,107 +1652,107 @@ const pn = {
|
|
|
1652
1652
|
function ut(t) {
|
|
1653
1653
|
return pn[t.value] || { left: null, right: null };
|
|
1654
1654
|
}
|
|
1655
|
-
var
|
|
1656
|
-
function
|
|
1655
|
+
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 || {});
|
|
1656
|
+
function de(t) {
|
|
1657
1657
|
var s;
|
|
1658
1658
|
const e = (s = t == null ? void 0 : t.type) == null ? void 0 : s.value.toLowerCase();
|
|
1659
1659
|
switch (e) {
|
|
1660
|
-
case
|
|
1661
|
-
case
|
|
1662
|
-
case
|
|
1663
|
-
case
|
|
1664
|
-
case
|
|
1665
|
-
case
|
|
1666
|
-
case
|
|
1667
|
-
return new
|
|
1660
|
+
case b.Enum:
|
|
1661
|
+
case b.Table:
|
|
1662
|
+
case b.Indexes:
|
|
1663
|
+
case b.Note:
|
|
1664
|
+
case b.Project:
|
|
1665
|
+
case b.Ref:
|
|
1666
|
+
case b.TableGroup:
|
|
1667
|
+
return new S(e);
|
|
1668
1668
|
default:
|
|
1669
1669
|
return new A();
|
|
1670
1670
|
}
|
|
1671
1671
|
}
|
|
1672
|
-
function
|
|
1672
|
+
function Ee(t) {
|
|
1673
1673
|
if (!He(t))
|
|
1674
|
-
return new
|
|
1675
|
-
const e =
|
|
1676
|
-
return e ? (e.push(t.rightExpression), new
|
|
1674
|
+
return new S([t]);
|
|
1675
|
+
const e = Ee(t.leftExpression).unwrap_or(void 0);
|
|
1676
|
+
return e ? (e.push(t.rightExpression), new S(e)) : new A();
|
|
1677
1677
|
}
|
|
1678
|
-
function
|
|
1678
|
+
function W(t) {
|
|
1679
1679
|
if (t === void 0)
|
|
1680
1680
|
return new A();
|
|
1681
|
-
const e =
|
|
1681
|
+
const e = Ee(t).unwrap_or(void 0);
|
|
1682
1682
|
if (!e)
|
|
1683
1683
|
return new A();
|
|
1684
1684
|
const s = [];
|
|
1685
1685
|
for (const n of e) {
|
|
1686
|
-
const i =
|
|
1686
|
+
const i = G(n).unwrap_or(void 0);
|
|
1687
1687
|
if (!i)
|
|
1688
1688
|
return new A();
|
|
1689
1689
|
s.push(i);
|
|
1690
1690
|
}
|
|
1691
|
-
return new
|
|
1691
|
+
return new S(s);
|
|
1692
1692
|
}
|
|
1693
|
-
function
|
|
1693
|
+
function Le(t) {
|
|
1694
1694
|
if (t === void 0)
|
|
1695
1695
|
return new A();
|
|
1696
|
-
const e =
|
|
1696
|
+
const e = Ee(t).unwrap_or(void 0);
|
|
1697
1697
|
if (!e || e.length === 0)
|
|
1698
1698
|
return new A();
|
|
1699
1699
|
const s = [];
|
|
1700
1700
|
let n;
|
|
1701
|
-
if (!M(
|
|
1701
|
+
if (!M(I.last(e))) {
|
|
1702
1702
|
const i = e.pop();
|
|
1703
1703
|
if (xt(i))
|
|
1704
1704
|
n = i.elementList.map(
|
|
1705
|
-
(r) =>
|
|
1705
|
+
(r) => V(r).unwrap()
|
|
1706
1706
|
);
|
|
1707
1707
|
else
|
|
1708
1708
|
return new A();
|
|
1709
1709
|
}
|
|
1710
1710
|
for (const i of e) {
|
|
1711
|
-
const r =
|
|
1711
|
+
const r = G(i).unwrap_or(void 0);
|
|
1712
1712
|
if (!r)
|
|
1713
1713
|
return new A();
|
|
1714
1714
|
s.push(r);
|
|
1715
1715
|
}
|
|
1716
|
-
return new
|
|
1716
|
+
return new S({
|
|
1717
1717
|
variables: s,
|
|
1718
1718
|
tupleElements: n
|
|
1719
1719
|
});
|
|
1720
1720
|
}
|
|
1721
|
-
function
|
|
1722
|
-
return M(t) ? new
|
|
1721
|
+
function G(t) {
|
|
1722
|
+
return M(t) ? new S(t.expression.variable.value) : new A();
|
|
1723
1723
|
}
|
|
1724
1724
|
function Ge(t) {
|
|
1725
1725
|
if (ht(t))
|
|
1726
|
-
return t instanceof K ? new
|
|
1726
|
+
return t instanceof K ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1727
1727
|
if (t instanceof J && t.elementList.every(ht)) {
|
|
1728
1728
|
const e = t.elementList.filter(
|
|
1729
1729
|
(n) => n instanceof K
|
|
1730
1730
|
), s = t.elementList.filter(M);
|
|
1731
|
-
return new
|
|
1731
|
+
return new S({ functional: e, nonFunctional: s });
|
|
1732
1732
|
}
|
|
1733
1733
|
return new A();
|
|
1734
1734
|
}
|
|
1735
|
-
function
|
|
1735
|
+
function V(t) {
|
|
1736
1736
|
var s;
|
|
1737
1737
|
const e = (s = t == null ? void 0 : t.expression.variable) == null ? void 0 : s.value;
|
|
1738
|
-
return e === void 0 ? new A() : new
|
|
1738
|
+
return e === void 0 ? new A() : new S(e);
|
|
1739
1739
|
}
|
|
1740
1740
|
function Y(t) {
|
|
1741
|
-
return
|
|
1741
|
+
return $(t) ? t.expression instanceof X ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
|
|
1742
1742
|
}
|
|
1743
1743
|
function dn(t) {
|
|
1744
1744
|
var e;
|
|
1745
|
-
return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 :
|
|
1745
|
+
return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : Le(t.leftExpression).and_then(() => Le(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1746
1746
|
}
|
|
1747
1747
|
function En(t) {
|
|
1748
|
-
const e =
|
|
1748
|
+
const e = Le(t.leftExpression), s = Le(t.rightExpression);
|
|
1749
1749
|
if (!e.isOk() || !s.isOk())
|
|
1750
1750
|
return !1;
|
|
1751
1751
|
const { tupleElements: n } = e.unwrap(), { tupleElements: i } = s.unwrap();
|
|
1752
1752
|
return (n == null ? void 0 : n.length) === (i == null ? void 0 : i.length);
|
|
1753
1753
|
}
|
|
1754
1754
|
function ht(t) {
|
|
1755
|
-
return t instanceof
|
|
1755
|
+
return t instanceof R && t.expression instanceof X || t instanceof K;
|
|
1756
1756
|
}
|
|
1757
1757
|
function Nn(t, e) {
|
|
1758
1758
|
var i, r, a, l;
|
|
@@ -1761,9 +1761,9 @@ function Nn(t, e) {
|
|
|
1761
1761
|
for (; s; ) {
|
|
1762
1762
|
if ((r = (i = s.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1763
1763
|
return (a = s.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1764
|
-
if (((l = s.symbol) == null ? void 0 : l.declaration) instanceof
|
|
1764
|
+
if (((l = s.symbol) == null ? void 0 : l.declaration) instanceof C && n)
|
|
1765
1765
|
return s.symbol;
|
|
1766
|
-
if (s instanceof
|
|
1766
|
+
if (s instanceof C)
|
|
1767
1767
|
return;
|
|
1768
1768
|
s = s.parent;
|
|
1769
1769
|
}
|
|
@@ -1776,7 +1776,7 @@ class mn {
|
|
|
1776
1776
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1777
1777
|
}
|
|
1778
1778
|
validateContext() {
|
|
1779
|
-
return this.declarationNode.parent instanceof
|
|
1779
|
+
return this.declarationNode.parent instanceof C || de(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)] : [];
|
|
1780
1780
|
}
|
|
1781
1781
|
validateName(e) {
|
|
1782
1782
|
return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1793,10 +1793,10 @@ class mn {
|
|
|
1793
1793
|
if (e instanceof ee)
|
|
1794
1794
|
return [new u(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1795
1795
|
const s = [];
|
|
1796
|
-
return
|
|
1796
|
+
return $(e.callee) || s.push(new u(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && s.push(...e.args.map((n) => new u(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", n))), s;
|
|
1797
1797
|
}
|
|
1798
1798
|
}
|
|
1799
|
-
class
|
|
1799
|
+
class _e {
|
|
1800
1800
|
constructor() {
|
|
1801
1801
|
this.table = /* @__PURE__ */ new Map();
|
|
1802
1802
|
}
|
|
@@ -1831,8 +1831,8 @@ class Tn {
|
|
|
1831
1831
|
}
|
|
1832
1832
|
registerElement() {
|
|
1833
1833
|
const e = [];
|
|
1834
|
-
this.declarationNode.symbol = this.symbolFactory.create(qt, { declaration: this.declarationNode, symbolTable: new
|
|
1835
|
-
const { name: s } = this.declarationNode, n =
|
|
1834
|
+
this.declarationNode.symbol = this.symbolFactory.create(qt, { declaration: this.declarationNode, symbolTable: new _e() });
|
|
1835
|
+
const { name: s } = this.declarationNode, n = W(s);
|
|
1836
1836
|
if (n.isOk()) {
|
|
1837
1837
|
const i = n.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = je(r);
|
|
1838
1838
|
a.has(l) && e.push(new u(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, s)), a.set(l, this.declarationNode.symbol);
|
|
@@ -1845,15 +1845,15 @@ class Tn {
|
|
|
1845
1845
|
validateBody(e) {
|
|
1846
1846
|
if (!e)
|
|
1847
1847
|
return [];
|
|
1848
|
-
if (e instanceof
|
|
1848
|
+
if (e instanceof x)
|
|
1849
1849
|
return this.validateFields([e]);
|
|
1850
|
-
const [s, n] =
|
|
1850
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
1851
1851
|
return [...this.validateFields(s), ...this.validateSubElements(n)];
|
|
1852
1852
|
}
|
|
1853
1853
|
validateFields(e) {
|
|
1854
1854
|
return e.length === 0 ? [new u(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((s) => {
|
|
1855
1855
|
const n = [];
|
|
1856
|
-
return s.callee && !M(s.callee) && n.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", s.callee)),
|
|
1856
|
+
return s.callee && !M(s.callee) && n.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", s.callee)), I.last(s.args) instanceof U && n.push(...this.validateFieldSetting(I.last(s.args))), s.args.length > 1 && n.push(...s.args.map((i) => new u(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), n.push(...this.registerField(s)), n;
|
|
1857
1857
|
});
|
|
1858
1858
|
}
|
|
1859
1859
|
validateFieldSetting(e) {
|
|
@@ -1863,7 +1863,7 @@ class Tn {
|
|
|
1863
1863
|
switch (r) {
|
|
1864
1864
|
case "note":
|
|
1865
1865
|
a.length > 1 && a.forEach((l) => n.push(new u(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
1866
|
-
|
|
1866
|
+
$(l.value) || n.push(new u(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
|
|
1867
1867
|
});
|
|
1868
1868
|
break;
|
|
1869
1869
|
default:
|
|
@@ -1882,7 +1882,7 @@ class Tn {
|
|
|
1882
1882
|
}
|
|
1883
1883
|
registerField(e) {
|
|
1884
1884
|
if (e.callee && M(e.callee)) {
|
|
1885
|
-
const s =
|
|
1885
|
+
const s = V(e.callee).unwrap(), n = Ye(s), i = this.symbolFactory.create(Ht, { declaration: e });
|
|
1886
1886
|
e.symbol = i;
|
|
1887
1887
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1888
1888
|
if (r.has(n)) {
|
|
@@ -1905,7 +1905,7 @@ class bn {
|
|
|
1905
1905
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1906
1906
|
}
|
|
1907
1907
|
validateContext() {
|
|
1908
|
-
return this.declarationNode.parent instanceof
|
|
1908
|
+
return this.declarationNode.parent instanceof C || de(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)] : [];
|
|
1909
1909
|
}
|
|
1910
1910
|
validateName(e) {
|
|
1911
1911
|
return e ? [new u(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
@@ -1919,9 +1919,9 @@ class bn {
|
|
|
1919
1919
|
validateBody(e) {
|
|
1920
1920
|
if (!e)
|
|
1921
1921
|
return [];
|
|
1922
|
-
if (e instanceof
|
|
1922
|
+
if (e instanceof x)
|
|
1923
1923
|
return [new u(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1924
|
-
const [s, n] =
|
|
1924
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
1925
1925
|
return [...this.validateFields(s), ...this.validateSubElements(n)];
|
|
1926
1926
|
}
|
|
1927
1927
|
validateFields(e) {
|
|
@@ -1929,7 +1929,7 @@ class bn {
|
|
|
1929
1929
|
if (!s.callee)
|
|
1930
1930
|
return [];
|
|
1931
1931
|
const n = [], i = [s.callee, ...s.args];
|
|
1932
|
-
return
|
|
1932
|
+
return I.last(i) instanceof U && n.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1933
1933
|
for (; r instanceof H; )
|
|
1934
1934
|
r.argumentList && !Ge(r.argumentList).isOk() && n.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;
|
|
1935
1935
|
Ge(r).isOk() || n.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));
|
|
@@ -1944,7 +1944,7 @@ class bn {
|
|
|
1944
1944
|
case "note":
|
|
1945
1945
|
case "name":
|
|
1946
1946
|
a.length > 1 && a.forEach((l) => n.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1947
|
-
|
|
1947
|
+
$(l.value) || n.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
|
|
1948
1948
|
});
|
|
1949
1949
|
break;
|
|
1950
1950
|
case "unique":
|
|
@@ -1981,7 +1981,7 @@ class In {
|
|
|
1981
1981
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1982
1982
|
}
|
|
1983
1983
|
validateContext() {
|
|
1984
|
-
return this.declarationNode.parent instanceof
|
|
1984
|
+
return this.declarationNode.parent instanceof C || ![b.Table, b.Project].includes(de(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)] : [];
|
|
1985
1985
|
}
|
|
1986
1986
|
validateName(e) {
|
|
1987
1987
|
return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
@@ -1995,14 +1995,14 @@ class In {
|
|
|
1995
1995
|
validateBody(e) {
|
|
1996
1996
|
if (!e)
|
|
1997
1997
|
return [];
|
|
1998
|
-
if (e instanceof
|
|
1998
|
+
if (e instanceof x)
|
|
1999
1999
|
return this.validateFields([e]);
|
|
2000
|
-
const [s, n] =
|
|
2000
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
2001
2001
|
return [...this.validateFields(s), ...this.validateSubElements(n)];
|
|
2002
2002
|
}
|
|
2003
2003
|
validateFields(e) {
|
|
2004
2004
|
const s = [];
|
|
2005
|
-
return e.length === 0 ? [new u(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((n) => s.push(new u(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", n))),
|
|
2005
|
+
return e.length === 0 ? [new u(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((n) => s.push(new u(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", n))), $(e[0].callee) || s.push(new u(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && s.push(...e[0].args.map((n) => new u(o.INVALID_NOTE, "A Note can only contain one quoted string", n))), s);
|
|
2006
2006
|
}
|
|
2007
2007
|
validateSubElements(e) {
|
|
2008
2008
|
return e.flatMap((s) => {
|
|
@@ -2024,7 +2024,7 @@ class Ln {
|
|
|
2024
2024
|
return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2025
2025
|
}
|
|
2026
2026
|
validateName(e) {
|
|
2027
|
-
return e ?
|
|
2027
|
+
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)] : [];
|
|
2028
2028
|
}
|
|
2029
2029
|
validateAlias(e) {
|
|
2030
2030
|
return e ? [new u(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
@@ -2035,9 +2035,9 @@ class Ln {
|
|
|
2035
2035
|
validateBody(e) {
|
|
2036
2036
|
if (!e)
|
|
2037
2037
|
return [];
|
|
2038
|
-
if (e instanceof
|
|
2038
|
+
if (e instanceof x)
|
|
2039
2039
|
return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2040
|
-
const [s, n] =
|
|
2040
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
2041
2041
|
return [
|
|
2042
2042
|
...s.map((i) => new u(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2043
2043
|
...this.validateSubElements(n)
|
|
@@ -2060,10 +2060,10 @@ class gn {
|
|
|
2060
2060
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2061
2061
|
}
|
|
2062
2062
|
validateContext() {
|
|
2063
|
-
return this.declarationNode.parent instanceof
|
|
2063
|
+
return this.declarationNode.parent instanceof C || de(this.declarationNode.parent).unwrap_or(void 0) === b.Table ? [] : [new u(o.INVALID_REF_CONTEXT, "A Ref must appear top-level or inside a table", this.declarationNode)];
|
|
2064
2064
|
}
|
|
2065
2065
|
validateName(e) {
|
|
2066
|
-
return e ?
|
|
2066
|
+
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)] : [];
|
|
2067
2067
|
}
|
|
2068
2068
|
validateAlias(e) {
|
|
2069
2069
|
return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
@@ -2074,9 +2074,9 @@ class gn {
|
|
|
2074
2074
|
validateBody(e) {
|
|
2075
2075
|
if (!e)
|
|
2076
2076
|
return [];
|
|
2077
|
-
if (e instanceof
|
|
2077
|
+
if (e instanceof x)
|
|
2078
2078
|
return this.validateFields([e]);
|
|
2079
|
-
const [s, n] =
|
|
2079
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
2080
2080
|
return [...this.validateFields(s), ...this.validateSubElements(n)];
|
|
2081
2081
|
}
|
|
2082
2082
|
validateFields(e) {
|
|
@@ -2084,7 +2084,7 @@ class gn {
|
|
|
2084
2084
|
return [new u(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2085
2085
|
const s = [];
|
|
2086
2086
|
return e.length > 1 && s.push(...e.slice(1).map((n) => new u(o.REF_REDEFINED, "A Ref can only contain one binary relationship", n))), e.forEach((n) => {
|
|
2087
|
-
n.callee && !dn(n.callee) && s.push(new u(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", n.callee)), n.callee && !En(n.callee) && s.push(new u(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", n.callee)),
|
|
2087
|
+
n.callee && !dn(n.callee) && s.push(new u(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", n.callee)), n.callee && !En(n.callee) && s.push(new u(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", n.callee)), I.last(n.args) instanceof U && this.validateFieldSettings(I.last(n.args)), n.args.length > 1 && s.push(...n.args.map((i) => new u(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
|
|
2088
2088
|
}), s;
|
|
2089
2089
|
}
|
|
2090
2090
|
validateFieldSettings(e) {
|
|
@@ -2117,7 +2117,7 @@ function _n(t) {
|
|
|
2117
2117
|
if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof te))
|
|
2118
2118
|
return !1;
|
|
2119
2119
|
let e;
|
|
2120
|
-
if (t instanceof te ? e =
|
|
2120
|
+
if (t instanceof te ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2121
2121
|
switch (e.toLowerCase()) {
|
|
2122
2122
|
case "cascade":
|
|
2123
2123
|
case "no action":
|
|
@@ -2141,10 +2141,10 @@ class An {
|
|
|
2141
2141
|
return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2142
2142
|
}
|
|
2143
2143
|
validateName(e) {
|
|
2144
|
-
return e ? e instanceof
|
|
2144
|
+
return e ? e instanceof he ? [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)];
|
|
2145
2145
|
}
|
|
2146
2146
|
validateAlias(e) {
|
|
2147
|
-
return e ?
|
|
2147
|
+
return e ? xn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2148
2148
|
}
|
|
2149
2149
|
validateSettingList(e) {
|
|
2150
2150
|
const s = z(e), n = s.getErrors(), i = s.getValue();
|
|
@@ -2153,12 +2153,12 @@ class An {
|
|
|
2153
2153
|
switch (r) {
|
|
2154
2154
|
case "headercolor":
|
|
2155
2155
|
a.length > 1 && n.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
|
|
2156
|
-
|
|
2156
|
+
kn(l.value) || n.push(new u(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
|
|
2157
2157
|
});
|
|
2158
2158
|
break;
|
|
2159
2159
|
case "note":
|
|
2160
2160
|
a.length > 1 && n.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
2161
|
-
|
|
2161
|
+
$(l.value) || n.push(new u(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
|
|
2162
2162
|
});
|
|
2163
2163
|
break;
|
|
2164
2164
|
default:
|
|
@@ -2169,24 +2169,24 @@ class An {
|
|
|
2169
2169
|
}
|
|
2170
2170
|
registerElement() {
|
|
2171
2171
|
const e = [];
|
|
2172
|
-
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new
|
|
2173
|
-
const { name: s, alias: n } = this.declarationNode, i =
|
|
2172
|
+
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new _e() });
|
|
2173
|
+
const { name: s, alias: n } = this.declarationNode, i = W(s);
|
|
2174
2174
|
if (i.isOk()) {
|
|
2175
|
-
const r = i.unwrap(), a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p =
|
|
2175
|
+
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
|
|
2176
2176
|
l.has(p) && e.push(new u(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, s)), l.set(p, this.declarationNode.symbol);
|
|
2177
2177
|
}
|
|
2178
|
-
if (n &&
|
|
2179
|
-
const r =
|
|
2180
|
-
this.publicSymbolTable.has(
|
|
2178
|
+
if (n && Pe(n) && !wn(n.expression.variable.value, i.unwrap_or([]))) {
|
|
2179
|
+
const r = V(n).unwrap(), a = xe(r);
|
|
2180
|
+
this.publicSymbolTable.has(a) && e.push(new u(o.DUPLICATE_NAME, `Table name '${r}' already exists`, s)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2181
2181
|
}
|
|
2182
2182
|
return e;
|
|
2183
2183
|
}
|
|
2184
2184
|
validateBody(e) {
|
|
2185
2185
|
if (!e)
|
|
2186
2186
|
return [];
|
|
2187
|
-
if (e instanceof
|
|
2187
|
+
if (e instanceof x)
|
|
2188
2188
|
return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2189
|
-
const [s, n] =
|
|
2189
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
2190
2190
|
return [...this.validateFields(s), ...this.validateSubElements(n)];
|
|
2191
2191
|
}
|
|
2192
2192
|
validateFields(e) {
|
|
@@ -2194,14 +2194,14 @@ class An {
|
|
|
2194
2194
|
if (!s.callee)
|
|
2195
2195
|
return [];
|
|
2196
2196
|
const n = [];
|
|
2197
|
-
s.args.length === 0 && n.push(new u(o.INVALID_COLUMN, "A column must have a type", s.callee)), M(s.callee) || n.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", s.callee)), s.args[0] && !
|
|
2197
|
+
s.args.length === 0 && n.push(new u(o.INVALID_COLUMN, "A column must have a type", s.callee)), M(s.callee) || n.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", s.callee)), s.args[0] && !vn(s.args[0]) && n.push(new u(o.INVALID_COLUMN_TYPE, "Invalid column type", s.args[0]));
|
|
2198
2198
|
const i = s.args.slice(1);
|
|
2199
2199
|
return n.push(...this.validateFieldSetting(i)), n.push(...this.registerField(s)), n;
|
|
2200
2200
|
});
|
|
2201
2201
|
}
|
|
2202
2202
|
registerField(e) {
|
|
2203
2203
|
if (e.callee && M(e.callee)) {
|
|
2204
|
-
const s =
|
|
2204
|
+
const s = V(e.callee).unwrap(), n = We(s), i = this.symbolFactory.create(Jt, { declaration: e });
|
|
2205
2205
|
e.symbol = i;
|
|
2206
2206
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2207
2207
|
if (r.has(n)) {
|
|
@@ -2217,15 +2217,15 @@ class An {
|
|
|
2217
2217
|
}
|
|
2218
2218
|
// This is needed to support legacy inline settings
|
|
2219
2219
|
validateFieldSetting(e) {
|
|
2220
|
-
if (!e.slice(0, -1).every(
|
|
2220
|
+
if (!e.slice(0, -1).every(fe) || !e.slice(-1).every((p) => fe(p) || p instanceof U))
|
|
2221
2221
|
return [...e.map((p) => new u(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2222
2222
|
if (e.length === 0)
|
|
2223
2223
|
return [];
|
|
2224
2224
|
let s;
|
|
2225
|
-
|
|
2225
|
+
I.last(e) instanceof U && (s = e.pop());
|
|
2226
2226
|
const n = z(s), i = n.getErrors(), r = n.getValue();
|
|
2227
2227
|
for (const p of e) {
|
|
2228
|
-
const h =
|
|
2228
|
+
const h = V(p).unwrap_or("").toLowerCase();
|
|
2229
2229
|
if (h !== "pk" && h !== "unique") {
|
|
2230
2230
|
i.push(new u(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2231
2231
|
continue;
|
|
@@ -2239,12 +2239,12 @@ class An {
|
|
|
2239
2239
|
switch (p) {
|
|
2240
2240
|
case "note":
|
|
2241
2241
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2242
|
-
|
|
2242
|
+
$(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2243
2243
|
});
|
|
2244
2244
|
break;
|
|
2245
2245
|
case "ref":
|
|
2246
2246
|
h.forEach((f) => {
|
|
2247
|
-
|
|
2247
|
+
On(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
|
|
2248
2248
|
});
|
|
2249
2249
|
break;
|
|
2250
2250
|
case "primary key":
|
|
@@ -2281,7 +2281,7 @@ class An {
|
|
|
2281
2281
|
break;
|
|
2282
2282
|
case "default":
|
|
2283
2283
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
|
|
2284
|
-
|
|
2284
|
+
Sn(f.value) || i.push(new u(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
|
|
2285
2285
|
});
|
|
2286
2286
|
break;
|
|
2287
2287
|
default:
|
|
@@ -2303,23 +2303,26 @@ class An {
|
|
|
2303
2303
|
return n.length > 1 && (s.push(...n.map((i) => new u(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), s.push()), s;
|
|
2304
2304
|
}
|
|
2305
2305
|
}
|
|
2306
|
-
function
|
|
2307
|
-
if (!(t instanceof H || He(t) || t instanceof
|
|
2306
|
+
function vn(t) {
|
|
2307
|
+
if (!(t instanceof H || He(t) || t instanceof R || t instanceof he))
|
|
2308
2308
|
return !1;
|
|
2309
2309
|
if (t instanceof H) {
|
|
2310
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((s) => le(s) ||
|
|
2310
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((s) => le(s) || $(s) || fe(s)))
|
|
2311
2311
|
return !1;
|
|
2312
2312
|
t = t.callee;
|
|
2313
2313
|
}
|
|
2314
|
-
for (; t instanceof
|
|
2314
|
+
for (; t instanceof he; ) {
|
|
2315
2315
|
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((s) => !s.colon && !s.value && le(s.name)))
|
|
2316
2316
|
return !1;
|
|
2317
2317
|
t = t.array;
|
|
2318
2318
|
}
|
|
2319
|
-
const e =
|
|
2319
|
+
const e = W(t).unwrap_or(void 0);
|
|
2320
2320
|
return e !== void 0 && e.length > 0;
|
|
2321
2321
|
}
|
|
2322
|
-
|
|
2322
|
+
function wn(t, e) {
|
|
2323
|
+
return e.length === 1 && t === e[0];
|
|
2324
|
+
}
|
|
2325
|
+
class yn {
|
|
2323
2326
|
constructor(e, s, n) {
|
|
2324
2327
|
this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
|
|
2325
2328
|
}
|
|
@@ -2337,8 +2340,8 @@ class vn {
|
|
|
2337
2340
|
}
|
|
2338
2341
|
registerElement() {
|
|
2339
2342
|
const { name: e } = this.declarationNode;
|
|
2340
|
-
this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new
|
|
2341
|
-
const s =
|
|
2343
|
+
this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new _e() });
|
|
2344
|
+
const s = W(e);
|
|
2342
2345
|
if (s.isOk()) {
|
|
2343
2346
|
const n = s.unwrap(), i = n.pop(), r = Ze(n, this.publicSymbolTable, this.symbolFactory), a = ze(i);
|
|
2344
2347
|
if (r.has(a))
|
|
@@ -2353,15 +2356,15 @@ class vn {
|
|
|
2353
2356
|
validateBody(e) {
|
|
2354
2357
|
if (!e)
|
|
2355
2358
|
return [];
|
|
2356
|
-
if (e instanceof
|
|
2359
|
+
if (e instanceof x)
|
|
2357
2360
|
return [new u(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2358
|
-
const [s, n] =
|
|
2361
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
2359
2362
|
return [...this.validateFields(s), ...this.validateSubElements(n)];
|
|
2360
2363
|
}
|
|
2361
2364
|
validateFields(e) {
|
|
2362
2365
|
return e.flatMap((s) => {
|
|
2363
2366
|
const n = [];
|
|
2364
|
-
return s.callee && !
|
|
2367
|
+
return s.callee && !W(s.callee).isOk() && n.push(new u(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", s.callee)), this.registerField(s), s.args.length > 0 && n.push(...s.args.map((i) => new u(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), n;
|
|
2365
2368
|
});
|
|
2366
2369
|
}
|
|
2367
2370
|
validateSubElements(e) {
|
|
@@ -2374,7 +2377,7 @@ class vn {
|
|
|
2374
2377
|
}
|
|
2375
2378
|
registerField(e) {
|
|
2376
2379
|
if (e.callee && M(e.callee)) {
|
|
2377
|
-
const s =
|
|
2380
|
+
const s = V(e.callee).unwrap(), n = Qe(s), i = this.symbolFactory.create(Kt, { declaration: e });
|
|
2378
2381
|
e.symbol = i;
|
|
2379
2382
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2380
2383
|
if (r.has(n)) {
|
|
@@ -2389,35 +2392,35 @@ class vn {
|
|
|
2389
2392
|
return [];
|
|
2390
2393
|
}
|
|
2391
2394
|
}
|
|
2392
|
-
const
|
|
2395
|
+
const wt = ["-", "+"];
|
|
2393
2396
|
function ie(t) {
|
|
2394
2397
|
switch (t.type.value.toLowerCase()) {
|
|
2395
|
-
case
|
|
2398
|
+
case b.Enum:
|
|
2396
2399
|
return Tn;
|
|
2397
|
-
case
|
|
2400
|
+
case b.Table:
|
|
2398
2401
|
return An;
|
|
2399
|
-
case
|
|
2400
|
-
return
|
|
2401
|
-
case
|
|
2402
|
+
case b.TableGroup:
|
|
2403
|
+
return yn;
|
|
2404
|
+
case b.Project:
|
|
2402
2405
|
return Ln;
|
|
2403
|
-
case
|
|
2406
|
+
case b.Ref:
|
|
2404
2407
|
return gn;
|
|
2405
|
-
case
|
|
2408
|
+
case b.Note:
|
|
2406
2409
|
return In;
|
|
2407
|
-
case
|
|
2410
|
+
case b.Indexes:
|
|
2408
2411
|
return bn;
|
|
2409
2412
|
default:
|
|
2410
2413
|
return mn;
|
|
2411
2414
|
}
|
|
2412
2415
|
}
|
|
2413
2416
|
function Je(t) {
|
|
2414
|
-
return !!
|
|
2417
|
+
return !!W(t).unwrap_or(!1);
|
|
2415
2418
|
}
|
|
2416
|
-
function
|
|
2417
|
-
return
|
|
2419
|
+
function xn(t) {
|
|
2420
|
+
return Pe(t);
|
|
2418
2421
|
}
|
|
2419
|
-
function
|
|
2420
|
-
return t instanceof
|
|
2422
|
+
function Pe(t) {
|
|
2423
|
+
return t instanceof R && t.expression instanceof X;
|
|
2421
2424
|
}
|
|
2422
2425
|
function Ze(t, e, s) {
|
|
2423
2426
|
var i;
|
|
@@ -2430,7 +2433,7 @@ function Ze(t, e, s) {
|
|
|
2430
2433
|
if (a = (i = n.get(l)) == null ? void 0 : i.symbolTable, !a)
|
|
2431
2434
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2432
2435
|
} else {
|
|
2433
|
-
a = new
|
|
2436
|
+
a = new _e();
|
|
2434
2437
|
const p = s.create(_t, { symbolTable: a });
|
|
2435
2438
|
n.set(l, p);
|
|
2436
2439
|
}
|
|
@@ -2441,9 +2444,9 @@ function Ze(t, e, s) {
|
|
|
2441
2444
|
function yt(t) {
|
|
2442
2445
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2443
2446
|
}
|
|
2444
|
-
function
|
|
2447
|
+
function kn(t) {
|
|
2445
2448
|
var s;
|
|
2446
|
-
if (!(t instanceof
|
|
2449
|
+
if (!(t instanceof R) || !(t.expression instanceof pe) || ((s = t.expression.literal) == null ? void 0 : s.kind) !== c.COLOR_LITERAL)
|
|
2447
2450
|
return !1;
|
|
2448
2451
|
const e = t.expression.literal.value;
|
|
2449
2452
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
@@ -2456,19 +2459,19 @@ function xn(t) {
|
|
|
2456
2459
|
function oe(t) {
|
|
2457
2460
|
return t === void 0;
|
|
2458
2461
|
}
|
|
2459
|
-
function
|
|
2462
|
+
function Sn(t) {
|
|
2460
2463
|
var e;
|
|
2461
|
-
return !!(
|
|
2464
|
+
return !!($(t) || le(t) || fe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression) || t instanceof K);
|
|
2462
2465
|
}
|
|
2463
2466
|
function le(t) {
|
|
2464
2467
|
var e;
|
|
2465
|
-
return t instanceof
|
|
2468
|
+
return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
|
|
2466
2469
|
}
|
|
2467
|
-
function
|
|
2470
|
+
function On(t) {
|
|
2468
2471
|
var s;
|
|
2469
2472
|
if (!(t instanceof Q) || !yt((s = t.op) == null ? void 0 : s.value))
|
|
2470
2473
|
return !1;
|
|
2471
|
-
const e =
|
|
2474
|
+
const e = W(t.expression).unwrap_or(void 0);
|
|
2472
2475
|
return e !== void 0 && e.length > 0;
|
|
2473
2476
|
}
|
|
2474
2477
|
function xt(t) {
|
|
@@ -2478,23 +2481,23 @@ function z(t) {
|
|
|
2478
2481
|
var n;
|
|
2479
2482
|
const e = {}, s = [];
|
|
2480
2483
|
if (!t)
|
|
2481
|
-
return new
|
|
2484
|
+
return new F({});
|
|
2482
2485
|
for (const i of t.elementList) {
|
|
2483
2486
|
if (!i.name)
|
|
2484
2487
|
continue;
|
|
2485
|
-
if (i.name instanceof
|
|
2488
|
+
if (i.name instanceof R) {
|
|
2486
2489
|
s.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2487
2490
|
continue;
|
|
2488
2491
|
}
|
|
2489
|
-
const r = (n =
|
|
2492
|
+
const r = (n = Re(i.name).unwrap_or(void 0)) == null ? void 0 : n.toLowerCase();
|
|
2490
2493
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2491
2494
|
}
|
|
2492
|
-
return new
|
|
2495
|
+
return new F(e, s);
|
|
2493
2496
|
}
|
|
2494
2497
|
class ft {
|
|
2495
2498
|
constructor(e, s) {
|
|
2496
2499
|
this.ast = e, this.symbolFactory = s, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
|
|
2497
|
-
symbolTable: new
|
|
2500
|
+
symbolTable: new _e()
|
|
2498
2501
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2499
2502
|
}
|
|
2500
2503
|
validate() {
|
|
@@ -2509,8 +2512,8 @@ class ft {
|
|
|
2509
2512
|
);
|
|
2510
2513
|
e.push(...r.validate());
|
|
2511
2514
|
});
|
|
2512
|
-
const s = this.ast.body.filter((n) =>
|
|
2513
|
-
return s.length > 1 && s.forEach((n) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", n))), new
|
|
2515
|
+
const s = this.ast.body.filter((n) => de(n).unwrap_or(void 0) === b.Project);
|
|
2516
|
+
return s.length > 1 && s.forEach((n) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", n))), new F(this.ast, e);
|
|
2514
2517
|
}
|
|
2515
2518
|
}
|
|
2516
2519
|
class re {
|
|
@@ -2523,9 +2526,9 @@ class re {
|
|
|
2523
2526
|
bindSettingList(e, s) {
|
|
2524
2527
|
if (e)
|
|
2525
2528
|
for (const n of e.elementList) {
|
|
2526
|
-
if (n.name instanceof
|
|
2529
|
+
if (n.name instanceof R)
|
|
2527
2530
|
continue;
|
|
2528
|
-
const i =
|
|
2531
|
+
const i = Re(n.name).unwrap_or(void 0);
|
|
2529
2532
|
if (!i)
|
|
2530
2533
|
continue;
|
|
2531
2534
|
const r = s[i.toLowerCase()];
|
|
@@ -2550,7 +2553,7 @@ class re {
|
|
|
2550
2553
|
this.bindSubfield(s);
|
|
2551
2554
|
}
|
|
2552
2555
|
bindSubfield(e) {
|
|
2553
|
-
const s = [e.callee, ...e.args], n =
|
|
2556
|
+
const s = [e.callee, ...e.args], n = I.last(s);
|
|
2554
2557
|
n instanceof U && (s.pop(), this.bindSettingList(n, this.subfield.settingList));
|
|
2555
2558
|
const { argBinderRules: i } = this.subfield.arg;
|
|
2556
2559
|
for (let r = 0; r < Math.min(s.length, i.length); r += 1)
|
|
@@ -2560,12 +2563,12 @@ class re {
|
|
|
2560
2563
|
scanAndBind(e, s) {
|
|
2561
2564
|
var n, i;
|
|
2562
2565
|
if (e)
|
|
2563
|
-
if (e instanceof
|
|
2564
|
-
if (e.expression instanceof
|
|
2566
|
+
if (e instanceof R) {
|
|
2567
|
+
if (e.expression instanceof X && ((i = s.keywords) != null && i.includes((n = e.expression.variable) == null ? void 0 : n.value.toLowerCase())))
|
|
2565
2568
|
return;
|
|
2566
2569
|
this.bindFragments([e], s);
|
|
2567
2570
|
} else
|
|
2568
|
-
e instanceof q ? He(e) ? this.bindFragments(
|
|
2571
|
+
e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]), s) : (this.scanAndBind(e.leftExpression, s), this.scanAndBind(e.rightExpression, s)) : e instanceof Q ? this.scanAndBind(e.expression, s) : e instanceof De ? this.scanAndBind(e.expression, s) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, s));
|
|
2569
2572
|
}
|
|
2570
2573
|
// Bind the fragments of a member access expression
|
|
2571
2574
|
// which can be a simple expression like v1.User,
|
|
@@ -2581,14 +2584,14 @@ class re {
|
|
|
2581
2584
|
return;
|
|
2582
2585
|
const T = [];
|
|
2583
2586
|
for (; n.length && h.length; ) {
|
|
2584
|
-
const f = n.pop(), N = h.pop(),
|
|
2587
|
+
const f = n.pop(), N = h.pop(), g = V(N).unwrap();
|
|
2585
2588
|
T.unshift({
|
|
2586
|
-
index: Fe(
|
|
2589
|
+
index: Fe(g, f),
|
|
2587
2590
|
referrer: N
|
|
2588
2591
|
});
|
|
2589
2592
|
}
|
|
2590
2593
|
for (; h.length; ) {
|
|
2591
|
-
const f = h.pop(), N =
|
|
2594
|
+
const f = h.pop(), N = V(f).unwrap();
|
|
2592
2595
|
T.unshift({
|
|
2593
2596
|
index: Fe(N, i),
|
|
2594
2597
|
referrer: f
|
|
@@ -2600,7 +2603,7 @@ class re {
|
|
|
2600
2603
|
...T,
|
|
2601
2604
|
{
|
|
2602
2605
|
index: Fe(
|
|
2603
|
-
|
|
2606
|
+
V(f).unwrap(),
|
|
2604
2607
|
p
|
|
2605
2608
|
),
|
|
2606
2609
|
referrer: f
|
|
@@ -2642,7 +2645,7 @@ class re {
|
|
|
2642
2645
|
n || this.errors.push(new u(o.BINDING_ERROR, s, e));
|
|
2643
2646
|
}
|
|
2644
2647
|
}
|
|
2645
|
-
class
|
|
2648
|
+
class Dn extends re {
|
|
2646
2649
|
constructor() {
|
|
2647
2650
|
super(...arguments), this.subfield = {
|
|
2648
2651
|
arg: {
|
|
@@ -2652,7 +2655,7 @@ class On extends re {
|
|
|
2652
2655
|
}, this.settingList = {};
|
|
2653
2656
|
}
|
|
2654
2657
|
}
|
|
2655
|
-
class
|
|
2658
|
+
class Rn extends re {
|
|
2656
2659
|
constructor() {
|
|
2657
2660
|
super(...arguments), this.subfield = {
|
|
2658
2661
|
arg: {
|
|
@@ -2662,7 +2665,7 @@ class Dn extends re {
|
|
|
2662
2665
|
}, this.settingList = {};
|
|
2663
2666
|
}
|
|
2664
2667
|
}
|
|
2665
|
-
class
|
|
2668
|
+
class Pn extends re {
|
|
2666
2669
|
constructor() {
|
|
2667
2670
|
super(...arguments), this.subfield = {
|
|
2668
2671
|
arg: {
|
|
@@ -2697,7 +2700,7 @@ class Rn extends re {
|
|
|
2697
2700
|
}, this.settingList = {};
|
|
2698
2701
|
}
|
|
2699
2702
|
}
|
|
2700
|
-
class
|
|
2703
|
+
class Un extends re {
|
|
2701
2704
|
constructor() {
|
|
2702
2705
|
super(...arguments), this.subfield = {
|
|
2703
2706
|
arg: {
|
|
@@ -2707,7 +2710,7 @@ class Pn extends re {
|
|
|
2707
2710
|
}, this.settingList = {};
|
|
2708
2711
|
}
|
|
2709
2712
|
}
|
|
2710
|
-
class
|
|
2713
|
+
class Mn extends re {
|
|
2711
2714
|
constructor() {
|
|
2712
2715
|
super(...arguments), this.subfield = {
|
|
2713
2716
|
arg: {
|
|
@@ -2717,7 +2720,7 @@ class Un extends re {
|
|
|
2717
2720
|
}, this.settingList = {};
|
|
2718
2721
|
}
|
|
2719
2722
|
}
|
|
2720
|
-
class
|
|
2723
|
+
class Fn extends re {
|
|
2721
2724
|
constructor() {
|
|
2722
2725
|
super(...arguments), this.subfield = {
|
|
2723
2726
|
arg: {
|
|
@@ -2734,7 +2737,7 @@ class Mn extends re {
|
|
|
2734
2737
|
}, this.settingList = {};
|
|
2735
2738
|
}
|
|
2736
2739
|
}
|
|
2737
|
-
class
|
|
2740
|
+
class Bn extends re {
|
|
2738
2741
|
constructor() {
|
|
2739
2742
|
super(...arguments), this.subfield = {
|
|
2740
2743
|
arg: {
|
|
@@ -2762,7 +2765,7 @@ class Fn extends re {
|
|
|
2762
2765
|
}, this.settingList = {};
|
|
2763
2766
|
}
|
|
2764
2767
|
}
|
|
2765
|
-
class
|
|
2768
|
+
class Vn extends re {
|
|
2766
2769
|
constructor() {
|
|
2767
2770
|
super(...arguments), this.subfield = {
|
|
2768
2771
|
arg: {
|
|
@@ -2781,25 +2784,25 @@ class Bn extends re {
|
|
|
2781
2784
|
}
|
|
2782
2785
|
function kt(t) {
|
|
2783
2786
|
switch (t.type.value.toLowerCase()) {
|
|
2784
|
-
case
|
|
2785
|
-
return
|
|
2786
|
-
case
|
|
2787
|
-
return Fn;
|
|
2788
|
-
case I.TableGroup:
|
|
2787
|
+
case b.Enum:
|
|
2788
|
+
return Rn;
|
|
2789
|
+
case b.Table:
|
|
2789
2790
|
return Bn;
|
|
2790
|
-
case
|
|
2791
|
-
return
|
|
2792
|
-
case
|
|
2791
|
+
case b.TableGroup:
|
|
2792
|
+
return Vn;
|
|
2793
|
+
case b.Project:
|
|
2793
2794
|
return Mn;
|
|
2794
|
-
case
|
|
2795
|
+
case b.Ref:
|
|
2796
|
+
return Fn;
|
|
2797
|
+
case b.Note:
|
|
2798
|
+
return Un;
|
|
2799
|
+
case b.Indexes:
|
|
2795
2800
|
return Pn;
|
|
2796
|
-
case I.Indexes:
|
|
2797
|
-
return Rn;
|
|
2798
2801
|
default:
|
|
2799
|
-
return
|
|
2802
|
+
return Dn;
|
|
2800
2803
|
}
|
|
2801
2804
|
}
|
|
2802
|
-
class
|
|
2805
|
+
class Gn {
|
|
2803
2806
|
constructor(e) {
|
|
2804
2807
|
this.ast = e, this.errors = [];
|
|
2805
2808
|
}
|
|
@@ -2809,10 +2812,10 @@ class Vn {
|
|
|
2809
2812
|
const s = kt(e);
|
|
2810
2813
|
new s(e, this.errors).bind();
|
|
2811
2814
|
}
|
|
2812
|
-
return new
|
|
2815
|
+
return new F(this.ast, this.errors);
|
|
2813
2816
|
}
|
|
2814
2817
|
}
|
|
2815
|
-
class
|
|
2818
|
+
class Cn {
|
|
2816
2819
|
constructor(e) {
|
|
2817
2820
|
this.generator = e;
|
|
2818
2821
|
}
|
|
@@ -2820,21 +2823,21 @@ class Gn {
|
|
|
2820
2823
|
return new e(s, this.generator.nextId());
|
|
2821
2824
|
}
|
|
2822
2825
|
}
|
|
2823
|
-
class
|
|
2826
|
+
class Xn {
|
|
2824
2827
|
constructor(e, s) {
|
|
2825
|
-
this.ast = e, this.symbolFactory = new
|
|
2828
|
+
this.ast = e, this.symbolFactory = new Cn(s);
|
|
2826
2829
|
}
|
|
2827
2830
|
// Analyzing: Invoking both the validator and binder
|
|
2828
2831
|
analyze() {
|
|
2829
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((s) => new
|
|
2832
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((s) => new Gn(s).resolve());
|
|
2830
2833
|
}
|
|
2831
2834
|
// For invoking the validator only
|
|
2832
2835
|
validate() {
|
|
2833
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((s) => new
|
|
2836
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((s) => new F(s, []));
|
|
2834
2837
|
}
|
|
2835
2838
|
}
|
|
2836
2839
|
function pt(t, e) {
|
|
2837
|
-
const { variables: s, tupleElements: n } =
|
|
2840
|
+
const { variables: s, tupleElements: n } = Le(t).unwrap();
|
|
2838
2841
|
return n ? s.length === 0 ? {
|
|
2839
2842
|
schemaName: e.schemaName,
|
|
2840
2843
|
tableName: e.name,
|
|
@@ -2866,7 +2869,7 @@ function St(t) {
|
|
|
2866
2869
|
}
|
|
2867
2870
|
throw new Error("Invalid relation op");
|
|
2868
2871
|
}
|
|
2869
|
-
function
|
|
2872
|
+
function k(t) {
|
|
2870
2873
|
return {
|
|
2871
2874
|
start: {
|
|
2872
2875
|
offset: t.startPos.offset,
|
|
@@ -2878,22 +2881,17 @@ function x(t) {
|
|
|
2878
2881
|
}
|
|
2879
2882
|
function Ce(t) {
|
|
2880
2883
|
var s;
|
|
2881
|
-
const e = (s =
|
|
2884
|
+
const e = (s = Ee(t).unwrap_or(void 0)) == null ? void 0 : s.pop();
|
|
2882
2885
|
return e instanceof J ? e.elementList.map((n) => n.referee) : [e.referee];
|
|
2883
2886
|
}
|
|
2884
|
-
function
|
|
2885
|
-
|
|
2886
|
-
`).map((e) => e.trim()).join(`
|
|
2887
|
-
`);
|
|
2888
|
-
}
|
|
2889
|
-
function _e(t) {
|
|
2890
|
-
const e = j(t).unwrap();
|
|
2887
|
+
function Ae(t) {
|
|
2888
|
+
const e = W(t).unwrap();
|
|
2891
2889
|
return {
|
|
2892
2890
|
name: e.pop(),
|
|
2893
2891
|
schemaName: e
|
|
2894
2892
|
};
|
|
2895
2893
|
}
|
|
2896
|
-
function
|
|
2894
|
+
function $n(t) {
|
|
2897
2895
|
return t.expression.literal.value;
|
|
2898
2896
|
}
|
|
2899
2897
|
function Ot(t, e) {
|
|
@@ -2907,7 +2905,7 @@ function Ot(t, e) {
|
|
|
2907
2905
|
function Dt(t, e) {
|
|
2908
2906
|
if (Array.isArray(t)) {
|
|
2909
2907
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2910
|
-
return
|
|
2908
|
+
return I.zip(i, r).every(([a, l]) => a === l);
|
|
2911
2909
|
}
|
|
2912
2910
|
const s = t.id, n = e.id;
|
|
2913
2911
|
return s === n;
|
|
@@ -2917,14 +2915,14 @@ class Ke {
|
|
|
2917
2915
|
this.declarationNode = e, this.env = s, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
2918
2916
|
}
|
|
2919
2917
|
interpret() {
|
|
2920
|
-
return this.ref.token =
|
|
2918
|
+
return this.ref.token = k(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
2921
2919
|
}
|
|
2922
2920
|
interpretName(e) {
|
|
2923
|
-
const s = [], n =
|
|
2921
|
+
const s = [], n = W(this.declarationNode.name).unwrap_or([]);
|
|
2924
2922
|
return this.ref.name = n.pop() || null, n.length > 1 && s.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = n.join(".") || null, s;
|
|
2925
2923
|
}
|
|
2926
2924
|
interpretBody(e) {
|
|
2927
|
-
return e instanceof
|
|
2925
|
+
return e instanceof x ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
2928
2926
|
}
|
|
2929
2927
|
interpretField(e) {
|
|
2930
2928
|
var h, T, f, N;
|
|
@@ -2938,20 +2936,20 @@ class Ke {
|
|
|
2938
2936
|
new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
|
|
2939
2937
|
];
|
|
2940
2938
|
if (e.args[0]) {
|
|
2941
|
-
const
|
|
2942
|
-
this.ref.onDelete =
|
|
2939
|
+
const g = z(e.args[0]).getValue();
|
|
2940
|
+
this.ref.onDelete = G((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = G((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
2943
2941
|
}
|
|
2944
2942
|
const p = St(s);
|
|
2945
2943
|
return this.ref.endpoints = [
|
|
2946
2944
|
{
|
|
2947
2945
|
...pt(n, this.container),
|
|
2948
2946
|
relation: p[0],
|
|
2949
|
-
token:
|
|
2947
|
+
token: k(n)
|
|
2950
2948
|
},
|
|
2951
2949
|
{
|
|
2952
2950
|
...pt(i, this.container),
|
|
2953
2951
|
relation: p[1],
|
|
2954
|
-
token:
|
|
2952
|
+
token: k(i)
|
|
2955
2953
|
}
|
|
2956
2954
|
], this.env.refIds[l] = this.declarationNode, [];
|
|
2957
2955
|
}
|
|
@@ -2961,7 +2959,7 @@ class Rt {
|
|
|
2961
2959
|
this.declarationNode = e, this.env = s, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2962
2960
|
}
|
|
2963
2961
|
interpret() {
|
|
2964
|
-
this.table.token =
|
|
2962
|
+
this.table.token = k(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
|
|
2965
2963
|
const e = [
|
|
2966
2964
|
...this.interpretName(this.declarationNode.name),
|
|
2967
2965
|
...this.interpretAlias(this.declarationNode.alias),
|
|
@@ -2980,13 +2978,13 @@ class Rt {
|
|
|
2980
2978
|
}), this.pkColumns.forEach((s) => s.pk = !1)), e;
|
|
2981
2979
|
}
|
|
2982
2980
|
interpretName(e) {
|
|
2983
|
-
const { name: s, schemaName: n } =
|
|
2981
|
+
const { name: s, schemaName: n } = Ae(e);
|
|
2984
2982
|
return n.length > 1 ? (this.table.name = s, this.table.schemaName = n.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = s, this.table.schemaName = n.length ? n[0] : null, []);
|
|
2985
2983
|
}
|
|
2986
2984
|
interpretAlias(e) {
|
|
2987
2985
|
if (!e)
|
|
2988
2986
|
return [];
|
|
2989
|
-
const s =
|
|
2987
|
+
const s = V(e).unwrap_or(null);
|
|
2990
2988
|
return s && (this.env.aliases.push({
|
|
2991
2989
|
name: s,
|
|
2992
2990
|
kind: "table",
|
|
@@ -2999,15 +2997,15 @@ class Rt {
|
|
|
2999
2997
|
interpretSettingList(e) {
|
|
3000
2998
|
var r, a, l;
|
|
3001
2999
|
const s = z(e).getValue();
|
|
3002
|
-
this.table.headerColor = (r = s.headercolor) != null && r.length ?
|
|
3000
|
+
this.table.headerColor = (r = s.headercolor) != null && r.length ? $n((l = (a = s.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
|
|
3003
3001
|
const [n] = s.note || [], i = Y(n == null ? void 0 : n.value).unwrap_or(void 0);
|
|
3004
3002
|
return this.table.note = n && {
|
|
3005
|
-
value:
|
|
3006
|
-
token:
|
|
3003
|
+
value: i,
|
|
3004
|
+
token: k(n)
|
|
3007
3005
|
}, [];
|
|
3008
3006
|
}
|
|
3009
3007
|
interpretBody(e) {
|
|
3010
|
-
const [s, n] =
|
|
3008
|
+
const [s, n] = I.partition(e.body, (i) => i instanceof x);
|
|
3011
3009
|
return [...this.interpretFields(s), ...this.interpretSubElements(n)];
|
|
3012
3010
|
}
|
|
3013
3011
|
interpretSubElements(e) {
|
|
@@ -3016,8 +3014,8 @@ class Rt {
|
|
|
3016
3014
|
switch ((n = s.type) == null ? void 0 : n.value.toLowerCase()) {
|
|
3017
3015
|
case "note":
|
|
3018
3016
|
return this.table.note = {
|
|
3019
|
-
value:
|
|
3020
|
-
token:
|
|
3017
|
+
value: Y(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
|
|
3018
|
+
token: k(s)
|
|
3021
3019
|
}, [];
|
|
3022
3020
|
case "indexes":
|
|
3023
3021
|
return this.interpretIndexes(s);
|
|
@@ -3031,26 +3029,26 @@ class Rt {
|
|
|
3031
3029
|
return e.flatMap((s) => this.interpretColumn(s));
|
|
3032
3030
|
}
|
|
3033
3031
|
interpretColumn(e) {
|
|
3034
|
-
var a, l, p, h, T, f, N;
|
|
3032
|
+
var a, l, p, h, T, f, N, g;
|
|
3035
3033
|
const s = [], n = {};
|
|
3036
|
-
n.name =
|
|
3037
|
-
const i =
|
|
3038
|
-
n.type = i.getValue(), s.push(...i.getErrors()), n.token =
|
|
3034
|
+
n.name = V(e.callee).unwrap();
|
|
3035
|
+
const i = Wn(e.args[0]);
|
|
3036
|
+
n.type = i.getValue(), s.push(...i.getErrors()), n.token = k(e), n.inline_refs = [];
|
|
3039
3037
|
const r = e.args.slice(1);
|
|
3040
|
-
if (
|
|
3041
|
-
const
|
|
3042
|
-
n.pk = !!((a =
|
|
3043
|
-
const
|
|
3044
|
-
n.note =
|
|
3045
|
-
value:
|
|
3046
|
-
token:
|
|
3038
|
+
if (I.last(r) instanceof U) {
|
|
3039
|
+
const v = z(r.pop()).getValue();
|
|
3040
|
+
n.pk = !!((a = v.pk) != null && a.length) || !!((l = v["primary key"]) != null && l.length), n.increment = !!((p = v.increment) != null && p.length), n.unique = !!((h = v.unique) != null && h.length), n.not_null = !!((T = v["not null"]) != null && T.length) && !0, n.dbdefault = jn((N = (f = v.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3041
|
+
const Ne = (g = v.note) == null ? void 0 : g.at(0);
|
|
3042
|
+
n.note = Ne && {
|
|
3043
|
+
value: Y(Ne.value).unwrap(),
|
|
3044
|
+
token: k(Ne)
|
|
3047
3045
|
};
|
|
3048
|
-
const
|
|
3049
|
-
n.inline_refs =
|
|
3050
|
-
const [nt] = Ce(
|
|
3046
|
+
const me = v.ref || [];
|
|
3047
|
+
n.inline_refs = me.flatMap((j) => {
|
|
3048
|
+
const [nt] = Ce(j.value.expression);
|
|
3051
3049
|
if (Dt(nt, e.symbol))
|
|
3052
|
-
return s.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
3053
|
-
const
|
|
3050
|
+
return s.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", j)), [];
|
|
3051
|
+
const ve = j.value.op, Z = W(j.value.expression).unwrap();
|
|
3054
3052
|
let ce;
|
|
3055
3053
|
if (Z.length === 1) {
|
|
3056
3054
|
const [ae] = Z;
|
|
@@ -3058,75 +3056,75 @@ class Rt {
|
|
|
3058
3056
|
schemaName: this.table.schemaName,
|
|
3059
3057
|
tableName: this.table.name,
|
|
3060
3058
|
fieldNames: [ae],
|
|
3061
|
-
relation:
|
|
3062
|
-
token:
|
|
3059
|
+
relation: ve.value,
|
|
3060
|
+
token: k(j)
|
|
3063
3061
|
};
|
|
3064
3062
|
} else if (Z.length === 2) {
|
|
3065
|
-
const [ae,
|
|
3063
|
+
const [ae, Te] = Z;
|
|
3066
3064
|
ce = {
|
|
3067
3065
|
schemaName: null,
|
|
3068
3066
|
tableName: ae,
|
|
3069
|
-
fieldNames: [
|
|
3070
|
-
relation:
|
|
3071
|
-
token:
|
|
3067
|
+
fieldNames: [Te],
|
|
3068
|
+
relation: ve.value,
|
|
3069
|
+
token: k(j)
|
|
3072
3070
|
};
|
|
3073
3071
|
} else if (Z.length === 3) {
|
|
3074
|
-
const [ae,
|
|
3072
|
+
const [ae, Te, it] = Z;
|
|
3075
3073
|
ce = {
|
|
3076
3074
|
schemaName: ae,
|
|
3077
|
-
tableName:
|
|
3075
|
+
tableName: Te,
|
|
3078
3076
|
fieldNames: [it],
|
|
3079
|
-
relation:
|
|
3080
|
-
token:
|
|
3077
|
+
relation: ve.value,
|
|
3078
|
+
token: k(j)
|
|
3081
3079
|
};
|
|
3082
3080
|
} else {
|
|
3083
|
-
s.push(new u(o.UNSUPPORTED, "Nested schema is not supported",
|
|
3084
|
-
const ae = Z.pop(),
|
|
3081
|
+
s.push(new u(o.UNSUPPORTED, "Nested schema is not supported", j));
|
|
3082
|
+
const ae = Z.pop(), Te = Z.pop();
|
|
3085
3083
|
ce = {
|
|
3086
3084
|
schemaName: Z.join("."),
|
|
3087
|
-
tableName:
|
|
3085
|
+
tableName: Te,
|
|
3088
3086
|
fieldNames: [ae],
|
|
3089
|
-
relation:
|
|
3090
|
-
token:
|
|
3087
|
+
relation: ve.value,
|
|
3088
|
+
token: k(j)
|
|
3091
3089
|
};
|
|
3092
3090
|
}
|
|
3093
|
-
const st = this.registerInlineRefToEnv(e, nt, ce,
|
|
3091
|
+
const st = this.registerInlineRefToEnv(e, nt, ce, j);
|
|
3094
3092
|
return s.push(...st), st.length === 0 ? ce : [];
|
|
3095
3093
|
});
|
|
3096
3094
|
}
|
|
3097
|
-
return n.pk || (n.pk = r.some((
|
|
3095
|
+
return n.pk || (n.pk = r.some((v) => G(v).unwrap().toLowerCase() === "pk")), n.unique || (n.unique = r.some((v) => G(v).unwrap().toLowerCase() === "unique")), this.table.fields.push(n), n.pk && this.pkColumns.push(n), s;
|
|
3098
3096
|
}
|
|
3099
3097
|
interpretIndexes(e) {
|
|
3100
3098
|
return this.table.indexes.push(...e.body.body.map((s) => {
|
|
3101
3099
|
var a, l, p, h, T, f, N;
|
|
3102
3100
|
const n = { columns: [] }, i = s;
|
|
3103
|
-
n.token =
|
|
3101
|
+
n.token = k(e);
|
|
3104
3102
|
const r = [i.callee, ...i.args];
|
|
3105
|
-
if (
|
|
3106
|
-
const
|
|
3107
|
-
n.pk = !!((a =
|
|
3108
|
-
const
|
|
3109
|
-
n.note =
|
|
3110
|
-
value:
|
|
3111
|
-
token:
|
|
3112
|
-
}, n.type =
|
|
3103
|
+
if (I.last(r) instanceof U) {
|
|
3104
|
+
const g = z(r.pop()).getValue();
|
|
3105
|
+
n.pk = !!((a = g.pk) != null && a.length), n.unique = !!((l = g.unique) != null && l.length), n.name = Y((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3106
|
+
const v = (T = g.note) == null ? void 0 : T.at(0);
|
|
3107
|
+
n.note = v && {
|
|
3108
|
+
value: Y(v.value).unwrap(),
|
|
3109
|
+
token: k(v)
|
|
3110
|
+
}, n.type = G((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3113
3111
|
}
|
|
3114
|
-
return r.flatMap((
|
|
3115
|
-
if (!(
|
|
3116
|
-
return
|
|
3117
|
-
const
|
|
3118
|
-
for (;
|
|
3119
|
-
|
|
3120
|
-
return
|
|
3121
|
-
}).forEach((
|
|
3122
|
-
const { functional:
|
|
3112
|
+
return r.flatMap((g) => {
|
|
3113
|
+
if (!(g instanceof H))
|
|
3114
|
+
return g;
|
|
3115
|
+
const v = [];
|
|
3116
|
+
for (; g instanceof H; )
|
|
3117
|
+
v.push(g.argumentList), g = g.callee;
|
|
3118
|
+
return v.push(g), v;
|
|
3119
|
+
}).forEach((g) => {
|
|
3120
|
+
const { functional: v, nonFunctional: Ne } = Ge(g).unwrap();
|
|
3123
3121
|
n.columns.push(
|
|
3124
|
-
...
|
|
3125
|
-
value:
|
|
3122
|
+
...v.map((me) => ({
|
|
3123
|
+
value: me.value.value,
|
|
3126
3124
|
type: "expression"
|
|
3127
3125
|
})),
|
|
3128
|
-
...
|
|
3129
|
-
value:
|
|
3126
|
+
...Ne.map((me) => ({
|
|
3127
|
+
value: V(me).unwrap(),
|
|
3130
3128
|
type: "column"
|
|
3131
3129
|
}))
|
|
3132
3130
|
);
|
|
@@ -3149,8 +3147,8 @@ class Rt {
|
|
|
3149
3147
|
{
|
|
3150
3148
|
schemaName: this.table.schemaName,
|
|
3151
3149
|
tableName: this.table.name,
|
|
3152
|
-
fieldNames: [
|
|
3153
|
-
token:
|
|
3150
|
+
fieldNames: [G(e.callee).unwrap()],
|
|
3151
|
+
token: k(e),
|
|
3154
3152
|
relation: a[0]
|
|
3155
3153
|
},
|
|
3156
3154
|
{
|
|
@@ -3161,30 +3159,30 @@ class Rt {
|
|
|
3161
3159
|
}), [];
|
|
3162
3160
|
}
|
|
3163
3161
|
}
|
|
3164
|
-
function
|
|
3162
|
+
function Wn(t) {
|
|
3165
3163
|
let e = null;
|
|
3166
|
-
t instanceof H && (e = t.argumentList.elementList.map((r) => le(r) ? r.expression.literal.value :
|
|
3164
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => le(r) ? r.expression.literal.value : $(r) ? Y(r).unwrap() : G(r).unwrap()).join(","), t = t.callee);
|
|
3167
3165
|
let s = "";
|
|
3168
|
-
for (; t instanceof
|
|
3166
|
+
for (; t instanceof he; )
|
|
3169
3167
|
s = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${s}`, t = t.array;
|
|
3170
|
-
const { name: n, schemaName: i } =
|
|
3171
|
-
return i.length > 1 && new
|
|
3168
|
+
const { name: n, schemaName: i } = Ae(t);
|
|
3169
|
+
return i.length > 1 && new F(
|
|
3172
3170
|
{
|
|
3173
3171
|
schemaName: i.length === 0 ? null : i[0],
|
|
3174
3172
|
type_name: `${n}${s}${e ? `(${e})` : ""}`,
|
|
3175
3173
|
args: e
|
|
3176
3174
|
},
|
|
3177
3175
|
[new u(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3178
|
-
), new
|
|
3176
|
+
), new F({
|
|
3179
3177
|
schemaName: i.length === 0 ? null : i[0],
|
|
3180
3178
|
type_name: `${n}${s}${e ? `(${e})` : ""}`,
|
|
3181
3179
|
args: e
|
|
3182
3180
|
});
|
|
3183
3181
|
}
|
|
3184
|
-
function
|
|
3182
|
+
function jn(t) {
|
|
3185
3183
|
var e, s, n;
|
|
3186
3184
|
if (t) {
|
|
3187
|
-
if (
|
|
3185
|
+
if ($(t))
|
|
3188
3186
|
return {
|
|
3189
3187
|
value: Y(t).unwrap(),
|
|
3190
3188
|
type: "string"
|
|
@@ -3194,12 +3192,12 @@ function Wn(t) {
|
|
|
3194
3192
|
type: "number",
|
|
3195
3193
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3196
3194
|
};
|
|
3197
|
-
if (
|
|
3195
|
+
if (fe(t))
|
|
3198
3196
|
return {
|
|
3199
3197
|
value: t.expression.variable.value.toLowerCase(),
|
|
3200
3198
|
type: "boolean"
|
|
3201
3199
|
};
|
|
3202
|
-
if (t instanceof Q &&
|
|
3200
|
+
if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression)) {
|
|
3203
3201
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3204
3202
|
return {
|
|
3205
3203
|
value: ((s = t.op) == null ? void 0 : s.value) === "-" ? 0 - i : i,
|
|
@@ -3220,10 +3218,10 @@ class Pt {
|
|
|
3220
3218
|
}
|
|
3221
3219
|
interpret() {
|
|
3222
3220
|
const e = [];
|
|
3223
|
-
this.tableGroup.token =
|
|
3224
|
-
const { name: s, schemaName: n } =
|
|
3221
|
+
this.tableGroup.token = k(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
|
|
3222
|
+
const { name: s, schemaName: n } = Ae(this.declarationNode.name);
|
|
3225
3223
|
return n.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = n.join("."), e.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = n[0] || null, this.tableGroup.tables = this.declarationNode.body.body.map((i) => {
|
|
3226
|
-
const r =
|
|
3224
|
+
const r = W(i.callee).unwrap();
|
|
3227
3225
|
return r.length > 2 && e.push(new u(o.UNSUPPORTED, "Nested schema is not supported", i)), {
|
|
3228
3226
|
name: r.pop(),
|
|
3229
3227
|
schemaName: r.join(".")
|
|
@@ -3236,26 +3234,26 @@ class Ut {
|
|
|
3236
3234
|
this.declarationNode = e, this.env = s, this.enum = { values: [] };
|
|
3237
3235
|
}
|
|
3238
3236
|
interpret() {
|
|
3239
|
-
return this.enum.token =
|
|
3237
|
+
return this.enum.token = k(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3240
3238
|
}
|
|
3241
3239
|
interpretName(e) {
|
|
3242
|
-
const { name: s, schemaName: n } =
|
|
3240
|
+
const { name: s, schemaName: n } = Ae(e);
|
|
3243
3241
|
return n.length > 1 ? (this.enum.name = s, this.enum.schemaName = n.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = s, this.enum.schemaName = n.length ? n[0] : null, []);
|
|
3244
3242
|
}
|
|
3245
3243
|
interpretBody(e) {
|
|
3246
3244
|
return e.body.flatMap((s) => {
|
|
3247
3245
|
var l;
|
|
3248
3246
|
const n = s, i = {};
|
|
3249
|
-
i.token =
|
|
3247
|
+
i.token = k(n), i.name = G(n.callee).unwrap();
|
|
3250
3248
|
const a = (l = z(n.args[0]).getValue().note) == null ? void 0 : l.at(0);
|
|
3251
3249
|
return i.note = a && {
|
|
3252
|
-
value:
|
|
3253
|
-
token:
|
|
3250
|
+
value: Y(a.value).unwrap(),
|
|
3251
|
+
token: k(a)
|
|
3254
3252
|
}, this.enum.values.push(i), [];
|
|
3255
3253
|
});
|
|
3256
3254
|
}
|
|
3257
3255
|
}
|
|
3258
|
-
class
|
|
3256
|
+
class Yn {
|
|
3259
3257
|
constructor(e, s) {
|
|
3260
3258
|
this.declarationNode = e, this.env = s, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3261
3259
|
}
|
|
@@ -3265,7 +3263,7 @@ class jn {
|
|
|
3265
3263
|
interpretName(e) {
|
|
3266
3264
|
if (!e)
|
|
3267
3265
|
return this.project.name = null, [];
|
|
3268
|
-
const { name: s } =
|
|
3266
|
+
const { name: s } = Ae(e);
|
|
3269
3267
|
return this.project.name = s, [];
|
|
3270
3268
|
}
|
|
3271
3269
|
interpretBody(e) {
|
|
@@ -3291,8 +3289,8 @@ class jn {
|
|
|
3291
3289
|
}
|
|
3292
3290
|
case "note":
|
|
3293
3291
|
return this.project.note = {
|
|
3294
|
-
value:
|
|
3295
|
-
token:
|
|
3292
|
+
value: Y(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
|
|
3293
|
+
token: k(n)
|
|
3296
3294
|
}, [];
|
|
3297
3295
|
default:
|
|
3298
3296
|
return this.project[n.type.value.toLowerCase()] = Y(n.body.callee).unwrap(), [];
|
|
@@ -3300,7 +3298,7 @@ class jn {
|
|
|
3300
3298
|
});
|
|
3301
3299
|
}
|
|
3302
3300
|
}
|
|
3303
|
-
class
|
|
3301
|
+
class zn {
|
|
3304
3302
|
constructor(e) {
|
|
3305
3303
|
this.ast = e, this.env = {
|
|
3306
3304
|
schema: [],
|
|
@@ -3315,25 +3313,25 @@ class Yn {
|
|
|
3315
3313
|
}
|
|
3316
3314
|
interpret() {
|
|
3317
3315
|
const e = this.ast.body.flatMap((s) => {
|
|
3318
|
-
switch (
|
|
3319
|
-
case
|
|
3316
|
+
switch (de(s).unwrap_or(void 0)) {
|
|
3317
|
+
case b.Table:
|
|
3320
3318
|
return new Rt(s, this.env).interpret();
|
|
3321
|
-
case
|
|
3319
|
+
case b.Ref:
|
|
3322
3320
|
return new Ke(s, this.env).interpret();
|
|
3323
|
-
case
|
|
3321
|
+
case b.TableGroup:
|
|
3324
3322
|
return new Pt(s, this.env).interpret();
|
|
3325
|
-
case
|
|
3323
|
+
case b.Enum:
|
|
3326
3324
|
return new Ut(s, this.env).interpret();
|
|
3327
|
-
case
|
|
3328
|
-
return new
|
|
3325
|
+
case b.Project:
|
|
3326
|
+
return new Yn(s, this.env).interpret();
|
|
3329
3327
|
default:
|
|
3330
3328
|
return [];
|
|
3331
3329
|
}
|
|
3332
3330
|
});
|
|
3333
|
-
return new
|
|
3331
|
+
return new F(Qn(this.env), e);
|
|
3334
3332
|
}
|
|
3335
3333
|
}
|
|
3336
|
-
function
|
|
3334
|
+
function Qn(t) {
|
|
3337
3335
|
return {
|
|
3338
3336
|
schemas: [],
|
|
3339
3337
|
tables: Array.from(t.tables.values()),
|
|
@@ -3344,28 +3342,28 @@ function zn(t) {
|
|
|
3344
3342
|
project: Array.from(t.project.values())[0] || {}
|
|
3345
3343
|
};
|
|
3346
3344
|
}
|
|
3347
|
-
var
|
|
3348
|
-
function
|
|
3345
|
+
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 || {});
|
|
3346
|
+
function ge(t) {
|
|
3349
3347
|
switch (t) {
|
|
3350
3348
|
case m.Schema:
|
|
3351
|
-
return
|
|
3349
|
+
return L.Module;
|
|
3352
3350
|
case m.Table:
|
|
3353
|
-
return
|
|
3351
|
+
return L.Class;
|
|
3354
3352
|
case m.Column:
|
|
3355
|
-
return
|
|
3353
|
+
return L.Field;
|
|
3356
3354
|
case m.Enum:
|
|
3357
|
-
return
|
|
3355
|
+
return L.Enum;
|
|
3358
3356
|
case m.EnumField:
|
|
3359
|
-
return
|
|
3357
|
+
return L.EnumMember;
|
|
3360
3358
|
case m.TableGroup:
|
|
3361
|
-
return
|
|
3359
|
+
return L.Struct;
|
|
3362
3360
|
case m.TableGroupField:
|
|
3363
|
-
return
|
|
3361
|
+
return L.Field;
|
|
3364
3362
|
default:
|
|
3365
|
-
return
|
|
3363
|
+
return L.Text;
|
|
3366
3364
|
}
|
|
3367
3365
|
}
|
|
3368
|
-
function
|
|
3366
|
+
function Se(t, e) {
|
|
3369
3367
|
if (!t || Ve(t))
|
|
3370
3368
|
return !1;
|
|
3371
3369
|
for (const s of t.trailingTrivia) {
|
|
@@ -3376,12 +3374,12 @@ function ke(t, e) {
|
|
|
3376
3374
|
}
|
|
3377
3375
|
return !0;
|
|
3378
3376
|
}
|
|
3379
|
-
function
|
|
3377
|
+
function O() {
|
|
3380
3378
|
return {
|
|
3381
3379
|
suggestions: []
|
|
3382
3380
|
};
|
|
3383
3381
|
}
|
|
3384
|
-
function
|
|
3382
|
+
function Oe(t) {
|
|
3385
3383
|
return {
|
|
3386
3384
|
...t,
|
|
3387
3385
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3390,7 +3388,7 @@ function Se(t) {
|
|
|
3390
3388
|
}))
|
|
3391
3389
|
};
|
|
3392
3390
|
}
|
|
3393
|
-
function
|
|
3391
|
+
function Ue(t) {
|
|
3394
3392
|
return {
|
|
3395
3393
|
...t,
|
|
3396
3394
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3413,14 +3411,14 @@ class Mt {
|
|
|
3413
3411
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3414
3412
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3415
3413
|
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3416
|
-
].find((N) => $t(N) &&
|
|
3417
|
-
return
|
|
3414
|
+
].find((N) => $t(N) && Ie(n, N)))
|
|
3415
|
+
return O();
|
|
3418
3416
|
if (a === void 0)
|
|
3419
3417
|
return Tt();
|
|
3420
|
-
if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) &&
|
|
3421
|
-
return
|
|
3418
|
+
if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && Ie(n, r))
|
|
3419
|
+
return O();
|
|
3422
3420
|
const p = this.compiler.container.element(n);
|
|
3423
|
-
if (this.compiler.container.scopeKind(n) ===
|
|
3421
|
+
if (this.compiler.container.scopeKind(n) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= n && p.type.end >= n)
|
|
3424
3422
|
return Tt();
|
|
3425
3423
|
const h = [...this.compiler.container.stack(n)].reverse();
|
|
3426
3424
|
for (const N of h)
|
|
@@ -3460,31 +3458,31 @@ class Mt {
|
|
|
3460
3458
|
if (N instanceof U)
|
|
3461
3459
|
return Et(this.compiler, n, N);
|
|
3462
3460
|
if (N instanceof J)
|
|
3463
|
-
return
|
|
3464
|
-
if (N instanceof
|
|
3461
|
+
return qn(this.compiler, n);
|
|
3462
|
+
if (N instanceof x)
|
|
3465
3463
|
return mt(this.compiler, n, N);
|
|
3466
|
-
if (N instanceof _ && (N.bodyColon && n >= N.bodyColon.end || N.body &&
|
|
3464
|
+
if (N instanceof _ && (N.bodyColon && n >= N.bodyColon.end || N.body && Ie(n, N.body)))
|
|
3467
3465
|
return mt(this.compiler, n, void 0);
|
|
3468
3466
|
}
|
|
3469
|
-
return
|
|
3467
|
+
return O();
|
|
3470
3468
|
}
|
|
3471
3469
|
}
|
|
3472
3470
|
function dt(t, e, s) {
|
|
3473
3471
|
const n = t.container.scopeKind(e);
|
|
3474
|
-
if ([
|
|
3475
|
-
const i =
|
|
3472
|
+
if ([D.REF, D.TABLE].includes(n)) {
|
|
3473
|
+
const i = Me(t, e, t.container.element(e), [
|
|
3476
3474
|
m.Table,
|
|
3477
3475
|
m.Schema,
|
|
3478
3476
|
m.Column
|
|
3479
3477
|
]);
|
|
3480
|
-
return
|
|
3478
|
+
return Se(s.op, e) ? Oe(i) : i;
|
|
3481
3479
|
}
|
|
3482
|
-
return
|
|
3480
|
+
return O();
|
|
3483
3481
|
}
|
|
3484
|
-
function
|
|
3482
|
+
function Me(t, e, s, n) {
|
|
3485
3483
|
var a;
|
|
3486
3484
|
if (s === void 0)
|
|
3487
|
-
return
|
|
3485
|
+
return O();
|
|
3488
3486
|
let i = s;
|
|
3489
3487
|
const r = { suggestions: [] };
|
|
3490
3488
|
for (; i; ) {
|
|
@@ -3495,22 +3493,22 @@ function Ue(t, e, s, n) {
|
|
|
3495
3493
|
label: p,
|
|
3496
3494
|
insertText: p,
|
|
3497
3495
|
insertTextRules: w.KeepWhitespace,
|
|
3498
|
-
kind:
|
|
3499
|
-
sortText:
|
|
3496
|
+
kind: ge(h),
|
|
3497
|
+
sortText: ge(h).toString().padStart(2, "0"),
|
|
3500
3498
|
range: void 0
|
|
3501
3499
|
}))
|
|
3502
3500
|
);
|
|
3503
3501
|
}
|
|
3504
3502
|
i = i instanceof _ ? i.parent : void 0;
|
|
3505
3503
|
}
|
|
3506
|
-
return
|
|
3504
|
+
return Ue(r);
|
|
3507
3505
|
}
|
|
3508
|
-
function
|
|
3506
|
+
function qn(t, e) {
|
|
3509
3507
|
var n;
|
|
3510
3508
|
switch (t.container.scopeKind(e)) {
|
|
3511
|
-
case
|
|
3509
|
+
case D.INDEXES:
|
|
3512
3510
|
return Vt(t, e);
|
|
3513
|
-
case
|
|
3511
|
+
case D.REF:
|
|
3514
3512
|
{
|
|
3515
3513
|
const i = [...t.container.stack(e)];
|
|
3516
3514
|
for (; i.length > 0; ) {
|
|
@@ -3525,126 +3523,126 @@ function Qn(t, e) {
|
|
|
3525
3523
|
}
|
|
3526
3524
|
return Bt(t, e);
|
|
3527
3525
|
}
|
|
3528
|
-
return
|
|
3526
|
+
return O();
|
|
3529
3527
|
}
|
|
3530
3528
|
function Et(t, e, s) {
|
|
3531
3529
|
const { token: n } = t.container.token(e);
|
|
3532
3530
|
if ([c.COMMA, c.LBRACKET].includes(n == null ? void 0 : n.kind)) {
|
|
3533
3531
|
const i = Nt(t, e);
|
|
3534
|
-
return (n == null ? void 0 : n.kind) === c.COMMA &&
|
|
3532
|
+
return (n == null ? void 0 : n.kind) === c.COMMA && Se(n, e) ? Oe(i) : i;
|
|
3535
3533
|
}
|
|
3536
3534
|
if (s.name && s.name.start <= e && s.name.end >= e)
|
|
3537
3535
|
return Nt(t, e);
|
|
3538
3536
|
if (s.name) {
|
|
3539
|
-
const i =
|
|
3537
|
+
const i = Hn(
|
|
3540
3538
|
t,
|
|
3541
3539
|
e,
|
|
3542
|
-
|
|
3540
|
+
Re(s.name).unwrap()
|
|
3543
3541
|
);
|
|
3544
|
-
return (n == null ? void 0 : n.kind) === c.COLON &&
|
|
3542
|
+
return (n == null ? void 0 : n.kind) === c.COLON && Se(n, e) ? Oe(i) : i;
|
|
3545
3543
|
}
|
|
3546
|
-
return
|
|
3544
|
+
return O();
|
|
3547
3545
|
}
|
|
3548
3546
|
function Nt(t, e) {
|
|
3549
3547
|
const s = t.container.element(e), n = t.container.scopeKind(e);
|
|
3550
|
-
if (s instanceof
|
|
3551
|
-
return
|
|
3552
|
-
if (s.body && !
|
|
3548
|
+
if (s instanceof C)
|
|
3549
|
+
return O();
|
|
3550
|
+
if (s.body && !Ie(e, s.body))
|
|
3553
3551
|
switch (n) {
|
|
3554
|
-
case
|
|
3552
|
+
case D.TABLE:
|
|
3555
3553
|
return {
|
|
3556
3554
|
suggestions: [
|
|
3557
3555
|
{
|
|
3558
3556
|
label: "headercolor",
|
|
3559
3557
|
insertText: "headercolor: ",
|
|
3560
|
-
kind:
|
|
3558
|
+
kind: L.Field,
|
|
3561
3559
|
insertTextRules: w.KeepWhitespace,
|
|
3562
3560
|
range: void 0
|
|
3563
3561
|
},
|
|
3564
3562
|
{
|
|
3565
3563
|
label: "note",
|
|
3566
3564
|
insertText: "note: ",
|
|
3567
|
-
kind:
|
|
3565
|
+
kind: L.Field,
|
|
3568
3566
|
insertTextRules: w.KeepWhitespace,
|
|
3569
3567
|
range: void 0
|
|
3570
3568
|
}
|
|
3571
3569
|
]
|
|
3572
3570
|
};
|
|
3573
3571
|
default:
|
|
3574
|
-
return
|
|
3572
|
+
return O();
|
|
3575
3573
|
}
|
|
3576
3574
|
switch (n) {
|
|
3577
|
-
case
|
|
3575
|
+
case D.TABLE:
|
|
3578
3576
|
return {
|
|
3579
3577
|
suggestions: [
|
|
3580
3578
|
...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
|
|
3581
3579
|
label: i,
|
|
3582
3580
|
insertText: i,
|
|
3583
|
-
kind:
|
|
3581
|
+
kind: L.Property,
|
|
3584
3582
|
insertTextRules: w.KeepWhitespace,
|
|
3585
3583
|
range: void 0
|
|
3586
3584
|
})),
|
|
3587
3585
|
...["ref", "default"].map((i) => ({
|
|
3588
3586
|
label: i,
|
|
3589
3587
|
insertText: `${i}: `,
|
|
3590
|
-
kind:
|
|
3588
|
+
kind: L.Property,
|
|
3591
3589
|
insertTextRules: w.KeepWhitespace,
|
|
3592
3590
|
range: void 0
|
|
3593
3591
|
})),
|
|
3594
3592
|
{
|
|
3595
3593
|
label: "note",
|
|
3596
3594
|
insertText: "note: ",
|
|
3597
|
-
kind:
|
|
3595
|
+
kind: L.Property,
|
|
3598
3596
|
insertTextRules: w.KeepWhitespace,
|
|
3599
3597
|
range: void 0
|
|
3600
3598
|
}
|
|
3601
3599
|
]
|
|
3602
3600
|
};
|
|
3603
|
-
case
|
|
3601
|
+
case D.ENUM:
|
|
3604
3602
|
return {
|
|
3605
3603
|
suggestions: [
|
|
3606
3604
|
{
|
|
3607
3605
|
label: "note",
|
|
3608
3606
|
insertText: "note: ",
|
|
3609
|
-
kind:
|
|
3607
|
+
kind: L.Property,
|
|
3610
3608
|
insertTextRules: w.KeepWhitespace,
|
|
3611
3609
|
range: void 0
|
|
3612
3610
|
}
|
|
3613
3611
|
]
|
|
3614
3612
|
};
|
|
3615
|
-
case
|
|
3613
|
+
case D.INDEXES:
|
|
3616
3614
|
return {
|
|
3617
3615
|
suggestions: [
|
|
3618
3616
|
...["unique", "pk"].map((i) => ({
|
|
3619
3617
|
label: i,
|
|
3620
3618
|
insertText: i,
|
|
3621
3619
|
insertTextRules: w.KeepWhitespace,
|
|
3622
|
-
kind:
|
|
3620
|
+
kind: L.Property,
|
|
3623
3621
|
range: void 0
|
|
3624
3622
|
})),
|
|
3625
3623
|
...["note", "name", "type"].map((i) => ({
|
|
3626
3624
|
label: i,
|
|
3627
3625
|
insertText: `${i}: `,
|
|
3628
|
-
kind:
|
|
3626
|
+
kind: L.Property,
|
|
3629
3627
|
insertTextRules: w.KeepWhitespace,
|
|
3630
3628
|
range: void 0
|
|
3631
3629
|
}))
|
|
3632
3630
|
]
|
|
3633
3631
|
};
|
|
3634
|
-
case
|
|
3632
|
+
case D.REF:
|
|
3635
3633
|
return {
|
|
3636
3634
|
suggestions: ["update", "delete"].map((i) => ({
|
|
3637
3635
|
label: i,
|
|
3638
3636
|
insertText: `${i}: `,
|
|
3639
|
-
kind:
|
|
3637
|
+
kind: L.Property,
|
|
3640
3638
|
insertTextRules: w.KeepWhitespace,
|
|
3641
3639
|
range: void 0
|
|
3642
3640
|
}))
|
|
3643
3641
|
};
|
|
3644
3642
|
}
|
|
3645
|
-
return
|
|
3643
|
+
return O();
|
|
3646
3644
|
}
|
|
3647
|
-
function
|
|
3645
|
+
function Hn(t, e, s) {
|
|
3648
3646
|
switch (s == null ? void 0 : s.toLowerCase()) {
|
|
3649
3647
|
case "update":
|
|
3650
3648
|
case "delete":
|
|
@@ -3652,7 +3650,7 @@ function qn(t, e, s) {
|
|
|
3652
3650
|
suggestions: ["cascade", "set default", "set null", "restrict"].map((n) => ({
|
|
3653
3651
|
label: n,
|
|
3654
3652
|
insertText: n,
|
|
3655
|
-
kind:
|
|
3653
|
+
kind: L.Value,
|
|
3656
3654
|
insertTextRules: w.KeepWhitespace,
|
|
3657
3655
|
range: void 0
|
|
3658
3656
|
}))
|
|
@@ -3662,24 +3660,24 @@ function qn(t, e, s) {
|
|
|
3662
3660
|
suggestions: ["btree", "hash"].map((n) => ({
|
|
3663
3661
|
label: n,
|
|
3664
3662
|
insertText: `${n}`,
|
|
3665
|
-
kind:
|
|
3663
|
+
kind: L.Value,
|
|
3666
3664
|
insertTextRules: w.KeepWhitespace,
|
|
3667
3665
|
range: void 0
|
|
3668
3666
|
}))
|
|
3669
3667
|
};
|
|
3670
3668
|
}
|
|
3671
|
-
return
|
|
3669
|
+
return O();
|
|
3672
3670
|
}
|
|
3673
3671
|
function Ft(t, e, s) {
|
|
3674
|
-
const n =
|
|
3672
|
+
const n = Ee(s).unwrap_or([]);
|
|
3675
3673
|
if (n.pop(), n.some((r) => !M(r)))
|
|
3676
|
-
return
|
|
3677
|
-
const i = n.map((r) =>
|
|
3678
|
-
return
|
|
3674
|
+
return O();
|
|
3675
|
+
const i = n.map((r) => G(r).unwrap());
|
|
3676
|
+
return Ue({
|
|
3679
3677
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3680
3678
|
label: a,
|
|
3681
3679
|
insertText: a,
|
|
3682
|
-
kind:
|
|
3680
|
+
kind: ge(r),
|
|
3683
3681
|
range: void 0
|
|
3684
3682
|
}))
|
|
3685
3683
|
});
|
|
@@ -3687,22 +3685,22 @@ function Ft(t, e, s) {
|
|
|
3687
3685
|
function mt(t, e, s) {
|
|
3688
3686
|
var i;
|
|
3689
3687
|
switch (t.container.scopeKind(e)) {
|
|
3690
|
-
case
|
|
3691
|
-
return Jn(t, e, s);
|
|
3692
|
-
case O.PROJECT:
|
|
3688
|
+
case D.TABLE:
|
|
3693
3689
|
return Zn(t, e, s);
|
|
3694
|
-
case
|
|
3695
|
-
return
|
|
3696
|
-
case
|
|
3697
|
-
return
|
|
3698
|
-
case
|
|
3690
|
+
case D.PROJECT:
|
|
3691
|
+
return Kn(t, e, s);
|
|
3692
|
+
case D.INDEXES:
|
|
3693
|
+
return ts(t, e);
|
|
3694
|
+
case D.ENUM:
|
|
3695
|
+
return Jn(t, e, s);
|
|
3696
|
+
case D.REF: {
|
|
3699
3697
|
const r = Bt(t, e);
|
|
3700
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON &&
|
|
3698
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
|
|
3701
3699
|
}
|
|
3702
|
-
case
|
|
3703
|
-
return
|
|
3700
|
+
case D.TABLEGROUP:
|
|
3701
|
+
return es(t);
|
|
3704
3702
|
default:
|
|
3705
|
-
return
|
|
3703
|
+
return O();
|
|
3706
3704
|
}
|
|
3707
3705
|
}
|
|
3708
3706
|
function Tt() {
|
|
@@ -3711,26 +3709,26 @@ function Tt() {
|
|
|
3711
3709
|
label: t,
|
|
3712
3710
|
insertText: t,
|
|
3713
3711
|
insertTextRules: w.KeepWhitespace,
|
|
3714
|
-
kind:
|
|
3712
|
+
kind: L.Keyword,
|
|
3715
3713
|
range: void 0
|
|
3716
3714
|
}))
|
|
3717
3715
|
};
|
|
3718
3716
|
}
|
|
3719
|
-
function
|
|
3720
|
-
return s != null && s.callee && tt(e, s) === 1 ?
|
|
3717
|
+
function Jn(t, e, s) {
|
|
3718
|
+
return s != null && s.callee && tt(e, s) === 1 ? Me(t, e, t.container.element(e), [
|
|
3721
3719
|
m.Schema,
|
|
3722
3720
|
m.Table,
|
|
3723
3721
|
m.Column
|
|
3724
|
-
]) :
|
|
3722
|
+
]) : O();
|
|
3725
3723
|
}
|
|
3726
|
-
function
|
|
3724
|
+
function Zn(t, e, s) {
|
|
3727
3725
|
if (!(s != null && s.callee))
|
|
3728
3726
|
return {
|
|
3729
3727
|
suggestions: ["Ref", "Note", "indexes"].map((i) => ({
|
|
3730
3728
|
label: i,
|
|
3731
3729
|
insertText: i,
|
|
3732
3730
|
insertTextRules: w.KeepWhitespace,
|
|
3733
|
-
kind:
|
|
3731
|
+
kind: L.Keyword,
|
|
3734
3732
|
range: void 0
|
|
3735
3733
|
}))
|
|
3736
3734
|
};
|
|
@@ -3740,39 +3738,39 @@ function Jn(t, e, s) {
|
|
|
3740
3738
|
label: i,
|
|
3741
3739
|
insertText: i,
|
|
3742
3740
|
insertTextRules: w.KeepWhitespace,
|
|
3743
|
-
kind:
|
|
3741
|
+
kind: L.Keyword,
|
|
3744
3742
|
range: void 0
|
|
3745
3743
|
}))
|
|
3746
|
-
} : n === 1 ?
|
|
3744
|
+
} : n === 1 ? ns(t, e) : O();
|
|
3747
3745
|
}
|
|
3748
|
-
function
|
|
3746
|
+
function Kn(t, e, s) {
|
|
3749
3747
|
return s != null && s.callee ? tt(e, s) === 0 ? {
|
|
3750
3748
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3751
3749
|
label: i,
|
|
3752
3750
|
insertText: i,
|
|
3753
3751
|
insertTextRules: w.KeepWhitespace,
|
|
3754
|
-
kind:
|
|
3752
|
+
kind: L.Keyword,
|
|
3755
3753
|
range: void 0
|
|
3756
3754
|
}))
|
|
3757
|
-
} :
|
|
3755
|
+
} : O() : {
|
|
3758
3756
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3759
3757
|
label: i,
|
|
3760
3758
|
insertText: i,
|
|
3761
3759
|
insertTextRules: w.KeepWhitespace,
|
|
3762
|
-
kind:
|
|
3760
|
+
kind: L.Keyword,
|
|
3763
3761
|
range: void 0
|
|
3764
3762
|
}))
|
|
3765
3763
|
};
|
|
3766
3764
|
}
|
|
3767
3765
|
function Bt(t, e) {
|
|
3768
|
-
return
|
|
3766
|
+
return Me(t, e, t.container.element(e), [
|
|
3769
3767
|
m.Schema,
|
|
3770
3768
|
m.Table,
|
|
3771
3769
|
m.Column
|
|
3772
3770
|
]);
|
|
3773
3771
|
}
|
|
3774
|
-
function
|
|
3775
|
-
return
|
|
3772
|
+
function es(t) {
|
|
3773
|
+
return Ue({
|
|
3776
3774
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3777
3775
|
const s = se(e).unwrap_or(void 0);
|
|
3778
3776
|
if (s === void 0)
|
|
@@ -3782,16 +3780,16 @@ function Kn(t) {
|
|
|
3782
3780
|
label: i,
|
|
3783
3781
|
insertText: i,
|
|
3784
3782
|
insertTextRules: w.KeepWhitespace,
|
|
3785
|
-
kind:
|
|
3783
|
+
kind: ge(n),
|
|
3786
3784
|
range: void 0
|
|
3787
3785
|
};
|
|
3788
3786
|
})
|
|
3789
3787
|
});
|
|
3790
3788
|
}
|
|
3791
|
-
function
|
|
3789
|
+
function ts(t, e) {
|
|
3792
3790
|
return Vt(t, e);
|
|
3793
3791
|
}
|
|
3794
|
-
function
|
|
3792
|
+
function ns(t, e) {
|
|
3795
3793
|
return {
|
|
3796
3794
|
suggestions: [
|
|
3797
3795
|
...[
|
|
@@ -3855,11 +3853,11 @@ function ts(t, e) {
|
|
|
3855
3853
|
label: s,
|
|
3856
3854
|
insertText: s,
|
|
3857
3855
|
insertTextRules: w.KeepWhitespace,
|
|
3858
|
-
kind:
|
|
3859
|
-
sortText:
|
|
3856
|
+
kind: L.TypeParameter,
|
|
3857
|
+
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3860
3858
|
range: void 0
|
|
3861
3859
|
})),
|
|
3862
|
-
...
|
|
3860
|
+
...Me(t, e, t.container.element(e), [
|
|
3863
3861
|
m.Enum,
|
|
3864
3862
|
m.Schema
|
|
3865
3863
|
]).suggestions
|
|
@@ -3869,9 +3867,9 @@ function ts(t, e) {
|
|
|
3869
3867
|
function Vt(t, e) {
|
|
3870
3868
|
const n = t.container.element(e).parent;
|
|
3871
3869
|
if (!((n == null ? void 0 : n.symbol) instanceof At))
|
|
3872
|
-
return
|
|
3870
|
+
return O();
|
|
3873
3871
|
const { symbolTable: i } = n.symbol;
|
|
3874
|
-
return
|
|
3872
|
+
return Ue({
|
|
3875
3873
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
3876
3874
|
const a = se(r).unwrap_or(void 0);
|
|
3877
3875
|
if (a === void 0)
|
|
@@ -3881,7 +3879,7 @@ function Vt(t, e) {
|
|
|
3881
3879
|
label: l,
|
|
3882
3880
|
insertText: l,
|
|
3883
3881
|
insertTextRules: w.KeepWhitespace,
|
|
3884
|
-
kind:
|
|
3882
|
+
kind: ge(m.Column),
|
|
3885
3883
|
range: void 0
|
|
3886
3884
|
};
|
|
3887
3885
|
})
|
|
@@ -3902,7 +3900,7 @@ class Gt {
|
|
|
3902
3900
|
const { uri: n } = e, i = et(e, s), r = [...this.compiler.container.stack(i)];
|
|
3903
3901
|
for (; r.length !== 0; ) {
|
|
3904
3902
|
const l = r.pop();
|
|
3905
|
-
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [
|
|
3903
|
+
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [ue.PRIMARY_EXPRESSION, ue.VARIABLE].includes(l == null ? void 0 : l.kind)) {
|
|
3906
3904
|
const { startPos: p, endPos: h } = l.referee.declaration;
|
|
3907
3905
|
return [
|
|
3908
3906
|
{
|
|
@@ -3929,9 +3927,9 @@ class Ct {
|
|
|
3929
3927
|
for (; r.length !== 0; ) {
|
|
3930
3928
|
const a = r.pop();
|
|
3931
3929
|
if (a && [
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3930
|
+
ue.ELEMENT_DECLARATION,
|
|
3931
|
+
ue.FUNCTION_APPLICATION,
|
|
3932
|
+
ue.PRIMARY_EXPRESSION
|
|
3935
3933
|
].includes(a == null ? void 0 : a.kind)) {
|
|
3936
3934
|
const { symbol: l } = a;
|
|
3937
3935
|
if (l != null && l.references.length)
|
|
@@ -3949,16 +3947,16 @@ class Ct {
|
|
|
3949
3947
|
return [];
|
|
3950
3948
|
}
|
|
3951
3949
|
}
|
|
3952
|
-
const
|
|
3950
|
+
const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3953
3951
|
__proto__: null,
|
|
3954
3952
|
CompletionItemInsertTextRule: w,
|
|
3955
|
-
CompletionItemKind:
|
|
3953
|
+
CompletionItemKind: L,
|
|
3956
3954
|
DBMLCompletionItemProvider: Mt,
|
|
3957
3955
|
DBMLDefinitionProvider: Gt,
|
|
3958
3956
|
DBMLReferencesProvider: Ct
|
|
3959
3957
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3960
|
-
var
|
|
3961
|
-
class
|
|
3958
|
+
var D = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(D || {});
|
|
3959
|
+
class as {
|
|
3962
3960
|
constructor() {
|
|
3963
3961
|
this.source = "", this.cache = new Array(
|
|
3964
3962
|
16
|
|
@@ -3966,7 +3964,7 @@ class rs {
|
|
|
3966
3964
|
).fill(null), this.nodeIdGenerator = new Wt(), this.symbolIdGenerator = new Qt(), this.token = {
|
|
3967
3965
|
invalidStream: this.createQuery(
|
|
3968
3966
|
6,
|
|
3969
|
-
() => this.parse.tokens().filter(
|
|
3967
|
+
() => this.parse.tokens().filter(vt)
|
|
3970
3968
|
),
|
|
3971
3969
|
// Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
|
|
3972
3970
|
flatStream: this.createQuery(
|
|
@@ -3978,8 +3976,8 @@ class rs {
|
|
|
3978
3976
|
_: this.createQuery(
|
|
3979
3977
|
0,
|
|
3980
3978
|
() => {
|
|
3981
|
-
const e = new rn(this.source).lex().chain((s) => new ln(s, this.nodeIdGenerator).parse()).chain(({ ast: s, tokens: n }) => new
|
|
3982
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: s, tokens: n }) => new
|
|
3979
|
+
const e = new rn(this.source).lex().chain((s) => new ln(s, this.nodeIdGenerator).parse()).chain(({ ast: s, tokens: n }) => new Xn(s, this.symbolIdGenerator).analyze().map(() => ({ ast: s, tokens: n })));
|
|
3980
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: s, tokens: n }) => new zn(s).interpret().map((r) => ({ ast: s, tokens: n, rawDb: r })));
|
|
3983
3981
|
}
|
|
3984
3982
|
),
|
|
3985
3983
|
ast: this.createQuery(
|
|
@@ -4016,8 +4014,8 @@ class rs {
|
|
|
4016
4014
|
let a = this.parse.ast();
|
|
4017
4015
|
const l = [a];
|
|
4018
4016
|
for (; ; ) {
|
|
4019
|
-
const h = sn(a).find((T) =>
|
|
4020
|
-
if (h === void 0 || h instanceof
|
|
4017
|
+
const h = sn(a).find((T) => Ie(r, T));
|
|
4018
|
+
if (h === void 0 || h instanceof B)
|
|
4021
4019
|
break;
|
|
4022
4020
|
l.push(h), a = h;
|
|
4023
4021
|
}
|
|
@@ -4025,8 +4023,8 @@ class rs {
|
|
|
4025
4023
|
return l;
|
|
4026
4024
|
for (; l.length > 0; ) {
|
|
4027
4025
|
let p = !1;
|
|
4028
|
-
const h =
|
|
4029
|
-
if (h instanceof
|
|
4026
|
+
const h = I.last(l);
|
|
4027
|
+
if (h instanceof x) {
|
|
4030
4028
|
const T = this.parse.source();
|
|
4031
4029
|
for (let f = h.end; f < e; f += 1)
|
|
4032
4030
|
T[f] === `
|
|
@@ -4034,7 +4032,7 @@ class rs {
|
|
|
4034
4032
|
} else
|
|
4035
4033
|
h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof U ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof ee ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof te || h.end < e && (l.pop(), p = !0);
|
|
4036
4034
|
if (p) {
|
|
4037
|
-
const T =
|
|
4035
|
+
const T = I.last(l);
|
|
4038
4036
|
T instanceof _ && T.end <= e && l.pop();
|
|
4039
4037
|
}
|
|
4040
4038
|
if (!p)
|
|
@@ -4072,7 +4070,7 @@ class rs {
|
|
|
4072
4070
|
),
|
|
4073
4071
|
scopeKind: this.createQuery(15, (e) => {
|
|
4074
4072
|
var n;
|
|
4075
|
-
if (this.container.element(e) instanceof
|
|
4073
|
+
if (this.container.element(e) instanceof C)
|
|
4076
4074
|
return 8;
|
|
4077
4075
|
switch ((n = this.container.element(e).type) == null ? void 0 : n.value.toLowerCase()) {
|
|
4078
4076
|
case "table":
|
|
@@ -4116,8 +4114,8 @@ class rs {
|
|
|
4116
4114
|
for (const h of e)
|
|
4117
4115
|
p = l.flatMap(
|
|
4118
4116
|
(T) => Yt(h).flatMap((f) => {
|
|
4119
|
-
const N = T.get(f),
|
|
4120
|
-
return !N || !
|
|
4117
|
+
const N = T.get(f), g = se(f).unwrap_or(void 0);
|
|
4118
|
+
return !N || !g ? [] : { ...g, symbol: N };
|
|
4121
4119
|
})
|
|
4122
4120
|
), l = p.flatMap(
|
|
4123
4121
|
(T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
|
|
@@ -4165,7 +4163,7 @@ class rs {
|
|
|
4165
4163
|
}
|
|
4166
4164
|
}
|
|
4167
4165
|
export {
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4166
|
+
as as Compiler,
|
|
4167
|
+
is as serialize,
|
|
4168
|
+
rs as services
|
|
4171
4169
|
};
|