@dbml/parse 3.4.3 → 3.5.1
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 +697 -703
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import I from "lodash";
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import I, { findLastIndex as jt, last as it } from "lodash";
|
|
2
|
+
var l = /* @__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))(l || {});
|
|
3
|
+
function Yt(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 === l.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 === l.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 === l.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 zt(t) {
|
|
63
|
+
return [l.SINGLE_LINE_COMMENT, l.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
|
}
|
|
@@ -108,7 +108,7 @@ class A extends x {
|
|
|
108
108
|
alias: i,
|
|
109
109
|
attributeList: r,
|
|
110
110
|
bodyColon: a,
|
|
111
|
-
body:
|
|
111
|
+
body: u
|
|
112
112
|
}, p) {
|
|
113
113
|
if (super(p, "<element-declaration>", [
|
|
114
114
|
e,
|
|
@@ -117,10 +117,10 @@ class A extends x {
|
|
|
117
117
|
i,
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
|
-
|
|
121
|
-
]),
|
|
120
|
+
u
|
|
121
|
+
]), u && a && !(u instanceof y || u instanceof A))
|
|
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 = u;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
class $ extends x {
|
|
@@ -151,7 +151,7 @@ class q extends x {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class Ue extends x {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
@@ -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
|
|
206
|
+
class We extends J {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -243,9 +243,9 @@ class U extends x {
|
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class xe extends x {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
|
-
const s = F.create(
|
|
248
|
+
const s = F.create(l.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -264,7 +264,7 @@ function gt(t, e) {
|
|
|
264
264
|
(i) => i !== null
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function ls(t, e = !1) {
|
|
268
268
|
return JSON.stringify(
|
|
269
269
|
t,
|
|
270
270
|
function(n, s) {
|
|
@@ -334,11 +334,11 @@ class w {
|
|
|
334
334
|
return !1;
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
var
|
|
338
|
-
function
|
|
337
|
+
var T = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t))(T || {});
|
|
338
|
+
function je(t) {
|
|
339
339
|
return `Schema:${t}`;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function Oe(t) {
|
|
342
342
|
return `Table:${t}`;
|
|
343
343
|
}
|
|
344
344
|
function Ye(t) {
|
|
@@ -356,7 +356,7 @@ function qe(t) {
|
|
|
356
356
|
function He(t) {
|
|
357
357
|
return `TableGroup field:${t}`;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function qt(t) {
|
|
360
360
|
return `Note:${t}`;
|
|
361
361
|
}
|
|
362
362
|
function Ve(t, e) {
|
|
@@ -368,9 +368,9 @@ function Ve(t, e) {
|
|
|
368
368
|
case "Enum field":
|
|
369
369
|
return Qe(t);
|
|
370
370
|
case "Schema":
|
|
371
|
-
return
|
|
371
|
+
return je(t);
|
|
372
372
|
case "Table":
|
|
373
|
-
return
|
|
373
|
+
return Oe(t);
|
|
374
374
|
case "TableGroup":
|
|
375
375
|
return qe(t);
|
|
376
376
|
case "TableGroup field":
|
|
@@ -381,22 +381,22 @@ function Ve(t, e) {
|
|
|
381
381
|
}
|
|
382
382
|
function ie(t) {
|
|
383
383
|
const [e, n] = t.split(":");
|
|
384
|
-
return Object.values(
|
|
384
|
+
return Object.values(T).includes(e) ? new S({
|
|
385
385
|
name: n,
|
|
386
386
|
kind: e
|
|
387
387
|
}) : new w();
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function Ht(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 Jt(t) {
|
|
397
397
|
return [
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
je,
|
|
399
|
+
Oe,
|
|
400
400
|
ze,
|
|
401
401
|
qe,
|
|
402
402
|
Ye,
|
|
@@ -404,19 +404,19 @@ function qt(t) {
|
|
|
404
404
|
He
|
|
405
405
|
].map((e) => e(t));
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function Me(t) {
|
|
408
408
|
return !!t.match(/(\p{L}|_|\p{M})/gu);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function Re(t) {
|
|
411
411
|
const [e] = t;
|
|
412
412
|
return e >= "0" && e <= "9";
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function Zt(t) {
|
|
415
415
|
const [e] = t;
|
|
416
|
-
return
|
|
416
|
+
return Re(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
417
417
|
}
|
|
418
418
|
function de(t) {
|
|
419
|
-
return
|
|
419
|
+
return Me(t) || Re(t);
|
|
420
420
|
}
|
|
421
421
|
function ct(t, e) {
|
|
422
422
|
const n = [], s = Math.min(t.length, e.length);
|
|
@@ -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 Kt {
|
|
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 en {
|
|
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 tn {
|
|
452
452
|
constructor({ declaration: e }, n) {
|
|
453
453
|
this.references = [], this.id = n, this.declaration = e;
|
|
454
454
|
}
|
|
@@ -458,25 +458,25 @@ class At {
|
|
|
458
458
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
class
|
|
461
|
+
class nn {
|
|
462
462
|
constructor({ declaration: e }, n) {
|
|
463
463
|
this.references = [], this.id = n, this.declaration = e;
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
class
|
|
466
|
+
class sn {
|
|
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 rn {
|
|
472
472
|
constructor({ declaration: e }, n) {
|
|
473
473
|
this.references = [], this.id = n, this.declaration = e;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
|
|
477
|
-
class
|
|
477
|
+
class c extends Error {
|
|
478
478
|
constructor(e, n, s) {
|
|
479
|
-
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this,
|
|
479
|
+
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, c.prototype);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
class B {
|
|
@@ -497,7 +497,7 @@ class B {
|
|
|
497
497
|
return new B(e(this.value), this.errors);
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function an(t, e, n) {
|
|
501
501
|
if (!t || !me(t) || e.length === 0)
|
|
502
502
|
return new w();
|
|
503
503
|
const s = [...e], i = Ge(t).unwrap(), r = s.pop();
|
|
@@ -529,47 +529,47 @@ function sn(t, e, n) {
|
|
|
529
529
|
) : new w();
|
|
530
530
|
}
|
|
531
531
|
function lt(t) {
|
|
532
|
-
return t.kind ===
|
|
532
|
+
return t.kind === l.IDENTIFIER && t.value === "as";
|
|
533
533
|
}
|
|
534
|
-
function
|
|
535
|
-
t && (t instanceof F ?
|
|
534
|
+
function N(t) {
|
|
535
|
+
t && (t instanceof F ? on(t) : cn(t));
|
|
536
536
|
}
|
|
537
|
-
function
|
|
538
|
-
t.kind !==
|
|
537
|
+
function on(t) {
|
|
538
|
+
t.kind !== l.EOF && (t.isInvalid = !0);
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function cn(t) {
|
|
541
541
|
if (t instanceof A)
|
|
542
|
-
|
|
542
|
+
N(t.type), N(t.name), N(t.as), N(t.alias), N(t.bodyColon), N(t.attributeList), N(t.body);
|
|
543
543
|
else if (t instanceof $)
|
|
544
|
-
t.identifiers.forEach(
|
|
544
|
+
t.identifiers.forEach(N);
|
|
545
545
|
else if (t instanceof se)
|
|
546
|
-
|
|
546
|
+
N(t.name), N(t.colon), N(t.value);
|
|
547
547
|
else if (t instanceof Q)
|
|
548
|
-
|
|
548
|
+
N(t.op), N(t.expression);
|
|
549
549
|
else if (t instanceof q)
|
|
550
|
-
|
|
551
|
-
else if (t instanceof
|
|
552
|
-
|
|
550
|
+
N(t.leftExpression), N(t.op), N(t.rightExpression);
|
|
551
|
+
else if (t instanceof Ue)
|
|
552
|
+
N(t.op), N(t.expression);
|
|
553
553
|
else if (t instanceof ne)
|
|
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
557
|
else if (t instanceof J)
|
|
558
|
-
|
|
558
|
+
N(t.tupleOpenParen), t.commaList.forEach(N), t.elementList.forEach(N), N(t.tupleCloseParen);
|
|
559
559
|
else if (t instanceof H)
|
|
560
|
-
|
|
560
|
+
N(t.callee), N(t.argumentList);
|
|
561
561
|
else if (t instanceof y)
|
|
562
|
-
|
|
562
|
+
N(t.callee), t.args.forEach(N);
|
|
563
563
|
else if (t instanceof U)
|
|
564
|
-
|
|
564
|
+
N(t.expression);
|
|
565
565
|
else if (t instanceof te)
|
|
566
|
-
|
|
566
|
+
N(t.value);
|
|
567
567
|
else if (t instanceof Z)
|
|
568
|
-
|
|
568
|
+
N(t.variable);
|
|
569
569
|
else if (t instanceof be)
|
|
570
|
-
|
|
570
|
+
N(t.literal);
|
|
571
571
|
else
|
|
572
|
-
throw t instanceof
|
|
572
|
+
throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
573
573
|
}
|
|
574
574
|
function vt(t) {
|
|
575
575
|
return !!(t != null && t.isInvalid);
|
|
@@ -577,7 +577,7 @@ function vt(t) {
|
|
|
577
577
|
function P(...t) {
|
|
578
578
|
return t.filter((e) => e !== void 0);
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function ln(t) {
|
|
581
581
|
if (t instanceof G)
|
|
582
582
|
return P(...t.body, t.eof);
|
|
583
583
|
if (t instanceof A)
|
|
@@ -602,7 +602,7 @@ function on(t) {
|
|
|
602
602
|
return P(t.op, t.expression);
|
|
603
603
|
if (t instanceof q)
|
|
604
604
|
return P(t.leftExpression, t.op, t.rightExpression);
|
|
605
|
-
if (t instanceof
|
|
605
|
+
if (t instanceof Ue)
|
|
606
606
|
return P(t.expression, t.op);
|
|
607
607
|
if (t instanceof te)
|
|
608
608
|
return P(t.value);
|
|
@@ -631,21 +631,21 @@ function on(t) {
|
|
|
631
631
|
t.array,
|
|
632
632
|
t.indexer
|
|
633
633
|
);
|
|
634
|
-
throw t instanceof
|
|
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
637
|
return M(t) ? new S(t.expression.variable) : new w();
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function j(t) {
|
|
640
640
|
var e;
|
|
641
|
-
return t instanceof U && (t.expression instanceof Z && t.expression.variable instanceof F && t.expression.variable.kind ===
|
|
641
|
+
return t instanceof U && (t.expression instanceof Z && t.expression.variable instanceof F && t.expression.variable.kind === l.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === l.STRING_LITERAL);
|
|
642
642
|
}
|
|
643
643
|
function M(t) {
|
|
644
644
|
return t instanceof U && t.expression instanceof Z && t.expression.variable instanceof F;
|
|
645
645
|
}
|
|
646
646
|
function me(t) {
|
|
647
647
|
var e;
|
|
648
|
-
return t instanceof U && t.expression instanceof Z && ((e = t.expression.variable) == null ? void 0 : e.kind) ===
|
|
648
|
+
return t instanceof U && t.expression instanceof Z && ((e = t.expression.variable) == null ? void 0 : e.kind) === l.IDENTIFIER;
|
|
649
649
|
}
|
|
650
650
|
function Je(t) {
|
|
651
651
|
var e;
|
|
@@ -657,7 +657,7 @@ function Te(t) {
|
|
|
657
657
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
658
658
|
return e === "" ? new w() : new S(e);
|
|
659
659
|
}
|
|
660
|
-
class
|
|
660
|
+
class un {
|
|
661
661
|
// list of errors during lexing
|
|
662
662
|
constructor(e) {
|
|
663
663
|
this.start = {
|
|
@@ -706,50 +706,50 @@ class cn {
|
|
|
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(l.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(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(l.SPACE);
|
|
717
717
|
break;
|
|
718
718
|
case "\r":
|
|
719
719
|
break;
|
|
720
720
|
case `
|
|
721
721
|
`:
|
|
722
|
-
this.addToken(
|
|
722
|
+
this.addToken(l.NEWLINE);
|
|
723
723
|
break;
|
|
724
724
|
case " ":
|
|
725
|
-
this.addToken(
|
|
725
|
+
this.addToken(l.TAB);
|
|
726
726
|
break;
|
|
727
727
|
case ",":
|
|
728
|
-
this.addToken(
|
|
728
|
+
this.addToken(l.COMMA);
|
|
729
729
|
break;
|
|
730
730
|
case "(":
|
|
731
|
-
this.addToken(
|
|
731
|
+
this.addToken(l.LPAREN);
|
|
732
732
|
break;
|
|
733
733
|
case ")":
|
|
734
|
-
this.addToken(
|
|
734
|
+
this.addToken(l.RPAREN);
|
|
735
735
|
break;
|
|
736
736
|
case "[":
|
|
737
|
-
this.addToken(
|
|
737
|
+
this.addToken(l.LBRACKET);
|
|
738
738
|
break;
|
|
739
739
|
case "]":
|
|
740
|
-
this.addToken(
|
|
740
|
+
this.addToken(l.RBRACKET);
|
|
741
741
|
break;
|
|
742
742
|
case "{":
|
|
743
|
-
this.addToken(
|
|
743
|
+
this.addToken(l.LBRACE);
|
|
744
744
|
break;
|
|
745
745
|
case "}":
|
|
746
|
-
this.addToken(
|
|
746
|
+
this.addToken(l.RBRACE);
|
|
747
747
|
break;
|
|
748
748
|
case ";":
|
|
749
|
-
this.addToken(
|
|
749
|
+
this.addToken(l.SEMICOLON);
|
|
750
750
|
break;
|
|
751
751
|
case ":":
|
|
752
|
-
this.addToken(
|
|
752
|
+
this.addToken(l.COLON);
|
|
753
753
|
break;
|
|
754
754
|
case "'":
|
|
755
755
|
this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
|
|
@@ -771,19 +771,19 @@ class cn {
|
|
|
771
771
|
this.operator();
|
|
772
772
|
break;
|
|
773
773
|
}
|
|
774
|
-
if (
|
|
774
|
+
if (Me(e)) {
|
|
775
775
|
this.identifier();
|
|
776
776
|
break;
|
|
777
777
|
}
|
|
778
|
-
if (
|
|
778
|
+
if (Re(e)) {
|
|
779
779
|
this.numericLiteralOrIdentifier();
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
|
-
this.addToken(
|
|
783
|
-
new
|
|
782
|
+
this.addToken(l.OP, !0), this.errors.push(
|
|
783
|
+
new c(
|
|
784
784
|
o.UNKNOWN_SYMBOL,
|
|
785
785
|
`Unexpected token '${e}'`,
|
|
786
|
-
this.createToken(
|
|
786
|
+
this.createToken(l.OP, !0)
|
|
787
787
|
)
|
|
788
788
|
);
|
|
789
789
|
break;
|
|
@@ -795,7 +795,7 @@ class cn {
|
|
|
795
795
|
let e = !0, n = [], s;
|
|
796
796
|
const i = [];
|
|
797
797
|
for (const r of this.tokens)
|
|
798
|
-
|
|
798
|
+
Yt(r) ? (n.push(r), r.kind === l.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 cn {
|
|
|
820
820
|
// Whether to interpret '\' as a backlash
|
|
821
821
|
consumeStopSequence: a = !0
|
|
822
822
|
}) {
|
|
823
|
-
let
|
|
823
|
+
let u = "";
|
|
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(), u += this.escapedString()) : u += this.advance();
|
|
827
827
|
if (this.isAtEnd() && !i) {
|
|
828
828
|
const p = this.createToken(e, !0);
|
|
829
829
|
this.tokens.push(p), this.errors.push(
|
|
830
|
-
new
|
|
830
|
+
new c(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
|
|
831
831
|
);
|
|
832
832
|
return;
|
|
833
833
|
}
|
|
@@ -835,7 +835,7 @@ class cn {
|
|
|
835
835
|
`) && !s) {
|
|
836
836
|
const p = this.createToken(e, !0);
|
|
837
837
|
this.tokens.push(p), this.errors.push(
|
|
838
|
-
new
|
|
838
|
+
new c(
|
|
839
839
|
o.UNEXPECTED_NEWLINE,
|
|
840
840
|
"Invalid newline encountered while parsing",
|
|
841
841
|
p
|
|
@@ -843,38 +843,38 @@ class cn {
|
|
|
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, u, !1));
|
|
847
847
|
}
|
|
848
848
|
singleLineStringLiteral() {
|
|
849
|
-
this.consumeUntil(
|
|
849
|
+
this.consumeUntil(l.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(l.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(l.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(l.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(l.SINGLE_LINE_COMMENT, `
|
|
878
878
|
`, {
|
|
879
879
|
allowNewline: !0,
|
|
880
880
|
allowEof: !0,
|
|
@@ -883,7 +883,7 @@ class cn {
|
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
885
|
multilineComment() {
|
|
886
|
-
this.consumeUntil(
|
|
886
|
+
this.consumeUntil(l.MULTILINE_COMMENT, "*/", {
|
|
887
887
|
allowNewline: !0,
|
|
888
888
|
allowEof: !1,
|
|
889
889
|
raw: !0
|
|
@@ -892,46 +892,46 @@ class cn {
|
|
|
892
892
|
identifier() {
|
|
893
893
|
for (; !this.isAtEnd() && de(this.peek()); )
|
|
894
894
|
this.advance();
|
|
895
|
-
this.addToken(
|
|
895
|
+
this.addToken(l.IDENTIFIER);
|
|
896
896
|
}
|
|
897
897
|
operator() {
|
|
898
898
|
for (; rt(this.peek()); )
|
|
899
899
|
this.advance();
|
|
900
|
-
this.addToken(
|
|
900
|
+
this.addToken(l.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(l.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(
|
|
912
|
+
return this.advance(), this.addToken(l.NUMERIC_LITERAL);
|
|
913
913
|
if (!n && !de(this.peek()))
|
|
914
|
-
return this.addToken(
|
|
915
|
-
if (!n && !
|
|
914
|
+
return this.addToken(l.NUMERIC_LITERAL);
|
|
915
|
+
if (!n && !Re(this.peek()))
|
|
916
916
|
break;
|
|
917
917
|
this.advance();
|
|
918
918
|
}
|
|
919
919
|
if (e > 0) {
|
|
920
920
|
for (; !this.isAtEnd() && (this.check(".") || de(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(l.NUMERIC_LITERAL, !0);
|
|
923
|
+
this.tokens.push(n), this.errors.push(new c(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
924
924
|
} else {
|
|
925
925
|
for (; !this.isAtEnd() && de(this.peek()); )
|
|
926
926
|
this.advance();
|
|
927
|
-
const n = this.createToken(
|
|
927
|
+
const n = this.createToken(l.IDENTIFIER, !1);
|
|
928
928
|
this.tokens.push(n);
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
colorLiteral() {
|
|
932
932
|
for (; !this.isAtEnd() && de(this.peek()); )
|
|
933
933
|
this.advance();
|
|
934
|
-
this.addToken(
|
|
934
|
+
this.addToken(l.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 };
|
|
@@ -971,7 +971,7 @@ class cn {
|
|
|
971
971
|
let n = "";
|
|
972
972
|
for (let s = 0; s <= 3; s += 1) {
|
|
973
973
|
if (this.isAtEnd() || !de(this.peek()))
|
|
974
|
-
return this.errors.push(new
|
|
974
|
+
return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(l.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));
|
|
@@ -981,8 +981,8 @@ class cn {
|
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
|
-
var
|
|
985
|
-
class
|
|
984
|
+
var Se = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Se || {});
|
|
985
|
+
class hn {
|
|
986
986
|
constructor() {
|
|
987
987
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
988
988
|
}
|
|
@@ -1023,7 +1023,7 @@ class ln {
|
|
|
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 l.COMMA:
|
|
1027
1027
|
if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
|
|
1028
1028
|
return [...this.stack].reverse().find(
|
|
1029
1029
|
(r) => [
|
|
@@ -1033,22 +1033,22 @@ class ln {
|
|
|
1033
1033
|
].includes(r)
|
|
1034
1034
|
);
|
|
1035
1035
|
break;
|
|
1036
|
-
case
|
|
1036
|
+
case l.RPAREN:
|
|
1037
1037
|
if (this.isWithinGroupExpressionContext())
|
|
1038
1038
|
return 1;
|
|
1039
1039
|
break;
|
|
1040
|
-
case
|
|
1040
|
+
case l.RBRACE:
|
|
1041
1041
|
if (this.isWithinBlockExpressionContext())
|
|
1042
1042
|
return 2;
|
|
1043
1043
|
break;
|
|
1044
|
-
case
|
|
1044
|
+
case l.RBRACKET:
|
|
1045
1045
|
if (this.isWithinListExpressionContext())
|
|
1046
1046
|
return 0;
|
|
1047
1047
|
break;
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
|
-
class
|
|
1051
|
+
class fn {
|
|
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 pn {
|
|
1065
1065
|
constructor(e, n) {
|
|
1066
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1066
|
+
this.current = 0, this.errors = [], this.contextStack = new hn(), this.synchronizeProgram = () => {
|
|
1067
1067
|
const s = this.peek();
|
|
1068
|
-
s.kind !==
|
|
1068
|
+
s.kind !== l.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 (lt(s) || this.check(
|
|
1072
|
+
if (lt(s) || this.check(l.COLON, l.LBRACE, l.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(l.COLON, l.LBRACE, l.LBRACKET))
|
|
1080
1080
|
break;
|
|
1081
|
-
|
|
1081
|
+
N(s), this.advance();
|
|
1082
1082
|
}
|
|
1083
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1083
|
+
}, this.blockExpression = this.contextStack.withContextDo(Se.BlockExpression, () => {
|
|
1084
1084
|
const s = { body: [] }, i = () => this.nodeFactory.create(ne, s);
|
|
1085
1085
|
try {
|
|
1086
|
-
this.consume("Expect an opening brace '{'",
|
|
1086
|
+
this.consume("Expect an opening brace '{'", l.LBRACE), s.blockOpenBrace = this.previous();
|
|
1087
1087
|
} catch (r) {
|
|
1088
1088
|
if (!(r instanceof d))
|
|
1089
1089
|
throw r;
|
|
@@ -1091,7 +1091,7 @@ class hn {
|
|
|
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(l.RBRACE); )
|
|
1095
1095
|
try {
|
|
1096
1096
|
s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
|
|
1097
1097
|
} catch (r) {
|
|
@@ -1102,7 +1102,7 @@ class hn {
|
|
|
1102
1102
|
this.synchronizeBlock();
|
|
1103
1103
|
}
|
|
1104
1104
|
try {
|
|
1105
|
-
this.consume("Expect a closing brace '}'",
|
|
1105
|
+
this.consume("Expect a closing brace '}'", l.RBRACE), s.blockCloseBrace = this.previous();
|
|
1106
1106
|
} catch (r) {
|
|
1107
1107
|
if (!(r instanceof d))
|
|
1108
1108
|
throw r;
|
|
@@ -1112,21 +1112,21 @@ class hn {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
return i();
|
|
1114
1114
|
}), this.synchronizeBlock = () => {
|
|
1115
|
-
if (!this.check(
|
|
1116
|
-
for (
|
|
1115
|
+
if (!this.check(l.RBRACE))
|
|
1116
|
+
for (N(this.advance()); !this.isAtEnd(); ) {
|
|
1117
1117
|
const s = this.peek();
|
|
1118
|
-
if (this.check(
|
|
1118
|
+
if (this.check(l.RBRACE) || ot(this.previous(), s))
|
|
1119
1119
|
break;
|
|
1120
|
-
|
|
1120
|
+
N(s), this.advance();
|
|
1121
1121
|
}
|
|
1122
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1123
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1122
|
+
}, this.tupleExpression = this.contextStack.withContextDo(Se.GroupExpression, () => {
|
|
1123
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(We, {
|
|
1124
1124
|
groupOpenParen: s.tupleOpenParen,
|
|
1125
1125
|
groupCloseParen: s.tupleCloseParen,
|
|
1126
1126
|
expression: s.elementList[0]
|
|
1127
1127
|
}), r = () => this.nodeFactory.create(J, s);
|
|
1128
1128
|
try {
|
|
1129
|
-
this.consume("Expect an opening parenthesis '('",
|
|
1129
|
+
this.consume("Expect an opening parenthesis '('", l.LPAREN), s.tupleOpenParen = this.previous();
|
|
1130
1130
|
} catch (a) {
|
|
1131
1131
|
if (!(a instanceof d))
|
|
1132
1132
|
throw a;
|
|
@@ -1134,7 +1134,7 @@ class hn {
|
|
|
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(l.RPAREN))
|
|
1138
1138
|
try {
|
|
1139
1139
|
s.elementList.push(this.normalExpression());
|
|
1140
1140
|
} catch (a) {
|
|
@@ -1144,9 +1144,9 @@ class hn {
|
|
|
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(l.RPAREN); )
|
|
1148
1148
|
try {
|
|
1149
|
-
this.consume("Expect a comma ','",
|
|
1149
|
+
this.consume("Expect a comma ','", l.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 hn {
|
|
|
1155
1155
|
this.synchronizeTuple();
|
|
1156
1156
|
}
|
|
1157
1157
|
try {
|
|
1158
|
-
this.consume("Expect a closing parenthesis ')'",
|
|
1158
|
+
this.consume("Expect a closing parenthesis ')'", l.RPAREN), s.tupleCloseParen = this.previous();
|
|
1159
1159
|
} catch (a) {
|
|
1160
1160
|
if (!(a instanceof d))
|
|
1161
1161
|
throw a;
|
|
@@ -1167,14 +1167,14 @@ class hn {
|
|
|
1167
1167
|
}), this.synchronizeTuple = () => {
|
|
1168
1168
|
for (; !this.isAtEnd(); ) {
|
|
1169
1169
|
const s = this.peek();
|
|
1170
|
-
if (this.check(
|
|
1170
|
+
if (this.check(l.RPAREN, l.COMMA))
|
|
1171
1171
|
break;
|
|
1172
|
-
|
|
1172
|
+
N(s), this.advance();
|
|
1173
1173
|
}
|
|
1174
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
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 '['", l.LBRACKET), s.listOpenBracket = this.previous();
|
|
1178
1178
|
} catch (r) {
|
|
1179
1179
|
if (!(r instanceof d))
|
|
1180
1180
|
throw r;
|
|
@@ -1182,7 +1182,7 @@ class hn {
|
|
|
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(l.RBRACKET))
|
|
1186
1186
|
try {
|
|
1187
1187
|
s.elementList.push(this.attribute());
|
|
1188
1188
|
} catch (r) {
|
|
@@ -1192,9 +1192,9 @@ class hn {
|
|
|
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(l.RBRACKET); )
|
|
1196
1196
|
try {
|
|
1197
|
-
this.consume("Expect a comma ','",
|
|
1197
|
+
this.consume("Expect a comma ','", l.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 hn {
|
|
|
1203
1203
|
this.synchronizeList();
|
|
1204
1204
|
}
|
|
1205
1205
|
try {
|
|
1206
|
-
this.consume("Expect a closing bracket ']'",
|
|
1206
|
+
this.consume("Expect a closing bracket ']'", l.RBRACKET), s.listCloseBracket = this.previous();
|
|
1207
1207
|
} catch (r) {
|
|
1208
1208
|
if (!(r instanceof d))
|
|
1209
1209
|
throw r;
|
|
@@ -1215,28 +1215,28 @@ class hn {
|
|
|
1215
1215
|
}), this.synchronizeList = () => {
|
|
1216
1216
|
for (; !this.isAtEnd(); ) {
|
|
1217
1217
|
const s = this.peek();
|
|
1218
|
-
if (this.check(
|
|
1218
|
+
if (this.check(l.COMMA, l.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(l.COMMA, l.RBRACKET, l.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(l.COMMA, l.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 fn(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 === l.EOF;
|
|
1240
1240
|
}
|
|
1241
1241
|
advance() {
|
|
1242
1242
|
return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
|
|
@@ -1271,8 +1271,8 @@ class hn {
|
|
|
1271
1271
|
// Return whether the token of one of the listed kinds are eventually reached
|
|
1272
1272
|
discardUntil(e, ...n) {
|
|
1273
1273
|
if (this.isAtEnd() || !this.check(...n)) {
|
|
1274
|
-
for (
|
|
1275
|
-
|
|
1274
|
+
for (N(this.peek()), this.logError(this.advance(), o.UNEXPECTED_TOKEN, e); !this.isAtEnd() && !this.check(...n); )
|
|
1275
|
+
N(this.advance());
|
|
1276
1276
|
return !this.isAtEnd();
|
|
1277
1277
|
}
|
|
1278
1278
|
return !0;
|
|
@@ -1310,11 +1310,11 @@ class hn {
|
|
|
1310
1310
|
elementDeclaration() {
|
|
1311
1311
|
const e = {}, n = () => this.nodeFactory.create(A, e);
|
|
1312
1312
|
try {
|
|
1313
|
-
this.consume("Expect an identifier",
|
|
1313
|
+
this.consume("Expect an identifier", l.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(l.COLON, l.LBRACE, l.LBRACKET))
|
|
1318
1318
|
try {
|
|
1319
1319
|
e.name = this.normalExpression();
|
|
1320
1320
|
} catch (s) {
|
|
@@ -1325,7 +1325,7 @@ class hn {
|
|
|
1325
1325
|
this.synchronizeElementDeclarationName();
|
|
1326
1326
|
}
|
|
1327
1327
|
if (lt(this.peek()))
|
|
1328
|
-
if (e.as = this.advance(), this.check(
|
|
1328
|
+
if (e.as = this.advance(), this.check(l.COLON, l.LBRACE, l.LBRACKET))
|
|
1329
1329
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1330
1330
|
else
|
|
1331
1331
|
try {
|
|
@@ -1338,21 +1338,21 @@ class hn {
|
|
|
1338
1338
|
this.synchronizeElementDeclarationAlias();
|
|
1339
1339
|
}
|
|
1340
1340
|
try {
|
|
1341
|
-
e.attributeList = this.check(
|
|
1341
|
+
e.attributeList = this.check(l.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
|
+
l.LBRACE,
|
|
1348
|
+
l.COLON
|
|
1349
1349
|
))
|
|
1350
1350
|
return n();
|
|
1351
1351
|
try {
|
|
1352
|
-
if (this.match(
|
|
1352
|
+
if (this.match(l.COLON)) {
|
|
1353
1353
|
e.bodyColon = this.previous();
|
|
1354
1354
|
const s = this.expression();
|
|
1355
|
-
s instanceof A ? (
|
|
1355
|
+
s instanceof A ? (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) {
|
|
@@ -1369,18 +1369,18 @@ class hn {
|
|
|
1369
1369
|
fieldDeclaration() {
|
|
1370
1370
|
const e = {}, n = () => this.nodeFactory.create(A, e);
|
|
1371
1371
|
try {
|
|
1372
|
-
this.consume("Expect an identifier",
|
|
1372
|
+
this.consume("Expect an identifier", l.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 ':'", l.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 A ? this.errors.push(new
|
|
1383
|
+
s instanceof A ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1384
1384
|
} catch (s) {
|
|
1385
1385
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1386
1386
|
}
|
|
@@ -1388,7 +1388,7 @@ class hn {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1390
1390
|
expression() {
|
|
1391
|
-
const e = { args: [] }, n = () =>
|
|
1391
|
+
const e = { args: [] }, n = () => an(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 hn {
|
|
|
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 === l.RBRACE || e === l.RBRACKET || e === l.RPAREN || e === l.COMMA || e === l.COLON;
|
|
1417
1417
|
}
|
|
1418
1418
|
normalExpression() {
|
|
1419
1419
|
return this.expression_bp(0);
|
|
@@ -1423,7 +1423,7 @@ class hn {
|
|
|
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 === l.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,7 +1442,7 @@ class hn {
|
|
|
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 === l.LBRACKET) {
|
|
1446
1446
|
if (Ce(this.previous()))
|
|
1447
1447
|
break;
|
|
1448
1448
|
try {
|
|
@@ -1461,12 +1461,12 @@ class hn {
|
|
|
1461
1461
|
if (r.left !== null) {
|
|
1462
1462
|
if (r.left <= e)
|
|
1463
1463
|
break;
|
|
1464
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1464
|
+
this.advance(), n = this.nodeFactory.create(Ue, {
|
|
1465
1465
|
expression: n,
|
|
1466
1466
|
op: i
|
|
1467
1467
|
});
|
|
1468
1468
|
} else {
|
|
1469
|
-
const a =
|
|
1469
|
+
const a = En(i);
|
|
1470
1470
|
if (a.left === null || a.left <= e)
|
|
1471
1471
|
break;
|
|
1472
1472
|
this.advance();
|
|
@@ -1476,12 +1476,12 @@ class hn {
|
|
|
1476
1476
|
op: i,
|
|
1477
1477
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1478
1478
|
});
|
|
1479
|
-
} catch (
|
|
1480
|
-
throw
|
|
1479
|
+
} catch (u) {
|
|
1480
|
+
throw u instanceof d ? (n = this.nodeFactory.create(q, {
|
|
1481
1481
|
leftExpression: n,
|
|
1482
1482
|
op: i,
|
|
1483
|
-
rightExpression:
|
|
1484
|
-
}), new d(
|
|
1483
|
+
rightExpression: u.partialNode
|
|
1484
|
+
}), new d(u.token, n, u.handlerContext)) : u;
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
1487
|
} else
|
|
@@ -1494,7 +1494,7 @@ class hn {
|
|
|
1494
1494
|
if (at(this.peek())) {
|
|
1495
1495
|
const n = {};
|
|
1496
1496
|
n.op = this.peek();
|
|
1497
|
-
const s =
|
|
1497
|
+
const s = mn(n.op);
|
|
1498
1498
|
if (s.right === null)
|
|
1499
1499
|
throw this.logError(
|
|
1500
1500
|
n.op,
|
|
@@ -1502,7 +1502,7 @@ class hn {
|
|
|
1502
1502
|
`Unexpected '${n.op.value}' in an expression`
|
|
1503
1503
|
), new d(
|
|
1504
1504
|
n.op,
|
|
1505
|
-
this.nodeFactory.create(
|
|
1505
|
+
this.nodeFactory.create(xe, { pre: n.op }),
|
|
1506
1506
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1507
1507
|
);
|
|
1508
1508
|
this.advance();
|
|
@@ -1516,10 +1516,10 @@ class hn {
|
|
|
1516
1516
|
)) : i;
|
|
1517
1517
|
}
|
|
1518
1518
|
e = this.nodeFactory.create(Q, n);
|
|
1519
|
-
} else if (e = this.extractOperand(), e instanceof
|
|
1519
|
+
} else if (e = this.extractOperand(), e instanceof xe)
|
|
1520
1520
|
throw new d(
|
|
1521
1521
|
this.peek(),
|
|
1522
|
-
this.nodeFactory.create(
|
|
1522
|
+
this.nodeFactory.create(xe, { pre: this.peek() }),
|
|
1523
1523
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1524
1524
|
);
|
|
1525
1525
|
return e;
|
|
@@ -1530,12 +1530,12 @@ class hn {
|
|
|
1530
1530
|
// e.g { ... }
|
|
1531
1531
|
extractOperand() {
|
|
1532
1532
|
return this.check(
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
) ? this.primaryExpression() : this.check(
|
|
1533
|
+
l.NUMERIC_LITERAL,
|
|
1534
|
+
l.STRING_LITERAL,
|
|
1535
|
+
l.COLOR_LITERAL,
|
|
1536
|
+
l.QUOTED_STRING,
|
|
1537
|
+
l.IDENTIFIER
|
|
1538
|
+
) ? this.primaryExpression() : this.check(l.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(l.LBRACKET) ? this.listExpression() : this.check(l.LBRACE) ? this.blockExpression() : this.check(l.LPAREN) ? this.tupleExpression() : (this.peek().kind === l.EOF ? this.logError(
|
|
1539
1539
|
this.peek(),
|
|
1540
1540
|
o.UNEXPECTED_EOF,
|
|
1541
1541
|
"Unexpected EOF"
|
|
@@ -1543,13 +1543,13 @@ class hn {
|
|
|
1543
1543
|
this.peek(),
|
|
1544
1544
|
o.INVALID_OPERAND,
|
|
1545
1545
|
`Invalid start of operand "${this.peek().value}"`
|
|
1546
|
-
), this.nodeFactory.create(
|
|
1546
|
+
), this.nodeFactory.create(xe, { pre: this.previous() }));
|
|
1547
1547
|
}
|
|
1548
1548
|
/* Parsing FunctionExpression */
|
|
1549
1549
|
functionExpression() {
|
|
1550
1550
|
const e = {};
|
|
1551
1551
|
try {
|
|
1552
|
-
this.consume("Expect a function expression",
|
|
1552
|
+
this.consume("Expect a function expression", l.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,
|
|
@@ -1560,19 +1560,19 @@ class hn {
|
|
|
1560
1560
|
return this.nodeFactory.create(te, e);
|
|
1561
1561
|
}
|
|
1562
1562
|
canBeField() {
|
|
1563
|
-
return this.peek().kind ===
|
|
1563
|
+
return this.peek().kind === l.IDENTIFIER && this.peek(1).kind === l.COLON;
|
|
1564
1564
|
}
|
|
1565
1565
|
/* Parsing PrimaryExpression */
|
|
1566
1566
|
primaryExpression() {
|
|
1567
1567
|
if (this.match(
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1568
|
+
l.COLOR_LITERAL,
|
|
1569
|
+
l.STRING_LITERAL,
|
|
1570
|
+
l.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(l.QUOTED_STRING, l.IDENTIFIER))
|
|
1576
1576
|
return this.nodeFactory.create(U, {
|
|
1577
1577
|
expression: this.nodeFactory.create(Z, { variable: this.previous() })
|
|
1578
1578
|
});
|
|
@@ -1584,7 +1584,7 @@ class hn {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
attribute() {
|
|
1586
1586
|
const e = {};
|
|
1587
|
-
if (this.check(
|
|
1587
|
+
if (this.check(l.COLON, l.RBRACKET, l.COMMA)) {
|
|
1588
1588
|
const n = this.peek();
|
|
1589
1589
|
this.logError(
|
|
1590
1590
|
n,
|
|
@@ -1605,12 +1605,12 @@ class hn {
|
|
|
1605
1605
|
);
|
|
1606
1606
|
this.synchronizeAttributeName();
|
|
1607
1607
|
}
|
|
1608
|
-
return this.match(
|
|
1608
|
+
return this.match(l.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 === l.IDENTIFIER && this.peek(1).kind === l.IDENTIFIER ? this.attributeName() : this.normalExpression();
|
|
1614
1614
|
} catch (n) {
|
|
1615
1615
|
if (!(n instanceof d) || !this.canHandle(n))
|
|
1616
1616
|
throw n;
|
|
@@ -1620,11 +1620,11 @@ class hn {
|
|
|
1620
1620
|
}
|
|
1621
1621
|
attributeName() {
|
|
1622
1622
|
const e = [];
|
|
1623
|
-
if (this.peek().kind !==
|
|
1623
|
+
if (this.peek().kind !== l.IDENTIFIER)
|
|
1624
1624
|
return this.primaryExpression();
|
|
1625
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1625
|
+
for (; !this.isAtEnd() && !this.check(l.COLON, l.COMMA, l.RBRACKET); )
|
|
1626
1626
|
try {
|
|
1627
|
-
this.consume("Expect an identifier",
|
|
1627
|
+
this.consume("Expect an identifier", l.IDENTIFIER), e.push(this.previous());
|
|
1628
1628
|
} catch (n) {
|
|
1629
1629
|
throw n instanceof d ? new d(
|
|
1630
1630
|
n.token,
|
|
@@ -1635,10 +1635,10 @@ class hn {
|
|
|
1635
1635
|
return this.nodeFactory.create($, { identifiers: e });
|
|
1636
1636
|
}
|
|
1637
1637
|
logError(e, n, s) {
|
|
1638
|
-
this.errors.push(new
|
|
1638
|
+
this.errors.push(new c(n, s, e));
|
|
1639
1639
|
}
|
|
1640
1640
|
}
|
|
1641
|
-
const
|
|
1641
|
+
const dn = {
|
|
1642
1642
|
"+": { left: 9, right: 10 },
|
|
1643
1643
|
"*": { left: 11, right: 12 },
|
|
1644
1644
|
"-": { left: 9, right: 10 },
|
|
@@ -1654,10 +1654,10 @@ const fn = {
|
|
|
1654
1654
|
"!=": { left: 4, right: 5 },
|
|
1655
1655
|
".": { left: 16, right: 17 }
|
|
1656
1656
|
};
|
|
1657
|
-
function
|
|
1658
|
-
return
|
|
1657
|
+
function En(t) {
|
|
1658
|
+
return dn[t.value] || { left: null, right: null };
|
|
1659
1659
|
}
|
|
1660
|
-
const
|
|
1660
|
+
const Nn = {
|
|
1661
1661
|
"+": { left: null, right: 15 },
|
|
1662
1662
|
"-": { left: null, right: 15 },
|
|
1663
1663
|
"<": { left: null, right: 15 },
|
|
@@ -1665,14 +1665,14 @@ const dn = {
|
|
|
1665
1665
|
"<>": { left: null, right: 15 },
|
|
1666
1666
|
"!": { left: null, right: 15 }
|
|
1667
1667
|
};
|
|
1668
|
-
function
|
|
1669
|
-
return
|
|
1668
|
+
function mn(t) {
|
|
1669
|
+
return Nn[t.value] || { left: null, right: null };
|
|
1670
1670
|
}
|
|
1671
|
-
const
|
|
1671
|
+
const Tn = {
|
|
1672
1672
|
"(": { left: 14, right: null }
|
|
1673
1673
|
};
|
|
1674
1674
|
function ut(t) {
|
|
1675
|
-
return
|
|
1675
|
+
return Tn[t.value] || { left: null, right: null };
|
|
1676
1676
|
}
|
|
1677
1677
|
var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
|
|
1678
1678
|
function ve(t) {
|
|
@@ -1722,7 +1722,7 @@ function _e(t) {
|
|
|
1722
1722
|
let s;
|
|
1723
1723
|
if (!M(I.last(e))) {
|
|
1724
1724
|
const i = e.pop();
|
|
1725
|
-
if (
|
|
1725
|
+
if (xt(i))
|
|
1726
1726
|
s = i.elementList.map(
|
|
1727
1727
|
(r) => V(r).unwrap()
|
|
1728
1728
|
);
|
|
@@ -1760,13 +1760,13 @@ function V(t) {
|
|
|
1760
1760
|
return e === void 0 ? new w() : new S(e);
|
|
1761
1761
|
}
|
|
1762
1762
|
function z(t) {
|
|
1763
|
-
return
|
|
1763
|
+
return j(t) ? t.expression instanceof Z ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new w();
|
|
1764
1764
|
}
|
|
1765
|
-
function
|
|
1765
|
+
function bn(t) {
|
|
1766
1766
|
var e;
|
|
1767
|
-
return !(t instanceof q) || !
|
|
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 In(t) {
|
|
1770
1770
|
const e = _e(t.leftExpression), n = _e(t.rightExpression);
|
|
1771
1771
|
if (!e.isOk() || !n.isOk())
|
|
1772
1772
|
return !1;
|
|
@@ -1776,21 +1776,21 @@ function Tn(t) {
|
|
|
1776
1776
|
function ht(t) {
|
|
1777
1777
|
return t instanceof U && t.expression instanceof Z || t instanceof te;
|
|
1778
1778
|
}
|
|
1779
|
-
function
|
|
1780
|
-
var i, r, a,
|
|
1779
|
+
function Ln(t, e) {
|
|
1780
|
+
var i, r, a, u;
|
|
1781
1781
|
let n = e;
|
|
1782
|
-
const s =
|
|
1782
|
+
const s = Ht(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 (((u = n.symbol) == null ? void 0 : u.declaration) instanceof G && s)
|
|
1787
1787
|
return n.symbol;
|
|
1788
1788
|
if (n instanceof G)
|
|
1789
1789
|
return;
|
|
1790
1790
|
n = n.parent;
|
|
1791
1791
|
}
|
|
1792
1792
|
}
|
|
1793
|
-
class
|
|
1793
|
+
class gn {
|
|
1794
1794
|
constructor(e, n, s) {
|
|
1795
1795
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1796
1796
|
}
|
|
@@ -1798,24 +1798,24 @@ class In {
|
|
|
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 G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new
|
|
1801
|
+
return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1802
1802
|
}
|
|
1803
1803
|
validateName(e) {
|
|
1804
|
-
return e ? [new
|
|
1804
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
1805
1805
|
}
|
|
1806
1806
|
validateAlias(e) {
|
|
1807
|
-
return e ? [new
|
|
1807
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
|
|
1808
1808
|
}
|
|
1809
1809
|
validateSettingList(e) {
|
|
1810
|
-
return e ? [new
|
|
1810
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
|
|
1811
1811
|
}
|
|
1812
1812
|
validateBody(e) {
|
|
1813
1813
|
if (!e)
|
|
1814
1814
|
return [];
|
|
1815
1815
|
if (e instanceof ne)
|
|
1816
|
-
return [new
|
|
1816
|
+
return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1817
1817
|
const n = [];
|
|
1818
|
-
return
|
|
1818
|
+
return j(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
1821
|
class we {
|
|
@@ -1835,7 +1835,7 @@ class we {
|
|
|
1835
1835
|
return this.table.entries();
|
|
1836
1836
|
}
|
|
1837
1837
|
}
|
|
1838
|
-
class
|
|
1838
|
+
class _n {
|
|
1839
1839
|
constructor(e, n, s) {
|
|
1840
1840
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1841
1841
|
}
|
|
@@ -1843,26 +1843,26 @@ class Ln {
|
|
|
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 A ? [new
|
|
1846
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1847
1847
|
}
|
|
1848
1848
|
validateName(e) {
|
|
1849
|
-
return e ?
|
|
1849
|
+
return e ? yt(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
1850
1850
|
}
|
|
1851
1851
|
validateAlias(e) {
|
|
1852
|
-
return e ? [new
|
|
1852
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1853
1853
|
}
|
|
1854
1854
|
registerElement() {
|
|
1855
1855
|
const e = [];
|
|
1856
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1856
|
+
this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new we() });
|
|
1857
1857
|
const { name: n } = this.declarationNode, s = C(n);
|
|
1858
1858
|
if (s.isOk()) {
|
|
1859
|
-
const i = s.unwrap(), r = i.pop(), a =
|
|
1860
|
-
a.has(
|
|
1859
|
+
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), u = ze(r);
|
|
1860
|
+
a.has(u) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(u, this.declarationNode.symbol);
|
|
1861
1861
|
}
|
|
1862
1862
|
return e;
|
|
1863
1863
|
}
|
|
1864
1864
|
validateSettingList(e) {
|
|
1865
|
-
return e ? [new
|
|
1865
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
|
|
1866
1866
|
}
|
|
1867
1867
|
validateBody(e) {
|
|
1868
1868
|
if (!e)
|
|
@@ -1873,25 +1873,25 @@ class Ln {
|
|
|
1873
1873
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1874
1874
|
}
|
|
1875
1875
|
validateFields(e) {
|
|
1876
|
-
return e.length === 0 ? [new
|
|
1876
|
+
return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1877
1877
|
const s = [];
|
|
1878
|
-
n.callee && !M(n.callee) && s.push(new
|
|
1878
|
+
n.callee && !M(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1879
1879
|
const i = [...n.args];
|
|
1880
|
-
return I.last(i) instanceof 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 c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1881
1881
|
});
|
|
1882
1882
|
}
|
|
1883
1883
|
validateFieldSettings(e) {
|
|
1884
|
-
const n =
|
|
1884
|
+
const n = W(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((u) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", u))), a.forEach((u) => {
|
|
1890
|
+
j(u.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", u));
|
|
1891
1891
|
});
|
|
1892
1892
|
break;
|
|
1893
1893
|
default:
|
|
1894
|
-
a.forEach((
|
|
1894
|
+
a.forEach((u) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, u)));
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
return s;
|
|
@@ -1906,14 +1906,14 @@ class Ln {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
registerField(e) {
|
|
1908
1908
|
if (e.callee && M(e.callee)) {
|
|
1909
|
-
const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(
|
|
1909
|
+
const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
|
|
1910
1910
|
e.symbol = i;
|
|
1911
1911
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1912
1912
|
if (r.has(s)) {
|
|
1913
1913
|
const a = r.get(s);
|
|
1914
1914
|
return [
|
|
1915
|
-
new
|
|
1916
|
-
new
|
|
1915
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
|
|
1916
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
|
|
1917
1917
|
];
|
|
1918
1918
|
}
|
|
1919
1919
|
r.set(s, i);
|
|
@@ -1921,7 +1921,7 @@ class Ln {
|
|
|
1921
1921
|
return [];
|
|
1922
1922
|
}
|
|
1923
1923
|
}
|
|
1924
|
-
class
|
|
1924
|
+
class An {
|
|
1925
1925
|
constructor(e, n, s) {
|
|
1926
1926
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1927
1927
|
}
|
|
@@ -1929,22 +1929,22 @@ class gn {
|
|
|
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 G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new
|
|
1932
|
+
return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1933
1933
|
}
|
|
1934
1934
|
validateName(e) {
|
|
1935
|
-
return e ? [new
|
|
1935
|
+
return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
1936
1936
|
}
|
|
1937
1937
|
validateAlias(e) {
|
|
1938
|
-
return e ? [new
|
|
1938
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
|
|
1939
1939
|
}
|
|
1940
1940
|
validateSettingList(e) {
|
|
1941
|
-
return e ? [new
|
|
1941
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
|
|
1942
1942
|
}
|
|
1943
1943
|
validateBody(e) {
|
|
1944
1944
|
if (!e)
|
|
1945
1945
|
return [];
|
|
1946
1946
|
if (e instanceof y)
|
|
1947
|
-
return [new
|
|
1947
|
+
return [new c(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 gn {
|
|
|
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 c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
|
|
1959
|
+
Xe(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
1960
1960
|
}), s;
|
|
1961
1961
|
});
|
|
1962
1962
|
}
|
|
1963
1963
|
validateFieldSetting(e) {
|
|
1964
|
-
const n =
|
|
1964
|
+
const n = W(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((u) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, u))), a.forEach((u) => {
|
|
1971
|
+
j(u.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, u));
|
|
1972
1972
|
});
|
|
1973
1973
|
break;
|
|
1974
1974
|
case "unique":
|
|
1975
1975
|
case "pk":
|
|
1976
|
-
a.length > 1 && a.forEach((
|
|
1977
|
-
le(
|
|
1976
|
+
a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, u))), a.forEach((u) => {
|
|
1977
|
+
le(u.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, u));
|
|
1978
1978
|
});
|
|
1979
1979
|
break;
|
|
1980
1980
|
case "type":
|
|
1981
|
-
a.length > 1 && a.forEach((
|
|
1982
|
-
M(
|
|
1981
|
+
a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", u))), a.forEach((u) => {
|
|
1982
|
+
M(u.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, u));
|
|
1983
1983
|
});
|
|
1984
1984
|
break;
|
|
1985
1985
|
default:
|
|
1986
|
-
a.forEach((
|
|
1986
|
+
a.forEach((u) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, u)));
|
|
1987
1987
|
}
|
|
1988
1988
|
}
|
|
1989
1989
|
return s;
|
|
@@ -1997,7 +1997,7 @@ class gn {
|
|
|
1997
1997
|
});
|
|
1998
1998
|
}
|
|
1999
1999
|
}
|
|
2000
|
-
class
|
|
2000
|
+
class vn {
|
|
2001
2001
|
constructor(e, n, s) {
|
|
2002
2002
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2003
2003
|
}
|
|
@@ -2005,24 +2005,24 @@ class _n {
|
|
|
2005
2005
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2006
2006
|
}
|
|
2007
2007
|
validateContext() {
|
|
2008
|
-
return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new
|
|
2008
|
+
return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
|
|
2009
2009
|
}
|
|
2010
2010
|
validateName(e) {
|
|
2011
2011
|
if (!(this.declarationNode.parent instanceof G))
|
|
2012
|
-
return e ? [new
|
|
2012
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2013
2013
|
if (!e)
|
|
2014
|
-
return [new
|
|
2014
|
+
return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2015
2015
|
const n = C(e);
|
|
2016
2016
|
if (!n.isOk())
|
|
2017
|
-
return [new
|
|
2018
|
-
const i = n.unwrap().join("."), r =
|
|
2019
|
-
return this.publicSymbolTable.has(r) ? [new
|
|
2017
|
+
return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2018
|
+
const i = n.unwrap().join("."), r = qt(i);
|
|
2019
|
+
return this.publicSymbolTable.has(r) ? [new c(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
|
|
2020
2020
|
}
|
|
2021
2021
|
validateAlias(e) {
|
|
2022
|
-
return e ? [new
|
|
2022
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2023
2023
|
}
|
|
2024
2024
|
validateSettingList(e) {
|
|
2025
|
-
return e ? [new
|
|
2025
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
|
|
2026
2026
|
}
|
|
2027
2027
|
validateBody(e) {
|
|
2028
2028
|
if (!e)
|
|
@@ -2034,7 +2034,7 @@ class _n {
|
|
|
2034
2034
|
}
|
|
2035
2035
|
validateFields(e) {
|
|
2036
2036
|
const n = [];
|
|
2037
|
-
return e.length === 0 ? [new
|
|
2037
|
+
return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), j(e[0].callee) || n.push(new c(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2038
2038
|
}
|
|
2039
2039
|
validateSubElements(e) {
|
|
2040
2040
|
return e.flatMap((n) => {
|
|
@@ -2045,7 +2045,7 @@ class _n {
|
|
|
2045
2045
|
});
|
|
2046
2046
|
}
|
|
2047
2047
|
}
|
|
2048
|
-
class
|
|
2048
|
+
class wn {
|
|
2049
2049
|
constructor(e, n, s) {
|
|
2050
2050
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2051
2051
|
}
|
|
@@ -2053,25 +2053,25 @@ class An {
|
|
|
2053
2053
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2054
2054
|
}
|
|
2055
2055
|
validateContext() {
|
|
2056
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2056
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2057
2057
|
}
|
|
2058
2058
|
validateName(e) {
|
|
2059
|
-
return e ?
|
|
2059
|
+
return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2060
2060
|
}
|
|
2061
2061
|
validateAlias(e) {
|
|
2062
|
-
return e ? [new
|
|
2062
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
2063
2063
|
}
|
|
2064
2064
|
validateSettingList(e) {
|
|
2065
|
-
return e ? [new
|
|
2065
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
|
|
2066
2066
|
}
|
|
2067
2067
|
validateBody(e) {
|
|
2068
2068
|
if (!e)
|
|
2069
2069
|
return [];
|
|
2070
2070
|
if (e instanceof y)
|
|
2071
|
-
return [new
|
|
2071
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2072
2072
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2073
2073
|
return [
|
|
2074
|
-
...n.map((i) => new
|
|
2074
|
+
...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2075
2075
|
...this.validateSubElements(s)
|
|
2076
2076
|
];
|
|
2077
2077
|
}
|
|
@@ -2084,7 +2084,7 @@ class An {
|
|
|
2084
2084
|
});
|
|
2085
2085
|
}
|
|
2086
2086
|
}
|
|
2087
|
-
class
|
|
2087
|
+
class yn {
|
|
2088
2088
|
constructor(e, n, s) {
|
|
2089
2089
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2090
2090
|
}
|
|
@@ -2092,16 +2092,16 @@ class vn {
|
|
|
2092
2092
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2093
2093
|
}
|
|
2094
2094
|
validateContext() {
|
|
2095
|
-
return this.declarationNode.parent instanceof G ? [] : [new
|
|
2095
|
+
return this.declarationNode.parent instanceof G ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2096
2096
|
}
|
|
2097
2097
|
validateName(e) {
|
|
2098
|
-
return e ?
|
|
2098
|
+
return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2099
2099
|
}
|
|
2100
2100
|
validateAlias(e) {
|
|
2101
|
-
return e ? [new
|
|
2101
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2102
2102
|
}
|
|
2103
2103
|
validateSettingList(e) {
|
|
2104
|
-
return e ? [new
|
|
2104
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
|
|
2105
2105
|
}
|
|
2106
2106
|
validateBody(e) {
|
|
2107
2107
|
if (!e)
|
|
@@ -2113,27 +2113,27 @@ class vn {
|
|
|
2113
2113
|
}
|
|
2114
2114
|
validateFields(e) {
|
|
2115
2115
|
if (e.length === 0)
|
|
2116
|
-
return [new
|
|
2116
|
+
return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2117
2117
|
const n = [];
|
|
2118
|
-
return e.length > 1 && n.push(...e.slice(1).map((s) => new
|
|
2119
|
-
s.callee && !
|
|
2118
|
+
return e.length > 1 && n.push(...e.slice(1).map((s) => new c(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2119
|
+
s.callee && !bn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !In(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2120
2120
|
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
|
|
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 c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2122
2122
|
}), n;
|
|
2123
2123
|
}
|
|
2124
2124
|
validateFieldSettings(e) {
|
|
2125
|
-
const n =
|
|
2125
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
2126
2126
|
for (const r in i) {
|
|
2127
2127
|
const a = i[r];
|
|
2128
2128
|
switch (r) {
|
|
2129
2129
|
case "delete":
|
|
2130
2130
|
case "update":
|
|
2131
|
-
a.length > 1 && a.forEach((
|
|
2132
|
-
|
|
2131
|
+
a.length > 1 && a.forEach((u) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, u))), a.forEach((u) => {
|
|
2132
|
+
kn(u.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, u));
|
|
2133
2133
|
});
|
|
2134
2134
|
break;
|
|
2135
2135
|
default:
|
|
2136
|
-
a.forEach((
|
|
2136
|
+
a.forEach((u) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, u)));
|
|
2137
2137
|
}
|
|
2138
2138
|
}
|
|
2139
2139
|
return s;
|
|
@@ -2147,8 +2147,8 @@ class vn {
|
|
|
2147
2147
|
});
|
|
2148
2148
|
}
|
|
2149
2149
|
}
|
|
2150
|
-
function
|
|
2151
|
-
if (!(M(t) && t.expression.variable.kind !==
|
|
2150
|
+
function kn(t) {
|
|
2151
|
+
if (!(M(t) && t.expression.variable.kind !== l.QUOTED_STRING) && !(t instanceof $))
|
|
2152
2152
|
return !1;
|
|
2153
2153
|
let e;
|
|
2154
2154
|
if (t instanceof $ ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
@@ -2164,7 +2164,7 @@ function wn(t) {
|
|
|
2164
2164
|
}
|
|
2165
2165
|
return !1;
|
|
2166
2166
|
}
|
|
2167
|
-
class
|
|
2167
|
+
class xn {
|
|
2168
2168
|
constructor(e, n, s) {
|
|
2169
2169
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2170
2170
|
}
|
|
@@ -2172,31 +2172,31 @@ class yn {
|
|
|
2172
2172
|
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
2173
|
}
|
|
2174
2174
|
validateContext() {
|
|
2175
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2175
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2176
2176
|
}
|
|
2177
2177
|
validateName(e) {
|
|
2178
|
-
return e ? e instanceof ue ? [new
|
|
2178
|
+
return e ? e instanceof ue ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : yt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2179
2179
|
}
|
|
2180
2180
|
validateAlias(e) {
|
|
2181
|
-
return e ?
|
|
2181
|
+
return e ? Dn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2182
2182
|
}
|
|
2183
2183
|
validateSettingList(e) {
|
|
2184
|
-
const n =
|
|
2184
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
2185
2185
|
for (const r in i) {
|
|
2186
2186
|
const a = i[r];
|
|
2187
2187
|
switch (r) {
|
|
2188
2188
|
case "headercolor":
|
|
2189
|
-
a.length > 1 && s.push(...a.map((
|
|
2190
|
-
|
|
2189
|
+
a.length > 1 && s.push(...a.map((u) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", u))), a.forEach((u) => {
|
|
2190
|
+
Pn(u.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", u.value || u.name));
|
|
2191
2191
|
});
|
|
2192
2192
|
break;
|
|
2193
2193
|
case "note":
|
|
2194
|
-
a.length > 1 && s.push(...a.map((
|
|
2195
|
-
|
|
2194
|
+
a.length > 1 && s.push(...a.map((u) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", u))), a.forEach((u) => {
|
|
2195
|
+
j(u.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", u.value || u.name));
|
|
2196
2196
|
});
|
|
2197
2197
|
break;
|
|
2198
2198
|
default:
|
|
2199
|
-
s.push(...a.map((
|
|
2199
|
+
s.push(...a.map((u) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, u)));
|
|
2200
2200
|
}
|
|
2201
2201
|
}
|
|
2202
2202
|
return s;
|
|
@@ -2206,12 +2206,12 @@ class yn {
|
|
|
2206
2206
|
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2207
2207
|
const { name: n, alias: s } = this.declarationNode, i = C(n);
|
|
2208
2208
|
if (i.isOk()) {
|
|
2209
|
-
const r = [...i.unwrap()], a = r.pop(),
|
|
2210
|
-
|
|
2209
|
+
const r = [...i.unwrap()], a = r.pop(), u = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
|
|
2210
|
+
u.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), u.set(p, this.declarationNode.symbol);
|
|
2211
2211
|
}
|
|
2212
|
-
if (s &&
|
|
2213
|
-
const r = V(s).unwrap(), a =
|
|
2214
|
-
this.publicSymbolTable.has(a) && e.push(new
|
|
2212
|
+
if (s && ye(s) && !On(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2213
|
+
const r = V(s).unwrap(), a = Oe(r);
|
|
2214
|
+
this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2215
2215
|
}
|
|
2216
2216
|
return e;
|
|
2217
2217
|
}
|
|
@@ -2219,30 +2219,30 @@ class yn {
|
|
|
2219
2219
|
if (!e)
|
|
2220
2220
|
return [];
|
|
2221
2221
|
if (e instanceof y)
|
|
2222
|
-
return [new
|
|
2222
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2223
2223
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2224
2224
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2225
2225
|
}
|
|
2226
2226
|
validateFields(e) {
|
|
2227
|
-
return e.length === 0 ? [new
|
|
2227
|
+
return e.length === 0 ? [new c(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
|
|
2228
2228
|
if (!n.callee)
|
|
2229
2229
|
return [];
|
|
2230
2230
|
const s = [];
|
|
2231
|
-
n.args.length === 0 && s.push(new
|
|
2231
|
+
n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Sn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2232
2232
|
const i = n.args.slice(1);
|
|
2233
2233
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2234
2234
|
});
|
|
2235
2235
|
}
|
|
2236
2236
|
registerField(e) {
|
|
2237
2237
|
if (e.callee && M(e.callee)) {
|
|
2238
|
-
const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(
|
|
2238
|
+
const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(nn, { declaration: e });
|
|
2239
2239
|
e.symbol = i;
|
|
2240
2240
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2241
2241
|
if (r.has(s)) {
|
|
2242
2242
|
const a = r.get(s);
|
|
2243
2243
|
return [
|
|
2244
|
-
new
|
|
2245
|
-
new
|
|
2244
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
|
|
2245
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
|
|
2246
2246
|
];
|
|
2247
2247
|
}
|
|
2248
2248
|
r.set(s, i);
|
|
@@ -2252,74 +2252,74 @@ class yn {
|
|
|
2252
2252
|
// This is needed to support legacy inline settings
|
|
2253
2253
|
validateFieldSetting(e) {
|
|
2254
2254
|
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof D))
|
|
2255
|
-
return [...e.map((p) => new
|
|
2255
|
+
return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2256
2256
|
if (e.length === 0)
|
|
2257
2257
|
return [];
|
|
2258
2258
|
let n;
|
|
2259
2259
|
I.last(e) instanceof D && (n = e.pop());
|
|
2260
|
-
const s =
|
|
2260
|
+
const s = W(n), i = s.getErrors(), r = s.getValue();
|
|
2261
2261
|
for (const p of e) {
|
|
2262
|
-
const
|
|
2263
|
-
if (
|
|
2264
|
-
i.push(new
|
|
2262
|
+
const f = V(p).unwrap_or("").toLowerCase();
|
|
2263
|
+
if (f !== "pk" && f !== "unique") {
|
|
2264
|
+
i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2265
2265
|
continue;
|
|
2266
2266
|
}
|
|
2267
|
-
r[
|
|
2267
|
+
r[f] === void 0 ? r[f] = [p] : r[f].push(p);
|
|
2268
2268
|
}
|
|
2269
|
-
const a = r.pk || [],
|
|
2270
|
-
a.length >= 1 &&
|
|
2269
|
+
const a = r.pk || [], u = r["primary key"] || [];
|
|
2270
|
+
a.length >= 1 && u.length >= 1 && i.push(...[...a, ...u].map((p) => new c(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
|
|
2271
2271
|
for (const p in r) {
|
|
2272
|
-
const
|
|
2272
|
+
const f = r[p];
|
|
2273
2273
|
switch (p) {
|
|
2274
2274
|
case "note":
|
|
2275
|
-
|
|
2276
|
-
|
|
2275
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
|
|
2276
|
+
j(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
|
|
2277
2277
|
});
|
|
2278
2278
|
break;
|
|
2279
2279
|
case "ref":
|
|
2280
|
-
|
|
2281
|
-
|
|
2280
|
+
f.forEach((h) => {
|
|
2281
|
+
Mn(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
|
|
2282
2282
|
});
|
|
2283
2283
|
break;
|
|
2284
2284
|
case "primary key":
|
|
2285
|
-
|
|
2286
|
-
le(
|
|
2285
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", h))), f.forEach((h) => {
|
|
2286
|
+
le(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
|
|
2287
2287
|
});
|
|
2288
2288
|
break;
|
|
2289
2289
|
case "pk":
|
|
2290
|
-
|
|
2291
|
-
|
|
2290
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
|
|
2291
|
+
h instanceof se && !le(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
|
|
2292
2292
|
});
|
|
2293
2293
|
break;
|
|
2294
2294
|
case "not null":
|
|
2295
|
-
|
|
2296
|
-
const
|
|
2297
|
-
|
|
2298
|
-
le(
|
|
2295
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", h)));
|
|
2296
|
+
const E = r.null || [];
|
|
2297
|
+
f.length >= 1 && E.length >= 1 && i.push(...[...f, ...E].map((h) => new c(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", h))), f.forEach((h) => {
|
|
2298
|
+
le(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", h.value || h.name));
|
|
2299
2299
|
});
|
|
2300
2300
|
break;
|
|
2301
2301
|
case "null":
|
|
2302
|
-
|
|
2303
|
-
le(
|
|
2302
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", h))), f.forEach((h) => {
|
|
2303
|
+
le(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
|
|
2304
2304
|
});
|
|
2305
2305
|
break;
|
|
2306
2306
|
case "unique":
|
|
2307
|
-
|
|
2308
|
-
|
|
2307
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
|
|
2308
|
+
h instanceof se && !le(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
|
|
2309
2309
|
});
|
|
2310
2310
|
break;
|
|
2311
2311
|
case "increment":
|
|
2312
|
-
|
|
2313
|
-
|
|
2312
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
|
|
2313
|
+
h instanceof se && !le(h.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
|
|
2314
2314
|
});
|
|
2315
2315
|
break;
|
|
2316
2316
|
case "default":
|
|
2317
|
-
|
|
2318
|
-
|
|
2317
|
+
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
|
|
2318
|
+
Un(h.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
|
|
2319
2319
|
});
|
|
2320
2320
|
break;
|
|
2321
2321
|
default:
|
|
2322
|
-
|
|
2322
|
+
f.forEach((h) => i.push(new c(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, h)));
|
|
2323
2323
|
}
|
|
2324
2324
|
}
|
|
2325
2325
|
return i;
|
|
@@ -2334,14 +2334,14 @@ class yn {
|
|
|
2334
2334
|
var r;
|
|
2335
2335
|
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2336
2336
|
});
|
|
2337
|
-
return s.length > 1 && (n.push(...s.map((i) => new
|
|
2337
|
+
return s.length > 1 && (n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
|
|
2338
2338
|
}
|
|
2339
2339
|
}
|
|
2340
|
-
function
|
|
2340
|
+
function Sn(t) {
|
|
2341
2341
|
if (!(t instanceof H || Je(t) || t instanceof U || t instanceof ue))
|
|
2342
2342
|
return !1;
|
|
2343
2343
|
if (t instanceof H) {
|
|
2344
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => he(n) ||
|
|
2344
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => he(n) || j(n) || me(n)))
|
|
2345
2345
|
return !1;
|
|
2346
2346
|
t = t.callee;
|
|
2347
2347
|
}
|
|
@@ -2353,10 +2353,10 @@ function kn(t) {
|
|
|
2353
2353
|
const e = C(t).unwrap_or(void 0);
|
|
2354
2354
|
return e !== void 0 && e.length > 0;
|
|
2355
2355
|
}
|
|
2356
|
-
function
|
|
2356
|
+
function On(t, e) {
|
|
2357
2357
|
return e.length === 1 && t === e[0];
|
|
2358
2358
|
}
|
|
2359
|
-
class
|
|
2359
|
+
class Rn {
|
|
2360
2360
|
constructor(e, n, s) {
|
|
2361
2361
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2362
2362
|
}
|
|
@@ -2364,41 +2364,41 @@ class Sn {
|
|
|
2364
2364
|
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)];
|
|
2365
2365
|
}
|
|
2366
2366
|
validateContext() {
|
|
2367
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2367
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
2368
2368
|
}
|
|
2369
2369
|
validateName(e) {
|
|
2370
|
-
return e ?
|
|
2370
|
+
return e ? ye(e) ? [] : [new c(o.INVALID_NAME, "A TableGroup name must be a single identifier", e)] : [new c(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
2371
2371
|
}
|
|
2372
2372
|
validateAlias(e) {
|
|
2373
|
-
return e ? [new
|
|
2373
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
|
|
2374
2374
|
}
|
|
2375
2375
|
registerElement() {
|
|
2376
2376
|
const { name: e } = this.declarationNode;
|
|
2377
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2377
|
+
this.declarationNode.symbol = this.symbolFactory.create(sn, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2378
2378
|
const n = C(e);
|
|
2379
2379
|
if (n.isOk()) {
|
|
2380
|
-
const s = n.unwrap(), i = s.pop(), r =
|
|
2380
|
+
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
|
|
2381
2381
|
if (r.has(a))
|
|
2382
|
-
return [new
|
|
2382
|
+
return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
|
|
2383
2383
|
r.set(a, this.declarationNode.symbol);
|
|
2384
2384
|
}
|
|
2385
2385
|
return [];
|
|
2386
2386
|
}
|
|
2387
2387
|
validateSettingList(e) {
|
|
2388
|
-
return e ? [new
|
|
2388
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
|
|
2389
2389
|
}
|
|
2390
2390
|
validateBody(e) {
|
|
2391
2391
|
if (!e)
|
|
2392
2392
|
return [];
|
|
2393
2393
|
if (e instanceof y)
|
|
2394
|
-
return [new
|
|
2394
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2395
2395
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
2396
2396
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2397
2397
|
}
|
|
2398
2398
|
validateFields(e) {
|
|
2399
2399
|
return e.flatMap((n) => {
|
|
2400
2400
|
const s = [];
|
|
2401
|
-
return n.callee && !C(n.callee).isOk() && s.push(new
|
|
2401
|
+
return n.callee && !C(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2402
2402
|
});
|
|
2403
2403
|
}
|
|
2404
2404
|
validateSubElements(e) {
|
|
@@ -2411,14 +2411,14 @@ class Sn {
|
|
|
2411
2411
|
}
|
|
2412
2412
|
registerField(e) {
|
|
2413
2413
|
if (e.callee && M(e.callee)) {
|
|
2414
|
-
const n = V(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(
|
|
2414
|
+
const n = V(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(rn, { declaration: e });
|
|
2415
2415
|
e.symbol = i;
|
|
2416
2416
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2417
2417
|
if (r.has(s)) {
|
|
2418
2418
|
const a = r.get(s);
|
|
2419
2419
|
return [
|
|
2420
|
-
new
|
|
2421
|
-
new
|
|
2420
|
+
new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
|
|
2421
|
+
new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
|
|
2422
2422
|
];
|
|
2423
2423
|
}
|
|
2424
2424
|
r.set(s, i);
|
|
@@ -2430,88 +2430,88 @@ const wt = ["-", "+"];
|
|
|
2430
2430
|
function re(t) {
|
|
2431
2431
|
switch (t.type.value.toLowerCase()) {
|
|
2432
2432
|
case b.Enum:
|
|
2433
|
-
return
|
|
2433
|
+
return _n;
|
|
2434
2434
|
case b.Table:
|
|
2435
|
-
return
|
|
2435
|
+
return xn;
|
|
2436
2436
|
case b.TableGroup:
|
|
2437
|
-
return
|
|
2437
|
+
return Rn;
|
|
2438
2438
|
case b.Project:
|
|
2439
|
-
return
|
|
2439
|
+
return wn;
|
|
2440
2440
|
case b.Ref:
|
|
2441
|
-
return
|
|
2441
|
+
return yn;
|
|
2442
2442
|
case b.Note:
|
|
2443
|
-
return
|
|
2443
|
+
return vn;
|
|
2444
2444
|
case b.Indexes:
|
|
2445
|
-
return
|
|
2445
|
+
return An;
|
|
2446
2446
|
default:
|
|
2447
|
-
return
|
|
2447
|
+
return gn;
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
function
|
|
2450
|
+
function yt(t) {
|
|
2451
2451
|
return !!C(t).unwrap_or(!1);
|
|
2452
2452
|
}
|
|
2453
|
-
function
|
|
2454
|
-
return
|
|
2453
|
+
function Dn(t) {
|
|
2454
|
+
return ye(t);
|
|
2455
2455
|
}
|
|
2456
|
-
function
|
|
2456
|
+
function ye(t) {
|
|
2457
2457
|
return t instanceof U && t.expression instanceof Z;
|
|
2458
2458
|
}
|
|
2459
|
-
function
|
|
2459
|
+
function Ze(t, e, n) {
|
|
2460
2460
|
var i;
|
|
2461
2461
|
t[0] === "public" && (t = t.slice(1));
|
|
2462
2462
|
let s = e;
|
|
2463
2463
|
for (const r of t) {
|
|
2464
2464
|
let a;
|
|
2465
|
-
const
|
|
2466
|
-
if (s.has(
|
|
2467
|
-
if (a = (i = s.get(
|
|
2465
|
+
const u = je(r);
|
|
2466
|
+
if (s.has(u)) {
|
|
2467
|
+
if (a = (i = s.get(u)) == null ? void 0 : i.symbolTable, !a)
|
|
2468
2468
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2469
2469
|
} else {
|
|
2470
2470
|
a = new we();
|
|
2471
2471
|
const p = n.create(_t, { symbolTable: a });
|
|
2472
|
-
s.set(
|
|
2472
|
+
s.set(u, p);
|
|
2473
2473
|
}
|
|
2474
2474
|
s = a;
|
|
2475
2475
|
}
|
|
2476
2476
|
return s;
|
|
2477
2477
|
}
|
|
2478
|
-
function
|
|
2478
|
+
function kt(t) {
|
|
2479
2479
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2480
2480
|
}
|
|
2481
|
-
function
|
|
2481
|
+
function Pn(t) {
|
|
2482
2482
|
var n;
|
|
2483
|
-
if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !==
|
|
2483
|
+
if (!(t instanceof U) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== l.COLOR_LITERAL)
|
|
2484
2484
|
return !1;
|
|
2485
2485
|
const e = t.expression.literal.value;
|
|
2486
2486
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2487
2487
|
return !1;
|
|
2488
2488
|
for (let s = 1; s < e.length; s += 1)
|
|
2489
|
-
if (!
|
|
2489
|
+
if (!Zt(e[s]))
|
|
2490
2490
|
return !1;
|
|
2491
2491
|
return !0;
|
|
2492
2492
|
}
|
|
2493
2493
|
function le(t) {
|
|
2494
2494
|
return t === void 0;
|
|
2495
2495
|
}
|
|
2496
|
-
function
|
|
2496
|
+
function Un(t) {
|
|
2497
2497
|
var e;
|
|
2498
|
-
return !!(
|
|
2498
|
+
return !!(j(t) || he(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) && he(t.expression) || t instanceof te);
|
|
2499
2499
|
}
|
|
2500
2500
|
function he(t) {
|
|
2501
2501
|
var e;
|
|
2502
|
-
return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) ===
|
|
2502
|
+
return t instanceof U && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === l.NUMERIC_LITERAL;
|
|
2503
2503
|
}
|
|
2504
|
-
function
|
|
2504
|
+
function Mn(t) {
|
|
2505
2505
|
var n;
|
|
2506
|
-
if (!(t instanceof Q) || !
|
|
2506
|
+
if (!(t instanceof Q) || !kt((n = t.op) == null ? void 0 : n.value))
|
|
2507
2507
|
return !1;
|
|
2508
2508
|
const e = C(t.expression).unwrap_or(void 0);
|
|
2509
2509
|
return e !== void 0 && e.length > 0;
|
|
2510
2510
|
}
|
|
2511
|
-
function
|
|
2511
|
+
function xt(t) {
|
|
2512
2512
|
return t instanceof J && t.elementList.every(M);
|
|
2513
2513
|
}
|
|
2514
|
-
function
|
|
2514
|
+
function W(t) {
|
|
2515
2515
|
var s;
|
|
2516
2516
|
const e = {}, n = [];
|
|
2517
2517
|
if (!t)
|
|
@@ -2520,7 +2520,7 @@ function j(t) {
|
|
|
2520
2520
|
if (!i.name)
|
|
2521
2521
|
continue;
|
|
2522
2522
|
if (i.name instanceof U) {
|
|
2523
|
-
n.push(new
|
|
2523
|
+
n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2524
2524
|
continue;
|
|
2525
2525
|
}
|
|
2526
2526
|
const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
@@ -2547,7 +2547,7 @@ class ft {
|
|
|
2547
2547
|
e.push(...r.validate());
|
|
2548
2548
|
});
|
|
2549
2549
|
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
|
|
2550
|
+
return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
|
|
2551
2551
|
}
|
|
2552
2552
|
}
|
|
2553
2553
|
class ae {
|
|
@@ -2579,7 +2579,7 @@ class ae {
|
|
|
2579
2579
|
if (s instanceof A) {
|
|
2580
2580
|
if (!s.type)
|
|
2581
2581
|
continue;
|
|
2582
|
-
const i =
|
|
2582
|
+
const i = St(s);
|
|
2583
2583
|
new i(s, this.errors).bind();
|
|
2584
2584
|
} else
|
|
2585
2585
|
this.bindSubfield(s);
|
|
@@ -2602,7 +2602,7 @@ class ae {
|
|
|
2602
2602
|
return;
|
|
2603
2603
|
this.bindFragments([e], n);
|
|
2604
2604
|
} else
|
|
2605
|
-
e instanceof q ? Je(e) ? this.bindFragments(fe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof
|
|
2605
|
+
e instanceof q ? Je(e) ? this.bindFragments(fe(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 J && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2606
2606
|
}
|
|
2607
2607
|
// Bind the fragments of a member access expression
|
|
2608
2608
|
// which can be a simple expression like v1.User,
|
|
@@ -2610,76 +2610,76 @@ class ae {
|
|
|
2610
2610
|
bindFragments(e, n) {
|
|
2611
2611
|
if (e.length === 0)
|
|
2612
2612
|
return;
|
|
2613
|
-
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((
|
|
2613
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), u = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
|
|
2614
2614
|
0,
|
|
2615
2615
|
r === -1 ? void 0 : r
|
|
2616
2616
|
);
|
|
2617
|
-
if (
|
|
2617
|
+
if (f.length === 0)
|
|
2618
2618
|
return;
|
|
2619
|
-
const
|
|
2620
|
-
for (; s.length &&
|
|
2621
|
-
const
|
|
2622
|
-
|
|
2623
|
-
index: Ve(g,
|
|
2624
|
-
referrer:
|
|
2619
|
+
const E = [];
|
|
2620
|
+
for (; s.length && f.length; ) {
|
|
2621
|
+
const h = s.pop(), m = f.pop(), g = V(m).unwrap();
|
|
2622
|
+
E.unshift({
|
|
2623
|
+
index: Ve(g, h),
|
|
2624
|
+
referrer: m
|
|
2625
2625
|
});
|
|
2626
2626
|
}
|
|
2627
|
-
for (;
|
|
2628
|
-
const
|
|
2629
|
-
|
|
2630
|
-
index: Ve(
|
|
2631
|
-
referrer:
|
|
2627
|
+
for (; f.length; ) {
|
|
2628
|
+
const h = f.pop(), m = V(h).unwrap();
|
|
2629
|
+
E.unshift({
|
|
2630
|
+
index: Ve(m, i),
|
|
2631
|
+
referrer: h
|
|
2632
2632
|
});
|
|
2633
2633
|
}
|
|
2634
|
-
return
|
|
2635
|
-
(
|
|
2634
|
+
return u ? u.elementList.forEach(
|
|
2635
|
+
(h) => this.resolveIndexStack(
|
|
2636
2636
|
[
|
|
2637
|
-
...
|
|
2637
|
+
...E,
|
|
2638
2638
|
{
|
|
2639
2639
|
index: Ve(
|
|
2640
|
-
V(
|
|
2640
|
+
V(h).unwrap(),
|
|
2641
2641
|
p
|
|
2642
2642
|
),
|
|
2643
|
-
referrer:
|
|
2643
|
+
referrer: h
|
|
2644
2644
|
}
|
|
2645
2645
|
],
|
|
2646
2646
|
n.ignoreNameNotFound
|
|
2647
2647
|
)
|
|
2648
|
-
) : this.resolveIndexStack(
|
|
2648
|
+
) : this.resolveIndexStack(E, n.ignoreNameNotFound);
|
|
2649
2649
|
}
|
|
2650
2650
|
// Looking up the indexes in the subname stack from the current declaration node
|
|
2651
2651
|
// Each time the index resolves to a symbol, the referrer's symbol is bound to it
|
|
2652
2652
|
resolveIndexStack(e, n) {
|
|
2653
2653
|
if (e.length === 0)
|
|
2654
2654
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
2655
|
-
const [s, ...i] = e, r =
|
|
2655
|
+
const [s, ...i] = e, r = Ln(s.index, this.declarationNode);
|
|
2656
2656
|
if (r === void 0) {
|
|
2657
|
-
const { kind:
|
|
2658
|
-
this.logError(s.referrer, `Can not find ${
|
|
2657
|
+
const { kind: f, name: E } = ie(s.index).unwrap();
|
|
2658
|
+
this.logError(s.referrer, `Can not find ${f} '${E}'`, n);
|
|
2659
2659
|
return;
|
|
2660
2660
|
}
|
|
2661
2661
|
r.references.push(s.referrer), s.referrer.referee = r;
|
|
2662
|
-
let a = r.symbolTable, { kind:
|
|
2663
|
-
for (const
|
|
2664
|
-
const { kind:
|
|
2665
|
-
if (!
|
|
2662
|
+
let a = r.symbolTable, { kind: u, name: p } = ie(s.index).unwrap();
|
|
2663
|
+
for (const f of i) {
|
|
2664
|
+
const { kind: E, name: h } = ie(f.index).unwrap(), m = a.get(f.index);
|
|
2665
|
+
if (!m) {
|
|
2666
2666
|
this.logError(
|
|
2667
|
-
|
|
2668
|
-
`${
|
|
2667
|
+
f.referrer,
|
|
2668
|
+
`${u} '${p}' does not have ${E} '${h}'`,
|
|
2669
2669
|
n
|
|
2670
2670
|
);
|
|
2671
2671
|
return;
|
|
2672
2672
|
}
|
|
2673
|
-
if (
|
|
2673
|
+
if (u = E, p = h, f.referrer.referee = m, m.references.push(f.referrer), !m.symbolTable)
|
|
2674
2674
|
break;
|
|
2675
|
-
a =
|
|
2675
|
+
a = m.symbolTable;
|
|
2676
2676
|
}
|
|
2677
2677
|
}
|
|
2678
2678
|
logError(e, n, s) {
|
|
2679
|
-
s || this.errors.push(new
|
|
2679
|
+
s || this.errors.push(new c(o.BINDING_ERROR, n, e));
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
class
|
|
2682
|
+
class Fn extends ae {
|
|
2683
2683
|
constructor() {
|
|
2684
2684
|
super(...arguments), this.subfield = {
|
|
2685
2685
|
arg: {
|
|
@@ -2689,7 +2689,7 @@ class Un extends ae {
|
|
|
2689
2689
|
}, this.settingList = {};
|
|
2690
2690
|
}
|
|
2691
2691
|
}
|
|
2692
|
-
class
|
|
2692
|
+
class Bn extends ae {
|
|
2693
2693
|
constructor() {
|
|
2694
2694
|
super(...arguments), this.subfield = {
|
|
2695
2695
|
arg: {
|
|
@@ -2699,33 +2699,33 @@ class Mn extends ae {
|
|
|
2699
2699
|
}, this.settingList = {};
|
|
2700
2700
|
}
|
|
2701
2701
|
}
|
|
2702
|
-
class
|
|
2702
|
+
class Vn extends ae {
|
|
2703
2703
|
constructor() {
|
|
2704
2704
|
super(...arguments), this.subfield = {
|
|
2705
2705
|
arg: {
|
|
2706
2706
|
argBinderRules: [
|
|
2707
2707
|
{
|
|
2708
2708
|
shouldBind: !0,
|
|
2709
|
-
topSubnamesSymbolKind: [
|
|
2710
|
-
remainingSubnamesSymbolKind:
|
|
2709
|
+
topSubnamesSymbolKind: [T.Table, T.Column],
|
|
2710
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2711
2711
|
ignoreNameNotFound: !1
|
|
2712
2712
|
},
|
|
2713
2713
|
{
|
|
2714
2714
|
shouldBind: !0,
|
|
2715
|
-
topSubnamesSymbolKind: [
|
|
2716
|
-
remainingSubnamesSymbolKind:
|
|
2715
|
+
topSubnamesSymbolKind: [T.Table, T.Column],
|
|
2716
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2717
2717
|
ignoreNameNotFound: !1
|
|
2718
2718
|
},
|
|
2719
2719
|
{
|
|
2720
2720
|
shouldBind: !0,
|
|
2721
|
-
topSubnamesSymbolKind: [
|
|
2722
|
-
remainingSubnamesSymbolKind:
|
|
2721
|
+
topSubnamesSymbolKind: [T.Table, T.Column],
|
|
2722
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2723
2723
|
ignoreNameNotFound: !1
|
|
2724
2724
|
},
|
|
2725
2725
|
{
|
|
2726
2726
|
shouldBind: !0,
|
|
2727
|
-
topSubnamesSymbolKind: [
|
|
2728
|
-
remainingSubnamesSymbolKind:
|
|
2727
|
+
topSubnamesSymbolKind: [T.Table, T.Column],
|
|
2728
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2729
2729
|
ignoreNameNotFound: !1
|
|
2730
2730
|
}
|
|
2731
2731
|
]
|
|
@@ -2734,7 +2734,7 @@ class Fn extends ae {
|
|
|
2734
2734
|
}, this.settingList = {};
|
|
2735
2735
|
}
|
|
2736
2736
|
}
|
|
2737
|
-
class
|
|
2737
|
+
class Gn extends ae {
|
|
2738
2738
|
constructor() {
|
|
2739
2739
|
super(...arguments), this.subfield = {
|
|
2740
2740
|
arg: {
|
|
@@ -2744,7 +2744,7 @@ class Bn extends ae {
|
|
|
2744
2744
|
}, this.settingList = {};
|
|
2745
2745
|
}
|
|
2746
2746
|
}
|
|
2747
|
-
class
|
|
2747
|
+
class Cn extends ae {
|
|
2748
2748
|
constructor() {
|
|
2749
2749
|
super(...arguments), this.subfield = {
|
|
2750
2750
|
arg: {
|
|
@@ -2754,15 +2754,15 @@ class Vn extends ae {
|
|
|
2754
2754
|
}, this.settingList = {};
|
|
2755
2755
|
}
|
|
2756
2756
|
}
|
|
2757
|
-
class
|
|
2757
|
+
class Xn extends ae {
|
|
2758
2758
|
constructor() {
|
|
2759
2759
|
super(...arguments), this.subfield = {
|
|
2760
2760
|
arg: {
|
|
2761
2761
|
argBinderRules: [
|
|
2762
2762
|
{
|
|
2763
2763
|
shouldBind: !0,
|
|
2764
|
-
topSubnamesSymbolKind: [
|
|
2765
|
-
remainingSubnamesSymbolKind:
|
|
2764
|
+
topSubnamesSymbolKind: [T.Table, T.Column],
|
|
2765
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2766
2766
|
ignoreNameNotFound: !1
|
|
2767
2767
|
}
|
|
2768
2768
|
]
|
|
@@ -2771,7 +2771,7 @@ class Gn extends ae {
|
|
|
2771
2771
|
}, this.settingList = {};
|
|
2772
2772
|
}
|
|
2773
2773
|
}
|
|
2774
|
-
class
|
|
2774
|
+
class $n extends ae {
|
|
2775
2775
|
constructor() {
|
|
2776
2776
|
super(...arguments), this.subfield = {
|
|
2777
2777
|
arg: {
|
|
@@ -2779,8 +2779,8 @@ class Cn extends ae {
|
|
|
2779
2779
|
{ shouldBind: !1 },
|
|
2780
2780
|
{
|
|
2781
2781
|
shouldBind: !0,
|
|
2782
|
-
topSubnamesSymbolKind: [
|
|
2783
|
-
remainingSubnamesSymbolKind:
|
|
2782
|
+
topSubnamesSymbolKind: [T.Enum],
|
|
2783
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2784
2784
|
ignoreNameNotFound: !0
|
|
2785
2785
|
}
|
|
2786
2786
|
]
|
|
@@ -2788,8 +2788,8 @@ class Cn extends ae {
|
|
|
2788
2788
|
settingList: {
|
|
2789
2789
|
ref: {
|
|
2790
2790
|
shouldBind: !0,
|
|
2791
|
-
topSubnamesSymbolKind: [
|
|
2792
|
-
remainingSubnamesSymbolKind:
|
|
2791
|
+
topSubnamesSymbolKind: [T.Table, T.Column],
|
|
2792
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2793
2793
|
ignoreNameNotFound: !1
|
|
2794
2794
|
},
|
|
2795
2795
|
default: {
|
|
@@ -2799,15 +2799,15 @@ class Cn extends ae {
|
|
|
2799
2799
|
}, this.settingList = {};
|
|
2800
2800
|
}
|
|
2801
2801
|
}
|
|
2802
|
-
class
|
|
2802
|
+
class Wn extends ae {
|
|
2803
2803
|
constructor() {
|
|
2804
2804
|
super(...arguments), this.subfield = {
|
|
2805
2805
|
arg: {
|
|
2806
2806
|
argBinderRules: [
|
|
2807
2807
|
{
|
|
2808
2808
|
shouldBind: !0,
|
|
2809
|
-
topSubnamesSymbolKind: [
|
|
2810
|
-
remainingSubnamesSymbolKind:
|
|
2809
|
+
topSubnamesSymbolKind: [T.Table],
|
|
2810
|
+
remainingSubnamesSymbolKind: T.Schema,
|
|
2811
2811
|
ignoreNameNotFound: !1
|
|
2812
2812
|
}
|
|
2813
2813
|
]
|
|
@@ -2816,40 +2816,40 @@ class Xn extends ae {
|
|
|
2816
2816
|
}, this.settingList = {};
|
|
2817
2817
|
}
|
|
2818
2818
|
}
|
|
2819
|
-
function
|
|
2819
|
+
function St(t) {
|
|
2820
2820
|
switch (t.type.value.toLowerCase()) {
|
|
2821
2821
|
case b.Enum:
|
|
2822
|
-
return
|
|
2822
|
+
return Bn;
|
|
2823
2823
|
case b.Table:
|
|
2824
|
-
return
|
|
2824
|
+
return $n;
|
|
2825
2825
|
case b.TableGroup:
|
|
2826
|
-
return
|
|
2826
|
+
return Wn;
|
|
2827
2827
|
case b.Project:
|
|
2828
|
-
return
|
|
2828
|
+
return Cn;
|
|
2829
2829
|
case b.Ref:
|
|
2830
|
-
return
|
|
2830
|
+
return Xn;
|
|
2831
2831
|
case b.Note:
|
|
2832
|
-
return
|
|
2832
|
+
return Gn;
|
|
2833
2833
|
case b.Indexes:
|
|
2834
|
-
return
|
|
2834
|
+
return Vn;
|
|
2835
2835
|
default:
|
|
2836
|
-
return
|
|
2836
|
+
return Fn;
|
|
2837
2837
|
}
|
|
2838
2838
|
}
|
|
2839
|
-
class
|
|
2839
|
+
class jn {
|
|
2840
2840
|
constructor(e) {
|
|
2841
2841
|
this.ast = e, this.errors = [];
|
|
2842
2842
|
}
|
|
2843
2843
|
resolve() {
|
|
2844
2844
|
for (const e of this.ast.body)
|
|
2845
2845
|
if (e.type) {
|
|
2846
|
-
const n =
|
|
2846
|
+
const n = St(e);
|
|
2847
2847
|
new n(e, this.errors).bind();
|
|
2848
2848
|
}
|
|
2849
2849
|
return new B(this.ast, this.errors);
|
|
2850
2850
|
}
|
|
2851
2851
|
}
|
|
2852
|
-
class
|
|
2852
|
+
class Yn {
|
|
2853
2853
|
constructor(e) {
|
|
2854
2854
|
this.generator = e;
|
|
2855
2855
|
}
|
|
@@ -2857,13 +2857,13 @@ class jn {
|
|
|
2857
2857
|
return new e(n, this.generator.nextId());
|
|
2858
2858
|
}
|
|
2859
2859
|
}
|
|
2860
|
-
class
|
|
2860
|
+
class zn {
|
|
2861
2861
|
constructor(e, n) {
|
|
2862
|
-
this.ast = e, this.symbolFactory = new
|
|
2862
|
+
this.ast = e, this.symbolFactory = new Yn(n);
|
|
2863
2863
|
}
|
|
2864
2864
|
// Analyzing: Invoking both the validator and binder
|
|
2865
2865
|
analyze() {
|
|
2866
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2866
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new jn(n).resolve());
|
|
2867
2867
|
}
|
|
2868
2868
|
// For invoking the validator only
|
|
2869
2869
|
validate() {
|
|
@@ -2890,7 +2890,7 @@ function pt(t, e) {
|
|
|
2890
2890
|
schemaName: n.pop() || null
|
|
2891
2891
|
};
|
|
2892
2892
|
}
|
|
2893
|
-
function
|
|
2893
|
+
function Ot(t) {
|
|
2894
2894
|
switch (t) {
|
|
2895
2895
|
case "<":
|
|
2896
2896
|
return ["1", "*"];
|
|
@@ -2925,10 +2925,10 @@ function Ie(t) {
|
|
|
2925
2925
|
schemaName: e
|
|
2926
2926
|
};
|
|
2927
2927
|
}
|
|
2928
|
-
function
|
|
2928
|
+
function Rt(t) {
|
|
2929
2929
|
return t.expression.literal.value;
|
|
2930
2930
|
}
|
|
2931
|
-
function
|
|
2931
|
+
function Dt(t, e) {
|
|
2932
2932
|
if (Array.isArray(t)) {
|
|
2933
2933
|
const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
|
|
2934
2934
|
return i < r ? `${i}-${r}` : `${r}-${i}`;
|
|
@@ -2936,10 +2936,10 @@ function Rt(t, e) {
|
|
|
2936
2936
|
const n = t.id.toString(), s = e.id.toString();
|
|
2937
2937
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
2938
2938
|
}
|
|
2939
|
-
function
|
|
2939
|
+
function Pt(t, e) {
|
|
2940
2940
|
if (Array.isArray(t)) {
|
|
2941
2941
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2942
|
-
return I.zip(i, r).every(([a,
|
|
2942
|
+
return I.zip(i, r).every(([a, u]) => a === u);
|
|
2943
2943
|
}
|
|
2944
2944
|
const n = t.id, s = e.id;
|
|
2945
2945
|
return n === s;
|
|
@@ -2950,7 +2950,7 @@ function Ne(t) {
|
|
|
2950
2950
|
return n.map((r) => r.slice(i)).join(`
|
|
2951
2951
|
`);
|
|
2952
2952
|
}
|
|
2953
|
-
class
|
|
2953
|
+
class Ut {
|
|
2954
2954
|
constructor(e, n) {
|
|
2955
2955
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2956
2956
|
}
|
|
@@ -2975,7 +2975,7 @@ class Pt {
|
|
|
2975
2975
|
}
|
|
2976
2976
|
interpretName(e) {
|
|
2977
2977
|
const { name: n, schemaName: s } = Ie(e);
|
|
2978
|
-
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new
|
|
2978
|
+
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
2979
2979
|
}
|
|
2980
2980
|
interpretAlias(e) {
|
|
2981
2981
|
if (!e)
|
|
@@ -2992,8 +2992,8 @@ class Pt {
|
|
|
2992
2992
|
}
|
|
2993
2993
|
interpretSettingList(e) {
|
|
2994
2994
|
var i, r, a;
|
|
2995
|
-
const n =
|
|
2996
|
-
this.table.headerColor = (i = n.headercolor) != null && i.length ?
|
|
2995
|
+
const n = W(e).getValue();
|
|
2996
|
+
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
2997
|
const [s] = n.note || [];
|
|
2998
2998
|
return this.table.note = s && {
|
|
2999
2999
|
value: z(s == null ? void 0 : s.value).map(Ne).unwrap(),
|
|
@@ -3023,15 +3023,15 @@ class Pt {
|
|
|
3023
3023
|
return e.flatMap((n) => this.interpretColumn(n));
|
|
3024
3024
|
}
|
|
3025
3025
|
interpretColumn(e) {
|
|
3026
|
-
var a,
|
|
3026
|
+
var a, u, p, f, E, h, m, g;
|
|
3027
3027
|
const n = [], s = {};
|
|
3028
3028
|
s.name = V(e.callee).unwrap();
|
|
3029
|
-
const i =
|
|
3029
|
+
const i = Qn(e.args[0]);
|
|
3030
3030
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = v(e), s.inline_refs = [];
|
|
3031
3031
|
const r = e.args.slice(1);
|
|
3032
3032
|
if (I.last(r) instanceof D) {
|
|
3033
|
-
const _ =
|
|
3034
|
-
s.pk = !!((a = _.pk) != null && a.length) || !!((
|
|
3033
|
+
const _ = W(r.pop()).getValue();
|
|
3034
|
+
s.pk = !!((a = _.pk) != null && a.length) || !!((u = _["primary key"]) != null && u.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 = qn((m = (h = _.default) == null ? void 0 : h.at(0)) == null ? void 0 : m.value);
|
|
3035
3035
|
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3036
3036
|
s.note = K && {
|
|
3037
3037
|
value: z(K.value).map(Ne).unwrap(),
|
|
@@ -3039,10 +3039,10 @@ class Pt {
|
|
|
3039
3039
|
};
|
|
3040
3040
|
const oe = _.ref || [];
|
|
3041
3041
|
s.inline_refs = oe.flatMap((Y) => {
|
|
3042
|
-
const [
|
|
3043
|
-
if (
|
|
3044
|
-
return n.push(new
|
|
3045
|
-
const
|
|
3042
|
+
const [tt] = $e(Y.value.expression);
|
|
3043
|
+
if (Pt(tt, e.symbol))
|
|
3044
|
+
return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
|
|
3045
|
+
const ke = Y.value.op, ee = C(Y.value.expression).unwrap();
|
|
3046
3046
|
let pe;
|
|
3047
3047
|
if (ee.length === 1) {
|
|
3048
3048
|
const [ce] = ee;
|
|
@@ -3050,7 +3050,7 @@ class Pt {
|
|
|
3050
3050
|
schemaName: this.table.schemaName,
|
|
3051
3051
|
tableName: this.table.name,
|
|
3052
3052
|
fieldNames: [ce],
|
|
3053
|
-
relation:
|
|
3053
|
+
relation: ke.value,
|
|
3054
3054
|
token: v(Y)
|
|
3055
3055
|
};
|
|
3056
3056
|
} else if (ee.length === 2) {
|
|
@@ -3059,49 +3059,49 @@ class Pt {
|
|
|
3059
3059
|
schemaName: null,
|
|
3060
3060
|
tableName: ce,
|
|
3061
3061
|
fieldNames: [Le],
|
|
3062
|
-
relation:
|
|
3062
|
+
relation: ke.value,
|
|
3063
3063
|
token: v(Y)
|
|
3064
3064
|
};
|
|
3065
3065
|
} else if (ee.length === 3) {
|
|
3066
|
-
const [ce, Le,
|
|
3066
|
+
const [ce, Le, st] = ee;
|
|
3067
3067
|
pe = {
|
|
3068
3068
|
schemaName: ce,
|
|
3069
3069
|
tableName: Le,
|
|
3070
|
-
fieldNames: [
|
|
3071
|
-
relation:
|
|
3070
|
+
fieldNames: [st],
|
|
3071
|
+
relation: ke.value,
|
|
3072
3072
|
token: v(Y)
|
|
3073
3073
|
};
|
|
3074
3074
|
} else {
|
|
3075
|
-
n.push(new
|
|
3075
|
+
n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", Y));
|
|
3076
3076
|
const ce = ee.pop(), Le = ee.pop();
|
|
3077
3077
|
pe = {
|
|
3078
3078
|
schemaName: ee.join("."),
|
|
3079
3079
|
tableName: Le,
|
|
3080
3080
|
fieldNames: [ce],
|
|
3081
|
-
relation:
|
|
3081
|
+
relation: ke.value,
|
|
3082
3082
|
token: v(Y)
|
|
3083
3083
|
};
|
|
3084
3084
|
}
|
|
3085
|
-
const
|
|
3086
|
-
return n.push(...
|
|
3085
|
+
const nt = this.registerInlineRefToEnv(e, tt, pe, Y);
|
|
3086
|
+
return n.push(...nt), nt.length === 0 ? pe : [];
|
|
3087
3087
|
});
|
|
3088
3088
|
}
|
|
3089
3089
|
return s.pk || (s.pk = r.some((_) => X(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => X(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3090
3090
|
}
|
|
3091
3091
|
interpretIndexes(e) {
|
|
3092
3092
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3093
|
-
var a,
|
|
3093
|
+
var a, u, p, f, E, h, m;
|
|
3094
3094
|
const s = { columns: [] }, i = n;
|
|
3095
3095
|
s.token = v(e);
|
|
3096
3096
|
const r = [i.callee, ...i.args];
|
|
3097
3097
|
if (I.last(r) instanceof D) {
|
|
3098
|
-
const g =
|
|
3099
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((
|
|
3100
|
-
const _ = (
|
|
3098
|
+
const g = W(r.pop()).getValue();
|
|
3099
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((u = g.unique) != null && u.length), s.name = z((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
|
|
3100
|
+
const _ = (E = g.note) == null ? void 0 : E.at(0);
|
|
3101
3101
|
s.note = _ && {
|
|
3102
3102
|
value: z(_.value).unwrap(),
|
|
3103
3103
|
token: v(_)
|
|
3104
|
-
}, s.type = X((
|
|
3104
|
+
}, s.type = X((m = (h = g.type) == null ? void 0 : h.at(0)) == null ? void 0 : m.value).unwrap_or(void 0);
|
|
3105
3105
|
}
|
|
3106
3106
|
return r.flatMap((g) => {
|
|
3107
3107
|
if (!(g instanceof H))
|
|
@@ -3128,13 +3128,13 @@ class Pt {
|
|
|
3128
3128
|
})), [];
|
|
3129
3129
|
}
|
|
3130
3130
|
registerInlineRefToEnv(e, n, s, i) {
|
|
3131
|
-
const r =
|
|
3131
|
+
const r = Dt(e.symbol, n);
|
|
3132
3132
|
if (this.env.refIds[r])
|
|
3133
3133
|
return [
|
|
3134
|
-
new
|
|
3135
|
-
new
|
|
3134
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3135
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3136
3136
|
];
|
|
3137
|
-
const a =
|
|
3137
|
+
const a = Ot(s.relation);
|
|
3138
3138
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
3139
3139
|
name: null,
|
|
3140
3140
|
schemaName: null,
|
|
@@ -3155,9 +3155,9 @@ class Pt {
|
|
|
3155
3155
|
}), [];
|
|
3156
3156
|
}
|
|
3157
3157
|
}
|
|
3158
|
-
function
|
|
3158
|
+
function Qn(t) {
|
|
3159
3159
|
let e = null;
|
|
3160
|
-
t instanceof H && (e = t.argumentList.elementList.map((r) => he(r) ? r.expression.literal.value :
|
|
3160
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => he(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3161
3161
|
let n = "";
|
|
3162
3162
|
for (; t instanceof ue; )
|
|
3163
3163
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
@@ -3168,17 +3168,17 @@ function Yn(t) {
|
|
|
3168
3168
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3169
3169
|
args: e
|
|
3170
3170
|
},
|
|
3171
|
-
[new
|
|
3171
|
+
[new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3172
3172
|
) : new B({
|
|
3173
3173
|
schemaName: i.length === 0 ? null : i[0],
|
|
3174
3174
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3175
3175
|
args: e
|
|
3176
3176
|
});
|
|
3177
3177
|
}
|
|
3178
|
-
function
|
|
3178
|
+
function qn(t) {
|
|
3179
3179
|
var e, n, s;
|
|
3180
3180
|
if (t) {
|
|
3181
|
-
if (
|
|
3181
|
+
if (j(t))
|
|
3182
3182
|
return {
|
|
3183
3183
|
value: z(t).unwrap(),
|
|
3184
3184
|
type: "string"
|
|
@@ -3208,7 +3208,7 @@ function zn(t) {
|
|
|
3208
3208
|
throw new Error("Unreachable");
|
|
3209
3209
|
}
|
|
3210
3210
|
}
|
|
3211
|
-
class
|
|
3211
|
+
class Hn {
|
|
3212
3212
|
constructor(e, n) {
|
|
3213
3213
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3214
3214
|
}
|
|
@@ -3225,13 +3225,13 @@ class Qn {
|
|
|
3225
3225
|
}
|
|
3226
3226
|
interpretSettingList(e) {
|
|
3227
3227
|
var s, i, r;
|
|
3228
|
-
const n =
|
|
3229
|
-
return this.note.headerColor = (s = n.headercolor) != null && s.length ?
|
|
3228
|
+
const n = W(e).getValue();
|
|
3229
|
+
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
3230
|
}
|
|
3231
3231
|
interpretBody(e) {
|
|
3232
3232
|
const [n, s] = I.partition(e.body, (i) => i instanceof y);
|
|
3233
3233
|
return n.length !== 1 || s.length > 0 ? [
|
|
3234
|
-
new
|
|
3234
|
+
new c(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3235
3235
|
] : [...this.interpretNote(n[0])];
|
|
3236
3236
|
}
|
|
3237
3237
|
interpretNote(e) {
|
|
@@ -3239,7 +3239,7 @@ class Qn {
|
|
|
3239
3239
|
return this.note.content = Ne(n), [];
|
|
3240
3240
|
}
|
|
3241
3241
|
}
|
|
3242
|
-
class
|
|
3242
|
+
class Mt {
|
|
3243
3243
|
constructor(e, n) {
|
|
3244
3244
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3245
3245
|
}
|
|
@@ -3248,29 +3248,29 @@ class Ut {
|
|
|
3248
3248
|
}
|
|
3249
3249
|
interpretName(e) {
|
|
3250
3250
|
const n = [], s = C(this.declarationNode.name).unwrap_or([]);
|
|
3251
|
-
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new
|
|
3251
|
+
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3252
3252
|
}
|
|
3253
3253
|
interpretBody(e) {
|
|
3254
3254
|
return e instanceof y ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3255
3255
|
}
|
|
3256
3256
|
interpretField(e) {
|
|
3257
|
-
var
|
|
3257
|
+
var f, E, h, m;
|
|
3258
3258
|
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
|
|
3259
|
-
if (
|
|
3260
|
-
return [new
|
|
3261
|
-
const
|
|
3262
|
-
if (this.env.refIds[
|
|
3259
|
+
if (Pt(r, a))
|
|
3260
|
+
return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3261
|
+
const u = Dt(r, a);
|
|
3262
|
+
if (this.env.refIds[u])
|
|
3263
3263
|
return [
|
|
3264
|
-
new
|
|
3265
|
-
new
|
|
3264
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3265
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[u])
|
|
3266
3266
|
];
|
|
3267
3267
|
if (e.args[0]) {
|
|
3268
|
-
const g =
|
|
3268
|
+
const g = W(e.args[0]).getValue(), _ = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
|
|
3269
3269
|
this.ref.onDelete = _ instanceof $ ? Te(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
|
|
3270
|
-
const K = (
|
|
3270
|
+
const K = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
|
|
3271
3271
|
this.ref.onUpdate = K instanceof $ ? Te(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
|
|
3272
3272
|
}
|
|
3273
|
-
const p =
|
|
3273
|
+
const p = Ot(n);
|
|
3274
3274
|
return this.ref.endpoints = [
|
|
3275
3275
|
{
|
|
3276
3276
|
...pt(s, this.container),
|
|
@@ -3282,10 +3282,10 @@ class Ut {
|
|
|
3282
3282
|
relation: p[1],
|
|
3283
3283
|
token: v(i)
|
|
3284
3284
|
}
|
|
3285
|
-
], this.env.refIds[
|
|
3285
|
+
], this.env.refIds[u] = this.declarationNode, [];
|
|
3286
3286
|
}
|
|
3287
3287
|
}
|
|
3288
|
-
class
|
|
3288
|
+
class Ft {
|
|
3289
3289
|
constructor(e, n) {
|
|
3290
3290
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3291
3291
|
}
|
|
@@ -3298,17 +3298,17 @@ class Mt {
|
|
|
3298
3298
|
}
|
|
3299
3299
|
interpretName(e) {
|
|
3300
3300
|
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
|
|
3301
|
+
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3302
3302
|
}
|
|
3303
3303
|
interpretBody(e) {
|
|
3304
3304
|
const n = [];
|
|
3305
3305
|
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3306
3306
|
const i = C(s.callee).unwrap();
|
|
3307
|
-
i.length > 2 && n.push(new
|
|
3307
|
+
i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3308
3308
|
const r = fe(s.callee).unwrap().pop().referee.id;
|
|
3309
3309
|
if (this.env.groupOfTable[r]) {
|
|
3310
|
-
const a = this.env.groupOfTable[r], { schemaName:
|
|
3311
|
-
n.push(new
|
|
3310
|
+
const a = this.env.groupOfTable[r], { schemaName: u, name: p } = this.env.tableGroups.get(a), f = u ? `${u}.${p}` : p;
|
|
3311
|
+
n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${f}"`, s));
|
|
3312
3312
|
} else
|
|
3313
3313
|
this.env.groupOfTable[r] = this.declarationNode;
|
|
3314
3314
|
return {
|
|
@@ -3318,7 +3318,7 @@ class Mt {
|
|
|
3318
3318
|
}), n;
|
|
3319
3319
|
}
|
|
3320
3320
|
}
|
|
3321
|
-
class
|
|
3321
|
+
class Bt {
|
|
3322
3322
|
constructor(e, n) {
|
|
3323
3323
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3324
3324
|
}
|
|
@@ -3327,14 +3327,14 @@ class Ft {
|
|
|
3327
3327
|
}
|
|
3328
3328
|
interpretName(e) {
|
|
3329
3329
|
const { name: n, schemaName: s } = Ie(e);
|
|
3330
|
-
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new
|
|
3330
|
+
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3331
3331
|
}
|
|
3332
3332
|
interpretBody(e) {
|
|
3333
3333
|
return e.body.flatMap((n) => {
|
|
3334
|
-
var
|
|
3334
|
+
var u;
|
|
3335
3335
|
const s = n, i = {};
|
|
3336
3336
|
i.token = v(s), i.name = X(s.callee).unwrap();
|
|
3337
|
-
const a = (
|
|
3337
|
+
const a = (u = W(s.args[0]).getValue().note) == null ? void 0 : u.at(0);
|
|
3338
3338
|
return i.note = a && {
|
|
3339
3339
|
value: z(a.value).map(Ne).unwrap(),
|
|
3340
3340
|
token: v(a)
|
|
@@ -3342,7 +3342,7 @@ class Ft {
|
|
|
3342
3342
|
});
|
|
3343
3343
|
}
|
|
3344
3344
|
}
|
|
3345
|
-
class
|
|
3345
|
+
class Jn {
|
|
3346
3346
|
constructor(e, n) {
|
|
3347
3347
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3348
3348
|
}
|
|
@@ -3361,19 +3361,19 @@ class qn {
|
|
|
3361
3361
|
const s = n;
|
|
3362
3362
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
3363
3363
|
case "table": {
|
|
3364
|
-
const r = new
|
|
3364
|
+
const r = new Ut(s, this.env).interpret();
|
|
3365
3365
|
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3366
3366
|
}
|
|
3367
3367
|
case "ref": {
|
|
3368
|
-
const r = new
|
|
3368
|
+
const r = new Mt(s, this.env).interpret();
|
|
3369
3369
|
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3370
3370
|
}
|
|
3371
3371
|
case "tablegroup": {
|
|
3372
|
-
const r = new
|
|
3372
|
+
const r = new Ft(s, this.env).interpret();
|
|
3373
3373
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
|
|
3374
3374
|
}
|
|
3375
3375
|
case "enum": {
|
|
3376
|
-
const r = new
|
|
3376
|
+
const r = new Bt(s, this.env).interpret();
|
|
3377
3377
|
return this.project.enums.push(this.env.enums.get(s)), r;
|
|
3378
3378
|
}
|
|
3379
3379
|
case "note":
|
|
@@ -3387,7 +3387,7 @@ class qn {
|
|
|
3387
3387
|
});
|
|
3388
3388
|
}
|
|
3389
3389
|
}
|
|
3390
|
-
class
|
|
3390
|
+
class Zn {
|
|
3391
3391
|
constructor(e) {
|
|
3392
3392
|
this.ast = e, this.env = {
|
|
3393
3393
|
schema: [],
|
|
@@ -3406,25 +3406,25 @@ class Hn {
|
|
|
3406
3406
|
const e = this.ast.body.flatMap((n) => {
|
|
3407
3407
|
switch (ve(n).unwrap_or(void 0)) {
|
|
3408
3408
|
case b.Table:
|
|
3409
|
-
return new
|
|
3409
|
+
return new Ut(n, this.env).interpret();
|
|
3410
3410
|
case b.Note:
|
|
3411
|
-
return new
|
|
3411
|
+
return new Hn(n, this.env).interpret();
|
|
3412
3412
|
case b.Ref:
|
|
3413
|
-
return new Ut(n, this.env).interpret();
|
|
3414
|
-
case b.TableGroup:
|
|
3415
3413
|
return new Mt(n, this.env).interpret();
|
|
3416
|
-
case b.
|
|
3414
|
+
case b.TableGroup:
|
|
3417
3415
|
return new Ft(n, this.env).interpret();
|
|
3416
|
+
case b.Enum:
|
|
3417
|
+
return new Bt(n, this.env).interpret();
|
|
3418
3418
|
case b.Project:
|
|
3419
|
-
return new
|
|
3419
|
+
return new Jn(n, this.env).interpret();
|
|
3420
3420
|
default:
|
|
3421
3421
|
return [];
|
|
3422
3422
|
}
|
|
3423
3423
|
});
|
|
3424
|
-
return new B(
|
|
3424
|
+
return new B(Kn(this.env), e);
|
|
3425
3425
|
}
|
|
3426
3426
|
}
|
|
3427
|
-
function
|
|
3427
|
+
function Kn(t) {
|
|
3428
3428
|
return {
|
|
3429
3429
|
schemas: [],
|
|
3430
3430
|
tables: Array.from(t.tables.values()),
|
|
@@ -3439,31 +3439,31 @@ function Jn(t) {
|
|
|
3439
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 || {}), k = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(k || {});
|
|
3440
3440
|
function Ae(t) {
|
|
3441
3441
|
switch (t) {
|
|
3442
|
-
case
|
|
3442
|
+
case T.Schema:
|
|
3443
3443
|
return L.Module;
|
|
3444
|
-
case
|
|
3444
|
+
case T.Table:
|
|
3445
3445
|
return L.Class;
|
|
3446
|
-
case
|
|
3446
|
+
case T.Column:
|
|
3447
3447
|
return L.Field;
|
|
3448
|
-
case
|
|
3448
|
+
case T.Enum:
|
|
3449
3449
|
return L.Enum;
|
|
3450
|
-
case
|
|
3450
|
+
case T.EnumField:
|
|
3451
3451
|
return L.EnumMember;
|
|
3452
|
-
case
|
|
3452
|
+
case T.TableGroup:
|
|
3453
3453
|
return L.Struct;
|
|
3454
|
-
case
|
|
3454
|
+
case T.TableGroupField:
|
|
3455
3455
|
return L.Field;
|
|
3456
3456
|
default:
|
|
3457
3457
|
return L.Text;
|
|
3458
3458
|
}
|
|
3459
3459
|
}
|
|
3460
|
-
function
|
|
3460
|
+
function De(t, e) {
|
|
3461
3461
|
if (!t || Ce(t))
|
|
3462
3462
|
return !1;
|
|
3463
3463
|
for (const n of t.trailingTrivia) {
|
|
3464
3464
|
if (n.start > e)
|
|
3465
3465
|
break;
|
|
3466
|
-
if (n.kind ===
|
|
3466
|
+
if (n.kind === l.NEWLINE && n.end <= e)
|
|
3467
3467
|
return !1;
|
|
3468
3468
|
}
|
|
3469
3469
|
return !0;
|
|
@@ -3473,7 +3473,7 @@ function O() {
|
|
|
3473
3473
|
suggestions: []
|
|
3474
3474
|
};
|
|
3475
3475
|
}
|
|
3476
|
-
function
|
|
3476
|
+
function Pe(t) {
|
|
3477
3477
|
return {
|
|
3478
3478
|
...t,
|
|
3479
3479
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3487,37 +3487,37 @@ function Fe(t) {
|
|
|
3487
3487
|
...t,
|
|
3488
3488
|
suggestions: t.suggestions.map((e) => ({
|
|
3489
3489
|
...e,
|
|
3490
|
-
insertText: e.insertText.split("").every(
|
|
3490
|
+
insertText: e.insertText.split("").every(Me) ? e.insertText : `"${e.insertText}"`
|
|
3491
3491
|
}))
|
|
3492
3492
|
};
|
|
3493
3493
|
}
|
|
3494
|
-
function
|
|
3494
|
+
function Ke(t, e) {
|
|
3495
3495
|
return t.getOffsetAt(e);
|
|
3496
3496
|
}
|
|
3497
|
-
class
|
|
3497
|
+
class Vt {
|
|
3498
3498
|
constructor(e, n = []) {
|
|
3499
3499
|
this.compiler = e, this.triggerCharacters = n;
|
|
3500
3500
|
}
|
|
3501
3501
|
provideCompletionItems(e, n) {
|
|
3502
|
-
var
|
|
3503
|
-
const s =
|
|
3502
|
+
var E, h;
|
|
3503
|
+
const s = Ke(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), u = a === void 0 ? i[0] : i[a + 1];
|
|
3504
3504
|
if ([
|
|
3505
3505
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3506
3506
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3507
|
-
...(
|
|
3508
|
-
].find((
|
|
3507
|
+
...(u == null ? void 0 : u.leadingTrivia) || []
|
|
3508
|
+
].find((m) => zt(m) && ge(s, m)))
|
|
3509
3509
|
return O();
|
|
3510
3510
|
if (a === void 0)
|
|
3511
3511
|
return Tt();
|
|
3512
|
-
if ([
|
|
3512
|
+
if ([l.STRING_LITERAL, l.QUOTED_STRING].includes(r.kind) && ge(s, r))
|
|
3513
3513
|
return O();
|
|
3514
3514
|
const p = this.compiler.container.element(s);
|
|
3515
3515
|
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
|
|
3516
3516
|
return Tt();
|
|
3517
|
-
const
|
|
3518
|
-
for (const
|
|
3519
|
-
if (
|
|
3520
|
-
switch ((
|
|
3517
|
+
const f = [...this.compiler.container.stack(s)].reverse();
|
|
3518
|
+
for (const m of f)
|
|
3519
|
+
if (m instanceof Q)
|
|
3520
|
+
switch ((E = m.op) == null ? void 0 : E.value) {
|
|
3521
3521
|
case ">":
|
|
3522
3522
|
case "<":
|
|
3523
3523
|
case "<>":
|
|
@@ -3525,11 +3525,11 @@ class Bt {
|
|
|
3525
3525
|
return dt(
|
|
3526
3526
|
this.compiler,
|
|
3527
3527
|
s,
|
|
3528
|
-
|
|
3528
|
+
m
|
|
3529
3529
|
);
|
|
3530
3530
|
}
|
|
3531
|
-
else if (
|
|
3532
|
-
switch ((
|
|
3531
|
+
else if (m instanceof q)
|
|
3532
|
+
switch ((h = m.op) == null ? void 0 : h.value) {
|
|
3533
3533
|
case ">":
|
|
3534
3534
|
case "<":
|
|
3535
3535
|
case "<>":
|
|
@@ -3537,25 +3537,25 @@ class Bt {
|
|
|
3537
3537
|
return dt(
|
|
3538
3538
|
this.compiler,
|
|
3539
3539
|
s,
|
|
3540
|
-
|
|
3540
|
+
m
|
|
3541
3541
|
);
|
|
3542
3542
|
case ".":
|
|
3543
|
-
return
|
|
3543
|
+
return Gt(
|
|
3544
3544
|
this.compiler,
|
|
3545
3545
|
s,
|
|
3546
|
-
|
|
3546
|
+
m
|
|
3547
3547
|
);
|
|
3548
3548
|
}
|
|
3549
3549
|
else {
|
|
3550
|
-
if (
|
|
3551
|
-
return Et(this.compiler, s,
|
|
3552
|
-
if (
|
|
3553
|
-
return Et(this.compiler, s,
|
|
3554
|
-
if (
|
|
3555
|
-
return
|
|
3556
|
-
if (
|
|
3557
|
-
return mt(this.compiler, s,
|
|
3558
|
-
if (
|
|
3550
|
+
if (m instanceof se)
|
|
3551
|
+
return Et(this.compiler, s, m);
|
|
3552
|
+
if (m instanceof D)
|
|
3553
|
+
return Et(this.compiler, s, m);
|
|
3554
|
+
if (m instanceof J)
|
|
3555
|
+
return es(this.compiler, s);
|
|
3556
|
+
if (m instanceof y)
|
|
3557
|
+
return mt(this.compiler, s, m);
|
|
3558
|
+
if (m instanceof A && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
|
|
3559
3559
|
return mt(this.compiler, s, void 0);
|
|
3560
3560
|
}
|
|
3561
3561
|
return O();
|
|
@@ -3565,11 +3565,11 @@ function dt(t, e, n) {
|
|
|
3565
3565
|
const s = t.container.scopeKind(e);
|
|
3566
3566
|
if ([R.REF, R.TABLE].includes(s)) {
|
|
3567
3567
|
const i = Be(t, e, t.container.element(e), [
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3568
|
+
T.Table,
|
|
3569
|
+
T.Schema,
|
|
3570
|
+
T.Column
|
|
3571
3571
|
]);
|
|
3572
|
-
return
|
|
3572
|
+
return De(n.op, e) ? Pe(i) : i;
|
|
3573
3573
|
}
|
|
3574
3574
|
return O();
|
|
3575
3575
|
}
|
|
@@ -3581,14 +3581,14 @@ function Be(t, e, n, s) {
|
|
|
3581
3581
|
const r = { suggestions: [] };
|
|
3582
3582
|
for (; i; ) {
|
|
3583
3583
|
if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
|
|
3584
|
-
const { symbol:
|
|
3584
|
+
const { symbol: u } = i;
|
|
3585
3585
|
r.suggestions.push(
|
|
3586
|
-
...t.symbol.members(
|
|
3586
|
+
...t.symbol.members(u).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
|
|
3587
3587
|
label: p,
|
|
3588
3588
|
insertText: p,
|
|
3589
3589
|
insertTextRules: k.KeepWhitespace,
|
|
3590
|
-
kind: Ae(
|
|
3591
|
-
sortText: Ae(
|
|
3590
|
+
kind: Ae(f),
|
|
3591
|
+
sortText: Ae(f).toString().padStart(2, "0"),
|
|
3592
3592
|
range: void 0
|
|
3593
3593
|
}))
|
|
3594
3594
|
);
|
|
@@ -3597,43 +3597,43 @@ function Be(t, e, n, s) {
|
|
|
3597
3597
|
}
|
|
3598
3598
|
return Fe(r);
|
|
3599
3599
|
}
|
|
3600
|
-
function
|
|
3600
|
+
function es(t, e) {
|
|
3601
3601
|
var s;
|
|
3602
3602
|
switch (t.container.scopeKind(e)) {
|
|
3603
3603
|
case R.INDEXES:
|
|
3604
|
-
return
|
|
3604
|
+
return Xt(t, e);
|
|
3605
3605
|
case R.REF:
|
|
3606
3606
|
{
|
|
3607
3607
|
const i = [...t.container.stack(e)];
|
|
3608
3608
|
for (; i.length > 0; ) {
|
|
3609
3609
|
const r = i.pop();
|
|
3610
3610
|
if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3611
|
-
return
|
|
3611
|
+
return Gt(
|
|
3612
3612
|
t,
|
|
3613
3613
|
e,
|
|
3614
3614
|
r
|
|
3615
3615
|
);
|
|
3616
3616
|
}
|
|
3617
3617
|
}
|
|
3618
|
-
return
|
|
3618
|
+
return Ct(t, e);
|
|
3619
3619
|
}
|
|
3620
3620
|
return O();
|
|
3621
3621
|
}
|
|
3622
3622
|
function Et(t, e, n) {
|
|
3623
3623
|
const { token: s } = t.container.token(e);
|
|
3624
|
-
if ([
|
|
3624
|
+
if ([l.COMMA, l.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3625
3625
|
const i = Nt(t, e);
|
|
3626
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3626
|
+
return (s == null ? void 0 : s.kind) === l.COMMA && De(s, e) ? Pe(i) : i;
|
|
3627
3627
|
}
|
|
3628
3628
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3629
3629
|
return Nt(t, e);
|
|
3630
3630
|
if (n.name instanceof $) {
|
|
3631
|
-
const i =
|
|
3631
|
+
const i = ts(
|
|
3632
3632
|
t,
|
|
3633
3633
|
e,
|
|
3634
3634
|
Te(n.name).unwrap()
|
|
3635
3635
|
);
|
|
3636
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3636
|
+
return (s == null ? void 0 : s.kind) === l.COLON && De(s, e) ? Pe(i) : i;
|
|
3637
3637
|
}
|
|
3638
3638
|
return O();
|
|
3639
3639
|
}
|
|
@@ -3736,7 +3736,7 @@ function Nt(t, e) {
|
|
|
3736
3736
|
}
|
|
3737
3737
|
return O();
|
|
3738
3738
|
}
|
|
3739
|
-
function
|
|
3739
|
+
function ts(t, e, n) {
|
|
3740
3740
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
3741
3741
|
case "update":
|
|
3742
3742
|
case "delete":
|
|
@@ -3762,7 +3762,7 @@ function Kn(t, e, n) {
|
|
|
3762
3762
|
}
|
|
3763
3763
|
return O();
|
|
3764
3764
|
}
|
|
3765
|
-
function
|
|
3765
|
+
function Gt(t, e, n) {
|
|
3766
3766
|
const s = fe(n).unwrap_or([]);
|
|
3767
3767
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3768
3768
|
return O();
|
|
@@ -3780,19 +3780,19 @@ function mt(t, e, n) {
|
|
|
3780
3780
|
var i;
|
|
3781
3781
|
switch (t.container.scopeKind(e)) {
|
|
3782
3782
|
case R.TABLE:
|
|
3783
|
-
return
|
|
3783
|
+
return ss(t, e, n);
|
|
3784
3784
|
case R.PROJECT:
|
|
3785
|
-
return
|
|
3785
|
+
return is(t, e, n);
|
|
3786
3786
|
case R.INDEXES:
|
|
3787
|
-
return
|
|
3787
|
+
return as(t, e);
|
|
3788
3788
|
case R.ENUM:
|
|
3789
|
-
return
|
|
3789
|
+
return ns(t, e, n);
|
|
3790
3790
|
case R.REF: {
|
|
3791
|
-
const r =
|
|
3792
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) ===
|
|
3791
|
+
const r = Ct(t, e);
|
|
3792
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === l.COLON && De(t.container.token(e).token, e) ? Pe(r) : r;
|
|
3793
3793
|
}
|
|
3794
3794
|
case R.TABLEGROUP:
|
|
3795
|
-
return
|
|
3795
|
+
return rs(t);
|
|
3796
3796
|
default:
|
|
3797
3797
|
return O();
|
|
3798
3798
|
}
|
|
@@ -3808,14 +3808,14 @@ function Tt() {
|
|
|
3808
3808
|
}))
|
|
3809
3809
|
};
|
|
3810
3810
|
}
|
|
3811
|
-
function
|
|
3812
|
-
return n != null && n.callee &&
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3811
|
+
function ns(t, e, n) {
|
|
3812
|
+
return n != null && n.callee && et(e, n) === 1 ? Be(t, e, t.container.element(e), [
|
|
3813
|
+
T.Schema,
|
|
3814
|
+
T.Table,
|
|
3815
|
+
T.Column
|
|
3816
3816
|
]) : O();
|
|
3817
3817
|
}
|
|
3818
|
-
function
|
|
3818
|
+
function ss(t, e, n) {
|
|
3819
3819
|
if (!(n != null && n.callee))
|
|
3820
3820
|
return {
|
|
3821
3821
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
@@ -3826,7 +3826,7 @@ function ts(t, e, n) {
|
|
|
3826
3826
|
range: void 0
|
|
3827
3827
|
}))
|
|
3828
3828
|
};
|
|
3829
|
-
const s =
|
|
3829
|
+
const s = et(e, n);
|
|
3830
3830
|
return s === 0 ? {
|
|
3831
3831
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3832
3832
|
label: i,
|
|
@@ -3835,10 +3835,10 @@ function ts(t, e, n) {
|
|
|
3835
3835
|
kind: L.Keyword,
|
|
3836
3836
|
range: void 0
|
|
3837
3837
|
}))
|
|
3838
|
-
} : s === 1 ?
|
|
3838
|
+
} : s === 1 ? os(t, e) : O();
|
|
3839
3839
|
}
|
|
3840
|
-
function
|
|
3841
|
-
return n != null && n.callee ?
|
|
3840
|
+
function is(t, e, n) {
|
|
3841
|
+
return n != null && n.callee ? et(e, n) === 0 ? {
|
|
3842
3842
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3843
3843
|
label: i,
|
|
3844
3844
|
insertText: i,
|
|
@@ -3856,21 +3856,21 @@ function ns(t, e, n) {
|
|
|
3856
3856
|
}))
|
|
3857
3857
|
};
|
|
3858
3858
|
}
|
|
3859
|
-
function
|
|
3859
|
+
function Ct(t, e) {
|
|
3860
3860
|
return Be(t, e, t.container.element(e), [
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3861
|
+
T.Schema,
|
|
3862
|
+
T.Table,
|
|
3863
|
+
T.Column
|
|
3864
3864
|
]);
|
|
3865
3865
|
}
|
|
3866
|
-
function
|
|
3866
|
+
function rs(t) {
|
|
3867
3867
|
return Fe({
|
|
3868
3868
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3869
3869
|
const n = ie(e).unwrap_or(void 0);
|
|
3870
3870
|
if (n === void 0)
|
|
3871
3871
|
return [];
|
|
3872
3872
|
const { kind: s, name: i } = n;
|
|
3873
|
-
return s !==
|
|
3873
|
+
return s !== T.Table && s !== T.Schema ? [] : {
|
|
3874
3874
|
label: i,
|
|
3875
3875
|
insertText: i,
|
|
3876
3876
|
insertTextRules: k.KeepWhitespace,
|
|
@@ -3880,10 +3880,10 @@ function ss(t) {
|
|
|
3880
3880
|
})
|
|
3881
3881
|
});
|
|
3882
3882
|
}
|
|
3883
|
-
function
|
|
3884
|
-
return
|
|
3883
|
+
function as(t, e) {
|
|
3884
|
+
return Xt(t, e);
|
|
3885
3885
|
}
|
|
3886
|
-
function
|
|
3886
|
+
function os(t, e) {
|
|
3887
3887
|
return {
|
|
3888
3888
|
suggestions: [
|
|
3889
3889
|
...[
|
|
@@ -3952,13 +3952,13 @@ function rs(t, e) {
|
|
|
3952
3952
|
range: void 0
|
|
3953
3953
|
})),
|
|
3954
3954
|
...Be(t, e, t.container.element(e), [
|
|
3955
|
-
|
|
3956
|
-
|
|
3955
|
+
T.Enum,
|
|
3956
|
+
T.Schema
|
|
3957
3957
|
]).suggestions
|
|
3958
3958
|
]
|
|
3959
3959
|
};
|
|
3960
3960
|
}
|
|
3961
|
-
function
|
|
3961
|
+
function Xt(t, e) {
|
|
3962
3962
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
3963
3963
|
if (!((s == null ? void 0 : s.symbol) instanceof At))
|
|
3964
3964
|
return O();
|
|
@@ -3968,41 +3968,41 @@ function Ct(t, e) {
|
|
|
3968
3968
|
const a = ie(r).unwrap_or(void 0);
|
|
3969
3969
|
if (a === void 0)
|
|
3970
3970
|
return [];
|
|
3971
|
-
const { name:
|
|
3971
|
+
const { name: u } = a;
|
|
3972
3972
|
return {
|
|
3973
|
-
label:
|
|
3974
|
-
insertText:
|
|
3973
|
+
label: u,
|
|
3974
|
+
insertText: u,
|
|
3975
3975
|
insertTextRules: k.KeepWhitespace,
|
|
3976
|
-
kind: Ae(
|
|
3976
|
+
kind: Ae(T.Column),
|
|
3977
3977
|
range: void 0
|
|
3978
3978
|
};
|
|
3979
3979
|
})
|
|
3980
3980
|
});
|
|
3981
3981
|
}
|
|
3982
|
-
function
|
|
3982
|
+
function et(t, e) {
|
|
3983
3983
|
if (!e.callee)
|
|
3984
3984
|
return -1;
|
|
3985
3985
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
3986
3986
|
return s === -1 ? n.length : s;
|
|
3987
3987
|
}
|
|
3988
|
-
class
|
|
3988
|
+
class $t {
|
|
3989
3989
|
constructor(e) {
|
|
3990
3990
|
this.compiler = e;
|
|
3991
3991
|
}
|
|
3992
3992
|
provideDefinition(e, n) {
|
|
3993
3993
|
var a;
|
|
3994
|
-
const { uri: s } = e, i =
|
|
3994
|
+
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
3995
3995
|
for (; r.length !== 0; ) {
|
|
3996
|
-
const
|
|
3997
|
-
if ((a =
|
|
3998
|
-
const { startPos: p, endPos:
|
|
3996
|
+
const u = r.pop();
|
|
3997
|
+
if ((a = u == null ? void 0 : u.referee) != null && a.declaration && [Ee.PRIMARY_EXPRESSION, Ee.VARIABLE].includes(u == null ? void 0 : u.kind)) {
|
|
3998
|
+
const { startPos: p, endPos: f } = u.referee.declaration;
|
|
3999
3999
|
return [
|
|
4000
4000
|
{
|
|
4001
4001
|
range: {
|
|
4002
4002
|
startColumn: p.column + 1,
|
|
4003
4003
|
startLineNumber: p.line + 1,
|
|
4004
|
-
endColumn:
|
|
4005
|
-
endLineNumber:
|
|
4004
|
+
endColumn: f.column + 1,
|
|
4005
|
+
endLineNumber: f.line + 1
|
|
4006
4006
|
},
|
|
4007
4007
|
uri: s
|
|
4008
4008
|
}
|
|
@@ -4012,12 +4012,12 @@ class Xt {
|
|
|
4012
4012
|
return [];
|
|
4013
4013
|
}
|
|
4014
4014
|
}
|
|
4015
|
-
class
|
|
4015
|
+
class Wt {
|
|
4016
4016
|
constructor(e) {
|
|
4017
4017
|
this.compiler = e;
|
|
4018
4018
|
}
|
|
4019
4019
|
provideReferences(e, n) {
|
|
4020
|
-
const { uri: s } = e, i =
|
|
4020
|
+
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
4021
4021
|
for (; r.length !== 0; ) {
|
|
4022
4022
|
const a = r.pop();
|
|
4023
4023
|
if (a && [
|
|
@@ -4025,14 +4025,14 @@ class $t {
|
|
|
4025
4025
|
Ee.FUNCTION_APPLICATION,
|
|
4026
4026
|
Ee.PRIMARY_EXPRESSION
|
|
4027
4027
|
].includes(a == null ? void 0 : a.kind)) {
|
|
4028
|
-
const { symbol:
|
|
4029
|
-
if (
|
|
4030
|
-
return
|
|
4028
|
+
const { symbol: u } = a;
|
|
4029
|
+
if (u != null && u.references.length)
|
|
4030
|
+
return u.references.map(({ startPos: p, endPos: f }) => ({
|
|
4031
4031
|
range: {
|
|
4032
4032
|
startColumn: p.column + 1,
|
|
4033
4033
|
startLineNumber: p.line + 1,
|
|
4034
|
-
endColumn:
|
|
4035
|
-
endLineNumber:
|
|
4034
|
+
endColumn: f.column + 1,
|
|
4035
|
+
endLineNumber: f.line + 1
|
|
4036
4036
|
},
|
|
4037
4037
|
uri: s
|
|
4038
4038
|
}));
|
|
@@ -4041,21 +4041,21 @@ class $t {
|
|
|
4041
4041
|
return [];
|
|
4042
4042
|
}
|
|
4043
4043
|
}
|
|
4044
|
-
const
|
|
4044
|
+
const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4045
4045
|
__proto__: null,
|
|
4046
4046
|
CompletionItemInsertTextRule: k,
|
|
4047
4047
|
CompletionItemKind: L,
|
|
4048
|
-
DBMLCompletionItemProvider:
|
|
4049
|
-
DBMLDefinitionProvider:
|
|
4050
|
-
DBMLReferencesProvider:
|
|
4048
|
+
DBMLCompletionItemProvider: Vt,
|
|
4049
|
+
DBMLDefinitionProvider: $t,
|
|
4050
|
+
DBMLReferencesProvider: Wt
|
|
4051
4051
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4052
4052
|
var R = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(R || {});
|
|
4053
|
-
class
|
|
4053
|
+
class hs {
|
|
4054
4054
|
constructor() {
|
|
4055
4055
|
this.source = "", this.cache = new Array(
|
|
4056
4056
|
16
|
|
4057
4057
|
/* TOTAL_QUERY_COUNT */
|
|
4058
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4058
|
+
).fill(null), this.nodeIdGenerator = new Qt(), this.symbolIdGenerator = new Kt(), this.token = {
|
|
4059
4059
|
invalidStream: this.createQuery(
|
|
4060
4060
|
6,
|
|
4061
4061
|
() => this.parse.tokens().filter(vt)
|
|
@@ -4070,8 +4070,8 @@ class ls {
|
|
|
4070
4070
|
_: this.createQuery(
|
|
4071
4071
|
0,
|
|
4072
4072
|
() => {
|
|
4073
|
-
const e = new
|
|
4074
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new
|
|
4073
|
+
const e = new un(this.source).lex().chain((n) => new pn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new zn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4074
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Zn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4075
4075
|
}
|
|
4076
4076
|
),
|
|
4077
4077
|
ast: this.createQuery(
|
|
@@ -4095,44 +4095,38 @@ class ls {
|
|
|
4095
4095
|
stack: this.createQuery(
|
|
4096
4096
|
10,
|
|
4097
4097
|
(e) => {
|
|
4098
|
-
const n = this.
|
|
4099
|
-
|
|
4100
|
-
const { token: i } = this.container.token(e);
|
|
4101
|
-
if (s === void 0)
|
|
4102
|
-
return [this.parse.ast()];
|
|
4103
|
-
for (; n[s].isInvalid && s >= 0; )
|
|
4104
|
-
s -= 1;
|
|
4105
|
-
if (s === -1)
|
|
4098
|
+
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), r = s === void 0 ? -1 : jt(n, (f) => !f.isInvalid, s);
|
|
4099
|
+
if (r === -1)
|
|
4106
4100
|
return [this.parse.ast()];
|
|
4107
|
-
const
|
|
4108
|
-
let
|
|
4109
|
-
const
|
|
4101
|
+
const a = n[r].start;
|
|
4102
|
+
let u = this.parse.ast();
|
|
4103
|
+
const p = [u];
|
|
4110
4104
|
for (; ; ) {
|
|
4111
|
-
const
|
|
4112
|
-
if (
|
|
4105
|
+
const E = ln(u).find((h) => ge(a, h));
|
|
4106
|
+
if (E === void 0 || E instanceof F)
|
|
4113
4107
|
break;
|
|
4114
|
-
|
|
4108
|
+
p.push(E), u = E;
|
|
4115
4109
|
}
|
|
4116
|
-
if ((i == null ? void 0 : i.kind) ===
|
|
4117
|
-
return
|
|
4118
|
-
for (;
|
|
4119
|
-
let
|
|
4120
|
-
const
|
|
4121
|
-
if (
|
|
4122
|
-
const
|
|
4123
|
-
for (let
|
|
4124
|
-
|
|
4125
|
-
` && (
|
|
4110
|
+
if ((i == null ? void 0 : i.kind) === l.COLON)
|
|
4111
|
+
return p;
|
|
4112
|
+
for (; p.length > 0; ) {
|
|
4113
|
+
let f = !1;
|
|
4114
|
+
const E = it(p);
|
|
4115
|
+
if (E instanceof y) {
|
|
4116
|
+
const h = this.parse.source();
|
|
4117
|
+
for (let m = E.end; m < e; m += 1)
|
|
4118
|
+
h[m] === `
|
|
4119
|
+
` && (p.pop(), f = !0);
|
|
4126
4120
|
} else
|
|
4127
|
-
|
|
4128
|
-
if (
|
|
4129
|
-
const
|
|
4130
|
-
|
|
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 J ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof ne ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof $ || E.end < e && (p.pop(), f = !0);
|
|
4122
|
+
if (f) {
|
|
4123
|
+
const h = it(p);
|
|
4124
|
+
h instanceof A && h.end <= e && p.pop();
|
|
4131
4125
|
}
|
|
4132
|
-
if (!
|
|
4126
|
+
if (!f)
|
|
4133
4127
|
break;
|
|
4134
4128
|
}
|
|
4135
|
-
return
|
|
4129
|
+
return p;
|
|
4136
4130
|
}
|
|
4137
4131
|
),
|
|
4138
4132
|
token: this.createQuery(
|
|
@@ -4204,15 +4198,15 @@ class ls {
|
|
|
4204
4198
|
if (!((i = r.symbol) != null && i.symbolTable))
|
|
4205
4199
|
continue;
|
|
4206
4200
|
const { symbolTable: a } = r.symbol;
|
|
4207
|
-
let
|
|
4208
|
-
for (const
|
|
4209
|
-
p =
|
|
4210
|
-
(
|
|
4211
|
-
const
|
|
4212
|
-
return !
|
|
4201
|
+
let u = [a], p = [];
|
|
4202
|
+
for (const f of e)
|
|
4203
|
+
p = u.flatMap(
|
|
4204
|
+
(E) => Jt(f).flatMap((h) => {
|
|
4205
|
+
const m = E.get(h), g = ie(h).unwrap_or(void 0);
|
|
4206
|
+
return !m || !g ? [] : { ...g, symbol: m };
|
|
4213
4207
|
})
|
|
4214
|
-
),
|
|
4215
|
-
(
|
|
4208
|
+
), u = p.flatMap(
|
|
4209
|
+
(E) => E.symbol.symbolTable ? E.symbol.symbolTable : []
|
|
4216
4210
|
);
|
|
4217
4211
|
s.push(...p);
|
|
4218
4212
|
}
|
|
@@ -4238,8 +4232,8 @@ class ls {
|
|
|
4238
4232
|
if (r.has(a))
|
|
4239
4233
|
return r.get(a);
|
|
4240
4234
|
}
|
|
4241
|
-
const
|
|
4242
|
-
return i !== void 0 ? r instanceof Map ? r.set(a,
|
|
4235
|
+
const u = n(i);
|
|
4236
|
+
return i !== void 0 ? r instanceof Map ? r.set(a, u) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, u)) : this.cache[e] = u, u;
|
|
4243
4237
|
};
|
|
4244
4238
|
}
|
|
4245
4239
|
setSource(e) {
|
|
@@ -4250,14 +4244,14 @@ class ls {
|
|
|
4250
4244
|
}
|
|
4251
4245
|
initMonacoServices() {
|
|
4252
4246
|
return {
|
|
4253
|
-
definitionProvider: new
|
|
4254
|
-
referenceProvider: new
|
|
4255
|
-
autocompletionProvider: new
|
|
4247
|
+
definitionProvider: new $t(this),
|
|
4248
|
+
referenceProvider: new Wt(this),
|
|
4249
|
+
autocompletionProvider: new Vt(this)
|
|
4256
4250
|
};
|
|
4257
4251
|
}
|
|
4258
4252
|
}
|
|
4259
4253
|
export {
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4254
|
+
hs as Compiler,
|
|
4255
|
+
ls as serialize,
|
|
4256
|
+
us as services
|
|
4263
4257
|
};
|