@dbml/parse 3.1.3-alpha.0 → 3.1.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +8 -10
- package/dist/dbml-parse.mjs +529 -531
- 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 u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
3
|
function $t(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 V {
|
|
40
40
|
constructor(e, n, s, i, r) {
|
|
41
41
|
this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
|
|
42
42
|
}
|
|
43
43
|
static create(e, n, s, i, r) {
|
|
44
|
-
return new
|
|
44
|
+
return new V(e, n, s, 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 === u.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 jt {
|
|
|
75
75
|
return this.id++;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class x {
|
|
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, n, s) {
|
|
82
82
|
this.id = e, this.kind = n;
|
|
83
83
|
const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof V ? Lt(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof V ? 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 F extends x {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class _ extends
|
|
103
|
+
class _ extends x {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -123,12 +123,12 @@ class _ extends y {
|
|
|
123
123
|
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = c;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class te extends
|
|
126
|
+
class te extends x {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class ne extends
|
|
131
|
+
class ne extends x {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: n,
|
|
@@ -137,12 +137,12 @@ class ne extends y {
|
|
|
137
137
|
super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class Q extends
|
|
140
|
+
class Q extends x {
|
|
141
141
|
constructor({ op: e, expression: n }, s) {
|
|
142
142
|
super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class q extends
|
|
145
|
+
class q extends x {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,22 +151,22 @@ class q extends y {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class De extends x {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class K extends
|
|
159
|
+
class K extends x {
|
|
160
160
|
constructor({ value: e }, n) {
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class v extends
|
|
164
|
+
class v extends x {
|
|
165
165
|
constructor({ callee: e, args: n = [] }, s) {
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class ee extends
|
|
169
|
+
class ee extends x {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -175,7 +175,7 @@ class ee extends y {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class U extends
|
|
178
|
+
class U extends x {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: n = [],
|
|
@@ -189,7 +189,7 @@ class U extends y {
|
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class J extends
|
|
192
|
+
class J extends x {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -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 x {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: n
|
|
@@ -228,28 +228,28 @@ class H extends y {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class pe extends x {
|
|
232
232
|
constructor({ literal: e }, n) {
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class W extends x {
|
|
237
237
|
constructor({ variable: e }, n) {
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class
|
|
241
|
+
class R extends x {
|
|
242
242
|
constructor({ expression: e }, n) {
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class we extends x {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
|
-
const s =
|
|
248
|
+
const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
252
|
+
class he extends x {
|
|
253
253
|
constructor({ expression: e, indexer: n }, s) {
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
@@ -260,16 +260,16 @@ function gt(t, e) {
|
|
|
260
260
|
if (!e || e.length === 0)
|
|
261
261
|
return t || [];
|
|
262
262
|
const [n] = t, [s] = e;
|
|
263
|
-
return (n.start < s.start ?
|
|
263
|
+
return (n.start < s.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 as(t, e = !1) {
|
|
268
268
|
return JSON.stringify(
|
|
269
269
|
t,
|
|
270
270
|
function(n, s) {
|
|
271
271
|
var i;
|
|
272
|
-
return !(this instanceof
|
|
272
|
+
return !(this instanceof F) && n === "symbol" ? s == null ? void 0 : s.id : (
|
|
273
273
|
/* this instanceof SyntaxNode && */
|
|
274
274
|
n === "symbol" ? {
|
|
275
275
|
symbolTable: s == null ? void 0 : s.symbolTable,
|
|
@@ -290,7 +290,7 @@ function rs(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) {
|
|
@@ -370,7 +370,7 @@ function Fe(t, e) {
|
|
|
370
370
|
case "Schema":
|
|
371
371
|
return $e(t);
|
|
372
372
|
case "Table":
|
|
373
|
-
return
|
|
373
|
+
return xe(t);
|
|
374
374
|
case "TableGroup":
|
|
375
375
|
return ze(t);
|
|
376
376
|
case "TableGroup field":
|
|
@@ -381,7 +381,7 @@ function Fe(t, e) {
|
|
|
381
381
|
}
|
|
382
382
|
function se(t) {
|
|
383
383
|
const [e, n] = t.split(":");
|
|
384
|
-
return Object.values(m).includes(e) ? new
|
|
384
|
+
return Object.values(m).includes(e) ? new S({
|
|
385
385
|
name: n,
|
|
386
386
|
kind: e
|
|
387
387
|
}) : new A();
|
|
@@ -396,7 +396,7 @@ function zt(t) {
|
|
|
396
396
|
function Qt(t) {
|
|
397
397
|
return [
|
|
398
398
|
$e,
|
|
399
|
-
|
|
399
|
+
xe,
|
|
400
400
|
je,
|
|
401
401
|
ze,
|
|
402
402
|
We,
|
|
@@ -408,16 +408,16 @@ function qe(t) {
|
|
|
408
408
|
const [e] = t;
|
|
409
409
|
return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
|
|
410
410
|
}
|
|
411
|
-
function
|
|
411
|
+
function ke(t) {
|
|
412
412
|
const [e] = t;
|
|
413
413
|
return e >= "0" && e <= "9";
|
|
414
414
|
}
|
|
415
415
|
function qt(t) {
|
|
416
416
|
const [e] = t;
|
|
417
|
-
return
|
|
417
|
+
return ke(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
418
418
|
}
|
|
419
|
-
function
|
|
420
|
-
return qe(t) ||
|
|
419
|
+
function Ie(t) {
|
|
420
|
+
return qe(t) || ke(t);
|
|
421
421
|
}
|
|
422
422
|
function ct(t, e) {
|
|
423
423
|
const n = [], s = Math.min(t.length, e.length);
|
|
@@ -425,7 +425,7 @@ function ct(t, e) {
|
|
|
425
425
|
n.push(t[i], e[i]);
|
|
426
426
|
return n.push(...t.slice(s), ...e.slice(s)), n;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function Le(t, e) {
|
|
429
429
|
return t >= e.start && t < e.end;
|
|
430
430
|
}
|
|
431
431
|
class Ht {
|
|
@@ -480,7 +480,7 @@ class l extends Error {
|
|
|
480
480
|
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, l.prototype);
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
class
|
|
483
|
+
class B {
|
|
484
484
|
constructor(e, n) {
|
|
485
485
|
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
486
486
|
}
|
|
@@ -492,20 +492,20 @@ class V {
|
|
|
492
492
|
}
|
|
493
493
|
chain(e) {
|
|
494
494
|
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
495
|
-
return new
|
|
495
|
+
return new B(n.value, s);
|
|
496
496
|
}
|
|
497
497
|
map(e) {
|
|
498
|
-
return new
|
|
498
|
+
return new B(e(this.value), this.errors);
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
function nn(t, e, n) {
|
|
502
|
-
if (!t || !
|
|
502
|
+
if (!t || !fe(t) || e.length === 0)
|
|
503
503
|
return new A();
|
|
504
504
|
const s = [...e], i = Be(t).unwrap(), r = s.pop();
|
|
505
505
|
if (!(r instanceof ee))
|
|
506
506
|
return new A();
|
|
507
|
-
const a =
|
|
508
|
-
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new
|
|
507
|
+
const a = I.last(s) instanceof U ? s.pop() : void 0;
|
|
508
|
+
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
|
|
509
509
|
n.create(_, {
|
|
510
510
|
type: i,
|
|
511
511
|
name: s[0],
|
|
@@ -514,14 +514,14 @@ function nn(t, e, n) {
|
|
|
514
514
|
attributeList: a,
|
|
515
515
|
body: r
|
|
516
516
|
})
|
|
517
|
-
) : s.length === 1 ? new
|
|
517
|
+
) : s.length === 1 ? new S(
|
|
518
518
|
n.create(_, {
|
|
519
519
|
type: i,
|
|
520
520
|
name: s[0],
|
|
521
521
|
attributeList: a,
|
|
522
522
|
body: r
|
|
523
523
|
})
|
|
524
|
-
) : s.length === 0 ? new
|
|
524
|
+
) : s.length === 0 ? new S(
|
|
525
525
|
n.create(_, {
|
|
526
526
|
type: i,
|
|
527
527
|
attributeList: a,
|
|
@@ -533,7 +533,7 @@ function lt(t) {
|
|
|
533
533
|
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
534
534
|
}
|
|
535
535
|
function E(t) {
|
|
536
|
-
t && (t instanceof
|
|
536
|
+
t && (t instanceof V ? sn(t) : rn(t));
|
|
537
537
|
}
|
|
538
538
|
function sn(t) {
|
|
539
539
|
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
@@ -549,7 +549,7 @@ function rn(t) {
|
|
|
549
549
|
E(t.op), E(t.expression);
|
|
550
550
|
else if (t instanceof q)
|
|
551
551
|
E(t.leftExpression), E(t.op), E(t.rightExpression);
|
|
552
|
-
else if (t instanceof
|
|
552
|
+
else if (t instanceof De)
|
|
553
553
|
E(t.op), E(t.expression);
|
|
554
554
|
else if (t instanceof ee)
|
|
555
555
|
E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
|
|
@@ -561,13 +561,13 @@ function rn(t) {
|
|
|
561
561
|
E(t.callee), E(t.argumentList);
|
|
562
562
|
else if (t instanceof v)
|
|
563
563
|
E(t.callee), t.args.forEach(E);
|
|
564
|
-
else if (t instanceof
|
|
564
|
+
else if (t instanceof R)
|
|
565
565
|
E(t.expression);
|
|
566
566
|
else if (t instanceof K)
|
|
567
567
|
E(t.value);
|
|
568
|
-
else if (t instanceof
|
|
568
|
+
else if (t instanceof W)
|
|
569
569
|
E(t.variable);
|
|
570
|
-
else if (t instanceof
|
|
570
|
+
else if (t instanceof pe)
|
|
571
571
|
E(t.literal);
|
|
572
572
|
else
|
|
573
573
|
throw t instanceof Xe ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
@@ -579,7 +579,7 @@ function P(...t) {
|
|
|
579
579
|
return t.filter((e) => e !== void 0);
|
|
580
580
|
}
|
|
581
581
|
function an(t) {
|
|
582
|
-
if (t instanceof
|
|
582
|
+
if (t instanceof F)
|
|
583
583
|
return P(...t.body, t.eof);
|
|
584
584
|
if (t instanceof _)
|
|
585
585
|
return P(
|
|
@@ -595,15 +595,15 @@ function an(t) {
|
|
|
595
595
|
return P(t.name, t.colon, t.value);
|
|
596
596
|
if (t instanceof te)
|
|
597
597
|
return t.identifiers;
|
|
598
|
-
if (t instanceof
|
|
598
|
+
if (t instanceof pe)
|
|
599
599
|
return t.literal ? [t.literal] : [];
|
|
600
|
-
if (t instanceof
|
|
600
|
+
if (t instanceof W)
|
|
601
601
|
return P(t.variable);
|
|
602
602
|
if (t instanceof Q)
|
|
603
603
|
return P(t.op, t.expression);
|
|
604
604
|
if (t instanceof q)
|
|
605
605
|
return P(t.leftExpression, t.op, t.rightExpression);
|
|
606
|
-
if (t instanceof
|
|
606
|
+
if (t instanceof De)
|
|
607
607
|
return P(t.expression, t.op);
|
|
608
608
|
if (t instanceof K)
|
|
609
609
|
return P(t.value);
|
|
@@ -625,33 +625,33 @@ function an(t) {
|
|
|
625
625
|
);
|
|
626
626
|
if (t instanceof H)
|
|
627
627
|
return P(t.callee, t.argumentList);
|
|
628
|
-
if (t instanceof
|
|
628
|
+
if (t instanceof R)
|
|
629
629
|
return P(t.expression);
|
|
630
630
|
throw t instanceof Xe ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
631
631
|
}
|
|
632
632
|
function Be(t) {
|
|
633
|
-
return M(t) ? new
|
|
633
|
+
return M(t) ? new S(t.expression.variable) : new A();
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function j(t) {
|
|
636
636
|
var e;
|
|
637
|
-
return t instanceof
|
|
637
|
+
return t instanceof R && (t.expression instanceof W && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
638
638
|
}
|
|
639
639
|
function M(t) {
|
|
640
|
-
return t instanceof
|
|
640
|
+
return t instanceof R && t.expression instanceof W && t.expression.variable instanceof V;
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function fe(t) {
|
|
643
643
|
var e;
|
|
644
|
-
return t instanceof
|
|
644
|
+
return t instanceof R && t.expression instanceof W && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
645
645
|
}
|
|
646
646
|
function He(t) {
|
|
647
647
|
var e;
|
|
648
|
-
return t instanceof q && t.leftExpression instanceof
|
|
648
|
+
return t instanceof q && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
649
649
|
}
|
|
650
|
-
function
|
|
650
|
+
function Re(t) {
|
|
651
651
|
if (t === void 0)
|
|
652
652
|
return new A();
|
|
653
653
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
654
|
-
return e === "" ? new A() : new
|
|
654
|
+
return e === "" ? new A() : new S(e);
|
|
655
655
|
}
|
|
656
656
|
class on {
|
|
657
657
|
// list of errors during lexing
|
|
@@ -693,7 +693,7 @@ class on {
|
|
|
693
693
|
this.tokens.push(this.createToken(e, n));
|
|
694
694
|
}
|
|
695
695
|
createToken(e, n = !1) {
|
|
696
|
-
return
|
|
696
|
+
return V.create(
|
|
697
697
|
e,
|
|
698
698
|
this.start,
|
|
699
699
|
this.current,
|
|
@@ -702,7 +702,7 @@ class on {
|
|
|
702
702
|
);
|
|
703
703
|
}
|
|
704
704
|
lex() {
|
|
705
|
-
return this.scanTokens(), this.tokens.push(
|
|
705
|
+
return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
|
|
706
706
|
}
|
|
707
707
|
scanTokens() {
|
|
708
708
|
for (; !this.isAtEnd(); ) {
|
|
@@ -771,7 +771,7 @@ class on {
|
|
|
771
771
|
this.identifier();
|
|
772
772
|
break;
|
|
773
773
|
}
|
|
774
|
-
if (
|
|
774
|
+
if (ke(e)) {
|
|
775
775
|
this.numericLiteral();
|
|
776
776
|
break;
|
|
777
777
|
}
|
|
@@ -839,7 +839,7 @@ class on {
|
|
|
839
839
|
);
|
|
840
840
|
return;
|
|
841
841
|
}
|
|
842
|
-
a && this.match(n), this.tokens.push(
|
|
842
|
+
a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, c, !1));
|
|
843
843
|
}
|
|
844
844
|
singleLineStringLiteral() {
|
|
845
845
|
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
@@ -886,7 +886,7 @@ class on {
|
|
|
886
886
|
});
|
|
887
887
|
}
|
|
888
888
|
identifier() {
|
|
889
|
-
for (; !this.isAtEnd() &&
|
|
889
|
+
for (; !this.isAtEnd() && Ie(this.peek()); )
|
|
890
890
|
this.advance();
|
|
891
891
|
this.addToken(u.IDENTIFIER);
|
|
892
892
|
}
|
|
@@ -905,19 +905,19 @@ class on {
|
|
|
905
905
|
break;
|
|
906
906
|
if (!s && this.current.offset === this.text.length - 1)
|
|
907
907
|
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
908
|
-
if (!s && !
|
|
908
|
+
if (!s && !Ie(this.peek()))
|
|
909
909
|
return this.addToken(u.NUMERIC_LITERAL);
|
|
910
|
-
if (!s && !
|
|
910
|
+
if (!s && !ke(this.peek()))
|
|
911
911
|
break;
|
|
912
912
|
this.advance();
|
|
913
913
|
}
|
|
914
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
914
|
+
for (; !this.isAtEnd() && (this.check(".") || Ie(this.peek())); )
|
|
915
915
|
this.advance();
|
|
916
916
|
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
917
917
|
this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
918
918
|
}
|
|
919
919
|
colorLiteral() {
|
|
920
|
-
for (; !this.isAtEnd() &&
|
|
920
|
+
for (; !this.isAtEnd() && Ie(this.peek()); )
|
|
921
921
|
this.advance();
|
|
922
922
|
this.addToken(u.COLOR_LITERAL);
|
|
923
923
|
}
|
|
@@ -949,7 +949,7 @@ class on {
|
|
|
949
949
|
case "u": {
|
|
950
950
|
let e = "";
|
|
951
951
|
for (let n = 0; n <= 3; n += 1) {
|
|
952
|
-
if (this.isAtEnd() || !
|
|
952
|
+
if (this.isAtEnd() || !Ie(this.peek()))
|
|
953
953
|
return `\\u${e}`;
|
|
954
954
|
e += this.advance();
|
|
955
955
|
}
|
|
@@ -960,7 +960,7 @@ class on {
|
|
|
960
960
|
}
|
|
961
961
|
}
|
|
962
962
|
}
|
|
963
|
-
var
|
|
963
|
+
var ye = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ye || {});
|
|
964
964
|
class cn {
|
|
965
965
|
constructor() {
|
|
966
966
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
@@ -973,7 +973,7 @@ class cn {
|
|
|
973
973
|
return e === 0 && (this.numberOfNestedLBrackets -= 1), e === 1 && (this.numberOfNestedLParens -= 1), e === 2 && (this.numberOfNestedLBraces -= 1), e;
|
|
974
974
|
}
|
|
975
975
|
top() {
|
|
976
|
-
return
|
|
976
|
+
return I.last(this.stack);
|
|
977
977
|
}
|
|
978
978
|
isWithinGroupExpressionContext() {
|
|
979
979
|
return this.numberOfNestedLParens > 0;
|
|
@@ -1059,7 +1059,7 @@ class un {
|
|
|
1059
1059
|
break;
|
|
1060
1060
|
E(s), this.advance();
|
|
1061
1061
|
}
|
|
1062
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1062
|
+
}, this.blockExpression = this.contextStack.withContextDo(ye.BlockExpression, () => {
|
|
1063
1063
|
const s = { body: [] }, i = () => this.nodeFactory.create(ee, s);
|
|
1064
1064
|
try {
|
|
1065
1065
|
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
@@ -1098,7 +1098,7 @@ class un {
|
|
|
1098
1098
|
break;
|
|
1099
1099
|
E(s), this.advance();
|
|
1100
1100
|
}
|
|
1101
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1101
|
+
}, this.tupleExpression = this.contextStack.withContextDo(ye.GroupExpression, () => {
|
|
1102
1102
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Xe, {
|
|
1103
1103
|
groupOpenParen: s.tupleOpenParen,
|
|
1104
1104
|
groupCloseParen: s.tupleCloseParen,
|
|
@@ -1129,7 +1129,7 @@ class un {
|
|
|
1129
1129
|
} catch (a) {
|
|
1130
1130
|
if (!(a instanceof d))
|
|
1131
1131
|
throw a;
|
|
1132
|
-
if (a.partialNode instanceof
|
|
1132
|
+
if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1133
1133
|
throw new d(a.token, r(), a.handlerContext);
|
|
1134
1134
|
this.synchronizeTuple();
|
|
1135
1135
|
}
|
|
@@ -1150,7 +1150,7 @@ class un {
|
|
|
1150
1150
|
break;
|
|
1151
1151
|
E(s), this.advance();
|
|
1152
1152
|
}
|
|
1153
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
1153
|
+
}, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
|
|
1154
1154
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, s);
|
|
1155
1155
|
try {
|
|
1156
1156
|
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
@@ -1177,7 +1177,7 @@ class un {
|
|
|
1177
1177
|
} catch (r) {
|
|
1178
1178
|
if (!(r instanceof d))
|
|
1179
1179
|
throw r;
|
|
1180
|
-
if (r.partialNode instanceof
|
|
1180
|
+
if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1181
1181
|
throw new d(r.token, i(), r.handlerContext);
|
|
1182
1182
|
this.synchronizeList();
|
|
1183
1183
|
}
|
|
@@ -1218,10 +1218,10 @@ class un {
|
|
|
1218
1218
|
return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
|
|
1219
1219
|
}
|
|
1220
1220
|
advance() {
|
|
1221
|
-
return this.isAtEnd() ?
|
|
1221
|
+
return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
|
|
1222
1222
|
}
|
|
1223
1223
|
peek(e = 0) {
|
|
1224
|
-
return e + this.current >= this.tokens.length ?
|
|
1224
|
+
return e + this.current >= this.tokens.length ? I.last(this.tokens) : this.tokens[this.current + e];
|
|
1225
1225
|
}
|
|
1226
1226
|
match(...e) {
|
|
1227
1227
|
const n = this.check(...e);
|
|
@@ -1268,8 +1268,8 @@ class un {
|
|
|
1268
1268
|
this.tokens = e;
|
|
1269
1269
|
}
|
|
1270
1270
|
parse() {
|
|
1271
|
-
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(
|
|
1272
|
-
return this.gatherInvalid(), new
|
|
1271
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(F, { body: e, eof: n });
|
|
1272
|
+
return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
|
|
1273
1273
|
}
|
|
1274
1274
|
/* Parsing and synchronizing ProgramNode */
|
|
1275
1275
|
program() {
|
|
@@ -1425,12 +1425,12 @@ class un {
|
|
|
1425
1425
|
if (Ve(this.previous()))
|
|
1426
1426
|
break;
|
|
1427
1427
|
try {
|
|
1428
|
-
n = this.nodeFactory.create(
|
|
1428
|
+
n = this.nodeFactory.create(he, {
|
|
1429
1429
|
expression: n,
|
|
1430
1430
|
indexer: this.listExpression()
|
|
1431
1431
|
});
|
|
1432
1432
|
} catch (i) {
|
|
1433
|
-
throw i instanceof d ? (n = this.nodeFactory.create(
|
|
1433
|
+
throw i instanceof d ? (n = this.nodeFactory.create(he, {
|
|
1434
1434
|
expression: n,
|
|
1435
1435
|
indexer: i.partialNode
|
|
1436
1436
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
@@ -1440,7 +1440,7 @@ class un {
|
|
|
1440
1440
|
if (r.left !== null) {
|
|
1441
1441
|
if (r.left <= e)
|
|
1442
1442
|
break;
|
|
1443
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1443
|
+
this.advance(), n = this.nodeFactory.create(De, {
|
|
1444
1444
|
expression: n,
|
|
1445
1445
|
op: i
|
|
1446
1446
|
});
|
|
@@ -1481,7 +1481,7 @@ class un {
|
|
|
1481
1481
|
`Unexpected '${n.op.value}' in an expression`
|
|
1482
1482
|
), new d(
|
|
1483
1483
|
n.op,
|
|
1484
|
-
this.nodeFactory.create(
|
|
1484
|
+
this.nodeFactory.create(we, { pre: n.op }),
|
|
1485
1485
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1486
1486
|
);
|
|
1487
1487
|
this.advance();
|
|
@@ -1495,10 +1495,10 @@ class un {
|
|
|
1495
1495
|
)) : i;
|
|
1496
1496
|
}
|
|
1497
1497
|
e = this.nodeFactory.create(Q, n);
|
|
1498
|
-
} else if (e = this.extractOperand(), e instanceof
|
|
1498
|
+
} else if (e = this.extractOperand(), e instanceof we)
|
|
1499
1499
|
throw new d(
|
|
1500
1500
|
this.peek(),
|
|
1501
|
-
this.nodeFactory.create(
|
|
1501
|
+
this.nodeFactory.create(we, { pre: this.peek() }),
|
|
1502
1502
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1503
1503
|
);
|
|
1504
1504
|
return e;
|
|
@@ -1522,7 +1522,7 @@ class un {
|
|
|
1522
1522
|
this.peek(),
|
|
1523
1523
|
o.INVALID_OPERAND,
|
|
1524
1524
|
`Invalid start of operand "${this.peek().value}"`
|
|
1525
|
-
), this.nodeFactory.create(
|
|
1525
|
+
), this.nodeFactory.create(we, { pre: this.previous() }));
|
|
1526
1526
|
}
|
|
1527
1527
|
/* Parsing FunctionExpression */
|
|
1528
1528
|
functionExpression() {
|
|
@@ -1548,17 +1548,17 @@ class un {
|
|
|
1548
1548
|
u.STRING_LITERAL,
|
|
1549
1549
|
u.NUMERIC_LITERAL
|
|
1550
1550
|
))
|
|
1551
|
-
return this.nodeFactory.create(
|
|
1552
|
-
expression: this.nodeFactory.create(
|
|
1551
|
+
return this.nodeFactory.create(R, {
|
|
1552
|
+
expression: this.nodeFactory.create(pe, { literal: this.previous() })
|
|
1553
1553
|
});
|
|
1554
1554
|
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1555
|
-
return this.nodeFactory.create(
|
|
1556
|
-
expression: this.nodeFactory.create(
|
|
1555
|
+
return this.nodeFactory.create(R, {
|
|
1556
|
+
expression: this.nodeFactory.create(W, { variable: this.previous() })
|
|
1557
1557
|
});
|
|
1558
1558
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1559
1559
|
this.peek(),
|
|
1560
|
-
this.nodeFactory.create(
|
|
1561
|
-
expression: this.nodeFactory.create(
|
|
1560
|
+
this.nodeFactory.create(R, {
|
|
1561
|
+
expression: this.nodeFactory.create(W, {})
|
|
1562
1562
|
}),
|
|
1563
1563
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1564
1564
|
);
|
|
@@ -1655,107 +1655,107 @@ const En = {
|
|
|
1655
1655
|
function ut(t) {
|
|
1656
1656
|
return En[t.value] || { left: null, right: null };
|
|
1657
1657
|
}
|
|
1658
|
-
var
|
|
1659
|
-
function
|
|
1658
|
+
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 || {});
|
|
1659
|
+
function de(t) {
|
|
1660
1660
|
var n;
|
|
1661
1661
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1662
1662
|
switch (e) {
|
|
1663
|
-
case
|
|
1664
|
-
case
|
|
1665
|
-
case
|
|
1666
|
-
case
|
|
1667
|
-
case
|
|
1668
|
-
case
|
|
1669
|
-
case
|
|
1670
|
-
return new
|
|
1663
|
+
case b.Enum:
|
|
1664
|
+
case b.Table:
|
|
1665
|
+
case b.Indexes:
|
|
1666
|
+
case b.Note:
|
|
1667
|
+
case b.Project:
|
|
1668
|
+
case b.Ref:
|
|
1669
|
+
case b.TableGroup:
|
|
1670
|
+
return new S(e);
|
|
1671
1671
|
default:
|
|
1672
1672
|
return new A();
|
|
1673
1673
|
}
|
|
1674
1674
|
}
|
|
1675
|
-
function
|
|
1675
|
+
function Ee(t) {
|
|
1676
1676
|
if (!He(t))
|
|
1677
|
-
return new
|
|
1678
|
-
const e =
|
|
1679
|
-
return e ? (e.push(t.rightExpression), new
|
|
1677
|
+
return new S([t]);
|
|
1678
|
+
const e = Ee(t.leftExpression).unwrap_or(void 0);
|
|
1679
|
+
return e ? (e.push(t.rightExpression), new S(e)) : new A();
|
|
1680
1680
|
}
|
|
1681
|
-
function
|
|
1681
|
+
function C(t) {
|
|
1682
1682
|
if (t === void 0)
|
|
1683
1683
|
return new A();
|
|
1684
|
-
const e =
|
|
1684
|
+
const e = Ee(t).unwrap_or(void 0);
|
|
1685
1685
|
if (!e)
|
|
1686
1686
|
return new A();
|
|
1687
1687
|
const n = [];
|
|
1688
1688
|
for (const s of e) {
|
|
1689
|
-
const i =
|
|
1689
|
+
const i = X(s).unwrap_or(void 0);
|
|
1690
1690
|
if (!i)
|
|
1691
1691
|
return new A();
|
|
1692
1692
|
n.push(i);
|
|
1693
1693
|
}
|
|
1694
|
-
return new
|
|
1694
|
+
return new S(n);
|
|
1695
1695
|
}
|
|
1696
|
-
function
|
|
1696
|
+
function ge(t) {
|
|
1697
1697
|
if (t === void 0)
|
|
1698
1698
|
return new A();
|
|
1699
|
-
const e =
|
|
1699
|
+
const e = Ee(t).unwrap_or(void 0);
|
|
1700
1700
|
if (!e || e.length === 0)
|
|
1701
1701
|
return new A();
|
|
1702
1702
|
const n = [];
|
|
1703
1703
|
let s;
|
|
1704
|
-
if (!M(
|
|
1704
|
+
if (!M(I.last(e))) {
|
|
1705
1705
|
const i = e.pop();
|
|
1706
1706
|
if (xt(i))
|
|
1707
1707
|
s = i.elementList.map(
|
|
1708
|
-
(r) =>
|
|
1708
|
+
(r) => G(r).unwrap()
|
|
1709
1709
|
);
|
|
1710
1710
|
else
|
|
1711
1711
|
return new A();
|
|
1712
1712
|
}
|
|
1713
1713
|
for (const i of e) {
|
|
1714
|
-
const r =
|
|
1714
|
+
const r = X(i).unwrap_or(void 0);
|
|
1715
1715
|
if (!r)
|
|
1716
1716
|
return new A();
|
|
1717
1717
|
n.push(r);
|
|
1718
1718
|
}
|
|
1719
|
-
return new
|
|
1719
|
+
return new S({
|
|
1720
1720
|
variables: n,
|
|
1721
1721
|
tupleElements: s
|
|
1722
1722
|
});
|
|
1723
1723
|
}
|
|
1724
|
-
function
|
|
1725
|
-
return M(t) ? new
|
|
1724
|
+
function X(t) {
|
|
1725
|
+
return M(t) ? new S(t.expression.variable.value) : new A();
|
|
1726
1726
|
}
|
|
1727
1727
|
function Ge(t) {
|
|
1728
1728
|
if (ht(t))
|
|
1729
|
-
return t instanceof K ? new
|
|
1729
|
+
return t instanceof K ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1730
1730
|
if (t instanceof J && t.elementList.every(ht)) {
|
|
1731
1731
|
const e = t.elementList.filter(
|
|
1732
1732
|
(s) => s instanceof K
|
|
1733
1733
|
), n = t.elementList.filter(M);
|
|
1734
|
-
return new
|
|
1734
|
+
return new S({ functional: e, nonFunctional: n });
|
|
1735
1735
|
}
|
|
1736
1736
|
return new A();
|
|
1737
1737
|
}
|
|
1738
|
-
function
|
|
1738
|
+
function G(t) {
|
|
1739
1739
|
var n;
|
|
1740
1740
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1741
|
-
return e === void 0 ? new A() : new
|
|
1741
|
+
return e === void 0 ? new A() : new S(e);
|
|
1742
1742
|
}
|
|
1743
1743
|
function z(t) {
|
|
1744
|
-
return
|
|
1744
|
+
return j(t) ? t.expression instanceof W ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
|
|
1745
1745
|
}
|
|
1746
1746
|
function Nn(t) {
|
|
1747
1747
|
var e;
|
|
1748
|
-
return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 :
|
|
1748
|
+
return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : ge(t.leftExpression).and_then(() => ge(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1749
1749
|
}
|
|
1750
1750
|
function mn(t) {
|
|
1751
|
-
const e =
|
|
1751
|
+
const e = ge(t.leftExpression), n = ge(t.rightExpression);
|
|
1752
1752
|
if (!e.isOk() || !n.isOk())
|
|
1753
1753
|
return !1;
|
|
1754
1754
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1755
1755
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1756
1756
|
}
|
|
1757
1757
|
function ht(t) {
|
|
1758
|
-
return t instanceof
|
|
1758
|
+
return t instanceof R && t.expression instanceof W || t instanceof K;
|
|
1759
1759
|
}
|
|
1760
1760
|
function Tn(t, e) {
|
|
1761
1761
|
var i, r, a, c;
|
|
@@ -1764,9 +1764,9 @@ function Tn(t, e) {
|
|
|
1764
1764
|
for (; n; ) {
|
|
1765
1765
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1766
1766
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1767
|
-
if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof
|
|
1767
|
+
if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof F && s)
|
|
1768
1768
|
return n.symbol;
|
|
1769
|
-
if (n instanceof
|
|
1769
|
+
if (n instanceof F)
|
|
1770
1770
|
return;
|
|
1771
1771
|
n = n.parent;
|
|
1772
1772
|
}
|
|
@@ -1779,7 +1779,7 @@ class bn {
|
|
|
1779
1779
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1780
1780
|
}
|
|
1781
1781
|
validateContext() {
|
|
1782
|
-
return this.declarationNode.parent instanceof
|
|
1782
|
+
return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1783
1783
|
}
|
|
1784
1784
|
validateName(e) {
|
|
1785
1785
|
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1796,10 +1796,10 @@ class bn {
|
|
|
1796
1796
|
if (e instanceof ee)
|
|
1797
1797
|
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1798
1798
|
const n = [];
|
|
1799
|
-
return
|
|
1799
|
+
return j(e.callee) || n.push(new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1800
1800
|
}
|
|
1801
1801
|
}
|
|
1802
|
-
class
|
|
1802
|
+
class Ae {
|
|
1803
1803
|
constructor() {
|
|
1804
1804
|
this.table = /* @__PURE__ */ new Map();
|
|
1805
1805
|
}
|
|
@@ -1834,8 +1834,8 @@ class In {
|
|
|
1834
1834
|
}
|
|
1835
1835
|
registerElement() {
|
|
1836
1836
|
const e = [];
|
|
1837
|
-
this.declarationNode.symbol = this.symbolFactory.create(Jt, { declaration: this.declarationNode, symbolTable: new
|
|
1838
|
-
const { name: n } = this.declarationNode, s =
|
|
1837
|
+
this.declarationNode.symbol = this.symbolFactory.create(Jt, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
1838
|
+
const { name: n } = this.declarationNode, s = C(n);
|
|
1839
1839
|
if (s.isOk()) {
|
|
1840
1840
|
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = je(r);
|
|
1841
1841
|
a.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(c, this.declarationNode.symbol);
|
|
@@ -1850,23 +1850,23 @@ class In {
|
|
|
1850
1850
|
return [];
|
|
1851
1851
|
if (e instanceof v)
|
|
1852
1852
|
return this.validateFields([e]);
|
|
1853
|
-
const [n, s] =
|
|
1853
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
1854
1854
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1855
1855
|
}
|
|
1856
1856
|
validateFields(e) {
|
|
1857
1857
|
return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1858
1858
|
const s = [];
|
|
1859
|
-
return n.callee && !M(n.callee) && s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)),
|
|
1859
|
+
return n.callee && !M(n.callee) && s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), I.last(n.args) instanceof U && s.push(...this.validateFieldSetting(I.last(n.args))), n.args.length > 1 && s.push(...n.args.map((i) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), s.push(...this.registerField(n)), s;
|
|
1860
1860
|
});
|
|
1861
1861
|
}
|
|
1862
1862
|
validateFieldSetting(e) {
|
|
1863
|
-
const n =
|
|
1863
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
1864
1864
|
for (const r in i) {
|
|
1865
1865
|
const a = i[r];
|
|
1866
1866
|
switch (r) {
|
|
1867
1867
|
case "note":
|
|
1868
1868
|
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
1869
|
-
|
|
1869
|
+
j(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1870
1870
|
});
|
|
1871
1871
|
break;
|
|
1872
1872
|
default:
|
|
@@ -1885,7 +1885,7 @@ class In {
|
|
|
1885
1885
|
}
|
|
1886
1886
|
registerField(e) {
|
|
1887
1887
|
if (e.callee && M(e.callee)) {
|
|
1888
|
-
const n =
|
|
1888
|
+
const n = G(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Zt, { declaration: e });
|
|
1889
1889
|
e.symbol = i;
|
|
1890
1890
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1891
1891
|
if (r.has(s)) {
|
|
@@ -1908,7 +1908,7 @@ class Ln {
|
|
|
1908
1908
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1909
1909
|
}
|
|
1910
1910
|
validateContext() {
|
|
1911
|
-
return this.declarationNode.parent instanceof
|
|
1911
|
+
return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new l(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1912
1912
|
}
|
|
1913
1913
|
validateName(e) {
|
|
1914
1914
|
return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
@@ -1924,7 +1924,7 @@ class Ln {
|
|
|
1924
1924
|
return [];
|
|
1925
1925
|
if (e instanceof v)
|
|
1926
1926
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1927
|
-
const [n, s] =
|
|
1927
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
1928
1928
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1929
1929
|
}
|
|
1930
1930
|
validateFields(e) {
|
|
@@ -1932,7 +1932,7 @@ class Ln {
|
|
|
1932
1932
|
if (!n.callee)
|
|
1933
1933
|
return [];
|
|
1934
1934
|
const s = [], i = [n.callee, ...n.args];
|
|
1935
|
-
return
|
|
1935
|
+
return I.last(i) instanceof U && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1936
1936
|
for (; r instanceof H; )
|
|
1937
1937
|
r.argumentList && !Ge(r.argumentList).isOk() && s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
|
|
1938
1938
|
Ge(r).isOk() || s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
@@ -1940,14 +1940,14 @@ class Ln {
|
|
|
1940
1940
|
});
|
|
1941
1941
|
}
|
|
1942
1942
|
validateFieldSetting(e) {
|
|
1943
|
-
const n =
|
|
1943
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
1944
1944
|
for (const r in i) {
|
|
1945
1945
|
const a = i[r];
|
|
1946
1946
|
switch (r) {
|
|
1947
1947
|
case "note":
|
|
1948
1948
|
case "name":
|
|
1949
1949
|
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1950
|
-
|
|
1950
|
+
j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
|
|
1951
1951
|
});
|
|
1952
1952
|
break;
|
|
1953
1953
|
case "unique":
|
|
@@ -1984,14 +1984,14 @@ class gn {
|
|
|
1984
1984
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1985
1985
|
}
|
|
1986
1986
|
validateContext() {
|
|
1987
|
-
return !(this.declarationNode.parent instanceof
|
|
1987
|
+
return !(this.declarationNode.parent instanceof F) && ![b.Table, b.Project].includes(de(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
|
|
1988
1988
|
}
|
|
1989
1989
|
validateName(e) {
|
|
1990
|
-
if (!(this.declarationNode.parent instanceof
|
|
1990
|
+
if (!(this.declarationNode.parent instanceof F))
|
|
1991
1991
|
return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
1992
1992
|
if (!e)
|
|
1993
1993
|
return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
1994
|
-
const n =
|
|
1994
|
+
const n = C(e);
|
|
1995
1995
|
if (!n.isOk())
|
|
1996
1996
|
return [];
|
|
1997
1997
|
const i = n.unwrap().join("."), r = Yt(i);
|
|
@@ -2001,19 +2001,19 @@ class gn {
|
|
|
2001
2001
|
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2002
2002
|
}
|
|
2003
2003
|
validateSettingList(e) {
|
|
2004
|
-
return e && !(this.declarationNode.parent instanceof
|
|
2004
|
+
return e && !(this.declarationNode.parent instanceof F) ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
|
|
2005
2005
|
}
|
|
2006
2006
|
validateBody(e) {
|
|
2007
2007
|
if (!e)
|
|
2008
2008
|
return [];
|
|
2009
2009
|
if (e instanceof v)
|
|
2010
2010
|
return this.validateFields([e]);
|
|
2011
|
-
const [n, s] =
|
|
2011
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2012
2012
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2013
2013
|
}
|
|
2014
2014
|
validateFields(e) {
|
|
2015
2015
|
const n = [];
|
|
2016
|
-
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))),
|
|
2016
|
+
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), j(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2017
2017
|
}
|
|
2018
2018
|
validateSubElements(e) {
|
|
2019
2019
|
return e.flatMap((n) => {
|
|
@@ -2035,7 +2035,7 @@ class _n {
|
|
|
2035
2035
|
return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2036
2036
|
}
|
|
2037
2037
|
validateName(e) {
|
|
2038
|
-
return e ?
|
|
2038
|
+
return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2039
2039
|
}
|
|
2040
2040
|
validateAlias(e) {
|
|
2041
2041
|
return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
@@ -2048,7 +2048,7 @@ class _n {
|
|
|
2048
2048
|
return [];
|
|
2049
2049
|
if (e instanceof v)
|
|
2050
2050
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2051
|
-
const [n, s] =
|
|
2051
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2052
2052
|
return [
|
|
2053
2053
|
...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2054
2054
|
...this.validateSubElements(s)
|
|
@@ -2071,10 +2071,10 @@ class An {
|
|
|
2071
2071
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2072
2072
|
}
|
|
2073
2073
|
validateContext() {
|
|
2074
|
-
return this.declarationNode.parent instanceof
|
|
2074
|
+
return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) === b.Table ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level or inside a table", this.declarationNode)];
|
|
2075
2075
|
}
|
|
2076
2076
|
validateName(e) {
|
|
2077
|
-
return e ?
|
|
2077
|
+
return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2078
2078
|
}
|
|
2079
2079
|
validateAlias(e) {
|
|
2080
2080
|
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
@@ -2087,7 +2087,7 @@ class An {
|
|
|
2087
2087
|
return [];
|
|
2088
2088
|
if (e instanceof v)
|
|
2089
2089
|
return this.validateFields([e]);
|
|
2090
|
-
const [n, s] =
|
|
2090
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2091
2091
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2092
2092
|
}
|
|
2093
2093
|
validateFields(e) {
|
|
@@ -2095,11 +2095,11 @@ class An {
|
|
|
2095
2095
|
return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2096
2096
|
const n = [];
|
|
2097
2097
|
return e.length > 1 && n.push(...e.slice(1).map((s) => new l(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2098
|
-
s.callee && !Nn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !mn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee)),
|
|
2098
|
+
s.callee && !Nn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !mn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee)), I.last(s.args) instanceof U && this.validateFieldSettings(I.last(s.args)), s.args.length > 1 && n.push(...s.args.map((i) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
|
|
2099
2099
|
}), n;
|
|
2100
2100
|
}
|
|
2101
2101
|
validateFieldSettings(e) {
|
|
2102
|
-
const n =
|
|
2102
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
2103
2103
|
for (const r in i) {
|
|
2104
2104
|
const a = i[r];
|
|
2105
2105
|
switch (r) {
|
|
@@ -2128,7 +2128,7 @@ function vn(t) {
|
|
|
2128
2128
|
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof te))
|
|
2129
2129
|
return !1;
|
|
2130
2130
|
let e;
|
|
2131
|
-
if (t instanceof te ? e =
|
|
2131
|
+
if (t instanceof te ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2132
2132
|
switch (e.toLowerCase()) {
|
|
2133
2133
|
case "cascade":
|
|
2134
2134
|
case "no action":
|
|
@@ -2152,24 +2152,24 @@ class wn {
|
|
|
2152
2152
|
return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2153
2153
|
}
|
|
2154
2154
|
validateName(e) {
|
|
2155
|
-
return e ? e instanceof
|
|
2155
|
+
return e ? e instanceof he ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2156
2156
|
}
|
|
2157
2157
|
validateAlias(e) {
|
|
2158
|
-
return e ?
|
|
2158
|
+
return e ? Sn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2159
2159
|
}
|
|
2160
2160
|
validateSettingList(e) {
|
|
2161
|
-
const n =
|
|
2161
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
2162
2162
|
for (const r in i) {
|
|
2163
2163
|
const a = i[r];
|
|
2164
2164
|
switch (r) {
|
|
2165
2165
|
case "headercolor":
|
|
2166
2166
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
|
|
2167
|
-
|
|
2167
|
+
On(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
|
|
2168
2168
|
});
|
|
2169
2169
|
break;
|
|
2170
2170
|
case "note":
|
|
2171
2171
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
2172
|
-
|
|
2172
|
+
j(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2173
2173
|
});
|
|
2174
2174
|
break;
|
|
2175
2175
|
default:
|
|
@@ -2180,15 +2180,15 @@ class wn {
|
|
|
2180
2180
|
}
|
|
2181
2181
|
registerElement() {
|
|
2182
2182
|
const e = [];
|
|
2183
|
-
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new
|
|
2184
|
-
const { name: n, alias: s } = this.declarationNode, i =
|
|
2183
|
+
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
2184
|
+
const { name: n, alias: s } = this.declarationNode, i = C(n);
|
|
2185
2185
|
if (i.isOk()) {
|
|
2186
|
-
const r = i.unwrap(), a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p =
|
|
2186
|
+
const r = [...i.unwrap()], a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
|
|
2187
2187
|
c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), c.set(p, this.declarationNode.symbol);
|
|
2188
2188
|
}
|
|
2189
|
-
if (s &&
|
|
2190
|
-
const r =
|
|
2191
|
-
this.publicSymbolTable.has(
|
|
2189
|
+
if (s && Pe(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2190
|
+
const r = G(s).unwrap(), a = xe(r);
|
|
2191
|
+
this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2192
2192
|
}
|
|
2193
2193
|
return e;
|
|
2194
2194
|
}
|
|
@@ -2197,7 +2197,7 @@ class wn {
|
|
|
2197
2197
|
return [];
|
|
2198
2198
|
if (e instanceof v)
|
|
2199
2199
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2200
|
-
const [n, s] =
|
|
2200
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2201
2201
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2202
2202
|
}
|
|
2203
2203
|
validateFields(e) {
|
|
@@ -2212,7 +2212,7 @@ class wn {
|
|
|
2212
2212
|
}
|
|
2213
2213
|
registerField(e) {
|
|
2214
2214
|
if (e.callee && M(e.callee)) {
|
|
2215
|
-
const n =
|
|
2215
|
+
const n = G(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Kt, { declaration: e });
|
|
2216
2216
|
e.symbol = i;
|
|
2217
2217
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2218
2218
|
if (r.has(s)) {
|
|
@@ -2228,15 +2228,15 @@ class wn {
|
|
|
2228
2228
|
}
|
|
2229
2229
|
// This is needed to support legacy inline settings
|
|
2230
2230
|
validateFieldSetting(e) {
|
|
2231
|
-
if (!e.slice(0, -1).every(
|
|
2231
|
+
if (!e.slice(0, -1).every(fe) || !e.slice(-1).every((p) => fe(p) || p instanceof U))
|
|
2232
2232
|
return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2233
2233
|
if (e.length === 0)
|
|
2234
2234
|
return [];
|
|
2235
2235
|
let n;
|
|
2236
|
-
|
|
2237
|
-
const s =
|
|
2236
|
+
I.last(e) instanceof U && (n = e.pop());
|
|
2237
|
+
const s = $(n), i = s.getErrors(), r = s.getValue();
|
|
2238
2238
|
for (const p of e) {
|
|
2239
|
-
const h =
|
|
2239
|
+
const h = G(p).unwrap_or("").toLowerCase();
|
|
2240
2240
|
if (h !== "pk" && h !== "unique") {
|
|
2241
2241
|
i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2242
2242
|
continue;
|
|
@@ -2250,12 +2250,12 @@ class wn {
|
|
|
2250
2250
|
switch (p) {
|
|
2251
2251
|
case "note":
|
|
2252
2252
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2253
|
-
|
|
2253
|
+
j(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2254
2254
|
});
|
|
2255
2255
|
break;
|
|
2256
2256
|
case "ref":
|
|
2257
2257
|
h.forEach((f) => {
|
|
2258
|
-
|
|
2258
|
+
Rn(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
|
|
2259
2259
|
});
|
|
2260
2260
|
break;
|
|
2261
2261
|
case "primary key":
|
|
@@ -2292,7 +2292,7 @@ class wn {
|
|
|
2292
2292
|
break;
|
|
2293
2293
|
case "default":
|
|
2294
2294
|
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
|
|
2295
|
-
|
|
2295
|
+
Dn(f.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
|
|
2296
2296
|
});
|
|
2297
2297
|
break;
|
|
2298
2298
|
default:
|
|
@@ -2315,22 +2315,25 @@ class wn {
|
|
|
2315
2315
|
}
|
|
2316
2316
|
}
|
|
2317
2317
|
function yn(t) {
|
|
2318
|
-
if (!(t instanceof H || He(t) || t instanceof
|
|
2318
|
+
if (!(t instanceof H || He(t) || t instanceof R || t instanceof he))
|
|
2319
2319
|
return !1;
|
|
2320
2320
|
if (t instanceof H) {
|
|
2321
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) ||
|
|
2321
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) || j(n) || fe(n)))
|
|
2322
2322
|
return !1;
|
|
2323
2323
|
t = t.callee;
|
|
2324
2324
|
}
|
|
2325
|
-
for (; t instanceof
|
|
2325
|
+
for (; t instanceof he; ) {
|
|
2326
2326
|
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ce(n.name)))
|
|
2327
2327
|
return !1;
|
|
2328
2328
|
t = t.array;
|
|
2329
2329
|
}
|
|
2330
|
-
const e =
|
|
2330
|
+
const e = C(t).unwrap_or(void 0);
|
|
2331
2331
|
return e !== void 0 && e.length > 0;
|
|
2332
2332
|
}
|
|
2333
|
-
|
|
2333
|
+
function xn(t, e) {
|
|
2334
|
+
return e.length === 1 && t === e[0];
|
|
2335
|
+
}
|
|
2336
|
+
class kn {
|
|
2334
2337
|
constructor(e, n, s) {
|
|
2335
2338
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2336
2339
|
}
|
|
@@ -2348,8 +2351,8 @@ class xn {
|
|
|
2348
2351
|
}
|
|
2349
2352
|
registerElement() {
|
|
2350
2353
|
const { name: e } = this.declarationNode;
|
|
2351
|
-
this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new
|
|
2352
|
-
const n =
|
|
2354
|
+
this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
2355
|
+
const n = C(e);
|
|
2353
2356
|
if (n.isOk()) {
|
|
2354
2357
|
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
|
|
2355
2358
|
if (r.has(a))
|
|
@@ -2366,13 +2369,13 @@ class xn {
|
|
|
2366
2369
|
return [];
|
|
2367
2370
|
if (e instanceof v)
|
|
2368
2371
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2369
|
-
const [n, s] =
|
|
2372
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2370
2373
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2371
2374
|
}
|
|
2372
2375
|
validateFields(e) {
|
|
2373
2376
|
return e.flatMap((n) => {
|
|
2374
2377
|
const s = [];
|
|
2375
|
-
return n.callee && !
|
|
2378
|
+
return n.callee && !C(n.callee).isOk() && s.push(new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2376
2379
|
});
|
|
2377
2380
|
}
|
|
2378
2381
|
validateSubElements(e) {
|
|
@@ -2385,7 +2388,7 @@ class xn {
|
|
|
2385
2388
|
}
|
|
2386
2389
|
registerField(e) {
|
|
2387
2390
|
if (e.callee && M(e.callee)) {
|
|
2388
|
-
const n =
|
|
2391
|
+
const n = G(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
|
|
2389
2392
|
e.symbol = i;
|
|
2390
2393
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2391
2394
|
if (r.has(s)) {
|
|
@@ -2403,32 +2406,32 @@ class xn {
|
|
|
2403
2406
|
const wt = ["-", "+"];
|
|
2404
2407
|
function ie(t) {
|
|
2405
2408
|
switch (t.type.value.toLowerCase()) {
|
|
2406
|
-
case
|
|
2409
|
+
case b.Enum:
|
|
2407
2410
|
return In;
|
|
2408
|
-
case
|
|
2411
|
+
case b.Table:
|
|
2409
2412
|
return wn;
|
|
2410
|
-
case
|
|
2411
|
-
return
|
|
2412
|
-
case
|
|
2413
|
+
case b.TableGroup:
|
|
2414
|
+
return kn;
|
|
2415
|
+
case b.Project:
|
|
2413
2416
|
return _n;
|
|
2414
|
-
case
|
|
2417
|
+
case b.Ref:
|
|
2415
2418
|
return An;
|
|
2416
|
-
case
|
|
2419
|
+
case b.Note:
|
|
2417
2420
|
return gn;
|
|
2418
|
-
case
|
|
2421
|
+
case b.Indexes:
|
|
2419
2422
|
return Ln;
|
|
2420
2423
|
default:
|
|
2421
2424
|
return bn;
|
|
2422
2425
|
}
|
|
2423
2426
|
}
|
|
2424
2427
|
function Je(t) {
|
|
2425
|
-
return !!
|
|
2428
|
+
return !!C(t).unwrap_or(!1);
|
|
2426
2429
|
}
|
|
2427
|
-
function
|
|
2428
|
-
return
|
|
2430
|
+
function Sn(t) {
|
|
2431
|
+
return Pe(t);
|
|
2429
2432
|
}
|
|
2430
|
-
function
|
|
2431
|
-
return t instanceof
|
|
2433
|
+
function Pe(t) {
|
|
2434
|
+
return t instanceof R && t.expression instanceof W;
|
|
2432
2435
|
}
|
|
2433
2436
|
function Ze(t, e, n) {
|
|
2434
2437
|
var i;
|
|
@@ -2441,7 +2444,7 @@ function Ze(t, e, n) {
|
|
|
2441
2444
|
if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
|
|
2442
2445
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2443
2446
|
} else {
|
|
2444
|
-
a = new
|
|
2447
|
+
a = new Ae();
|
|
2445
2448
|
const p = n.create(_t, { symbolTable: a });
|
|
2446
2449
|
s.set(c, p);
|
|
2447
2450
|
}
|
|
@@ -2452,9 +2455,9 @@ function Ze(t, e, n) {
|
|
|
2452
2455
|
function yt(t) {
|
|
2453
2456
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2454
2457
|
}
|
|
2455
|
-
function
|
|
2458
|
+
function On(t) {
|
|
2456
2459
|
var n;
|
|
2457
|
-
if (!(t instanceof
|
|
2460
|
+
if (!(t instanceof R) || !(t.expression instanceof pe) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2458
2461
|
return !1;
|
|
2459
2462
|
const e = t.expression.literal.value;
|
|
2460
2463
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
@@ -2467,45 +2470,45 @@ function Sn(t) {
|
|
|
2467
2470
|
function oe(t) {
|
|
2468
2471
|
return t === void 0;
|
|
2469
2472
|
}
|
|
2470
|
-
function
|
|
2473
|
+
function Dn(t) {
|
|
2471
2474
|
var e;
|
|
2472
|
-
return !!(
|
|
2475
|
+
return !!(j(t) || ce(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) && ce(t.expression) || t instanceof K);
|
|
2473
2476
|
}
|
|
2474
2477
|
function ce(t) {
|
|
2475
2478
|
var e;
|
|
2476
|
-
return t instanceof
|
|
2479
|
+
return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
|
|
2477
2480
|
}
|
|
2478
|
-
function
|
|
2481
|
+
function Rn(t) {
|
|
2479
2482
|
var n;
|
|
2480
2483
|
if (!(t instanceof Q) || !yt((n = t.op) == null ? void 0 : n.value))
|
|
2481
2484
|
return !1;
|
|
2482
|
-
const e =
|
|
2485
|
+
const e = C(t.expression).unwrap_or(void 0);
|
|
2483
2486
|
return e !== void 0 && e.length > 0;
|
|
2484
2487
|
}
|
|
2485
2488
|
function xt(t) {
|
|
2486
2489
|
return t instanceof J && t.elementList.every(M);
|
|
2487
2490
|
}
|
|
2488
|
-
function
|
|
2491
|
+
function $(t) {
|
|
2489
2492
|
var s;
|
|
2490
2493
|
const e = {}, n = [];
|
|
2491
2494
|
if (!t)
|
|
2492
|
-
return new
|
|
2495
|
+
return new B({});
|
|
2493
2496
|
for (const i of t.elementList) {
|
|
2494
2497
|
if (!i.name)
|
|
2495
2498
|
continue;
|
|
2496
|
-
if (i.name instanceof
|
|
2499
|
+
if (i.name instanceof R) {
|
|
2497
2500
|
n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2498
2501
|
continue;
|
|
2499
2502
|
}
|
|
2500
|
-
const r = (s =
|
|
2503
|
+
const r = (s = Re(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2501
2504
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2502
2505
|
}
|
|
2503
|
-
return new
|
|
2506
|
+
return new B(e, n);
|
|
2504
2507
|
}
|
|
2505
2508
|
class ft {
|
|
2506
2509
|
constructor(e, n) {
|
|
2507
2510
|
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
|
|
2508
|
-
symbolTable: new
|
|
2511
|
+
symbolTable: new Ae()
|
|
2509
2512
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2510
2513
|
}
|
|
2511
2514
|
validate() {
|
|
@@ -2520,8 +2523,8 @@ class ft {
|
|
|
2520
2523
|
);
|
|
2521
2524
|
e.push(...r.validate());
|
|
2522
2525
|
});
|
|
2523
|
-
const n = this.ast.body.filter((s) =>
|
|
2524
|
-
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new
|
|
2526
|
+
const n = this.ast.body.filter((s) => de(s).unwrap_or(void 0) === b.Project);
|
|
2527
|
+
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
|
|
2525
2528
|
}
|
|
2526
2529
|
}
|
|
2527
2530
|
class re {
|
|
@@ -2534,9 +2537,9 @@ class re {
|
|
|
2534
2537
|
bindSettingList(e, n) {
|
|
2535
2538
|
if (e)
|
|
2536
2539
|
for (const s of e.elementList) {
|
|
2537
|
-
if (s.name instanceof
|
|
2540
|
+
if (s.name instanceof R)
|
|
2538
2541
|
continue;
|
|
2539
|
-
const i =
|
|
2542
|
+
const i = Re(s.name).unwrap_or(void 0);
|
|
2540
2543
|
if (!i)
|
|
2541
2544
|
continue;
|
|
2542
2545
|
const r = n[i.toLowerCase()];
|
|
@@ -2561,7 +2564,7 @@ class re {
|
|
|
2561
2564
|
this.bindSubfield(n);
|
|
2562
2565
|
}
|
|
2563
2566
|
bindSubfield(e) {
|
|
2564
|
-
const n = [e.callee, ...e.args], s =
|
|
2567
|
+
const n = [e.callee, ...e.args], s = I.last(n);
|
|
2565
2568
|
s instanceof U && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
|
|
2566
2569
|
const { argBinderRules: i } = this.subfield.arg;
|
|
2567
2570
|
for (let r = 0; r < Math.min(n.length, i.length); r += 1)
|
|
@@ -2571,12 +2574,12 @@ class re {
|
|
|
2571
2574
|
scanAndBind(e, n) {
|
|
2572
2575
|
var s, i;
|
|
2573
2576
|
if (e)
|
|
2574
|
-
if (e instanceof
|
|
2575
|
-
if (e.expression instanceof
|
|
2577
|
+
if (e instanceof R) {
|
|
2578
|
+
if (e.expression instanceof W && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2576
2579
|
return;
|
|
2577
2580
|
this.bindFragments([e], n);
|
|
2578
2581
|
} else
|
|
2579
|
-
e instanceof q ? He(e) ? this.bindFragments(
|
|
2582
|
+
e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2580
2583
|
}
|
|
2581
2584
|
// Bind the fragments of a member access expression
|
|
2582
2585
|
// which can be a simple expression like v1.User,
|
|
@@ -2592,14 +2595,14 @@ class re {
|
|
|
2592
2595
|
return;
|
|
2593
2596
|
const T = [];
|
|
2594
2597
|
for (; s.length && h.length; ) {
|
|
2595
|
-
const f = s.pop(), N = h.pop(),
|
|
2598
|
+
const f = s.pop(), N = h.pop(), g = G(N).unwrap();
|
|
2596
2599
|
T.unshift({
|
|
2597
|
-
index: Fe(
|
|
2600
|
+
index: Fe(g, f),
|
|
2598
2601
|
referrer: N
|
|
2599
2602
|
});
|
|
2600
2603
|
}
|
|
2601
2604
|
for (; h.length; ) {
|
|
2602
|
-
const f = h.pop(), N =
|
|
2605
|
+
const f = h.pop(), N = G(f).unwrap();
|
|
2603
2606
|
T.unshift({
|
|
2604
2607
|
index: Fe(N, i),
|
|
2605
2608
|
referrer: f
|
|
@@ -2611,7 +2614,7 @@ class re {
|
|
|
2611
2614
|
...T,
|
|
2612
2615
|
{
|
|
2613
2616
|
index: Fe(
|
|
2614
|
-
|
|
2617
|
+
G(f).unwrap(),
|
|
2615
2618
|
p
|
|
2616
2619
|
),
|
|
2617
2620
|
referrer: f
|
|
@@ -2653,7 +2656,7 @@ class re {
|
|
|
2653
2656
|
s || this.errors.push(new l(o.BINDING_ERROR, n, e));
|
|
2654
2657
|
}
|
|
2655
2658
|
}
|
|
2656
|
-
class
|
|
2659
|
+
class Pn extends re {
|
|
2657
2660
|
constructor() {
|
|
2658
2661
|
super(...arguments), this.subfield = {
|
|
2659
2662
|
arg: {
|
|
@@ -2663,7 +2666,7 @@ class Rn extends re {
|
|
|
2663
2666
|
}, this.settingList = {};
|
|
2664
2667
|
}
|
|
2665
2668
|
}
|
|
2666
|
-
class
|
|
2669
|
+
class Un extends re {
|
|
2667
2670
|
constructor() {
|
|
2668
2671
|
super(...arguments), this.subfield = {
|
|
2669
2672
|
arg: {
|
|
@@ -2673,7 +2676,7 @@ class Pn extends re {
|
|
|
2673
2676
|
}, this.settingList = {};
|
|
2674
2677
|
}
|
|
2675
2678
|
}
|
|
2676
|
-
class
|
|
2679
|
+
class Mn extends re {
|
|
2677
2680
|
constructor() {
|
|
2678
2681
|
super(...arguments), this.subfield = {
|
|
2679
2682
|
arg: {
|
|
@@ -2708,7 +2711,7 @@ class Un extends re {
|
|
|
2708
2711
|
}, this.settingList = {};
|
|
2709
2712
|
}
|
|
2710
2713
|
}
|
|
2711
|
-
class
|
|
2714
|
+
class Fn extends re {
|
|
2712
2715
|
constructor() {
|
|
2713
2716
|
super(...arguments), this.subfield = {
|
|
2714
2717
|
arg: {
|
|
@@ -2718,7 +2721,7 @@ class Mn extends re {
|
|
|
2718
2721
|
}, this.settingList = {};
|
|
2719
2722
|
}
|
|
2720
2723
|
}
|
|
2721
|
-
class
|
|
2724
|
+
class Bn extends re {
|
|
2722
2725
|
constructor() {
|
|
2723
2726
|
super(...arguments), this.subfield = {
|
|
2724
2727
|
arg: {
|
|
@@ -2728,7 +2731,7 @@ class Fn extends re {
|
|
|
2728
2731
|
}, this.settingList = {};
|
|
2729
2732
|
}
|
|
2730
2733
|
}
|
|
2731
|
-
class
|
|
2734
|
+
class Vn extends re {
|
|
2732
2735
|
constructor() {
|
|
2733
2736
|
super(...arguments), this.subfield = {
|
|
2734
2737
|
arg: {
|
|
@@ -2745,7 +2748,7 @@ class Bn extends re {
|
|
|
2745
2748
|
}, this.settingList = {};
|
|
2746
2749
|
}
|
|
2747
2750
|
}
|
|
2748
|
-
class
|
|
2751
|
+
class Gn extends re {
|
|
2749
2752
|
constructor() {
|
|
2750
2753
|
super(...arguments), this.subfield = {
|
|
2751
2754
|
arg: {
|
|
@@ -2773,7 +2776,7 @@ class Vn extends re {
|
|
|
2773
2776
|
}, this.settingList = {};
|
|
2774
2777
|
}
|
|
2775
2778
|
}
|
|
2776
|
-
class
|
|
2779
|
+
class Cn extends re {
|
|
2777
2780
|
constructor() {
|
|
2778
2781
|
super(...arguments), this.subfield = {
|
|
2779
2782
|
arg: {
|
|
@@ -2792,25 +2795,25 @@ class Gn extends re {
|
|
|
2792
2795
|
}
|
|
2793
2796
|
function kt(t) {
|
|
2794
2797
|
switch (t.type.value.toLowerCase()) {
|
|
2795
|
-
case
|
|
2796
|
-
return
|
|
2797
|
-
case
|
|
2798
|
-
return Vn;
|
|
2799
|
-
case I.TableGroup:
|
|
2798
|
+
case b.Enum:
|
|
2799
|
+
return Un;
|
|
2800
|
+
case b.Table:
|
|
2800
2801
|
return Gn;
|
|
2801
|
-
case
|
|
2802
|
-
return
|
|
2803
|
-
case
|
|
2802
|
+
case b.TableGroup:
|
|
2803
|
+
return Cn;
|
|
2804
|
+
case b.Project:
|
|
2804
2805
|
return Bn;
|
|
2805
|
-
case
|
|
2806
|
+
case b.Ref:
|
|
2807
|
+
return Vn;
|
|
2808
|
+
case b.Note:
|
|
2809
|
+
return Fn;
|
|
2810
|
+
case b.Indexes:
|
|
2806
2811
|
return Mn;
|
|
2807
|
-
case I.Indexes:
|
|
2808
|
-
return Un;
|
|
2809
2812
|
default:
|
|
2810
|
-
return
|
|
2813
|
+
return Pn;
|
|
2811
2814
|
}
|
|
2812
2815
|
}
|
|
2813
|
-
class
|
|
2816
|
+
class Xn {
|
|
2814
2817
|
constructor(e) {
|
|
2815
2818
|
this.ast = e, this.errors = [];
|
|
2816
2819
|
}
|
|
@@ -2820,10 +2823,10 @@ class Cn {
|
|
|
2820
2823
|
const n = kt(e);
|
|
2821
2824
|
new n(e, this.errors).bind();
|
|
2822
2825
|
}
|
|
2823
|
-
return new
|
|
2826
|
+
return new B(this.ast, this.errors);
|
|
2824
2827
|
}
|
|
2825
2828
|
}
|
|
2826
|
-
class
|
|
2829
|
+
class $n {
|
|
2827
2830
|
constructor(e) {
|
|
2828
2831
|
this.generator = e;
|
|
2829
2832
|
}
|
|
@@ -2831,21 +2834,21 @@ class Xn {
|
|
|
2831
2834
|
return new e(n, this.generator.nextId());
|
|
2832
2835
|
}
|
|
2833
2836
|
}
|
|
2834
|
-
class
|
|
2837
|
+
class Wn {
|
|
2835
2838
|
constructor(e, n) {
|
|
2836
|
-
this.ast = e, this.symbolFactory = new
|
|
2839
|
+
this.ast = e, this.symbolFactory = new $n(n);
|
|
2837
2840
|
}
|
|
2838
2841
|
// Analyzing: Invoking both the validator and binder
|
|
2839
2842
|
analyze() {
|
|
2840
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2843
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Xn(n).resolve());
|
|
2841
2844
|
}
|
|
2842
2845
|
// For invoking the validator only
|
|
2843
2846
|
validate() {
|
|
2844
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2847
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
|
|
2845
2848
|
}
|
|
2846
2849
|
}
|
|
2847
2850
|
function pt(t, e) {
|
|
2848
|
-
const { variables: n, tupleElements: s } =
|
|
2851
|
+
const { variables: n, tupleElements: s } = ge(t).unwrap();
|
|
2849
2852
|
return s ? n.length === 0 ? {
|
|
2850
2853
|
schemaName: e.schemaName,
|
|
2851
2854
|
tableName: e.name,
|
|
@@ -2877,7 +2880,7 @@ function St(t) {
|
|
|
2877
2880
|
}
|
|
2878
2881
|
throw new Error("Invalid relation op");
|
|
2879
2882
|
}
|
|
2880
|
-
function
|
|
2883
|
+
function k(t) {
|
|
2881
2884
|
return {
|
|
2882
2885
|
start: {
|
|
2883
2886
|
offset: t.startPos.offset,
|
|
@@ -2889,16 +2892,11 @@ function x(t) {
|
|
|
2889
2892
|
}
|
|
2890
2893
|
function Ce(t) {
|
|
2891
2894
|
var n;
|
|
2892
|
-
const e = (n =
|
|
2895
|
+
const e = (n = Ee(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2893
2896
|
return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2894
2897
|
}
|
|
2895
|
-
function
|
|
2896
|
-
|
|
2897
|
-
`).map((e) => e.trim()).join(`
|
|
2898
|
-
`);
|
|
2899
|
-
}
|
|
2900
|
-
function me(t) {
|
|
2901
|
-
const e = X(t).unwrap();
|
|
2898
|
+
function Ne(t) {
|
|
2899
|
+
const e = C(t).unwrap();
|
|
2902
2900
|
return {
|
|
2903
2901
|
name: e.pop(),
|
|
2904
2902
|
schemaName: e
|
|
@@ -2918,7 +2916,7 @@ function Dt(t, e) {
|
|
|
2918
2916
|
function Rt(t, e) {
|
|
2919
2917
|
if (Array.isArray(t)) {
|
|
2920
2918
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2921
|
-
return
|
|
2919
|
+
return I.zip(i, r).every(([a, c]) => a === c);
|
|
2922
2920
|
}
|
|
2923
2921
|
const n = t.id, s = e.id;
|
|
2924
2922
|
return n === s;
|
|
@@ -2928,10 +2926,10 @@ class Ke {
|
|
|
2928
2926
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
2929
2927
|
}
|
|
2930
2928
|
interpret() {
|
|
2931
|
-
return this.ref.token =
|
|
2929
|
+
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)];
|
|
2932
2930
|
}
|
|
2933
2931
|
interpretName(e) {
|
|
2934
|
-
const n = [], s =
|
|
2932
|
+
const n = [], s = C(this.declarationNode.name).unwrap_or([]);
|
|
2935
2933
|
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
2936
2934
|
}
|
|
2937
2935
|
interpretBody(e) {
|
|
@@ -2949,20 +2947,20 @@ class Ke {
|
|
|
2949
2947
|
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
|
|
2950
2948
|
];
|
|
2951
2949
|
if (e.args[0]) {
|
|
2952
|
-
const
|
|
2953
|
-
this.ref.onDelete =
|
|
2950
|
+
const g = $(e.args[0]).getValue();
|
|
2951
|
+
this.ref.onDelete = X((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = X((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
2954
2952
|
}
|
|
2955
2953
|
const p = St(n);
|
|
2956
2954
|
return this.ref.endpoints = [
|
|
2957
2955
|
{
|
|
2958
2956
|
...pt(s, this.container),
|
|
2959
2957
|
relation: p[0],
|
|
2960
|
-
token:
|
|
2958
|
+
token: k(s)
|
|
2961
2959
|
},
|
|
2962
2960
|
{
|
|
2963
2961
|
...pt(i, this.container),
|
|
2964
2962
|
relation: p[1],
|
|
2965
|
-
token:
|
|
2963
|
+
token: k(i)
|
|
2966
2964
|
}
|
|
2967
2965
|
], this.env.refIds[c] = this.declarationNode, [];
|
|
2968
2966
|
}
|
|
@@ -2972,7 +2970,7 @@ class Pt {
|
|
|
2972
2970
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2973
2971
|
}
|
|
2974
2972
|
interpret() {
|
|
2975
|
-
this.table.token =
|
|
2973
|
+
this.table.token = k(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
|
|
2976
2974
|
const e = [
|
|
2977
2975
|
...this.interpretName(this.declarationNode.name),
|
|
2978
2976
|
...this.interpretAlias(this.declarationNode.alias),
|
|
@@ -2991,13 +2989,13 @@ class Pt {
|
|
|
2991
2989
|
}), this.pkColumns.forEach((n) => n.pk = !1)), e;
|
|
2992
2990
|
}
|
|
2993
2991
|
interpretName(e) {
|
|
2994
|
-
const { name: n, schemaName: s } =
|
|
2992
|
+
const { name: n, schemaName: s } = Ne(e);
|
|
2995
2993
|
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
2996
2994
|
}
|
|
2997
2995
|
interpretAlias(e) {
|
|
2998
2996
|
if (!e)
|
|
2999
2997
|
return [];
|
|
3000
|
-
const n =
|
|
2998
|
+
const n = G(e).unwrap_or(null);
|
|
3001
2999
|
return n && (this.env.aliases.push({
|
|
3002
3000
|
name: n,
|
|
3003
3001
|
kind: "table",
|
|
@@ -3009,16 +3007,16 @@ class Pt {
|
|
|
3009
3007
|
}
|
|
3010
3008
|
interpretSettingList(e) {
|
|
3011
3009
|
var r, a, c;
|
|
3012
|
-
const n =
|
|
3010
|
+
const n = $(e).getValue();
|
|
3013
3011
|
this.table.headerColor = (r = n.headercolor) != null && r.length ? Ot((c = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : c.value) : void 0;
|
|
3014
3012
|
const [s] = n.note || [], i = z(s == null ? void 0 : s.value).unwrap_or(void 0);
|
|
3015
3013
|
return this.table.note = s && {
|
|
3016
|
-
value:
|
|
3017
|
-
token:
|
|
3014
|
+
value: i,
|
|
3015
|
+
token: k(s)
|
|
3018
3016
|
}, [];
|
|
3019
3017
|
}
|
|
3020
3018
|
interpretBody(e) {
|
|
3021
|
-
const [n, s] =
|
|
3019
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
3022
3020
|
return [...this.interpretFields(n), ...this.interpretSubElements(s)];
|
|
3023
3021
|
}
|
|
3024
3022
|
interpretSubElements(e) {
|
|
@@ -3027,8 +3025,8 @@ class Pt {
|
|
|
3027
3025
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3028
3026
|
case "note":
|
|
3029
3027
|
return this.table.note = {
|
|
3030
|
-
value:
|
|
3031
|
-
token:
|
|
3028
|
+
value: z(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
|
|
3029
|
+
token: k(n)
|
|
3032
3030
|
}, [];
|
|
3033
3031
|
case "indexes":
|
|
3034
3032
|
return this.interpretIndexes(n);
|
|
@@ -3042,26 +3040,26 @@ class Pt {
|
|
|
3042
3040
|
return e.flatMap((n) => this.interpretColumn(n));
|
|
3043
3041
|
}
|
|
3044
3042
|
interpretColumn(e) {
|
|
3045
|
-
var a, c, p, h, T, f, N;
|
|
3043
|
+
var a, c, p, h, T, f, N, g;
|
|
3046
3044
|
const n = [], s = {};
|
|
3047
|
-
s.name =
|
|
3048
|
-
const i =
|
|
3049
|
-
s.type = i.getValue(), n.push(...i.getErrors()), s.token =
|
|
3045
|
+
s.name = G(e.callee).unwrap();
|
|
3046
|
+
const i = jn(e.args[0]);
|
|
3047
|
+
s.type = i.getValue(), n.push(...i.getErrors()), s.token = k(e), s.inline_refs = [];
|
|
3050
3048
|
const r = e.args.slice(1);
|
|
3051
|
-
if (
|
|
3052
|
-
const
|
|
3053
|
-
s.pk = !!((a =
|
|
3054
|
-
const
|
|
3055
|
-
s.note =
|
|
3056
|
-
value:
|
|
3057
|
-
token:
|
|
3049
|
+
if (I.last(r) instanceof U) {
|
|
3050
|
+
const w = $(r.pop()).getValue();
|
|
3051
|
+
s.pk = !!((a = w.pk) != null && a.length) || !!((c = w["primary key"]) != null && c.length), s.increment = !!((p = w.increment) != null && p.length), s.unique = !!((h = w.unique) != null && h.length), s.not_null = !!((T = w["not null"]) != null && T.length) && !0, s.dbdefault = Yn((N = (f = w.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3052
|
+
const me = (g = w.note) == null ? void 0 : g.at(0);
|
|
3053
|
+
s.note = me && {
|
|
3054
|
+
value: z(me.value).unwrap(),
|
|
3055
|
+
token: k(me)
|
|
3058
3056
|
};
|
|
3059
|
-
const
|
|
3060
|
-
s.inline_refs =
|
|
3061
|
-
const [nt] = Ce(
|
|
3057
|
+
const Te = w.ref || [];
|
|
3058
|
+
s.inline_refs = Te.flatMap((Y) => {
|
|
3059
|
+
const [nt] = Ce(Y.value.expression);
|
|
3062
3060
|
if (Rt(nt, e.symbol))
|
|
3063
|
-
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
3064
|
-
const
|
|
3061
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
|
|
3062
|
+
const ve = Y.value.op, Z = C(Y.value.expression).unwrap();
|
|
3065
3063
|
let le;
|
|
3066
3064
|
if (Z.length === 1) {
|
|
3067
3065
|
const [ae] = Z;
|
|
@@ -3069,75 +3067,75 @@ class Pt {
|
|
|
3069
3067
|
schemaName: this.table.schemaName,
|
|
3070
3068
|
tableName: this.table.name,
|
|
3071
3069
|
fieldNames: [ae],
|
|
3072
|
-
relation:
|
|
3073
|
-
token:
|
|
3070
|
+
relation: ve.value,
|
|
3071
|
+
token: k(Y)
|
|
3074
3072
|
};
|
|
3075
3073
|
} else if (Z.length === 2) {
|
|
3076
|
-
const [ae,
|
|
3074
|
+
const [ae, be] = Z;
|
|
3077
3075
|
le = {
|
|
3078
3076
|
schemaName: null,
|
|
3079
3077
|
tableName: ae,
|
|
3080
|
-
fieldNames: [
|
|
3081
|
-
relation:
|
|
3082
|
-
token:
|
|
3078
|
+
fieldNames: [be],
|
|
3079
|
+
relation: ve.value,
|
|
3080
|
+
token: k(Y)
|
|
3083
3081
|
};
|
|
3084
3082
|
} else if (Z.length === 3) {
|
|
3085
|
-
const [ae,
|
|
3083
|
+
const [ae, be, it] = Z;
|
|
3086
3084
|
le = {
|
|
3087
3085
|
schemaName: ae,
|
|
3088
|
-
tableName:
|
|
3086
|
+
tableName: be,
|
|
3089
3087
|
fieldNames: [it],
|
|
3090
|
-
relation:
|
|
3091
|
-
token:
|
|
3088
|
+
relation: ve.value,
|
|
3089
|
+
token: k(Y)
|
|
3092
3090
|
};
|
|
3093
3091
|
} else {
|
|
3094
|
-
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported",
|
|
3095
|
-
const ae = Z.pop(),
|
|
3092
|
+
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", Y));
|
|
3093
|
+
const ae = Z.pop(), be = Z.pop();
|
|
3096
3094
|
le = {
|
|
3097
3095
|
schemaName: Z.join("."),
|
|
3098
|
-
tableName:
|
|
3096
|
+
tableName: be,
|
|
3099
3097
|
fieldNames: [ae],
|
|
3100
|
-
relation:
|
|
3101
|
-
token:
|
|
3098
|
+
relation: ve.value,
|
|
3099
|
+
token: k(Y)
|
|
3102
3100
|
};
|
|
3103
3101
|
}
|
|
3104
|
-
const st = this.registerInlineRefToEnv(e, nt, le,
|
|
3102
|
+
const st = this.registerInlineRefToEnv(e, nt, le, Y);
|
|
3105
3103
|
return n.push(...st), st.length === 0 ? le : [];
|
|
3106
3104
|
});
|
|
3107
3105
|
}
|
|
3108
|
-
return s.pk || (s.pk = r.some((
|
|
3106
|
+
return s.pk || (s.pk = r.some((w) => X(w).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((w) => X(w).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3109
3107
|
}
|
|
3110
3108
|
interpretIndexes(e) {
|
|
3111
3109
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3112
3110
|
var a, c, p, h, T, f, N;
|
|
3113
3111
|
const s = { columns: [] }, i = n;
|
|
3114
|
-
s.token =
|
|
3112
|
+
s.token = k(e);
|
|
3115
3113
|
const r = [i.callee, ...i.args];
|
|
3116
|
-
if (
|
|
3117
|
-
const
|
|
3118
|
-
s.pk = !!((a =
|
|
3119
|
-
const
|
|
3120
|
-
s.note =
|
|
3121
|
-
value:
|
|
3122
|
-
token:
|
|
3123
|
-
}, s.type =
|
|
3114
|
+
if (I.last(r) instanceof U) {
|
|
3115
|
+
const g = $(r.pop()).getValue();
|
|
3116
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3117
|
+
const w = (T = g.note) == null ? void 0 : T.at(0);
|
|
3118
|
+
s.note = w && {
|
|
3119
|
+
value: z(w.value).unwrap(),
|
|
3120
|
+
token: k(w)
|
|
3121
|
+
}, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3124
3122
|
}
|
|
3125
|
-
return r.flatMap((
|
|
3126
|
-
if (!(
|
|
3127
|
-
return
|
|
3128
|
-
const
|
|
3129
|
-
for (;
|
|
3130
|
-
|
|
3131
|
-
return
|
|
3132
|
-
}).forEach((
|
|
3133
|
-
const { functional:
|
|
3123
|
+
return r.flatMap((g) => {
|
|
3124
|
+
if (!(g instanceof H))
|
|
3125
|
+
return g;
|
|
3126
|
+
const w = [];
|
|
3127
|
+
for (; g instanceof H; )
|
|
3128
|
+
w.push(g.argumentList), g = g.callee;
|
|
3129
|
+
return w.push(g), w;
|
|
3130
|
+
}).forEach((g) => {
|
|
3131
|
+
const { functional: w, nonFunctional: me } = Ge(g).unwrap();
|
|
3134
3132
|
s.columns.push(
|
|
3135
|
-
...
|
|
3136
|
-
value:
|
|
3133
|
+
...w.map((Te) => ({
|
|
3134
|
+
value: Te.value.value,
|
|
3137
3135
|
type: "expression"
|
|
3138
3136
|
})),
|
|
3139
|
-
...
|
|
3140
|
-
value:
|
|
3137
|
+
...me.map((Te) => ({
|
|
3138
|
+
value: G(Te).unwrap(),
|
|
3141
3139
|
type: "column"
|
|
3142
3140
|
}))
|
|
3143
3141
|
);
|
|
@@ -3160,8 +3158,8 @@ class Pt {
|
|
|
3160
3158
|
{
|
|
3161
3159
|
schemaName: this.table.schemaName,
|
|
3162
3160
|
tableName: this.table.name,
|
|
3163
|
-
fieldNames: [
|
|
3164
|
-
token:
|
|
3161
|
+
fieldNames: [X(e.callee).unwrap()],
|
|
3162
|
+
token: k(e),
|
|
3165
3163
|
relation: a[0]
|
|
3166
3164
|
},
|
|
3167
3165
|
{
|
|
@@ -3172,30 +3170,30 @@ class Pt {
|
|
|
3172
3170
|
}), [];
|
|
3173
3171
|
}
|
|
3174
3172
|
}
|
|
3175
|
-
function
|
|
3173
|
+
function jn(t) {
|
|
3176
3174
|
let e = null;
|
|
3177
|
-
t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value :
|
|
3175
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3178
3176
|
let n = "";
|
|
3179
|
-
for (; t instanceof
|
|
3177
|
+
for (; t instanceof he; )
|
|
3180
3178
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3181
|
-
const { name: s, schemaName: i } =
|
|
3182
|
-
return i.length > 1 && new
|
|
3179
|
+
const { name: s, schemaName: i } = Ne(t);
|
|
3180
|
+
return i.length > 1 && new B(
|
|
3183
3181
|
{
|
|
3184
3182
|
schemaName: i.length === 0 ? null : i[0],
|
|
3185
3183
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3186
3184
|
args: e
|
|
3187
3185
|
},
|
|
3188
3186
|
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3189
|
-
), new
|
|
3187
|
+
), new B({
|
|
3190
3188
|
schemaName: i.length === 0 ? null : i[0],
|
|
3191
3189
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3192
3190
|
args: e
|
|
3193
3191
|
});
|
|
3194
3192
|
}
|
|
3195
|
-
function
|
|
3193
|
+
function Yn(t) {
|
|
3196
3194
|
var e, n, s;
|
|
3197
3195
|
if (t) {
|
|
3198
|
-
if (
|
|
3196
|
+
if (j(t))
|
|
3199
3197
|
return {
|
|
3200
3198
|
value: z(t).unwrap(),
|
|
3201
3199
|
type: "string"
|
|
@@ -3205,7 +3203,7 @@ function jn(t) {
|
|
|
3205
3203
|
type: "number",
|
|
3206
3204
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3207
3205
|
};
|
|
3208
|
-
if (
|
|
3206
|
+
if (fe(t))
|
|
3209
3207
|
return {
|
|
3210
3208
|
value: t.expression.variable.value.toLowerCase(),
|
|
3211
3209
|
type: "boolean"
|
|
@@ -3225,34 +3223,34 @@ function jn(t) {
|
|
|
3225
3223
|
throw new Error("Unreachable");
|
|
3226
3224
|
}
|
|
3227
3225
|
}
|
|
3228
|
-
class
|
|
3226
|
+
class zn {
|
|
3229
3227
|
constructor(e, n) {
|
|
3230
3228
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3231
3229
|
}
|
|
3232
3230
|
interpret() {
|
|
3233
|
-
return this.note.token =
|
|
3231
|
+
return this.note.token = k(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
|
|
3234
3232
|
...this.interpretName(this.declarationNode.name),
|
|
3235
3233
|
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3236
3234
|
...this.interpretBody(this.declarationNode.body)
|
|
3237
3235
|
];
|
|
3238
3236
|
}
|
|
3239
3237
|
interpretName(e) {
|
|
3240
|
-
const { name: n } =
|
|
3238
|
+
const { name: n } = Ne(e);
|
|
3241
3239
|
return this.note.name = n, [];
|
|
3242
3240
|
}
|
|
3243
3241
|
interpretSettingList(e) {
|
|
3244
3242
|
var s, i, r;
|
|
3245
|
-
const n =
|
|
3243
|
+
const n = $(e).getValue();
|
|
3246
3244
|
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ot((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
|
|
3247
3245
|
}
|
|
3248
3246
|
interpretBody(e) {
|
|
3249
|
-
const [n, s] =
|
|
3247
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
3250
3248
|
return n.length !== 1 || s.length > 0 ? [
|
|
3251
3249
|
new l(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3252
3250
|
] : [...this.interpretNote(n[0])];
|
|
3253
3251
|
}
|
|
3254
3252
|
interpretNote(e) {
|
|
3255
|
-
const n =
|
|
3253
|
+
const n = I.get(e, "callee.expression.literal.value", "");
|
|
3256
3254
|
return this.note.content = n, [];
|
|
3257
3255
|
}
|
|
3258
3256
|
}
|
|
@@ -3262,10 +3260,10 @@ class Ut {
|
|
|
3262
3260
|
}
|
|
3263
3261
|
interpret() {
|
|
3264
3262
|
const e = [];
|
|
3265
|
-
this.tableGroup.token =
|
|
3266
|
-
const { name: n, schemaName: s } =
|
|
3263
|
+
this.tableGroup.token = k(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
|
|
3264
|
+
const { name: n, schemaName: s } = Ne(this.declarationNode.name);
|
|
3267
3265
|
return s.length >= 2 && (this.tableGroup.name = n, this.tableGroup.schemaName = s.join("."), e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = n, this.tableGroup.schemaName = s[0] || null, this.tableGroup.tables = this.declarationNode.body.body.map((i) => {
|
|
3268
|
-
const r =
|
|
3266
|
+
const r = C(i.callee).unwrap();
|
|
3269
3267
|
return r.length > 2 && e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", i)), {
|
|
3270
3268
|
name: r.pop(),
|
|
3271
3269
|
schemaName: r.join(".")
|
|
@@ -3278,26 +3276,26 @@ class Mt {
|
|
|
3278
3276
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3279
3277
|
}
|
|
3280
3278
|
interpret() {
|
|
3281
|
-
return this.enum.token =
|
|
3279
|
+
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)];
|
|
3282
3280
|
}
|
|
3283
3281
|
interpretName(e) {
|
|
3284
|
-
const { name: n, schemaName: s } =
|
|
3282
|
+
const { name: n, schemaName: s } = Ne(e);
|
|
3285
3283
|
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3286
3284
|
}
|
|
3287
3285
|
interpretBody(e) {
|
|
3288
3286
|
return e.body.flatMap((n) => {
|
|
3289
3287
|
var c;
|
|
3290
3288
|
const s = n, i = {};
|
|
3291
|
-
i.token =
|
|
3292
|
-
const a = (c =
|
|
3289
|
+
i.token = k(s), i.name = X(s.callee).unwrap();
|
|
3290
|
+
const a = (c = $(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3293
3291
|
return i.note = a && {
|
|
3294
|
-
value:
|
|
3295
|
-
token:
|
|
3292
|
+
value: z(a.value).unwrap(),
|
|
3293
|
+
token: k(a)
|
|
3296
3294
|
}, this.enum.values.push(i), [];
|
|
3297
3295
|
});
|
|
3298
3296
|
}
|
|
3299
3297
|
}
|
|
3300
|
-
class
|
|
3298
|
+
class Qn {
|
|
3301
3299
|
constructor(e, n) {
|
|
3302
3300
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3303
3301
|
}
|
|
@@ -3307,7 +3305,7 @@ class zn {
|
|
|
3307
3305
|
interpretName(e) {
|
|
3308
3306
|
if (!e)
|
|
3309
3307
|
return this.project.name = null, [];
|
|
3310
|
-
const { name: n } =
|
|
3308
|
+
const { name: n } = Ne(e);
|
|
3311
3309
|
return this.project.name = n, [];
|
|
3312
3310
|
}
|
|
3313
3311
|
interpretBody(e) {
|
|
@@ -3333,8 +3331,8 @@ class zn {
|
|
|
3333
3331
|
}
|
|
3334
3332
|
case "note":
|
|
3335
3333
|
return this.project.note = {
|
|
3336
|
-
value:
|
|
3337
|
-
token:
|
|
3334
|
+
value: z(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
|
|
3335
|
+
token: k(s)
|
|
3338
3336
|
}, [];
|
|
3339
3337
|
default:
|
|
3340
3338
|
return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
|
|
@@ -3342,7 +3340,7 @@ class zn {
|
|
|
3342
3340
|
});
|
|
3343
3341
|
}
|
|
3344
3342
|
}
|
|
3345
|
-
class
|
|
3343
|
+
class qn {
|
|
3346
3344
|
constructor(e) {
|
|
3347
3345
|
this.ast = e, this.env = {
|
|
3348
3346
|
schema: [],
|
|
@@ -3358,27 +3356,27 @@ class Qn {
|
|
|
3358
3356
|
}
|
|
3359
3357
|
interpret() {
|
|
3360
3358
|
const e = this.ast.body.flatMap((n) => {
|
|
3361
|
-
switch (
|
|
3362
|
-
case
|
|
3359
|
+
switch (de(n).unwrap_or(void 0)) {
|
|
3360
|
+
case b.Table:
|
|
3363
3361
|
return new Pt(n, this.env).interpret();
|
|
3364
|
-
case
|
|
3365
|
-
return new
|
|
3366
|
-
case
|
|
3362
|
+
case b.Note:
|
|
3363
|
+
return new zn(n, this.env).interpret();
|
|
3364
|
+
case b.Ref:
|
|
3367
3365
|
return new Ke(n, this.env).interpret();
|
|
3368
|
-
case
|
|
3366
|
+
case b.TableGroup:
|
|
3369
3367
|
return new Ut(n, this.env).interpret();
|
|
3370
|
-
case
|
|
3368
|
+
case b.Enum:
|
|
3371
3369
|
return new Mt(n, this.env).interpret();
|
|
3372
|
-
case
|
|
3373
|
-
return new
|
|
3370
|
+
case b.Project:
|
|
3371
|
+
return new Qn(n, this.env).interpret();
|
|
3374
3372
|
default:
|
|
3375
3373
|
return [];
|
|
3376
3374
|
}
|
|
3377
3375
|
});
|
|
3378
|
-
return new
|
|
3376
|
+
return new B(Hn(this.env), e);
|
|
3379
3377
|
}
|
|
3380
3378
|
}
|
|
3381
|
-
function
|
|
3379
|
+
function Hn(t) {
|
|
3382
3380
|
return {
|
|
3383
3381
|
schemas: [],
|
|
3384
3382
|
tables: Array.from(t.tables.values()),
|
|
@@ -3390,28 +3388,28 @@ function qn(t) {
|
|
|
3390
3388
|
project: Array.from(t.project.values())[0] || {}
|
|
3391
3389
|
};
|
|
3392
3390
|
}
|
|
3393
|
-
var
|
|
3394
|
-
function
|
|
3391
|
+
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
|
|
3392
|
+
function _e(t) {
|
|
3395
3393
|
switch (t) {
|
|
3396
3394
|
case m.Schema:
|
|
3397
|
-
return
|
|
3395
|
+
return L.Module;
|
|
3398
3396
|
case m.Table:
|
|
3399
|
-
return
|
|
3397
|
+
return L.Class;
|
|
3400
3398
|
case m.Column:
|
|
3401
|
-
return
|
|
3399
|
+
return L.Field;
|
|
3402
3400
|
case m.Enum:
|
|
3403
|
-
return
|
|
3401
|
+
return L.Enum;
|
|
3404
3402
|
case m.EnumField:
|
|
3405
|
-
return
|
|
3403
|
+
return L.EnumMember;
|
|
3406
3404
|
case m.TableGroup:
|
|
3407
|
-
return
|
|
3405
|
+
return L.Struct;
|
|
3408
3406
|
case m.TableGroupField:
|
|
3409
|
-
return
|
|
3407
|
+
return L.Field;
|
|
3410
3408
|
default:
|
|
3411
|
-
return
|
|
3409
|
+
return L.Text;
|
|
3412
3410
|
}
|
|
3413
3411
|
}
|
|
3414
|
-
function
|
|
3412
|
+
function Se(t, e) {
|
|
3415
3413
|
if (!t || Ve(t))
|
|
3416
3414
|
return !1;
|
|
3417
3415
|
for (const n of t.trailingTrivia) {
|
|
@@ -3422,12 +3420,12 @@ function ke(t, e) {
|
|
|
3422
3420
|
}
|
|
3423
3421
|
return !0;
|
|
3424
3422
|
}
|
|
3425
|
-
function
|
|
3423
|
+
function O() {
|
|
3426
3424
|
return {
|
|
3427
3425
|
suggestions: []
|
|
3428
3426
|
};
|
|
3429
3427
|
}
|
|
3430
|
-
function
|
|
3428
|
+
function Oe(t) {
|
|
3431
3429
|
return {
|
|
3432
3430
|
...t,
|
|
3433
3431
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3436,7 +3434,7 @@ function Se(t) {
|
|
|
3436
3434
|
}))
|
|
3437
3435
|
};
|
|
3438
3436
|
}
|
|
3439
|
-
function
|
|
3437
|
+
function Ue(t) {
|
|
3440
3438
|
return {
|
|
3441
3439
|
...t,
|
|
3442
3440
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3459,14 +3457,14 @@ class Ft {
|
|
|
3459
3457
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3460
3458
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3461
3459
|
...(c == null ? void 0 : c.leadingTrivia) || []
|
|
3462
|
-
].find((N) => Wt(N) &&
|
|
3463
|
-
return
|
|
3460
|
+
].find((N) => Wt(N) && Le(s, N)))
|
|
3461
|
+
return O();
|
|
3464
3462
|
if (a === void 0)
|
|
3465
3463
|
return Tt();
|
|
3466
|
-
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) &&
|
|
3467
|
-
return
|
|
3464
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
|
|
3465
|
+
return O();
|
|
3468
3466
|
const p = this.compiler.container.element(s);
|
|
3469
|
-
if (this.compiler.container.scopeKind(s) ===
|
|
3467
|
+
if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
|
|
3470
3468
|
return Tt();
|
|
3471
3469
|
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3472
3470
|
for (const N of h)
|
|
@@ -3506,31 +3504,31 @@ class Ft {
|
|
|
3506
3504
|
if (N instanceof U)
|
|
3507
3505
|
return Et(this.compiler, s, N);
|
|
3508
3506
|
if (N instanceof J)
|
|
3509
|
-
return
|
|
3507
|
+
return Jn(this.compiler, s);
|
|
3510
3508
|
if (N instanceof v)
|
|
3511
3509
|
return mt(this.compiler, s, N);
|
|
3512
|
-
if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body &&
|
|
3510
|
+
if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
|
|
3513
3511
|
return mt(this.compiler, s, void 0);
|
|
3514
3512
|
}
|
|
3515
|
-
return
|
|
3513
|
+
return O();
|
|
3516
3514
|
}
|
|
3517
3515
|
}
|
|
3518
3516
|
function dt(t, e, n) {
|
|
3519
3517
|
const s = t.container.scopeKind(e);
|
|
3520
|
-
if ([
|
|
3521
|
-
const i =
|
|
3518
|
+
if ([D.REF, D.TABLE].includes(s)) {
|
|
3519
|
+
const i = Me(t, e, t.container.element(e), [
|
|
3522
3520
|
m.Table,
|
|
3523
3521
|
m.Schema,
|
|
3524
3522
|
m.Column
|
|
3525
3523
|
]);
|
|
3526
|
-
return
|
|
3524
|
+
return Se(n.op, e) ? Oe(i) : i;
|
|
3527
3525
|
}
|
|
3528
|
-
return
|
|
3526
|
+
return O();
|
|
3529
3527
|
}
|
|
3530
|
-
function
|
|
3528
|
+
function Me(t, e, n, s) {
|
|
3531
3529
|
var a;
|
|
3532
3530
|
if (n === void 0)
|
|
3533
|
-
return
|
|
3531
|
+
return O();
|
|
3534
3532
|
let i = n;
|
|
3535
3533
|
const r = { suggestions: [] };
|
|
3536
3534
|
for (; i; ) {
|
|
@@ -3540,23 +3538,23 @@ function Ue(t, e, n, s) {
|
|
|
3540
3538
|
...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
|
|
3541
3539
|
label: p,
|
|
3542
3540
|
insertText: p,
|
|
3543
|
-
insertTextRules:
|
|
3544
|
-
kind:
|
|
3545
|
-
sortText:
|
|
3541
|
+
insertTextRules: y.KeepWhitespace,
|
|
3542
|
+
kind: _e(h),
|
|
3543
|
+
sortText: _e(h).toString().padStart(2, "0"),
|
|
3546
3544
|
range: void 0
|
|
3547
3545
|
}))
|
|
3548
3546
|
);
|
|
3549
3547
|
}
|
|
3550
3548
|
i = i instanceof _ ? i.parent : void 0;
|
|
3551
3549
|
}
|
|
3552
|
-
return
|
|
3550
|
+
return Ue(r);
|
|
3553
3551
|
}
|
|
3554
|
-
function
|
|
3552
|
+
function Jn(t, e) {
|
|
3555
3553
|
var s;
|
|
3556
3554
|
switch (t.container.scopeKind(e)) {
|
|
3557
|
-
case
|
|
3555
|
+
case D.INDEXES:
|
|
3558
3556
|
return Gt(t, e);
|
|
3559
|
-
case
|
|
3557
|
+
case D.REF:
|
|
3560
3558
|
{
|
|
3561
3559
|
const i = [...t.container.stack(e)];
|
|
3562
3560
|
for (; i.length > 0; ) {
|
|
@@ -3571,126 +3569,126 @@ function Hn(t, e) {
|
|
|
3571
3569
|
}
|
|
3572
3570
|
return Vt(t, e);
|
|
3573
3571
|
}
|
|
3574
|
-
return
|
|
3572
|
+
return O();
|
|
3575
3573
|
}
|
|
3576
3574
|
function Et(t, e, n) {
|
|
3577
3575
|
const { token: s } = t.container.token(e);
|
|
3578
3576
|
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3579
3577
|
const i = Nt(t, e);
|
|
3580
|
-
return (s == null ? void 0 : s.kind) === u.COMMA &&
|
|
3578
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && Se(s, e) ? Oe(i) : i;
|
|
3581
3579
|
}
|
|
3582
3580
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3583
3581
|
return Nt(t, e);
|
|
3584
3582
|
if (n.name) {
|
|
3585
|
-
const i =
|
|
3583
|
+
const i = Zn(
|
|
3586
3584
|
t,
|
|
3587
3585
|
e,
|
|
3588
|
-
|
|
3586
|
+
Re(n.name).unwrap()
|
|
3589
3587
|
);
|
|
3590
|
-
return (s == null ? void 0 : s.kind) === u.COLON &&
|
|
3588
|
+
return (s == null ? void 0 : s.kind) === u.COLON && Se(s, e) ? Oe(i) : i;
|
|
3591
3589
|
}
|
|
3592
|
-
return
|
|
3590
|
+
return O();
|
|
3593
3591
|
}
|
|
3594
3592
|
function Nt(t, e) {
|
|
3595
3593
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3596
|
-
if (n instanceof
|
|
3597
|
-
return
|
|
3598
|
-
if (n.body && !
|
|
3594
|
+
if (n instanceof F)
|
|
3595
|
+
return O();
|
|
3596
|
+
if (n.body && !Le(e, n.body))
|
|
3599
3597
|
switch (s) {
|
|
3600
|
-
case
|
|
3598
|
+
case D.TABLE:
|
|
3601
3599
|
return {
|
|
3602
3600
|
suggestions: [
|
|
3603
3601
|
{
|
|
3604
3602
|
label: "headercolor",
|
|
3605
3603
|
insertText: "headercolor: ",
|
|
3606
|
-
kind:
|
|
3607
|
-
insertTextRules:
|
|
3604
|
+
kind: L.Field,
|
|
3605
|
+
insertTextRules: y.KeepWhitespace,
|
|
3608
3606
|
range: void 0
|
|
3609
3607
|
},
|
|
3610
3608
|
{
|
|
3611
3609
|
label: "note",
|
|
3612
3610
|
insertText: "note: ",
|
|
3613
|
-
kind:
|
|
3614
|
-
insertTextRules:
|
|
3611
|
+
kind: L.Field,
|
|
3612
|
+
insertTextRules: y.KeepWhitespace,
|
|
3615
3613
|
range: void 0
|
|
3616
3614
|
}
|
|
3617
3615
|
]
|
|
3618
3616
|
};
|
|
3619
3617
|
default:
|
|
3620
|
-
return
|
|
3618
|
+
return O();
|
|
3621
3619
|
}
|
|
3622
3620
|
switch (s) {
|
|
3623
|
-
case
|
|
3621
|
+
case D.TABLE:
|
|
3624
3622
|
return {
|
|
3625
3623
|
suggestions: [
|
|
3626
3624
|
...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
|
|
3627
3625
|
label: i,
|
|
3628
3626
|
insertText: i,
|
|
3629
|
-
kind:
|
|
3630
|
-
insertTextRules:
|
|
3627
|
+
kind: L.Property,
|
|
3628
|
+
insertTextRules: y.KeepWhitespace,
|
|
3631
3629
|
range: void 0
|
|
3632
3630
|
})),
|
|
3633
3631
|
...["ref", "default"].map((i) => ({
|
|
3634
3632
|
label: i,
|
|
3635
3633
|
insertText: `${i}: `,
|
|
3636
|
-
kind:
|
|
3637
|
-
insertTextRules:
|
|
3634
|
+
kind: L.Property,
|
|
3635
|
+
insertTextRules: y.KeepWhitespace,
|
|
3638
3636
|
range: void 0
|
|
3639
3637
|
})),
|
|
3640
3638
|
{
|
|
3641
3639
|
label: "note",
|
|
3642
3640
|
insertText: "note: ",
|
|
3643
|
-
kind:
|
|
3644
|
-
insertTextRules:
|
|
3641
|
+
kind: L.Property,
|
|
3642
|
+
insertTextRules: y.KeepWhitespace,
|
|
3645
3643
|
range: void 0
|
|
3646
3644
|
}
|
|
3647
3645
|
]
|
|
3648
3646
|
};
|
|
3649
|
-
case
|
|
3647
|
+
case D.ENUM:
|
|
3650
3648
|
return {
|
|
3651
3649
|
suggestions: [
|
|
3652
3650
|
{
|
|
3653
3651
|
label: "note",
|
|
3654
3652
|
insertText: "note: ",
|
|
3655
|
-
kind:
|
|
3656
|
-
insertTextRules:
|
|
3653
|
+
kind: L.Property,
|
|
3654
|
+
insertTextRules: y.KeepWhitespace,
|
|
3657
3655
|
range: void 0
|
|
3658
3656
|
}
|
|
3659
3657
|
]
|
|
3660
3658
|
};
|
|
3661
|
-
case
|
|
3659
|
+
case D.INDEXES:
|
|
3662
3660
|
return {
|
|
3663
3661
|
suggestions: [
|
|
3664
3662
|
...["unique", "pk"].map((i) => ({
|
|
3665
3663
|
label: i,
|
|
3666
3664
|
insertText: i,
|
|
3667
|
-
insertTextRules:
|
|
3668
|
-
kind:
|
|
3665
|
+
insertTextRules: y.KeepWhitespace,
|
|
3666
|
+
kind: L.Property,
|
|
3669
3667
|
range: void 0
|
|
3670
3668
|
})),
|
|
3671
3669
|
...["note", "name", "type"].map((i) => ({
|
|
3672
3670
|
label: i,
|
|
3673
3671
|
insertText: `${i}: `,
|
|
3674
|
-
kind:
|
|
3675
|
-
insertTextRules:
|
|
3672
|
+
kind: L.Property,
|
|
3673
|
+
insertTextRules: y.KeepWhitespace,
|
|
3676
3674
|
range: void 0
|
|
3677
3675
|
}))
|
|
3678
3676
|
]
|
|
3679
3677
|
};
|
|
3680
|
-
case
|
|
3678
|
+
case D.REF:
|
|
3681
3679
|
return {
|
|
3682
3680
|
suggestions: ["update", "delete"].map((i) => ({
|
|
3683
3681
|
label: i,
|
|
3684
3682
|
insertText: `${i}: `,
|
|
3685
|
-
kind:
|
|
3686
|
-
insertTextRules:
|
|
3683
|
+
kind: L.Property,
|
|
3684
|
+
insertTextRules: y.KeepWhitespace,
|
|
3687
3685
|
range: void 0
|
|
3688
3686
|
}))
|
|
3689
3687
|
};
|
|
3690
3688
|
}
|
|
3691
|
-
return
|
|
3689
|
+
return O();
|
|
3692
3690
|
}
|
|
3693
|
-
function
|
|
3691
|
+
function Zn(t, e, n) {
|
|
3694
3692
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
3695
3693
|
case "update":
|
|
3696
3694
|
case "delete":
|
|
@@ -3698,8 +3696,8 @@ function Jn(t, e, n) {
|
|
|
3698
3696
|
suggestions: ["cascade", "set default", "set null", "restrict"].map((s) => ({
|
|
3699
3697
|
label: s,
|
|
3700
3698
|
insertText: s,
|
|
3701
|
-
kind:
|
|
3702
|
-
insertTextRules:
|
|
3699
|
+
kind: L.Value,
|
|
3700
|
+
insertTextRules: y.KeepWhitespace,
|
|
3703
3701
|
range: void 0
|
|
3704
3702
|
}))
|
|
3705
3703
|
};
|
|
@@ -3708,24 +3706,24 @@ function Jn(t, e, n) {
|
|
|
3708
3706
|
suggestions: ["btree", "hash"].map((s) => ({
|
|
3709
3707
|
label: s,
|
|
3710
3708
|
insertText: `${s}`,
|
|
3711
|
-
kind:
|
|
3712
|
-
insertTextRules:
|
|
3709
|
+
kind: L.Value,
|
|
3710
|
+
insertTextRules: y.KeepWhitespace,
|
|
3713
3711
|
range: void 0
|
|
3714
3712
|
}))
|
|
3715
3713
|
};
|
|
3716
3714
|
}
|
|
3717
|
-
return
|
|
3715
|
+
return O();
|
|
3718
3716
|
}
|
|
3719
3717
|
function Bt(t, e, n) {
|
|
3720
|
-
const s =
|
|
3718
|
+
const s = Ee(n).unwrap_or([]);
|
|
3721
3719
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3722
|
-
return
|
|
3723
|
-
const i = s.map((r) =>
|
|
3724
|
-
return
|
|
3720
|
+
return O();
|
|
3721
|
+
const i = s.map((r) => X(r).unwrap());
|
|
3722
|
+
return Ue({
|
|
3725
3723
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3726
3724
|
label: a,
|
|
3727
3725
|
insertText: a,
|
|
3728
|
-
kind:
|
|
3726
|
+
kind: _e(r),
|
|
3729
3727
|
range: void 0
|
|
3730
3728
|
}))
|
|
3731
3729
|
});
|
|
@@ -3733,22 +3731,22 @@ function Bt(t, e, n) {
|
|
|
3733
3731
|
function mt(t, e, n) {
|
|
3734
3732
|
var i;
|
|
3735
3733
|
switch (t.container.scopeKind(e)) {
|
|
3736
|
-
case
|
|
3737
|
-
return Kn(t, e, n);
|
|
3738
|
-
case O.PROJECT:
|
|
3734
|
+
case D.TABLE:
|
|
3739
3735
|
return es(t, e, n);
|
|
3740
|
-
case
|
|
3741
|
-
return
|
|
3742
|
-
case
|
|
3743
|
-
return
|
|
3744
|
-
case
|
|
3736
|
+
case D.PROJECT:
|
|
3737
|
+
return ts(t, e, n);
|
|
3738
|
+
case D.INDEXES:
|
|
3739
|
+
return ss(t, e);
|
|
3740
|
+
case D.ENUM:
|
|
3741
|
+
return Kn(t, e, n);
|
|
3742
|
+
case D.REF: {
|
|
3745
3743
|
const r = Vt(t, e);
|
|
3746
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON &&
|
|
3744
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
|
|
3747
3745
|
}
|
|
3748
|
-
case
|
|
3749
|
-
return
|
|
3746
|
+
case D.TABLEGROUP:
|
|
3747
|
+
return ns(t);
|
|
3750
3748
|
default:
|
|
3751
|
-
return
|
|
3749
|
+
return O();
|
|
3752
3750
|
}
|
|
3753
3751
|
}
|
|
3754
3752
|
function Tt() {
|
|
@@ -3756,27 +3754,27 @@ function Tt() {
|
|
|
3756
3754
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3757
3755
|
label: t,
|
|
3758
3756
|
insertText: t,
|
|
3759
|
-
insertTextRules:
|
|
3760
|
-
kind:
|
|
3757
|
+
insertTextRules: y.KeepWhitespace,
|
|
3758
|
+
kind: L.Keyword,
|
|
3761
3759
|
range: void 0
|
|
3762
3760
|
}))
|
|
3763
3761
|
};
|
|
3764
3762
|
}
|
|
3765
|
-
function
|
|
3766
|
-
return n != null && n.callee && tt(e, n) === 1 ?
|
|
3763
|
+
function Kn(t, e, n) {
|
|
3764
|
+
return n != null && n.callee && tt(e, n) === 1 ? Me(t, e, t.container.element(e), [
|
|
3767
3765
|
m.Schema,
|
|
3768
3766
|
m.Table,
|
|
3769
3767
|
m.Column
|
|
3770
|
-
]) :
|
|
3768
|
+
]) : O();
|
|
3771
3769
|
}
|
|
3772
|
-
function
|
|
3770
|
+
function es(t, e, n) {
|
|
3773
3771
|
if (!(n != null && n.callee))
|
|
3774
3772
|
return {
|
|
3775
3773
|
suggestions: ["Ref", "Note", "indexes"].map((i) => ({
|
|
3776
3774
|
label: i,
|
|
3777
3775
|
insertText: i,
|
|
3778
|
-
insertTextRules:
|
|
3779
|
-
kind:
|
|
3776
|
+
insertTextRules: y.KeepWhitespace,
|
|
3777
|
+
kind: L.Keyword,
|
|
3780
3778
|
range: void 0
|
|
3781
3779
|
}))
|
|
3782
3780
|
};
|
|
@@ -3785,40 +3783,40 @@ function Kn(t, e, n) {
|
|
|
3785
3783
|
suggestions: ["Ref", "Note", "indexes"].map((i) => ({
|
|
3786
3784
|
label: i,
|
|
3787
3785
|
insertText: i,
|
|
3788
|
-
insertTextRules:
|
|
3789
|
-
kind:
|
|
3786
|
+
insertTextRules: y.KeepWhitespace,
|
|
3787
|
+
kind: L.Keyword,
|
|
3790
3788
|
range: void 0
|
|
3791
3789
|
}))
|
|
3792
|
-
} : s === 1 ?
|
|
3790
|
+
} : s === 1 ? is(t, e) : O();
|
|
3793
3791
|
}
|
|
3794
|
-
function
|
|
3792
|
+
function ts(t, e, n) {
|
|
3795
3793
|
return n != null && n.callee ? tt(e, n) === 0 ? {
|
|
3796
3794
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3797
3795
|
label: i,
|
|
3798
3796
|
insertText: i,
|
|
3799
|
-
insertTextRules:
|
|
3800
|
-
kind:
|
|
3797
|
+
insertTextRules: y.KeepWhitespace,
|
|
3798
|
+
kind: L.Keyword,
|
|
3801
3799
|
range: void 0
|
|
3802
3800
|
}))
|
|
3803
|
-
} :
|
|
3801
|
+
} : O() : {
|
|
3804
3802
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3805
3803
|
label: i,
|
|
3806
3804
|
insertText: i,
|
|
3807
|
-
insertTextRules:
|
|
3808
|
-
kind:
|
|
3805
|
+
insertTextRules: y.KeepWhitespace,
|
|
3806
|
+
kind: L.Keyword,
|
|
3809
3807
|
range: void 0
|
|
3810
3808
|
}))
|
|
3811
3809
|
};
|
|
3812
3810
|
}
|
|
3813
3811
|
function Vt(t, e) {
|
|
3814
|
-
return
|
|
3812
|
+
return Me(t, e, t.container.element(e), [
|
|
3815
3813
|
m.Schema,
|
|
3816
3814
|
m.Table,
|
|
3817
3815
|
m.Column
|
|
3818
3816
|
]);
|
|
3819
3817
|
}
|
|
3820
|
-
function
|
|
3821
|
-
return
|
|
3818
|
+
function ns(t) {
|
|
3819
|
+
return Ue({
|
|
3822
3820
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3823
3821
|
const n = se(e).unwrap_or(void 0);
|
|
3824
3822
|
if (n === void 0)
|
|
@@ -3827,17 +3825,17 @@ function ts(t) {
|
|
|
3827
3825
|
return s !== m.Table && s !== m.Schema ? [] : {
|
|
3828
3826
|
label: i,
|
|
3829
3827
|
insertText: i,
|
|
3830
|
-
insertTextRules:
|
|
3831
|
-
kind:
|
|
3828
|
+
insertTextRules: y.KeepWhitespace,
|
|
3829
|
+
kind: _e(s),
|
|
3832
3830
|
range: void 0
|
|
3833
3831
|
};
|
|
3834
3832
|
})
|
|
3835
3833
|
});
|
|
3836
3834
|
}
|
|
3837
|
-
function
|
|
3835
|
+
function ss(t, e) {
|
|
3838
3836
|
return Gt(t, e);
|
|
3839
3837
|
}
|
|
3840
|
-
function
|
|
3838
|
+
function is(t, e) {
|
|
3841
3839
|
return {
|
|
3842
3840
|
suggestions: [
|
|
3843
3841
|
...[
|
|
@@ -3900,12 +3898,12 @@ function ss(t, e) {
|
|
|
3900
3898
|
].map((n) => ({
|
|
3901
3899
|
label: n,
|
|
3902
3900
|
insertText: n,
|
|
3903
|
-
insertTextRules:
|
|
3904
|
-
kind:
|
|
3905
|
-
sortText:
|
|
3901
|
+
insertTextRules: y.KeepWhitespace,
|
|
3902
|
+
kind: L.TypeParameter,
|
|
3903
|
+
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3906
3904
|
range: void 0
|
|
3907
3905
|
})),
|
|
3908
|
-
...
|
|
3906
|
+
...Me(t, e, t.container.element(e), [
|
|
3909
3907
|
m.Enum,
|
|
3910
3908
|
m.Schema
|
|
3911
3909
|
]).suggestions
|
|
@@ -3915,9 +3913,9 @@ function ss(t, e) {
|
|
|
3915
3913
|
function Gt(t, e) {
|
|
3916
3914
|
const s = t.container.element(e).parent;
|
|
3917
3915
|
if (!((s == null ? void 0 : s.symbol) instanceof At))
|
|
3918
|
-
return
|
|
3916
|
+
return O();
|
|
3919
3917
|
const { symbolTable: i } = s.symbol;
|
|
3920
|
-
return
|
|
3918
|
+
return Ue({
|
|
3921
3919
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
3922
3920
|
const a = se(r).unwrap_or(void 0);
|
|
3923
3921
|
if (a === void 0)
|
|
@@ -3926,8 +3924,8 @@ function Gt(t, e) {
|
|
|
3926
3924
|
return {
|
|
3927
3925
|
label: c,
|
|
3928
3926
|
insertText: c,
|
|
3929
|
-
insertTextRules:
|
|
3930
|
-
kind:
|
|
3927
|
+
insertTextRules: y.KeepWhitespace,
|
|
3928
|
+
kind: _e(m.Column),
|
|
3931
3929
|
range: void 0
|
|
3932
3930
|
};
|
|
3933
3931
|
})
|
|
@@ -3948,7 +3946,7 @@ class Ct {
|
|
|
3948
3946
|
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
3949
3947
|
for (; r.length !== 0; ) {
|
|
3950
3948
|
const c = r.pop();
|
|
3951
|
-
if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [
|
|
3949
|
+
if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [ue.PRIMARY_EXPRESSION, ue.VARIABLE].includes(c == null ? void 0 : c.kind)) {
|
|
3952
3950
|
const { startPos: p, endPos: h } = c.referee.declaration;
|
|
3953
3951
|
return [
|
|
3954
3952
|
{
|
|
@@ -3975,9 +3973,9 @@ class Xt {
|
|
|
3975
3973
|
for (; r.length !== 0; ) {
|
|
3976
3974
|
const a = r.pop();
|
|
3977
3975
|
if (a && [
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3976
|
+
ue.ELEMENT_DECLARATION,
|
|
3977
|
+
ue.FUNCTION_APPLICATION,
|
|
3978
|
+
ue.PRIMARY_EXPRESSION
|
|
3981
3979
|
].includes(a == null ? void 0 : a.kind)) {
|
|
3982
3980
|
const { symbol: c } = a;
|
|
3983
3981
|
if (c != null && c.references.length)
|
|
@@ -3995,16 +3993,16 @@ class Xt {
|
|
|
3995
3993
|
return [];
|
|
3996
3994
|
}
|
|
3997
3995
|
}
|
|
3998
|
-
const
|
|
3996
|
+
const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3999
3997
|
__proto__: null,
|
|
4000
|
-
CompletionItemInsertTextRule:
|
|
4001
|
-
CompletionItemKind:
|
|
3998
|
+
CompletionItemInsertTextRule: y,
|
|
3999
|
+
CompletionItemKind: L,
|
|
4002
4000
|
DBMLCompletionItemProvider: Ft,
|
|
4003
4001
|
DBMLDefinitionProvider: Ct,
|
|
4004
4002
|
DBMLReferencesProvider: Xt
|
|
4005
4003
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4006
|
-
var
|
|
4007
|
-
class
|
|
4004
|
+
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 || {});
|
|
4005
|
+
class cs {
|
|
4008
4006
|
constructor() {
|
|
4009
4007
|
this.source = "", this.cache = new Array(
|
|
4010
4008
|
16
|
|
@@ -4024,8 +4022,8 @@ class os {
|
|
|
4024
4022
|
_: this.createQuery(
|
|
4025
4023
|
0,
|
|
4026
4024
|
() => {
|
|
4027
|
-
const e = new on(this.source).lex().chain((n) => new un(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new
|
|
4028
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new
|
|
4025
|
+
const e = new on(this.source).lex().chain((n) => new un(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4026
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new qn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4029
4027
|
}
|
|
4030
4028
|
),
|
|
4031
4029
|
ast: this.createQuery(
|
|
@@ -4062,8 +4060,8 @@ class os {
|
|
|
4062
4060
|
let a = this.parse.ast();
|
|
4063
4061
|
const c = [a];
|
|
4064
4062
|
for (; ; ) {
|
|
4065
|
-
const h = an(a).find((T) =>
|
|
4066
|
-
if (h === void 0 || h instanceof
|
|
4063
|
+
const h = an(a).find((T) => Le(r, T));
|
|
4064
|
+
if (h === void 0 || h instanceof V)
|
|
4067
4065
|
break;
|
|
4068
4066
|
c.push(h), a = h;
|
|
4069
4067
|
}
|
|
@@ -4071,7 +4069,7 @@ class os {
|
|
|
4071
4069
|
return c;
|
|
4072
4070
|
for (; c.length > 0; ) {
|
|
4073
4071
|
let p = !1;
|
|
4074
|
-
const h =
|
|
4072
|
+
const h = I.last(c);
|
|
4075
4073
|
if (h instanceof v) {
|
|
4076
4074
|
const T = this.parse.source();
|
|
4077
4075
|
for (let f = h.end; f < e; f += 1)
|
|
@@ -4080,7 +4078,7 @@ class os {
|
|
|
4080
4078
|
} else
|
|
4081
4079
|
h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof U ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ee ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof te || h.end < e && (c.pop(), p = !0);
|
|
4082
4080
|
if (p) {
|
|
4083
|
-
const T =
|
|
4081
|
+
const T = I.last(c);
|
|
4084
4082
|
T instanceof _ && T.end <= e && c.pop();
|
|
4085
4083
|
}
|
|
4086
4084
|
if (!p)
|
|
@@ -4118,7 +4116,7 @@ class os {
|
|
|
4118
4116
|
),
|
|
4119
4117
|
scopeKind: this.createQuery(15, (e) => {
|
|
4120
4118
|
var s;
|
|
4121
|
-
if (this.container.element(e) instanceof
|
|
4119
|
+
if (this.container.element(e) instanceof F)
|
|
4122
4120
|
return 8;
|
|
4123
4121
|
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4124
4122
|
case "table":
|
|
@@ -4162,8 +4160,8 @@ class os {
|
|
|
4162
4160
|
for (const h of e)
|
|
4163
4161
|
p = c.flatMap(
|
|
4164
4162
|
(T) => Qt(h).flatMap((f) => {
|
|
4165
|
-
const N = T.get(f),
|
|
4166
|
-
return !N || !
|
|
4163
|
+
const N = T.get(f), g = se(f).unwrap_or(void 0);
|
|
4164
|
+
return !N || !g ? [] : { ...g, symbol: N };
|
|
4167
4165
|
})
|
|
4168
4166
|
), c = p.flatMap(
|
|
4169
4167
|
(T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
|
|
@@ -4211,7 +4209,7 @@ class os {
|
|
|
4211
4209
|
}
|
|
4212
4210
|
}
|
|
4213
4211
|
export {
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4212
|
+
cs as Compiler,
|
|
4213
|
+
as as serialize,
|
|
4214
|
+
os as services
|
|
4217
4215
|
};
|