@dbml/parse 3.7.3 → 3.7.4
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 -8
- package/dist/dbml-parse.mjs +518 -520
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import I, { partition as
|
|
1
|
+
import I, { partition as Yt, findLastIndex as zt, last as rt } from "lodash";
|
|
2
2
|
var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
|
-
function
|
|
3
|
+
function Qt(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -12,7 +12,7 @@ function zt(t) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function at(t) {
|
|
16
16
|
if (!t)
|
|
17
17
|
return !1;
|
|
18
18
|
switch (t) {
|
|
@@ -33,7 +33,7 @@ function rt(t) {
|
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function ot(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
39
|
class F {
|
|
@@ -44,27 +44,27 @@ class F {
|
|
|
44
44
|
return new F(e, n, s, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function It(t) {
|
|
48
48
|
return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 ||
|
|
50
|
+
function lt(t, e) {
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || It(t);
|
|
52
52
|
}
|
|
53
53
|
function Ce(t) {
|
|
54
54
|
return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
|
-
function It(t) {
|
|
57
|
-
return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
|
|
58
|
-
}
|
|
59
56
|
function Lt(t) {
|
|
60
|
-
return t.
|
|
57
|
+
return t.trailingTrivia.length === 0 ? t.end : Lt(I.last(t.trailingTrivia));
|
|
61
58
|
}
|
|
62
|
-
function
|
|
59
|
+
function gt(t) {
|
|
60
|
+
return t.leadingTrivia.length === 0 ? t.start : gt(t.leadingTrivia[0]);
|
|
61
|
+
}
|
|
62
|
+
function qt(t) {
|
|
63
63
|
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class Ht {
|
|
68
68
|
constructor() {
|
|
69
69
|
this.id = 0;
|
|
70
70
|
}
|
|
@@ -81,13 +81,13 @@ class x {
|
|
|
81
81
|
constructor(e, n, s) {
|
|
82
82
|
this.id = e, this.kind = n;
|
|
83
83
|
const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ?
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ? gt(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ?
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ? Lt(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
@@ -108,7 +108,7 @@ class v extends x {
|
|
|
108
108
|
alias: i,
|
|
109
109
|
attributeList: r,
|
|
110
110
|
bodyColon: a,
|
|
111
|
-
body:
|
|
111
|
+
body: l
|
|
112
112
|
}, p) {
|
|
113
113
|
if (super(p, "<element-declaration>", [
|
|
114
114
|
e,
|
|
@@ -117,10 +117,10 @@ class v extends x {
|
|
|
117
117
|
i,
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
|
-
|
|
121
|
-
]),
|
|
120
|
+
l
|
|
121
|
+
]), l && a && !(l instanceof w || l instanceof v))
|
|
122
122
|
throw new Error("If an element has a simple body, it must be a function application node");
|
|
123
|
-
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body =
|
|
123
|
+
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = l;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
class Y extends x {
|
|
@@ -161,7 +161,7 @@ class ne extends x {
|
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class
|
|
164
|
+
class w extends x {
|
|
165
165
|
constructor({ callee: e, args: n = [] }, s) {
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
@@ -175,7 +175,7 @@ class J extends x {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class
|
|
178
|
+
class R extends x {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: n = [],
|
|
@@ -184,7 +184,7 @@ class D extends x {
|
|
|
184
184
|
}, r) {
|
|
185
185
|
super(r, "<list-expression>", [
|
|
186
186
|
e,
|
|
187
|
-
...
|
|
187
|
+
..._t(n, s),
|
|
188
188
|
i
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
@@ -198,7 +198,7 @@ class Z extends x {
|
|
|
198
198
|
}, r) {
|
|
199
199
|
super(r, "<tuple-expression>", [
|
|
200
200
|
e,
|
|
201
|
-
...
|
|
201
|
+
..._t(n, s),
|
|
202
202
|
i
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
@@ -254,7 +254,7 @@ class he extends x {
|
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function _t(t, e) {
|
|
258
258
|
if (!t || t.length === 0)
|
|
259
259
|
return e || [];
|
|
260
260
|
if (!e || e.length === 0)
|
|
@@ -356,7 +356,7 @@ function qe(t) {
|
|
|
356
356
|
function He(t) {
|
|
357
357
|
return `TableGroup field:${t}`;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function Jt(t) {
|
|
360
360
|
return `Note:${t}`;
|
|
361
361
|
}
|
|
362
362
|
function Ve(t, e) {
|
|
@@ -386,14 +386,14 @@ function ie(t) {
|
|
|
386
386
|
kind: e
|
|
387
387
|
}) : new k();
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function Zt(t) {
|
|
390
390
|
const e = ie(t).unwrap_or(void 0);
|
|
391
391
|
if (!e)
|
|
392
392
|
return !1;
|
|
393
393
|
const { kind: n, name: s } = e;
|
|
394
394
|
return n === "Schema" && s === "public";
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function Kt(t) {
|
|
397
397
|
return [
|
|
398
398
|
je,
|
|
399
399
|
Oe,
|
|
@@ -407,18 +407,18 @@ function Zt(t) {
|
|
|
407
407
|
function Me(t) {
|
|
408
408
|
return !!t.match(/(\p{L}|_|\p{M})/gu);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function De(t) {
|
|
411
411
|
const [e] = t;
|
|
412
412
|
return e >= "0" && e <= "9";
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function en(t) {
|
|
415
415
|
const [e] = t;
|
|
416
|
-
return
|
|
416
|
+
return De(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
417
417
|
}
|
|
418
418
|
function Ee(t) {
|
|
419
|
-
return Me(t) ||
|
|
419
|
+
return Me(t) || De(t);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function ct(t, e) {
|
|
422
422
|
const n = [], s = Math.min(t.length, e.length);
|
|
423
423
|
for (let i = 0; i < s; i += 1)
|
|
424
424
|
n.push(t[i], e[i]);
|
|
@@ -427,7 +427,7 @@ function lt(t, e) {
|
|
|
427
427
|
function ge(t, e) {
|
|
428
428
|
return t >= e.start && t < e.end;
|
|
429
429
|
}
|
|
430
|
-
class
|
|
430
|
+
class tn {
|
|
431
431
|
constructor() {
|
|
432
432
|
this.id = 0;
|
|
433
433
|
}
|
|
@@ -438,45 +438,45 @@ class en {
|
|
|
438
438
|
return this.id++;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
class
|
|
441
|
+
class At {
|
|
442
442
|
constructor({ symbolTable: e }, n) {
|
|
443
443
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
-
class
|
|
446
|
+
class nn {
|
|
447
447
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
448
448
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
class
|
|
451
|
+
class sn {
|
|
452
452
|
constructor({ declaration: e }, n) {
|
|
453
453
|
this.references = [], this.id = n, this.declaration = e;
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
|
-
class
|
|
456
|
+
class vt {
|
|
457
457
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
458
458
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
class
|
|
461
|
+
class rn {
|
|
462
462
|
constructor({ declaration: e }, n) {
|
|
463
463
|
this.references = [], this.id = n, this.declaration = e;
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
class
|
|
466
|
+
class an {
|
|
467
467
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
468
468
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
class
|
|
471
|
+
class on {
|
|
472
472
|
constructor({ declaration: e }, n) {
|
|
473
473
|
this.references = [], this.id = n, this.declaration = e;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
|
|
477
|
-
class
|
|
477
|
+
class c extends Error {
|
|
478
478
|
constructor(e, n, s) {
|
|
479
|
-
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,
|
|
479
|
+
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, c.prototype);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
class V {
|
|
@@ -497,13 +497,13 @@ class V {
|
|
|
497
497
|
return new V(e(this.value), this.errors);
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function ln(t, e, n) {
|
|
501
501
|
if (!t || !me(t) || e.length === 0)
|
|
502
502
|
return new k();
|
|
503
503
|
const s = [...e], i = Ge(t).unwrap(), r = s.pop();
|
|
504
504
|
if (!(r instanceof J))
|
|
505
505
|
return new k();
|
|
506
|
-
const a = I.last(s) instanceof
|
|
506
|
+
const a = I.last(s) instanceof R ? s.pop() : void 0;
|
|
507
507
|
return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new S(
|
|
508
508
|
n.create(v, {
|
|
509
509
|
type: i,
|
|
@@ -528,16 +528,16 @@ function on(t, e, n) {
|
|
|
528
528
|
})
|
|
529
529
|
) : new k();
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function ut(t) {
|
|
532
532
|
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
533
533
|
}
|
|
534
534
|
function N(t) {
|
|
535
|
-
t && (t instanceof F ?
|
|
535
|
+
t && (t instanceof F ? cn(t) : un(t));
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function cn(t) {
|
|
538
538
|
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function un(t) {
|
|
541
541
|
if (t instanceof v)
|
|
542
542
|
N(t.type), N(t.name), N(t.as), N(t.alias), N(t.bodyColon), N(t.attributeList), N(t.body);
|
|
543
543
|
else if (t instanceof Y)
|
|
@@ -552,13 +552,13 @@ function cn(t) {
|
|
|
552
552
|
N(t.op), N(t.expression);
|
|
553
553
|
else if (t instanceof J)
|
|
554
554
|
N(t.blockOpenBrace), t.body.forEach(N), N(t.blockCloseBrace);
|
|
555
|
-
else if (t instanceof
|
|
555
|
+
else if (t instanceof R)
|
|
556
556
|
N(t.listOpenBracket), t.commaList.forEach(N), t.elementList.forEach(N), N(t.listCloseBracket);
|
|
557
557
|
else if (t instanceof Z)
|
|
558
558
|
N(t.tupleOpenParen), t.commaList.forEach(N), t.elementList.forEach(N), N(t.tupleCloseParen);
|
|
559
559
|
else if (t instanceof H)
|
|
560
560
|
N(t.callee), N(t.argumentList);
|
|
561
|
-
else if (t instanceof
|
|
561
|
+
else if (t instanceof w)
|
|
562
562
|
N(t.callee), t.args.forEach(N);
|
|
563
563
|
else if (t instanceof U)
|
|
564
564
|
N(t.expression);
|
|
@@ -571,13 +571,13 @@ function cn(t) {
|
|
|
571
571
|
else
|
|
572
572
|
throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
573
573
|
}
|
|
574
|
-
function
|
|
574
|
+
function wt(t) {
|
|
575
575
|
return !!(t != null && t.isInvalid);
|
|
576
576
|
}
|
|
577
577
|
function P(...t) {
|
|
578
578
|
return t.filter((e) => e !== void 0);
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function hn(t) {
|
|
581
581
|
if (t instanceof X)
|
|
582
582
|
return P(...t.body, t.eof);
|
|
583
583
|
if (t instanceof v)
|
|
@@ -606,20 +606,20 @@ function un(t) {
|
|
|
606
606
|
return P(t.expression, t.op);
|
|
607
607
|
if (t instanceof ne)
|
|
608
608
|
return P(t.value);
|
|
609
|
-
if (t instanceof
|
|
609
|
+
if (t instanceof w)
|
|
610
610
|
return P(t.callee, ...t.args);
|
|
611
611
|
if (t instanceof J)
|
|
612
612
|
return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
613
|
-
if (t instanceof
|
|
613
|
+
if (t instanceof R)
|
|
614
614
|
return P(
|
|
615
615
|
t.listOpenBracket,
|
|
616
|
-
...
|
|
616
|
+
...ct(t.elementList, t.commaList),
|
|
617
617
|
t.listCloseBracket
|
|
618
618
|
);
|
|
619
619
|
if (t instanceof Z)
|
|
620
620
|
return P(
|
|
621
621
|
t.tupleOpenParen,
|
|
622
|
-
...
|
|
622
|
+
...ct(t.elementList, t.commaList),
|
|
623
623
|
t.tupleCloseParen
|
|
624
624
|
);
|
|
625
625
|
if (t instanceof H)
|
|
@@ -657,7 +657,7 @@ function Te(t) {
|
|
|
657
657
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
658
658
|
return e === "" ? new k() : new S(e);
|
|
659
659
|
}
|
|
660
|
-
class
|
|
660
|
+
class fn {
|
|
661
661
|
// list of errors during lexing
|
|
662
662
|
constructor(e) {
|
|
663
663
|
this.start = {
|
|
@@ -767,7 +767,7 @@ class hn {
|
|
|
767
767
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
|
|
768
768
|
break;
|
|
769
769
|
default:
|
|
770
|
-
if (
|
|
770
|
+
if (at(e)) {
|
|
771
771
|
this.operator();
|
|
772
772
|
break;
|
|
773
773
|
}
|
|
@@ -775,12 +775,12 @@ class hn {
|
|
|
775
775
|
this.identifier();
|
|
776
776
|
break;
|
|
777
777
|
}
|
|
778
|
-
if (
|
|
778
|
+
if (De(e)) {
|
|
779
779
|
this.numericLiteralOrIdentifier();
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
782
|
this.addToken(u.OP, !0), this.errors.push(
|
|
783
|
-
new
|
|
783
|
+
new c(
|
|
784
784
|
o.UNKNOWN_SYMBOL,
|
|
785
785
|
`Unexpected token '${e}'`,
|
|
786
786
|
this.createToken(u.OP, !0)
|
|
@@ -795,13 +795,13 @@ class hn {
|
|
|
795
795
|
let e = !0, n = [], s;
|
|
796
796
|
const i = [];
|
|
797
797
|
for (const r of this.tokens)
|
|
798
|
-
|
|
798
|
+
Qt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
|
|
799
799
|
this.tokens = i;
|
|
800
800
|
}
|
|
801
801
|
gatherInvalid() {
|
|
802
802
|
let e;
|
|
803
803
|
const n = [], s = [];
|
|
804
|
-
for (e = 0; e < this.tokens.length &&
|
|
804
|
+
for (e = 0; e < this.tokens.length && wt(this.tokens[e]); e += 1)
|
|
805
805
|
s.push(this.tokens[e]);
|
|
806
806
|
let i = this.tokens[e];
|
|
807
807
|
for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
@@ -820,14 +820,14 @@ class hn {
|
|
|
820
820
|
// Whether to interpret '\' as a backlash
|
|
821
821
|
consumeStopSequence: a = !0
|
|
822
822
|
}) {
|
|
823
|
-
let
|
|
823
|
+
let l = "";
|
|
824
824
|
for (; !this.isAtEnd() && (s || !this.check(`
|
|
825
825
|
`)) && !this.check(n); )
|
|
826
|
-
this.peek() === "\\" && !r ? (this.advance(),
|
|
826
|
+
this.peek() === "\\" && !r ? (this.advance(), l += this.escapedString()) : l += this.advance();
|
|
827
827
|
if (this.isAtEnd() && !i) {
|
|
828
828
|
const p = this.createToken(e, !0);
|
|
829
829
|
this.tokens.push(p), this.errors.push(
|
|
830
|
-
new
|
|
830
|
+
new c(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
|
|
831
831
|
);
|
|
832
832
|
return;
|
|
833
833
|
}
|
|
@@ -835,7 +835,7 @@ class hn {
|
|
|
835
835
|
`) && !s) {
|
|
836
836
|
const p = this.createToken(e, !0);
|
|
837
837
|
this.tokens.push(p), this.errors.push(
|
|
838
|
-
new
|
|
838
|
+
new c(
|
|
839
839
|
o.UNEXPECTED_NEWLINE,
|
|
840
840
|
"Invalid newline encountered while parsing",
|
|
841
841
|
p
|
|
@@ -843,7 +843,7 @@ class hn {
|
|
|
843
843
|
);
|
|
844
844
|
return;
|
|
845
845
|
}
|
|
846
|
-
a && this.match(n), this.tokens.push(F.create(e, this.start, this.current,
|
|
846
|
+
a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, l, !1));
|
|
847
847
|
}
|
|
848
848
|
singleLineStringLiteral() {
|
|
849
849
|
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
@@ -895,7 +895,7 @@ class hn {
|
|
|
895
895
|
this.addToken(u.IDENTIFIER);
|
|
896
896
|
}
|
|
897
897
|
operator() {
|
|
898
|
-
for (;
|
|
898
|
+
for (; at(this.peek()); )
|
|
899
899
|
this.advance();
|
|
900
900
|
this.addToken(u.OP);
|
|
901
901
|
}
|
|
@@ -912,7 +912,7 @@ class hn {
|
|
|
912
912
|
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
913
913
|
if (!n && !Ee(this.peek()))
|
|
914
914
|
return this.addToken(u.NUMERIC_LITERAL);
|
|
915
|
-
if (!n && !
|
|
915
|
+
if (!n && !De(this.peek()))
|
|
916
916
|
break;
|
|
917
917
|
this.advance();
|
|
918
918
|
}
|
|
@@ -920,7 +920,7 @@ class hn {
|
|
|
920
920
|
for (; !this.isAtEnd() && (this.check(".") || Ee(this.peek())); )
|
|
921
921
|
this.advance();
|
|
922
922
|
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
923
|
-
this.tokens.push(n), this.errors.push(new
|
|
923
|
+
this.tokens.push(n), this.errors.push(new c(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
924
924
|
} else {
|
|
925
925
|
for (; !this.isAtEnd() && Ee(this.peek()); )
|
|
926
926
|
this.advance();
|
|
@@ -971,7 +971,7 @@ class hn {
|
|
|
971
971
|
let n = "";
|
|
972
972
|
for (let s = 0; s <= 3; s += 1) {
|
|
973
973
|
if (this.isAtEnd() || !Ee(this.peek()))
|
|
974
|
-
return this.errors.push(new
|
|
974
|
+
return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
|
|
975
975
|
n += this.advance();
|
|
976
976
|
}
|
|
977
977
|
return String.fromCharCode(parseInt(n, 16));
|
|
@@ -982,7 +982,7 @@ class hn {
|
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
984
|
var Se = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Se || {});
|
|
985
|
-
class
|
|
985
|
+
class pn {
|
|
986
986
|
constructor() {
|
|
987
987
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
988
988
|
}
|
|
@@ -1048,7 +1048,7 @@ class fn {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
|
-
class
|
|
1051
|
+
class dn {
|
|
1052
1052
|
constructor(e) {
|
|
1053
1053
|
this.generator = e;
|
|
1054
1054
|
}
|
|
@@ -1061,15 +1061,15 @@ class d {
|
|
|
1061
1061
|
this.token = e, this.partialNode = n, this.handlerContext = s;
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
class
|
|
1064
|
+
class En {
|
|
1065
1065
|
constructor(e, n) {
|
|
1066
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1066
|
+
this.current = 0, this.errors = [], this.contextStack = new pn(), this.synchronizeProgram = () => {
|
|
1067
1067
|
const s = this.peek();
|
|
1068
1068
|
s.kind !== u.EOF ? N(this.advance()) : (N(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1069
1069
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1070
1070
|
for (; !this.isAtEnd(); ) {
|
|
1071
1071
|
const s = this.peek();
|
|
1072
|
-
if (
|
|
1072
|
+
if (ut(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1073
1073
|
break;
|
|
1074
1074
|
N(s), this.advance();
|
|
1075
1075
|
}
|
|
@@ -1115,7 +1115,7 @@ class dn {
|
|
|
1115
1115
|
if (!this.check(u.RBRACE))
|
|
1116
1116
|
for (N(this.advance()); !this.isAtEnd(); ) {
|
|
1117
1117
|
const s = this.peek();
|
|
1118
|
-
if (this.check(u.RBRACE) ||
|
|
1118
|
+
if (this.check(u.RBRACE) || lt(this.previous(), s))
|
|
1119
1119
|
break;
|
|
1120
1120
|
N(s), this.advance();
|
|
1121
1121
|
}
|
|
@@ -1172,7 +1172,7 @@ class dn {
|
|
|
1172
1172
|
N(s), this.advance();
|
|
1173
1173
|
}
|
|
1174
1174
|
}, this.listExpression = this.contextStack.withContextDo(Se.ListExpression, () => {
|
|
1175
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1175
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(R, s);
|
|
1176
1176
|
try {
|
|
1177
1177
|
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
1178
1178
|
} catch (r) {
|
|
@@ -1233,7 +1233,7 @@ class dn {
|
|
|
1233
1233
|
break;
|
|
1234
1234
|
N(s), this.advance();
|
|
1235
1235
|
}
|
|
1236
|
-
}, this.tokens = e, this.nodeFactory = new
|
|
1236
|
+
}, this.tokens = e, this.nodeFactory = new dn(n);
|
|
1237
1237
|
}
|
|
1238
1238
|
isAtEnd() {
|
|
1239
1239
|
return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
|
|
@@ -1324,7 +1324,7 @@ class dn {
|
|
|
1324
1324
|
throw new d(s.token, n(), s.handlerContext);
|
|
1325
1325
|
this.synchronizeElementDeclarationName();
|
|
1326
1326
|
}
|
|
1327
|
-
if (
|
|
1327
|
+
if (ut(this.peek()))
|
|
1328
1328
|
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1329
1329
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1330
1330
|
else
|
|
@@ -1380,7 +1380,7 @@ class dn {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
try {
|
|
1382
1382
|
const s = this.expression();
|
|
1383
|
-
s instanceof v ? this.errors.push(new
|
|
1383
|
+
s instanceof v ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1384
1384
|
} catch (s) {
|
|
1385
1385
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1386
1386
|
}
|
|
@@ -1388,8 +1388,8 @@ class dn {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1390
1390
|
expression() {
|
|
1391
|
-
const e = { args: [] }, n = () =>
|
|
1392
|
-
this.nodeFactory.create(
|
|
1391
|
+
const e = { args: [] }, n = () => ln(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1392
|
+
this.nodeFactory.create(w, e)
|
|
1393
1393
|
);
|
|
1394
1394
|
try {
|
|
1395
1395
|
e.callee = this.normalExpression();
|
|
@@ -1410,7 +1410,7 @@ class dn {
|
|
|
1410
1410
|
return n();
|
|
1411
1411
|
}
|
|
1412
1412
|
shouldStopExpression() {
|
|
1413
|
-
if (this.isAtEnd() ||
|
|
1413
|
+
if (this.isAtEnd() || It(this.previous()))
|
|
1414
1414
|
return !0;
|
|
1415
1415
|
const e = this.peek().kind;
|
|
1416
1416
|
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
@@ -1424,12 +1424,12 @@ class dn {
|
|
|
1424
1424
|
for (; !this.isAtEnd(); ) {
|
|
1425
1425
|
const s = this.peek();
|
|
1426
1426
|
if (s.kind === u.LPAREN) {
|
|
1427
|
-
const { left: i } =
|
|
1427
|
+
const { left: i } = ht(s);
|
|
1428
1428
|
if (i < e || // When '(' is encountered,
|
|
1429
1429
|
// consider it part of another expression if
|
|
1430
1430
|
// it's at the start of a new line
|
|
1431
1431
|
// and we're currently not having unmatched '(' or '['
|
|
1432
|
-
|
|
1432
|
+
lt(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1433
1433
|
break;
|
|
1434
1434
|
try {
|
|
1435
1435
|
n = this.nodeFactory.create(H, {
|
|
@@ -1456,8 +1456,8 @@ class dn {
|
|
|
1456
1456
|
indexer: i.partialNode
|
|
1457
1457
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
1458
1458
|
}
|
|
1459
|
-
} else if (
|
|
1460
|
-
const i = s, r =
|
|
1459
|
+
} else if (ot(s)) {
|
|
1460
|
+
const i = s, r = ht(i);
|
|
1461
1461
|
if (r.left !== null) {
|
|
1462
1462
|
if (r.left <= e)
|
|
1463
1463
|
break;
|
|
@@ -1466,7 +1466,7 @@ class dn {
|
|
|
1466
1466
|
op: i
|
|
1467
1467
|
});
|
|
1468
1468
|
} else {
|
|
1469
|
-
const a =
|
|
1469
|
+
const a = mn(i);
|
|
1470
1470
|
if (a.left === null || a.left <= e)
|
|
1471
1471
|
break;
|
|
1472
1472
|
this.advance();
|
|
@@ -1476,12 +1476,12 @@ class dn {
|
|
|
1476
1476
|
op: i,
|
|
1477
1477
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1478
1478
|
});
|
|
1479
|
-
} catch (
|
|
1480
|
-
throw
|
|
1479
|
+
} catch (l) {
|
|
1480
|
+
throw l instanceof d ? (n = this.nodeFactory.create(q, {
|
|
1481
1481
|
leftExpression: n,
|
|
1482
1482
|
op: i,
|
|
1483
|
-
rightExpression:
|
|
1484
|
-
}), new d(
|
|
1483
|
+
rightExpression: l.partialNode
|
|
1484
|
+
}), new d(l.token, n, l.handlerContext)) : l;
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
1487
|
} else
|
|
@@ -1491,10 +1491,10 @@ class dn {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
leftExpression_bp() {
|
|
1493
1493
|
let e;
|
|
1494
|
-
if (
|
|
1494
|
+
if (ot(this.peek())) {
|
|
1495
1495
|
const n = {};
|
|
1496
1496
|
n.op = this.peek();
|
|
1497
|
-
const s =
|
|
1497
|
+
const s = bn(n.op);
|
|
1498
1498
|
if (s.right === null)
|
|
1499
1499
|
throw this.logError(
|
|
1500
1500
|
n.op,
|
|
@@ -1635,10 +1635,10 @@ class dn {
|
|
|
1635
1635
|
return this.nodeFactory.create(Y, { identifiers: e });
|
|
1636
1636
|
}
|
|
1637
1637
|
logError(e, n, s) {
|
|
1638
|
-
this.errors.push(new
|
|
1638
|
+
this.errors.push(new c(n, s, e));
|
|
1639
1639
|
}
|
|
1640
1640
|
}
|
|
1641
|
-
const
|
|
1641
|
+
const Nn = {
|
|
1642
1642
|
"+": { left: 9, right: 10 },
|
|
1643
1643
|
"*": { left: 11, right: 12 },
|
|
1644
1644
|
"-": { left: 9, right: 10 },
|
|
@@ -1654,10 +1654,10 @@ const En = {
|
|
|
1654
1654
|
"!=": { left: 4, right: 5 },
|
|
1655
1655
|
".": { left: 16, right: 17 }
|
|
1656
1656
|
};
|
|
1657
|
-
function
|
|
1658
|
-
return
|
|
1657
|
+
function mn(t) {
|
|
1658
|
+
return Nn[t.value] || { left: null, right: null };
|
|
1659
1659
|
}
|
|
1660
|
-
const
|
|
1660
|
+
const Tn = {
|
|
1661
1661
|
"+": { left: null, right: 15 },
|
|
1662
1662
|
"-": { left: null, right: 15 },
|
|
1663
1663
|
"<": { left: null, right: 15 },
|
|
@@ -1665,14 +1665,14 @@ const mn = {
|
|
|
1665
1665
|
"<>": { left: null, right: 15 },
|
|
1666
1666
|
"!": { left: null, right: 15 }
|
|
1667
1667
|
};
|
|
1668
|
-
function
|
|
1669
|
-
return
|
|
1668
|
+
function bn(t) {
|
|
1669
|
+
return Tn[t.value] || { left: null, right: null };
|
|
1670
1670
|
}
|
|
1671
|
-
const
|
|
1671
|
+
const In = {
|
|
1672
1672
|
"(": { left: 14, right: null }
|
|
1673
1673
|
};
|
|
1674
|
-
function
|
|
1675
|
-
return
|
|
1674
|
+
function ht(t) {
|
|
1675
|
+
return In[t.value] || { left: null, right: null };
|
|
1676
1676
|
}
|
|
1677
1677
|
var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
|
|
1678
1678
|
function ve(t) {
|
|
@@ -1722,7 +1722,7 @@ function _e(t) {
|
|
|
1722
1722
|
let s;
|
|
1723
1723
|
if (!M(I.last(e))) {
|
|
1724
1724
|
const i = e.pop();
|
|
1725
|
-
if (
|
|
1725
|
+
if (Ot(i))
|
|
1726
1726
|
s = i.elementList.map(
|
|
1727
1727
|
(r) => C(r).unwrap()
|
|
1728
1728
|
);
|
|
@@ -1744,9 +1744,9 @@ function j(t) {
|
|
|
1744
1744
|
return M(t) ? new S(t.expression.variable.value) : new k();
|
|
1745
1745
|
}
|
|
1746
1746
|
function Xe(t) {
|
|
1747
|
-
if (
|
|
1747
|
+
if (ft(t))
|
|
1748
1748
|
return t instanceof ne ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1749
|
-
if (t instanceof Z && t.elementList.every(
|
|
1749
|
+
if (t instanceof Z && t.elementList.every(ft)) {
|
|
1750
1750
|
const e = t.elementList.filter(
|
|
1751
1751
|
(s) => s instanceof ne
|
|
1752
1752
|
), n = t.elementList.filter(M);
|
|
@@ -1762,35 +1762,35 @@ function C(t) {
|
|
|
1762
1762
|
function G(t) {
|
|
1763
1763
|
return $(t) ? t.expression instanceof K ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new k();
|
|
1764
1764
|
}
|
|
1765
|
-
function
|
|
1765
|
+
function Ln(t) {
|
|
1766
1766
|
var e;
|
|
1767
|
-
return !(t instanceof q) || !
|
|
1767
|
+
return !(t instanceof q) || !xt((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1768
1768
|
}
|
|
1769
|
-
function
|
|
1769
|
+
function gn(t) {
|
|
1770
1770
|
const e = _e(t.leftExpression), n = _e(t.rightExpression);
|
|
1771
1771
|
if (!e.isOk() || !n.isOk())
|
|
1772
1772
|
return !1;
|
|
1773
1773
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1774
1774
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1775
1775
|
}
|
|
1776
|
-
function
|
|
1776
|
+
function ft(t) {
|
|
1777
1777
|
return t instanceof U && t.expression instanceof K || t instanceof ne;
|
|
1778
1778
|
}
|
|
1779
|
-
function
|
|
1780
|
-
var i, r, a,
|
|
1779
|
+
function _n(t, e) {
|
|
1780
|
+
var i, r, a, l;
|
|
1781
1781
|
let n = e;
|
|
1782
|
-
const s =
|
|
1782
|
+
const s = Zt(t);
|
|
1783
1783
|
for (; n; ) {
|
|
1784
1784
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1785
1785
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1786
|
-
if (((
|
|
1786
|
+
if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof X && s)
|
|
1787
1787
|
return n.symbol;
|
|
1788
1788
|
if (n instanceof X)
|
|
1789
1789
|
return;
|
|
1790
1790
|
n = n.parent;
|
|
1791
1791
|
}
|
|
1792
1792
|
}
|
|
1793
|
-
class
|
|
1793
|
+
class An {
|
|
1794
1794
|
constructor(e, n, s) {
|
|
1795
1795
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1796
1796
|
}
|
|
@@ -1798,24 +1798,24 @@ class _n {
|
|
|
1798
1798
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1799
1799
|
}
|
|
1800
1800
|
validateContext() {
|
|
1801
|
-
return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new
|
|
1801
|
+
return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1802
1802
|
}
|
|
1803
1803
|
validateName(e) {
|
|
1804
|
-
return e ? [new
|
|
1804
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
1805
1805
|
}
|
|
1806
1806
|
validateAlias(e) {
|
|
1807
|
-
return e ? [new
|
|
1807
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
|
|
1808
1808
|
}
|
|
1809
1809
|
validateSettingList(e) {
|
|
1810
|
-
return e ? [new
|
|
1810
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
|
|
1811
1811
|
}
|
|
1812
1812
|
validateBody(e) {
|
|
1813
1813
|
if (!e)
|
|
1814
1814
|
return [];
|
|
1815
1815
|
if (e instanceof J)
|
|
1816
|
-
return [new
|
|
1816
|
+
return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1817
1817
|
const n = [];
|
|
1818
|
-
return $(e.callee) || n.push(new
|
|
1818
|
+
return $(e.callee) || n.push(new c(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 c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
1821
|
class we {
|
|
@@ -1835,7 +1835,7 @@ class we {
|
|
|
1835
1835
|
return this.table.entries();
|
|
1836
1836
|
}
|
|
1837
1837
|
}
|
|
1838
|
-
class
|
|
1838
|
+
class vn {
|
|
1839
1839
|
constructor(e, n, s) {
|
|
1840
1840
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1841
1841
|
}
|
|
@@ -1843,41 +1843,41 @@ class An {
|
|
|
1843
1843
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
1844
1844
|
}
|
|
1845
1845
|
validateContext() {
|
|
1846
|
-
return this.declarationNode.parent instanceof v ? [new
|
|
1846
|
+
return this.declarationNode.parent instanceof v ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1847
1847
|
}
|
|
1848
1848
|
validateName(e) {
|
|
1849
|
-
return e ?
|
|
1849
|
+
return e ? kt(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
1850
1850
|
}
|
|
1851
1851
|
validateAlias(e) {
|
|
1852
|
-
return e ? [new
|
|
1852
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1853
1853
|
}
|
|
1854
1854
|
registerElement() {
|
|
1855
1855
|
const e = [];
|
|
1856
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1856
|
+
this.declarationNode.symbol = this.symbolFactory.create(nn, { declaration: this.declarationNode, symbolTable: new we() });
|
|
1857
1857
|
const { name: n } = this.declarationNode, s = W(n);
|
|
1858
1858
|
if (s.isOk()) {
|
|
1859
|
-
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory),
|
|
1860
|
-
a.has(
|
|
1859
|
+
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = ze(r);
|
|
1860
|
+
a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
|
|
1861
1861
|
}
|
|
1862
1862
|
return e;
|
|
1863
1863
|
}
|
|
1864
1864
|
validateSettingList(e) {
|
|
1865
|
-
return e ? [new
|
|
1865
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
|
|
1866
1866
|
}
|
|
1867
1867
|
validateBody(e) {
|
|
1868
1868
|
if (!e)
|
|
1869
1869
|
return [];
|
|
1870
|
-
if (e instanceof
|
|
1870
|
+
if (e instanceof w)
|
|
1871
1871
|
return this.validateFields([e]);
|
|
1872
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1872
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
1873
1873
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1874
1874
|
}
|
|
1875
1875
|
validateFields(e) {
|
|
1876
|
-
return e.length === 0 ? [new
|
|
1876
|
+
return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1877
1877
|
const s = [];
|
|
1878
|
-
n.callee && !M(n.callee) && s.push(new
|
|
1878
|
+
n.callee && !M(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1879
1879
|
const i = [...n.args];
|
|
1880
|
-
return I.last(i) instanceof
|
|
1880
|
+
return I.last(i) instanceof R ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof R && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1881
1881
|
});
|
|
1882
1882
|
}
|
|
1883
1883
|
validateFieldSettings(e) {
|
|
@@ -1886,12 +1886,12 @@ class An {
|
|
|
1886
1886
|
const a = i[r];
|
|
1887
1887
|
switch (r) {
|
|
1888
1888
|
case "note":
|
|
1889
|
-
a.length > 1 && a.forEach((
|
|
1890
|
-
$(
|
|
1889
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
1890
|
+
$(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
|
|
1891
1891
|
});
|
|
1892
1892
|
break;
|
|
1893
1893
|
default:
|
|
1894
|
-
a.forEach((
|
|
1894
|
+
a.forEach((l) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
return s;
|
|
@@ -1906,14 +1906,14 @@ class An {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
registerField(e) {
|
|
1908
1908
|
if (e.callee && M(e.callee)) {
|
|
1909
|
-
const n = C(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(
|
|
1909
|
+
const n = C(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(sn, { declaration: e });
|
|
1910
1910
|
e.symbol = i;
|
|
1911
1911
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1912
1912
|
if (r.has(s)) {
|
|
1913
1913
|
const a = r.get(s);
|
|
1914
1914
|
return [
|
|
1915
|
-
new
|
|
1916
|
-
new
|
|
1915
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
|
|
1916
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
|
|
1917
1917
|
];
|
|
1918
1918
|
}
|
|
1919
1919
|
r.set(s, i);
|
|
@@ -1921,7 +1921,7 @@ class An {
|
|
|
1921
1921
|
return [];
|
|
1922
1922
|
}
|
|
1923
1923
|
}
|
|
1924
|
-
class
|
|
1924
|
+
class wn {
|
|
1925
1925
|
constructor(e, n, s) {
|
|
1926
1926
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1927
1927
|
}
|
|
@@ -1929,23 +1929,23 @@ class vn {
|
|
|
1929
1929
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1930
1930
|
}
|
|
1931
1931
|
validateContext() {
|
|
1932
|
-
return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new
|
|
1932
|
+
return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1933
1933
|
}
|
|
1934
1934
|
validateName(e) {
|
|
1935
|
-
return e ? [new
|
|
1935
|
+
return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
1936
1936
|
}
|
|
1937
1937
|
validateAlias(e) {
|
|
1938
|
-
return e ? [new
|
|
1938
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
|
|
1939
1939
|
}
|
|
1940
1940
|
validateSettingList(e) {
|
|
1941
|
-
return e ? [new
|
|
1941
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
|
|
1942
1942
|
}
|
|
1943
1943
|
validateBody(e) {
|
|
1944
1944
|
if (!e)
|
|
1945
1945
|
return [];
|
|
1946
|
-
if (e instanceof
|
|
1947
|
-
return [new
|
|
1948
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1946
|
+
if (e instanceof w)
|
|
1947
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1948
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
1949
1949
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1950
1950
|
}
|
|
1951
1951
|
validateFields(e) {
|
|
@@ -1953,10 +1953,10 @@ class vn {
|
|
|
1953
1953
|
if (!n.callee)
|
|
1954
1954
|
return [];
|
|
1955
1955
|
const s = [], i = [n.callee, ...n.args];
|
|
1956
|
-
return I.last(i) instanceof
|
|
1956
|
+
return I.last(i) instanceof R && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1957
1957
|
for (; r instanceof H; )
|
|
1958
|
-
r.argumentList && !Xe(r.argumentList).isOk() && s.push(new
|
|
1959
|
-
Xe(r).isOk() || s.push(new
|
|
1958
|
+
r.argumentList && !Xe(r.argumentList).isOk() && s.push(new c(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;
|
|
1959
|
+
Xe(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
1960
1960
|
}), s;
|
|
1961
1961
|
});
|
|
1962
1962
|
}
|
|
@@ -1967,23 +1967,23 @@ class vn {
|
|
|
1967
1967
|
switch (r) {
|
|
1968
1968
|
case "note":
|
|
1969
1969
|
case "name":
|
|
1970
|
-
a.length > 1 && a.forEach((
|
|
1971
|
-
$(
|
|
1970
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1971
|
+
$(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
|
|
1972
1972
|
});
|
|
1973
1973
|
break;
|
|
1974
1974
|
case "unique":
|
|
1975
1975
|
case "pk":
|
|
1976
|
-
a.length > 1 && a.forEach((
|
|
1977
|
-
ue(
|
|
1976
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1977
|
+
ue(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
|
|
1978
1978
|
});
|
|
1979
1979
|
break;
|
|
1980
1980
|
case "type":
|
|
1981
|
-
a.length > 1 && a.forEach((
|
|
1982
|
-
M(
|
|
1981
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
|
|
1982
|
+
M(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
|
|
1983
1983
|
});
|
|
1984
1984
|
break;
|
|
1985
1985
|
default:
|
|
1986
|
-
a.forEach((
|
|
1986
|
+
a.forEach((l) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
|
|
1987
1987
|
}
|
|
1988
1988
|
}
|
|
1989
1989
|
return s;
|
|
@@ -1997,7 +1997,7 @@ class vn {
|
|
|
1997
1997
|
});
|
|
1998
1998
|
}
|
|
1999
1999
|
}
|
|
2000
|
-
class
|
|
2000
|
+
class yn {
|
|
2001
2001
|
constructor(e, n, s) {
|
|
2002
2002
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2003
2003
|
}
|
|
@@ -2015,7 +2015,7 @@ class wn {
|
|
|
2015
2015
|
b.Table,
|
|
2016
2016
|
b.TableGroup,
|
|
2017
2017
|
b.Project
|
|
2018
|
-
].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new
|
|
2018
|
+
].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(
|
|
2019
2019
|
o.INVALID_NOTE_CONTEXT,
|
|
2020
2020
|
"A Note can only appear inside a Table, a Table Group or a Project. Sticky note can only appear at the global scope.",
|
|
2021
2021
|
this.declarationNode
|
|
@@ -2023,32 +2023,32 @@ class wn {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
validateName(e) {
|
|
2025
2025
|
if (!(this.declarationNode.parent instanceof X))
|
|
2026
|
-
return e ? [new
|
|
2026
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2027
2027
|
if (!e)
|
|
2028
|
-
return [new
|
|
2028
|
+
return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2029
2029
|
const n = W(e);
|
|
2030
2030
|
if (!n.isOk())
|
|
2031
|
-
return [new
|
|
2032
|
-
const i = n.unwrap().join("."), r =
|
|
2033
|
-
return this.publicSymbolTable.has(r) ? [new
|
|
2031
|
+
return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2032
|
+
const i = n.unwrap().join("."), r = Jt(i);
|
|
2033
|
+
return this.publicSymbolTable.has(r) ? [new c(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
|
|
2034
2034
|
}
|
|
2035
2035
|
validateAlias(e) {
|
|
2036
|
-
return e ? [new
|
|
2036
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2037
2037
|
}
|
|
2038
2038
|
validateSettingList(e) {
|
|
2039
|
-
return e ? [new
|
|
2039
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
|
|
2040
2040
|
}
|
|
2041
2041
|
validateBody(e) {
|
|
2042
2042
|
if (!e)
|
|
2043
2043
|
return [];
|
|
2044
|
-
if (e instanceof
|
|
2044
|
+
if (e instanceof w)
|
|
2045
2045
|
return this.validateFields([e]);
|
|
2046
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2046
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2047
2047
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2048
2048
|
}
|
|
2049
2049
|
validateFields(e) {
|
|
2050
2050
|
const n = [];
|
|
2051
|
-
return e.length === 0 ? [new
|
|
2051
|
+
return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new c(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 c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2052
2052
|
}
|
|
2053
2053
|
validateSubElements(e) {
|
|
2054
2054
|
return e.flatMap((n) => {
|
|
@@ -2059,7 +2059,7 @@ class wn {
|
|
|
2059
2059
|
});
|
|
2060
2060
|
}
|
|
2061
2061
|
}
|
|
2062
|
-
class
|
|
2062
|
+
class kn {
|
|
2063
2063
|
constructor(e, n, s) {
|
|
2064
2064
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2065
2065
|
}
|
|
@@ -2067,25 +2067,25 @@ class yn {
|
|
|
2067
2067
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2068
2068
|
}
|
|
2069
2069
|
validateContext() {
|
|
2070
|
-
return this.declarationNode.parent instanceof v ? [new
|
|
2070
|
+
return this.declarationNode.parent instanceof v ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2071
2071
|
}
|
|
2072
2072
|
validateName(e) {
|
|
2073
|
-
return e ? ye(e) ? [] : [new
|
|
2073
|
+
return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2074
2074
|
}
|
|
2075
2075
|
validateAlias(e) {
|
|
2076
|
-
return e ? [new
|
|
2076
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
2077
2077
|
}
|
|
2078
2078
|
validateSettingList(e) {
|
|
2079
|
-
return e ? [new
|
|
2079
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
|
|
2080
2080
|
}
|
|
2081
2081
|
validateBody(e) {
|
|
2082
2082
|
if (!e)
|
|
2083
2083
|
return [];
|
|
2084
|
-
if (e instanceof
|
|
2085
|
-
return [new
|
|
2086
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2084
|
+
if (e instanceof w)
|
|
2085
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2086
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2087
2087
|
return [
|
|
2088
|
-
...n.map((i) => new
|
|
2088
|
+
...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2089
2089
|
...this.validateSubElements(s)
|
|
2090
2090
|
];
|
|
2091
2091
|
}
|
|
@@ -2098,7 +2098,7 @@ class yn {
|
|
|
2098
2098
|
});
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
|
-
class
|
|
2101
|
+
class xn {
|
|
2102
2102
|
constructor(e, n, s) {
|
|
2103
2103
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2104
2104
|
}
|
|
@@ -2106,33 +2106,33 @@ class kn {
|
|
|
2106
2106
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2107
2107
|
}
|
|
2108
2108
|
validateContext() {
|
|
2109
|
-
return this.declarationNode.parent instanceof X ? [] : [new
|
|
2109
|
+
return this.declarationNode.parent instanceof X ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2110
2110
|
}
|
|
2111
2111
|
validateName(e) {
|
|
2112
|
-
return e ? ye(e) ? [] : [new
|
|
2112
|
+
return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2113
2113
|
}
|
|
2114
2114
|
validateAlias(e) {
|
|
2115
|
-
return e ? [new
|
|
2115
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2116
2116
|
}
|
|
2117
2117
|
validateSettingList(e) {
|
|
2118
|
-
return e ? [new
|
|
2118
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
|
|
2119
2119
|
}
|
|
2120
2120
|
validateBody(e) {
|
|
2121
2121
|
if (!e)
|
|
2122
2122
|
return [];
|
|
2123
|
-
if (e instanceof
|
|
2123
|
+
if (e instanceof w)
|
|
2124
2124
|
return this.validateFields([e]);
|
|
2125
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2125
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2126
2126
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2127
2127
|
}
|
|
2128
2128
|
validateFields(e) {
|
|
2129
2129
|
if (e.length === 0)
|
|
2130
|
-
return [new
|
|
2130
|
+
return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2131
2131
|
const n = [];
|
|
2132
|
-
return e.length > 1 && n.push(...e.slice(1).map((s) => new
|
|
2133
|
-
s.callee && !
|
|
2132
|
+
return e.length > 1 && n.push(...e.slice(1).map((s) => new c(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2133
|
+
s.callee && !Ln(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !gn(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2134
2134
|
const i = [...s.args];
|
|
2135
|
-
I.last(i) instanceof
|
|
2135
|
+
I.last(i) instanceof R ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof R && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2136
2136
|
}), n;
|
|
2137
2137
|
}
|
|
2138
2138
|
validateFieldSettings(e) {
|
|
@@ -2142,12 +2142,12 @@ class kn {
|
|
|
2142
2142
|
switch (r) {
|
|
2143
2143
|
case "delete":
|
|
2144
2144
|
case "update":
|
|
2145
|
-
a.length > 1 && a.forEach((
|
|
2146
|
-
|
|
2145
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
2146
|
+
Sn(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
|
|
2147
2147
|
});
|
|
2148
2148
|
break;
|
|
2149
2149
|
default:
|
|
2150
|
-
a.forEach((
|
|
2150
|
+
a.forEach((l) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
|
|
2151
2151
|
}
|
|
2152
2152
|
}
|
|
2153
2153
|
return s;
|
|
@@ -2161,7 +2161,7 @@ class kn {
|
|
|
2161
2161
|
});
|
|
2162
2162
|
}
|
|
2163
2163
|
}
|
|
2164
|
-
function
|
|
2164
|
+
function Sn(t) {
|
|
2165
2165
|
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof Y))
|
|
2166
2166
|
return !1;
|
|
2167
2167
|
let e;
|
|
@@ -2178,7 +2178,7 @@ function xn(t) {
|
|
|
2178
2178
|
}
|
|
2179
2179
|
return !1;
|
|
2180
2180
|
}
|
|
2181
|
-
class
|
|
2181
|
+
class On {
|
|
2182
2182
|
constructor(e, n, s) {
|
|
2183
2183
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2184
2184
|
}
|
|
@@ -2186,13 +2186,13 @@ class Sn {
|
|
|
2186
2186
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
2187
2187
|
}
|
|
2188
2188
|
validateContext() {
|
|
2189
|
-
return this.declarationNode.parent instanceof v ? [new
|
|
2189
|
+
return this.declarationNode.parent instanceof v ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2190
2190
|
}
|
|
2191
2191
|
validateName(e) {
|
|
2192
|
-
return e ? e instanceof he ? [new
|
|
2192
|
+
return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : kt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2193
2193
|
}
|
|
2194
2194
|
validateAlias(e) {
|
|
2195
|
-
return e ?
|
|
2195
|
+
return e ? Un(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2196
2196
|
}
|
|
2197
2197
|
validateSettingList(e) {
|
|
2198
2198
|
const n = B(e), s = n.getErrors(), i = n.getValue();
|
|
@@ -2200,63 +2200,63 @@ class Sn {
|
|
|
2200
2200
|
const a = i[r];
|
|
2201
2201
|
switch (r) {
|
|
2202
2202
|
case "headercolor":
|
|
2203
|
-
a.length > 1 && s.push(...a.map((
|
|
2204
|
-
|
|
2203
|
+
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
|
|
2204
|
+
St(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
|
|
2205
2205
|
});
|
|
2206
2206
|
break;
|
|
2207
2207
|
case "note":
|
|
2208
|
-
a.length > 1 && s.push(...a.map((
|
|
2209
|
-
$(
|
|
2208
|
+
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
2209
|
+
$(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
|
|
2210
2210
|
});
|
|
2211
2211
|
break;
|
|
2212
2212
|
default:
|
|
2213
|
-
s.push(...a.map((
|
|
2213
|
+
s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
|
|
2214
2214
|
}
|
|
2215
2215
|
}
|
|
2216
2216
|
return s;
|
|
2217
2217
|
}
|
|
2218
2218
|
registerElement() {
|
|
2219
2219
|
const e = [];
|
|
2220
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2220
|
+
this.declarationNode.symbol = this.symbolFactory.create(vt, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2221
2221
|
const { name: n, alias: s } = this.declarationNode, i = W(n);
|
|
2222
2222
|
if (i.isOk()) {
|
|
2223
|
-
const r = [...i.unwrap()], a = r.pop(),
|
|
2224
|
-
|
|
2223
|
+
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
|
|
2224
|
+
l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
|
|
2225
2225
|
}
|
|
2226
2226
|
if (s && ye(s) && !Rn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2227
2227
|
const r = C(s).unwrap(), a = Oe(r);
|
|
2228
|
-
this.publicSymbolTable.has(a) && e.push(new
|
|
2228
|
+
this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2229
2229
|
}
|
|
2230
2230
|
return e;
|
|
2231
2231
|
}
|
|
2232
2232
|
validateBody(e) {
|
|
2233
2233
|
if (!e)
|
|
2234
2234
|
return [];
|
|
2235
|
-
if (e instanceof
|
|
2236
|
-
return [new
|
|
2237
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2235
|
+
if (e instanceof w)
|
|
2236
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2237
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2238
2238
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2239
2239
|
}
|
|
2240
2240
|
validateFields(e) {
|
|
2241
|
-
return e.length === 0 ? [new
|
|
2241
|
+
return e.length === 0 ? [new c(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
|
|
2242
2242
|
if (!n.callee)
|
|
2243
2243
|
return [];
|
|
2244
2244
|
const s = [];
|
|
2245
|
-
n.args.length === 0 && s.push(new
|
|
2245
|
+
n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Dn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2246
2246
|
const i = n.args.slice(1);
|
|
2247
2247
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2248
2248
|
});
|
|
2249
2249
|
}
|
|
2250
2250
|
registerField(e) {
|
|
2251
2251
|
if (e.callee && M(e.callee)) {
|
|
2252
|
-
const n = C(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(
|
|
2252
|
+
const n = C(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(rn, { declaration: e });
|
|
2253
2253
|
e.symbol = i;
|
|
2254
2254
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2255
2255
|
if (r.has(s)) {
|
|
2256
2256
|
const a = r.get(s);
|
|
2257
2257
|
return [
|
|
2258
|
-
new
|
|
2259
|
-
new
|
|
2258
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
|
|
2259
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
|
|
2260
2260
|
];
|
|
2261
2261
|
}
|
|
2262
2262
|
r.set(s, i);
|
|
@@ -2265,75 +2265,75 @@ class Sn {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
// This is needed to support legacy inline settings
|
|
2267
2267
|
validateFieldSetting(e) {
|
|
2268
|
-
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof
|
|
2269
|
-
return [...e.map((p) => new
|
|
2268
|
+
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof R))
|
|
2269
|
+
return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2270
2270
|
if (e.length === 0)
|
|
2271
2271
|
return [];
|
|
2272
2272
|
let n;
|
|
2273
|
-
I.last(e) instanceof
|
|
2273
|
+
I.last(e) instanceof R && (n = e.pop());
|
|
2274
2274
|
const s = B(n), i = s.getErrors(), r = s.getValue();
|
|
2275
2275
|
for (const p of e) {
|
|
2276
2276
|
const f = C(p).unwrap_or("").toLowerCase();
|
|
2277
2277
|
if (f !== "pk" && f !== "unique") {
|
|
2278
|
-
i.push(new
|
|
2278
|
+
i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2279
2279
|
continue;
|
|
2280
2280
|
}
|
|
2281
2281
|
r[f] === void 0 ? r[f] = [p] : r[f].push(p);
|
|
2282
2282
|
}
|
|
2283
|
-
const a = r.pk || [],
|
|
2284
|
-
a.length >= 1 &&
|
|
2283
|
+
const a = r.pk || [], l = r["primary key"] || [];
|
|
2284
|
+
a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new c(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
|
|
2285
2285
|
for (const p in r) {
|
|
2286
2286
|
const f = r[p];
|
|
2287
2287
|
switch (p) {
|
|
2288
2288
|
case "note":
|
|
2289
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2290
|
-
$(h.value) || i.push(new
|
|
2289
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
|
|
2290
|
+
$(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
|
|
2291
2291
|
});
|
|
2292
2292
|
break;
|
|
2293
2293
|
case "ref":
|
|
2294
2294
|
f.forEach((h) => {
|
|
2295
|
-
Fn(h.value) || i.push(new
|
|
2295
|
+
Fn(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
|
|
2296
2296
|
});
|
|
2297
2297
|
break;
|
|
2298
2298
|
case "primary key":
|
|
2299
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2300
|
-
ue(h.value) || i.push(new
|
|
2299
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", h))), f.forEach((h) => {
|
|
2300
|
+
ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
|
|
2301
2301
|
});
|
|
2302
2302
|
break;
|
|
2303
2303
|
case "pk":
|
|
2304
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2305
|
-
h instanceof se && !ue(h.value) && i.push(new
|
|
2304
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
|
|
2305
|
+
h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
|
|
2306
2306
|
});
|
|
2307
2307
|
break;
|
|
2308
2308
|
case "not null":
|
|
2309
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2309
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", h)));
|
|
2310
2310
|
const E = r.null || [];
|
|
2311
|
-
f.length >= 1 && E.length >= 1 && i.push(...[...f, ...E].map((h) => new
|
|
2312
|
-
ue(h.value) || i.push(new
|
|
2311
|
+
f.length >= 1 && E.length >= 1 && i.push(...[...f, ...E].map((h) => new c(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", h))), f.forEach((h) => {
|
|
2312
|
+
ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", h.value || h.name));
|
|
2313
2313
|
});
|
|
2314
2314
|
break;
|
|
2315
2315
|
case "null":
|
|
2316
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2317
|
-
ue(h.value) || i.push(new
|
|
2316
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", h))), f.forEach((h) => {
|
|
2317
|
+
ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
|
|
2318
2318
|
});
|
|
2319
2319
|
break;
|
|
2320
2320
|
case "unique":
|
|
2321
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2322
|
-
h instanceof se && !ue(h.value) && i.push(new
|
|
2321
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
|
|
2322
|
+
h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
|
|
2323
2323
|
});
|
|
2324
2324
|
break;
|
|
2325
2325
|
case "increment":
|
|
2326
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2327
|
-
h instanceof se && !ue(h.value) && i.push(new
|
|
2326
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
|
|
2327
|
+
h instanceof se && !ue(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
|
|
2328
2328
|
});
|
|
2329
2329
|
break;
|
|
2330
2330
|
case "default":
|
|
2331
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2332
|
-
Mn(h.value) || i.push(new
|
|
2331
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
|
|
2332
|
+
Mn(h.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
|
|
2333
2333
|
});
|
|
2334
2334
|
break;
|
|
2335
2335
|
default:
|
|
2336
|
-
f.forEach((h) => i.push(new
|
|
2336
|
+
f.forEach((h) => i.push(new c(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, h)));
|
|
2337
2337
|
}
|
|
2338
2338
|
}
|
|
2339
2339
|
return i;
|
|
@@ -2348,10 +2348,10 @@ class Sn {
|
|
|
2348
2348
|
var r;
|
|
2349
2349
|
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2350
2350
|
});
|
|
2351
|
-
return s.length > 1 && n.push(...s.map((i) => new
|
|
2351
|
+
return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2352
2352
|
}
|
|
2353
2353
|
}
|
|
2354
|
-
function
|
|
2354
|
+
function Dn(t) {
|
|
2355
2355
|
if (!(t instanceof H || Je(t) || t instanceof U || t instanceof he))
|
|
2356
2356
|
return !1;
|
|
2357
2357
|
if (t instanceof H) {
|
|
@@ -2370,7 +2370,7 @@ function On(t) {
|
|
|
2370
2370
|
function Rn(t, e) {
|
|
2371
2371
|
return e.length === 1 && t === e[0];
|
|
2372
2372
|
}
|
|
2373
|
-
class
|
|
2373
|
+
class Pn {
|
|
2374
2374
|
constructor(e, n, s) {
|
|
2375
2375
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2376
2376
|
}
|
|
@@ -2385,25 +2385,25 @@ class Dn {
|
|
|
2385
2385
|
];
|
|
2386
2386
|
}
|
|
2387
2387
|
validateContext() {
|
|
2388
|
-
return this.declarationNode.parent instanceof v ? [new
|
|
2388
|
+
return this.declarationNode.parent instanceof v ? [new c(
|
|
2389
2389
|
o.INVALID_TABLEGROUP_CONTEXT,
|
|
2390
2390
|
"TableGroup must appear top-level",
|
|
2391
2391
|
this.declarationNode
|
|
2392
2392
|
)] : [];
|
|
2393
2393
|
}
|
|
2394
2394
|
validateName(e) {
|
|
2395
|
-
return e ? ye(e) ? [] : [new
|
|
2395
|
+
return e ? ye(e) ? [] : [new c(
|
|
2396
2396
|
o.INVALID_NAME,
|
|
2397
2397
|
"A TableGroup name must be a single identifier",
|
|
2398
2398
|
e
|
|
2399
|
-
)] : [new
|
|
2399
|
+
)] : [new c(
|
|
2400
2400
|
o.NAME_NOT_FOUND,
|
|
2401
2401
|
"A TableGroup must have a name",
|
|
2402
2402
|
this.declarationNode
|
|
2403
2403
|
)];
|
|
2404
2404
|
}
|
|
2405
2405
|
validateAlias(e) {
|
|
2406
|
-
return e ? [new
|
|
2406
|
+
return e ? [new c(
|
|
2407
2407
|
o.UNEXPECTED_ALIAS,
|
|
2408
2408
|
"A TableGroup shouldn't have an alias",
|
|
2409
2409
|
e
|
|
@@ -2411,12 +2411,12 @@ class Dn {
|
|
|
2411
2411
|
}
|
|
2412
2412
|
registerElement() {
|
|
2413
2413
|
const { name: e } = this.declarationNode;
|
|
2414
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2414
|
+
this.declarationNode.symbol = this.symbolFactory.create(an, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2415
2415
|
const n = W(e);
|
|
2416
2416
|
if (n.isOk()) {
|
|
2417
2417
|
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
|
|
2418
2418
|
if (r.has(a))
|
|
2419
|
-
return [new
|
|
2419
|
+
return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
|
|
2420
2420
|
r.set(a, this.declarationNode.symbol);
|
|
2421
2421
|
}
|
|
2422
2422
|
return [];
|
|
@@ -2425,31 +2425,37 @@ class Dn {
|
|
|
2425
2425
|
const n = B(e), s = n.getErrors(), i = n.getValue();
|
|
2426
2426
|
return I.forIn(i, (r, a) => {
|
|
2427
2427
|
switch (a) {
|
|
2428
|
-
case "
|
|
2429
|
-
s.push(...r.map((
|
|
2430
|
-
o.
|
|
2431
|
-
"'
|
|
2432
|
-
|
|
2433
|
-
)))
|
|
2428
|
+
case "color":
|
|
2429
|
+
r.length > 1 && s.push(...r.map((l) => new c(
|
|
2430
|
+
o.DUPLICATE_TABLE_SETTING,
|
|
2431
|
+
"'color' can only appear once",
|
|
2432
|
+
l
|
|
2433
|
+
))), r.forEach((l) => {
|
|
2434
|
+
St(l.value) || s.push(new c(
|
|
2435
|
+
o.INVALID_TABLE_SETTING,
|
|
2436
|
+
"'color' must be a color literal",
|
|
2437
|
+
l.value || l.name
|
|
2438
|
+
));
|
|
2439
|
+
});
|
|
2434
2440
|
break;
|
|
2435
2441
|
case "note":
|
|
2436
|
-
r.length > 1 && s.push(...r.map((
|
|
2442
|
+
r.length > 1 && s.push(...r.map((l) => new c(
|
|
2437
2443
|
o.DUPLICATE_TABLE_SETTING,
|
|
2438
2444
|
"'note' can only appear once",
|
|
2439
|
-
|
|
2440
|
-
))), r.filter((
|
|
2441
|
-
s.push(new
|
|
2445
|
+
l
|
|
2446
|
+
))), r.filter((l) => !$(l.value)).forEach((l) => {
|
|
2447
|
+
s.push(new c(
|
|
2442
2448
|
o.INVALID_TABLE_SETTING,
|
|
2443
2449
|
"'note' must be a string literal",
|
|
2444
|
-
|
|
2450
|
+
l.value || l.name
|
|
2445
2451
|
));
|
|
2446
2452
|
});
|
|
2447
2453
|
break;
|
|
2448
2454
|
default:
|
|
2449
|
-
s.push(...r.map((
|
|
2455
|
+
s.push(...r.map((l) => new c(
|
|
2450
2456
|
o.INVALID_TABLE_SETTING,
|
|
2451
2457
|
`Unknown '${a}' setting`,
|
|
2452
|
-
|
|
2458
|
+
l
|
|
2453
2459
|
)));
|
|
2454
2460
|
break;
|
|
2455
2461
|
}
|
|
@@ -2458,13 +2464,13 @@ class Dn {
|
|
|
2458
2464
|
validateBody(e) {
|
|
2459
2465
|
if (!e)
|
|
2460
2466
|
return [];
|
|
2461
|
-
if (e instanceof
|
|
2462
|
-
return [new
|
|
2467
|
+
if (e instanceof w)
|
|
2468
|
+
return [new c(
|
|
2463
2469
|
o.UNEXPECTED_SIMPLE_BODY,
|
|
2464
2470
|
"A TableGroup's body must be a block",
|
|
2465
2471
|
e
|
|
2466
2472
|
)];
|
|
2467
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2473
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2468
2474
|
return [
|
|
2469
2475
|
...this.validateFields(n),
|
|
2470
2476
|
...this.validateSubElements(s)
|
|
@@ -2473,7 +2479,7 @@ class Dn {
|
|
|
2473
2479
|
validateFields(e) {
|
|
2474
2480
|
return e.flatMap((n) => {
|
|
2475
2481
|
const s = [];
|
|
2476
|
-
return n.callee && !W(n.callee).isOk() && s.push(new
|
|
2482
|
+
return n.callee && !W(n.callee).isOk() && s.push(new c(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 c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2477
2483
|
});
|
|
2478
2484
|
}
|
|
2479
2485
|
validateSubElements(e) {
|
|
@@ -2486,18 +2492,18 @@ class Dn {
|
|
|
2486
2492
|
var r;
|
|
2487
2493
|
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2488
2494
|
});
|
|
2489
|
-
return s.length > 1 && n.push(...s.map((i) => new
|
|
2495
|
+
return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2490
2496
|
}
|
|
2491
2497
|
registerField(e) {
|
|
2492
2498
|
if (e.callee && M(e.callee)) {
|
|
2493
|
-
const n = C(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(
|
|
2499
|
+
const n = C(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(on, { declaration: e });
|
|
2494
2500
|
e.symbol = i;
|
|
2495
2501
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2496
2502
|
if (r.has(s)) {
|
|
2497
2503
|
const a = r.get(s);
|
|
2498
2504
|
return [
|
|
2499
|
-
new
|
|
2500
|
-
new
|
|
2505
|
+
new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
|
|
2506
|
+
new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
|
|
2501
2507
|
];
|
|
2502
2508
|
}
|
|
2503
2509
|
r.set(s, i);
|
|
@@ -2505,31 +2511,31 @@ class Dn {
|
|
|
2505
2511
|
return [];
|
|
2506
2512
|
}
|
|
2507
2513
|
}
|
|
2508
|
-
const
|
|
2514
|
+
const yt = ["-", "+"];
|
|
2509
2515
|
function ae(t) {
|
|
2510
2516
|
switch (t.type.value.toLowerCase()) {
|
|
2511
2517
|
case b.Enum:
|
|
2512
|
-
return
|
|
2518
|
+
return vn;
|
|
2513
2519
|
case b.Table:
|
|
2514
|
-
return
|
|
2520
|
+
return On;
|
|
2515
2521
|
case b.TableGroup:
|
|
2516
|
-
return
|
|
2522
|
+
return Pn;
|
|
2517
2523
|
case b.Project:
|
|
2518
|
-
return yn;
|
|
2519
|
-
case b.Ref:
|
|
2520
2524
|
return kn;
|
|
2525
|
+
case b.Ref:
|
|
2526
|
+
return xn;
|
|
2521
2527
|
case b.Note:
|
|
2522
|
-
return
|
|
2528
|
+
return yn;
|
|
2523
2529
|
case b.Indexes:
|
|
2524
|
-
return
|
|
2530
|
+
return wn;
|
|
2525
2531
|
default:
|
|
2526
|
-
return
|
|
2532
|
+
return An;
|
|
2527
2533
|
}
|
|
2528
2534
|
}
|
|
2529
|
-
function
|
|
2535
|
+
function kt(t) {
|
|
2530
2536
|
return !!W(t).unwrap_or(!1);
|
|
2531
2537
|
}
|
|
2532
|
-
function
|
|
2538
|
+
function Un(t) {
|
|
2533
2539
|
return ye(t);
|
|
2534
2540
|
}
|
|
2535
2541
|
function ye(t) {
|
|
@@ -2541,23 +2547,23 @@ function Ze(t, e, n) {
|
|
|
2541
2547
|
let s = e;
|
|
2542
2548
|
for (const r of t) {
|
|
2543
2549
|
let a;
|
|
2544
|
-
const
|
|
2545
|
-
if (s.has(
|
|
2546
|
-
if (a = (i = s.get(
|
|
2550
|
+
const l = je(r);
|
|
2551
|
+
if (s.has(l)) {
|
|
2552
|
+
if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
|
|
2547
2553
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2548
2554
|
} else {
|
|
2549
2555
|
a = new we();
|
|
2550
|
-
const p = n.create(
|
|
2551
|
-
s.set(
|
|
2556
|
+
const p = n.create(At, { symbolTable: a });
|
|
2557
|
+
s.set(l, p);
|
|
2552
2558
|
}
|
|
2553
2559
|
s = a;
|
|
2554
2560
|
}
|
|
2555
2561
|
return s;
|
|
2556
2562
|
}
|
|
2557
|
-
function
|
|
2563
|
+
function xt(t) {
|
|
2558
2564
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2559
2565
|
}
|
|
2560
|
-
function
|
|
2566
|
+
function St(t) {
|
|
2561
2567
|
var n;
|
|
2562
2568
|
if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2563
2569
|
return !1;
|
|
@@ -2565,7 +2571,7 @@ function Un(t) {
|
|
|
2565
2571
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2566
2572
|
return !1;
|
|
2567
2573
|
for (let s = 1; s < e.length; s += 1)
|
|
2568
|
-
if (!
|
|
2574
|
+
if (!en(e[s]))
|
|
2569
2575
|
return !1;
|
|
2570
2576
|
return !0;
|
|
2571
2577
|
}
|
|
@@ -2574,7 +2580,7 @@ function ue(t) {
|
|
|
2574
2580
|
}
|
|
2575
2581
|
function Mn(t) {
|
|
2576
2582
|
var e;
|
|
2577
|
-
return !!($(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q &&
|
|
2583
|
+
return !!($(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof ne);
|
|
2578
2584
|
}
|
|
2579
2585
|
function fe(t) {
|
|
2580
2586
|
var e;
|
|
@@ -2582,12 +2588,12 @@ function fe(t) {
|
|
|
2582
2588
|
}
|
|
2583
2589
|
function Fn(t) {
|
|
2584
2590
|
var n;
|
|
2585
|
-
if (!(t instanceof Q) || !
|
|
2591
|
+
if (!(t instanceof Q) || !xt((n = t.op) == null ? void 0 : n.value))
|
|
2586
2592
|
return !1;
|
|
2587
2593
|
const e = W(t.expression).unwrap_or(void 0);
|
|
2588
2594
|
return e !== void 0 && e.length > 0;
|
|
2589
2595
|
}
|
|
2590
|
-
function
|
|
2596
|
+
function Ot(t) {
|
|
2591
2597
|
return t instanceof Z && t.elementList.every(M);
|
|
2592
2598
|
}
|
|
2593
2599
|
function B(t) {
|
|
@@ -2599,7 +2605,7 @@ function B(t) {
|
|
|
2599
2605
|
if (!i.name)
|
|
2600
2606
|
continue;
|
|
2601
2607
|
if (i.name instanceof U) {
|
|
2602
|
-
n.push(new
|
|
2608
|
+
n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2603
2609
|
continue;
|
|
2604
2610
|
}
|
|
2605
2611
|
const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
@@ -2607,9 +2613,9 @@ function B(t) {
|
|
|
2607
2613
|
}
|
|
2608
2614
|
return new V(e, n);
|
|
2609
2615
|
}
|
|
2610
|
-
class
|
|
2616
|
+
class pt {
|
|
2611
2617
|
constructor(e, n) {
|
|
2612
|
-
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(
|
|
2618
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(At, {
|
|
2613
2619
|
symbolTable: new we()
|
|
2614
2620
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2615
2621
|
}
|
|
@@ -2626,7 +2632,7 @@ class ft {
|
|
|
2626
2632
|
e.push(...r.validate());
|
|
2627
2633
|
});
|
|
2628
2634
|
const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
|
|
2629
|
-
return n.length > 1 && n.forEach((s) => e.push(new
|
|
2635
|
+
return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new V(this.ast, e);
|
|
2630
2636
|
}
|
|
2631
2637
|
}
|
|
2632
2638
|
class oe {
|
|
@@ -2658,7 +2664,7 @@ class oe {
|
|
|
2658
2664
|
if (s instanceof v) {
|
|
2659
2665
|
if (!s.type)
|
|
2660
2666
|
continue;
|
|
2661
|
-
const i =
|
|
2667
|
+
const i = Dt(s);
|
|
2662
2668
|
new i(s, this.errors).bind();
|
|
2663
2669
|
} else
|
|
2664
2670
|
this.bindSubfield(s);
|
|
@@ -2667,7 +2673,7 @@ class oe {
|
|
|
2667
2673
|
}
|
|
2668
2674
|
bindSubfield(e) {
|
|
2669
2675
|
const n = [e.callee, ...e.args], s = I.last(n);
|
|
2670
|
-
s instanceof
|
|
2676
|
+
s instanceof R && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
|
|
2671
2677
|
const { argBinderRules: i } = this.subfield.arg;
|
|
2672
2678
|
for (let r = 0; r < Math.min(n.length, i.length); r += 1)
|
|
2673
2679
|
i[r].shouldBind && this.scanAndBind(n[r], i[r]);
|
|
@@ -2689,7 +2695,7 @@ class oe {
|
|
|
2689
2695
|
bindFragments(e, n) {
|
|
2690
2696
|
if (e.length === 0)
|
|
2691
2697
|
return;
|
|
2692
|
-
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)),
|
|
2698
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), l = r !== -1 && Ot(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
|
|
2693
2699
|
0,
|
|
2694
2700
|
r === -1 ? void 0 : r
|
|
2695
2701
|
);
|
|
@@ -2710,7 +2716,7 @@ class oe {
|
|
|
2710
2716
|
referrer: h
|
|
2711
2717
|
});
|
|
2712
2718
|
}
|
|
2713
|
-
return
|
|
2719
|
+
return l ? l.elementList.forEach(
|
|
2714
2720
|
(h) => this.resolveIndexStack(
|
|
2715
2721
|
[
|
|
2716
2722
|
...E,
|
|
@@ -2731,31 +2737,31 @@ class oe {
|
|
|
2731
2737
|
resolveIndexStack(e, n) {
|
|
2732
2738
|
if (e.length === 0)
|
|
2733
2739
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
2734
|
-
const [s, ...i] = e, r =
|
|
2740
|
+
const [s, ...i] = e, r = _n(s.index, this.declarationNode);
|
|
2735
2741
|
if (r === void 0) {
|
|
2736
2742
|
const { kind: f, name: E } = ie(s.index).unwrap();
|
|
2737
2743
|
this.logError(s.referrer, `Can not find ${f} '${E}'`, n);
|
|
2738
2744
|
return;
|
|
2739
2745
|
}
|
|
2740
2746
|
r.references.push(s.referrer), s.referrer.referee = r;
|
|
2741
|
-
let a = r.symbolTable, { kind:
|
|
2747
|
+
let a = r.symbolTable, { kind: l, name: p } = ie(s.index).unwrap();
|
|
2742
2748
|
for (const f of i) {
|
|
2743
2749
|
const { kind: E, name: h } = ie(f.index).unwrap(), m = a.get(f.index);
|
|
2744
2750
|
if (!m) {
|
|
2745
2751
|
this.logError(
|
|
2746
2752
|
f.referrer,
|
|
2747
|
-
`${
|
|
2753
|
+
`${l} '${p}' does not have ${E} '${h}'`,
|
|
2748
2754
|
n
|
|
2749
2755
|
);
|
|
2750
2756
|
return;
|
|
2751
2757
|
}
|
|
2752
|
-
if (
|
|
2758
|
+
if (l = E, p = h, f.referrer.referee = m, m.references.push(f.referrer), !m.symbolTable)
|
|
2753
2759
|
break;
|
|
2754
2760
|
a = m.symbolTable;
|
|
2755
2761
|
}
|
|
2756
2762
|
}
|
|
2757
2763
|
logError(e, n, s) {
|
|
2758
|
-
s || this.errors.push(new
|
|
2764
|
+
s || this.errors.push(new c(o.BINDING_ERROR, n, e));
|
|
2759
2765
|
}
|
|
2760
2766
|
}
|
|
2761
2767
|
class Bn extends oe {
|
|
@@ -2895,7 +2901,7 @@ class jn extends oe {
|
|
|
2895
2901
|
}, this.settingList = {};
|
|
2896
2902
|
}
|
|
2897
2903
|
}
|
|
2898
|
-
function
|
|
2904
|
+
function Dt(t) {
|
|
2899
2905
|
switch (t.type.value.toLowerCase()) {
|
|
2900
2906
|
case b.Enum:
|
|
2901
2907
|
return Vn;
|
|
@@ -2922,7 +2928,7 @@ class Yn {
|
|
|
2922
2928
|
resolve() {
|
|
2923
2929
|
for (const e of this.ast.body)
|
|
2924
2930
|
if (e.type) {
|
|
2925
|
-
const n =
|
|
2931
|
+
const n = Dt(e);
|
|
2926
2932
|
new n(e, this.errors).bind();
|
|
2927
2933
|
}
|
|
2928
2934
|
return new V(this.ast, this.errors);
|
|
@@ -2942,14 +2948,14 @@ class Qn {
|
|
|
2942
2948
|
}
|
|
2943
2949
|
// Analyzing: Invoking both the validator and binder
|
|
2944
2950
|
analyze() {
|
|
2945
|
-
return new
|
|
2951
|
+
return new pt(this.ast, this.symbolFactory).validate().chain((n) => new Yn(n).resolve());
|
|
2946
2952
|
}
|
|
2947
2953
|
// For invoking the validator only
|
|
2948
2954
|
validate() {
|
|
2949
|
-
return new
|
|
2955
|
+
return new pt(this.ast, this.symbolFactory).validate().chain((n) => new V(n, []));
|
|
2950
2956
|
}
|
|
2951
2957
|
}
|
|
2952
|
-
function
|
|
2958
|
+
function dt(t, e) {
|
|
2953
2959
|
const { variables: n, tupleElements: s } = _e(t).unwrap();
|
|
2954
2960
|
return s ? n.length === 0 ? {
|
|
2955
2961
|
schemaName: e.schemaName,
|
|
@@ -2969,7 +2975,7 @@ function pt(t, e) {
|
|
|
2969
2975
|
schemaName: n.pop() || null
|
|
2970
2976
|
};
|
|
2971
2977
|
}
|
|
2972
|
-
function
|
|
2978
|
+
function Rt(t) {
|
|
2973
2979
|
switch (t) {
|
|
2974
2980
|
case "<":
|
|
2975
2981
|
return ["1", "*"];
|
|
@@ -3004,10 +3010,10 @@ function Ie(t) {
|
|
|
3004
3010
|
schemaName: e
|
|
3005
3011
|
};
|
|
3006
3012
|
}
|
|
3007
|
-
function
|
|
3013
|
+
function Ke(t) {
|
|
3008
3014
|
return t.expression.literal.value;
|
|
3009
3015
|
}
|
|
3010
|
-
function
|
|
3016
|
+
function Pt(t, e) {
|
|
3011
3017
|
if (Array.isArray(t)) {
|
|
3012
3018
|
const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
|
|
3013
3019
|
return i < r ? `${i}-${r}` : `${r}-${i}`;
|
|
@@ -3015,10 +3021,10 @@ function Dt(t, e) {
|
|
|
3015
3021
|
const n = t.id.toString(), s = e.id.toString();
|
|
3016
3022
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
3017
3023
|
}
|
|
3018
|
-
function
|
|
3024
|
+
function Ut(t, e) {
|
|
3019
3025
|
if (Array.isArray(t)) {
|
|
3020
3026
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
3021
|
-
return I.zip(i, r).every(([a,
|
|
3027
|
+
return I.zip(i, r).every(([a, l]) => a === l);
|
|
3022
3028
|
}
|
|
3023
3029
|
const n = t.id, s = e.id;
|
|
3024
3030
|
return n === s;
|
|
@@ -3029,7 +3035,7 @@ function re(t) {
|
|
|
3029
3035
|
return n.map((r) => r.slice(i)).join(`
|
|
3030
3036
|
`);
|
|
3031
3037
|
}
|
|
3032
|
-
class
|
|
3038
|
+
class Mt {
|
|
3033
3039
|
constructor(e, n) {
|
|
3034
3040
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
3035
3041
|
}
|
|
@@ -3054,7 +3060,7 @@ class Ut {
|
|
|
3054
3060
|
}
|
|
3055
3061
|
interpretName(e) {
|
|
3056
3062
|
const { name: n, schemaName: s } = Ie(e);
|
|
3057
|
-
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new
|
|
3063
|
+
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
3058
3064
|
}
|
|
3059
3065
|
interpretAlias(e) {
|
|
3060
3066
|
if (!e)
|
|
@@ -3072,7 +3078,7 @@ class Ut {
|
|
|
3072
3078
|
interpretSettingList(e) {
|
|
3073
3079
|
var i, r, a;
|
|
3074
3080
|
const n = B(e).getValue();
|
|
3075
|
-
this.table.headerColor = (i = n.headercolor) != null && i.length ?
|
|
3081
|
+
this.table.headerColor = (i = n.headercolor) != null && i.length ? Ke((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
|
|
3076
3082
|
const [s] = n.note || [];
|
|
3077
3083
|
return this.table.note = s && {
|
|
3078
3084
|
value: G(s == null ? void 0 : s.value).map(re).unwrap(),
|
|
@@ -3080,7 +3086,7 @@ class Ut {
|
|
|
3080
3086
|
}, [];
|
|
3081
3087
|
}
|
|
3082
3088
|
interpretBody(e) {
|
|
3083
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
3089
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
3084
3090
|
return [...this.interpretFields(n), ...this.interpretSubElements(s)];
|
|
3085
3091
|
}
|
|
3086
3092
|
interpretSubElements(e) {
|
|
@@ -3102,15 +3108,15 @@ class Ut {
|
|
|
3102
3108
|
return e.flatMap((n) => this.interpretColumn(n));
|
|
3103
3109
|
}
|
|
3104
3110
|
interpretColumn(e) {
|
|
3105
|
-
var a,
|
|
3111
|
+
var a, l, p, f, E, h, m, g;
|
|
3106
3112
|
const n = [], s = {};
|
|
3107
3113
|
s.name = C(e.callee).unwrap();
|
|
3108
3114
|
const i = qn(e.args[0]);
|
|
3109
3115
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = A(e), s.inline_refs = [];
|
|
3110
3116
|
const r = e.args.slice(1);
|
|
3111
|
-
if (I.last(r) instanceof
|
|
3117
|
+
if (I.last(r) instanceof R) {
|
|
3112
3118
|
const _ = B(r.pop()).getValue();
|
|
3113
|
-
s.pk = !!((a = _.pk) != null && a.length) || !!((
|
|
3119
|
+
s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((f = _.unique) != null && f.length), s.not_null = !!((E = _["not null"]) != null && E.length) && !0, s.dbdefault = Hn((m = (h = _.default) == null ? void 0 : h.at(0)) == null ? void 0 : m.value);
|
|
3114
3120
|
const ee = (g = _.note) == null ? void 0 : g.at(0);
|
|
3115
3121
|
s.note = ee && {
|
|
3116
3122
|
value: G(ee.value).map(re).unwrap(),
|
|
@@ -3118,9 +3124,9 @@ class Ut {
|
|
|
3118
3124
|
};
|
|
3119
3125
|
const le = _.ref || [];
|
|
3120
3126
|
s.inline_refs = le.flatMap((z) => {
|
|
3121
|
-
const [
|
|
3122
|
-
if (
|
|
3123
|
-
return n.push(new
|
|
3127
|
+
const [nt] = $e(z.value.expression);
|
|
3128
|
+
if (Ut(nt, e.symbol))
|
|
3129
|
+
return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
|
|
3124
3130
|
const ke = z.value.op, te = W(z.value.expression).unwrap();
|
|
3125
3131
|
let de;
|
|
3126
3132
|
if (te.length === 1) {
|
|
@@ -3142,16 +3148,16 @@ class Ut {
|
|
|
3142
3148
|
token: A(z)
|
|
3143
3149
|
};
|
|
3144
3150
|
} else if (te.length === 3) {
|
|
3145
|
-
const [ce, Le,
|
|
3151
|
+
const [ce, Le, it] = te;
|
|
3146
3152
|
de = {
|
|
3147
3153
|
schemaName: ce,
|
|
3148
3154
|
tableName: Le,
|
|
3149
|
-
fieldNames: [
|
|
3155
|
+
fieldNames: [it],
|
|
3150
3156
|
relation: ke.value,
|
|
3151
3157
|
token: A(z)
|
|
3152
3158
|
};
|
|
3153
3159
|
} else {
|
|
3154
|
-
n.push(new
|
|
3160
|
+
n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
|
|
3155
3161
|
const ce = te.pop(), Le = te.pop();
|
|
3156
3162
|
de = {
|
|
3157
3163
|
schemaName: te.join("."),
|
|
@@ -3161,21 +3167,21 @@ class Ut {
|
|
|
3161
3167
|
token: A(z)
|
|
3162
3168
|
};
|
|
3163
3169
|
}
|
|
3164
|
-
const
|
|
3165
|
-
return n.push(...
|
|
3170
|
+
const st = this.registerInlineRefToEnv(e, nt, de, z);
|
|
3171
|
+
return n.push(...st), st.length === 0 ? de : [];
|
|
3166
3172
|
});
|
|
3167
3173
|
}
|
|
3168
3174
|
return s.pk || (s.pk = r.some((_) => j(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => j(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3169
3175
|
}
|
|
3170
3176
|
interpretIndexes(e) {
|
|
3171
3177
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3172
|
-
var a,
|
|
3178
|
+
var a, l, p, f, E, h, m;
|
|
3173
3179
|
const s = { columns: [] }, i = n;
|
|
3174
3180
|
s.token = A(i);
|
|
3175
3181
|
const r = [i.callee, ...i.args];
|
|
3176
|
-
if (I.last(r) instanceof
|
|
3182
|
+
if (I.last(r) instanceof R) {
|
|
3177
3183
|
const g = B(r.pop()).getValue();
|
|
3178
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((
|
|
3184
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = G((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
|
|
3179
3185
|
const _ = (E = g.note) == null ? void 0 : E.at(0);
|
|
3180
3186
|
s.note = _ && {
|
|
3181
3187
|
value: G(_.value).unwrap(),
|
|
@@ -3207,13 +3213,13 @@ class Ut {
|
|
|
3207
3213
|
})), [];
|
|
3208
3214
|
}
|
|
3209
3215
|
registerInlineRefToEnv(e, n, s, i) {
|
|
3210
|
-
const r =
|
|
3216
|
+
const r = Pt(e.symbol, n);
|
|
3211
3217
|
if (this.env.refIds[r])
|
|
3212
3218
|
return [
|
|
3213
|
-
new
|
|
3214
|
-
new
|
|
3219
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3220
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3215
3221
|
];
|
|
3216
|
-
const a =
|
|
3222
|
+
const a = Rt(s.relation);
|
|
3217
3223
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
3218
3224
|
name: null,
|
|
3219
3225
|
schemaName: null,
|
|
@@ -3247,7 +3253,7 @@ function qn(t) {
|
|
|
3247
3253
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3248
3254
|
args: e
|
|
3249
3255
|
},
|
|
3250
|
-
[new
|
|
3256
|
+
[new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3251
3257
|
) : new V({
|
|
3252
3258
|
schemaName: i.length === 0 ? null : i[0],
|
|
3253
3259
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
@@ -3272,7 +3278,7 @@ function Hn(t) {
|
|
|
3272
3278
|
value: t.expression.variable.value.toLowerCase(),
|
|
3273
3279
|
type: "boolean"
|
|
3274
3280
|
};
|
|
3275
|
-
if (t instanceof Q &&
|
|
3281
|
+
if (t instanceof Q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
|
|
3276
3282
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3277
3283
|
return {
|
|
3278
3284
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
@@ -3305,12 +3311,12 @@ class Jn {
|
|
|
3305
3311
|
interpretSettingList(e) {
|
|
3306
3312
|
var s, i, r;
|
|
3307
3313
|
const n = B(e).getValue();
|
|
3308
|
-
return this.note.headerColor = (s = n.headercolor) != null && s.length ?
|
|
3314
|
+
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ke((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
|
|
3309
3315
|
}
|
|
3310
3316
|
interpretBody(e) {
|
|
3311
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
3317
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
3312
3318
|
return n.length !== 1 || s.length > 0 ? [
|
|
3313
|
-
new
|
|
3319
|
+
new c(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3314
3320
|
] : [...this.interpretNote(n[0])];
|
|
3315
3321
|
}
|
|
3316
3322
|
interpretNote(e) {
|
|
@@ -3318,7 +3324,7 @@ class Jn {
|
|
|
3318
3324
|
return this.note.content = re(n), [];
|
|
3319
3325
|
}
|
|
3320
3326
|
}
|
|
3321
|
-
class
|
|
3327
|
+
class Ft {
|
|
3322
3328
|
constructor(e, n) {
|
|
3323
3329
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof v ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3324
3330
|
}
|
|
@@ -3327,21 +3333,21 @@ class Mt {
|
|
|
3327
3333
|
}
|
|
3328
3334
|
interpretName(e) {
|
|
3329
3335
|
const n = [], s = W(this.declarationNode.name).unwrap_or([]);
|
|
3330
|
-
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new
|
|
3336
|
+
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3331
3337
|
}
|
|
3332
3338
|
interpretBody(e) {
|
|
3333
|
-
return e instanceof
|
|
3339
|
+
return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3334
3340
|
}
|
|
3335
3341
|
interpretField(e) {
|
|
3336
3342
|
var f, E, h, m;
|
|
3337
3343
|
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
|
|
3338
|
-
if (
|
|
3339
|
-
return [new
|
|
3340
|
-
const
|
|
3341
|
-
if (this.env.refIds[
|
|
3344
|
+
if (Ut(r, a))
|
|
3345
|
+
return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3346
|
+
const l = Pt(r, a);
|
|
3347
|
+
if (this.env.refIds[l])
|
|
3342
3348
|
return [
|
|
3343
|
-
new
|
|
3344
|
-
new
|
|
3349
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3350
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
|
|
3345
3351
|
];
|
|
3346
3352
|
if (e.args[0]) {
|
|
3347
3353
|
const g = B(e.args[0]).getValue(), _ = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
|
|
@@ -3349,22 +3355,22 @@ class Mt {
|
|
|
3349
3355
|
const ee = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
|
|
3350
3356
|
this.ref.onUpdate = ee instanceof Y ? Te(ee).unwrap_or(void 0) : j(ee).unwrap_or(void 0);
|
|
3351
3357
|
}
|
|
3352
|
-
const p =
|
|
3358
|
+
const p = Rt(n);
|
|
3353
3359
|
return this.ref.endpoints = [
|
|
3354
3360
|
{
|
|
3355
|
-
...
|
|
3361
|
+
...dt(s, this.container),
|
|
3356
3362
|
relation: p[0],
|
|
3357
3363
|
token: A(s)
|
|
3358
3364
|
},
|
|
3359
3365
|
{
|
|
3360
|
-
...
|
|
3366
|
+
...dt(i, this.container),
|
|
3361
3367
|
relation: p[1],
|
|
3362
3368
|
token: A(i)
|
|
3363
3369
|
}
|
|
3364
|
-
], this.env.refIds[
|
|
3370
|
+
], this.env.refIds[l] = this.declarationNode, [];
|
|
3365
3371
|
}
|
|
3366
3372
|
}
|
|
3367
|
-
class
|
|
3373
|
+
class Bt {
|
|
3368
3374
|
constructor(e, n) {
|
|
3369
3375
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3370
3376
|
}
|
|
@@ -3378,10 +3384,10 @@ class Ft {
|
|
|
3378
3384
|
}
|
|
3379
3385
|
interpretName(e) {
|
|
3380
3386
|
const n = [], { name: s, schemaName: i } = Ie(e);
|
|
3381
|
-
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new
|
|
3387
|
+
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3382
3388
|
}
|
|
3383
3389
|
interpretBody(e) {
|
|
3384
|
-
const [n, s] =
|
|
3390
|
+
const [n, s] = Yt(e.body, (i) => i instanceof w);
|
|
3385
3391
|
return [
|
|
3386
3392
|
...this.interpretFields(n),
|
|
3387
3393
|
...this.interpretSubElements(s)
|
|
@@ -3407,11 +3413,11 @@ class Ft {
|
|
|
3407
3413
|
const n = [];
|
|
3408
3414
|
return this.tableGroup.tables = e.map((s) => {
|
|
3409
3415
|
const i = W(s.callee).unwrap();
|
|
3410
|
-
i.length > 2 && n.push(new
|
|
3416
|
+
i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3411
3417
|
const r = pe(s.callee).unwrap().pop().referee.id;
|
|
3412
3418
|
if (this.env.groupOfTable[r]) {
|
|
3413
|
-
const a = this.env.groupOfTable[r], { schemaName:
|
|
3414
|
-
n.push(new
|
|
3419
|
+
const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), f = l ? `${l}.${p}` : p;
|
|
3420
|
+
n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${f}"`, s));
|
|
3415
3421
|
} else
|
|
3416
3422
|
this.env.groupOfTable[r] = this.declarationNode;
|
|
3417
3423
|
return {
|
|
@@ -3421,14 +3427,17 @@ class Ft {
|
|
|
3421
3427
|
}), n;
|
|
3422
3428
|
}
|
|
3423
3429
|
interpretSettingList(e) {
|
|
3424
|
-
|
|
3430
|
+
var i, r, a;
|
|
3431
|
+
const n = B(e).getValue();
|
|
3432
|
+
this.tableGroup.color = (i = n.color) != null && i.length ? Ke((a = (r = n.color) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
|
|
3433
|
+
const [s] = n.note || [];
|
|
3425
3434
|
return this.tableGroup.note = s && {
|
|
3426
3435
|
value: G(s == null ? void 0 : s.value).map(re).unwrap(),
|
|
3427
3436
|
token: A(s)
|
|
3428
3437
|
}, [];
|
|
3429
3438
|
}
|
|
3430
3439
|
}
|
|
3431
|
-
class
|
|
3440
|
+
class Vt {
|
|
3432
3441
|
constructor(e, n) {
|
|
3433
3442
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3434
3443
|
}
|
|
@@ -3437,14 +3446,14 @@ class Bt {
|
|
|
3437
3446
|
}
|
|
3438
3447
|
interpretName(e) {
|
|
3439
3448
|
const { name: n, schemaName: s } = Ie(e);
|
|
3440
|
-
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new
|
|
3449
|
+
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3441
3450
|
}
|
|
3442
3451
|
interpretBody(e) {
|
|
3443
3452
|
return e.body.flatMap((n) => {
|
|
3444
|
-
var
|
|
3453
|
+
var l;
|
|
3445
3454
|
const s = n, i = {};
|
|
3446
3455
|
i.token = A(s), i.name = j(s.callee).unwrap();
|
|
3447
|
-
const a = (
|
|
3456
|
+
const a = (l = B(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
|
|
3448
3457
|
return i.note = a && {
|
|
3449
3458
|
value: G(a.value).map(re).unwrap(),
|
|
3450
3459
|
token: A(a)
|
|
@@ -3471,19 +3480,19 @@ class Zn {
|
|
|
3471
3480
|
const s = n;
|
|
3472
3481
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
3473
3482
|
case "table": {
|
|
3474
|
-
const r = new
|
|
3483
|
+
const r = new Mt(s, this.env).interpret();
|
|
3475
3484
|
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3476
3485
|
}
|
|
3477
3486
|
case "ref": {
|
|
3478
|
-
const r = new
|
|
3487
|
+
const r = new Ft(s, this.env).interpret();
|
|
3479
3488
|
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3480
3489
|
}
|
|
3481
3490
|
case "tablegroup": {
|
|
3482
|
-
const r = new
|
|
3491
|
+
const r = new Bt(s, this.env).interpret();
|
|
3483
3492
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
|
|
3484
3493
|
}
|
|
3485
3494
|
case "enum": {
|
|
3486
|
-
const r = new
|
|
3495
|
+
const r = new Vt(s, this.env).interpret();
|
|
3487
3496
|
return this.project.enums.push(this.env.enums.get(s)), r;
|
|
3488
3497
|
}
|
|
3489
3498
|
case "note":
|
|
@@ -3516,15 +3525,15 @@ class Kn {
|
|
|
3516
3525
|
const e = this.ast.body.flatMap((n) => {
|
|
3517
3526
|
switch (ve(n).unwrap_or(void 0)) {
|
|
3518
3527
|
case b.Table:
|
|
3519
|
-
return new
|
|
3528
|
+
return new Mt(n, this.env).interpret();
|
|
3520
3529
|
case b.Note:
|
|
3521
3530
|
return new Jn(n, this.env).interpret();
|
|
3522
3531
|
case b.Ref:
|
|
3523
|
-
return new Mt(n, this.env).interpret();
|
|
3524
|
-
case b.TableGroup:
|
|
3525
3532
|
return new Ft(n, this.env).interpret();
|
|
3526
|
-
case b.
|
|
3533
|
+
case b.TableGroup:
|
|
3527
3534
|
return new Bt(n, this.env).interpret();
|
|
3535
|
+
case b.Enum:
|
|
3536
|
+
return new Vt(n, this.env).interpret();
|
|
3528
3537
|
case b.Project:
|
|
3529
3538
|
return new Zn(n, this.env).interpret();
|
|
3530
3539
|
default:
|
|
@@ -3546,7 +3555,7 @@ function es(t) {
|
|
|
3546
3555
|
project: Array.from(t.project.values())[0] || {}
|
|
3547
3556
|
};
|
|
3548
3557
|
}
|
|
3549
|
-
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 || {}),
|
|
3558
|
+
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 || {});
|
|
3550
3559
|
function Ae(t) {
|
|
3551
3560
|
switch (t) {
|
|
3552
3561
|
case T.Schema:
|
|
@@ -3567,7 +3576,7 @@ function Ae(t) {
|
|
|
3567
3576
|
return L.Text;
|
|
3568
3577
|
}
|
|
3569
3578
|
}
|
|
3570
|
-
function
|
|
3579
|
+
function Re(t, e) {
|
|
3571
3580
|
if (!t || Ce(t))
|
|
3572
3581
|
return !1;
|
|
3573
3582
|
for (const n of t.trailingTrivia) {
|
|
@@ -3578,7 +3587,7 @@ function De(t, e) {
|
|
|
3578
3587
|
}
|
|
3579
3588
|
return !0;
|
|
3580
3589
|
}
|
|
3581
|
-
function
|
|
3590
|
+
function D() {
|
|
3582
3591
|
return {
|
|
3583
3592
|
suggestions: []
|
|
3584
3593
|
};
|
|
@@ -3601,29 +3610,29 @@ function Fe(t) {
|
|
|
3601
3610
|
}))
|
|
3602
3611
|
};
|
|
3603
3612
|
}
|
|
3604
|
-
function
|
|
3613
|
+
function et(t, e) {
|
|
3605
3614
|
return t.getOffsetAt(e);
|
|
3606
3615
|
}
|
|
3607
|
-
class
|
|
3616
|
+
class Gt {
|
|
3608
3617
|
constructor(e, n = []) {
|
|
3609
3618
|
this.compiler = e, this.triggerCharacters = n;
|
|
3610
3619
|
}
|
|
3611
3620
|
provideCompletionItems(e, n) {
|
|
3612
3621
|
var E, h;
|
|
3613
|
-
const s =
|
|
3622
|
+
const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
|
|
3614
3623
|
if ([
|
|
3615
3624
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3616
3625
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3617
|
-
...(
|
|
3618
|
-
].find((m) =>
|
|
3619
|
-
return
|
|
3626
|
+
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3627
|
+
].find((m) => qt(m) && ge(s, m)))
|
|
3628
|
+
return D();
|
|
3620
3629
|
if (a === void 0)
|
|
3621
|
-
return
|
|
3630
|
+
return bt();
|
|
3622
3631
|
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
|
|
3623
|
-
return
|
|
3632
|
+
return D();
|
|
3624
3633
|
const p = this.compiler.container.element(s);
|
|
3625
3634
|
if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof v && p.type && p.type.start <= s && p.type.end >= s)
|
|
3626
|
-
return
|
|
3635
|
+
return bt();
|
|
3627
3636
|
const f = [...this.compiler.container.stack(s)].reverse();
|
|
3628
3637
|
for (const m of f)
|
|
3629
3638
|
if (m instanceof Q)
|
|
@@ -3632,7 +3641,7 @@ class Vt {
|
|
|
3632
3641
|
case "<":
|
|
3633
3642
|
case "<>":
|
|
3634
3643
|
case "-":
|
|
3635
|
-
return
|
|
3644
|
+
return Et(
|
|
3636
3645
|
this.compiler,
|
|
3637
3646
|
s,
|
|
3638
3647
|
m
|
|
@@ -3644,13 +3653,13 @@ class Vt {
|
|
|
3644
3653
|
case "<":
|
|
3645
3654
|
case "<>":
|
|
3646
3655
|
case "-":
|
|
3647
|
-
return
|
|
3656
|
+
return Et(
|
|
3648
3657
|
this.compiler,
|
|
3649
3658
|
s,
|
|
3650
3659
|
m
|
|
3651
3660
|
);
|
|
3652
3661
|
case ".":
|
|
3653
|
-
return
|
|
3662
|
+
return Ct(
|
|
3654
3663
|
this.compiler,
|
|
3655
3664
|
s,
|
|
3656
3665
|
m
|
|
@@ -3658,20 +3667,20 @@ class Vt {
|
|
|
3658
3667
|
}
|
|
3659
3668
|
else {
|
|
3660
3669
|
if (m instanceof se)
|
|
3661
|
-
return
|
|
3662
|
-
if (m instanceof
|
|
3663
|
-
return
|
|
3670
|
+
return Nt(this.compiler, s, m);
|
|
3671
|
+
if (m instanceof R)
|
|
3672
|
+
return Nt(this.compiler, s, m);
|
|
3664
3673
|
if (m instanceof Z)
|
|
3665
3674
|
return ts(this.compiler, s);
|
|
3666
|
-
if (m instanceof
|
|
3667
|
-
return
|
|
3675
|
+
if (m instanceof w)
|
|
3676
|
+
return Tt(this.compiler, s, m);
|
|
3668
3677
|
if (m instanceof v && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
|
|
3669
|
-
return
|
|
3678
|
+
return Tt(this.compiler, s, void 0);
|
|
3670
3679
|
}
|
|
3671
|
-
return
|
|
3680
|
+
return D();
|
|
3672
3681
|
}
|
|
3673
3682
|
}
|
|
3674
|
-
function
|
|
3683
|
+
function Et(t, e, n) {
|
|
3675
3684
|
const s = t.container.scopeKind(e);
|
|
3676
3685
|
if ([O.REF, O.TABLE].includes(s)) {
|
|
3677
3686
|
const i = Be(t, e, t.container.element(e), [
|
|
@@ -3679,24 +3688,24 @@ function dt(t, e, n) {
|
|
|
3679
3688
|
T.Schema,
|
|
3680
3689
|
T.Column
|
|
3681
3690
|
]);
|
|
3682
|
-
return
|
|
3691
|
+
return Re(n.op, e) ? Pe(i) : i;
|
|
3683
3692
|
}
|
|
3684
|
-
return
|
|
3693
|
+
return D();
|
|
3685
3694
|
}
|
|
3686
3695
|
function Be(t, e, n, s) {
|
|
3687
3696
|
var a;
|
|
3688
3697
|
if (n === void 0)
|
|
3689
|
-
return
|
|
3698
|
+
return D();
|
|
3690
3699
|
let i = n;
|
|
3691
3700
|
const r = { suggestions: [] };
|
|
3692
3701
|
for (; i; ) {
|
|
3693
3702
|
if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
|
|
3694
|
-
const { symbol:
|
|
3703
|
+
const { symbol: l } = i;
|
|
3695
3704
|
r.suggestions.push(
|
|
3696
|
-
...t.symbol.members(
|
|
3705
|
+
...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
|
|
3697
3706
|
label: p,
|
|
3698
3707
|
insertText: p,
|
|
3699
|
-
insertTextRules:
|
|
3708
|
+
insertTextRules: y.KeepWhitespace,
|
|
3700
3709
|
kind: Ae(f),
|
|
3701
3710
|
sortText: Ae(f).toString().padStart(2, "0"),
|
|
3702
3711
|
range: void 0
|
|
@@ -3711,81 +3720,70 @@ function ts(t, e) {
|
|
|
3711
3720
|
var s;
|
|
3712
3721
|
switch (t.container.scopeKind(e)) {
|
|
3713
3722
|
case O.INDEXES:
|
|
3714
|
-
return
|
|
3723
|
+
return $t(t, e);
|
|
3715
3724
|
case O.REF:
|
|
3716
3725
|
{
|
|
3717
3726
|
const i = [...t.container.stack(e)];
|
|
3718
3727
|
for (; i.length > 0; ) {
|
|
3719
3728
|
const r = i.pop();
|
|
3720
3729
|
if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3721
|
-
return
|
|
3730
|
+
return Ct(
|
|
3722
3731
|
t,
|
|
3723
3732
|
e,
|
|
3724
3733
|
r
|
|
3725
3734
|
);
|
|
3726
3735
|
}
|
|
3727
3736
|
}
|
|
3728
|
-
return
|
|
3737
|
+
return Xt(t, e);
|
|
3729
3738
|
}
|
|
3730
|
-
return
|
|
3739
|
+
return D();
|
|
3731
3740
|
}
|
|
3732
|
-
function
|
|
3741
|
+
function Nt(t, e, n) {
|
|
3733
3742
|
const { token: s } = t.container.token(e);
|
|
3734
3743
|
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3735
|
-
const i =
|
|
3736
|
-
return (s == null ? void 0 : s.kind) === u.COMMA &&
|
|
3744
|
+
const i = mt(t, e);
|
|
3745
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && Re(s, e) ? Pe(i) : i;
|
|
3737
3746
|
}
|
|
3738
3747
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3739
|
-
return
|
|
3748
|
+
return mt(t, e);
|
|
3740
3749
|
if (n.name instanceof Y) {
|
|
3741
3750
|
const i = ns(
|
|
3742
3751
|
t,
|
|
3743
3752
|
e,
|
|
3744
3753
|
Te(n.name).unwrap_or("")
|
|
3745
3754
|
);
|
|
3746
|
-
return (s == null ? void 0 : s.kind) === u.COLON &&
|
|
3755
|
+
return (s == null ? void 0 : s.kind) === u.COLON && Re(s, e) ? Pe(i) : i;
|
|
3747
3756
|
}
|
|
3748
|
-
return
|
|
3757
|
+
return D();
|
|
3749
3758
|
}
|
|
3750
|
-
function
|
|
3759
|
+
function mt(t, e) {
|
|
3751
3760
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3752
3761
|
if (n instanceof X)
|
|
3753
|
-
return
|
|
3762
|
+
return D();
|
|
3754
3763
|
if (n.body && !ge(e, n.body))
|
|
3755
3764
|
switch (s) {
|
|
3756
3765
|
case O.TABLE:
|
|
3757
3766
|
return {
|
|
3758
|
-
suggestions: [
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
},
|
|
3766
|
-
{
|
|
3767
|
-
label: "note",
|
|
3768
|
-
insertText: "note: ",
|
|
3769
|
-
kind: L.Field,
|
|
3770
|
-
insertTextRules: w.KeepWhitespace,
|
|
3771
|
-
range: void 0
|
|
3772
|
-
}
|
|
3773
|
-
]
|
|
3767
|
+
suggestions: ["headercolor", "note"].map((i) => ({
|
|
3768
|
+
label: i,
|
|
3769
|
+
insertText: `${i}: `,
|
|
3770
|
+
kind: L.Field,
|
|
3771
|
+
insertTextRules: y.KeepWhitespace,
|
|
3772
|
+
range: void 0
|
|
3773
|
+
}))
|
|
3774
3774
|
};
|
|
3775
3775
|
case O.TABLEGROUP:
|
|
3776
3776
|
return {
|
|
3777
|
-
suggestions: [
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
}
|
|
3785
|
-
]
|
|
3777
|
+
suggestions: ["color", "note"].map((i) => ({
|
|
3778
|
+
label: i,
|
|
3779
|
+
insertText: `${i}: `,
|
|
3780
|
+
kind: L.Field,
|
|
3781
|
+
insertTextRules: y.KeepWhitespace,
|
|
3782
|
+
range: void 0
|
|
3783
|
+
}))
|
|
3786
3784
|
};
|
|
3787
3785
|
default:
|
|
3788
|
-
return
|
|
3786
|
+
return D();
|
|
3789
3787
|
}
|
|
3790
3788
|
switch (s) {
|
|
3791
3789
|
case O.TABLE:
|
|
@@ -3795,21 +3793,21 @@ function Nt(t, e) {
|
|
|
3795
3793
|
label: i,
|
|
3796
3794
|
insertText: i,
|
|
3797
3795
|
kind: L.Property,
|
|
3798
|
-
insertTextRules:
|
|
3796
|
+
insertTextRules: y.KeepWhitespace,
|
|
3799
3797
|
range: void 0
|
|
3800
3798
|
})),
|
|
3801
3799
|
...["ref", "default"].map((i) => ({
|
|
3802
3800
|
label: i,
|
|
3803
3801
|
insertText: `${i}: `,
|
|
3804
3802
|
kind: L.Property,
|
|
3805
|
-
insertTextRules:
|
|
3803
|
+
insertTextRules: y.KeepWhitespace,
|
|
3806
3804
|
range: void 0
|
|
3807
3805
|
})),
|
|
3808
3806
|
{
|
|
3809
3807
|
label: "note",
|
|
3810
3808
|
insertText: "note: ",
|
|
3811
3809
|
kind: L.Property,
|
|
3812
|
-
insertTextRules:
|
|
3810
|
+
insertTextRules: y.KeepWhitespace,
|
|
3813
3811
|
range: void 0
|
|
3814
3812
|
}
|
|
3815
3813
|
]
|
|
@@ -3821,7 +3819,7 @@ function Nt(t, e) {
|
|
|
3821
3819
|
label: "note",
|
|
3822
3820
|
insertText: "note: ",
|
|
3823
3821
|
kind: L.Property,
|
|
3824
|
-
insertTextRules:
|
|
3822
|
+
insertTextRules: y.KeepWhitespace,
|
|
3825
3823
|
range: void 0
|
|
3826
3824
|
}
|
|
3827
3825
|
]
|
|
@@ -3832,7 +3830,7 @@ function Nt(t, e) {
|
|
|
3832
3830
|
...["unique", "pk"].map((i) => ({
|
|
3833
3831
|
label: i,
|
|
3834
3832
|
insertText: i,
|
|
3835
|
-
insertTextRules:
|
|
3833
|
+
insertTextRules: y.KeepWhitespace,
|
|
3836
3834
|
kind: L.Property,
|
|
3837
3835
|
range: void 0
|
|
3838
3836
|
})),
|
|
@@ -3840,7 +3838,7 @@ function Nt(t, e) {
|
|
|
3840
3838
|
label: i,
|
|
3841
3839
|
insertText: `${i}: `,
|
|
3842
3840
|
kind: L.Property,
|
|
3843
|
-
insertTextRules:
|
|
3841
|
+
insertTextRules: y.KeepWhitespace,
|
|
3844
3842
|
range: void 0
|
|
3845
3843
|
}))
|
|
3846
3844
|
]
|
|
@@ -3851,12 +3849,12 @@ function Nt(t, e) {
|
|
|
3851
3849
|
label: i,
|
|
3852
3850
|
insertText: `${i}: `,
|
|
3853
3851
|
kind: L.Property,
|
|
3854
|
-
insertTextRules:
|
|
3852
|
+
insertTextRules: y.KeepWhitespace,
|
|
3855
3853
|
range: void 0
|
|
3856
3854
|
}))
|
|
3857
3855
|
};
|
|
3858
3856
|
}
|
|
3859
|
-
return
|
|
3857
|
+
return D();
|
|
3860
3858
|
}
|
|
3861
3859
|
function ns(t, e, n) {
|
|
3862
3860
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
@@ -3867,7 +3865,7 @@ function ns(t, e, n) {
|
|
|
3867
3865
|
label: s,
|
|
3868
3866
|
insertText: s,
|
|
3869
3867
|
kind: L.Value,
|
|
3870
|
-
insertTextRules:
|
|
3868
|
+
insertTextRules: y.KeepWhitespace,
|
|
3871
3869
|
range: void 0
|
|
3872
3870
|
}))
|
|
3873
3871
|
};
|
|
@@ -3877,17 +3875,17 @@ function ns(t, e, n) {
|
|
|
3877
3875
|
label: s,
|
|
3878
3876
|
insertText: `${s}`,
|
|
3879
3877
|
kind: L.Value,
|
|
3880
|
-
insertTextRules:
|
|
3878
|
+
insertTextRules: y.KeepWhitespace,
|
|
3881
3879
|
range: void 0
|
|
3882
3880
|
}))
|
|
3883
3881
|
};
|
|
3884
3882
|
}
|
|
3885
|
-
return
|
|
3883
|
+
return D();
|
|
3886
3884
|
}
|
|
3887
|
-
function
|
|
3885
|
+
function Ct(t, e, n) {
|
|
3888
3886
|
const s = pe(n).unwrap_or([]);
|
|
3889
3887
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3890
|
-
return
|
|
3888
|
+
return D();
|
|
3891
3889
|
const i = s.map((r) => j(r).unwrap());
|
|
3892
3890
|
return Fe({
|
|
3893
3891
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
@@ -3898,7 +3896,7 @@ function Gt(t, e, n) {
|
|
|
3898
3896
|
}))
|
|
3899
3897
|
});
|
|
3900
3898
|
}
|
|
3901
|
-
function
|
|
3899
|
+
function Tt(t, e, n) {
|
|
3902
3900
|
var i;
|
|
3903
3901
|
switch (t.container.scopeKind(e)) {
|
|
3904
3902
|
case O.TABLE:
|
|
@@ -3910,32 +3908,32 @@ function mt(t, e, n) {
|
|
|
3910
3908
|
case O.ENUM:
|
|
3911
3909
|
return ss(t, e, n);
|
|
3912
3910
|
case O.REF: {
|
|
3913
|
-
const r =
|
|
3914
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON &&
|
|
3911
|
+
const r = Xt(t, e);
|
|
3912
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Re(t.container.token(e).token, e) ? Pe(r) : r;
|
|
3915
3913
|
}
|
|
3916
3914
|
case O.TABLEGROUP:
|
|
3917
3915
|
return as(t);
|
|
3918
3916
|
default:
|
|
3919
|
-
return
|
|
3917
|
+
return D();
|
|
3920
3918
|
}
|
|
3921
3919
|
}
|
|
3922
|
-
function
|
|
3920
|
+
function bt() {
|
|
3923
3921
|
return {
|
|
3924
3922
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3925
3923
|
label: t,
|
|
3926
3924
|
insertText: t,
|
|
3927
|
-
insertTextRules:
|
|
3925
|
+
insertTextRules: y.KeepWhitespace,
|
|
3928
3926
|
kind: L.Keyword,
|
|
3929
3927
|
range: void 0
|
|
3930
3928
|
}))
|
|
3931
3929
|
};
|
|
3932
3930
|
}
|
|
3933
3931
|
function ss(t, e, n) {
|
|
3934
|
-
return n != null && n.callee &&
|
|
3932
|
+
return n != null && n.callee && tt(e, n) === 1 ? Be(t, e, t.container.element(e), [
|
|
3935
3933
|
T.Schema,
|
|
3936
3934
|
T.Table,
|
|
3937
3935
|
T.Column
|
|
3938
|
-
]) :
|
|
3936
|
+
]) : D();
|
|
3939
3937
|
}
|
|
3940
3938
|
function is(t, e, n) {
|
|
3941
3939
|
if (!(n != null && n.callee))
|
|
@@ -3943,42 +3941,42 @@ function is(t, e, n) {
|
|
|
3943
3941
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3944
3942
|
label: i,
|
|
3945
3943
|
insertText: i,
|
|
3946
|
-
insertTextRules:
|
|
3944
|
+
insertTextRules: y.KeepWhitespace,
|
|
3947
3945
|
kind: L.Keyword,
|
|
3948
3946
|
range: void 0
|
|
3949
3947
|
}))
|
|
3950
3948
|
};
|
|
3951
|
-
const s =
|
|
3949
|
+
const s = tt(e, n);
|
|
3952
3950
|
return s === 0 ? {
|
|
3953
3951
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3954
3952
|
label: i,
|
|
3955
3953
|
insertText: i,
|
|
3956
|
-
insertTextRules:
|
|
3954
|
+
insertTextRules: y.KeepWhitespace,
|
|
3957
3955
|
kind: L.Keyword,
|
|
3958
3956
|
range: void 0
|
|
3959
3957
|
}))
|
|
3960
|
-
} : s === 1 ? ls(t, e) :
|
|
3958
|
+
} : s === 1 ? ls(t, e) : D();
|
|
3961
3959
|
}
|
|
3962
3960
|
function rs(t, e, n) {
|
|
3963
|
-
return n != null && n.callee ?
|
|
3961
|
+
return n != null && n.callee ? tt(e, n) === 0 ? {
|
|
3964
3962
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3965
3963
|
label: i,
|
|
3966
3964
|
insertText: i,
|
|
3967
|
-
insertTextRules:
|
|
3965
|
+
insertTextRules: y.KeepWhitespace,
|
|
3968
3966
|
kind: L.Keyword,
|
|
3969
3967
|
range: void 0
|
|
3970
3968
|
}))
|
|
3971
|
-
} :
|
|
3969
|
+
} : D() : {
|
|
3972
3970
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3973
3971
|
label: i,
|
|
3974
3972
|
insertText: i,
|
|
3975
|
-
insertTextRules:
|
|
3973
|
+
insertTextRules: y.KeepWhitespace,
|
|
3976
3974
|
kind: L.Keyword,
|
|
3977
3975
|
range: void 0
|
|
3978
3976
|
}))
|
|
3979
3977
|
};
|
|
3980
3978
|
}
|
|
3981
|
-
function
|
|
3979
|
+
function Xt(t, e) {
|
|
3982
3980
|
return Be(t, e, t.container.element(e), [
|
|
3983
3981
|
T.Schema,
|
|
3984
3982
|
T.Table,
|
|
@@ -3997,7 +3995,7 @@ function as(t) {
|
|
|
3997
3995
|
return s !== T.Table && s !== T.Schema ? [] : {
|
|
3998
3996
|
label: i,
|
|
3999
3997
|
insertText: i,
|
|
4000
|
-
insertTextRules:
|
|
3998
|
+
insertTextRules: y.KeepWhitespace,
|
|
4001
3999
|
kind: Ae(s),
|
|
4002
4000
|
range: void 0
|
|
4003
4001
|
};
|
|
@@ -4006,7 +4004,7 @@ function as(t) {
|
|
|
4006
4004
|
...["Note"].map((e) => ({
|
|
4007
4005
|
label: e,
|
|
4008
4006
|
insertText: e,
|
|
4009
|
-
insertTextRules:
|
|
4007
|
+
insertTextRules: y.KeepWhitespace,
|
|
4010
4008
|
kind: L.Keyword,
|
|
4011
4009
|
range: void 0
|
|
4012
4010
|
}))
|
|
@@ -4014,7 +4012,7 @@ function as(t) {
|
|
|
4014
4012
|
};
|
|
4015
4013
|
}
|
|
4016
4014
|
function os(t, e) {
|
|
4017
|
-
return
|
|
4015
|
+
return $t(t, e);
|
|
4018
4016
|
}
|
|
4019
4017
|
function ls(t, e) {
|
|
4020
4018
|
return {
|
|
@@ -4079,7 +4077,7 @@ function ls(t, e) {
|
|
|
4079
4077
|
].map((n) => ({
|
|
4080
4078
|
label: n,
|
|
4081
4079
|
insertText: n,
|
|
4082
|
-
insertTextRules:
|
|
4080
|
+
insertTextRules: y.KeepWhitespace,
|
|
4083
4081
|
kind: L.TypeParameter,
|
|
4084
4082
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
4085
4083
|
range: void 0
|
|
@@ -4091,44 +4089,44 @@ function ls(t, e) {
|
|
|
4091
4089
|
]
|
|
4092
4090
|
};
|
|
4093
4091
|
}
|
|
4094
|
-
function
|
|
4092
|
+
function $t(t, e) {
|
|
4095
4093
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
4096
|
-
if (!((s == null ? void 0 : s.symbol) instanceof
|
|
4097
|
-
return
|
|
4094
|
+
if (!((s == null ? void 0 : s.symbol) instanceof vt))
|
|
4095
|
+
return D();
|
|
4098
4096
|
const { symbolTable: i } = s.symbol;
|
|
4099
4097
|
return Fe({
|
|
4100
4098
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
4101
4099
|
const a = ie(r).unwrap_or(void 0);
|
|
4102
4100
|
if (a === void 0)
|
|
4103
4101
|
return [];
|
|
4104
|
-
const { name:
|
|
4102
|
+
const { name: l } = a;
|
|
4105
4103
|
return {
|
|
4106
|
-
label:
|
|
4107
|
-
insertText:
|
|
4108
|
-
insertTextRules:
|
|
4104
|
+
label: l,
|
|
4105
|
+
insertText: l,
|
|
4106
|
+
insertTextRules: y.KeepWhitespace,
|
|
4109
4107
|
kind: Ae(T.Column),
|
|
4110
4108
|
range: void 0
|
|
4111
4109
|
};
|
|
4112
4110
|
})
|
|
4113
4111
|
});
|
|
4114
4112
|
}
|
|
4115
|
-
function
|
|
4113
|
+
function tt(t, e) {
|
|
4116
4114
|
if (!e.callee)
|
|
4117
4115
|
return -1;
|
|
4118
4116
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
4119
4117
|
return s === -1 ? n.length : s;
|
|
4120
4118
|
}
|
|
4121
|
-
class
|
|
4119
|
+
class Wt {
|
|
4122
4120
|
constructor(e) {
|
|
4123
4121
|
this.compiler = e;
|
|
4124
4122
|
}
|
|
4125
4123
|
provideDefinition(e, n) {
|
|
4126
4124
|
var a;
|
|
4127
|
-
const { uri: s } = e, i =
|
|
4125
|
+
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
4128
4126
|
for (; r.length !== 0; ) {
|
|
4129
|
-
const
|
|
4130
|
-
if ((a =
|
|
4131
|
-
const { startPos: p, endPos: f } =
|
|
4127
|
+
const l = r.pop();
|
|
4128
|
+
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(l == null ? void 0 : l.kind)) {
|
|
4129
|
+
const { startPos: p, endPos: f } = l.referee.declaration;
|
|
4132
4130
|
return [
|
|
4133
4131
|
{
|
|
4134
4132
|
range: {
|
|
@@ -4145,12 +4143,12 @@ class $t {
|
|
|
4145
4143
|
return [];
|
|
4146
4144
|
}
|
|
4147
4145
|
}
|
|
4148
|
-
class
|
|
4146
|
+
class jt {
|
|
4149
4147
|
constructor(e) {
|
|
4150
4148
|
this.compiler = e;
|
|
4151
4149
|
}
|
|
4152
4150
|
provideReferences(e, n) {
|
|
4153
|
-
const { uri: s } = e, i =
|
|
4151
|
+
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
4154
4152
|
for (; r.length !== 0; ) {
|
|
4155
4153
|
const a = r.pop();
|
|
4156
4154
|
if (a && [
|
|
@@ -4158,9 +4156,9 @@ class Wt {
|
|
|
4158
4156
|
Ne.FUNCTION_APPLICATION,
|
|
4159
4157
|
Ne.PRIMARY_EXPRESSION
|
|
4160
4158
|
].includes(a == null ? void 0 : a.kind)) {
|
|
4161
|
-
const { symbol:
|
|
4162
|
-
if (
|
|
4163
|
-
return
|
|
4159
|
+
const { symbol: l } = a;
|
|
4160
|
+
if (l != null && l.references.length)
|
|
4161
|
+
return l.references.map(({ startPos: p, endPos: f }) => ({
|
|
4164
4162
|
range: {
|
|
4165
4163
|
startColumn: p.column + 1,
|
|
4166
4164
|
startLineNumber: p.line + 1,
|
|
@@ -4176,11 +4174,11 @@ class Wt {
|
|
|
4176
4174
|
}
|
|
4177
4175
|
const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4178
4176
|
__proto__: null,
|
|
4179
|
-
CompletionItemInsertTextRule:
|
|
4177
|
+
CompletionItemInsertTextRule: y,
|
|
4180
4178
|
CompletionItemKind: L,
|
|
4181
|
-
DBMLCompletionItemProvider:
|
|
4182
|
-
DBMLDefinitionProvider:
|
|
4183
|
-
DBMLReferencesProvider:
|
|
4179
|
+
DBMLCompletionItemProvider: Gt,
|
|
4180
|
+
DBMLDefinitionProvider: Wt,
|
|
4181
|
+
DBMLReferencesProvider: jt
|
|
4184
4182
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4185
4183
|
var O = /* @__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))(O || {});
|
|
4186
4184
|
class fs {
|
|
@@ -4188,10 +4186,10 @@ class fs {
|
|
|
4188
4186
|
this.source = "", this.cache = new Array(
|
|
4189
4187
|
16
|
|
4190
4188
|
/* TOTAL_QUERY_COUNT */
|
|
4191
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4189
|
+
).fill(null), this.nodeIdGenerator = new Ht(), this.symbolIdGenerator = new tn(), this.token = {
|
|
4192
4190
|
invalidStream: this.createQuery(
|
|
4193
4191
|
6,
|
|
4194
|
-
() => this.parse.tokens().filter(
|
|
4192
|
+
() => this.parse.tokens().filter(wt)
|
|
4195
4193
|
),
|
|
4196
4194
|
// Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
|
|
4197
4195
|
flatStream: this.createQuery(
|
|
@@ -4203,7 +4201,7 @@ class fs {
|
|
|
4203
4201
|
_: this.createQuery(
|
|
4204
4202
|
0,
|
|
4205
4203
|
() => {
|
|
4206
|
-
const e = new
|
|
4204
|
+
const e = new fn(this.source).lex().chain((n) => new En(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Qn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4207
4205
|
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Kn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4208
4206
|
}
|
|
4209
4207
|
),
|
|
@@ -4228,32 +4226,32 @@ class fs {
|
|
|
4228
4226
|
stack: this.createQuery(
|
|
4229
4227
|
10,
|
|
4230
4228
|
(e) => {
|
|
4231
|
-
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 :
|
|
4229
|
+
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : zt(n, (f) => !f.isInvalid, s);
|
|
4232
4230
|
if (r === -1)
|
|
4233
4231
|
return [this.parse.ast()];
|
|
4234
4232
|
const a = n[r].start;
|
|
4235
|
-
let
|
|
4236
|
-
const p = [
|
|
4233
|
+
let l = this.parse.ast();
|
|
4234
|
+
const p = [l];
|
|
4237
4235
|
for (; ; ) {
|
|
4238
|
-
const E =
|
|
4236
|
+
const E = hn(l).find((h) => ge(a, h));
|
|
4239
4237
|
if (E === void 0 || E instanceof F)
|
|
4240
4238
|
break;
|
|
4241
|
-
p.push(E),
|
|
4239
|
+
p.push(E), l = E;
|
|
4242
4240
|
}
|
|
4243
4241
|
if ((i == null ? void 0 : i.kind) === u.COLON)
|
|
4244
4242
|
return p;
|
|
4245
4243
|
for (; p.length > 0; ) {
|
|
4246
4244
|
let f = !1;
|
|
4247
|
-
const E =
|
|
4248
|
-
if (E instanceof
|
|
4245
|
+
const E = rt(p);
|
|
4246
|
+
if (E instanceof w) {
|
|
4249
4247
|
const h = this.parse.source();
|
|
4250
4248
|
for (let m = E.end; m < e; m += 1)
|
|
4251
4249
|
h[m] === `
|
|
4252
4250
|
` && (p.pop(), f = !0);
|
|
4253
4251
|
} else
|
|
4254
|
-
E instanceof Q || E instanceof q ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof
|
|
4252
|
+
E instanceof Q || E instanceof q ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof R ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof Z ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof J ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof Y || E.end < e && (p.pop(), f = !0);
|
|
4255
4253
|
if (f) {
|
|
4256
|
-
const h =
|
|
4254
|
+
const h = rt(p);
|
|
4257
4255
|
h instanceof v && h.end <= e && p.pop();
|
|
4258
4256
|
}
|
|
4259
4257
|
if (!f)
|
|
@@ -4331,14 +4329,14 @@ class fs {
|
|
|
4331
4329
|
if (!((i = r.symbol) != null && i.symbolTable))
|
|
4332
4330
|
continue;
|
|
4333
4331
|
const { symbolTable: a } = r.symbol;
|
|
4334
|
-
let
|
|
4332
|
+
let l = [a], p = [];
|
|
4335
4333
|
for (const f of e)
|
|
4336
|
-
p =
|
|
4337
|
-
(E) =>
|
|
4334
|
+
p = l.flatMap(
|
|
4335
|
+
(E) => Kt(f).flatMap((h) => {
|
|
4338
4336
|
const m = E.get(h), g = ie(h).unwrap_or(void 0);
|
|
4339
4337
|
return !m || !g ? [] : { ...g, symbol: m };
|
|
4340
4338
|
})
|
|
4341
|
-
),
|
|
4339
|
+
), l = p.flatMap(
|
|
4342
4340
|
(E) => E.symbol.symbolTable ? E.symbol.symbolTable : []
|
|
4343
4341
|
);
|
|
4344
4342
|
s.push(...p);
|
|
@@ -4365,8 +4363,8 @@ class fs {
|
|
|
4365
4363
|
if (r.has(a))
|
|
4366
4364
|
return r.get(a);
|
|
4367
4365
|
}
|
|
4368
|
-
const
|
|
4369
|
-
return i !== void 0 ? r instanceof Map ? r.set(a,
|
|
4366
|
+
const l = n(i);
|
|
4367
|
+
return i !== void 0 ? r instanceof Map ? r.set(a, l) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, l)) : this.cache[e] = l, l;
|
|
4370
4368
|
};
|
|
4371
4369
|
}
|
|
4372
4370
|
setSource(e) {
|
|
@@ -4377,9 +4375,9 @@ class fs {
|
|
|
4377
4375
|
}
|
|
4378
4376
|
initMonacoServices() {
|
|
4379
4377
|
return {
|
|
4380
|
-
definitionProvider: new
|
|
4381
|
-
referenceProvider: new
|
|
4382
|
-
autocompletionProvider: new
|
|
4378
|
+
definitionProvider: new Wt(this),
|
|
4379
|
+
referenceProvider: new jt(this),
|
|
4380
|
+
autocompletionProvider: new Gt(this)
|
|
4383
4381
|
};
|
|
4384
4382
|
}
|
|
4385
4383
|
}
|