@dbml/parse 3.7.1 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +9 -9
- package/dist/dbml-parse.mjs +888 -755
- package/dist/lib/analyzer/validator/elementValidators/note.d.ts +1 -1
- package/dist/lib/analyzer/validator/elementValidators/tableGroup.d.ts +2 -2
- package/dist/lib/interpreter/elementInterpreter/tableGroup.d.ts +3 -0
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import I, {
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import I, { partition as jt, findLastIndex as Yt, last as it } from "lodash";
|
|
2
|
+
var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
|
+
function zt(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -45,13 +45,13 @@ class F {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function bt(t) {
|
|
48
|
-
return t.trailingTrivia.find(({ kind: e }) => e ===
|
|
48
|
+
return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
50
|
function ot(t, e) {
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s ===
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || bt(t);
|
|
52
52
|
}
|
|
53
53
|
function Ce(t) {
|
|
54
|
-
return t.trailingTrivia.find(({ kind: e }) => e ===
|
|
54
|
+
return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
56
|
function It(t) {
|
|
57
57
|
return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
|
|
@@ -59,12 +59,12 @@ function It(t) {
|
|
|
59
59
|
function Lt(t) {
|
|
60
60
|
return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return [
|
|
62
|
+
function Qt(t) {
|
|
63
|
+
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class qt {
|
|
68
68
|
constructor() {
|
|
69
69
|
this.id = 0;
|
|
70
70
|
}
|
|
@@ -94,13 +94,13 @@ class x {
|
|
|
94
94
|
}, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
var
|
|
98
|
-
class
|
|
97
|
+
var Ne = /* @__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))(Ne || {});
|
|
98
|
+
class X extends x {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class v extends x {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -108,7 +108,7 @@ class A extends x {
|
|
|
108
108
|
alias: i,
|
|
109
109
|
attributeList: r,
|
|
110
110
|
bodyColon: a,
|
|
111
|
-
body:
|
|
111
|
+
body: c
|
|
112
112
|
}, p) {
|
|
113
113
|
if (super(p, "<element-declaration>", [
|
|
114
114
|
e,
|
|
@@ -117,13 +117,13 @@ class A extends x {
|
|
|
117
117
|
i,
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
|
-
|
|
121
|
-
]),
|
|
120
|
+
c
|
|
121
|
+
]), c && a && !(c instanceof y || c instanceof v))
|
|
122
122
|
throw new Error("If an element has a simple body, it must be a function application node");
|
|
123
|
-
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body =
|
|
123
|
+
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = c;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class
|
|
126
|
+
class Y extends x {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
@@ -156,7 +156,7 @@ class Ue extends x {
|
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class
|
|
159
|
+
class ne extends x {
|
|
160
160
|
constructor({ value: e }, n) {
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
@@ -166,7 +166,7 @@ class y extends x {
|
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class
|
|
169
|
+
class J extends x {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -189,7 +189,7 @@ class D extends x {
|
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class
|
|
192
|
+
class Z extends x {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -203,7 +203,7 @@ class J extends x {
|
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class We extends
|
|
206
|
+
class We extends Z {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -233,7 +233,7 @@ class be extends x {
|
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class K extends x {
|
|
237
237
|
constructor({ variable: e }, n) {
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
@@ -245,11 +245,11 @@ class U extends x {
|
|
|
245
245
|
}
|
|
246
246
|
class xe extends x {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
|
-
const s = F.create(
|
|
248
|
+
const s = F.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
252
|
+
class he extends x {
|
|
253
253
|
constructor({ expression: e, indexer: n }, s) {
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
@@ -264,12 +264,12 @@ function gt(t, e) {
|
|
|
264
264
|
(i) => i !== null
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function us(t, e = !1) {
|
|
268
268
|
return JSON.stringify(
|
|
269
269
|
t,
|
|
270
270
|
function(n, s) {
|
|
271
271
|
var i;
|
|
272
|
-
return !(this instanceof
|
|
272
|
+
return !(this instanceof X) && n === "symbol" ? s == null ? void 0 : s.id : (
|
|
273
273
|
/* this instanceof SyntaxNode && */
|
|
274
274
|
n === "symbol" ? {
|
|
275
275
|
symbolTable: s == null ? void 0 : s.symbolTable,
|
|
@@ -312,7 +312,7 @@ class S {
|
|
|
312
312
|
return !0;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class k {
|
|
316
316
|
// eslint-disable-next-line class-methods-use-this
|
|
317
317
|
unwrap() {
|
|
318
318
|
throw new Error("Trying to unwrap a None value");
|
|
@@ -323,11 +323,11 @@ class w {
|
|
|
323
323
|
}
|
|
324
324
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
|
325
325
|
and_then(e) {
|
|
326
|
-
return new
|
|
326
|
+
return new k();
|
|
327
327
|
}
|
|
328
328
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
|
329
329
|
map(e) {
|
|
330
|
-
return new
|
|
330
|
+
return new k();
|
|
331
331
|
}
|
|
332
332
|
// eslint-disable-next-line class-methods-use-this
|
|
333
333
|
isOk() {
|
|
@@ -356,7 +356,7 @@ function qe(t) {
|
|
|
356
356
|
function He(t) {
|
|
357
357
|
return `TableGroup field:${t}`;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function Ht(t) {
|
|
360
360
|
return `Note:${t}`;
|
|
361
361
|
}
|
|
362
362
|
function Ve(t, e) {
|
|
@@ -384,16 +384,16 @@ function ie(t) {
|
|
|
384
384
|
return Object.values(T).includes(e) ? new S({
|
|
385
385
|
name: n,
|
|
386
386
|
kind: e
|
|
387
|
-
}) : new
|
|
387
|
+
}) : new k();
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function Jt(t) {
|
|
390
390
|
const e = ie(t).unwrap_or(void 0);
|
|
391
391
|
if (!e)
|
|
392
392
|
return !1;
|
|
393
393
|
const { kind: n, name: s } = e;
|
|
394
394
|
return n === "Schema" && s === "public";
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function Zt(t) {
|
|
397
397
|
return [
|
|
398
398
|
je,
|
|
399
399
|
Oe,
|
|
@@ -411,14 +411,14 @@ function Re(t) {
|
|
|
411
411
|
const [e] = t;
|
|
412
412
|
return e >= "0" && e <= "9";
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function Kt(t) {
|
|
415
415
|
const [e] = t;
|
|
416
416
|
return Re(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function Ee(t) {
|
|
419
419
|
return Me(t) || Re(t);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function lt(t, e) {
|
|
422
422
|
const n = [], s = Math.min(t.length, e.length);
|
|
423
423
|
for (let i = 0; i < s; i += 1)
|
|
424
424
|
n.push(t[i], e[i]);
|
|
@@ -427,7 +427,7 @@ function ct(t, e) {
|
|
|
427
427
|
function ge(t, e) {
|
|
428
428
|
return t >= e.start && t < e.end;
|
|
429
429
|
}
|
|
430
|
-
class
|
|
430
|
+
class en {
|
|
431
431
|
constructor() {
|
|
432
432
|
this.id = 0;
|
|
433
433
|
}
|
|
@@ -443,12 +443,12 @@ class _t {
|
|
|
443
443
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
-
class
|
|
446
|
+
class tn {
|
|
447
447
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
448
448
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
class
|
|
451
|
+
class nn {
|
|
452
452
|
constructor({ declaration: e }, n) {
|
|
453
453
|
this.references = [], this.id = n, this.declaration = e;
|
|
454
454
|
}
|
|
@@ -458,28 +458,28 @@ class At {
|
|
|
458
458
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
class
|
|
461
|
+
class sn {
|
|
462
462
|
constructor({ declaration: e }, n) {
|
|
463
463
|
this.references = [], this.id = n, this.declaration = e;
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
class
|
|
466
|
+
class rn {
|
|
467
467
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
468
468
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
class
|
|
471
|
+
class an {
|
|
472
472
|
constructor({ declaration: e }, n) {
|
|
473
473
|
this.references = [], this.id = n, this.declaration = e;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
|
|
477
|
-
class
|
|
477
|
+
class l extends Error {
|
|
478
478
|
constructor(e, n, s) {
|
|
479
|
-
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this,
|
|
479
|
+
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, l.prototype);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
class
|
|
482
|
+
class V {
|
|
483
483
|
constructor(e, n) {
|
|
484
484
|
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
485
485
|
}
|
|
@@ -491,21 +491,21 @@ class B {
|
|
|
491
491
|
}
|
|
492
492
|
chain(e) {
|
|
493
493
|
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
494
|
-
return new
|
|
494
|
+
return new V(n.value, s);
|
|
495
495
|
}
|
|
496
496
|
map(e) {
|
|
497
|
-
return new
|
|
497
|
+
return new V(e(this.value), this.errors);
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function on(t, e, n) {
|
|
501
501
|
if (!t || !me(t) || e.length === 0)
|
|
502
|
-
return new
|
|
502
|
+
return new k();
|
|
503
503
|
const s = [...e], i = Ge(t).unwrap(), r = s.pop();
|
|
504
|
-
if (!(r instanceof
|
|
505
|
-
return new
|
|
504
|
+
if (!(r instanceof J))
|
|
505
|
+
return new k();
|
|
506
506
|
const a = I.last(s) instanceof D ? s.pop() : void 0;
|
|
507
507
|
return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new S(
|
|
508
|
-
n.create(
|
|
508
|
+
n.create(v, {
|
|
509
509
|
type: i,
|
|
510
510
|
name: s[0],
|
|
511
511
|
as: Ge(s[1]).unwrap(),
|
|
@@ -514,33 +514,33 @@ function an(t, e, n) {
|
|
|
514
514
|
body: r
|
|
515
515
|
})
|
|
516
516
|
) : s.length === 1 ? new S(
|
|
517
|
-
n.create(
|
|
517
|
+
n.create(v, {
|
|
518
518
|
type: i,
|
|
519
519
|
name: s[0],
|
|
520
520
|
attributeList: a,
|
|
521
521
|
body: r
|
|
522
522
|
})
|
|
523
523
|
) : s.length === 0 ? new S(
|
|
524
|
-
n.create(
|
|
524
|
+
n.create(v, {
|
|
525
525
|
type: i,
|
|
526
526
|
attributeList: a,
|
|
527
527
|
body: r
|
|
528
528
|
})
|
|
529
|
-
) : new
|
|
529
|
+
) : new k();
|
|
530
530
|
}
|
|
531
|
-
function
|
|
532
|
-
return t.kind ===
|
|
531
|
+
function ct(t) {
|
|
532
|
+
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
533
533
|
}
|
|
534
534
|
function N(t) {
|
|
535
|
-
t && (t instanceof F ?
|
|
535
|
+
t && (t instanceof F ? ln(t) : cn(t));
|
|
536
536
|
}
|
|
537
|
-
function
|
|
538
|
-
t.kind !==
|
|
537
|
+
function ln(t) {
|
|
538
|
+
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
539
539
|
}
|
|
540
540
|
function cn(t) {
|
|
541
|
-
if (t instanceof
|
|
541
|
+
if (t instanceof v)
|
|
542
542
|
N(t.type), N(t.name), N(t.as), N(t.alias), N(t.bodyColon), N(t.attributeList), N(t.body);
|
|
543
|
-
else if (t instanceof
|
|
543
|
+
else if (t instanceof Y)
|
|
544
544
|
t.identifiers.forEach(N);
|
|
545
545
|
else if (t instanceof se)
|
|
546
546
|
N(t.name), N(t.colon), N(t.value);
|
|
@@ -550,11 +550,11 @@ function cn(t) {
|
|
|
550
550
|
N(t.leftExpression), N(t.op), N(t.rightExpression);
|
|
551
551
|
else if (t instanceof Ue)
|
|
552
552
|
N(t.op), N(t.expression);
|
|
553
|
-
else if (t instanceof
|
|
553
|
+
else if (t instanceof J)
|
|
554
554
|
N(t.blockOpenBrace), t.body.forEach(N), N(t.blockCloseBrace);
|
|
555
555
|
else if (t instanceof D)
|
|
556
556
|
N(t.listOpenBracket), t.commaList.forEach(N), t.elementList.forEach(N), N(t.listCloseBracket);
|
|
557
|
-
else if (t instanceof
|
|
557
|
+
else if (t instanceof Z)
|
|
558
558
|
N(t.tupleOpenParen), t.commaList.forEach(N), t.elementList.forEach(N), N(t.tupleCloseParen);
|
|
559
559
|
else if (t instanceof H)
|
|
560
560
|
N(t.callee), N(t.argumentList);
|
|
@@ -562,9 +562,9 @@ function cn(t) {
|
|
|
562
562
|
N(t.callee), t.args.forEach(N);
|
|
563
563
|
else if (t instanceof U)
|
|
564
564
|
N(t.expression);
|
|
565
|
-
else if (t instanceof
|
|
565
|
+
else if (t instanceof ne)
|
|
566
566
|
N(t.value);
|
|
567
|
-
else if (t instanceof
|
|
567
|
+
else if (t instanceof K)
|
|
568
568
|
N(t.variable);
|
|
569
569
|
else if (t instanceof be)
|
|
570
570
|
N(t.literal);
|
|
@@ -577,10 +577,10 @@ function vt(t) {
|
|
|
577
577
|
function P(...t) {
|
|
578
578
|
return t.filter((e) => e !== void 0);
|
|
579
579
|
}
|
|
580
|
-
function
|
|
581
|
-
if (t instanceof
|
|
580
|
+
function un(t) {
|
|
581
|
+
if (t instanceof X)
|
|
582
582
|
return P(...t.body, t.eof);
|
|
583
|
-
if (t instanceof
|
|
583
|
+
if (t instanceof v)
|
|
584
584
|
return P(
|
|
585
585
|
t.type,
|
|
586
586
|
t.name,
|
|
@@ -592,11 +592,11 @@ function ln(t) {
|
|
|
592
592
|
);
|
|
593
593
|
if (t instanceof se)
|
|
594
594
|
return P(t.name, t.colon, t.value);
|
|
595
|
-
if (t instanceof
|
|
595
|
+
if (t instanceof Y)
|
|
596
596
|
return t.identifiers;
|
|
597
597
|
if (t instanceof be)
|
|
598
598
|
return t.literal ? [t.literal] : [];
|
|
599
|
-
if (t instanceof
|
|
599
|
+
if (t instanceof K)
|
|
600
600
|
return P(t.variable);
|
|
601
601
|
if (t instanceof Q)
|
|
602
602
|
return P(t.op, t.expression);
|
|
@@ -604,29 +604,29 @@ function ln(t) {
|
|
|
604
604
|
return P(t.leftExpression, t.op, t.rightExpression);
|
|
605
605
|
if (t instanceof Ue)
|
|
606
606
|
return P(t.expression, t.op);
|
|
607
|
-
if (t instanceof
|
|
607
|
+
if (t instanceof ne)
|
|
608
608
|
return P(t.value);
|
|
609
609
|
if (t instanceof y)
|
|
610
610
|
return P(t.callee, ...t.args);
|
|
611
|
-
if (t instanceof
|
|
611
|
+
if (t instanceof J)
|
|
612
612
|
return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
613
613
|
if (t instanceof D)
|
|
614
614
|
return P(
|
|
615
615
|
t.listOpenBracket,
|
|
616
|
-
...
|
|
616
|
+
...lt(t.elementList, t.commaList),
|
|
617
617
|
t.listCloseBracket
|
|
618
618
|
);
|
|
619
|
-
if (t instanceof
|
|
619
|
+
if (t instanceof Z)
|
|
620
620
|
return P(
|
|
621
621
|
t.tupleOpenParen,
|
|
622
|
-
...
|
|
622
|
+
...lt(t.elementList, t.commaList),
|
|
623
623
|
t.tupleCloseParen
|
|
624
624
|
);
|
|
625
625
|
if (t instanceof H)
|
|
626
626
|
return P(t.callee, t.argumentList);
|
|
627
627
|
if (t instanceof U)
|
|
628
628
|
return P(t.expression);
|
|
629
|
-
if (t instanceof
|
|
629
|
+
if (t instanceof he)
|
|
630
630
|
return P(
|
|
631
631
|
t.array,
|
|
632
632
|
t.indexer
|
|
@@ -634,18 +634,18 @@ function ln(t) {
|
|
|
634
634
|
throw t instanceof We ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
635
635
|
}
|
|
636
636
|
function Ge(t) {
|
|
637
|
-
return M(t) ? new S(t.expression.variable) : new
|
|
637
|
+
return M(t) ? new S(t.expression.variable) : new k();
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function $(t) {
|
|
640
640
|
var e;
|
|
641
|
-
return t instanceof U && (t.expression instanceof
|
|
641
|
+
return t instanceof U && (t.expression instanceof K && t.expression.variable instanceof F && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
642
642
|
}
|
|
643
643
|
function M(t) {
|
|
644
|
-
return t instanceof U && t.expression instanceof
|
|
644
|
+
return t instanceof U && t.expression instanceof K && t.expression.variable instanceof F;
|
|
645
645
|
}
|
|
646
646
|
function me(t) {
|
|
647
647
|
var e;
|
|
648
|
-
return t instanceof U && t.expression instanceof
|
|
648
|
+
return t instanceof U && t.expression instanceof K && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
649
649
|
}
|
|
650
650
|
function Je(t) {
|
|
651
651
|
var e;
|
|
@@ -653,11 +653,11 @@ function Je(t) {
|
|
|
653
653
|
}
|
|
654
654
|
function Te(t) {
|
|
655
655
|
if (t === void 0)
|
|
656
|
-
return new
|
|
656
|
+
return new k();
|
|
657
657
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
658
|
-
return e === "" ? new
|
|
658
|
+
return e === "" ? new k() : new S(e);
|
|
659
659
|
}
|
|
660
|
-
class
|
|
660
|
+
class hn {
|
|
661
661
|
// list of errors during lexing
|
|
662
662
|
constructor(e) {
|
|
663
663
|
this.start = {
|
|
@@ -706,50 +706,50 @@ class un {
|
|
|
706
706
|
);
|
|
707
707
|
}
|
|
708
708
|
lex() {
|
|
709
|
-
return this.scanTokens(), this.tokens.push(F.create(
|
|
709
|
+
return this.scanTokens(), this.tokens.push(F.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new V(this.tokens, this.errors);
|
|
710
710
|
}
|
|
711
711
|
scanTokens() {
|
|
712
712
|
for (; !this.isAtEnd(); ) {
|
|
713
713
|
const e = this.advance();
|
|
714
714
|
switch (e) {
|
|
715
715
|
case " ":
|
|
716
|
-
this.addToken(
|
|
716
|
+
this.addToken(u.SPACE);
|
|
717
717
|
break;
|
|
718
718
|
case "\r":
|
|
719
719
|
break;
|
|
720
720
|
case `
|
|
721
721
|
`:
|
|
722
|
-
this.addToken(
|
|
722
|
+
this.addToken(u.NEWLINE);
|
|
723
723
|
break;
|
|
724
724
|
case " ":
|
|
725
|
-
this.addToken(
|
|
725
|
+
this.addToken(u.TAB);
|
|
726
726
|
break;
|
|
727
727
|
case ",":
|
|
728
|
-
this.addToken(
|
|
728
|
+
this.addToken(u.COMMA);
|
|
729
729
|
break;
|
|
730
730
|
case "(":
|
|
731
|
-
this.addToken(
|
|
731
|
+
this.addToken(u.LPAREN);
|
|
732
732
|
break;
|
|
733
733
|
case ")":
|
|
734
|
-
this.addToken(
|
|
734
|
+
this.addToken(u.RPAREN);
|
|
735
735
|
break;
|
|
736
736
|
case "[":
|
|
737
|
-
this.addToken(
|
|
737
|
+
this.addToken(u.LBRACKET);
|
|
738
738
|
break;
|
|
739
739
|
case "]":
|
|
740
|
-
this.addToken(
|
|
740
|
+
this.addToken(u.RBRACKET);
|
|
741
741
|
break;
|
|
742
742
|
case "{":
|
|
743
|
-
this.addToken(
|
|
743
|
+
this.addToken(u.LBRACE);
|
|
744
744
|
break;
|
|
745
745
|
case "}":
|
|
746
|
-
this.addToken(
|
|
746
|
+
this.addToken(u.RBRACE);
|
|
747
747
|
break;
|
|
748
748
|
case ";":
|
|
749
|
-
this.addToken(
|
|
749
|
+
this.addToken(u.SEMICOLON);
|
|
750
750
|
break;
|
|
751
751
|
case ":":
|
|
752
|
-
this.addToken(
|
|
752
|
+
this.addToken(u.COLON);
|
|
753
753
|
break;
|
|
754
754
|
case "'":
|
|
755
755
|
this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
|
|
@@ -779,11 +779,11 @@ class un {
|
|
|
779
779
|
this.numericLiteralOrIdentifier();
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
|
-
this.addToken(
|
|
783
|
-
new
|
|
782
|
+
this.addToken(u.OP, !0), this.errors.push(
|
|
783
|
+
new l(
|
|
784
784
|
o.UNKNOWN_SYMBOL,
|
|
785
785
|
`Unexpected token '${e}'`,
|
|
786
|
-
this.createToken(
|
|
786
|
+
this.createToken(u.OP, !0)
|
|
787
787
|
)
|
|
788
788
|
);
|
|
789
789
|
break;
|
|
@@ -795,7 +795,7 @@ class un {
|
|
|
795
795
|
let e = !0, n = [], s;
|
|
796
796
|
const i = [];
|
|
797
797
|
for (const r of this.tokens)
|
|
798
|
-
|
|
798
|
+
zt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
|
|
799
799
|
this.tokens = i;
|
|
800
800
|
}
|
|
801
801
|
gatherInvalid() {
|
|
@@ -820,14 +820,14 @@ class un {
|
|
|
820
820
|
// Whether to interpret '\' as a backlash
|
|
821
821
|
consumeStopSequence: a = !0
|
|
822
822
|
}) {
|
|
823
|
-
let
|
|
823
|
+
let c = "";
|
|
824
824
|
for (; !this.isAtEnd() && (s || !this.check(`
|
|
825
825
|
`)) && !this.check(n); )
|
|
826
|
-
this.peek() === "\\" && !r ? (this.advance(),
|
|
826
|
+
this.peek() === "\\" && !r ? (this.advance(), c += this.escapedString()) : c += this.advance();
|
|
827
827
|
if (this.isAtEnd() && !i) {
|
|
828
828
|
const p = this.createToken(e, !0);
|
|
829
829
|
this.tokens.push(p), this.errors.push(
|
|
830
|
-
new
|
|
830
|
+
new l(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
|
|
831
831
|
);
|
|
832
832
|
return;
|
|
833
833
|
}
|
|
@@ -835,7 +835,7 @@ class un {
|
|
|
835
835
|
`) && !s) {
|
|
836
836
|
const p = this.createToken(e, !0);
|
|
837
837
|
this.tokens.push(p), this.errors.push(
|
|
838
|
-
new
|
|
838
|
+
new l(
|
|
839
839
|
o.UNEXPECTED_NEWLINE,
|
|
840
840
|
"Invalid newline encountered while parsing",
|
|
841
841
|
p
|
|
@@ -843,38 +843,38 @@ class un {
|
|
|
843
843
|
);
|
|
844
844
|
return;
|
|
845
845
|
}
|
|
846
|
-
a && this.match(n), this.tokens.push(F.create(e, this.start, this.current,
|
|
846
|
+
a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, c, !1));
|
|
847
847
|
}
|
|
848
848
|
singleLineStringLiteral() {
|
|
849
|
-
this.consumeUntil(
|
|
849
|
+
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
850
850
|
allowNewline: !1,
|
|
851
851
|
allowEof: !1,
|
|
852
852
|
raw: !1
|
|
853
853
|
});
|
|
854
854
|
}
|
|
855
855
|
multilineStringLiteral() {
|
|
856
|
-
this.consumeUntil(
|
|
856
|
+
this.consumeUntil(u.STRING_LITERAL, "'''", {
|
|
857
857
|
allowNewline: !0,
|
|
858
858
|
allowEof: !1,
|
|
859
859
|
raw: !1
|
|
860
860
|
});
|
|
861
861
|
}
|
|
862
862
|
functionExpression() {
|
|
863
|
-
this.consumeUntil(
|
|
863
|
+
this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
|
|
864
864
|
allowNewline: !1,
|
|
865
865
|
allowEof: !1,
|
|
866
866
|
raw: !0
|
|
867
867
|
});
|
|
868
868
|
}
|
|
869
869
|
quotedVariable() {
|
|
870
|
-
this.consumeUntil(
|
|
870
|
+
this.consumeUntil(u.QUOTED_STRING, '"', {
|
|
871
871
|
allowNewline: !1,
|
|
872
872
|
allowEof: !1,
|
|
873
873
|
raw: !1
|
|
874
874
|
});
|
|
875
875
|
}
|
|
876
876
|
singleLineComment() {
|
|
877
|
-
this.consumeUntil(
|
|
877
|
+
this.consumeUntil(u.SINGLE_LINE_COMMENT, `
|
|
878
878
|
`, {
|
|
879
879
|
allowNewline: !0,
|
|
880
880
|
allowEof: !0,
|
|
@@ -883,55 +883,55 @@ class un {
|
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
885
|
multilineComment() {
|
|
886
|
-
this.consumeUntil(
|
|
886
|
+
this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
|
|
887
887
|
allowNewline: !0,
|
|
888
888
|
allowEof: !1,
|
|
889
889
|
raw: !0
|
|
890
890
|
});
|
|
891
891
|
}
|
|
892
892
|
identifier() {
|
|
893
|
-
for (; !this.isAtEnd() &&
|
|
893
|
+
for (; !this.isAtEnd() && Ee(this.peek()); )
|
|
894
894
|
this.advance();
|
|
895
|
-
this.addToken(
|
|
895
|
+
this.addToken(u.IDENTIFIER);
|
|
896
896
|
}
|
|
897
897
|
operator() {
|
|
898
898
|
for (; rt(this.peek()); )
|
|
899
899
|
this.advance();
|
|
900
|
-
this.addToken(
|
|
900
|
+
this.addToken(u.OP);
|
|
901
901
|
}
|
|
902
902
|
// we accept identifiers starting with digits but must contain at least one char or underscore
|
|
903
903
|
numericLiteralOrIdentifier() {
|
|
904
904
|
let e = 0;
|
|
905
905
|
if (this.isAtEnd())
|
|
906
|
-
return this.addToken(
|
|
906
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
907
907
|
for (; !this.isAtEnd(); ) {
|
|
908
908
|
const n = this.check(".");
|
|
909
909
|
if (e += n ? 1 : 0, e > 1)
|
|
910
910
|
break;
|
|
911
911
|
if (!n && this.current.offset === this.text.length - 1)
|
|
912
|
-
return this.advance(), this.addToken(
|
|
913
|
-
if (!n && !
|
|
914
|
-
return this.addToken(
|
|
912
|
+
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
913
|
+
if (!n && !Ee(this.peek()))
|
|
914
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
915
915
|
if (!n && !Re(this.peek()))
|
|
916
916
|
break;
|
|
917
917
|
this.advance();
|
|
918
918
|
}
|
|
919
919
|
if (e > 0) {
|
|
920
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
920
|
+
for (; !this.isAtEnd() && (this.check(".") || Ee(this.peek())); )
|
|
921
921
|
this.advance();
|
|
922
|
-
const n = this.createToken(
|
|
923
|
-
this.tokens.push(n), this.errors.push(new
|
|
922
|
+
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
923
|
+
this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
924
924
|
} else {
|
|
925
|
-
for (; !this.isAtEnd() &&
|
|
925
|
+
for (; !this.isAtEnd() && Ee(this.peek()); )
|
|
926
926
|
this.advance();
|
|
927
|
-
const n = this.createToken(
|
|
927
|
+
const n = this.createToken(u.IDENTIFIER, !1);
|
|
928
928
|
this.tokens.push(n);
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
colorLiteral() {
|
|
932
|
-
for (; !this.isAtEnd() &&
|
|
932
|
+
for (; !this.isAtEnd() && Ee(this.peek()); )
|
|
933
933
|
this.advance();
|
|
934
|
-
this.addToken(
|
|
934
|
+
this.addToken(u.COLOR_LITERAL);
|
|
935
935
|
}
|
|
936
936
|
escapedString() {
|
|
937
937
|
const e = { column: this.current.column - 1, offset: this.current.offset - 1, line: this.current.line };
|
|
@@ -970,8 +970,8 @@ class un {
|
|
|
970
970
|
case "u": {
|
|
971
971
|
let n = "";
|
|
972
972
|
for (let s = 0; s <= 3; s += 1) {
|
|
973
|
-
if (this.isAtEnd() || !
|
|
974
|
-
return this.errors.push(new
|
|
973
|
+
if (this.isAtEnd() || !Ee(this.peek()))
|
|
974
|
+
return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
|
|
975
975
|
n += this.advance();
|
|
976
976
|
}
|
|
977
977
|
return String.fromCharCode(parseInt(n, 16));
|
|
@@ -982,7 +982,7 @@ class un {
|
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
984
|
var Se = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Se || {});
|
|
985
|
-
class
|
|
985
|
+
class fn {
|
|
986
986
|
constructor() {
|
|
987
987
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
988
988
|
}
|
|
@@ -1023,7 +1023,7 @@ class hn {
|
|
|
1023
1023
|
if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
|
|
1024
1024
|
for (let s = n; s < e.length - 1; s += 1)
|
|
1025
1025
|
switch (e[s].kind) {
|
|
1026
|
-
case
|
|
1026
|
+
case u.COMMA:
|
|
1027
1027
|
if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
|
|
1028
1028
|
return [...this.stack].reverse().find(
|
|
1029
1029
|
(r) => [
|
|
@@ -1033,22 +1033,22 @@ class hn {
|
|
|
1033
1033
|
].includes(r)
|
|
1034
1034
|
);
|
|
1035
1035
|
break;
|
|
1036
|
-
case
|
|
1036
|
+
case u.RPAREN:
|
|
1037
1037
|
if (this.isWithinGroupExpressionContext())
|
|
1038
1038
|
return 1;
|
|
1039
1039
|
break;
|
|
1040
|
-
case
|
|
1040
|
+
case u.RBRACE:
|
|
1041
1041
|
if (this.isWithinBlockExpressionContext())
|
|
1042
1042
|
return 2;
|
|
1043
1043
|
break;
|
|
1044
|
-
case
|
|
1044
|
+
case u.RBRACKET:
|
|
1045
1045
|
if (this.isWithinListExpressionContext())
|
|
1046
1046
|
return 0;
|
|
1047
1047
|
break;
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
|
-
class
|
|
1051
|
+
class pn {
|
|
1052
1052
|
constructor(e) {
|
|
1053
1053
|
this.generator = e;
|
|
1054
1054
|
}
|
|
@@ -1061,29 +1061,29 @@ class d {
|
|
|
1061
1061
|
this.token = e, this.partialNode = n, this.handlerContext = s;
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
class
|
|
1064
|
+
class dn {
|
|
1065
1065
|
constructor(e, n) {
|
|
1066
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1066
|
+
this.current = 0, this.errors = [], this.contextStack = new fn(), this.synchronizeProgram = () => {
|
|
1067
1067
|
const s = this.peek();
|
|
1068
|
-
s.kind !==
|
|
1068
|
+
s.kind !== u.EOF ? N(this.advance()) : (N(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1069
1069
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1070
1070
|
for (; !this.isAtEnd(); ) {
|
|
1071
1071
|
const s = this.peek();
|
|
1072
|
-
if (
|
|
1072
|
+
if (ct(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1073
1073
|
break;
|
|
1074
1074
|
N(s), this.advance();
|
|
1075
1075
|
}
|
|
1076
1076
|
}, this.synchronizeElementDeclarationAlias = () => {
|
|
1077
1077
|
for (; !this.isAtEnd(); ) {
|
|
1078
1078
|
const s = this.peek();
|
|
1079
|
-
if (this.check(
|
|
1079
|
+
if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1080
1080
|
break;
|
|
1081
1081
|
N(s), this.advance();
|
|
1082
1082
|
}
|
|
1083
1083
|
}, this.blockExpression = this.contextStack.withContextDo(Se.BlockExpression, () => {
|
|
1084
|
-
const s = { body: [] }, i = () => this.nodeFactory.create(
|
|
1084
|
+
const s = { body: [] }, i = () => this.nodeFactory.create(J, s);
|
|
1085
1085
|
try {
|
|
1086
|
-
this.consume("Expect an opening brace '{'",
|
|
1086
|
+
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
1087
1087
|
} catch (r) {
|
|
1088
1088
|
if (!(r instanceof d))
|
|
1089
1089
|
throw r;
|
|
@@ -1091,7 +1091,7 @@ class pn {
|
|
|
1091
1091
|
throw new d(r.token, i(), r.handlerContext);
|
|
1092
1092
|
this.synchronizeBlock();
|
|
1093
1093
|
}
|
|
1094
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1094
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACE); )
|
|
1095
1095
|
try {
|
|
1096
1096
|
s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
|
|
1097
1097
|
} catch (r) {
|
|
@@ -1102,7 +1102,7 @@ class pn {
|
|
|
1102
1102
|
this.synchronizeBlock();
|
|
1103
1103
|
}
|
|
1104
1104
|
try {
|
|
1105
|
-
this.consume("Expect a closing brace '}'",
|
|
1105
|
+
this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
|
|
1106
1106
|
} catch (r) {
|
|
1107
1107
|
if (!(r instanceof d))
|
|
1108
1108
|
throw r;
|
|
@@ -1112,10 +1112,10 @@ class pn {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
return i();
|
|
1114
1114
|
}), this.synchronizeBlock = () => {
|
|
1115
|
-
if (!this.check(
|
|
1115
|
+
if (!this.check(u.RBRACE))
|
|
1116
1116
|
for (N(this.advance()); !this.isAtEnd(); ) {
|
|
1117
1117
|
const s = this.peek();
|
|
1118
|
-
if (this.check(
|
|
1118
|
+
if (this.check(u.RBRACE) || ot(this.previous(), s))
|
|
1119
1119
|
break;
|
|
1120
1120
|
N(s), this.advance();
|
|
1121
1121
|
}
|
|
@@ -1124,9 +1124,9 @@ class pn {
|
|
|
1124
1124
|
groupOpenParen: s.tupleOpenParen,
|
|
1125
1125
|
groupCloseParen: s.tupleCloseParen,
|
|
1126
1126
|
expression: s.elementList[0]
|
|
1127
|
-
}), r = () => this.nodeFactory.create(
|
|
1127
|
+
}), r = () => this.nodeFactory.create(Z, s);
|
|
1128
1128
|
try {
|
|
1129
|
-
this.consume("Expect an opening parenthesis '('",
|
|
1129
|
+
this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
|
|
1130
1130
|
} catch (a) {
|
|
1131
1131
|
if (!(a instanceof d))
|
|
1132
1132
|
throw a;
|
|
@@ -1134,7 +1134,7 @@ class pn {
|
|
|
1134
1134
|
throw new d(a.token, r(), a.handlerContext);
|
|
1135
1135
|
this.synchronizeTuple();
|
|
1136
1136
|
}
|
|
1137
|
-
if (!this.isAtEnd() && !this.check(
|
|
1137
|
+
if (!this.isAtEnd() && !this.check(u.RPAREN))
|
|
1138
1138
|
try {
|
|
1139
1139
|
s.elementList.push(this.normalExpression());
|
|
1140
1140
|
} catch (a) {
|
|
@@ -1144,9 +1144,9 @@ class pn {
|
|
|
1144
1144
|
throw new d(a.token, i(), a.handlerContext);
|
|
1145
1145
|
this.synchronizeTuple();
|
|
1146
1146
|
}
|
|
1147
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1147
|
+
for (; !this.isAtEnd() && !this.check(u.RPAREN); )
|
|
1148
1148
|
try {
|
|
1149
|
-
this.consume("Expect a comma ','",
|
|
1149
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
|
|
1150
1150
|
} catch (a) {
|
|
1151
1151
|
if (!(a instanceof d))
|
|
1152
1152
|
throw a;
|
|
@@ -1155,7 +1155,7 @@ class pn {
|
|
|
1155
1155
|
this.synchronizeTuple();
|
|
1156
1156
|
}
|
|
1157
1157
|
try {
|
|
1158
|
-
this.consume("Expect a closing parenthesis ')'",
|
|
1158
|
+
this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
|
|
1159
1159
|
} catch (a) {
|
|
1160
1160
|
if (!(a instanceof d))
|
|
1161
1161
|
throw a;
|
|
@@ -1167,14 +1167,14 @@ class pn {
|
|
|
1167
1167
|
}), this.synchronizeTuple = () => {
|
|
1168
1168
|
for (; !this.isAtEnd(); ) {
|
|
1169
1169
|
const s = this.peek();
|
|
1170
|
-
if (this.check(
|
|
1170
|
+
if (this.check(u.RPAREN, u.COMMA))
|
|
1171
1171
|
break;
|
|
1172
1172
|
N(s), this.advance();
|
|
1173
1173
|
}
|
|
1174
1174
|
}, this.listExpression = this.contextStack.withContextDo(Se.ListExpression, () => {
|
|
1175
1175
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(D, s);
|
|
1176
1176
|
try {
|
|
1177
|
-
this.consume("Expect an opening bracket '['",
|
|
1177
|
+
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
1178
1178
|
} catch (r) {
|
|
1179
1179
|
if (!(r instanceof d))
|
|
1180
1180
|
throw r;
|
|
@@ -1182,7 +1182,7 @@ class pn {
|
|
|
1182
1182
|
throw new d(r.token, i(), r.handlerContext);
|
|
1183
1183
|
this.synchronizeList();
|
|
1184
1184
|
}
|
|
1185
|
-
if (!this.isAtEnd() && !this.check(
|
|
1185
|
+
if (!this.isAtEnd() && !this.check(u.RBRACKET))
|
|
1186
1186
|
try {
|
|
1187
1187
|
s.elementList.push(this.attribute());
|
|
1188
1188
|
} catch (r) {
|
|
@@ -1192,9 +1192,9 @@ class pn {
|
|
|
1192
1192
|
throw new d(r.token, i(), r.handlerContext);
|
|
1193
1193
|
this.synchronizeList();
|
|
1194
1194
|
}
|
|
1195
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1195
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
|
|
1196
1196
|
try {
|
|
1197
|
-
this.consume("Expect a comma ','",
|
|
1197
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
|
|
1198
1198
|
} catch (r) {
|
|
1199
1199
|
if (!(r instanceof d))
|
|
1200
1200
|
throw r;
|
|
@@ -1203,7 +1203,7 @@ class pn {
|
|
|
1203
1203
|
this.synchronizeList();
|
|
1204
1204
|
}
|
|
1205
1205
|
try {
|
|
1206
|
-
this.consume("Expect a closing bracket ']'",
|
|
1206
|
+
this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
|
|
1207
1207
|
} catch (r) {
|
|
1208
1208
|
if (!(r instanceof d))
|
|
1209
1209
|
throw r;
|
|
@@ -1215,28 +1215,28 @@ class pn {
|
|
|
1215
1215
|
}), this.synchronizeList = () => {
|
|
1216
1216
|
for (; !this.isAtEnd(); ) {
|
|
1217
1217
|
const s = this.peek();
|
|
1218
|
-
if (this.check(
|
|
1218
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1219
1219
|
break;
|
|
1220
1220
|
N(s), this.advance();
|
|
1221
1221
|
}
|
|
1222
1222
|
}, this.synchronizeAttributeName = () => {
|
|
1223
1223
|
for (; !this.isAtEnd(); ) {
|
|
1224
1224
|
const s = this.peek();
|
|
1225
|
-
if (this.check(
|
|
1225
|
+
if (this.check(u.COMMA, u.RBRACKET, u.COLON))
|
|
1226
1226
|
break;
|
|
1227
1227
|
N(s), this.advance();
|
|
1228
1228
|
}
|
|
1229
1229
|
}, this.synchronizeAttributeValue = () => {
|
|
1230
1230
|
for (; !this.isAtEnd(); ) {
|
|
1231
1231
|
const s = this.peek();
|
|
1232
|
-
if (this.check(
|
|
1232
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1233
1233
|
break;
|
|
1234
1234
|
N(s), this.advance();
|
|
1235
1235
|
}
|
|
1236
|
-
}, this.tokens = e, this.nodeFactory = new
|
|
1236
|
+
}, this.tokens = e, this.nodeFactory = new pn(n);
|
|
1237
1237
|
}
|
|
1238
1238
|
isAtEnd() {
|
|
1239
|
-
return this.current >= this.tokens.length || this.tokens[this.current].kind ===
|
|
1239
|
+
return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
|
|
1240
1240
|
}
|
|
1241
1241
|
advance() {
|
|
1242
1242
|
return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
|
|
@@ -1289,8 +1289,8 @@ class pn {
|
|
|
1289
1289
|
this.tokens = e;
|
|
1290
1290
|
}
|
|
1291
1291
|
parse() {
|
|
1292
|
-
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(
|
|
1293
|
-
return this.gatherInvalid(), new
|
|
1292
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(X, { body: e, eof: n });
|
|
1293
|
+
return this.gatherInvalid(), new V({ ast: s, tokens: this.tokens }, this.errors);
|
|
1294
1294
|
}
|
|
1295
1295
|
/* Parsing and synchronizing ProgramNode */
|
|
1296
1296
|
program() {
|
|
@@ -1308,13 +1308,13 @@ class pn {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
/* Parsing and synchronizing top-level ElementDeclarationNode */
|
|
1310
1310
|
elementDeclaration() {
|
|
1311
|
-
const e = {}, n = () => this.nodeFactory.create(
|
|
1311
|
+
const e = {}, n = () => this.nodeFactory.create(v, e);
|
|
1312
1312
|
try {
|
|
1313
|
-
this.consume("Expect an identifier",
|
|
1313
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1314
1314
|
} catch (s) {
|
|
1315
1315
|
throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1316
1316
|
}
|
|
1317
|
-
if (!this.check(
|
|
1317
|
+
if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1318
1318
|
try {
|
|
1319
1319
|
e.name = this.normalExpression();
|
|
1320
1320
|
} catch (s) {
|
|
@@ -1324,8 +1324,8 @@ class pn {
|
|
|
1324
1324
|
throw new d(s.token, n(), s.handlerContext);
|
|
1325
1325
|
this.synchronizeElementDeclarationName();
|
|
1326
1326
|
}
|
|
1327
|
-
if (
|
|
1328
|
-
if (e.as = this.advance(), this.check(
|
|
1327
|
+
if (ct(this.peek()))
|
|
1328
|
+
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1329
1329
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1330
1330
|
else
|
|
1331
1331
|
try {
|
|
@@ -1338,27 +1338,27 @@ class pn {
|
|
|
1338
1338
|
this.synchronizeElementDeclarationAlias();
|
|
1339
1339
|
}
|
|
1340
1340
|
try {
|
|
1341
|
-
e.attributeList = this.check(
|
|
1341
|
+
e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
|
|
1342
1342
|
} catch (s) {
|
|
1343
1343
|
throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1344
1344
|
}
|
|
1345
1345
|
if (!this.discardUntil(
|
|
1346
1346
|
"Expect an opening brace '{' or a colon ':'",
|
|
1347
|
-
|
|
1348
|
-
|
|
1347
|
+
u.LBRACE,
|
|
1348
|
+
u.COLON
|
|
1349
1349
|
))
|
|
1350
1350
|
return n();
|
|
1351
1351
|
try {
|
|
1352
|
-
if (this.match(
|
|
1352
|
+
if (this.match(u.COLON)) {
|
|
1353
1353
|
e.bodyColon = this.previous();
|
|
1354
1354
|
const s = this.expression();
|
|
1355
|
-
s instanceof
|
|
1355
|
+
s instanceof v ? (N(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
|
|
1356
1356
|
} else
|
|
1357
1357
|
e.body = this.blockExpression();
|
|
1358
1358
|
} catch (s) {
|
|
1359
1359
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1360
1360
|
}
|
|
1361
|
-
return this.nodeFactory.create(
|
|
1361
|
+
return this.nodeFactory.create(v, e);
|
|
1362
1362
|
}
|
|
1363
1363
|
/* Parsing nested element declarations with simple body */
|
|
1364
1364
|
// e.g
|
|
@@ -1367,28 +1367,28 @@ class pn {
|
|
|
1367
1367
|
// Note: 'This is a note' // fieldDeclaration() handles this
|
|
1368
1368
|
// }
|
|
1369
1369
|
fieldDeclaration() {
|
|
1370
|
-
const e = {}, n = () => this.nodeFactory.create(
|
|
1370
|
+
const e = {}, n = () => this.nodeFactory.create(v, e);
|
|
1371
1371
|
try {
|
|
1372
|
-
this.consume("Expect an identifier",
|
|
1372
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1373
1373
|
} catch (s) {
|
|
1374
1374
|
throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1375
1375
|
}
|
|
1376
1376
|
try {
|
|
1377
|
-
this.consume("Expect a colon ':'",
|
|
1377
|
+
this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
|
|
1378
1378
|
} catch (s) {
|
|
1379
1379
|
throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1380
1380
|
}
|
|
1381
1381
|
try {
|
|
1382
1382
|
const s = this.expression();
|
|
1383
|
-
s instanceof
|
|
1383
|
+
s instanceof v ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1384
1384
|
} catch (s) {
|
|
1385
1385
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1386
1386
|
}
|
|
1387
|
-
return this.nodeFactory.create(
|
|
1387
|
+
return this.nodeFactory.create(v, e);
|
|
1388
1388
|
}
|
|
1389
1389
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1390
1390
|
expression() {
|
|
1391
|
-
const e = { args: [] }, n = () =>
|
|
1391
|
+
const e = { args: [] }, n = () => on(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1392
1392
|
this.nodeFactory.create(y, e)
|
|
1393
1393
|
);
|
|
1394
1394
|
try {
|
|
@@ -1413,7 +1413,7 @@ class pn {
|
|
|
1413
1413
|
if (this.isAtEnd() || bt(this.previous()))
|
|
1414
1414
|
return !0;
|
|
1415
1415
|
const e = this.peek().kind;
|
|
1416
|
-
return e ===
|
|
1416
|
+
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
1417
1417
|
}
|
|
1418
1418
|
normalExpression() {
|
|
1419
1419
|
return this.expression_bp(0);
|
|
@@ -1423,7 +1423,7 @@ class pn {
|
|
|
1423
1423
|
let n = this.leftExpression_bp();
|
|
1424
1424
|
for (; !this.isAtEnd(); ) {
|
|
1425
1425
|
const s = this.peek();
|
|
1426
|
-
if (s.kind ===
|
|
1426
|
+
if (s.kind === u.LPAREN) {
|
|
1427
1427
|
const { left: i } = ut(s);
|
|
1428
1428
|
if (i < e || // When '(' is encountered,
|
|
1429
1429
|
// consider it part of another expression if
|
|
@@ -1442,16 +1442,16 @@ class pn {
|
|
|
1442
1442
|
argumentList: r.partialNode
|
|
1443
1443
|
}), new d(r.token, n, r.handlerContext)) : r;
|
|
1444
1444
|
}
|
|
1445
|
-
} else if (s.kind ===
|
|
1445
|
+
} else if (s.kind === u.LBRACKET) {
|
|
1446
1446
|
if (Ce(this.previous()))
|
|
1447
1447
|
break;
|
|
1448
1448
|
try {
|
|
1449
|
-
n = this.nodeFactory.create(
|
|
1449
|
+
n = this.nodeFactory.create(he, {
|
|
1450
1450
|
expression: n,
|
|
1451
1451
|
indexer: this.listExpression()
|
|
1452
1452
|
});
|
|
1453
1453
|
} catch (i) {
|
|
1454
|
-
throw i instanceof d ? (n = this.nodeFactory.create(
|
|
1454
|
+
throw i instanceof d ? (n = this.nodeFactory.create(he, {
|
|
1455
1455
|
expression: n,
|
|
1456
1456
|
indexer: i.partialNode
|
|
1457
1457
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
@@ -1466,7 +1466,7 @@ class pn {
|
|
|
1466
1466
|
op: i
|
|
1467
1467
|
});
|
|
1468
1468
|
} else {
|
|
1469
|
-
const a =
|
|
1469
|
+
const a = Nn(i);
|
|
1470
1470
|
if (a.left === null || a.left <= e)
|
|
1471
1471
|
break;
|
|
1472
1472
|
this.advance();
|
|
@@ -1476,12 +1476,12 @@ class pn {
|
|
|
1476
1476
|
op: i,
|
|
1477
1477
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1478
1478
|
});
|
|
1479
|
-
} catch (
|
|
1480
|
-
throw
|
|
1479
|
+
} catch (c) {
|
|
1480
|
+
throw c instanceof d ? (n = this.nodeFactory.create(q, {
|
|
1481
1481
|
leftExpression: n,
|
|
1482
1482
|
op: i,
|
|
1483
|
-
rightExpression:
|
|
1484
|
-
}), new d(
|
|
1483
|
+
rightExpression: c.partialNode
|
|
1484
|
+
}), new d(c.token, n, c.handlerContext)) : c;
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
1487
|
} else
|
|
@@ -1494,7 +1494,7 @@ class pn {
|
|
|
1494
1494
|
if (at(this.peek())) {
|
|
1495
1495
|
const n = {};
|
|
1496
1496
|
n.op = this.peek();
|
|
1497
|
-
const s =
|
|
1497
|
+
const s = Tn(n.op);
|
|
1498
1498
|
if (s.right === null)
|
|
1499
1499
|
throw this.logError(
|
|
1500
1500
|
n.op,
|
|
@@ -1530,12 +1530,12 @@ class pn {
|
|
|
1530
1530
|
// e.g { ... }
|
|
1531
1531
|
extractOperand() {
|
|
1532
1532
|
return this.check(
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
) ? this.primaryExpression() : this.check(
|
|
1533
|
+
u.NUMERIC_LITERAL,
|
|
1534
|
+
u.STRING_LITERAL,
|
|
1535
|
+
u.COLOR_LITERAL,
|
|
1536
|
+
u.QUOTED_STRING,
|
|
1537
|
+
u.IDENTIFIER
|
|
1538
|
+
) ? this.primaryExpression() : this.check(u.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(u.LBRACKET) ? this.listExpression() : this.check(u.LBRACE) ? this.blockExpression() : this.check(u.LPAREN) ? this.tupleExpression() : (this.peek().kind === u.EOF ? this.logError(
|
|
1539
1539
|
this.peek(),
|
|
1540
1540
|
o.UNEXPECTED_EOF,
|
|
1541
1541
|
"Unexpected EOF"
|
|
@@ -1549,32 +1549,32 @@ class pn {
|
|
|
1549
1549
|
functionExpression() {
|
|
1550
1550
|
const e = {};
|
|
1551
1551
|
try {
|
|
1552
|
-
this.consume("Expect a function expression",
|
|
1552
|
+
this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
|
|
1553
1553
|
} catch (n) {
|
|
1554
1554
|
throw n instanceof d ? (e.value = n.partialNode, new d(
|
|
1555
1555
|
n.token,
|
|
1556
|
-
this.nodeFactory.create(
|
|
1556
|
+
this.nodeFactory.create(ne, e),
|
|
1557
1557
|
n.handlerContext
|
|
1558
1558
|
)) : n;
|
|
1559
1559
|
}
|
|
1560
|
-
return this.nodeFactory.create(
|
|
1560
|
+
return this.nodeFactory.create(ne, e);
|
|
1561
1561
|
}
|
|
1562
1562
|
canBeField() {
|
|
1563
|
-
return this.peek().kind ===
|
|
1563
|
+
return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
|
|
1564
1564
|
}
|
|
1565
1565
|
/* Parsing PrimaryExpression */
|
|
1566
1566
|
primaryExpression() {
|
|
1567
1567
|
if (this.match(
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1568
|
+
u.COLOR_LITERAL,
|
|
1569
|
+
u.STRING_LITERAL,
|
|
1570
|
+
u.NUMERIC_LITERAL
|
|
1571
1571
|
))
|
|
1572
1572
|
return this.nodeFactory.create(U, {
|
|
1573
1573
|
expression: this.nodeFactory.create(be, { literal: this.previous() })
|
|
1574
1574
|
});
|
|
1575
|
-
if (this.match(
|
|
1575
|
+
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1576
1576
|
return this.nodeFactory.create(U, {
|
|
1577
|
-
expression: this.nodeFactory.create(
|
|
1577
|
+
expression: this.nodeFactory.create(K, { variable: this.previous() })
|
|
1578
1578
|
});
|
|
1579
1579
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1580
1580
|
this.peek(),
|
|
@@ -1584,13 +1584,13 @@ class pn {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
attribute() {
|
|
1586
1586
|
const e = {};
|
|
1587
|
-
if (this.check(
|
|
1587
|
+
if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
|
|
1588
1588
|
const n = this.peek();
|
|
1589
1589
|
this.logError(
|
|
1590
1590
|
n,
|
|
1591
1591
|
o.EMPTY_ATTRIBUTE_NAME,
|
|
1592
1592
|
"Expect a non-empty attribute name"
|
|
1593
|
-
), e.name = this.nodeFactory.create(
|
|
1593
|
+
), e.name = this.nodeFactory.create(Y, { identifiers: [] });
|
|
1594
1594
|
} else
|
|
1595
1595
|
try {
|
|
1596
1596
|
e.name = this.attributeName();
|
|
@@ -1605,12 +1605,12 @@ class pn {
|
|
|
1605
1605
|
);
|
|
1606
1606
|
this.synchronizeAttributeName();
|
|
1607
1607
|
}
|
|
1608
|
-
return this.match(
|
|
1608
|
+
return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
|
|
1609
1609
|
}
|
|
1610
1610
|
attributeValue() {
|
|
1611
1611
|
let e;
|
|
1612
1612
|
try {
|
|
1613
|
-
e = this.peek().kind ===
|
|
1613
|
+
e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
|
|
1614
1614
|
} catch (n) {
|
|
1615
1615
|
if (!(n instanceof d) || !this.canHandle(n))
|
|
1616
1616
|
throw n;
|
|
@@ -1620,25 +1620,25 @@ class pn {
|
|
|
1620
1620
|
}
|
|
1621
1621
|
attributeName() {
|
|
1622
1622
|
const e = [];
|
|
1623
|
-
if (this.peek().kind !==
|
|
1623
|
+
if (this.peek().kind !== u.IDENTIFIER)
|
|
1624
1624
|
return this.primaryExpression();
|
|
1625
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1625
|
+
for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
|
|
1626
1626
|
try {
|
|
1627
|
-
this.consume("Expect an identifier",
|
|
1627
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
|
|
1628
1628
|
} catch (n) {
|
|
1629
1629
|
throw n instanceof d ? new d(
|
|
1630
1630
|
n.token,
|
|
1631
|
-
this.nodeFactory.create(
|
|
1631
|
+
this.nodeFactory.create(Y, { identifiers: e }),
|
|
1632
1632
|
n.handlerContext
|
|
1633
1633
|
) : n;
|
|
1634
1634
|
}
|
|
1635
|
-
return this.nodeFactory.create(
|
|
1635
|
+
return this.nodeFactory.create(Y, { identifiers: e });
|
|
1636
1636
|
}
|
|
1637
1637
|
logError(e, n, s) {
|
|
1638
|
-
this.errors.push(new
|
|
1638
|
+
this.errors.push(new l(n, s, e));
|
|
1639
1639
|
}
|
|
1640
1640
|
}
|
|
1641
|
-
const
|
|
1641
|
+
const En = {
|
|
1642
1642
|
"+": { left: 9, right: 10 },
|
|
1643
1643
|
"*": { left: 11, right: 12 },
|
|
1644
1644
|
"-": { left: 9, right: 10 },
|
|
@@ -1654,10 +1654,10 @@ const dn = {
|
|
|
1654
1654
|
"!=": { left: 4, right: 5 },
|
|
1655
1655
|
".": { left: 16, right: 17 }
|
|
1656
1656
|
};
|
|
1657
|
-
function
|
|
1658
|
-
return
|
|
1657
|
+
function Nn(t) {
|
|
1658
|
+
return En[t.value] || { left: null, right: null };
|
|
1659
1659
|
}
|
|
1660
|
-
const
|
|
1660
|
+
const mn = {
|
|
1661
1661
|
"+": { left: null, right: 15 },
|
|
1662
1662
|
"-": { left: null, right: 15 },
|
|
1663
1663
|
"<": { left: null, right: 15 },
|
|
@@ -1665,14 +1665,14 @@ const Nn = {
|
|
|
1665
1665
|
"<>": { left: null, right: 15 },
|
|
1666
1666
|
"!": { left: null, right: 15 }
|
|
1667
1667
|
};
|
|
1668
|
-
function
|
|
1669
|
-
return
|
|
1668
|
+
function Tn(t) {
|
|
1669
|
+
return mn[t.value] || { left: null, right: null };
|
|
1670
1670
|
}
|
|
1671
|
-
const
|
|
1671
|
+
const bn = {
|
|
1672
1672
|
"(": { left: 14, right: null }
|
|
1673
1673
|
};
|
|
1674
1674
|
function ut(t) {
|
|
1675
|
-
return
|
|
1675
|
+
return bn[t.value] || { left: null, right: null };
|
|
1676
1676
|
}
|
|
1677
1677
|
var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
|
|
1678
1678
|
function ve(t) {
|
|
@@ -1688,51 +1688,51 @@ function ve(t) {
|
|
|
1688
1688
|
case b.TableGroup:
|
|
1689
1689
|
return new S(e);
|
|
1690
1690
|
default:
|
|
1691
|
-
return new
|
|
1691
|
+
return new k();
|
|
1692
1692
|
}
|
|
1693
1693
|
}
|
|
1694
|
-
function
|
|
1694
|
+
function pe(t) {
|
|
1695
1695
|
if (!Je(t))
|
|
1696
1696
|
return new S([t]);
|
|
1697
|
-
const e =
|
|
1698
|
-
return e ? (e.push(t.rightExpression), new S(e)) : new
|
|
1697
|
+
const e = pe(t.leftExpression).unwrap_or(void 0);
|
|
1698
|
+
return e ? (e.push(t.rightExpression), new S(e)) : new k();
|
|
1699
1699
|
}
|
|
1700
|
-
function
|
|
1700
|
+
function W(t) {
|
|
1701
1701
|
if (t === void 0)
|
|
1702
|
-
return new
|
|
1703
|
-
const e =
|
|
1702
|
+
return new k();
|
|
1703
|
+
const e = pe(t).unwrap_or(void 0);
|
|
1704
1704
|
if (!e)
|
|
1705
|
-
return new
|
|
1705
|
+
return new k();
|
|
1706
1706
|
const n = [];
|
|
1707
1707
|
for (const s of e) {
|
|
1708
|
-
const i =
|
|
1708
|
+
const i = j(s).unwrap_or(void 0);
|
|
1709
1709
|
if (!i)
|
|
1710
|
-
return new
|
|
1710
|
+
return new k();
|
|
1711
1711
|
n.push(i);
|
|
1712
1712
|
}
|
|
1713
1713
|
return new S(n);
|
|
1714
1714
|
}
|
|
1715
1715
|
function _e(t) {
|
|
1716
1716
|
if (t === void 0)
|
|
1717
|
-
return new
|
|
1718
|
-
const e =
|
|
1717
|
+
return new k();
|
|
1718
|
+
const e = pe(t).unwrap_or(void 0);
|
|
1719
1719
|
if (!e || e.length === 0)
|
|
1720
|
-
return new
|
|
1720
|
+
return new k();
|
|
1721
1721
|
const n = [];
|
|
1722
1722
|
let s;
|
|
1723
1723
|
if (!M(I.last(e))) {
|
|
1724
1724
|
const i = e.pop();
|
|
1725
1725
|
if (xt(i))
|
|
1726
1726
|
s = i.elementList.map(
|
|
1727
|
-
(r) =>
|
|
1727
|
+
(r) => C(r).unwrap()
|
|
1728
1728
|
);
|
|
1729
1729
|
else
|
|
1730
|
-
return new
|
|
1730
|
+
return new k();
|
|
1731
1731
|
}
|
|
1732
1732
|
for (const i of e) {
|
|
1733
|
-
const r =
|
|
1733
|
+
const r = j(i).unwrap_or(void 0);
|
|
1734
1734
|
if (!r)
|
|
1735
|
-
return new
|
|
1735
|
+
return new k();
|
|
1736
1736
|
n.push(r);
|
|
1737
1737
|
}
|
|
1738
1738
|
return new S({
|
|
@@ -1740,33 +1740,33 @@ function _e(t) {
|
|
|
1740
1740
|
tupleElements: s
|
|
1741
1741
|
});
|
|
1742
1742
|
}
|
|
1743
|
-
function
|
|
1744
|
-
return M(t) ? new S(t.expression.variable.value) : new
|
|
1743
|
+
function j(t) {
|
|
1744
|
+
return M(t) ? new S(t.expression.variable.value) : new k();
|
|
1745
1745
|
}
|
|
1746
1746
|
function Xe(t) {
|
|
1747
1747
|
if (ht(t))
|
|
1748
|
-
return t instanceof
|
|
1749
|
-
if (t instanceof
|
|
1748
|
+
return t instanceof ne ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1749
|
+
if (t instanceof Z && t.elementList.every(ht)) {
|
|
1750
1750
|
const e = t.elementList.filter(
|
|
1751
|
-
(s) => s instanceof
|
|
1751
|
+
(s) => s instanceof ne
|
|
1752
1752
|
), n = t.elementList.filter(M);
|
|
1753
1753
|
return new S({ functional: e, nonFunctional: n });
|
|
1754
1754
|
}
|
|
1755
|
-
return new
|
|
1755
|
+
return new k();
|
|
1756
1756
|
}
|
|
1757
|
-
function
|
|
1757
|
+
function C(t) {
|
|
1758
1758
|
var n;
|
|
1759
1759
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1760
|
-
return e === void 0 ? new
|
|
1760
|
+
return e === void 0 ? new k() : new S(e);
|
|
1761
1761
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return
|
|
1762
|
+
function G(t) {
|
|
1763
|
+
return $(t) ? t.expression instanceof K ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new k();
|
|
1764
1764
|
}
|
|
1765
|
-
function
|
|
1765
|
+
function In(t) {
|
|
1766
1766
|
var e;
|
|
1767
1767
|
return !(t instanceof q) || !kt((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1768
1768
|
}
|
|
1769
|
-
function
|
|
1769
|
+
function Ln(t) {
|
|
1770
1770
|
const e = _e(t.leftExpression), n = _e(t.rightExpression);
|
|
1771
1771
|
if (!e.isOk() || !n.isOk())
|
|
1772
1772
|
return !1;
|
|
@@ -1774,23 +1774,23 @@ function In(t) {
|
|
|
1774
1774
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1775
1775
|
}
|
|
1776
1776
|
function ht(t) {
|
|
1777
|
-
return t instanceof U && t.expression instanceof
|
|
1777
|
+
return t instanceof U && t.expression instanceof K || t instanceof ne;
|
|
1778
1778
|
}
|
|
1779
|
-
function
|
|
1780
|
-
var i, r, a,
|
|
1779
|
+
function gn(t, e) {
|
|
1780
|
+
var i, r, a, c;
|
|
1781
1781
|
let n = e;
|
|
1782
|
-
const s =
|
|
1782
|
+
const s = Jt(t);
|
|
1783
1783
|
for (; n; ) {
|
|
1784
1784
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1785
1785
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1786
|
-
if (((
|
|
1786
|
+
if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof X && s)
|
|
1787
1787
|
return n.symbol;
|
|
1788
|
-
if (n instanceof
|
|
1788
|
+
if (n instanceof X)
|
|
1789
1789
|
return;
|
|
1790
1790
|
n = n.parent;
|
|
1791
1791
|
}
|
|
1792
1792
|
}
|
|
1793
|
-
class
|
|
1793
|
+
class _n {
|
|
1794
1794
|
constructor(e, n, s) {
|
|
1795
1795
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1796
1796
|
}
|
|
@@ -1798,24 +1798,24 @@ class gn {
|
|
|
1798
1798
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1799
1799
|
}
|
|
1800
1800
|
validateContext() {
|
|
1801
|
-
return this.declarationNode.parent instanceof
|
|
1801
|
+
return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1802
1802
|
}
|
|
1803
1803
|
validateName(e) {
|
|
1804
|
-
return e ? [new
|
|
1804
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
1805
1805
|
}
|
|
1806
1806
|
validateAlias(e) {
|
|
1807
|
-
return e ? [new
|
|
1807
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
|
|
1808
1808
|
}
|
|
1809
1809
|
validateSettingList(e) {
|
|
1810
|
-
return e ? [new
|
|
1810
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
|
|
1811
1811
|
}
|
|
1812
1812
|
validateBody(e) {
|
|
1813
1813
|
if (!e)
|
|
1814
1814
|
return [];
|
|
1815
|
-
if (e instanceof
|
|
1816
|
-
return [new
|
|
1815
|
+
if (e instanceof J)
|
|
1816
|
+
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1817
1817
|
const n = [];
|
|
1818
|
-
return
|
|
1818
|
+
return $(e.callee) || n.push(new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
1821
|
class we {
|
|
@@ -1835,7 +1835,7 @@ class we {
|
|
|
1835
1835
|
return this.table.entries();
|
|
1836
1836
|
}
|
|
1837
1837
|
}
|
|
1838
|
-
class
|
|
1838
|
+
class An {
|
|
1839
1839
|
constructor(e, n, s) {
|
|
1840
1840
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1841
1841
|
}
|
|
@@ -1843,26 +1843,26 @@ class _n {
|
|
|
1843
1843
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
1844
1844
|
}
|
|
1845
1845
|
validateContext() {
|
|
1846
|
-
return this.declarationNode.parent instanceof
|
|
1846
|
+
return this.declarationNode.parent instanceof v ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1847
1847
|
}
|
|
1848
1848
|
validateName(e) {
|
|
1849
|
-
return e ? yt(e) ? [] : [new
|
|
1849
|
+
return e ? yt(e) ? [] : [new l(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new l(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
1850
1850
|
}
|
|
1851
1851
|
validateAlias(e) {
|
|
1852
|
-
return e ? [new
|
|
1852
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1853
1853
|
}
|
|
1854
1854
|
registerElement() {
|
|
1855
1855
|
const e = [];
|
|
1856
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1857
|
-
const { name: n } = this.declarationNode, s =
|
|
1856
|
+
this.declarationNode.symbol = this.symbolFactory.create(tn, { declaration: this.declarationNode, symbolTable: new we() });
|
|
1857
|
+
const { name: n } = this.declarationNode, s = W(n);
|
|
1858
1858
|
if (s.isOk()) {
|
|
1859
|
-
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory),
|
|
1860
|
-
a.has(
|
|
1859
|
+
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = ze(r);
|
|
1860
|
+
a.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(c, this.declarationNode.symbol);
|
|
1861
1861
|
}
|
|
1862
1862
|
return e;
|
|
1863
1863
|
}
|
|
1864
1864
|
validateSettingList(e) {
|
|
1865
|
-
return e ? [new
|
|
1865
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
|
|
1866
1866
|
}
|
|
1867
1867
|
validateBody(e) {
|
|
1868
1868
|
if (!e)
|
|
@@ -1873,25 +1873,25 @@ class _n {
|
|
|
1873
1873
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1874
1874
|
}
|
|
1875
1875
|
validateFields(e) {
|
|
1876
|
-
return e.length === 0 ? [new
|
|
1876
|
+
return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1877
1877
|
const s = [];
|
|
1878
|
-
n.callee && !M(n.callee) && s.push(new
|
|
1878
|
+
n.callee && !M(n.callee) && s.push(new l(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1879
1879
|
const i = [...n.args];
|
|
1880
|
-
return I.last(i) instanceof D ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof D && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new
|
|
1880
|
+
return I.last(i) instanceof D ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof D && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1881
1881
|
});
|
|
1882
1882
|
}
|
|
1883
1883
|
validateFieldSettings(e) {
|
|
1884
|
-
const n =
|
|
1884
|
+
const n = B(e), s = n.getErrors(), i = n.getValue();
|
|
1885
1885
|
for (const r in i) {
|
|
1886
1886
|
const a = i[r];
|
|
1887
1887
|
switch (r) {
|
|
1888
1888
|
case "note":
|
|
1889
|
-
a.length > 1 && a.forEach((
|
|
1890
|
-
|
|
1889
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
1890
|
+
$(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1891
1891
|
});
|
|
1892
1892
|
break;
|
|
1893
1893
|
default:
|
|
1894
|
-
a.forEach((
|
|
1894
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, c)));
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
return s;
|
|
@@ -1900,20 +1900,20 @@ class _n {
|
|
|
1900
1900
|
return e.flatMap((n) => {
|
|
1901
1901
|
if (n.parent = this.declarationNode, !n.type)
|
|
1902
1902
|
return [];
|
|
1903
|
-
const s =
|
|
1903
|
+
const s = ae(n);
|
|
1904
1904
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1905
1905
|
});
|
|
1906
1906
|
}
|
|
1907
1907
|
registerField(e) {
|
|
1908
1908
|
if (e.callee && M(e.callee)) {
|
|
1909
|
-
const n =
|
|
1909
|
+
const n = C(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(nn, { declaration: e });
|
|
1910
1910
|
e.symbol = i;
|
|
1911
1911
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1912
1912
|
if (r.has(s)) {
|
|
1913
1913
|
const a = r.get(s);
|
|
1914
1914
|
return [
|
|
1915
|
-
new
|
|
1916
|
-
new
|
|
1915
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
|
|
1916
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
|
|
1917
1917
|
];
|
|
1918
1918
|
}
|
|
1919
1919
|
r.set(s, i);
|
|
@@ -1921,7 +1921,7 @@ class _n {
|
|
|
1921
1921
|
return [];
|
|
1922
1922
|
}
|
|
1923
1923
|
}
|
|
1924
|
-
class
|
|
1924
|
+
class vn {
|
|
1925
1925
|
constructor(e, n, s) {
|
|
1926
1926
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1927
1927
|
}
|
|
@@ -1929,22 +1929,22 @@ class An {
|
|
|
1929
1929
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1930
1930
|
}
|
|
1931
1931
|
validateContext() {
|
|
1932
|
-
return this.declarationNode.parent instanceof
|
|
1932
|
+
return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new l(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1933
1933
|
}
|
|
1934
1934
|
validateName(e) {
|
|
1935
|
-
return e ? [new
|
|
1935
|
+
return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
1936
1936
|
}
|
|
1937
1937
|
validateAlias(e) {
|
|
1938
|
-
return e ? [new
|
|
1938
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
|
|
1939
1939
|
}
|
|
1940
1940
|
validateSettingList(e) {
|
|
1941
|
-
return e ? [new
|
|
1941
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
|
|
1942
1942
|
}
|
|
1943
1943
|
validateBody(e) {
|
|
1944
1944
|
if (!e)
|
|
1945
1945
|
return [];
|
|
1946
1946
|
if (e instanceof y)
|
|
1947
|
-
return [new
|
|
1947
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1948
1948
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
1949
1949
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1950
1950
|
}
|
|
@@ -1955,35 +1955,35 @@ class An {
|
|
|
1955
1955
|
const s = [], i = [n.callee, ...n.args];
|
|
1956
1956
|
return I.last(i) instanceof D && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1957
1957
|
for (; r instanceof H; )
|
|
1958
|
-
r.argumentList && !Xe(r.argumentList).isOk() && s.push(new
|
|
1959
|
-
Xe(r).isOk() || s.push(new
|
|
1958
|
+
r.argumentList && !Xe(r.argumentList).isOk() && s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
|
|
1959
|
+
Xe(r).isOk() || s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
1960
1960
|
}), s;
|
|
1961
1961
|
});
|
|
1962
1962
|
}
|
|
1963
1963
|
validateFieldSetting(e) {
|
|
1964
|
-
const n =
|
|
1964
|
+
const n = B(e), s = n.getErrors(), i = n.getValue();
|
|
1965
1965
|
for (const r in i) {
|
|
1966
1966
|
const a = i[r];
|
|
1967
1967
|
switch (r) {
|
|
1968
1968
|
case "note":
|
|
1969
1969
|
case "name":
|
|
1970
|
-
a.length > 1 && a.forEach((
|
|
1971
|
-
|
|
1970
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1971
|
+
$(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
|
|
1972
1972
|
});
|
|
1973
1973
|
break;
|
|
1974
1974
|
case "unique":
|
|
1975
1975
|
case "pk":
|
|
1976
|
-
a.length > 1 && a.forEach((
|
|
1977
|
-
|
|
1976
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1977
|
+
ue(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
|
|
1978
1978
|
});
|
|
1979
1979
|
break;
|
|
1980
1980
|
case "type":
|
|
1981
|
-
a.length > 1 && a.forEach((
|
|
1982
|
-
M(
|
|
1981
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), a.forEach((c) => {
|
|
1982
|
+
M(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
|
|
1983
1983
|
});
|
|
1984
1984
|
break;
|
|
1985
1985
|
default:
|
|
1986
|
-
a.forEach((
|
|
1986
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, c)));
|
|
1987
1987
|
}
|
|
1988
1988
|
}
|
|
1989
1989
|
return s;
|
|
@@ -1992,37 +1992,51 @@ class An {
|
|
|
1992
1992
|
return e.flatMap((n) => {
|
|
1993
1993
|
if (n.parent = this.declarationNode, !n.type)
|
|
1994
1994
|
return [];
|
|
1995
|
-
const s =
|
|
1995
|
+
const s = ae(n);
|
|
1996
1996
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1997
1997
|
});
|
|
1998
1998
|
}
|
|
1999
1999
|
}
|
|
2000
|
-
class
|
|
2000
|
+
class wn {
|
|
2001
2001
|
constructor(e, n, s) {
|
|
2002
2002
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2003
2003
|
}
|
|
2004
2004
|
validate() {
|
|
2005
|
-
return [
|
|
2005
|
+
return [
|
|
2006
|
+
...this.validateContext(),
|
|
2007
|
+
...this.validateName(this.declarationNode.name),
|
|
2008
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2009
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2010
|
+
...this.validateBody(this.declarationNode.body)
|
|
2011
|
+
];
|
|
2006
2012
|
}
|
|
2007
2013
|
validateContext() {
|
|
2008
|
-
return !(this.declarationNode.parent instanceof
|
|
2014
|
+
return !(this.declarationNode.parent instanceof X) && ![
|
|
2015
|
+
b.Table,
|
|
2016
|
+
b.TableGroup,
|
|
2017
|
+
b.Project
|
|
2018
|
+
].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
|
|
2019
|
+
o.INVALID_NOTE_CONTEXT,
|
|
2020
|
+
"A Note can only appear inside a Table, a Table Group or a Project. Sticky note can only appear at the global scope.",
|
|
2021
|
+
this.declarationNode
|
|
2022
|
+
)] : [];
|
|
2009
2023
|
}
|
|
2010
2024
|
validateName(e) {
|
|
2011
|
-
if (!(this.declarationNode.parent instanceof
|
|
2012
|
-
return e ? [new
|
|
2025
|
+
if (!(this.declarationNode.parent instanceof X))
|
|
2026
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2013
2027
|
if (!e)
|
|
2014
|
-
return [new
|
|
2015
|
-
const n =
|
|
2028
|
+
return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2029
|
+
const n = W(e);
|
|
2016
2030
|
if (!n.isOk())
|
|
2017
|
-
return [new
|
|
2018
|
-
const i = n.unwrap().join("."), r =
|
|
2019
|
-
return this.publicSymbolTable.has(r) ? [new
|
|
2031
|
+
return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2032
|
+
const i = n.unwrap().join("."), r = Ht(i);
|
|
2033
|
+
return this.publicSymbolTable.has(r) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
|
|
2020
2034
|
}
|
|
2021
2035
|
validateAlias(e) {
|
|
2022
|
-
return e ? [new
|
|
2036
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2023
2037
|
}
|
|
2024
2038
|
validateSettingList(e) {
|
|
2025
|
-
return e ? [new
|
|
2039
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
|
|
2026
2040
|
}
|
|
2027
2041
|
validateBody(e) {
|
|
2028
2042
|
if (!e)
|
|
@@ -2034,18 +2048,18 @@ class vn {
|
|
|
2034
2048
|
}
|
|
2035
2049
|
validateFields(e) {
|
|
2036
2050
|
const n = [];
|
|
2037
|
-
return e.length === 0 ? [new
|
|
2051
|
+
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2038
2052
|
}
|
|
2039
2053
|
validateSubElements(e) {
|
|
2040
2054
|
return e.flatMap((n) => {
|
|
2041
2055
|
if (n.parent = this.declarationNode, !n.type)
|
|
2042
2056
|
return [];
|
|
2043
|
-
const s =
|
|
2057
|
+
const s = ae(n);
|
|
2044
2058
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2045
2059
|
});
|
|
2046
2060
|
}
|
|
2047
2061
|
}
|
|
2048
|
-
class
|
|
2062
|
+
class yn {
|
|
2049
2063
|
constructor(e, n, s) {
|
|
2050
2064
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2051
2065
|
}
|
|
@@ -2053,25 +2067,25 @@ class wn {
|
|
|
2053
2067
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2054
2068
|
}
|
|
2055
2069
|
validateContext() {
|
|
2056
|
-
return this.declarationNode.parent instanceof
|
|
2070
|
+
return this.declarationNode.parent instanceof v ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2057
2071
|
}
|
|
2058
2072
|
validateName(e) {
|
|
2059
|
-
return e ? ye(e) ? [] : [new
|
|
2073
|
+
return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2060
2074
|
}
|
|
2061
2075
|
validateAlias(e) {
|
|
2062
|
-
return e ? [new
|
|
2076
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
2063
2077
|
}
|
|
2064
2078
|
validateSettingList(e) {
|
|
2065
|
-
return e ? [new
|
|
2079
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
|
|
2066
2080
|
}
|
|
2067
2081
|
validateBody(e) {
|
|
2068
2082
|
if (!e)
|
|
2069
2083
|
return [];
|
|
2070
2084
|
if (e instanceof y)
|
|
2071
|
-
return [new
|
|
2085
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2072
2086
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2073
2087
|
return [
|
|
2074
|
-
...n.map((i) => new
|
|
2088
|
+
...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2075
2089
|
...this.validateSubElements(s)
|
|
2076
2090
|
];
|
|
2077
2091
|
}
|
|
@@ -2079,12 +2093,12 @@ class wn {
|
|
|
2079
2093
|
return e.flatMap((n) => {
|
|
2080
2094
|
if (n.parent = this.declarationNode, !n.type)
|
|
2081
2095
|
return [];
|
|
2082
|
-
const s =
|
|
2096
|
+
const s = ae(n);
|
|
2083
2097
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2084
2098
|
});
|
|
2085
2099
|
}
|
|
2086
2100
|
}
|
|
2087
|
-
class
|
|
2101
|
+
class kn {
|
|
2088
2102
|
constructor(e, n, s) {
|
|
2089
2103
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2090
2104
|
}
|
|
@@ -2092,16 +2106,16 @@ class yn {
|
|
|
2092
2106
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2093
2107
|
}
|
|
2094
2108
|
validateContext() {
|
|
2095
|
-
return this.declarationNode.parent instanceof
|
|
2109
|
+
return this.declarationNode.parent instanceof X ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2096
2110
|
}
|
|
2097
2111
|
validateName(e) {
|
|
2098
|
-
return e ? ye(e) ? [] : [new
|
|
2112
|
+
return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2099
2113
|
}
|
|
2100
2114
|
validateAlias(e) {
|
|
2101
|
-
return e ? [new
|
|
2115
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2102
2116
|
}
|
|
2103
2117
|
validateSettingList(e) {
|
|
2104
|
-
return e ? [new
|
|
2118
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
|
|
2105
2119
|
}
|
|
2106
2120
|
validateBody(e) {
|
|
2107
2121
|
if (!e)
|
|
@@ -2113,27 +2127,27 @@ class yn {
|
|
|
2113
2127
|
}
|
|
2114
2128
|
validateFields(e) {
|
|
2115
2129
|
if (e.length === 0)
|
|
2116
|
-
return [new
|
|
2130
|
+
return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2117
2131
|
const n = [];
|
|
2118
|
-
return e.length > 1 && n.push(...e.slice(1).map((s) => new
|
|
2119
|
-
s.callee && !
|
|
2132
|
+
return e.length > 1 && n.push(...e.slice(1).map((s) => new l(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2133
|
+
s.callee && !In(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Ln(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2120
2134
|
const i = [...s.args];
|
|
2121
|
-
I.last(i) instanceof D ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof D && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new
|
|
2135
|
+
I.last(i) instanceof D ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof D && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2122
2136
|
}), n;
|
|
2123
2137
|
}
|
|
2124
2138
|
validateFieldSettings(e) {
|
|
2125
|
-
const n =
|
|
2139
|
+
const n = B(e), s = n.getErrors(), i = n.getValue();
|
|
2126
2140
|
for (const r in i) {
|
|
2127
2141
|
const a = i[r];
|
|
2128
2142
|
switch (r) {
|
|
2129
2143
|
case "delete":
|
|
2130
2144
|
case "update":
|
|
2131
|
-
a.length > 1 && a.forEach((
|
|
2132
|
-
|
|
2145
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
2146
|
+
xn(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
|
|
2133
2147
|
});
|
|
2134
2148
|
break;
|
|
2135
2149
|
default:
|
|
2136
|
-
a.forEach((
|
|
2150
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, c)));
|
|
2137
2151
|
}
|
|
2138
2152
|
}
|
|
2139
2153
|
return s;
|
|
@@ -2142,16 +2156,16 @@ class yn {
|
|
|
2142
2156
|
return e.flatMap((n) => {
|
|
2143
2157
|
if (n.parent = this.declarationNode, !n.type)
|
|
2144
2158
|
return [];
|
|
2145
|
-
const s =
|
|
2159
|
+
const s = ae(n);
|
|
2146
2160
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2147
2161
|
});
|
|
2148
2162
|
}
|
|
2149
2163
|
}
|
|
2150
|
-
function
|
|
2151
|
-
if (!(M(t) && t.expression.variable.kind !==
|
|
2164
|
+
function xn(t) {
|
|
2165
|
+
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof Y))
|
|
2152
2166
|
return !1;
|
|
2153
2167
|
let e;
|
|
2154
|
-
if (t instanceof
|
|
2168
|
+
if (t instanceof Y ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2155
2169
|
switch (e.toLowerCase()) {
|
|
2156
2170
|
case "cascade":
|
|
2157
2171
|
case "no action":
|
|
@@ -2164,7 +2178,7 @@ function kn(t) {
|
|
|
2164
2178
|
}
|
|
2165
2179
|
return !1;
|
|
2166
2180
|
}
|
|
2167
|
-
class
|
|
2181
|
+
class Sn {
|
|
2168
2182
|
constructor(e, n, s) {
|
|
2169
2183
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2170
2184
|
}
|
|
@@ -2172,31 +2186,31 @@ class xn {
|
|
|
2172
2186
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
2173
2187
|
}
|
|
2174
2188
|
validateContext() {
|
|
2175
|
-
return this.declarationNode.parent instanceof
|
|
2189
|
+
return this.declarationNode.parent instanceof v ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2176
2190
|
}
|
|
2177
2191
|
validateName(e) {
|
|
2178
|
-
return e ? e instanceof
|
|
2192
|
+
return e ? e instanceof he ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : yt(e) ? [] : [new l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2179
2193
|
}
|
|
2180
2194
|
validateAlias(e) {
|
|
2181
|
-
return e ?
|
|
2195
|
+
return e ? Pn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2182
2196
|
}
|
|
2183
2197
|
validateSettingList(e) {
|
|
2184
|
-
const n =
|
|
2198
|
+
const n = B(e), s = n.getErrors(), i = n.getValue();
|
|
2185
2199
|
for (const r in i) {
|
|
2186
2200
|
const a = i[r];
|
|
2187
2201
|
switch (r) {
|
|
2188
2202
|
case "headercolor":
|
|
2189
|
-
a.length > 1 && s.push(...a.map((
|
|
2190
|
-
|
|
2203
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
|
|
2204
|
+
Un(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
|
|
2191
2205
|
});
|
|
2192
2206
|
break;
|
|
2193
2207
|
case "note":
|
|
2194
|
-
a.length > 1 && s.push(...a.map((
|
|
2195
|
-
|
|
2208
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
2209
|
+
$(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2196
2210
|
});
|
|
2197
2211
|
break;
|
|
2198
2212
|
default:
|
|
2199
|
-
s.push(...a.map((
|
|
2213
|
+
s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
|
|
2200
2214
|
}
|
|
2201
2215
|
}
|
|
2202
2216
|
return s;
|
|
@@ -2204,14 +2218,14 @@ class xn {
|
|
|
2204
2218
|
registerElement() {
|
|
2205
2219
|
const e = [];
|
|
2206
2220
|
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2207
|
-
const { name: n, alias: s } = this.declarationNode, i =
|
|
2221
|
+
const { name: n, alias: s } = this.declarationNode, i = W(n);
|
|
2208
2222
|
if (i.isOk()) {
|
|
2209
|
-
const r = [...i.unwrap()], a = r.pop(),
|
|
2210
|
-
|
|
2223
|
+
const r = [...i.unwrap()], a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
|
|
2224
|
+
c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), c.set(p, this.declarationNode.symbol);
|
|
2211
2225
|
}
|
|
2212
|
-
if (s && ye(s) && !
|
|
2213
|
-
const r =
|
|
2214
|
-
this.publicSymbolTable.has(a) && e.push(new
|
|
2226
|
+
if (s && ye(s) && !Rn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2227
|
+
const r = C(s).unwrap(), a = Oe(r);
|
|
2228
|
+
this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2215
2229
|
}
|
|
2216
2230
|
return e;
|
|
2217
2231
|
}
|
|
@@ -2219,30 +2233,30 @@ class xn {
|
|
|
2219
2233
|
if (!e)
|
|
2220
2234
|
return [];
|
|
2221
2235
|
if (e instanceof y)
|
|
2222
|
-
return [new
|
|
2236
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2223
2237
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2224
2238
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2225
2239
|
}
|
|
2226
2240
|
validateFields(e) {
|
|
2227
|
-
return e.length === 0 ? [new
|
|
2241
|
+
return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
|
|
2228
2242
|
if (!n.callee)
|
|
2229
2243
|
return [];
|
|
2230
2244
|
const s = [];
|
|
2231
|
-
n.args.length === 0 && s.push(new
|
|
2245
|
+
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !On(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2232
2246
|
const i = n.args.slice(1);
|
|
2233
2247
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2234
2248
|
});
|
|
2235
2249
|
}
|
|
2236
2250
|
registerField(e) {
|
|
2237
2251
|
if (e.callee && M(e.callee)) {
|
|
2238
|
-
const n =
|
|
2252
|
+
const n = C(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(sn, { declaration: e });
|
|
2239
2253
|
e.symbol = i;
|
|
2240
2254
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2241
2255
|
if (r.has(s)) {
|
|
2242
2256
|
const a = r.get(s);
|
|
2243
2257
|
return [
|
|
2244
|
-
new
|
|
2245
|
-
new
|
|
2258
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
|
|
2259
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
|
|
2246
2260
|
];
|
|
2247
2261
|
}
|
|
2248
2262
|
r.set(s, i);
|
|
@@ -2252,74 +2266,74 @@ class xn {
|
|
|
2252
2266
|
// This is needed to support legacy inline settings
|
|
2253
2267
|
validateFieldSetting(e) {
|
|
2254
2268
|
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof D))
|
|
2255
|
-
return [...e.map((p) => new
|
|
2269
|
+
return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2256
2270
|
if (e.length === 0)
|
|
2257
2271
|
return [];
|
|
2258
2272
|
let n;
|
|
2259
2273
|
I.last(e) instanceof D && (n = e.pop());
|
|
2260
|
-
const s =
|
|
2274
|
+
const s = B(n), i = s.getErrors(), r = s.getValue();
|
|
2261
2275
|
for (const p of e) {
|
|
2262
|
-
const f =
|
|
2276
|
+
const f = C(p).unwrap_or("").toLowerCase();
|
|
2263
2277
|
if (f !== "pk" && f !== "unique") {
|
|
2264
|
-
i.push(new
|
|
2278
|
+
i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2265
2279
|
continue;
|
|
2266
2280
|
}
|
|
2267
2281
|
r[f] === void 0 ? r[f] = [p] : r[f].push(p);
|
|
2268
2282
|
}
|
|
2269
|
-
const a = r.pk || [],
|
|
2270
|
-
a.length >= 1 &&
|
|
2283
|
+
const a = r.pk || [], c = r["primary key"] || [];
|
|
2284
|
+
a.length >= 1 && c.length >= 1 && i.push(...[...a, ...c].map((p) => new l(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
|
|
2271
2285
|
for (const p in r) {
|
|
2272
2286
|
const f = r[p];
|
|
2273
2287
|
switch (p) {
|
|
2274
2288
|
case "note":
|
|
2275
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2276
|
-
|
|
2289
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
|
|
2290
|
+
$(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
|
|
2277
2291
|
});
|
|
2278
2292
|
break;
|
|
2279
2293
|
case "ref":
|
|
2280
2294
|
f.forEach((h) => {
|
|
2281
|
-
|
|
2295
|
+
Fn(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
|
|
2282
2296
|
});
|
|
2283
2297
|
break;
|
|
2284
2298
|
case "primary key":
|
|
2285
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2286
|
-
|
|
2299
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", h))), f.forEach((h) => {
|
|
2300
|
+
ue(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
|
|
2287
2301
|
});
|
|
2288
2302
|
break;
|
|
2289
2303
|
case "pk":
|
|
2290
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2291
|
-
h instanceof se && !
|
|
2304
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
|
|
2305
|
+
h instanceof se && !ue(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
|
|
2292
2306
|
});
|
|
2293
2307
|
break;
|
|
2294
2308
|
case "not null":
|
|
2295
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2309
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", h)));
|
|
2296
2310
|
const E = r.null || [];
|
|
2297
|
-
f.length >= 1 && E.length >= 1 && i.push(...[...f, ...E].map((h) => new
|
|
2298
|
-
|
|
2311
|
+
f.length >= 1 && E.length >= 1 && i.push(...[...f, ...E].map((h) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", h))), f.forEach((h) => {
|
|
2312
|
+
ue(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", h.value || h.name));
|
|
2299
2313
|
});
|
|
2300
2314
|
break;
|
|
2301
2315
|
case "null":
|
|
2302
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2303
|
-
|
|
2316
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", h))), f.forEach((h) => {
|
|
2317
|
+
ue(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
|
|
2304
2318
|
});
|
|
2305
2319
|
break;
|
|
2306
2320
|
case "unique":
|
|
2307
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2308
|
-
h instanceof se && !
|
|
2321
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
|
|
2322
|
+
h instanceof se && !ue(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
|
|
2309
2323
|
});
|
|
2310
2324
|
break;
|
|
2311
2325
|
case "increment":
|
|
2312
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2313
|
-
h instanceof se && !
|
|
2326
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
|
|
2327
|
+
h instanceof se && !ue(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
|
|
2314
2328
|
});
|
|
2315
2329
|
break;
|
|
2316
2330
|
case "default":
|
|
2317
|
-
f.length > 1 && i.push(...f.map((h) => new
|
|
2318
|
-
|
|
2331
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
|
|
2332
|
+
Mn(h.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
|
|
2319
2333
|
});
|
|
2320
2334
|
break;
|
|
2321
2335
|
default:
|
|
2322
|
-
f.forEach((h) => i.push(new
|
|
2336
|
+
f.forEach((h) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, h)));
|
|
2323
2337
|
}
|
|
2324
2338
|
}
|
|
2325
2339
|
return i;
|
|
@@ -2328,97 +2342,162 @@ class xn {
|
|
|
2328
2342
|
const n = e.flatMap((i) => {
|
|
2329
2343
|
if (i.parent = this.declarationNode, !i.type)
|
|
2330
2344
|
return [];
|
|
2331
|
-
const r =
|
|
2345
|
+
const r = ae(i);
|
|
2332
2346
|
return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2333
2347
|
}), s = e.filter((i) => {
|
|
2334
2348
|
var r;
|
|
2335
2349
|
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2336
2350
|
});
|
|
2337
|
-
return s.length > 1 &&
|
|
2351
|
+
return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2338
2352
|
}
|
|
2339
2353
|
}
|
|
2340
|
-
function
|
|
2341
|
-
if (!(t instanceof H || Je(t) || t instanceof U || t instanceof
|
|
2354
|
+
function On(t) {
|
|
2355
|
+
if (!(t instanceof H || Je(t) || t instanceof U || t instanceof he))
|
|
2342
2356
|
return !1;
|
|
2343
2357
|
if (t instanceof H) {
|
|
2344
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2358
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => fe(n) || $(n) || me(n)))
|
|
2345
2359
|
return !1;
|
|
2346
2360
|
t = t.callee;
|
|
2347
2361
|
}
|
|
2348
|
-
for (; t instanceof
|
|
2349
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value &&
|
|
2362
|
+
for (; t instanceof he; ) {
|
|
2363
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && fe(n.name)))
|
|
2350
2364
|
return !1;
|
|
2351
2365
|
t = t.array;
|
|
2352
2366
|
}
|
|
2353
|
-
const e =
|
|
2367
|
+
const e = W(t).unwrap_or(void 0);
|
|
2354
2368
|
return e !== void 0 && e.length > 0;
|
|
2355
2369
|
}
|
|
2356
|
-
function
|
|
2370
|
+
function Rn(t, e) {
|
|
2357
2371
|
return e.length === 1 && t === e[0];
|
|
2358
2372
|
}
|
|
2359
|
-
class
|
|
2373
|
+
class Dn {
|
|
2360
2374
|
constructor(e, n, s) {
|
|
2361
2375
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2362
2376
|
}
|
|
2363
2377
|
validate() {
|
|
2364
|
-
return [
|
|
2378
|
+
return [
|
|
2379
|
+
...this.validateContext(),
|
|
2380
|
+
...this.validateName(this.declarationNode.name),
|
|
2381
|
+
...this.validateAlias(this.declarationNode.alias),
|
|
2382
|
+
...this.validateSettingList(this.declarationNode.attributeList),
|
|
2383
|
+
...this.registerElement(),
|
|
2384
|
+
...this.validateBody(this.declarationNode.body)
|
|
2385
|
+
];
|
|
2365
2386
|
}
|
|
2366
2387
|
validateContext() {
|
|
2367
|
-
return this.declarationNode.parent instanceof
|
|
2388
|
+
return this.declarationNode.parent instanceof v ? [new l(
|
|
2389
|
+
o.INVALID_TABLEGROUP_CONTEXT,
|
|
2390
|
+
"TableGroup must appear top-level",
|
|
2391
|
+
this.declarationNode
|
|
2392
|
+
)] : [];
|
|
2368
2393
|
}
|
|
2369
2394
|
validateName(e) {
|
|
2370
|
-
return e ? ye(e) ? [] : [new
|
|
2395
|
+
return e ? ye(e) ? [] : [new l(
|
|
2396
|
+
o.INVALID_NAME,
|
|
2397
|
+
"A TableGroup name must be a single identifier",
|
|
2398
|
+
e
|
|
2399
|
+
)] : [new l(
|
|
2400
|
+
o.NAME_NOT_FOUND,
|
|
2401
|
+
"A TableGroup must have a name",
|
|
2402
|
+
this.declarationNode
|
|
2403
|
+
)];
|
|
2371
2404
|
}
|
|
2372
2405
|
validateAlias(e) {
|
|
2373
|
-
return e ? [new
|
|
2406
|
+
return e ? [new l(
|
|
2407
|
+
o.UNEXPECTED_ALIAS,
|
|
2408
|
+
"A TableGroup shouldn't have an alias",
|
|
2409
|
+
e
|
|
2410
|
+
)] : [];
|
|
2374
2411
|
}
|
|
2375
2412
|
registerElement() {
|
|
2376
2413
|
const { name: e } = this.declarationNode;
|
|
2377
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2378
|
-
const n =
|
|
2414
|
+
this.declarationNode.symbol = this.symbolFactory.create(rn, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2415
|
+
const n = W(e);
|
|
2379
2416
|
if (n.isOk()) {
|
|
2380
2417
|
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
|
|
2381
2418
|
if (r.has(a))
|
|
2382
|
-
return [new
|
|
2419
|
+
return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
|
|
2383
2420
|
r.set(a, this.declarationNode.symbol);
|
|
2384
2421
|
}
|
|
2385
2422
|
return [];
|
|
2386
2423
|
}
|
|
2387
2424
|
validateSettingList(e) {
|
|
2388
|
-
|
|
2425
|
+
const n = B(e), s = n.getErrors(), i = n.getValue();
|
|
2426
|
+
return I.forIn(i, (r, a) => {
|
|
2427
|
+
switch (a) {
|
|
2428
|
+
case "headercolor":
|
|
2429
|
+
s.push(...r.map((c) => new l(
|
|
2430
|
+
o.INVALID_TABLE_SETTING,
|
|
2431
|
+
"'headercolor' is not supported",
|
|
2432
|
+
c
|
|
2433
|
+
)));
|
|
2434
|
+
break;
|
|
2435
|
+
case "note":
|
|
2436
|
+
r.length > 1 && s.push(...r.map((c) => new l(
|
|
2437
|
+
o.DUPLICATE_TABLE_SETTING,
|
|
2438
|
+
"'note' can only appear once",
|
|
2439
|
+
c
|
|
2440
|
+
))), r.filter((c) => !$(c.value)).forEach((c) => {
|
|
2441
|
+
s.push(new l(
|
|
2442
|
+
o.INVALID_TABLE_SETTING,
|
|
2443
|
+
"'note' must be a string literal",
|
|
2444
|
+
c.value || c.name
|
|
2445
|
+
));
|
|
2446
|
+
});
|
|
2447
|
+
break;
|
|
2448
|
+
default:
|
|
2449
|
+
s.push(...r.map((c) => new l(
|
|
2450
|
+
o.INVALID_TABLE_SETTING,
|
|
2451
|
+
`Unknown '${a}' setting`,
|
|
2452
|
+
c
|
|
2453
|
+
)));
|
|
2454
|
+
break;
|
|
2455
|
+
}
|
|
2456
|
+
}), s;
|
|
2389
2457
|
}
|
|
2390
2458
|
validateBody(e) {
|
|
2391
2459
|
if (!e)
|
|
2392
2460
|
return [];
|
|
2393
2461
|
if (e instanceof y)
|
|
2394
|
-
return [new
|
|
2462
|
+
return [new l(
|
|
2463
|
+
o.UNEXPECTED_SIMPLE_BODY,
|
|
2464
|
+
"A TableGroup's body must be a block",
|
|
2465
|
+
e
|
|
2466
|
+
)];
|
|
2395
2467
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2396
|
-
return [
|
|
2468
|
+
return [
|
|
2469
|
+
...this.validateFields(n),
|
|
2470
|
+
...this.validateSubElements(s)
|
|
2471
|
+
];
|
|
2397
2472
|
}
|
|
2398
2473
|
validateFields(e) {
|
|
2399
2474
|
return e.flatMap((n) => {
|
|
2400
2475
|
const s = [];
|
|
2401
|
-
return n.callee && !
|
|
2476
|
+
return n.callee && !W(n.callee).isOk() && s.push(new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2402
2477
|
});
|
|
2403
2478
|
}
|
|
2404
2479
|
validateSubElements(e) {
|
|
2405
|
-
|
|
2406
|
-
if (
|
|
2480
|
+
const n = e.flatMap((i) => {
|
|
2481
|
+
if (i.parent = this.declarationNode, !i.type)
|
|
2407
2482
|
return [];
|
|
2408
|
-
const
|
|
2409
|
-
return new
|
|
2483
|
+
const r = ae(i);
|
|
2484
|
+
return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2485
|
+
}), s = e.filter((i) => {
|
|
2486
|
+
var r;
|
|
2487
|
+
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2410
2488
|
});
|
|
2489
|
+
return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2411
2490
|
}
|
|
2412
2491
|
registerField(e) {
|
|
2413
2492
|
if (e.callee && M(e.callee)) {
|
|
2414
|
-
const n =
|
|
2493
|
+
const n = C(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(an, { declaration: e });
|
|
2415
2494
|
e.symbol = i;
|
|
2416
2495
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2417
2496
|
if (r.has(s)) {
|
|
2418
2497
|
const a = r.get(s);
|
|
2419
2498
|
return [
|
|
2420
|
-
new
|
|
2421
|
-
new
|
|
2499
|
+
new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
|
|
2500
|
+
new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
|
|
2422
2501
|
];
|
|
2423
2502
|
}
|
|
2424
2503
|
r.set(s, i);
|
|
@@ -2427,34 +2506,34 @@ class Rn {
|
|
|
2427
2506
|
}
|
|
2428
2507
|
}
|
|
2429
2508
|
const wt = ["-", "+"];
|
|
2430
|
-
function
|
|
2509
|
+
function ae(t) {
|
|
2431
2510
|
switch (t.type.value.toLowerCase()) {
|
|
2432
2511
|
case b.Enum:
|
|
2433
|
-
return
|
|
2512
|
+
return An;
|
|
2434
2513
|
case b.Table:
|
|
2435
|
-
return
|
|
2514
|
+
return Sn;
|
|
2436
2515
|
case b.TableGroup:
|
|
2437
|
-
return
|
|
2516
|
+
return Dn;
|
|
2438
2517
|
case b.Project:
|
|
2439
|
-
return wn;
|
|
2440
|
-
case b.Ref:
|
|
2441
2518
|
return yn;
|
|
2519
|
+
case b.Ref:
|
|
2520
|
+
return kn;
|
|
2442
2521
|
case b.Note:
|
|
2443
|
-
return
|
|
2522
|
+
return wn;
|
|
2444
2523
|
case b.Indexes:
|
|
2445
|
-
return
|
|
2524
|
+
return vn;
|
|
2446
2525
|
default:
|
|
2447
|
-
return
|
|
2526
|
+
return _n;
|
|
2448
2527
|
}
|
|
2449
2528
|
}
|
|
2450
2529
|
function yt(t) {
|
|
2451
|
-
return !!
|
|
2530
|
+
return !!W(t).unwrap_or(!1);
|
|
2452
2531
|
}
|
|
2453
|
-
function
|
|
2532
|
+
function Pn(t) {
|
|
2454
2533
|
return ye(t);
|
|
2455
2534
|
}
|
|
2456
2535
|
function ye(t) {
|
|
2457
|
-
return t instanceof U && t.expression instanceof
|
|
2536
|
+
return t instanceof U && t.expression instanceof K;
|
|
2458
2537
|
}
|
|
2459
2538
|
function Ze(t, e, n) {
|
|
2460
2539
|
var i;
|
|
@@ -2462,14 +2541,14 @@ function Ze(t, e, n) {
|
|
|
2462
2541
|
let s = e;
|
|
2463
2542
|
for (const r of t) {
|
|
2464
2543
|
let a;
|
|
2465
|
-
const
|
|
2466
|
-
if (s.has(
|
|
2467
|
-
if (a = (i = s.get(
|
|
2544
|
+
const c = je(r);
|
|
2545
|
+
if (s.has(c)) {
|
|
2546
|
+
if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
|
|
2468
2547
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2469
2548
|
} else {
|
|
2470
2549
|
a = new we();
|
|
2471
2550
|
const p = n.create(_t, { symbolTable: a });
|
|
2472
|
-
s.set(
|
|
2551
|
+
s.set(c, p);
|
|
2473
2552
|
}
|
|
2474
2553
|
s = a;
|
|
2475
2554
|
}
|
|
@@ -2478,55 +2557,55 @@ function Ze(t, e, n) {
|
|
|
2478
2557
|
function kt(t) {
|
|
2479
2558
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2480
2559
|
}
|
|
2481
|
-
function
|
|
2560
|
+
function Un(t) {
|
|
2482
2561
|
var n;
|
|
2483
|
-
if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !==
|
|
2562
|
+
if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2484
2563
|
return !1;
|
|
2485
2564
|
const e = t.expression.literal.value;
|
|
2486
2565
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2487
2566
|
return !1;
|
|
2488
2567
|
for (let s = 1; s < e.length; s += 1)
|
|
2489
|
-
if (!
|
|
2568
|
+
if (!Kt(e[s]))
|
|
2490
2569
|
return !1;
|
|
2491
2570
|
return !0;
|
|
2492
2571
|
}
|
|
2493
|
-
function
|
|
2572
|
+
function ue(t) {
|
|
2494
2573
|
return t === void 0;
|
|
2495
2574
|
}
|
|
2496
|
-
function
|
|
2575
|
+
function Mn(t) {
|
|
2497
2576
|
var e;
|
|
2498
|
-
return !!(
|
|
2577
|
+
return !!($(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof ne);
|
|
2499
2578
|
}
|
|
2500
|
-
function
|
|
2579
|
+
function fe(t) {
|
|
2501
2580
|
var e;
|
|
2502
|
-
return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) ===
|
|
2581
|
+
return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
|
|
2503
2582
|
}
|
|
2504
|
-
function
|
|
2583
|
+
function Fn(t) {
|
|
2505
2584
|
var n;
|
|
2506
2585
|
if (!(t instanceof Q) || !kt((n = t.op) == null ? void 0 : n.value))
|
|
2507
2586
|
return !1;
|
|
2508
|
-
const e =
|
|
2587
|
+
const e = W(t.expression).unwrap_or(void 0);
|
|
2509
2588
|
return e !== void 0 && e.length > 0;
|
|
2510
2589
|
}
|
|
2511
2590
|
function xt(t) {
|
|
2512
|
-
return t instanceof
|
|
2591
|
+
return t instanceof Z && t.elementList.every(M);
|
|
2513
2592
|
}
|
|
2514
|
-
function
|
|
2593
|
+
function B(t) {
|
|
2515
2594
|
var s;
|
|
2516
2595
|
const e = {}, n = [];
|
|
2517
2596
|
if (!t)
|
|
2518
|
-
return new
|
|
2597
|
+
return new V({});
|
|
2519
2598
|
for (const i of t.elementList) {
|
|
2520
2599
|
if (!i.name)
|
|
2521
2600
|
continue;
|
|
2522
2601
|
if (i.name instanceof U) {
|
|
2523
|
-
n.push(new
|
|
2602
|
+
n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2524
2603
|
continue;
|
|
2525
2604
|
}
|
|
2526
2605
|
const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2527
2606
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2528
2607
|
}
|
|
2529
|
-
return new
|
|
2608
|
+
return new V(e, n);
|
|
2530
2609
|
}
|
|
2531
2610
|
class ft {
|
|
2532
2611
|
constructor(e, n) {
|
|
@@ -2539,7 +2618,7 @@ class ft {
|
|
|
2539
2618
|
this.ast.body.forEach((s) => {
|
|
2540
2619
|
if (s.parent = this.ast, s.type === void 0)
|
|
2541
2620
|
return;
|
|
2542
|
-
const i =
|
|
2621
|
+
const i = ae(s), r = new i(
|
|
2543
2622
|
s,
|
|
2544
2623
|
this.publicSchemaSymbol.symbolTable,
|
|
2545
2624
|
this.symbolFactory
|
|
@@ -2547,10 +2626,10 @@ class ft {
|
|
|
2547
2626
|
e.push(...r.validate());
|
|
2548
2627
|
});
|
|
2549
2628
|
const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
|
|
2550
|
-
return n.length > 1 && n.forEach((s) => e.push(new
|
|
2629
|
+
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new V(this.ast, e);
|
|
2551
2630
|
}
|
|
2552
2631
|
}
|
|
2553
|
-
class
|
|
2632
|
+
class oe {
|
|
2554
2633
|
constructor(e, n) {
|
|
2555
2634
|
this.declarationNode = e, this.errors = n;
|
|
2556
2635
|
}
|
|
@@ -2574,9 +2653,9 @@ class ae {
|
|
|
2574
2653
|
if (!e.body)
|
|
2575
2654
|
return;
|
|
2576
2655
|
const { body: n } = e;
|
|
2577
|
-
if (n instanceof
|
|
2656
|
+
if (n instanceof J)
|
|
2578
2657
|
for (const s of n.body)
|
|
2579
|
-
if (s instanceof
|
|
2658
|
+
if (s instanceof v) {
|
|
2580
2659
|
if (!s.type)
|
|
2581
2660
|
continue;
|
|
2582
2661
|
const i = St(s);
|
|
@@ -2598,11 +2677,11 @@ class ae {
|
|
|
2598
2677
|
var s, i;
|
|
2599
2678
|
if (e)
|
|
2600
2679
|
if (e instanceof U) {
|
|
2601
|
-
if (e.expression instanceof
|
|
2680
|
+
if (e.expression instanceof K && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2602
2681
|
return;
|
|
2603
2682
|
this.bindFragments([e], n);
|
|
2604
2683
|
} else
|
|
2605
|
-
e instanceof q ? Je(e) ? this.bindFragments(
|
|
2684
|
+
e instanceof q ? Je(e) ? this.bindFragments(pe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof Z && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2606
2685
|
}
|
|
2607
2686
|
// Bind the fragments of a member access expression
|
|
2608
2687
|
// which can be a simple expression like v1.User,
|
|
@@ -2610,7 +2689,7 @@ class ae {
|
|
|
2610
2689
|
bindFragments(e, n) {
|
|
2611
2690
|
if (e.length === 0)
|
|
2612
2691
|
return;
|
|
2613
|
-
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)),
|
|
2692
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), c = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
|
|
2614
2693
|
0,
|
|
2615
2694
|
r === -1 ? void 0 : r
|
|
2616
2695
|
);
|
|
@@ -2618,26 +2697,26 @@ class ae {
|
|
|
2618
2697
|
return;
|
|
2619
2698
|
const E = [];
|
|
2620
2699
|
for (; s.length && f.length; ) {
|
|
2621
|
-
const h = s.pop(), m = f.pop(), g =
|
|
2700
|
+
const h = s.pop(), m = f.pop(), g = C(m).unwrap();
|
|
2622
2701
|
E.unshift({
|
|
2623
2702
|
index: Ve(g, h),
|
|
2624
2703
|
referrer: m
|
|
2625
2704
|
});
|
|
2626
2705
|
}
|
|
2627
2706
|
for (; f.length; ) {
|
|
2628
|
-
const h = f.pop(), m =
|
|
2707
|
+
const h = f.pop(), m = C(h).unwrap();
|
|
2629
2708
|
E.unshift({
|
|
2630
2709
|
index: Ve(m, i),
|
|
2631
2710
|
referrer: h
|
|
2632
2711
|
});
|
|
2633
2712
|
}
|
|
2634
|
-
return
|
|
2713
|
+
return c ? c.elementList.forEach(
|
|
2635
2714
|
(h) => this.resolveIndexStack(
|
|
2636
2715
|
[
|
|
2637
2716
|
...E,
|
|
2638
2717
|
{
|
|
2639
2718
|
index: Ve(
|
|
2640
|
-
|
|
2719
|
+
C(h).unwrap(),
|
|
2641
2720
|
p
|
|
2642
2721
|
),
|
|
2643
2722
|
referrer: h
|
|
@@ -2652,34 +2731,34 @@ class ae {
|
|
|
2652
2731
|
resolveIndexStack(e, n) {
|
|
2653
2732
|
if (e.length === 0)
|
|
2654
2733
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
2655
|
-
const [s, ...i] = e, r =
|
|
2734
|
+
const [s, ...i] = e, r = gn(s.index, this.declarationNode);
|
|
2656
2735
|
if (r === void 0) {
|
|
2657
2736
|
const { kind: f, name: E } = ie(s.index).unwrap();
|
|
2658
2737
|
this.logError(s.referrer, `Can not find ${f} '${E}'`, n);
|
|
2659
2738
|
return;
|
|
2660
2739
|
}
|
|
2661
2740
|
r.references.push(s.referrer), s.referrer.referee = r;
|
|
2662
|
-
let a = r.symbolTable, { kind:
|
|
2741
|
+
let a = r.symbolTable, { kind: c, name: p } = ie(s.index).unwrap();
|
|
2663
2742
|
for (const f of i) {
|
|
2664
2743
|
const { kind: E, name: h } = ie(f.index).unwrap(), m = a.get(f.index);
|
|
2665
2744
|
if (!m) {
|
|
2666
2745
|
this.logError(
|
|
2667
2746
|
f.referrer,
|
|
2668
|
-
`${
|
|
2747
|
+
`${c} '${p}' does not have ${E} '${h}'`,
|
|
2669
2748
|
n
|
|
2670
2749
|
);
|
|
2671
2750
|
return;
|
|
2672
2751
|
}
|
|
2673
|
-
if (
|
|
2752
|
+
if (c = E, p = h, f.referrer.referee = m, m.references.push(f.referrer), !m.symbolTable)
|
|
2674
2753
|
break;
|
|
2675
2754
|
a = m.symbolTable;
|
|
2676
2755
|
}
|
|
2677
2756
|
}
|
|
2678
2757
|
logError(e, n, s) {
|
|
2679
|
-
s || this.errors.push(new
|
|
2758
|
+
s || this.errors.push(new l(o.BINDING_ERROR, n, e));
|
|
2680
2759
|
}
|
|
2681
2760
|
}
|
|
2682
|
-
class
|
|
2761
|
+
class Bn extends oe {
|
|
2683
2762
|
constructor() {
|
|
2684
2763
|
super(...arguments), this.subfield = {
|
|
2685
2764
|
arg: {
|
|
@@ -2689,7 +2768,7 @@ class Fn extends ae {
|
|
|
2689
2768
|
}, this.settingList = {};
|
|
2690
2769
|
}
|
|
2691
2770
|
}
|
|
2692
|
-
class
|
|
2771
|
+
class Vn extends oe {
|
|
2693
2772
|
constructor() {
|
|
2694
2773
|
super(...arguments), this.subfield = {
|
|
2695
2774
|
arg: {
|
|
@@ -2699,7 +2778,7 @@ class Bn extends ae {
|
|
|
2699
2778
|
}, this.settingList = {};
|
|
2700
2779
|
}
|
|
2701
2780
|
}
|
|
2702
|
-
class
|
|
2781
|
+
class Gn extends oe {
|
|
2703
2782
|
constructor() {
|
|
2704
2783
|
super(...arguments), this.subfield = {
|
|
2705
2784
|
arg: {
|
|
@@ -2734,7 +2813,7 @@ class Vn extends ae {
|
|
|
2734
2813
|
}, this.settingList = {};
|
|
2735
2814
|
}
|
|
2736
2815
|
}
|
|
2737
|
-
class
|
|
2816
|
+
class Cn extends oe {
|
|
2738
2817
|
constructor() {
|
|
2739
2818
|
super(...arguments), this.subfield = {
|
|
2740
2819
|
arg: {
|
|
@@ -2744,7 +2823,7 @@ class Gn extends ae {
|
|
|
2744
2823
|
}, this.settingList = {};
|
|
2745
2824
|
}
|
|
2746
2825
|
}
|
|
2747
|
-
class
|
|
2826
|
+
class Xn extends oe {
|
|
2748
2827
|
constructor() {
|
|
2749
2828
|
super(...arguments), this.subfield = {
|
|
2750
2829
|
arg: {
|
|
@@ -2754,7 +2833,7 @@ class Cn extends ae {
|
|
|
2754
2833
|
}, this.settingList = {};
|
|
2755
2834
|
}
|
|
2756
2835
|
}
|
|
2757
|
-
class
|
|
2836
|
+
class $n extends oe {
|
|
2758
2837
|
constructor() {
|
|
2759
2838
|
super(...arguments), this.subfield = {
|
|
2760
2839
|
arg: {
|
|
@@ -2771,7 +2850,7 @@ class Xn extends ae {
|
|
|
2771
2850
|
}, this.settingList = {};
|
|
2772
2851
|
}
|
|
2773
2852
|
}
|
|
2774
|
-
class
|
|
2853
|
+
class Wn extends oe {
|
|
2775
2854
|
constructor() {
|
|
2776
2855
|
super(...arguments), this.subfield = {
|
|
2777
2856
|
arg: {
|
|
@@ -2799,7 +2878,7 @@ class $n extends ae {
|
|
|
2799
2878
|
}, this.settingList = {};
|
|
2800
2879
|
}
|
|
2801
2880
|
}
|
|
2802
|
-
class
|
|
2881
|
+
class jn extends oe {
|
|
2803
2882
|
constructor() {
|
|
2804
2883
|
super(...arguments), this.subfield = {
|
|
2805
2884
|
arg: {
|
|
@@ -2819,24 +2898,24 @@ class Wn extends ae {
|
|
|
2819
2898
|
function St(t) {
|
|
2820
2899
|
switch (t.type.value.toLowerCase()) {
|
|
2821
2900
|
case b.Enum:
|
|
2822
|
-
return
|
|
2901
|
+
return Vn;
|
|
2823
2902
|
case b.Table:
|
|
2824
|
-
return $n;
|
|
2825
|
-
case b.TableGroup:
|
|
2826
2903
|
return Wn;
|
|
2904
|
+
case b.TableGroup:
|
|
2905
|
+
return jn;
|
|
2827
2906
|
case b.Project:
|
|
2828
|
-
return Cn;
|
|
2829
|
-
case b.Ref:
|
|
2830
2907
|
return Xn;
|
|
2908
|
+
case b.Ref:
|
|
2909
|
+
return $n;
|
|
2831
2910
|
case b.Note:
|
|
2832
|
-
return
|
|
2911
|
+
return Cn;
|
|
2833
2912
|
case b.Indexes:
|
|
2834
|
-
return
|
|
2913
|
+
return Gn;
|
|
2835
2914
|
default:
|
|
2836
|
-
return
|
|
2915
|
+
return Bn;
|
|
2837
2916
|
}
|
|
2838
2917
|
}
|
|
2839
|
-
class
|
|
2918
|
+
class Yn {
|
|
2840
2919
|
constructor(e) {
|
|
2841
2920
|
this.ast = e, this.errors = [];
|
|
2842
2921
|
}
|
|
@@ -2846,10 +2925,10 @@ class jn {
|
|
|
2846
2925
|
const n = St(e);
|
|
2847
2926
|
new n(e, this.errors).bind();
|
|
2848
2927
|
}
|
|
2849
|
-
return new
|
|
2928
|
+
return new V(this.ast, this.errors);
|
|
2850
2929
|
}
|
|
2851
2930
|
}
|
|
2852
|
-
class
|
|
2931
|
+
class zn {
|
|
2853
2932
|
constructor(e) {
|
|
2854
2933
|
this.generator = e;
|
|
2855
2934
|
}
|
|
@@ -2857,17 +2936,17 @@ class Yn {
|
|
|
2857
2936
|
return new e(n, this.generator.nextId());
|
|
2858
2937
|
}
|
|
2859
2938
|
}
|
|
2860
|
-
class
|
|
2939
|
+
class Qn {
|
|
2861
2940
|
constructor(e, n) {
|
|
2862
|
-
this.ast = e, this.symbolFactory = new
|
|
2941
|
+
this.ast = e, this.symbolFactory = new zn(n);
|
|
2863
2942
|
}
|
|
2864
2943
|
// Analyzing: Invoking both the validator and binder
|
|
2865
2944
|
analyze() {
|
|
2866
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2945
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Yn(n).resolve());
|
|
2867
2946
|
}
|
|
2868
2947
|
// For invoking the validator only
|
|
2869
2948
|
validate() {
|
|
2870
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2949
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new V(n, []));
|
|
2871
2950
|
}
|
|
2872
2951
|
}
|
|
2873
2952
|
function pt(t, e) {
|
|
@@ -2903,7 +2982,7 @@ function Ot(t) {
|
|
|
2903
2982
|
}
|
|
2904
2983
|
throw new Error("Invalid relation op");
|
|
2905
2984
|
}
|
|
2906
|
-
function
|
|
2985
|
+
function A(t) {
|
|
2907
2986
|
return {
|
|
2908
2987
|
start: {
|
|
2909
2988
|
offset: t.startPos.offset,
|
|
@@ -2915,11 +2994,11 @@ function v(t) {
|
|
|
2915
2994
|
}
|
|
2916
2995
|
function $e(t) {
|
|
2917
2996
|
var n;
|
|
2918
|
-
const e = (n =
|
|
2919
|
-
return e instanceof
|
|
2997
|
+
const e = (n = pe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2998
|
+
return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2920
2999
|
}
|
|
2921
3000
|
function Ie(t) {
|
|
2922
|
-
const e =
|
|
3001
|
+
const e = W(t).unwrap();
|
|
2923
3002
|
return {
|
|
2924
3003
|
name: e.pop(),
|
|
2925
3004
|
schemaName: e
|
|
@@ -2939,12 +3018,12 @@ function Dt(t, e) {
|
|
|
2939
3018
|
function Pt(t, e) {
|
|
2940
3019
|
if (Array.isArray(t)) {
|
|
2941
3020
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2942
|
-
return I.zip(i, r).every(([a,
|
|
3021
|
+
return I.zip(i, r).every(([a, c]) => a === c);
|
|
2943
3022
|
}
|
|
2944
3023
|
const n = t.id, s = e.id;
|
|
2945
3024
|
return n === s;
|
|
2946
3025
|
}
|
|
2947
|
-
function
|
|
3026
|
+
function re(t) {
|
|
2948
3027
|
const e = t.split(`
|
|
2949
3028
|
`), n = e.slice(e.findIndex((r) => r.trimStart() !== "")), s = n.filter((r) => r.trimStart()), i = Math.min(...s.map((r) => r.length - r.trimStart().length));
|
|
2950
3029
|
return n.map((r) => r.slice(i)).join(`
|
|
@@ -2955,7 +3034,7 @@ class Ut {
|
|
|
2955
3034
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2956
3035
|
}
|
|
2957
3036
|
interpret() {
|
|
2958
|
-
this.table.token =
|
|
3037
|
+
this.table.token = A(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
|
|
2959
3038
|
const e = [
|
|
2960
3039
|
...this.interpretName(this.declarationNode.name),
|
|
2961
3040
|
...this.interpretAlias(this.declarationNode.alias),
|
|
@@ -2975,12 +3054,12 @@ class Ut {
|
|
|
2975
3054
|
}
|
|
2976
3055
|
interpretName(e) {
|
|
2977
3056
|
const { name: n, schemaName: s } = Ie(e);
|
|
2978
|
-
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new
|
|
3057
|
+
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
2979
3058
|
}
|
|
2980
3059
|
interpretAlias(e) {
|
|
2981
3060
|
if (!e)
|
|
2982
3061
|
return [];
|
|
2983
|
-
const n =
|
|
3062
|
+
const n = C(e).unwrap_or(null);
|
|
2984
3063
|
return n && (this.env.aliases.push({
|
|
2985
3064
|
name: n,
|
|
2986
3065
|
kind: "table",
|
|
@@ -2992,12 +3071,12 @@ class Ut {
|
|
|
2992
3071
|
}
|
|
2993
3072
|
interpretSettingList(e) {
|
|
2994
3073
|
var i, r, a;
|
|
2995
|
-
const n =
|
|
3074
|
+
const n = B(e).getValue();
|
|
2996
3075
|
this.table.headerColor = (i = n.headercolor) != null && i.length ? Rt((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
|
|
2997
3076
|
const [s] = n.note || [];
|
|
2998
3077
|
return this.table.note = s && {
|
|
2999
|
-
value:
|
|
3000
|
-
token:
|
|
3078
|
+
value: G(s == null ? void 0 : s.value).map(re).unwrap(),
|
|
3079
|
+
token: A(s)
|
|
3001
3080
|
}, [];
|
|
3002
3081
|
}
|
|
3003
3082
|
interpretBody(e) {
|
|
@@ -3010,8 +3089,8 @@ class Ut {
|
|
|
3010
3089
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3011
3090
|
case "note":
|
|
3012
3091
|
return this.table.note = {
|
|
3013
|
-
value:
|
|
3014
|
-
token:
|
|
3092
|
+
value: G(n.body instanceof J ? n.body.body[0].callee : n.body.callee).map(re).unwrap(),
|
|
3093
|
+
token: A(n)
|
|
3015
3094
|
}, [];
|
|
3016
3095
|
case "indexes":
|
|
3017
3096
|
return this.interpretIndexes(n);
|
|
@@ -3023,85 +3102,85 @@ class Ut {
|
|
|
3023
3102
|
return e.flatMap((n) => this.interpretColumn(n));
|
|
3024
3103
|
}
|
|
3025
3104
|
interpretColumn(e) {
|
|
3026
|
-
var a,
|
|
3105
|
+
var a, c, p, f, E, h, m, g;
|
|
3027
3106
|
const n = [], s = {};
|
|
3028
|
-
s.name =
|
|
3029
|
-
const i =
|
|
3030
|
-
s.type = i.getValue(), n.push(...i.getErrors()), s.token =
|
|
3107
|
+
s.name = C(e.callee).unwrap();
|
|
3108
|
+
const i = qn(e.args[0]);
|
|
3109
|
+
s.type = i.getValue(), n.push(...i.getErrors()), s.token = A(e), s.inline_refs = [];
|
|
3031
3110
|
const r = e.args.slice(1);
|
|
3032
3111
|
if (I.last(r) instanceof D) {
|
|
3033
|
-
const _ =
|
|
3034
|
-
s.pk = !!((a = _.pk) != null && a.length) || !!((
|
|
3035
|
-
const
|
|
3036
|
-
s.note =
|
|
3037
|
-
value:
|
|
3038
|
-
token:
|
|
3112
|
+
const _ = B(r.pop()).getValue();
|
|
3113
|
+
s.pk = !!((a = _.pk) != null && a.length) || !!((c = _["primary key"]) != null && c.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((f = _.unique) != null && f.length), s.not_null = !!((E = _["not null"]) != null && E.length) && !0, s.dbdefault = Hn((m = (h = _.default) == null ? void 0 : h.at(0)) == null ? void 0 : m.value);
|
|
3114
|
+
const ee = (g = _.note) == null ? void 0 : g.at(0);
|
|
3115
|
+
s.note = ee && {
|
|
3116
|
+
value: G(ee.value).map(re).unwrap(),
|
|
3117
|
+
token: A(ee)
|
|
3039
3118
|
};
|
|
3040
|
-
const
|
|
3041
|
-
s.inline_refs =
|
|
3042
|
-
const [tt] = $e(
|
|
3119
|
+
const le = _.ref || [];
|
|
3120
|
+
s.inline_refs = le.flatMap((z) => {
|
|
3121
|
+
const [tt] = $e(z.value.expression);
|
|
3043
3122
|
if (Pt(tt, e.symbol))
|
|
3044
|
-
return n.push(new
|
|
3045
|
-
const ke =
|
|
3046
|
-
let
|
|
3047
|
-
if (
|
|
3048
|
-
const [ce] =
|
|
3049
|
-
|
|
3123
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
|
|
3124
|
+
const ke = z.value.op, te = W(z.value.expression).unwrap();
|
|
3125
|
+
let de;
|
|
3126
|
+
if (te.length === 1) {
|
|
3127
|
+
const [ce] = te;
|
|
3128
|
+
de = {
|
|
3050
3129
|
schemaName: this.table.schemaName,
|
|
3051
3130
|
tableName: this.table.name,
|
|
3052
3131
|
fieldNames: [ce],
|
|
3053
3132
|
relation: ke.value,
|
|
3054
|
-
token:
|
|
3133
|
+
token: A(z)
|
|
3055
3134
|
};
|
|
3056
|
-
} else if (
|
|
3057
|
-
const [ce, Le] =
|
|
3058
|
-
|
|
3135
|
+
} else if (te.length === 2) {
|
|
3136
|
+
const [ce, Le] = te;
|
|
3137
|
+
de = {
|
|
3059
3138
|
schemaName: null,
|
|
3060
3139
|
tableName: ce,
|
|
3061
3140
|
fieldNames: [Le],
|
|
3062
3141
|
relation: ke.value,
|
|
3063
|
-
token:
|
|
3142
|
+
token: A(z)
|
|
3064
3143
|
};
|
|
3065
|
-
} else if (
|
|
3066
|
-
const [ce, Le, st] =
|
|
3067
|
-
|
|
3144
|
+
} else if (te.length === 3) {
|
|
3145
|
+
const [ce, Le, st] = te;
|
|
3146
|
+
de = {
|
|
3068
3147
|
schemaName: ce,
|
|
3069
3148
|
tableName: Le,
|
|
3070
3149
|
fieldNames: [st],
|
|
3071
3150
|
relation: ke.value,
|
|
3072
|
-
token:
|
|
3151
|
+
token: A(z)
|
|
3073
3152
|
};
|
|
3074
3153
|
} else {
|
|
3075
|
-
n.push(new
|
|
3076
|
-
const ce =
|
|
3077
|
-
|
|
3078
|
-
schemaName:
|
|
3154
|
+
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", z));
|
|
3155
|
+
const ce = te.pop(), Le = te.pop();
|
|
3156
|
+
de = {
|
|
3157
|
+
schemaName: te.join("."),
|
|
3079
3158
|
tableName: Le,
|
|
3080
3159
|
fieldNames: [ce],
|
|
3081
3160
|
relation: ke.value,
|
|
3082
|
-
token:
|
|
3161
|
+
token: A(z)
|
|
3083
3162
|
};
|
|
3084
3163
|
}
|
|
3085
|
-
const nt = this.registerInlineRefToEnv(e, tt,
|
|
3086
|
-
return n.push(...nt), nt.length === 0 ?
|
|
3164
|
+
const nt = this.registerInlineRefToEnv(e, tt, de, z);
|
|
3165
|
+
return n.push(...nt), nt.length === 0 ? de : [];
|
|
3087
3166
|
});
|
|
3088
3167
|
}
|
|
3089
|
-
return s.pk || (s.pk = r.some((_) =>
|
|
3168
|
+
return s.pk || (s.pk = r.some((_) => j(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => j(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3090
3169
|
}
|
|
3091
3170
|
interpretIndexes(e) {
|
|
3092
3171
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3093
|
-
var a,
|
|
3172
|
+
var a, c, p, f, E, h, m;
|
|
3094
3173
|
const s = { columns: [] }, i = n;
|
|
3095
|
-
s.token =
|
|
3174
|
+
s.token = A(i);
|
|
3096
3175
|
const r = [i.callee, ...i.args];
|
|
3097
3176
|
if (I.last(r) instanceof D) {
|
|
3098
|
-
const g =
|
|
3099
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((
|
|
3177
|
+
const g = B(r.pop()).getValue();
|
|
3178
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = G((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
|
|
3100
3179
|
const _ = (E = g.note) == null ? void 0 : E.at(0);
|
|
3101
3180
|
s.note = _ && {
|
|
3102
|
-
value:
|
|
3103
|
-
token:
|
|
3104
|
-
}, s.type =
|
|
3181
|
+
value: G(_.value).unwrap(),
|
|
3182
|
+
token: A(_)
|
|
3183
|
+
}, s.type = j((m = (h = g.type) == null ? void 0 : h.at(0)) == null ? void 0 : m.value).unwrap_or(void 0);
|
|
3105
3184
|
}
|
|
3106
3185
|
return r.flatMap((g) => {
|
|
3107
3186
|
if (!(g instanceof H))
|
|
@@ -3111,17 +3190,17 @@ class Ut {
|
|
|
3111
3190
|
_.push(g.argumentList), g = g.callee;
|
|
3112
3191
|
return _.push(g), _;
|
|
3113
3192
|
}).forEach((g) => {
|
|
3114
|
-
const { functional: _, nonFunctional:
|
|
3193
|
+
const { functional: _, nonFunctional: ee } = Xe(g).unwrap();
|
|
3115
3194
|
s.columns.push(
|
|
3116
|
-
..._.map((
|
|
3117
|
-
value:
|
|
3195
|
+
..._.map((le) => ({
|
|
3196
|
+
value: le.value.value,
|
|
3118
3197
|
type: "expression",
|
|
3119
|
-
token:
|
|
3198
|
+
token: A(le)
|
|
3120
3199
|
})),
|
|
3121
|
-
...
|
|
3122
|
-
value:
|
|
3200
|
+
...ee.map((le) => ({
|
|
3201
|
+
value: C(le).unwrap(),
|
|
3123
3202
|
type: "column",
|
|
3124
|
-
token:
|
|
3203
|
+
token: A(le)
|
|
3125
3204
|
}))
|
|
3126
3205
|
);
|
|
3127
3206
|
}), s;
|
|
@@ -3131,8 +3210,8 @@ class Ut {
|
|
|
3131
3210
|
const r = Dt(e.symbol, n);
|
|
3132
3211
|
if (this.env.refIds[r])
|
|
3133
3212
|
return [
|
|
3134
|
-
new
|
|
3135
|
-
new
|
|
3213
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3214
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3136
3215
|
];
|
|
3137
3216
|
const a = Ot(s.relation);
|
|
3138
3217
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
@@ -3147,43 +3226,43 @@ class Ut {
|
|
|
3147
3226
|
{
|
|
3148
3227
|
schemaName: this.table.schemaName,
|
|
3149
3228
|
tableName: this.table.name,
|
|
3150
|
-
fieldNames: [
|
|
3151
|
-
token:
|
|
3229
|
+
fieldNames: [j(e.callee).unwrap()],
|
|
3230
|
+
token: A(e),
|
|
3152
3231
|
relation: a[0]
|
|
3153
3232
|
}
|
|
3154
3233
|
]
|
|
3155
3234
|
}), [];
|
|
3156
3235
|
}
|
|
3157
3236
|
}
|
|
3158
|
-
function
|
|
3237
|
+
function qn(t) {
|
|
3159
3238
|
let e = null;
|
|
3160
|
-
t instanceof H && (e = t.argumentList.elementList.map((r) =>
|
|
3239
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => fe(r) ? r.expression.literal.value : $(r) ? G(r).unwrap() : j(r).unwrap()).join(","), t = t.callee);
|
|
3161
3240
|
let n = "";
|
|
3162
|
-
for (; t instanceof
|
|
3241
|
+
for (; t instanceof he; )
|
|
3163
3242
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3164
3243
|
const { name: s, schemaName: i } = Ie(t);
|
|
3165
|
-
return i.length > 1 ? new
|
|
3244
|
+
return i.length > 1 ? new V(
|
|
3166
3245
|
{
|
|
3167
3246
|
schemaName: i.length === 0 ? null : i[0],
|
|
3168
3247
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3169
3248
|
args: e
|
|
3170
3249
|
},
|
|
3171
|
-
[new
|
|
3172
|
-
) : new
|
|
3250
|
+
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3251
|
+
) : new V({
|
|
3173
3252
|
schemaName: i.length === 0 ? null : i[0],
|
|
3174
3253
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3175
3254
|
args: e
|
|
3176
3255
|
});
|
|
3177
3256
|
}
|
|
3178
|
-
function
|
|
3257
|
+
function Hn(t) {
|
|
3179
3258
|
var e, n, s;
|
|
3180
3259
|
if (t) {
|
|
3181
|
-
if (
|
|
3260
|
+
if ($(t))
|
|
3182
3261
|
return {
|
|
3183
|
-
value:
|
|
3262
|
+
value: G(t).unwrap(),
|
|
3184
3263
|
type: "string"
|
|
3185
3264
|
};
|
|
3186
|
-
if (
|
|
3265
|
+
if (fe(t))
|
|
3187
3266
|
return {
|
|
3188
3267
|
type: "number",
|
|
3189
3268
|
value: Number.parseFloat(t.expression.literal.value)
|
|
@@ -3193,14 +3272,14 @@ function qn(t) {
|
|
|
3193
3272
|
value: t.expression.variable.value.toLowerCase(),
|
|
3194
3273
|
type: "boolean"
|
|
3195
3274
|
};
|
|
3196
|
-
if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) &&
|
|
3275
|
+
if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
|
|
3197
3276
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3198
3277
|
return {
|
|
3199
3278
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
3200
3279
|
type: "number"
|
|
3201
3280
|
};
|
|
3202
3281
|
}
|
|
3203
|
-
if (t instanceof
|
|
3282
|
+
if (t instanceof ne)
|
|
3204
3283
|
return {
|
|
3205
3284
|
value: (s = t.value) == null ? void 0 : s.value,
|
|
3206
3285
|
type: "expression"
|
|
@@ -3208,12 +3287,12 @@ function qn(t) {
|
|
|
3208
3287
|
throw new Error("Unreachable");
|
|
3209
3288
|
}
|
|
3210
3289
|
}
|
|
3211
|
-
class
|
|
3290
|
+
class Jn {
|
|
3212
3291
|
constructor(e, n) {
|
|
3213
3292
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3214
3293
|
}
|
|
3215
3294
|
interpret() {
|
|
3216
|
-
return this.note.token =
|
|
3295
|
+
return this.note.token = A(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
|
|
3217
3296
|
...this.interpretName(this.declarationNode.name),
|
|
3218
3297
|
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3219
3298
|
...this.interpretBody(this.declarationNode.body)
|
|
@@ -3225,30 +3304,30 @@ class Hn {
|
|
|
3225
3304
|
}
|
|
3226
3305
|
interpretSettingList(e) {
|
|
3227
3306
|
var s, i, r;
|
|
3228
|
-
const n =
|
|
3307
|
+
const n = B(e).getValue();
|
|
3229
3308
|
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Rt((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
|
|
3230
3309
|
}
|
|
3231
3310
|
interpretBody(e) {
|
|
3232
3311
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
3233
3312
|
return n.length !== 1 || s.length > 0 ? [
|
|
3234
|
-
new
|
|
3313
|
+
new l(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3235
3314
|
] : [...this.interpretNote(n[0])];
|
|
3236
3315
|
}
|
|
3237
3316
|
interpretNote(e) {
|
|
3238
3317
|
const n = I.get(e, "callee.expression.literal.value", "");
|
|
3239
|
-
return this.note.content =
|
|
3318
|
+
return this.note.content = re(n), [];
|
|
3240
3319
|
}
|
|
3241
3320
|
}
|
|
3242
3321
|
class Mt {
|
|
3243
3322
|
constructor(e, n) {
|
|
3244
|
-
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof
|
|
3323
|
+
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof v ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3245
3324
|
}
|
|
3246
3325
|
interpret() {
|
|
3247
|
-
return this.ref.token =
|
|
3326
|
+
return this.ref.token = A(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3248
3327
|
}
|
|
3249
3328
|
interpretName(e) {
|
|
3250
|
-
const n = [], s =
|
|
3251
|
-
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new
|
|
3329
|
+
const n = [], s = W(this.declarationNode.name).unwrap_or([]);
|
|
3330
|
+
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3252
3331
|
}
|
|
3253
3332
|
interpretBody(e) {
|
|
3254
3333
|
return e instanceof y ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
@@ -3257,32 +3336,32 @@ class Mt {
|
|
|
3257
3336
|
var f, E, h, m;
|
|
3258
3337
|
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
|
|
3259
3338
|
if (Pt(r, a))
|
|
3260
|
-
return [new
|
|
3261
|
-
const
|
|
3262
|
-
if (this.env.refIds[
|
|
3339
|
+
return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3340
|
+
const c = Dt(r, a);
|
|
3341
|
+
if (this.env.refIds[c])
|
|
3263
3342
|
return [
|
|
3264
|
-
new
|
|
3265
|
-
new
|
|
3343
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3344
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
|
|
3266
3345
|
];
|
|
3267
3346
|
if (e.args[0]) {
|
|
3268
|
-
const g =
|
|
3269
|
-
this.ref.onDelete = _ instanceof
|
|
3270
|
-
const
|
|
3271
|
-
this.ref.onUpdate =
|
|
3347
|
+
const g = B(e.args[0]).getValue(), _ = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
|
|
3348
|
+
this.ref.onDelete = _ instanceof Y ? Te(_).unwrap_or(void 0) : j(_).unwrap_or(void 0);
|
|
3349
|
+
const ee = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
|
|
3350
|
+
this.ref.onUpdate = ee instanceof Y ? Te(ee).unwrap_or(void 0) : j(ee).unwrap_or(void 0);
|
|
3272
3351
|
}
|
|
3273
3352
|
const p = Ot(n);
|
|
3274
3353
|
return this.ref.endpoints = [
|
|
3275
3354
|
{
|
|
3276
3355
|
...pt(s, this.container),
|
|
3277
3356
|
relation: p[0],
|
|
3278
|
-
token:
|
|
3357
|
+
token: A(s)
|
|
3279
3358
|
},
|
|
3280
3359
|
{
|
|
3281
3360
|
...pt(i, this.container),
|
|
3282
3361
|
relation: p[1],
|
|
3283
|
-
token:
|
|
3362
|
+
token: A(i)
|
|
3284
3363
|
}
|
|
3285
|
-
], this.env.refIds[
|
|
3364
|
+
], this.env.refIds[c] = this.declarationNode, [];
|
|
3286
3365
|
}
|
|
3287
3366
|
}
|
|
3288
3367
|
class Ft {
|
|
@@ -3291,24 +3370,48 @@ class Ft {
|
|
|
3291
3370
|
}
|
|
3292
3371
|
interpret() {
|
|
3293
3372
|
const e = [];
|
|
3294
|
-
return this.tableGroup.token =
|
|
3373
|
+
return this.tableGroup.token = A(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
|
|
3295
3374
|
...this.interpretName(this.declarationNode.name),
|
|
3375
|
+
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3296
3376
|
...this.interpretBody(this.declarationNode.body)
|
|
3297
3377
|
), e;
|
|
3298
3378
|
}
|
|
3299
3379
|
interpretName(e) {
|
|
3300
3380
|
const n = [], { name: s, schemaName: i } = Ie(e);
|
|
3301
|
-
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new
|
|
3381
|
+
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3302
3382
|
}
|
|
3303
3383
|
interpretBody(e) {
|
|
3384
|
+
const [n, s] = jt(e.body, (i) => i instanceof y);
|
|
3385
|
+
return [
|
|
3386
|
+
...this.interpretFields(n),
|
|
3387
|
+
...this.interpretSubElements(s)
|
|
3388
|
+
];
|
|
3389
|
+
}
|
|
3390
|
+
interpretSubElements(e) {
|
|
3391
|
+
return e.flatMap((n) => {
|
|
3392
|
+
var s;
|
|
3393
|
+
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3394
|
+
case "note":
|
|
3395
|
+
this.tableGroup.note = {
|
|
3396
|
+
value: G(
|
|
3397
|
+
n.body instanceof J ? n.body.body[0].callee : n.body.callee
|
|
3398
|
+
).map(re).unwrap(),
|
|
3399
|
+
token: A(n)
|
|
3400
|
+
};
|
|
3401
|
+
break;
|
|
3402
|
+
}
|
|
3403
|
+
return [];
|
|
3404
|
+
});
|
|
3405
|
+
}
|
|
3406
|
+
interpretFields(e) {
|
|
3304
3407
|
const n = [];
|
|
3305
|
-
return this.tableGroup.tables =
|
|
3306
|
-
const i =
|
|
3307
|
-
i.length > 2 && n.push(new
|
|
3308
|
-
const r =
|
|
3408
|
+
return this.tableGroup.tables = e.map((s) => {
|
|
3409
|
+
const i = W(s.callee).unwrap();
|
|
3410
|
+
i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3411
|
+
const r = pe(s.callee).unwrap().pop().referee.id;
|
|
3309
3412
|
if (this.env.groupOfTable[r]) {
|
|
3310
|
-
const a = this.env.groupOfTable[r], { schemaName:
|
|
3311
|
-
n.push(new
|
|
3413
|
+
const a = this.env.groupOfTable[r], { schemaName: c, name: p } = this.env.tableGroups.get(a), f = c ? `${c}.${p}` : p;
|
|
3414
|
+
n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${f}"`, s));
|
|
3312
3415
|
} else
|
|
3313
3416
|
this.env.groupOfTable[r] = this.declarationNode;
|
|
3314
3417
|
return {
|
|
@@ -3317,37 +3420,44 @@ class Ft {
|
|
|
3317
3420
|
};
|
|
3318
3421
|
}), n;
|
|
3319
3422
|
}
|
|
3423
|
+
interpretSettingList(e) {
|
|
3424
|
+
const n = B(e).getValue(), [s] = n.note || [];
|
|
3425
|
+
return this.tableGroup.note = s && {
|
|
3426
|
+
value: G(s == null ? void 0 : s.value).map(re).unwrap(),
|
|
3427
|
+
token: A(s)
|
|
3428
|
+
}, [];
|
|
3429
|
+
}
|
|
3320
3430
|
}
|
|
3321
3431
|
class Bt {
|
|
3322
3432
|
constructor(e, n) {
|
|
3323
3433
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3324
3434
|
}
|
|
3325
3435
|
interpret() {
|
|
3326
|
-
return this.enum.token =
|
|
3436
|
+
return this.enum.token = A(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3327
3437
|
}
|
|
3328
3438
|
interpretName(e) {
|
|
3329
3439
|
const { name: n, schemaName: s } = Ie(e);
|
|
3330
|
-
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new
|
|
3440
|
+
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3331
3441
|
}
|
|
3332
3442
|
interpretBody(e) {
|
|
3333
3443
|
return e.body.flatMap((n) => {
|
|
3334
|
-
var
|
|
3444
|
+
var c;
|
|
3335
3445
|
const s = n, i = {};
|
|
3336
|
-
i.token =
|
|
3337
|
-
const a = (
|
|
3446
|
+
i.token = A(s), i.name = j(s.callee).unwrap();
|
|
3447
|
+
const a = (c = B(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3338
3448
|
return i.note = a && {
|
|
3339
|
-
value:
|
|
3340
|
-
token:
|
|
3449
|
+
value: G(a.value).map(re).unwrap(),
|
|
3450
|
+
token: A(a)
|
|
3341
3451
|
}, this.enum.values.push(i), [];
|
|
3342
3452
|
});
|
|
3343
3453
|
}
|
|
3344
3454
|
}
|
|
3345
|
-
class
|
|
3455
|
+
class Zn {
|
|
3346
3456
|
constructor(e, n) {
|
|
3347
3457
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3348
3458
|
}
|
|
3349
3459
|
interpret() {
|
|
3350
|
-
return this.env.project.set(this.declarationNode, this.project), this.project.token =
|
|
3460
|
+
return this.env.project.set(this.declarationNode, this.project), this.project.token = A(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3351
3461
|
}
|
|
3352
3462
|
interpretName(e) {
|
|
3353
3463
|
if (!e)
|
|
@@ -3378,16 +3488,16 @@ class Jn {
|
|
|
3378
3488
|
}
|
|
3379
3489
|
case "note":
|
|
3380
3490
|
return this.project.note = {
|
|
3381
|
-
value:
|
|
3382
|
-
token:
|
|
3491
|
+
value: G(s.body instanceof J ? s.body.body[0].callee : s.body.callee).map(re).unwrap(),
|
|
3492
|
+
token: A(s)
|
|
3383
3493
|
}, [];
|
|
3384
3494
|
default:
|
|
3385
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
3495
|
+
return this.project[s.type.value.toLowerCase()] = G(s.body.callee).unwrap(), [];
|
|
3386
3496
|
}
|
|
3387
3497
|
});
|
|
3388
3498
|
}
|
|
3389
3499
|
}
|
|
3390
|
-
class
|
|
3500
|
+
class Kn {
|
|
3391
3501
|
constructor(e) {
|
|
3392
3502
|
this.ast = e, this.env = {
|
|
3393
3503
|
schema: [],
|
|
@@ -3408,7 +3518,7 @@ class Zn {
|
|
|
3408
3518
|
case b.Table:
|
|
3409
3519
|
return new Ut(n, this.env).interpret();
|
|
3410
3520
|
case b.Note:
|
|
3411
|
-
return new
|
|
3521
|
+
return new Jn(n, this.env).interpret();
|
|
3412
3522
|
case b.Ref:
|
|
3413
3523
|
return new Mt(n, this.env).interpret();
|
|
3414
3524
|
case b.TableGroup:
|
|
@@ -3416,15 +3526,15 @@ class Zn {
|
|
|
3416
3526
|
case b.Enum:
|
|
3417
3527
|
return new Bt(n, this.env).interpret();
|
|
3418
3528
|
case b.Project:
|
|
3419
|
-
return new
|
|
3529
|
+
return new Zn(n, this.env).interpret();
|
|
3420
3530
|
default:
|
|
3421
3531
|
return [];
|
|
3422
3532
|
}
|
|
3423
3533
|
});
|
|
3424
|
-
return new
|
|
3534
|
+
return new V(es(this.env), e);
|
|
3425
3535
|
}
|
|
3426
3536
|
}
|
|
3427
|
-
function
|
|
3537
|
+
function es(t) {
|
|
3428
3538
|
return {
|
|
3429
3539
|
schemas: [],
|
|
3430
3540
|
tables: Array.from(t.tables.values()),
|
|
@@ -3436,7 +3546,7 @@ function Kn(t) {
|
|
|
3436
3546
|
project: Array.from(t.project.values())[0] || {}
|
|
3437
3547
|
};
|
|
3438
3548
|
}
|
|
3439
|
-
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 || {}),
|
|
3549
|
+
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
|
|
3440
3550
|
function Ae(t) {
|
|
3441
3551
|
switch (t) {
|
|
3442
3552
|
case T.Schema:
|
|
@@ -3463,12 +3573,12 @@ function De(t, e) {
|
|
|
3463
3573
|
for (const n of t.trailingTrivia) {
|
|
3464
3574
|
if (n.start > e)
|
|
3465
3575
|
break;
|
|
3466
|
-
if (n.kind ===
|
|
3576
|
+
if (n.kind === u.NEWLINE && n.end <= e)
|
|
3467
3577
|
return !1;
|
|
3468
3578
|
}
|
|
3469
3579
|
return !0;
|
|
3470
3580
|
}
|
|
3471
|
-
function
|
|
3581
|
+
function R() {
|
|
3472
3582
|
return {
|
|
3473
3583
|
suggestions: []
|
|
3474
3584
|
};
|
|
@@ -3500,19 +3610,19 @@ class Vt {
|
|
|
3500
3610
|
}
|
|
3501
3611
|
provideCompletionItems(e, n) {
|
|
3502
3612
|
var E, h;
|
|
3503
|
-
const s = Ke(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s),
|
|
3613
|
+
const s = Ke(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), c = a === void 0 ? i[0] : i[a + 1];
|
|
3504
3614
|
if ([
|
|
3505
3615
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3506
3616
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3507
|
-
...(
|
|
3508
|
-
].find((m) =>
|
|
3509
|
-
return
|
|
3617
|
+
...(c == null ? void 0 : c.leadingTrivia) || []
|
|
3618
|
+
].find((m) => Qt(m) && ge(s, m)))
|
|
3619
|
+
return R();
|
|
3510
3620
|
if (a === void 0)
|
|
3511
3621
|
return Tt();
|
|
3512
|
-
if ([
|
|
3513
|
-
return
|
|
3622
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
|
|
3623
|
+
return R();
|
|
3514
3624
|
const p = this.compiler.container.element(s);
|
|
3515
|
-
if (this.compiler.container.scopeKind(s) ===
|
|
3625
|
+
if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof v && p.type && p.type.start <= s && p.type.end >= s)
|
|
3516
3626
|
return Tt();
|
|
3517
3627
|
const f = [...this.compiler.container.stack(s)].reverse();
|
|
3518
3628
|
for (const m of f)
|
|
@@ -3551,19 +3661,19 @@ class Vt {
|
|
|
3551
3661
|
return Et(this.compiler, s, m);
|
|
3552
3662
|
if (m instanceof D)
|
|
3553
3663
|
return Et(this.compiler, s, m);
|
|
3554
|
-
if (m instanceof
|
|
3555
|
-
return
|
|
3664
|
+
if (m instanceof Z)
|
|
3665
|
+
return ts(this.compiler, s);
|
|
3556
3666
|
if (m instanceof y)
|
|
3557
3667
|
return mt(this.compiler, s, m);
|
|
3558
|
-
if (m instanceof
|
|
3668
|
+
if (m instanceof v && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
|
|
3559
3669
|
return mt(this.compiler, s, void 0);
|
|
3560
3670
|
}
|
|
3561
|
-
return
|
|
3671
|
+
return R();
|
|
3562
3672
|
}
|
|
3563
3673
|
}
|
|
3564
3674
|
function dt(t, e, n) {
|
|
3565
3675
|
const s = t.container.scopeKind(e);
|
|
3566
|
-
if ([
|
|
3676
|
+
if ([O.REF, O.TABLE].includes(s)) {
|
|
3567
3677
|
const i = Be(t, e, t.container.element(e), [
|
|
3568
3678
|
T.Table,
|
|
3569
3679
|
T.Schema,
|
|
@@ -3571,38 +3681,38 @@ function dt(t, e, n) {
|
|
|
3571
3681
|
]);
|
|
3572
3682
|
return De(n.op, e) ? Pe(i) : i;
|
|
3573
3683
|
}
|
|
3574
|
-
return
|
|
3684
|
+
return R();
|
|
3575
3685
|
}
|
|
3576
3686
|
function Be(t, e, n, s) {
|
|
3577
3687
|
var a;
|
|
3578
3688
|
if (n === void 0)
|
|
3579
|
-
return
|
|
3689
|
+
return R();
|
|
3580
3690
|
let i = n;
|
|
3581
3691
|
const r = { suggestions: [] };
|
|
3582
3692
|
for (; i; ) {
|
|
3583
3693
|
if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
|
|
3584
|
-
const { symbol:
|
|
3694
|
+
const { symbol: c } = i;
|
|
3585
3695
|
r.suggestions.push(
|
|
3586
|
-
...t.symbol.members(
|
|
3696
|
+
...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
|
|
3587
3697
|
label: p,
|
|
3588
3698
|
insertText: p,
|
|
3589
|
-
insertTextRules:
|
|
3699
|
+
insertTextRules: w.KeepWhitespace,
|
|
3590
3700
|
kind: Ae(f),
|
|
3591
3701
|
sortText: Ae(f).toString().padStart(2, "0"),
|
|
3592
3702
|
range: void 0
|
|
3593
3703
|
}))
|
|
3594
3704
|
);
|
|
3595
3705
|
}
|
|
3596
|
-
i = i instanceof
|
|
3706
|
+
i = i instanceof v ? i.parent : void 0;
|
|
3597
3707
|
}
|
|
3598
3708
|
return Fe(r);
|
|
3599
3709
|
}
|
|
3600
|
-
function
|
|
3710
|
+
function ts(t, e) {
|
|
3601
3711
|
var s;
|
|
3602
3712
|
switch (t.container.scopeKind(e)) {
|
|
3603
|
-
case
|
|
3713
|
+
case O.INDEXES:
|
|
3604
3714
|
return Xt(t, e);
|
|
3605
|
-
case
|
|
3715
|
+
case O.REF:
|
|
3606
3716
|
{
|
|
3607
3717
|
const i = [...t.container.stack(e)];
|
|
3608
3718
|
for (; i.length > 0; ) {
|
|
@@ -3617,100 +3727,112 @@ function es(t, e) {
|
|
|
3617
3727
|
}
|
|
3618
3728
|
return Ct(t, e);
|
|
3619
3729
|
}
|
|
3620
|
-
return
|
|
3730
|
+
return R();
|
|
3621
3731
|
}
|
|
3622
3732
|
function Et(t, e, n) {
|
|
3623
3733
|
const { token: s } = t.container.token(e);
|
|
3624
|
-
if ([
|
|
3734
|
+
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3625
3735
|
const i = Nt(t, e);
|
|
3626
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3736
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && De(s, e) ? Pe(i) : i;
|
|
3627
3737
|
}
|
|
3628
3738
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3629
3739
|
return Nt(t, e);
|
|
3630
|
-
if (n.name instanceof
|
|
3631
|
-
const i =
|
|
3740
|
+
if (n.name instanceof Y) {
|
|
3741
|
+
const i = ns(
|
|
3632
3742
|
t,
|
|
3633
3743
|
e,
|
|
3634
3744
|
Te(n.name).unwrap_or("")
|
|
3635
3745
|
);
|
|
3636
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3746
|
+
return (s == null ? void 0 : s.kind) === u.COLON && De(s, e) ? Pe(i) : i;
|
|
3637
3747
|
}
|
|
3638
|
-
return
|
|
3748
|
+
return R();
|
|
3639
3749
|
}
|
|
3640
3750
|
function Nt(t, e) {
|
|
3641
3751
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3642
|
-
if (n instanceof
|
|
3643
|
-
return
|
|
3752
|
+
if (n instanceof X)
|
|
3753
|
+
return R();
|
|
3644
3754
|
if (n.body && !ge(e, n.body))
|
|
3645
3755
|
switch (s) {
|
|
3646
|
-
case
|
|
3756
|
+
case O.TABLE:
|
|
3647
3757
|
return {
|
|
3648
3758
|
suggestions: [
|
|
3649
3759
|
{
|
|
3650
3760
|
label: "headercolor",
|
|
3651
3761
|
insertText: "headercolor: ",
|
|
3652
3762
|
kind: L.Field,
|
|
3653
|
-
insertTextRules:
|
|
3763
|
+
insertTextRules: w.KeepWhitespace,
|
|
3654
3764
|
range: void 0
|
|
3655
3765
|
},
|
|
3656
3766
|
{
|
|
3657
3767
|
label: "note",
|
|
3658
3768
|
insertText: "note: ",
|
|
3659
3769
|
kind: L.Field,
|
|
3660
|
-
insertTextRules:
|
|
3770
|
+
insertTextRules: w.KeepWhitespace,
|
|
3771
|
+
range: void 0
|
|
3772
|
+
}
|
|
3773
|
+
]
|
|
3774
|
+
};
|
|
3775
|
+
case O.TABLEGROUP:
|
|
3776
|
+
return {
|
|
3777
|
+
suggestions: [
|
|
3778
|
+
{
|
|
3779
|
+
label: "note",
|
|
3780
|
+
insertText: "note: ",
|
|
3781
|
+
kind: L.Field,
|
|
3782
|
+
insertTextRules: w.KeepWhitespace,
|
|
3661
3783
|
range: void 0
|
|
3662
3784
|
}
|
|
3663
3785
|
]
|
|
3664
3786
|
};
|
|
3665
3787
|
default:
|
|
3666
|
-
return
|
|
3788
|
+
return R();
|
|
3667
3789
|
}
|
|
3668
3790
|
switch (s) {
|
|
3669
|
-
case
|
|
3791
|
+
case O.TABLE:
|
|
3670
3792
|
return {
|
|
3671
3793
|
suggestions: [
|
|
3672
3794
|
...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
|
|
3673
3795
|
label: i,
|
|
3674
3796
|
insertText: i,
|
|
3675
3797
|
kind: L.Property,
|
|
3676
|
-
insertTextRules:
|
|
3798
|
+
insertTextRules: w.KeepWhitespace,
|
|
3677
3799
|
range: void 0
|
|
3678
3800
|
})),
|
|
3679
3801
|
...["ref", "default"].map((i) => ({
|
|
3680
3802
|
label: i,
|
|
3681
3803
|
insertText: `${i}: `,
|
|
3682
3804
|
kind: L.Property,
|
|
3683
|
-
insertTextRules:
|
|
3805
|
+
insertTextRules: w.KeepWhitespace,
|
|
3684
3806
|
range: void 0
|
|
3685
3807
|
})),
|
|
3686
3808
|
{
|
|
3687
3809
|
label: "note",
|
|
3688
3810
|
insertText: "note: ",
|
|
3689
3811
|
kind: L.Property,
|
|
3690
|
-
insertTextRules:
|
|
3812
|
+
insertTextRules: w.KeepWhitespace,
|
|
3691
3813
|
range: void 0
|
|
3692
3814
|
}
|
|
3693
3815
|
]
|
|
3694
3816
|
};
|
|
3695
|
-
case
|
|
3817
|
+
case O.ENUM:
|
|
3696
3818
|
return {
|
|
3697
3819
|
suggestions: [
|
|
3698
3820
|
{
|
|
3699
3821
|
label: "note",
|
|
3700
3822
|
insertText: "note: ",
|
|
3701
3823
|
kind: L.Property,
|
|
3702
|
-
insertTextRules:
|
|
3824
|
+
insertTextRules: w.KeepWhitespace,
|
|
3703
3825
|
range: void 0
|
|
3704
3826
|
}
|
|
3705
3827
|
]
|
|
3706
3828
|
};
|
|
3707
|
-
case
|
|
3829
|
+
case O.INDEXES:
|
|
3708
3830
|
return {
|
|
3709
3831
|
suggestions: [
|
|
3710
3832
|
...["unique", "pk"].map((i) => ({
|
|
3711
3833
|
label: i,
|
|
3712
3834
|
insertText: i,
|
|
3713
|
-
insertTextRules:
|
|
3835
|
+
insertTextRules: w.KeepWhitespace,
|
|
3714
3836
|
kind: L.Property,
|
|
3715
3837
|
range: void 0
|
|
3716
3838
|
})),
|
|
@@ -3718,25 +3840,25 @@ function Nt(t, e) {
|
|
|
3718
3840
|
label: i,
|
|
3719
3841
|
insertText: `${i}: `,
|
|
3720
3842
|
kind: L.Property,
|
|
3721
|
-
insertTextRules:
|
|
3843
|
+
insertTextRules: w.KeepWhitespace,
|
|
3722
3844
|
range: void 0
|
|
3723
3845
|
}))
|
|
3724
3846
|
]
|
|
3725
3847
|
};
|
|
3726
|
-
case
|
|
3848
|
+
case O.REF:
|
|
3727
3849
|
return {
|
|
3728
3850
|
suggestions: ["update", "delete"].map((i) => ({
|
|
3729
3851
|
label: i,
|
|
3730
3852
|
insertText: `${i}: `,
|
|
3731
3853
|
kind: L.Property,
|
|
3732
|
-
insertTextRules:
|
|
3854
|
+
insertTextRules: w.KeepWhitespace,
|
|
3733
3855
|
range: void 0
|
|
3734
3856
|
}))
|
|
3735
3857
|
};
|
|
3736
3858
|
}
|
|
3737
|
-
return
|
|
3859
|
+
return R();
|
|
3738
3860
|
}
|
|
3739
|
-
function
|
|
3861
|
+
function ns(t, e, n) {
|
|
3740
3862
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
3741
3863
|
case "update":
|
|
3742
3864
|
case "delete":
|
|
@@ -3745,7 +3867,7 @@ function ts(t, e, n) {
|
|
|
3745
3867
|
label: s,
|
|
3746
3868
|
insertText: s,
|
|
3747
3869
|
kind: L.Value,
|
|
3748
|
-
insertTextRules:
|
|
3870
|
+
insertTextRules: w.KeepWhitespace,
|
|
3749
3871
|
range: void 0
|
|
3750
3872
|
}))
|
|
3751
3873
|
};
|
|
@@ -3755,18 +3877,18 @@ function ts(t, e, n) {
|
|
|
3755
3877
|
label: s,
|
|
3756
3878
|
insertText: `${s}`,
|
|
3757
3879
|
kind: L.Value,
|
|
3758
|
-
insertTextRules:
|
|
3880
|
+
insertTextRules: w.KeepWhitespace,
|
|
3759
3881
|
range: void 0
|
|
3760
3882
|
}))
|
|
3761
3883
|
};
|
|
3762
3884
|
}
|
|
3763
|
-
return
|
|
3885
|
+
return R();
|
|
3764
3886
|
}
|
|
3765
3887
|
function Gt(t, e, n) {
|
|
3766
|
-
const s =
|
|
3888
|
+
const s = pe(n).unwrap_or([]);
|
|
3767
3889
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3768
|
-
return
|
|
3769
|
-
const i = s.map((r) =>
|
|
3890
|
+
return R();
|
|
3891
|
+
const i = s.map((r) => j(r).unwrap());
|
|
3770
3892
|
return Fe({
|
|
3771
3893
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3772
3894
|
label: a,
|
|
@@ -3779,22 +3901,22 @@ function Gt(t, e, n) {
|
|
|
3779
3901
|
function mt(t, e, n) {
|
|
3780
3902
|
var i;
|
|
3781
3903
|
switch (t.container.scopeKind(e)) {
|
|
3782
|
-
case
|
|
3783
|
-
return ss(t, e, n);
|
|
3784
|
-
case R.PROJECT:
|
|
3904
|
+
case O.TABLE:
|
|
3785
3905
|
return is(t, e, n);
|
|
3786
|
-
case
|
|
3787
|
-
return
|
|
3788
|
-
case
|
|
3789
|
-
return
|
|
3790
|
-
case
|
|
3906
|
+
case O.PROJECT:
|
|
3907
|
+
return rs(t, e, n);
|
|
3908
|
+
case O.INDEXES:
|
|
3909
|
+
return os(t, e);
|
|
3910
|
+
case O.ENUM:
|
|
3911
|
+
return ss(t, e, n);
|
|
3912
|
+
case O.REF: {
|
|
3791
3913
|
const r = Ct(t, e);
|
|
3792
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) ===
|
|
3914
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && De(t.container.token(e).token, e) ? Pe(r) : r;
|
|
3793
3915
|
}
|
|
3794
|
-
case
|
|
3795
|
-
return
|
|
3916
|
+
case O.TABLEGROUP:
|
|
3917
|
+
return as(t);
|
|
3796
3918
|
default:
|
|
3797
|
-
return
|
|
3919
|
+
return R();
|
|
3798
3920
|
}
|
|
3799
3921
|
}
|
|
3800
3922
|
function Tt() {
|
|
@@ -3802,26 +3924,26 @@ function Tt() {
|
|
|
3802
3924
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3803
3925
|
label: t,
|
|
3804
3926
|
insertText: t,
|
|
3805
|
-
insertTextRules:
|
|
3927
|
+
insertTextRules: w.KeepWhitespace,
|
|
3806
3928
|
kind: L.Keyword,
|
|
3807
3929
|
range: void 0
|
|
3808
3930
|
}))
|
|
3809
3931
|
};
|
|
3810
3932
|
}
|
|
3811
|
-
function
|
|
3933
|
+
function ss(t, e, n) {
|
|
3812
3934
|
return n != null && n.callee && et(e, n) === 1 ? Be(t, e, t.container.element(e), [
|
|
3813
3935
|
T.Schema,
|
|
3814
3936
|
T.Table,
|
|
3815
3937
|
T.Column
|
|
3816
|
-
]) :
|
|
3938
|
+
]) : R();
|
|
3817
3939
|
}
|
|
3818
|
-
function
|
|
3940
|
+
function is(t, e, n) {
|
|
3819
3941
|
if (!(n != null && n.callee))
|
|
3820
3942
|
return {
|
|
3821
3943
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3822
3944
|
label: i,
|
|
3823
3945
|
insertText: i,
|
|
3824
|
-
insertTextRules:
|
|
3946
|
+
insertTextRules: w.KeepWhitespace,
|
|
3825
3947
|
kind: L.Keyword,
|
|
3826
3948
|
range: void 0
|
|
3827
3949
|
}))
|
|
@@ -3831,26 +3953,26 @@ function ss(t, e, n) {
|
|
|
3831
3953
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3832
3954
|
label: i,
|
|
3833
3955
|
insertText: i,
|
|
3834
|
-
insertTextRules:
|
|
3956
|
+
insertTextRules: w.KeepWhitespace,
|
|
3835
3957
|
kind: L.Keyword,
|
|
3836
3958
|
range: void 0
|
|
3837
3959
|
}))
|
|
3838
|
-
} : s === 1 ?
|
|
3960
|
+
} : s === 1 ? ls(t, e) : R();
|
|
3839
3961
|
}
|
|
3840
|
-
function
|
|
3962
|
+
function rs(t, e, n) {
|
|
3841
3963
|
return n != null && n.callee ? et(e, n) === 0 ? {
|
|
3842
3964
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3843
3965
|
label: i,
|
|
3844
3966
|
insertText: i,
|
|
3845
|
-
insertTextRules:
|
|
3967
|
+
insertTextRules: w.KeepWhitespace,
|
|
3846
3968
|
kind: L.Keyword,
|
|
3847
3969
|
range: void 0
|
|
3848
3970
|
}))
|
|
3849
|
-
} :
|
|
3971
|
+
} : R() : {
|
|
3850
3972
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3851
3973
|
label: i,
|
|
3852
3974
|
insertText: i,
|
|
3853
|
-
insertTextRules:
|
|
3975
|
+
insertTextRules: w.KeepWhitespace,
|
|
3854
3976
|
kind: L.Keyword,
|
|
3855
3977
|
range: void 0
|
|
3856
3978
|
}))
|
|
@@ -3863,27 +3985,38 @@ function Ct(t, e) {
|
|
|
3863
3985
|
T.Column
|
|
3864
3986
|
]);
|
|
3865
3987
|
}
|
|
3866
|
-
function
|
|
3867
|
-
return
|
|
3868
|
-
suggestions: [
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3988
|
+
function as(t) {
|
|
3989
|
+
return {
|
|
3990
|
+
suggestions: [
|
|
3991
|
+
...Fe({
|
|
3992
|
+
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3993
|
+
const n = ie(e).unwrap_or(void 0);
|
|
3994
|
+
if (n === void 0)
|
|
3995
|
+
return [];
|
|
3996
|
+
const { kind: s, name: i } = n;
|
|
3997
|
+
return s !== T.Table && s !== T.Schema ? [] : {
|
|
3998
|
+
label: i,
|
|
3999
|
+
insertText: i,
|
|
4000
|
+
insertTextRules: w.KeepWhitespace,
|
|
4001
|
+
kind: Ae(s),
|
|
4002
|
+
range: void 0
|
|
4003
|
+
};
|
|
4004
|
+
})
|
|
4005
|
+
}).suggestions,
|
|
4006
|
+
...["Note"].map((e) => ({
|
|
4007
|
+
label: e,
|
|
4008
|
+
insertText: e,
|
|
4009
|
+
insertTextRules: w.KeepWhitespace,
|
|
4010
|
+
kind: L.Keyword,
|
|
3878
4011
|
range: void 0
|
|
3879
|
-
}
|
|
3880
|
-
|
|
3881
|
-
}
|
|
4012
|
+
}))
|
|
4013
|
+
]
|
|
4014
|
+
};
|
|
3882
4015
|
}
|
|
3883
|
-
function
|
|
4016
|
+
function os(t, e) {
|
|
3884
4017
|
return Xt(t, e);
|
|
3885
4018
|
}
|
|
3886
|
-
function
|
|
4019
|
+
function ls(t, e) {
|
|
3887
4020
|
return {
|
|
3888
4021
|
suggestions: [
|
|
3889
4022
|
...[
|
|
@@ -3946,7 +4079,7 @@ function os(t, e) {
|
|
|
3946
4079
|
].map((n) => ({
|
|
3947
4080
|
label: n,
|
|
3948
4081
|
insertText: n,
|
|
3949
|
-
insertTextRules:
|
|
4082
|
+
insertTextRules: w.KeepWhitespace,
|
|
3950
4083
|
kind: L.TypeParameter,
|
|
3951
4084
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3952
4085
|
range: void 0
|
|
@@ -3961,18 +4094,18 @@ function os(t, e) {
|
|
|
3961
4094
|
function Xt(t, e) {
|
|
3962
4095
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
3963
4096
|
if (!((s == null ? void 0 : s.symbol) instanceof At))
|
|
3964
|
-
return
|
|
4097
|
+
return R();
|
|
3965
4098
|
const { symbolTable: i } = s.symbol;
|
|
3966
4099
|
return Fe({
|
|
3967
4100
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
3968
4101
|
const a = ie(r).unwrap_or(void 0);
|
|
3969
4102
|
if (a === void 0)
|
|
3970
4103
|
return [];
|
|
3971
|
-
const { name:
|
|
4104
|
+
const { name: c } = a;
|
|
3972
4105
|
return {
|
|
3973
|
-
label:
|
|
3974
|
-
insertText:
|
|
3975
|
-
insertTextRules:
|
|
4106
|
+
label: c,
|
|
4107
|
+
insertText: c,
|
|
4108
|
+
insertTextRules: w.KeepWhitespace,
|
|
3976
4109
|
kind: Ae(T.Column),
|
|
3977
4110
|
range: void 0
|
|
3978
4111
|
};
|
|
@@ -3993,9 +4126,9 @@ class $t {
|
|
|
3993
4126
|
var a;
|
|
3994
4127
|
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
3995
4128
|
for (; r.length !== 0; ) {
|
|
3996
|
-
const
|
|
3997
|
-
if ((a =
|
|
3998
|
-
const { startPos: p, endPos: f } =
|
|
4129
|
+
const c = r.pop();
|
|
4130
|
+
if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(c == null ? void 0 : c.kind)) {
|
|
4131
|
+
const { startPos: p, endPos: f } = c.referee.declaration;
|
|
3999
4132
|
return [
|
|
4000
4133
|
{
|
|
4001
4134
|
range: {
|
|
@@ -4021,13 +4154,13 @@ class Wt {
|
|
|
4021
4154
|
for (; r.length !== 0; ) {
|
|
4022
4155
|
const a = r.pop();
|
|
4023
4156
|
if (a && [
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4157
|
+
Ne.ELEMENT_DECLARATION,
|
|
4158
|
+
Ne.FUNCTION_APPLICATION,
|
|
4159
|
+
Ne.PRIMARY_EXPRESSION
|
|
4027
4160
|
].includes(a == null ? void 0 : a.kind)) {
|
|
4028
|
-
const { symbol:
|
|
4029
|
-
if (
|
|
4030
|
-
return
|
|
4161
|
+
const { symbol: c } = a;
|
|
4162
|
+
if (c != null && c.references.length)
|
|
4163
|
+
return c.references.map(({ startPos: p, endPos: f }) => ({
|
|
4031
4164
|
range: {
|
|
4032
4165
|
startColumn: p.column + 1,
|
|
4033
4166
|
startLineNumber: p.line + 1,
|
|
@@ -4041,21 +4174,21 @@ class Wt {
|
|
|
4041
4174
|
return [];
|
|
4042
4175
|
}
|
|
4043
4176
|
}
|
|
4044
|
-
const
|
|
4177
|
+
const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4045
4178
|
__proto__: null,
|
|
4046
|
-
CompletionItemInsertTextRule:
|
|
4179
|
+
CompletionItemInsertTextRule: w,
|
|
4047
4180
|
CompletionItemKind: L,
|
|
4048
4181
|
DBMLCompletionItemProvider: Vt,
|
|
4049
4182
|
DBMLDefinitionProvider: $t,
|
|
4050
4183
|
DBMLReferencesProvider: Wt
|
|
4051
4184
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4052
|
-
var
|
|
4053
|
-
class
|
|
4185
|
+
var O = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(O || {});
|
|
4186
|
+
class fs {
|
|
4054
4187
|
constructor() {
|
|
4055
4188
|
this.source = "", this.cache = new Array(
|
|
4056
4189
|
16
|
|
4057
4190
|
/* TOTAL_QUERY_COUNT */
|
|
4058
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4191
|
+
).fill(null), this.nodeIdGenerator = new qt(), this.symbolIdGenerator = new en(), this.token = {
|
|
4059
4192
|
invalidStream: this.createQuery(
|
|
4060
4193
|
6,
|
|
4061
4194
|
() => this.parse.tokens().filter(vt)
|
|
@@ -4070,8 +4203,8 @@ class hs {
|
|
|
4070
4203
|
_: this.createQuery(
|
|
4071
4204
|
0,
|
|
4072
4205
|
() => {
|
|
4073
|
-
const e = new
|
|
4074
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new
|
|
4206
|
+
const e = new hn(this.source).lex().chain((n) => new dn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Qn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4207
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Kn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4075
4208
|
}
|
|
4076
4209
|
),
|
|
4077
4210
|
ast: this.createQuery(
|
|
@@ -4095,19 +4228,19 @@ class hs {
|
|
|
4095
4228
|
stack: this.createQuery(
|
|
4096
4229
|
10,
|
|
4097
4230
|
(e) => {
|
|
4098
|
-
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 :
|
|
4231
|
+
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : Yt(n, (f) => !f.isInvalid, s);
|
|
4099
4232
|
if (r === -1)
|
|
4100
4233
|
return [this.parse.ast()];
|
|
4101
4234
|
const a = n[r].start;
|
|
4102
|
-
let
|
|
4103
|
-
const p = [
|
|
4235
|
+
let c = this.parse.ast();
|
|
4236
|
+
const p = [c];
|
|
4104
4237
|
for (; ; ) {
|
|
4105
|
-
const E =
|
|
4238
|
+
const E = un(c).find((h) => ge(a, h));
|
|
4106
4239
|
if (E === void 0 || E instanceof F)
|
|
4107
4240
|
break;
|
|
4108
|
-
p.push(E),
|
|
4241
|
+
p.push(E), c = E;
|
|
4109
4242
|
}
|
|
4110
|
-
if ((i == null ? void 0 : i.kind) ===
|
|
4243
|
+
if ((i == null ? void 0 : i.kind) === u.COLON)
|
|
4111
4244
|
return p;
|
|
4112
4245
|
for (; p.length > 0; ) {
|
|
4113
4246
|
let f = !1;
|
|
@@ -4118,10 +4251,10 @@ class hs {
|
|
|
4118
4251
|
h[m] === `
|
|
4119
4252
|
` && (p.pop(), f = !0);
|
|
4120
4253
|
} else
|
|
4121
|
-
E instanceof Q || E instanceof q ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof D ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof
|
|
4254
|
+
E instanceof Q || E instanceof q ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof D ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof Z ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof J ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof Y || E.end < e && (p.pop(), f = !0);
|
|
4122
4255
|
if (f) {
|
|
4123
4256
|
const h = it(p);
|
|
4124
|
-
h instanceof
|
|
4257
|
+
h instanceof v && h.end <= e && p.pop();
|
|
4125
4258
|
}
|
|
4126
4259
|
if (!f)
|
|
4127
4260
|
break;
|
|
@@ -4144,7 +4277,7 @@ class hs {
|
|
|
4144
4277
|
(e) => {
|
|
4145
4278
|
const n = this.container.stack(e);
|
|
4146
4279
|
for (let s = n.length - 1; s >= 0; s -= 1)
|
|
4147
|
-
if (n[s] instanceof
|
|
4280
|
+
if (n[s] instanceof v)
|
|
4148
4281
|
return n[s];
|
|
4149
4282
|
return this.parse.ast();
|
|
4150
4283
|
}
|
|
@@ -4158,7 +4291,7 @@ class hs {
|
|
|
4158
4291
|
),
|
|
4159
4292
|
scopeKind: this.createQuery(15, (e) => {
|
|
4160
4293
|
var s;
|
|
4161
|
-
if (this.container.element(e) instanceof
|
|
4294
|
+
if (this.container.element(e) instanceof X)
|
|
4162
4295
|
return 8;
|
|
4163
4296
|
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4164
4297
|
case "table":
|
|
@@ -4194,18 +4327,18 @@ class hs {
|
|
|
4194
4327
|
if (e.length === 0)
|
|
4195
4328
|
return [];
|
|
4196
4329
|
const s = [];
|
|
4197
|
-
for (let r = n; r; r = r instanceof
|
|
4330
|
+
for (let r = n; r; r = r instanceof v ? r.parent : void 0) {
|
|
4198
4331
|
if (!((i = r.symbol) != null && i.symbolTable))
|
|
4199
4332
|
continue;
|
|
4200
4333
|
const { symbolTable: a } = r.symbol;
|
|
4201
|
-
let
|
|
4334
|
+
let c = [a], p = [];
|
|
4202
4335
|
for (const f of e)
|
|
4203
|
-
p =
|
|
4204
|
-
(E) =>
|
|
4336
|
+
p = c.flatMap(
|
|
4337
|
+
(E) => Zt(f).flatMap((h) => {
|
|
4205
4338
|
const m = E.get(h), g = ie(h).unwrap_or(void 0);
|
|
4206
4339
|
return !m || !g ? [] : { ...g, symbol: m };
|
|
4207
4340
|
})
|
|
4208
|
-
),
|
|
4341
|
+
), c = p.flatMap(
|
|
4209
4342
|
(E) => E.symbol.symbolTable ? E.symbol.symbolTable : []
|
|
4210
4343
|
);
|
|
4211
4344
|
s.push(...p);
|
|
@@ -4232,8 +4365,8 @@ class hs {
|
|
|
4232
4365
|
if (r.has(a))
|
|
4233
4366
|
return r.get(a);
|
|
4234
4367
|
}
|
|
4235
|
-
const
|
|
4236
|
-
return i !== void 0 ? r instanceof Map ? r.set(a,
|
|
4368
|
+
const c = n(i);
|
|
4369
|
+
return i !== void 0 ? r instanceof Map ? r.set(a, c) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, c)) : this.cache[e] = c, c;
|
|
4237
4370
|
};
|
|
4238
4371
|
}
|
|
4239
4372
|
setSource(e) {
|
|
@@ -4251,7 +4384,7 @@ class hs {
|
|
|
4251
4384
|
}
|
|
4252
4385
|
}
|
|
4253
4386
|
export {
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4387
|
+
fs as Compiler,
|
|
4388
|
+
us as serialize,
|
|
4389
|
+
hs as services
|
|
4257
4390
|
};
|