@dbml/parse 3.1.5 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +5 -5
- package/dist/dbml-parse.mjs +377 -353
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -12,7 +12,7 @@ function Xt(t) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function it(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 rt(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
39
|
class B {
|
|
@@ -44,20 +44,20 @@ class B {
|
|
|
44
44
|
return new B(e, n, s, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Tt(t) {
|
|
48
48
|
return t.trailingTrivia.find(({ kind: e }) => e === c.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s === c.NEWLINE) !== void 0 ||
|
|
50
|
+
function at(t, e) {
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === c.NEWLINE) !== void 0 || Tt(t);
|
|
52
52
|
}
|
|
53
53
|
function Ve(t) {
|
|
54
54
|
return t.trailingTrivia.find(({ kind: e }) => e === c.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return t.trailingTrivia.length === 0 ? t.end :
|
|
56
|
+
function bt(t) {
|
|
57
|
+
return t.trailingTrivia.length === 0 ? t.end : bt(I.last(t.trailingTrivia));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return t.leadingTrivia.length === 0 ? t.start :
|
|
59
|
+
function It(t) {
|
|
60
|
+
return t.leadingTrivia.length === 0 ? t.start : It(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
62
|
function $t(t) {
|
|
63
63
|
return [c.SINGLE_LINE_COMMENT, c.MULTILINE_COMMENT].includes(
|
|
@@ -81,20 +81,20 @@ class y {
|
|
|
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 B ?
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? It(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 B ?
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? bt(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
94
94
|
}, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
var
|
|
97
|
+
var pe = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(pe || {});
|
|
98
98
|
class C extends y {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
@@ -151,7 +151,7 @@ class q extends y {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class Re extends y {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
@@ -175,7 +175,7 @@ class te extends y {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class
|
|
178
|
+
class P extends y {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: n = [],
|
|
@@ -184,7 +184,7 @@ class U extends y {
|
|
|
184
184
|
}, r) {
|
|
185
185
|
super(r, "<list-expression>", [
|
|
186
186
|
e,
|
|
187
|
-
...
|
|
187
|
+
...Lt(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 J extends y {
|
|
|
198
198
|
}, r) {
|
|
199
199
|
super(r, "<tuple-expression>", [
|
|
200
200
|
e,
|
|
201
|
-
...
|
|
201
|
+
...Lt(n, s),
|
|
202
202
|
i
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
@@ -228,7 +228,7 @@ class H extends y {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class Ee extends y {
|
|
232
232
|
constructor({ literal: e }, n) {
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
@@ -238,7 +238,7 @@ class X extends y {
|
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class
|
|
241
|
+
class D extends y {
|
|
242
242
|
constructor({ expression: e }, n) {
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
@@ -249,12 +249,12 @@ class we extends y {
|
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
252
|
+
class le extends y {
|
|
253
253
|
constructor({ expression: e, indexer: n }, s) {
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function Lt(t, e) {
|
|
258
258
|
if (!t || t.length === 0)
|
|
259
259
|
return e || [];
|
|
260
260
|
if (!e || e.length === 0)
|
|
@@ -290,7 +290,7 @@ function is(t, e = !1) {
|
|
|
290
290
|
e ? 2 : 0
|
|
291
291
|
);
|
|
292
292
|
}
|
|
293
|
-
class
|
|
293
|
+
class O {
|
|
294
294
|
constructor(e) {
|
|
295
295
|
this.value = e;
|
|
296
296
|
}
|
|
@@ -305,7 +305,7 @@ class S {
|
|
|
305
305
|
return e(this.value);
|
|
306
306
|
}
|
|
307
307
|
map(e) {
|
|
308
|
-
return new
|
|
308
|
+
return new O(e(this.value));
|
|
309
309
|
}
|
|
310
310
|
// eslint-disable-next-line class-methods-use-this
|
|
311
311
|
isOk() {
|
|
@@ -378,7 +378,7 @@ function Fe(t, e) {
|
|
|
378
378
|
}
|
|
379
379
|
function se(t) {
|
|
380
380
|
const [e, n] = t.split(":");
|
|
381
|
-
return Object.values(m).includes(e) ? new
|
|
381
|
+
return Object.values(m).includes(e) ? new O({
|
|
382
382
|
name: n,
|
|
383
383
|
kind: e
|
|
384
384
|
}) : new A();
|
|
@@ -413,16 +413,16 @@ function zt(t) {
|
|
|
413
413
|
const [e] = t;
|
|
414
414
|
return xe(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function fe(t) {
|
|
417
417
|
return qe(t) || xe(t);
|
|
418
418
|
}
|
|
419
|
-
function
|
|
419
|
+
function ot(t, e) {
|
|
420
420
|
const n = [], s = Math.min(t.length, e.length);
|
|
421
421
|
for (let i = 0; i < s; i += 1)
|
|
422
422
|
n.push(t[i], e[i]);
|
|
423
423
|
return n.push(...t.slice(s), ...e.slice(s)), n;
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function be(t, e) {
|
|
426
426
|
return t >= e.start && t < e.end;
|
|
427
427
|
}
|
|
428
428
|
class Qt {
|
|
@@ -436,7 +436,7 @@ class Qt {
|
|
|
436
436
|
return this.id++;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
class
|
|
439
|
+
class gt {
|
|
440
440
|
constructor({ symbolTable: e }, n) {
|
|
441
441
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
442
442
|
}
|
|
@@ -451,7 +451,7 @@ class Ht {
|
|
|
451
451
|
this.references = [], this.id = n, this.declaration = e;
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
-
class
|
|
454
|
+
class _t {
|
|
455
455
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
456
456
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
457
457
|
}
|
|
@@ -471,7 +471,7 @@ class Kt {
|
|
|
471
471
|
this.references = [], this.id = n, this.declaration = e;
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
|
-
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_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))(o || {});
|
|
474
|
+
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_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 || {});
|
|
475
475
|
class u extends Error {
|
|
476
476
|
constructor(e, n, s) {
|
|
477
477
|
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, u.prototype);
|
|
@@ -496,13 +496,13 @@ class F {
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
function en(t, e, n) {
|
|
499
|
-
if (!t || !
|
|
499
|
+
if (!t || !de(t) || e.length === 0)
|
|
500
500
|
return new A();
|
|
501
501
|
const s = [...e], i = Be(t).unwrap(), r = s.pop();
|
|
502
502
|
if (!(r instanceof te))
|
|
503
503
|
return new A();
|
|
504
|
-
const a = I.last(s) instanceof
|
|
505
|
-
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new
|
|
504
|
+
const a = I.last(s) instanceof P ? s.pop() : void 0;
|
|
505
|
+
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new O(
|
|
506
506
|
n.create(_, {
|
|
507
507
|
type: i,
|
|
508
508
|
name: s[0],
|
|
@@ -511,14 +511,14 @@ function en(t, e, n) {
|
|
|
511
511
|
attributeList: a,
|
|
512
512
|
body: r
|
|
513
513
|
})
|
|
514
|
-
) : s.length === 1 ? new
|
|
514
|
+
) : s.length === 1 ? new O(
|
|
515
515
|
n.create(_, {
|
|
516
516
|
type: i,
|
|
517
517
|
name: s[0],
|
|
518
518
|
attributeList: a,
|
|
519
519
|
body: r
|
|
520
520
|
})
|
|
521
|
-
) : s.length === 0 ? new
|
|
521
|
+
) : s.length === 0 ? new O(
|
|
522
522
|
n.create(_, {
|
|
523
523
|
type: i,
|
|
524
524
|
attributeList: a,
|
|
@@ -526,7 +526,7 @@ function en(t, e, n) {
|
|
|
526
526
|
})
|
|
527
527
|
) : new A();
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function lt(t) {
|
|
530
530
|
return t.kind === c.IDENTIFIER && t.value === "as";
|
|
531
531
|
}
|
|
532
532
|
function E(t) {
|
|
@@ -546,11 +546,11 @@ function nn(t) {
|
|
|
546
546
|
E(t.op), E(t.expression);
|
|
547
547
|
else if (t instanceof q)
|
|
548
548
|
E(t.leftExpression), E(t.op), E(t.rightExpression);
|
|
549
|
-
else if (t instanceof
|
|
549
|
+
else if (t instanceof Re)
|
|
550
550
|
E(t.op), E(t.expression);
|
|
551
551
|
else if (t instanceof te)
|
|
552
552
|
E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
|
|
553
|
-
else if (t instanceof
|
|
553
|
+
else if (t instanceof P)
|
|
554
554
|
E(t.listOpenBracket), t.commaList.forEach(E), t.elementList.forEach(E), E(t.listCloseBracket);
|
|
555
555
|
else if (t instanceof J)
|
|
556
556
|
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
@@ -558,28 +558,28 @@ function nn(t) {
|
|
|
558
558
|
E(t.callee), E(t.argumentList);
|
|
559
559
|
else if (t instanceof k)
|
|
560
560
|
E(t.callee), t.args.forEach(E);
|
|
561
|
-
else if (t instanceof
|
|
561
|
+
else if (t instanceof D)
|
|
562
562
|
E(t.expression);
|
|
563
563
|
else if (t instanceof ee)
|
|
564
564
|
E(t.value);
|
|
565
565
|
else if (t instanceof X)
|
|
566
566
|
E(t.variable);
|
|
567
|
-
else if (t instanceof
|
|
567
|
+
else if (t instanceof Ee)
|
|
568
568
|
E(t.literal);
|
|
569
569
|
else
|
|
570
570
|
throw t instanceof Xe ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
571
571
|
}
|
|
572
|
-
function
|
|
572
|
+
function At(t) {
|
|
573
573
|
return !!(t != null && t.isInvalid);
|
|
574
574
|
}
|
|
575
|
-
function
|
|
575
|
+
function U(...t) {
|
|
576
576
|
return t.filter((e) => e !== void 0);
|
|
577
577
|
}
|
|
578
578
|
function sn(t) {
|
|
579
579
|
if (t instanceof C)
|
|
580
|
-
return
|
|
580
|
+
return U(...t.body, t.eof);
|
|
581
581
|
if (t instanceof _)
|
|
582
|
-
return
|
|
582
|
+
return U(
|
|
583
583
|
t.type,
|
|
584
584
|
t.name,
|
|
585
585
|
t.as,
|
|
@@ -589,66 +589,71 @@ function sn(t) {
|
|
|
589
589
|
t.body
|
|
590
590
|
);
|
|
591
591
|
if (t instanceof ne)
|
|
592
|
-
return
|
|
592
|
+
return U(t.name, t.colon, t.value);
|
|
593
593
|
if (t instanceof K)
|
|
594
594
|
return t.identifiers;
|
|
595
|
-
if (t instanceof
|
|
595
|
+
if (t instanceof Ee)
|
|
596
596
|
return t.literal ? [t.literal] : [];
|
|
597
597
|
if (t instanceof X)
|
|
598
|
-
return
|
|
598
|
+
return U(t.variable);
|
|
599
599
|
if (t instanceof Q)
|
|
600
|
-
return
|
|
600
|
+
return U(t.op, t.expression);
|
|
601
601
|
if (t instanceof q)
|
|
602
|
-
return
|
|
603
|
-
if (t instanceof
|
|
604
|
-
return
|
|
602
|
+
return U(t.leftExpression, t.op, t.rightExpression);
|
|
603
|
+
if (t instanceof Re)
|
|
604
|
+
return U(t.expression, t.op);
|
|
605
605
|
if (t instanceof ee)
|
|
606
|
-
return
|
|
606
|
+
return U(t.value);
|
|
607
607
|
if (t instanceof k)
|
|
608
|
-
return
|
|
608
|
+
return U(t.callee, ...t.args);
|
|
609
609
|
if (t instanceof te)
|
|
610
|
-
return
|
|
611
|
-
if (t instanceof
|
|
612
|
-
return
|
|
610
|
+
return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
611
|
+
if (t instanceof P)
|
|
612
|
+
return U(
|
|
613
613
|
t.listOpenBracket,
|
|
614
|
-
...
|
|
614
|
+
...ot(t.elementList, t.commaList),
|
|
615
615
|
t.listCloseBracket
|
|
616
616
|
);
|
|
617
617
|
if (t instanceof J)
|
|
618
|
-
return
|
|
618
|
+
return U(
|
|
619
619
|
t.tupleOpenParen,
|
|
620
|
-
...
|
|
620
|
+
...ot(t.elementList, t.commaList),
|
|
621
621
|
t.tupleCloseParen
|
|
622
622
|
);
|
|
623
623
|
if (t instanceof H)
|
|
624
|
-
return
|
|
625
|
-
if (t instanceof
|
|
626
|
-
return
|
|
624
|
+
return U(t.callee, t.argumentList);
|
|
625
|
+
if (t instanceof D)
|
|
626
|
+
return U(t.expression);
|
|
627
|
+
if (t instanceof le)
|
|
628
|
+
return U(
|
|
629
|
+
t.array,
|
|
630
|
+
t.indexer
|
|
631
|
+
);
|
|
627
632
|
throw t instanceof Xe ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
628
633
|
}
|
|
629
634
|
function Be(t) {
|
|
630
|
-
return M(t) ? new
|
|
635
|
+
return M(t) ? new O(t.expression.variable) : new A();
|
|
631
636
|
}
|
|
632
637
|
function $(t) {
|
|
633
638
|
var e;
|
|
634
|
-
return t instanceof
|
|
639
|
+
return t instanceof D && (t.expression instanceof X && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof Ee && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
|
|
635
640
|
}
|
|
636
641
|
function M(t) {
|
|
637
|
-
return t instanceof
|
|
642
|
+
return t instanceof D && t.expression instanceof X && t.expression.variable instanceof B;
|
|
638
643
|
}
|
|
639
|
-
function
|
|
644
|
+
function de(t) {
|
|
640
645
|
var e;
|
|
641
|
-
return t instanceof
|
|
646
|
+
return t instanceof D && t.expression instanceof X && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
|
|
642
647
|
}
|
|
643
648
|
function He(t) {
|
|
644
649
|
var e;
|
|
645
650
|
return t instanceof q && t.leftExpression instanceof y && t.rightExpression instanceof y && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
646
651
|
}
|
|
647
|
-
function
|
|
652
|
+
function De(t) {
|
|
648
653
|
if (t === void 0)
|
|
649
654
|
return new A();
|
|
650
655
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
651
|
-
return e === "" ? new A() : new
|
|
656
|
+
return e === "" ? new A() : new O(e);
|
|
652
657
|
}
|
|
653
658
|
class rn {
|
|
654
659
|
// list of errors during lexing
|
|
@@ -760,7 +765,7 @@ class rn {
|
|
|
760
765
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
|
|
761
766
|
break;
|
|
762
767
|
default:
|
|
763
|
-
if (
|
|
768
|
+
if (it(e)) {
|
|
764
769
|
this.operator();
|
|
765
770
|
break;
|
|
766
771
|
}
|
|
@@ -794,7 +799,7 @@ class rn {
|
|
|
794
799
|
gatherInvalid() {
|
|
795
800
|
let e;
|
|
796
801
|
const n = [], s = [];
|
|
797
|
-
for (e = 0; e < this.tokens.length &&
|
|
802
|
+
for (e = 0; e < this.tokens.length && At(this.tokens[e]); e += 1)
|
|
798
803
|
s.push(this.tokens[e]);
|
|
799
804
|
let i = this.tokens[e];
|
|
800
805
|
for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
@@ -883,12 +888,12 @@ class rn {
|
|
|
883
888
|
});
|
|
884
889
|
}
|
|
885
890
|
identifier() {
|
|
886
|
-
for (; !this.isAtEnd() &&
|
|
891
|
+
for (; !this.isAtEnd() && fe(this.peek()); )
|
|
887
892
|
this.advance();
|
|
888
893
|
this.addToken(c.IDENTIFIER);
|
|
889
894
|
}
|
|
890
895
|
operator() {
|
|
891
|
-
for (;
|
|
896
|
+
for (; it(this.peek()); )
|
|
892
897
|
this.advance();
|
|
893
898
|
this.addToken(c.OP);
|
|
894
899
|
}
|
|
@@ -903,26 +908,26 @@ class rn {
|
|
|
903
908
|
break;
|
|
904
909
|
if (!n && this.current.offset === this.text.length - 1)
|
|
905
910
|
return this.advance(), this.addToken(c.NUMERIC_LITERAL);
|
|
906
|
-
if (!n && !
|
|
911
|
+
if (!n && !fe(this.peek()))
|
|
907
912
|
return this.addToken(c.NUMERIC_LITERAL);
|
|
908
913
|
if (!n && !xe(this.peek()))
|
|
909
914
|
break;
|
|
910
915
|
this.advance();
|
|
911
916
|
}
|
|
912
917
|
if (e > 0) {
|
|
913
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
918
|
+
for (; !this.isAtEnd() && (this.check(".") || fe(this.peek())); )
|
|
914
919
|
this.advance();
|
|
915
920
|
const n = this.createToken(c.NUMERIC_LITERAL, !0);
|
|
916
921
|
this.tokens.push(n), this.errors.push(new u(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
917
922
|
} else {
|
|
918
|
-
for (; !this.isAtEnd() &&
|
|
923
|
+
for (; !this.isAtEnd() && fe(this.peek()); )
|
|
919
924
|
this.advance();
|
|
920
925
|
const n = this.createToken(c.IDENTIFIER, !1);
|
|
921
926
|
this.tokens.push(n);
|
|
922
927
|
}
|
|
923
928
|
}
|
|
924
929
|
colorLiteral() {
|
|
925
|
-
for (; !this.isAtEnd() &&
|
|
930
|
+
for (; !this.isAtEnd() && fe(this.peek()); )
|
|
926
931
|
this.advance();
|
|
927
932
|
this.addToken(c.COLOR_LITERAL);
|
|
928
933
|
}
|
|
@@ -954,7 +959,7 @@ class rn {
|
|
|
954
959
|
case "u": {
|
|
955
960
|
let e = "";
|
|
956
961
|
for (let n = 0; n <= 3; n += 1) {
|
|
957
|
-
if (this.isAtEnd() || !
|
|
962
|
+
if (this.isAtEnd() || !fe(this.peek()))
|
|
958
963
|
return `\\u${e}`;
|
|
959
964
|
e += this.advance();
|
|
960
965
|
}
|
|
@@ -1053,7 +1058,7 @@ class ln {
|
|
|
1053
1058
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1054
1059
|
for (; !this.isAtEnd(); ) {
|
|
1055
1060
|
const s = this.peek();
|
|
1056
|
-
if (
|
|
1061
|
+
if (lt(s) || this.check(c.COLON, c.LBRACE, c.LBRACKET))
|
|
1057
1062
|
break;
|
|
1058
1063
|
E(s), this.advance();
|
|
1059
1064
|
}
|
|
@@ -1099,7 +1104,7 @@ class ln {
|
|
|
1099
1104
|
if (!this.check(c.RBRACE))
|
|
1100
1105
|
for (E(this.advance()); !this.isAtEnd(); ) {
|
|
1101
1106
|
const s = this.peek();
|
|
1102
|
-
if (this.check(c.RBRACE) ||
|
|
1107
|
+
if (this.check(c.RBRACE) || at(this.previous(), s))
|
|
1103
1108
|
break;
|
|
1104
1109
|
E(s), this.advance();
|
|
1105
1110
|
}
|
|
@@ -1156,7 +1161,7 @@ class ln {
|
|
|
1156
1161
|
E(s), this.advance();
|
|
1157
1162
|
}
|
|
1158
1163
|
}, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
|
|
1159
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1164
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(P, s);
|
|
1160
1165
|
try {
|
|
1161
1166
|
this.consume("Expect an opening bracket '['", c.LBRACKET), s.listOpenBracket = this.previous();
|
|
1162
1167
|
} catch (r) {
|
|
@@ -1308,7 +1313,7 @@ class ln {
|
|
|
1308
1313
|
throw new d(s.token, n(), s.handlerContext);
|
|
1309
1314
|
this.synchronizeElementDeclarationName();
|
|
1310
1315
|
}
|
|
1311
|
-
if (
|
|
1316
|
+
if (lt(this.peek()))
|
|
1312
1317
|
if (e.as = this.advance(), this.check(c.COLON, c.LBRACE, c.LBRACKET))
|
|
1313
1318
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1314
1319
|
else
|
|
@@ -1394,7 +1399,7 @@ class ln {
|
|
|
1394
1399
|
return n();
|
|
1395
1400
|
}
|
|
1396
1401
|
shouldStopExpression() {
|
|
1397
|
-
if (this.isAtEnd() ||
|
|
1402
|
+
if (this.isAtEnd() || Tt(this.previous()))
|
|
1398
1403
|
return !0;
|
|
1399
1404
|
const e = this.peek().kind;
|
|
1400
1405
|
return e === c.RBRACE || e === c.RBRACKET || e === c.RPAREN || e === c.COMMA || e === c.COLON;
|
|
@@ -1408,12 +1413,12 @@ class ln {
|
|
|
1408
1413
|
for (; !this.isAtEnd(); ) {
|
|
1409
1414
|
const s = this.peek();
|
|
1410
1415
|
if (s.kind === c.LPAREN) {
|
|
1411
|
-
const { left: i } =
|
|
1416
|
+
const { left: i } = ct(s);
|
|
1412
1417
|
if (i < e || // When '(' is encountered,
|
|
1413
1418
|
// consider it part of another expression if
|
|
1414
1419
|
// it's at the start of a new line
|
|
1415
1420
|
// and we're currently not having unmatched '(' or '['
|
|
1416
|
-
|
|
1421
|
+
at(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1417
1422
|
break;
|
|
1418
1423
|
try {
|
|
1419
1424
|
n = this.nodeFactory.create(H, {
|
|
@@ -1430,22 +1435,22 @@ class ln {
|
|
|
1430
1435
|
if (Ve(this.previous()))
|
|
1431
1436
|
break;
|
|
1432
1437
|
try {
|
|
1433
|
-
n = this.nodeFactory.create(
|
|
1438
|
+
n = this.nodeFactory.create(le, {
|
|
1434
1439
|
expression: n,
|
|
1435
1440
|
indexer: this.listExpression()
|
|
1436
1441
|
});
|
|
1437
1442
|
} catch (i) {
|
|
1438
|
-
throw i instanceof d ? (n = this.nodeFactory.create(
|
|
1443
|
+
throw i instanceof d ? (n = this.nodeFactory.create(le, {
|
|
1439
1444
|
expression: n,
|
|
1440
1445
|
indexer: i.partialNode
|
|
1441
1446
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
1442
1447
|
}
|
|
1443
|
-
} else if (
|
|
1444
|
-
const i = s, r =
|
|
1448
|
+
} else if (rt(s)) {
|
|
1449
|
+
const i = s, r = ct(i);
|
|
1445
1450
|
if (r.left !== null) {
|
|
1446
1451
|
if (r.left <= e)
|
|
1447
1452
|
break;
|
|
1448
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1453
|
+
this.advance(), n = this.nodeFactory.create(Re, {
|
|
1449
1454
|
expression: n,
|
|
1450
1455
|
op: i
|
|
1451
1456
|
});
|
|
@@ -1475,7 +1480,7 @@ class ln {
|
|
|
1475
1480
|
}
|
|
1476
1481
|
leftExpression_bp() {
|
|
1477
1482
|
let e;
|
|
1478
|
-
if (
|
|
1483
|
+
if (rt(this.peek())) {
|
|
1479
1484
|
const n = {};
|
|
1480
1485
|
n.op = this.peek();
|
|
1481
1486
|
const s = fn(n.op);
|
|
@@ -1553,16 +1558,16 @@ class ln {
|
|
|
1553
1558
|
c.STRING_LITERAL,
|
|
1554
1559
|
c.NUMERIC_LITERAL
|
|
1555
1560
|
))
|
|
1556
|
-
return this.nodeFactory.create(
|
|
1557
|
-
expression: this.nodeFactory.create(
|
|
1561
|
+
return this.nodeFactory.create(D, {
|
|
1562
|
+
expression: this.nodeFactory.create(Ee, { literal: this.previous() })
|
|
1558
1563
|
});
|
|
1559
1564
|
if (this.match(c.QUOTED_STRING, c.IDENTIFIER))
|
|
1560
|
-
return this.nodeFactory.create(
|
|
1565
|
+
return this.nodeFactory.create(D, {
|
|
1561
1566
|
expression: this.nodeFactory.create(X, { variable: this.previous() })
|
|
1562
1567
|
});
|
|
1563
1568
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1564
1569
|
this.peek(),
|
|
1565
|
-
this.nodeFactory.create(
|
|
1570
|
+
this.nodeFactory.create(D, {
|
|
1566
1571
|
expression: this.nodeFactory.create(X, {})
|
|
1567
1572
|
}),
|
|
1568
1573
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1657,11 +1662,11 @@ function fn(t) {
|
|
|
1657
1662
|
const pn = {
|
|
1658
1663
|
"(": { left: 14, right: null }
|
|
1659
1664
|
};
|
|
1660
|
-
function
|
|
1665
|
+
function ct(t) {
|
|
1661
1666
|
return pn[t.value] || { left: null, right: null };
|
|
1662
1667
|
}
|
|
1663
1668
|
var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
|
|
1664
|
-
function
|
|
1669
|
+
function ge(t) {
|
|
1665
1670
|
var n;
|
|
1666
1671
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1667
1672
|
switch (e) {
|
|
@@ -1672,21 +1677,21 @@ function Ee(t) {
|
|
|
1672
1677
|
case b.Project:
|
|
1673
1678
|
case b.Ref:
|
|
1674
1679
|
case b.TableGroup:
|
|
1675
|
-
return new
|
|
1680
|
+
return new O(e);
|
|
1676
1681
|
default:
|
|
1677
1682
|
return new A();
|
|
1678
1683
|
}
|
|
1679
1684
|
}
|
|
1680
|
-
function
|
|
1685
|
+
function ue(t) {
|
|
1681
1686
|
if (!He(t))
|
|
1682
|
-
return new
|
|
1683
|
-
const e =
|
|
1684
|
-
return e ? (e.push(t.rightExpression), new
|
|
1687
|
+
return new O([t]);
|
|
1688
|
+
const e = ue(t.leftExpression).unwrap_or(void 0);
|
|
1689
|
+
return e ? (e.push(t.rightExpression), new O(e)) : new A();
|
|
1685
1690
|
}
|
|
1686
1691
|
function W(t) {
|
|
1687
1692
|
if (t === void 0)
|
|
1688
1693
|
return new A();
|
|
1689
|
-
const e =
|
|
1694
|
+
const e = ue(t).unwrap_or(void 0);
|
|
1690
1695
|
if (!e)
|
|
1691
1696
|
return new A();
|
|
1692
1697
|
const n = [];
|
|
@@ -1696,19 +1701,19 @@ function W(t) {
|
|
|
1696
1701
|
return new A();
|
|
1697
1702
|
n.push(i);
|
|
1698
1703
|
}
|
|
1699
|
-
return new
|
|
1704
|
+
return new O(n);
|
|
1700
1705
|
}
|
|
1701
|
-
function
|
|
1706
|
+
function Ie(t) {
|
|
1702
1707
|
if (t === void 0)
|
|
1703
1708
|
return new A();
|
|
1704
|
-
const e =
|
|
1709
|
+
const e = ue(t).unwrap_or(void 0);
|
|
1705
1710
|
if (!e || e.length === 0)
|
|
1706
1711
|
return new A();
|
|
1707
1712
|
const n = [];
|
|
1708
1713
|
let s;
|
|
1709
1714
|
if (!M(I.last(e))) {
|
|
1710
1715
|
const i = e.pop();
|
|
1711
|
-
if (
|
|
1716
|
+
if (yt(i))
|
|
1712
1717
|
s = i.elementList.map(
|
|
1713
1718
|
(r) => V(r).unwrap()
|
|
1714
1719
|
);
|
|
@@ -1721,46 +1726,46 @@ function Le(t) {
|
|
|
1721
1726
|
return new A();
|
|
1722
1727
|
n.push(r);
|
|
1723
1728
|
}
|
|
1724
|
-
return new
|
|
1729
|
+
return new O({
|
|
1725
1730
|
variables: n,
|
|
1726
1731
|
tupleElements: s
|
|
1727
1732
|
});
|
|
1728
1733
|
}
|
|
1729
1734
|
function G(t) {
|
|
1730
|
-
return M(t) ? new
|
|
1735
|
+
return M(t) ? new O(t.expression.variable.value) : new A();
|
|
1731
1736
|
}
|
|
1732
1737
|
function Ge(t) {
|
|
1733
|
-
if (
|
|
1734
|
-
return t instanceof ee ? new
|
|
1735
|
-
if (t instanceof J && t.elementList.every(
|
|
1738
|
+
if (ut(t))
|
|
1739
|
+
return t instanceof ee ? new O({ functional: [t], nonFunctional: [] }) : new O({ functional: [], nonFunctional: [t] });
|
|
1740
|
+
if (t instanceof J && t.elementList.every(ut)) {
|
|
1736
1741
|
const e = t.elementList.filter(
|
|
1737
1742
|
(s) => s instanceof ee
|
|
1738
1743
|
), n = t.elementList.filter(M);
|
|
1739
|
-
return new
|
|
1744
|
+
return new O({ functional: e, nonFunctional: n });
|
|
1740
1745
|
}
|
|
1741
1746
|
return new A();
|
|
1742
1747
|
}
|
|
1743
1748
|
function V(t) {
|
|
1744
1749
|
var n;
|
|
1745
1750
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1746
|
-
return e === void 0 ? new A() : new
|
|
1751
|
+
return e === void 0 ? new A() : new O(e);
|
|
1747
1752
|
}
|
|
1748
1753
|
function Y(t) {
|
|
1749
|
-
return $(t) ? t.expression instanceof X ? new
|
|
1754
|
+
return $(t) ? t.expression instanceof X ? new O(t.expression.variable.value) : new O(t.expression.literal.value) : new A();
|
|
1750
1755
|
}
|
|
1751
1756
|
function dn(t) {
|
|
1752
1757
|
var e;
|
|
1753
|
-
return !(t instanceof q) || !
|
|
1758
|
+
return !(t instanceof q) || !wt((e = t.op) == null ? void 0 : e.value) ? !1 : Ie(t.leftExpression).and_then(() => Ie(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1754
1759
|
}
|
|
1755
1760
|
function En(t) {
|
|
1756
|
-
const e =
|
|
1761
|
+
const e = Ie(t.leftExpression), n = Ie(t.rightExpression);
|
|
1757
1762
|
if (!e.isOk() || !n.isOk())
|
|
1758
1763
|
return !1;
|
|
1759
1764
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1760
1765
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1761
1766
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return t instanceof
|
|
1767
|
+
function ut(t) {
|
|
1768
|
+
return t instanceof D && t.expression instanceof X || t instanceof ee;
|
|
1764
1769
|
}
|
|
1765
1770
|
function Nn(t, e) {
|
|
1766
1771
|
var i, r, a, l;
|
|
@@ -1784,7 +1789,7 @@ class mn {
|
|
|
1784
1789
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1785
1790
|
}
|
|
1786
1791
|
validateContext() {
|
|
1787
|
-
return this.declarationNode.parent instanceof C ||
|
|
1792
|
+
return this.declarationNode.parent instanceof C || ge(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new u(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1788
1793
|
}
|
|
1789
1794
|
validateName(e) {
|
|
1790
1795
|
return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1861,10 +1866,12 @@ class Tn {
|
|
|
1861
1866
|
validateFields(e) {
|
|
1862
1867
|
return e.length === 0 ? [new u(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1863
1868
|
const s = [];
|
|
1864
|
-
|
|
1869
|
+
n.callee && !M(n.callee) && s.push(new u(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1870
|
+
const i = [...n.args];
|
|
1871
|
+
return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new u(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1865
1872
|
});
|
|
1866
1873
|
}
|
|
1867
|
-
|
|
1874
|
+
validateFieldSettings(e) {
|
|
1868
1875
|
const n = z(e), s = n.getErrors(), i = n.getValue();
|
|
1869
1876
|
for (const r in i) {
|
|
1870
1877
|
const a = i[r];
|
|
@@ -1913,7 +1920,7 @@ class bn {
|
|
|
1913
1920
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1914
1921
|
}
|
|
1915
1922
|
validateContext() {
|
|
1916
|
-
return this.declarationNode.parent instanceof C ||
|
|
1923
|
+
return this.declarationNode.parent instanceof C || ge(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new u(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1917
1924
|
}
|
|
1918
1925
|
validateName(e) {
|
|
1919
1926
|
return e ? [new u(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
@@ -1937,7 +1944,7 @@ class bn {
|
|
|
1937
1944
|
if (!n.callee)
|
|
1938
1945
|
return [];
|
|
1939
1946
|
const s = [], i = [n.callee, ...n.args];
|
|
1940
|
-
return I.last(i) instanceof
|
|
1947
|
+
return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1941
1948
|
for (; r instanceof H; )
|
|
1942
1949
|
r.argumentList && !Ge(r.argumentList).isOk() && s.push(new u(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
|
|
1943
1950
|
Ge(r).isOk() || s.push(new u(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
@@ -1989,7 +1996,7 @@ class In {
|
|
|
1989
1996
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1990
1997
|
}
|
|
1991
1998
|
validateContext() {
|
|
1992
|
-
return this.declarationNode.parent instanceof C || ![b.Table, b.Project].includes(
|
|
1999
|
+
return this.declarationNode.parent instanceof C || ![b.Table, b.Project].includes(ge(this.declarationNode.parent).unwrap_or(void 0)) ? [new u(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project", this.declarationNode)] : [];
|
|
1993
2000
|
}
|
|
1994
2001
|
validateName(e) {
|
|
1995
2002
|
return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
@@ -2068,7 +2075,7 @@ class gn {
|
|
|
2068
2075
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2069
2076
|
}
|
|
2070
2077
|
validateContext() {
|
|
2071
|
-
return this.declarationNode.parent instanceof C
|
|
2078
|
+
return this.declarationNode.parent instanceof C ? [] : [new u(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2072
2079
|
}
|
|
2073
2080
|
validateName(e) {
|
|
2074
2081
|
return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
@@ -2092,7 +2099,9 @@ class gn {
|
|
|
2092
2099
|
return [new u(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2093
2100
|
const n = [];
|
|
2094
2101
|
return e.length > 1 && n.push(...e.slice(1).map((s) => new u(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2095
|
-
s.callee && !dn(s.callee) && n.push(new u(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !En(s.callee) && n.push(new u(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee))
|
|
2102
|
+
s.callee && !dn(s.callee) && n.push(new u(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !En(s.callee) && n.push(new u(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2103
|
+
const i = [...s.args];
|
|
2104
|
+
I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new u(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2096
2105
|
}), n;
|
|
2097
2106
|
}
|
|
2098
2107
|
validateFieldSettings(e) {
|
|
@@ -2125,7 +2134,7 @@ function _n(t) {
|
|
|
2125
2134
|
if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof K))
|
|
2126
2135
|
return !1;
|
|
2127
2136
|
let e;
|
|
2128
|
-
if (t instanceof K ? e =
|
|
2137
|
+
if (t instanceof K ? e = De(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2129
2138
|
switch (e.toLowerCase()) {
|
|
2130
2139
|
case "cascade":
|
|
2131
2140
|
case "no action":
|
|
@@ -2149,7 +2158,7 @@ class An {
|
|
|
2149
2158
|
return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2150
2159
|
}
|
|
2151
2160
|
validateName(e) {
|
|
2152
|
-
return e ? e instanceof
|
|
2161
|
+
return e ? e instanceof le ? [new u(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new u(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new u(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2153
2162
|
}
|
|
2154
2163
|
validateAlias(e) {
|
|
2155
2164
|
return e ? kn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
@@ -2177,7 +2186,7 @@ class An {
|
|
|
2177
2186
|
}
|
|
2178
2187
|
registerElement() {
|
|
2179
2188
|
const e = [];
|
|
2180
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2189
|
+
this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new _e() });
|
|
2181
2190
|
const { name: n, alias: s } = this.declarationNode, i = W(n);
|
|
2182
2191
|
if (i.isOk()) {
|
|
2183
2192
|
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = ke(a);
|
|
@@ -2225,12 +2234,12 @@ class An {
|
|
|
2225
2234
|
}
|
|
2226
2235
|
// This is needed to support legacy inline settings
|
|
2227
2236
|
validateFieldSetting(e) {
|
|
2228
|
-
if (!e.slice(0, -1).every(
|
|
2237
|
+
if (!e.slice(0, -1).every(de) || !e.slice(-1).every((p) => de(p) || p instanceof P))
|
|
2229
2238
|
return [...e.map((p) => new u(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2230
2239
|
if (e.length === 0)
|
|
2231
2240
|
return [];
|
|
2232
2241
|
let n;
|
|
2233
|
-
I.last(e) instanceof
|
|
2242
|
+
I.last(e) instanceof P && (n = e.pop());
|
|
2234
2243
|
const s = z(n), i = s.getErrors(), r = s.getValue();
|
|
2235
2244
|
for (const p of e) {
|
|
2236
2245
|
const h = V(p).unwrap_or("").toLowerCase();
|
|
@@ -2252,7 +2261,7 @@ class An {
|
|
|
2252
2261
|
break;
|
|
2253
2262
|
case "ref":
|
|
2254
2263
|
h.forEach((f) => {
|
|
2255
|
-
|
|
2264
|
+
Sn(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
|
|
2256
2265
|
});
|
|
2257
2266
|
break;
|
|
2258
2267
|
case "primary key":
|
|
@@ -2289,7 +2298,7 @@ class An {
|
|
|
2289
2298
|
break;
|
|
2290
2299
|
case "default":
|
|
2291
2300
|
h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
|
|
2292
|
-
|
|
2301
|
+
On(f.value) || i.push(new u(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
|
|
2293
2302
|
});
|
|
2294
2303
|
break;
|
|
2295
2304
|
default:
|
|
@@ -2312,15 +2321,15 @@ class An {
|
|
|
2312
2321
|
}
|
|
2313
2322
|
}
|
|
2314
2323
|
function vn(t) {
|
|
2315
|
-
if (!(t instanceof H || He(t) || t instanceof
|
|
2324
|
+
if (!(t instanceof H || He(t) || t instanceof D || t instanceof le))
|
|
2316
2325
|
return !1;
|
|
2317
2326
|
if (t instanceof H) {
|
|
2318
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2327
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) || $(n) || de(n)))
|
|
2319
2328
|
return !1;
|
|
2320
2329
|
t = t.callee;
|
|
2321
2330
|
}
|
|
2322
|
-
for (; t instanceof
|
|
2323
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value &&
|
|
2331
|
+
for (; t instanceof le; ) {
|
|
2332
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ce(n.name)))
|
|
2324
2333
|
return !1;
|
|
2325
2334
|
t = t.array;
|
|
2326
2335
|
}
|
|
@@ -2400,7 +2409,7 @@ class yn {
|
|
|
2400
2409
|
return [];
|
|
2401
2410
|
}
|
|
2402
2411
|
}
|
|
2403
|
-
const
|
|
2412
|
+
const vt = ["-", "+"];
|
|
2404
2413
|
function ie(t) {
|
|
2405
2414
|
switch (t.type.value.toLowerCase()) {
|
|
2406
2415
|
case b.Enum:
|
|
@@ -2428,7 +2437,7 @@ function kn(t) {
|
|
|
2428
2437
|
return Pe(t);
|
|
2429
2438
|
}
|
|
2430
2439
|
function Pe(t) {
|
|
2431
|
-
return t instanceof
|
|
2440
|
+
return t instanceof D && t.expression instanceof X;
|
|
2432
2441
|
}
|
|
2433
2442
|
function Ze(t, e, n) {
|
|
2434
2443
|
var i;
|
|
@@ -2442,19 +2451,19 @@ function Ze(t, e, n) {
|
|
|
2442
2451
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2443
2452
|
} else {
|
|
2444
2453
|
a = new _e();
|
|
2445
|
-
const p = n.create(
|
|
2454
|
+
const p = n.create(gt, { symbolTable: a });
|
|
2446
2455
|
s.set(l, p);
|
|
2447
2456
|
}
|
|
2448
2457
|
s = a;
|
|
2449
2458
|
}
|
|
2450
2459
|
return s;
|
|
2451
2460
|
}
|
|
2452
|
-
function
|
|
2461
|
+
function wt(t) {
|
|
2453
2462
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2454
2463
|
}
|
|
2455
2464
|
function xn(t) {
|
|
2456
2465
|
var n;
|
|
2457
|
-
if (!(t instanceof
|
|
2466
|
+
if (!(t instanceof D) || !(t.expression instanceof Ee) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== c.COLOR_LITERAL)
|
|
2458
2467
|
return !1;
|
|
2459
2468
|
const e = t.expression.literal.value;
|
|
2460
2469
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
@@ -2467,22 +2476,22 @@ function xn(t) {
|
|
|
2467
2476
|
function oe(t) {
|
|
2468
2477
|
return t === void 0;
|
|
2469
2478
|
}
|
|
2470
|
-
function
|
|
2479
|
+
function On(t) {
|
|
2471
2480
|
var e;
|
|
2472
|
-
return !!($(t) ||
|
|
2481
|
+
return !!($(t) || ce(t) || de(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && vt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression) || t instanceof ee);
|
|
2473
2482
|
}
|
|
2474
|
-
function
|
|
2483
|
+
function ce(t) {
|
|
2475
2484
|
var e;
|
|
2476
|
-
return t instanceof
|
|
2485
|
+
return t instanceof D && t.expression instanceof Ee && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
|
|
2477
2486
|
}
|
|
2478
|
-
function
|
|
2487
|
+
function Sn(t) {
|
|
2479
2488
|
var n;
|
|
2480
|
-
if (!(t instanceof Q) || !
|
|
2489
|
+
if (!(t instanceof Q) || !wt((n = t.op) == null ? void 0 : n.value))
|
|
2481
2490
|
return !1;
|
|
2482
2491
|
const e = W(t.expression).unwrap_or(void 0);
|
|
2483
2492
|
return e !== void 0 && e.length > 0;
|
|
2484
2493
|
}
|
|
2485
|
-
function
|
|
2494
|
+
function yt(t) {
|
|
2486
2495
|
return t instanceof J && t.elementList.every(M);
|
|
2487
2496
|
}
|
|
2488
2497
|
function z(t) {
|
|
@@ -2493,18 +2502,18 @@ function z(t) {
|
|
|
2493
2502
|
for (const i of t.elementList) {
|
|
2494
2503
|
if (!i.name)
|
|
2495
2504
|
continue;
|
|
2496
|
-
if (i.name instanceof
|
|
2505
|
+
if (i.name instanceof D) {
|
|
2497
2506
|
n.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2498
2507
|
continue;
|
|
2499
2508
|
}
|
|
2500
|
-
const r = (s =
|
|
2509
|
+
const r = (s = De(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2501
2510
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2502
2511
|
}
|
|
2503
2512
|
return new F(e, n);
|
|
2504
2513
|
}
|
|
2505
|
-
class
|
|
2514
|
+
class ht {
|
|
2506
2515
|
constructor(e, n) {
|
|
2507
|
-
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(
|
|
2516
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(gt, {
|
|
2508
2517
|
symbolTable: new _e()
|
|
2509
2518
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2510
2519
|
}
|
|
@@ -2520,7 +2529,7 @@ class ft {
|
|
|
2520
2529
|
);
|
|
2521
2530
|
e.push(...r.validate());
|
|
2522
2531
|
});
|
|
2523
|
-
const n = this.ast.body.filter((s) =>
|
|
2532
|
+
const n = this.ast.body.filter((s) => ge(s).unwrap_or(void 0) === b.Project);
|
|
2524
2533
|
return n.length > 1 && n.forEach((s) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
|
|
2525
2534
|
}
|
|
2526
2535
|
}
|
|
@@ -2534,9 +2543,9 @@ class re {
|
|
|
2534
2543
|
bindSettingList(e, n) {
|
|
2535
2544
|
if (e)
|
|
2536
2545
|
for (const s of e.elementList) {
|
|
2537
|
-
if (s.name instanceof
|
|
2546
|
+
if (s.name instanceof D)
|
|
2538
2547
|
continue;
|
|
2539
|
-
const i =
|
|
2548
|
+
const i = De(s.name).unwrap_or(void 0);
|
|
2540
2549
|
if (!i)
|
|
2541
2550
|
continue;
|
|
2542
2551
|
const r = n[i.toLowerCase()];
|
|
@@ -2553,7 +2562,7 @@ class re {
|
|
|
2553
2562
|
if (s instanceof _) {
|
|
2554
2563
|
if (!s.type)
|
|
2555
2564
|
continue;
|
|
2556
|
-
const i =
|
|
2565
|
+
const i = kt(s);
|
|
2557
2566
|
new i(s, this.errors).bind();
|
|
2558
2567
|
} else
|
|
2559
2568
|
this.bindSubfield(s);
|
|
@@ -2562,7 +2571,7 @@ class re {
|
|
|
2562
2571
|
}
|
|
2563
2572
|
bindSubfield(e) {
|
|
2564
2573
|
const n = [e.callee, ...e.args], s = I.last(n);
|
|
2565
|
-
s instanceof
|
|
2574
|
+
s instanceof P && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
|
|
2566
2575
|
const { argBinderRules: i } = this.subfield.arg;
|
|
2567
2576
|
for (let r = 0; r < Math.min(n.length, i.length); r += 1)
|
|
2568
2577
|
i[r].shouldBind && this.scanAndBind(n[r], i[r]);
|
|
@@ -2571,12 +2580,12 @@ class re {
|
|
|
2571
2580
|
scanAndBind(e, n) {
|
|
2572
2581
|
var s, i;
|
|
2573
2582
|
if (e)
|
|
2574
|
-
if (e instanceof
|
|
2583
|
+
if (e instanceof D) {
|
|
2575
2584
|
if (e.expression instanceof X && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2576
2585
|
return;
|
|
2577
2586
|
this.bindFragments([e], n);
|
|
2578
2587
|
} else
|
|
2579
|
-
e instanceof q ? He(e) ? this.bindFragments(
|
|
2588
|
+
e instanceof q ? He(e) ? this.bindFragments(ue(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof Re ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2580
2589
|
}
|
|
2581
2590
|
// Bind the fragments of a member access expression
|
|
2582
2591
|
// which can be a simple expression like v1.User,
|
|
@@ -2584,7 +2593,7 @@ class re {
|
|
|
2584
2593
|
bindFragments(e, n) {
|
|
2585
2594
|
if (e.length === 0)
|
|
2586
2595
|
return;
|
|
2587
|
-
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 &&
|
|
2596
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 && yt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
|
|
2588
2597
|
0,
|
|
2589
2598
|
r === -1 ? void 0 : r
|
|
2590
2599
|
);
|
|
@@ -2653,7 +2662,7 @@ class re {
|
|
|
2653
2662
|
s || this.errors.push(new u(o.BINDING_ERROR, n, e));
|
|
2654
2663
|
}
|
|
2655
2664
|
}
|
|
2656
|
-
class
|
|
2665
|
+
class Rn extends re {
|
|
2657
2666
|
constructor() {
|
|
2658
2667
|
super(...arguments), this.subfield = {
|
|
2659
2668
|
arg: {
|
|
@@ -2663,7 +2672,7 @@ class Dn extends re {
|
|
|
2663
2672
|
}, this.settingList = {};
|
|
2664
2673
|
}
|
|
2665
2674
|
}
|
|
2666
|
-
class
|
|
2675
|
+
class Dn extends re {
|
|
2667
2676
|
constructor() {
|
|
2668
2677
|
super(...arguments), this.subfield = {
|
|
2669
2678
|
arg: {
|
|
@@ -2790,10 +2799,10 @@ class Vn extends re {
|
|
|
2790
2799
|
}, this.settingList = {};
|
|
2791
2800
|
}
|
|
2792
2801
|
}
|
|
2793
|
-
function
|
|
2802
|
+
function kt(t) {
|
|
2794
2803
|
switch (t.type.value.toLowerCase()) {
|
|
2795
2804
|
case b.Enum:
|
|
2796
|
-
return
|
|
2805
|
+
return Dn;
|
|
2797
2806
|
case b.Table:
|
|
2798
2807
|
return Bn;
|
|
2799
2808
|
case b.TableGroup:
|
|
@@ -2807,7 +2816,7 @@ function xt(t) {
|
|
|
2807
2816
|
case b.Indexes:
|
|
2808
2817
|
return Pn;
|
|
2809
2818
|
default:
|
|
2810
|
-
return
|
|
2819
|
+
return Rn;
|
|
2811
2820
|
}
|
|
2812
2821
|
}
|
|
2813
2822
|
class Gn {
|
|
@@ -2817,7 +2826,7 @@ class Gn {
|
|
|
2817
2826
|
resolve() {
|
|
2818
2827
|
for (const e of this.ast.body)
|
|
2819
2828
|
if (e.type) {
|
|
2820
|
-
const n =
|
|
2829
|
+
const n = kt(e);
|
|
2821
2830
|
new n(e, this.errors).bind();
|
|
2822
2831
|
}
|
|
2823
2832
|
return new F(this.ast, this.errors);
|
|
@@ -2837,15 +2846,15 @@ class Xn {
|
|
|
2837
2846
|
}
|
|
2838
2847
|
// Analyzing: Invoking both the validator and binder
|
|
2839
2848
|
analyze() {
|
|
2840
|
-
return new
|
|
2849
|
+
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new Gn(n).resolve());
|
|
2841
2850
|
}
|
|
2842
2851
|
// For invoking the validator only
|
|
2843
2852
|
validate() {
|
|
2844
|
-
return new
|
|
2853
|
+
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new F(n, []));
|
|
2845
2854
|
}
|
|
2846
2855
|
}
|
|
2847
|
-
function
|
|
2848
|
-
const { variables: n, tupleElements: s } =
|
|
2856
|
+
function ft(t, e) {
|
|
2857
|
+
const { variables: n, tupleElements: s } = Ie(t).unwrap();
|
|
2849
2858
|
return s ? n.length === 0 ? {
|
|
2850
2859
|
schemaName: e.schemaName,
|
|
2851
2860
|
tableName: e.name,
|
|
@@ -2864,7 +2873,7 @@ function pt(t, e) {
|
|
|
2864
2873
|
schemaName: n.pop() || null
|
|
2865
2874
|
};
|
|
2866
2875
|
}
|
|
2867
|
-
function
|
|
2876
|
+
function xt(t) {
|
|
2868
2877
|
switch (t) {
|
|
2869
2878
|
case "<":
|
|
2870
2879
|
return ["1", "*"];
|
|
@@ -2889,7 +2898,7 @@ function x(t) {
|
|
|
2889
2898
|
}
|
|
2890
2899
|
function Ce(t) {
|
|
2891
2900
|
var n;
|
|
2892
|
-
const e = (n =
|
|
2901
|
+
const e = (n = ue(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2893
2902
|
return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2894
2903
|
}
|
|
2895
2904
|
function Ae(t) {
|
|
@@ -2905,12 +2914,12 @@ function $n(t) {
|
|
|
2905
2914
|
function Ot(t, e) {
|
|
2906
2915
|
if (Array.isArray(t)) {
|
|
2907
2916
|
const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
|
|
2908
|
-
return i < r ? `${i}-${r}` : `${
|
|
2917
|
+
return i < r ? `${i}-${r}` : `${r}-${i}`;
|
|
2909
2918
|
}
|
|
2910
2919
|
const n = t.id, s = e.id;
|
|
2911
2920
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
2912
2921
|
}
|
|
2913
|
-
function
|
|
2922
|
+
function St(t, e) {
|
|
2914
2923
|
if (Array.isArray(t)) {
|
|
2915
2924
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2916
2925
|
return I.zip(i, r).every(([a, l]) => a === l);
|
|
@@ -2918,50 +2927,6 @@ function Dt(t, e) {
|
|
|
2918
2927
|
const n = t.id, s = e.id;
|
|
2919
2928
|
return n === s;
|
|
2920
2929
|
}
|
|
2921
|
-
class Ke {
|
|
2922
|
-
constructor(e, n) {
|
|
2923
|
-
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
2924
|
-
}
|
|
2925
|
-
interpret() {
|
|
2926
|
-
return this.ref.token = x(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
2927
|
-
}
|
|
2928
|
-
interpretName(e) {
|
|
2929
|
-
const n = [], s = W(this.declarationNode.name).unwrap_or([]);
|
|
2930
|
-
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
2931
|
-
}
|
|
2932
|
-
interpretBody(e) {
|
|
2933
|
-
return e instanceof k ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
2934
|
-
}
|
|
2935
|
-
interpretField(e) {
|
|
2936
|
-
var h, T, f, N;
|
|
2937
|
-
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
|
|
2938
|
-
if (Dt(r, a))
|
|
2939
|
-
return [new u(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
2940
|
-
const l = Ot(r, a);
|
|
2941
|
-
if (this.env.refIds[l])
|
|
2942
|
-
return [
|
|
2943
|
-
new u(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
2944
|
-
new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
|
|
2945
|
-
];
|
|
2946
|
-
if (e.args[0]) {
|
|
2947
|
-
const g = z(e.args[0]).getValue();
|
|
2948
|
-
this.ref.onDelete = G((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = G((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
2949
|
-
}
|
|
2950
|
-
const p = St(n);
|
|
2951
|
-
return this.ref.endpoints = [
|
|
2952
|
-
{
|
|
2953
|
-
...pt(s, this.container),
|
|
2954
|
-
relation: p[0],
|
|
2955
|
-
token: x(s)
|
|
2956
|
-
},
|
|
2957
|
-
{
|
|
2958
|
-
...pt(i, this.container),
|
|
2959
|
-
relation: p[1],
|
|
2960
|
-
token: x(i)
|
|
2961
|
-
}
|
|
2962
|
-
], this.env.refIds[l] = this.declarationNode, [];
|
|
2963
|
-
}
|
|
2964
|
-
}
|
|
2965
2930
|
class Rt {
|
|
2966
2931
|
constructor(e, n) {
|
|
2967
2932
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
@@ -3027,8 +2992,6 @@ class Rt {
|
|
|
3027
2992
|
}, [];
|
|
3028
2993
|
case "indexes":
|
|
3029
2994
|
return this.interpretIndexes(n);
|
|
3030
|
-
case "ref":
|
|
3031
|
-
return new Ke(n, this.env).interpret();
|
|
3032
2995
|
}
|
|
3033
2996
|
return [];
|
|
3034
2997
|
});
|
|
@@ -3043,24 +3006,24 @@ class Rt {
|
|
|
3043
3006
|
const i = Wn(e.args[0]);
|
|
3044
3007
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
|
|
3045
3008
|
const r = e.args.slice(1);
|
|
3046
|
-
if (I.last(r) instanceof
|
|
3009
|
+
if (I.last(r) instanceof P) {
|
|
3047
3010
|
const v = z(r.pop()).getValue();
|
|
3048
3011
|
s.pk = !!((a = v.pk) != null && a.length) || !!((l = v["primary key"]) != null && l.length), s.increment = !!((p = v.increment) != null && p.length), s.unique = !!((h = v.unique) != null && h.length), s.not_null = !!((T = v["not null"]) != null && T.length) && !0, s.dbdefault = jn((N = (f = v.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3049
|
-
const
|
|
3050
|
-
s.note =
|
|
3051
|
-
value: Y(
|
|
3052
|
-
token: x(
|
|
3012
|
+
const Ne = (g = v.note) == null ? void 0 : g.at(0);
|
|
3013
|
+
s.note = Ne && {
|
|
3014
|
+
value: Y(Ne.value).unwrap(),
|
|
3015
|
+
token: x(Ne)
|
|
3053
3016
|
};
|
|
3054
|
-
const
|
|
3055
|
-
s.inline_refs =
|
|
3056
|
-
const [
|
|
3057
|
-
if (
|
|
3017
|
+
const me = v.ref || [];
|
|
3018
|
+
s.inline_refs = me.flatMap((j) => {
|
|
3019
|
+
const [tt] = Ce(j.value.expression);
|
|
3020
|
+
if (St(tt, e.symbol))
|
|
3058
3021
|
return n.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", j)), [];
|
|
3059
3022
|
const ve = j.value.op, Z = W(j.value.expression).unwrap();
|
|
3060
|
-
let
|
|
3023
|
+
let he;
|
|
3061
3024
|
if (Z.length === 1) {
|
|
3062
3025
|
const [ae] = Z;
|
|
3063
|
-
|
|
3026
|
+
he = {
|
|
3064
3027
|
schemaName: this.table.schemaName,
|
|
3065
3028
|
tableName: this.table.name,
|
|
3066
3029
|
fieldNames: [ae],
|
|
@@ -3068,36 +3031,36 @@ class Rt {
|
|
|
3068
3031
|
token: x(j)
|
|
3069
3032
|
};
|
|
3070
3033
|
} else if (Z.length === 2) {
|
|
3071
|
-
const [ae,
|
|
3072
|
-
|
|
3034
|
+
const [ae, Te] = Z;
|
|
3035
|
+
he = {
|
|
3073
3036
|
schemaName: null,
|
|
3074
3037
|
tableName: ae,
|
|
3075
|
-
fieldNames: [
|
|
3038
|
+
fieldNames: [Te],
|
|
3076
3039
|
relation: ve.value,
|
|
3077
3040
|
token: x(j)
|
|
3078
3041
|
};
|
|
3079
3042
|
} else if (Z.length === 3) {
|
|
3080
|
-
const [ae,
|
|
3081
|
-
|
|
3043
|
+
const [ae, Te, st] = Z;
|
|
3044
|
+
he = {
|
|
3082
3045
|
schemaName: ae,
|
|
3083
|
-
tableName:
|
|
3084
|
-
fieldNames: [
|
|
3046
|
+
tableName: Te,
|
|
3047
|
+
fieldNames: [st],
|
|
3085
3048
|
relation: ve.value,
|
|
3086
3049
|
token: x(j)
|
|
3087
3050
|
};
|
|
3088
3051
|
} else {
|
|
3089
3052
|
n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", j));
|
|
3090
|
-
const ae = Z.pop(),
|
|
3091
|
-
|
|
3053
|
+
const ae = Z.pop(), Te = Z.pop();
|
|
3054
|
+
he = {
|
|
3092
3055
|
schemaName: Z.join("."),
|
|
3093
|
-
tableName:
|
|
3056
|
+
tableName: Te,
|
|
3094
3057
|
fieldNames: [ae],
|
|
3095
3058
|
relation: ve.value,
|
|
3096
3059
|
token: x(j)
|
|
3097
3060
|
};
|
|
3098
3061
|
}
|
|
3099
|
-
const
|
|
3100
|
-
return n.push(...
|
|
3062
|
+
const nt = this.registerInlineRefToEnv(e, tt, he, j);
|
|
3063
|
+
return n.push(...nt), nt.length === 0 ? he : [];
|
|
3101
3064
|
});
|
|
3102
3065
|
}
|
|
3103
3066
|
return s.pk || (s.pk = r.some((v) => G(v).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((v) => G(v).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
@@ -3108,7 +3071,7 @@ class Rt {
|
|
|
3108
3071
|
const s = { columns: [] }, i = n;
|
|
3109
3072
|
s.token = x(e);
|
|
3110
3073
|
const r = [i.callee, ...i.args];
|
|
3111
|
-
if (I.last(r) instanceof
|
|
3074
|
+
if (I.last(r) instanceof P) {
|
|
3112
3075
|
const g = z(r.pop()).getValue();
|
|
3113
3076
|
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = Y((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3114
3077
|
const v = (T = g.note) == null ? void 0 : T.at(0);
|
|
@@ -3125,14 +3088,14 @@ class Rt {
|
|
|
3125
3088
|
v.push(g.argumentList), g = g.callee;
|
|
3126
3089
|
return v.push(g), v;
|
|
3127
3090
|
}).forEach((g) => {
|
|
3128
|
-
const { functional: v, nonFunctional:
|
|
3091
|
+
const { functional: v, nonFunctional: Ne } = Ge(g).unwrap();
|
|
3129
3092
|
s.columns.push(
|
|
3130
|
-
...v.map((
|
|
3131
|
-
value:
|
|
3093
|
+
...v.map((me) => ({
|
|
3094
|
+
value: me.value.value,
|
|
3132
3095
|
type: "expression"
|
|
3133
3096
|
})),
|
|
3134
|
-
...
|
|
3135
|
-
value: V(
|
|
3097
|
+
...Ne.map((me) => ({
|
|
3098
|
+
value: V(me).unwrap(),
|
|
3136
3099
|
type: "column"
|
|
3137
3100
|
}))
|
|
3138
3101
|
);
|
|
@@ -3146,7 +3109,7 @@ class Rt {
|
|
|
3146
3109
|
new u(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3147
3110
|
new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3148
3111
|
];
|
|
3149
|
-
const a =
|
|
3112
|
+
const a = xt(s.relation);
|
|
3150
3113
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
3151
3114
|
name: null,
|
|
3152
3115
|
schemaName: null,
|
|
@@ -3169,9 +3132,9 @@ class Rt {
|
|
|
3169
3132
|
}
|
|
3170
3133
|
function Wn(t) {
|
|
3171
3134
|
let e = null;
|
|
3172
|
-
t instanceof H && (e = t.argumentList.elementList.map((r) =>
|
|
3135
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value : $(r) ? Y(r).unwrap() : G(r).unwrap()).join(","), t = t.callee);
|
|
3173
3136
|
let n = "";
|
|
3174
|
-
for (; t instanceof
|
|
3137
|
+
for (; t instanceof le; )
|
|
3175
3138
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3176
3139
|
const { name: s, schemaName: i } = Ae(t);
|
|
3177
3140
|
return i.length > 1 ? new F(
|
|
@@ -3195,17 +3158,17 @@ function jn(t) {
|
|
|
3195
3158
|
value: Y(t).unwrap(),
|
|
3196
3159
|
type: "string"
|
|
3197
3160
|
};
|
|
3198
|
-
if (
|
|
3161
|
+
if (ce(t))
|
|
3199
3162
|
return {
|
|
3200
3163
|
type: "number",
|
|
3201
3164
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3202
3165
|
};
|
|
3203
|
-
if (
|
|
3166
|
+
if (de(t))
|
|
3204
3167
|
return {
|
|
3205
3168
|
value: t.expression.variable.value.toLowerCase(),
|
|
3206
3169
|
type: "boolean"
|
|
3207
3170
|
};
|
|
3208
|
-
if (t instanceof Q &&
|
|
3171
|
+
if (t instanceof Q && vt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression)) {
|
|
3209
3172
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3210
3173
|
return {
|
|
3211
3174
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
@@ -3220,21 +3183,81 @@ function jn(t) {
|
|
|
3220
3183
|
throw new Error("Unreachable");
|
|
3221
3184
|
}
|
|
3222
3185
|
}
|
|
3186
|
+
class Dt {
|
|
3187
|
+
constructor(e, n) {
|
|
3188
|
+
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3189
|
+
}
|
|
3190
|
+
interpret() {
|
|
3191
|
+
return this.ref.token = x(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3192
|
+
}
|
|
3193
|
+
interpretName(e) {
|
|
3194
|
+
const n = [], s = W(this.declarationNode.name).unwrap_or([]);
|
|
3195
|
+
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3196
|
+
}
|
|
3197
|
+
interpretBody(e) {
|
|
3198
|
+
return e instanceof k ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3199
|
+
}
|
|
3200
|
+
interpretField(e) {
|
|
3201
|
+
var h, T, f, N;
|
|
3202
|
+
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
|
|
3203
|
+
if (St(r, a))
|
|
3204
|
+
return [new u(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3205
|
+
const l = Ot(r, a);
|
|
3206
|
+
if (this.env.refIds[l])
|
|
3207
|
+
return [
|
|
3208
|
+
new u(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3209
|
+
new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
|
|
3210
|
+
];
|
|
3211
|
+
if (e.args[0]) {
|
|
3212
|
+
const g = z(e.args[0]).getValue();
|
|
3213
|
+
this.ref.onDelete = G((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = G((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3214
|
+
}
|
|
3215
|
+
const p = xt(n);
|
|
3216
|
+
return this.ref.endpoints = [
|
|
3217
|
+
{
|
|
3218
|
+
...ft(s, this.container),
|
|
3219
|
+
relation: p[0],
|
|
3220
|
+
token: x(s)
|
|
3221
|
+
},
|
|
3222
|
+
{
|
|
3223
|
+
...ft(i, this.container),
|
|
3224
|
+
relation: p[1],
|
|
3225
|
+
token: x(i)
|
|
3226
|
+
}
|
|
3227
|
+
], this.env.refIds[l] = this.declarationNode, [];
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3223
3230
|
class Pt {
|
|
3224
3231
|
constructor(e, n) {
|
|
3225
3232
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3226
3233
|
}
|
|
3227
3234
|
interpret() {
|
|
3228
3235
|
const e = [];
|
|
3229
|
-
this.tableGroup.token = x(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup)
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
+
return this.tableGroup.token = x(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
|
|
3237
|
+
...this.interpretName(this.declarationNode.name),
|
|
3238
|
+
...this.interpretBody(this.declarationNode.body)
|
|
3239
|
+
), e;
|
|
3240
|
+
}
|
|
3241
|
+
interpretName(e) {
|
|
3242
|
+
const n = [], { name: s, schemaName: i } = Ae(e);
|
|
3243
|
+
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3244
|
+
}
|
|
3245
|
+
interpretBody(e) {
|
|
3246
|
+
const n = [];
|
|
3247
|
+
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3248
|
+
const i = W(s.callee).unwrap();
|
|
3249
|
+
i.length > 2 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3250
|
+
const r = ue(s.callee).unwrap().pop().referee.id;
|
|
3251
|
+
if (this.env.groupOfTable[r]) {
|
|
3252
|
+
const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), h = l ? `${l}.${p}` : p;
|
|
3253
|
+
n.push(new u(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
|
|
3254
|
+
} else
|
|
3255
|
+
this.env.groupOfTable[r] = this.declarationNode;
|
|
3256
|
+
return {
|
|
3257
|
+
name: i.pop(),
|
|
3258
|
+
schemaName: i.join(".")
|
|
3236
3259
|
};
|
|
3237
|
-
}),
|
|
3260
|
+
}), n;
|
|
3238
3261
|
}
|
|
3239
3262
|
}
|
|
3240
3263
|
class Ut {
|
|
@@ -3284,7 +3307,7 @@ class Yn {
|
|
|
3284
3307
|
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3285
3308
|
}
|
|
3286
3309
|
case "ref": {
|
|
3287
|
-
const r = new
|
|
3310
|
+
const r = new Dt(s, this.env).interpret();
|
|
3288
3311
|
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3289
3312
|
}
|
|
3290
3313
|
case "tablegroup": {
|
|
@@ -3315,17 +3338,18 @@ class zn {
|
|
|
3315
3338
|
ref: /* @__PURE__ */ new Map(),
|
|
3316
3339
|
enums: /* @__PURE__ */ new Map(),
|
|
3317
3340
|
tableGroups: /* @__PURE__ */ new Map(),
|
|
3341
|
+
groupOfTable: {},
|
|
3318
3342
|
aliases: [],
|
|
3319
3343
|
project: /* @__PURE__ */ new Map()
|
|
3320
3344
|
};
|
|
3321
3345
|
}
|
|
3322
3346
|
interpret() {
|
|
3323
3347
|
const e = this.ast.body.flatMap((n) => {
|
|
3324
|
-
switch (
|
|
3348
|
+
switch (ge(n).unwrap_or(void 0)) {
|
|
3325
3349
|
case b.Table:
|
|
3326
3350
|
return new Rt(n, this.env).interpret();
|
|
3327
3351
|
case b.Ref:
|
|
3328
|
-
return new
|
|
3352
|
+
return new Dt(n, this.env).interpret();
|
|
3329
3353
|
case b.TableGroup:
|
|
3330
3354
|
return new Pt(n, this.env).interpret();
|
|
3331
3355
|
case b.Enum:
|
|
@@ -3351,7 +3375,7 @@ function Qn(t) {
|
|
|
3351
3375
|
};
|
|
3352
3376
|
}
|
|
3353
3377
|
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
|
|
3354
|
-
function
|
|
3378
|
+
function Le(t) {
|
|
3355
3379
|
switch (t) {
|
|
3356
3380
|
case m.Schema:
|
|
3357
3381
|
return L.Module;
|
|
@@ -3371,7 +3395,7 @@ function ge(t) {
|
|
|
3371
3395
|
return L.Text;
|
|
3372
3396
|
}
|
|
3373
3397
|
}
|
|
3374
|
-
function
|
|
3398
|
+
function Oe(t, e) {
|
|
3375
3399
|
if (!t || Ve(t))
|
|
3376
3400
|
return !1;
|
|
3377
3401
|
for (const n of t.trailingTrivia) {
|
|
@@ -3382,12 +3406,12 @@ function Se(t, e) {
|
|
|
3382
3406
|
}
|
|
3383
3407
|
return !0;
|
|
3384
3408
|
}
|
|
3385
|
-
function
|
|
3409
|
+
function S() {
|
|
3386
3410
|
return {
|
|
3387
3411
|
suggestions: []
|
|
3388
3412
|
};
|
|
3389
3413
|
}
|
|
3390
|
-
function
|
|
3414
|
+
function Se(t) {
|
|
3391
3415
|
return {
|
|
3392
3416
|
...t,
|
|
3393
3417
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3405,7 +3429,7 @@ function Ue(t) {
|
|
|
3405
3429
|
}))
|
|
3406
3430
|
};
|
|
3407
3431
|
}
|
|
3408
|
-
function
|
|
3432
|
+
function Ke(t, e) {
|
|
3409
3433
|
return t.getOffsetAt(e);
|
|
3410
3434
|
}
|
|
3411
3435
|
class Mt {
|
|
@@ -3414,20 +3438,20 @@ class Mt {
|
|
|
3414
3438
|
}
|
|
3415
3439
|
provideCompletionItems(e, n) {
|
|
3416
3440
|
var T, f;
|
|
3417
|
-
const s =
|
|
3441
|
+
const s = Ke(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];
|
|
3418
3442
|
if ([
|
|
3419
3443
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3420
3444
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3421
3445
|
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3422
|
-
].find((N) => $t(N) &&
|
|
3423
|
-
return
|
|
3446
|
+
].find((N) => $t(N) && be(s, N)))
|
|
3447
|
+
return S();
|
|
3424
3448
|
if (a === void 0)
|
|
3425
|
-
return
|
|
3426
|
-
if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) &&
|
|
3427
|
-
return
|
|
3449
|
+
return mt();
|
|
3450
|
+
if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && be(s, r))
|
|
3451
|
+
return S();
|
|
3428
3452
|
const p = this.compiler.container.element(s);
|
|
3429
|
-
if (this.compiler.container.scopeKind(s) ===
|
|
3430
|
-
return
|
|
3453
|
+
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
|
|
3454
|
+
return mt();
|
|
3431
3455
|
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3432
3456
|
for (const N of h)
|
|
3433
3457
|
if (N instanceof Q)
|
|
@@ -3436,7 +3460,7 @@ class Mt {
|
|
|
3436
3460
|
case "<":
|
|
3437
3461
|
case "<>":
|
|
3438
3462
|
case "-":
|
|
3439
|
-
return
|
|
3463
|
+
return pt(
|
|
3440
3464
|
this.compiler,
|
|
3441
3465
|
s,
|
|
3442
3466
|
N
|
|
@@ -3448,7 +3472,7 @@ class Mt {
|
|
|
3448
3472
|
case "<":
|
|
3449
3473
|
case "<>":
|
|
3450
3474
|
case "-":
|
|
3451
|
-
return
|
|
3475
|
+
return pt(
|
|
3452
3476
|
this.compiler,
|
|
3453
3477
|
s,
|
|
3454
3478
|
N
|
|
@@ -3462,35 +3486,35 @@ class Mt {
|
|
|
3462
3486
|
}
|
|
3463
3487
|
else {
|
|
3464
3488
|
if (N instanceof ne)
|
|
3465
|
-
return
|
|
3466
|
-
if (N instanceof
|
|
3467
|
-
return
|
|
3489
|
+
return dt(this.compiler, s, N);
|
|
3490
|
+
if (N instanceof P)
|
|
3491
|
+
return dt(this.compiler, s, N);
|
|
3468
3492
|
if (N instanceof J)
|
|
3469
3493
|
return qn(this.compiler, s);
|
|
3470
3494
|
if (N instanceof k)
|
|
3471
|
-
return
|
|
3472
|
-
if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body &&
|
|
3473
|
-
return
|
|
3495
|
+
return Nt(this.compiler, s, N);
|
|
3496
|
+
if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && be(s, N.body)))
|
|
3497
|
+
return Nt(this.compiler, s, void 0);
|
|
3474
3498
|
}
|
|
3475
|
-
return
|
|
3499
|
+
return S();
|
|
3476
3500
|
}
|
|
3477
3501
|
}
|
|
3478
|
-
function
|
|
3502
|
+
function pt(t, e, n) {
|
|
3479
3503
|
const s = t.container.scopeKind(e);
|
|
3480
|
-
if ([
|
|
3504
|
+
if ([R.REF, R.TABLE].includes(s)) {
|
|
3481
3505
|
const i = Me(t, e, t.container.element(e), [
|
|
3482
3506
|
m.Table,
|
|
3483
3507
|
m.Schema,
|
|
3484
3508
|
m.Column
|
|
3485
3509
|
]);
|
|
3486
|
-
return
|
|
3510
|
+
return Oe(n.op, e) ? Se(i) : i;
|
|
3487
3511
|
}
|
|
3488
|
-
return
|
|
3512
|
+
return S();
|
|
3489
3513
|
}
|
|
3490
3514
|
function Me(t, e, n, s) {
|
|
3491
3515
|
var a;
|
|
3492
3516
|
if (n === void 0)
|
|
3493
|
-
return
|
|
3517
|
+
return S();
|
|
3494
3518
|
let i = n;
|
|
3495
3519
|
const r = { suggestions: [] };
|
|
3496
3520
|
for (; i; ) {
|
|
@@ -3501,8 +3525,8 @@ function Me(t, e, n, s) {
|
|
|
3501
3525
|
label: p,
|
|
3502
3526
|
insertText: p,
|
|
3503
3527
|
insertTextRules: w.KeepWhitespace,
|
|
3504
|
-
kind:
|
|
3505
|
-
sortText:
|
|
3528
|
+
kind: Le(h),
|
|
3529
|
+
sortText: Le(h).toString().padStart(2, "0"),
|
|
3506
3530
|
range: void 0
|
|
3507
3531
|
}))
|
|
3508
3532
|
);
|
|
@@ -3514,9 +3538,9 @@ function Me(t, e, n, s) {
|
|
|
3514
3538
|
function qn(t, e) {
|
|
3515
3539
|
var s;
|
|
3516
3540
|
switch (t.container.scopeKind(e)) {
|
|
3517
|
-
case
|
|
3541
|
+
case R.INDEXES:
|
|
3518
3542
|
return Vt(t, e);
|
|
3519
|
-
case
|
|
3543
|
+
case R.REF:
|
|
3520
3544
|
{
|
|
3521
3545
|
const i = [...t.container.stack(e)];
|
|
3522
3546
|
for (; i.length > 0; ) {
|
|
@@ -3531,33 +3555,33 @@ function qn(t, e) {
|
|
|
3531
3555
|
}
|
|
3532
3556
|
return Bt(t, e);
|
|
3533
3557
|
}
|
|
3534
|
-
return
|
|
3558
|
+
return S();
|
|
3535
3559
|
}
|
|
3536
|
-
function
|
|
3560
|
+
function dt(t, e, n) {
|
|
3537
3561
|
const { token: s } = t.container.token(e);
|
|
3538
3562
|
if ([c.COMMA, c.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3539
|
-
const i =
|
|
3540
|
-
return (s == null ? void 0 : s.kind) === c.COMMA &&
|
|
3563
|
+
const i = Et(t, e);
|
|
3564
|
+
return (s == null ? void 0 : s.kind) === c.COMMA && Oe(s, e) ? Se(i) : i;
|
|
3541
3565
|
}
|
|
3542
3566
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3543
|
-
return
|
|
3567
|
+
return Et(t, e);
|
|
3544
3568
|
if (n.name instanceof K) {
|
|
3545
3569
|
const i = Hn(
|
|
3546
3570
|
t,
|
|
3547
3571
|
e,
|
|
3548
|
-
|
|
3572
|
+
De(n.name).unwrap()
|
|
3549
3573
|
);
|
|
3550
|
-
return (s == null ? void 0 : s.kind) === c.COLON &&
|
|
3574
|
+
return (s == null ? void 0 : s.kind) === c.COLON && Oe(s, e) ? Se(i) : i;
|
|
3551
3575
|
}
|
|
3552
|
-
return
|
|
3576
|
+
return S();
|
|
3553
3577
|
}
|
|
3554
|
-
function
|
|
3578
|
+
function Et(t, e) {
|
|
3555
3579
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3556
3580
|
if (n instanceof C)
|
|
3557
|
-
return
|
|
3558
|
-
if (n.body && !
|
|
3581
|
+
return S();
|
|
3582
|
+
if (n.body && !be(e, n.body))
|
|
3559
3583
|
switch (s) {
|
|
3560
|
-
case
|
|
3584
|
+
case R.TABLE:
|
|
3561
3585
|
return {
|
|
3562
3586
|
suggestions: [
|
|
3563
3587
|
{
|
|
@@ -3577,10 +3601,10 @@ function Nt(t, e) {
|
|
|
3577
3601
|
]
|
|
3578
3602
|
};
|
|
3579
3603
|
default:
|
|
3580
|
-
return
|
|
3604
|
+
return S();
|
|
3581
3605
|
}
|
|
3582
3606
|
switch (s) {
|
|
3583
|
-
case
|
|
3607
|
+
case R.TABLE:
|
|
3584
3608
|
return {
|
|
3585
3609
|
suggestions: [
|
|
3586
3610
|
...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
|
|
@@ -3606,7 +3630,7 @@ function Nt(t, e) {
|
|
|
3606
3630
|
}
|
|
3607
3631
|
]
|
|
3608
3632
|
};
|
|
3609
|
-
case
|
|
3633
|
+
case R.ENUM:
|
|
3610
3634
|
return {
|
|
3611
3635
|
suggestions: [
|
|
3612
3636
|
{
|
|
@@ -3618,7 +3642,7 @@ function Nt(t, e) {
|
|
|
3618
3642
|
}
|
|
3619
3643
|
]
|
|
3620
3644
|
};
|
|
3621
|
-
case
|
|
3645
|
+
case R.INDEXES:
|
|
3622
3646
|
return {
|
|
3623
3647
|
suggestions: [
|
|
3624
3648
|
...["unique", "pk"].map((i) => ({
|
|
@@ -3637,7 +3661,7 @@ function Nt(t, e) {
|
|
|
3637
3661
|
}))
|
|
3638
3662
|
]
|
|
3639
3663
|
};
|
|
3640
|
-
case
|
|
3664
|
+
case R.REF:
|
|
3641
3665
|
return {
|
|
3642
3666
|
suggestions: ["update", "delete"].map((i) => ({
|
|
3643
3667
|
label: i,
|
|
@@ -3648,7 +3672,7 @@ function Nt(t, e) {
|
|
|
3648
3672
|
}))
|
|
3649
3673
|
};
|
|
3650
3674
|
}
|
|
3651
|
-
return
|
|
3675
|
+
return S();
|
|
3652
3676
|
}
|
|
3653
3677
|
function Hn(t, e, n) {
|
|
3654
3678
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
@@ -3674,44 +3698,44 @@ function Hn(t, e, n) {
|
|
|
3674
3698
|
}))
|
|
3675
3699
|
};
|
|
3676
3700
|
}
|
|
3677
|
-
return
|
|
3701
|
+
return S();
|
|
3678
3702
|
}
|
|
3679
3703
|
function Ft(t, e, n) {
|
|
3680
|
-
const s =
|
|
3704
|
+
const s = ue(n).unwrap_or([]);
|
|
3681
3705
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3682
|
-
return
|
|
3706
|
+
return S();
|
|
3683
3707
|
const i = s.map((r) => G(r).unwrap());
|
|
3684
3708
|
return Ue({
|
|
3685
3709
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3686
3710
|
label: a,
|
|
3687
3711
|
insertText: a,
|
|
3688
|
-
kind:
|
|
3712
|
+
kind: Le(r),
|
|
3689
3713
|
range: void 0
|
|
3690
3714
|
}))
|
|
3691
3715
|
});
|
|
3692
3716
|
}
|
|
3693
|
-
function
|
|
3717
|
+
function Nt(t, e, n) {
|
|
3694
3718
|
var i;
|
|
3695
3719
|
switch (t.container.scopeKind(e)) {
|
|
3696
|
-
case
|
|
3720
|
+
case R.TABLE:
|
|
3697
3721
|
return Zn(t, e, n);
|
|
3698
|
-
case
|
|
3722
|
+
case R.PROJECT:
|
|
3699
3723
|
return Kn(t, e, n);
|
|
3700
|
-
case
|
|
3724
|
+
case R.INDEXES:
|
|
3701
3725
|
return ts(t, e);
|
|
3702
|
-
case
|
|
3726
|
+
case R.ENUM:
|
|
3703
3727
|
return Jn(t, e, n);
|
|
3704
|
-
case
|
|
3728
|
+
case R.REF: {
|
|
3705
3729
|
const r = Bt(t, e);
|
|
3706
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON &&
|
|
3730
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Oe(t.container.token(e).token, e) ? Se(r) : r;
|
|
3707
3731
|
}
|
|
3708
|
-
case
|
|
3732
|
+
case R.TABLEGROUP:
|
|
3709
3733
|
return es(t);
|
|
3710
3734
|
default:
|
|
3711
|
-
return
|
|
3735
|
+
return S();
|
|
3712
3736
|
}
|
|
3713
3737
|
}
|
|
3714
|
-
function
|
|
3738
|
+
function mt() {
|
|
3715
3739
|
return {
|
|
3716
3740
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3717
3741
|
label: t,
|
|
@@ -3723,16 +3747,16 @@ function Tt() {
|
|
|
3723
3747
|
};
|
|
3724
3748
|
}
|
|
3725
3749
|
function Jn(t, e, n) {
|
|
3726
|
-
return n != null && n.callee &&
|
|
3750
|
+
return n != null && n.callee && et(e, n) === 1 ? Me(t, e, t.container.element(e), [
|
|
3727
3751
|
m.Schema,
|
|
3728
3752
|
m.Table,
|
|
3729
3753
|
m.Column
|
|
3730
|
-
]) :
|
|
3754
|
+
]) : S();
|
|
3731
3755
|
}
|
|
3732
3756
|
function Zn(t, e, n) {
|
|
3733
3757
|
if (!(n != null && n.callee))
|
|
3734
3758
|
return {
|
|
3735
|
-
suggestions: ["
|
|
3759
|
+
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3736
3760
|
label: i,
|
|
3737
3761
|
insertText: i,
|
|
3738
3762
|
insertTextRules: w.KeepWhitespace,
|
|
@@ -3740,19 +3764,19 @@ function Zn(t, e, n) {
|
|
|
3740
3764
|
range: void 0
|
|
3741
3765
|
}))
|
|
3742
3766
|
};
|
|
3743
|
-
const s =
|
|
3767
|
+
const s = et(e, n);
|
|
3744
3768
|
return s === 0 ? {
|
|
3745
|
-
suggestions: ["
|
|
3769
|
+
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3746
3770
|
label: i,
|
|
3747
3771
|
insertText: i,
|
|
3748
3772
|
insertTextRules: w.KeepWhitespace,
|
|
3749
3773
|
kind: L.Keyword,
|
|
3750
3774
|
range: void 0
|
|
3751
3775
|
}))
|
|
3752
|
-
} : s === 1 ? ns(t, e) :
|
|
3776
|
+
} : s === 1 ? ns(t, e) : S();
|
|
3753
3777
|
}
|
|
3754
3778
|
function Kn(t, e, n) {
|
|
3755
|
-
return n != null && n.callee ?
|
|
3779
|
+
return n != null && n.callee ? et(e, n) === 0 ? {
|
|
3756
3780
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3757
3781
|
label: i,
|
|
3758
3782
|
insertText: i,
|
|
@@ -3760,7 +3784,7 @@ function Kn(t, e, n) {
|
|
|
3760
3784
|
kind: L.Keyword,
|
|
3761
3785
|
range: void 0
|
|
3762
3786
|
}))
|
|
3763
|
-
} :
|
|
3787
|
+
} : S() : {
|
|
3764
3788
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3765
3789
|
label: i,
|
|
3766
3790
|
insertText: i,
|
|
@@ -3788,7 +3812,7 @@ function es(t) {
|
|
|
3788
3812
|
label: i,
|
|
3789
3813
|
insertText: i,
|
|
3790
3814
|
insertTextRules: w.KeepWhitespace,
|
|
3791
|
-
kind:
|
|
3815
|
+
kind: Le(s),
|
|
3792
3816
|
range: void 0
|
|
3793
3817
|
};
|
|
3794
3818
|
})
|
|
@@ -3874,8 +3898,8 @@ function ns(t, e) {
|
|
|
3874
3898
|
}
|
|
3875
3899
|
function Vt(t, e) {
|
|
3876
3900
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
3877
|
-
if (!((s == null ? void 0 : s.symbol) instanceof
|
|
3878
|
-
return
|
|
3901
|
+
if (!((s == null ? void 0 : s.symbol) instanceof _t))
|
|
3902
|
+
return S();
|
|
3879
3903
|
const { symbolTable: i } = s.symbol;
|
|
3880
3904
|
return Ue({
|
|
3881
3905
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
@@ -3887,13 +3911,13 @@ function Vt(t, e) {
|
|
|
3887
3911
|
label: l,
|
|
3888
3912
|
insertText: l,
|
|
3889
3913
|
insertTextRules: w.KeepWhitespace,
|
|
3890
|
-
kind:
|
|
3914
|
+
kind: Le(m.Column),
|
|
3891
3915
|
range: void 0
|
|
3892
3916
|
};
|
|
3893
3917
|
})
|
|
3894
3918
|
});
|
|
3895
3919
|
}
|
|
3896
|
-
function
|
|
3920
|
+
function et(t, e) {
|
|
3897
3921
|
if (!e.callee)
|
|
3898
3922
|
return -1;
|
|
3899
3923
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
@@ -3905,10 +3929,10 @@ class Gt {
|
|
|
3905
3929
|
}
|
|
3906
3930
|
provideDefinition(e, n) {
|
|
3907
3931
|
var a;
|
|
3908
|
-
const { uri: s } = e, i =
|
|
3932
|
+
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
3909
3933
|
for (; r.length !== 0; ) {
|
|
3910
3934
|
const l = r.pop();
|
|
3911
|
-
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [
|
|
3935
|
+
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [pe.PRIMARY_EXPRESSION, pe.VARIABLE].includes(l == null ? void 0 : l.kind)) {
|
|
3912
3936
|
const { startPos: p, endPos: h } = l.referee.declaration;
|
|
3913
3937
|
return [
|
|
3914
3938
|
{
|
|
@@ -3931,13 +3955,13 @@ class Ct {
|
|
|
3931
3955
|
this.compiler = e;
|
|
3932
3956
|
}
|
|
3933
3957
|
provideReferences(e, n) {
|
|
3934
|
-
const { uri: s } = e, i =
|
|
3958
|
+
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
3935
3959
|
for (; r.length !== 0; ) {
|
|
3936
3960
|
const a = r.pop();
|
|
3937
3961
|
if (a && [
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3962
|
+
pe.ELEMENT_DECLARATION,
|
|
3963
|
+
pe.FUNCTION_APPLICATION,
|
|
3964
|
+
pe.PRIMARY_EXPRESSION
|
|
3941
3965
|
].includes(a == null ? void 0 : a.kind)) {
|
|
3942
3966
|
const { symbol: l } = a;
|
|
3943
3967
|
if (l != null && l.references.length)
|
|
@@ -3963,7 +3987,7 @@ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3963
3987
|
DBMLDefinitionProvider: Gt,
|
|
3964
3988
|
DBMLReferencesProvider: Ct
|
|
3965
3989
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3966
|
-
var
|
|
3990
|
+
var R = /* @__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))(R || {});
|
|
3967
3991
|
class as {
|
|
3968
3992
|
constructor() {
|
|
3969
3993
|
this.source = "", this.cache = new Array(
|
|
@@ -3972,7 +3996,7 @@ class as {
|
|
|
3972
3996
|
).fill(null), this.nodeIdGenerator = new Wt(), this.symbolIdGenerator = new Qt(), this.token = {
|
|
3973
3997
|
invalidStream: this.createQuery(
|
|
3974
3998
|
6,
|
|
3975
|
-
() => this.parse.tokens().filter(
|
|
3999
|
+
() => this.parse.tokens().filter(At)
|
|
3976
4000
|
),
|
|
3977
4001
|
// Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
|
|
3978
4002
|
flatStream: this.createQuery(
|
|
@@ -4022,7 +4046,7 @@ class as {
|
|
|
4022
4046
|
let a = this.parse.ast();
|
|
4023
4047
|
const l = [a];
|
|
4024
4048
|
for (; ; ) {
|
|
4025
|
-
const h = sn(a).find((T) =>
|
|
4049
|
+
const h = sn(a).find((T) => be(r, T));
|
|
4026
4050
|
if (h === void 0 || h instanceof B)
|
|
4027
4051
|
break;
|
|
4028
4052
|
l.push(h), a = h;
|
|
@@ -4038,7 +4062,7 @@ class as {
|
|
|
4038
4062
|
T[f] === `
|
|
4039
4063
|
` && (l.pop(), p = !0);
|
|
4040
4064
|
} else
|
|
4041
|
-
h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof
|
|
4065
|
+
h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof te ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof K || h.end < e && (l.pop(), p = !0);
|
|
4042
4066
|
if (p) {
|
|
4043
4067
|
const T = I.last(l);
|
|
4044
4068
|
T instanceof _ && T.end <= e && l.pop();
|