@dbml/parse 3.1.8 → 3.1.9-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +8 -8
- package/dist/dbml-parse.mjs +665 -619
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import I from "lodash";
|
|
2
|
-
var
|
|
3
|
-
function
|
|
2
|
+
var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
|
+
function $t(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -45,13 +45,13 @@ class B {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function Tt(t) {
|
|
48
|
-
return t.trailingTrivia.find(({ kind: e }) => e ===
|
|
48
|
+
return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
50
|
function at(t, e) {
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s ===
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || Tt(t);
|
|
52
52
|
}
|
|
53
53
|
function Ve(t) {
|
|
54
|
-
return t.trailingTrivia.find(({ kind: e }) => e ===
|
|
54
|
+
return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
56
|
function bt(t) {
|
|
57
57
|
return t.trailingTrivia.length === 0 ? t.end : bt(I.last(t.trailingTrivia));
|
|
@@ -59,12 +59,12 @@ function bt(t) {
|
|
|
59
59
|
function It(t) {
|
|
60
60
|
return t.leadingTrivia.length === 0 ? t.start : It(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return [
|
|
62
|
+
function Wt(t) {
|
|
63
|
+
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class jt {
|
|
68
68
|
constructor() {
|
|
69
69
|
this.id = 0;
|
|
70
70
|
}
|
|
@@ -75,7 +75,7 @@ class Wt {
|
|
|
75
75
|
return this.id++;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class k {
|
|
79
79
|
// The symbol that this syntax node refers to
|
|
80
80
|
// args must be passed in order of appearance in the node
|
|
81
81
|
constructor(e, n, s) {
|
|
@@ -95,12 +95,12 @@ class y {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
var de = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(de || {});
|
|
98
|
-
class
|
|
98
|
+
class G extends k {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class A extends
|
|
103
|
+
class A extends k {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -118,17 +118,17 @@ class A extends y {
|
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
120
|
l
|
|
121
|
-
]), l && a && !(l instanceof
|
|
121
|
+
]), l && a && !(l instanceof w || l instanceof A))
|
|
122
122
|
throw new Error("If an element has a simple body, it must be a function application node");
|
|
123
123
|
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = l;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class
|
|
126
|
+
class $ extends k {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class se extends
|
|
131
|
+
class se extends k {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: n,
|
|
@@ -137,12 +137,12 @@ class se extends y {
|
|
|
137
137
|
super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class q extends
|
|
140
|
+
class q extends k {
|
|
141
141
|
constructor({ op: e, expression: n }, s) {
|
|
142
142
|
super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class H extends
|
|
145
|
+
class H extends k {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,22 +151,22 @@ class H extends y {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class De extends
|
|
154
|
+
class De extends k {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class te extends
|
|
159
|
+
class te extends k {
|
|
160
160
|
constructor({ value: e }, n) {
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class
|
|
164
|
+
class w extends k {
|
|
165
165
|
constructor({ callee: e, args: n = [] }, s) {
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class ne extends
|
|
169
|
+
class ne extends k {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -175,7 +175,7 @@ class ne extends y {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class P extends
|
|
178
|
+
class P extends k {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: n = [],
|
|
@@ -189,7 +189,7 @@ class P extends y {
|
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class Z extends
|
|
192
|
+
class Z extends k {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -220,7 +220,7 @@ class Xe extends Z {
|
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class J extends
|
|
223
|
+
class J extends k {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: n
|
|
@@ -228,28 +228,28 @@ class J extends y {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class me extends
|
|
231
|
+
class me extends k {
|
|
232
232
|
constructor({ literal: e }, n) {
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class j extends k {
|
|
237
237
|
constructor({ variable: e }, n) {
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class D extends
|
|
241
|
+
class D extends k {
|
|
242
242
|
constructor({ expression: e }, n) {
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class ye extends
|
|
246
|
+
class ye extends k {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
|
-
const s = B.create(
|
|
248
|
+
const s = B.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class ce extends
|
|
252
|
+
class ce extends k {
|
|
253
253
|
constructor({ expression: e, indexer: n }, s) {
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
@@ -264,12 +264,12 @@ function Lt(t, e) {
|
|
|
264
264
|
(i) => i !== null
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function as(t, e = !1) {
|
|
268
268
|
return JSON.stringify(
|
|
269
269
|
t,
|
|
270
270
|
function(n, s) {
|
|
271
271
|
var i;
|
|
272
|
-
return !(this instanceof
|
|
272
|
+
return !(this instanceof G) && n === "symbol" ? s == null ? void 0 : s.id : (
|
|
273
273
|
/* this instanceof SyntaxNode && */
|
|
274
274
|
n === "symbol" ? {
|
|
275
275
|
symbolTable: s == null ? void 0 : s.symbolTable,
|
|
@@ -290,7 +290,7 @@ function is(t, e = !1) {
|
|
|
290
290
|
e ? 2 : 0
|
|
291
291
|
);
|
|
292
292
|
}
|
|
293
|
-
class
|
|
293
|
+
class S {
|
|
294
294
|
constructor(e) {
|
|
295
295
|
this.value = e;
|
|
296
296
|
}
|
|
@@ -305,7 +305,7 @@ class O {
|
|
|
305
305
|
return e(this.value);
|
|
306
306
|
}
|
|
307
307
|
map(e) {
|
|
308
|
-
return new
|
|
308
|
+
return new S(e(this.value));
|
|
309
309
|
}
|
|
310
310
|
// eslint-disable-next-line class-methods-use-this
|
|
311
311
|
isOk() {
|
|
@@ -334,7 +334,7 @@ class v {
|
|
|
334
334
|
return !1;
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
var m = /* @__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))(m || {});
|
|
337
|
+
var m = /* @__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))(m || {});
|
|
338
338
|
function $e(t) {
|
|
339
339
|
return `Schema:${t}`;
|
|
340
340
|
}
|
|
@@ -356,6 +356,9 @@ function ze(t) {
|
|
|
356
356
|
function Qe(t) {
|
|
357
357
|
return `TableGroup field:${t}`;
|
|
358
358
|
}
|
|
359
|
+
function Yt(t) {
|
|
360
|
+
return `Note:${t}`;
|
|
361
|
+
}
|
|
359
362
|
function Fe(t, e) {
|
|
360
363
|
switch (e) {
|
|
361
364
|
case "Column":
|
|
@@ -378,19 +381,19 @@ function Fe(t, e) {
|
|
|
378
381
|
}
|
|
379
382
|
function ie(t) {
|
|
380
383
|
const [e, n] = t.split(":");
|
|
381
|
-
return Object.values(m).includes(e) ? new
|
|
384
|
+
return Object.values(m).includes(e) ? new S({
|
|
382
385
|
name: n,
|
|
383
386
|
kind: e
|
|
384
387
|
}) : new v();
|
|
385
388
|
}
|
|
386
|
-
function
|
|
389
|
+
function zt(t) {
|
|
387
390
|
const e = ie(t).unwrap_or(void 0);
|
|
388
391
|
if (!e)
|
|
389
392
|
return !1;
|
|
390
393
|
const { kind: n, name: s } = e;
|
|
391
394
|
return n === "Schema" && s === "public";
|
|
392
395
|
}
|
|
393
|
-
function
|
|
396
|
+
function Qt(t) {
|
|
394
397
|
return [
|
|
395
398
|
$e,
|
|
396
399
|
xe,
|
|
@@ -405,16 +408,16 @@ function qe(t) {
|
|
|
405
408
|
const [e] = t;
|
|
406
409
|
return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
|
|
407
410
|
}
|
|
408
|
-
function
|
|
411
|
+
function Se(t) {
|
|
409
412
|
const [e] = t;
|
|
410
413
|
return e >= "0" && e <= "9";
|
|
411
414
|
}
|
|
412
|
-
function
|
|
415
|
+
function qt(t) {
|
|
413
416
|
const [e] = t;
|
|
414
|
-
return
|
|
417
|
+
return Se(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
415
418
|
}
|
|
416
419
|
function pe(t) {
|
|
417
|
-
return qe(t) ||
|
|
420
|
+
return qe(t) || Se(t);
|
|
418
421
|
}
|
|
419
422
|
function ot(t, e) {
|
|
420
423
|
const n = [], s = Math.min(t.length, e.length);
|
|
@@ -422,10 +425,10 @@ function ot(t, e) {
|
|
|
422
425
|
n.push(t[i], e[i]);
|
|
423
426
|
return n.push(...t.slice(s), ...e.slice(s)), n;
|
|
424
427
|
}
|
|
425
|
-
function
|
|
428
|
+
function Le(t, e) {
|
|
426
429
|
return t >= e.start && t < e.end;
|
|
427
430
|
}
|
|
428
|
-
class
|
|
431
|
+
class Ht {
|
|
429
432
|
constructor() {
|
|
430
433
|
this.id = 0;
|
|
431
434
|
}
|
|
@@ -441,12 +444,12 @@ class gt {
|
|
|
441
444
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
442
445
|
}
|
|
443
446
|
}
|
|
444
|
-
class
|
|
447
|
+
class Jt {
|
|
445
448
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
446
449
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
|
-
class
|
|
452
|
+
class Zt {
|
|
450
453
|
constructor({ declaration: e }, n) {
|
|
451
454
|
this.references = [], this.id = n, this.declaration = e;
|
|
452
455
|
}
|
|
@@ -456,25 +459,25 @@ class _t {
|
|
|
456
459
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
457
460
|
}
|
|
458
461
|
}
|
|
459
|
-
class
|
|
462
|
+
class Kt {
|
|
460
463
|
constructor({ declaration: e }, n) {
|
|
461
464
|
this.references = [], this.id = n, this.declaration = e;
|
|
462
465
|
}
|
|
463
466
|
}
|
|
464
|
-
class
|
|
467
|
+
class en {
|
|
465
468
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
466
469
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
467
470
|
}
|
|
468
471
|
}
|
|
469
|
-
class
|
|
472
|
+
class tn {
|
|
470
473
|
constructor({ declaration: e }, n) {
|
|
471
474
|
this.references = [], this.id = n, this.declaration = e;
|
|
472
475
|
}
|
|
473
476
|
}
|
|
474
477
|
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
|
|
475
|
-
class
|
|
478
|
+
class c extends Error {
|
|
476
479
|
constructor(e, n, s) {
|
|
477
|
-
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this,
|
|
480
|
+
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, c.prototype);
|
|
478
481
|
}
|
|
479
482
|
}
|
|
480
483
|
class F {
|
|
@@ -495,14 +498,14 @@ class F {
|
|
|
495
498
|
return new F(e(this.value), this.errors);
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
|
-
function
|
|
501
|
+
function nn(t, e, n) {
|
|
499
502
|
if (!t || !Ee(t) || e.length === 0)
|
|
500
503
|
return new v();
|
|
501
504
|
const s = [...e], i = Be(t).unwrap(), r = s.pop();
|
|
502
505
|
if (!(r instanceof ne))
|
|
503
506
|
return new v();
|
|
504
507
|
const a = I.last(s) instanceof P ? s.pop() : void 0;
|
|
505
|
-
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new
|
|
508
|
+
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
|
|
506
509
|
n.create(A, {
|
|
507
510
|
type: i,
|
|
508
511
|
name: s[0],
|
|
@@ -511,14 +514,14 @@ function en(t, e, n) {
|
|
|
511
514
|
attributeList: a,
|
|
512
515
|
body: r
|
|
513
516
|
})
|
|
514
|
-
) : s.length === 1 ? new
|
|
517
|
+
) : s.length === 1 ? new S(
|
|
515
518
|
n.create(A, {
|
|
516
519
|
type: i,
|
|
517
520
|
name: s[0],
|
|
518
521
|
attributeList: a,
|
|
519
522
|
body: r
|
|
520
523
|
})
|
|
521
|
-
) : s.length === 0 ? new
|
|
524
|
+
) : s.length === 0 ? new S(
|
|
522
525
|
n.create(A, {
|
|
523
526
|
type: i,
|
|
524
527
|
attributeList: a,
|
|
@@ -527,18 +530,18 @@ function en(t, e, n) {
|
|
|
527
530
|
) : new v();
|
|
528
531
|
}
|
|
529
532
|
function lt(t) {
|
|
530
|
-
return t.kind ===
|
|
533
|
+
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
531
534
|
}
|
|
532
535
|
function E(t) {
|
|
533
|
-
t && (t instanceof B ?
|
|
536
|
+
t && (t instanceof B ? sn(t) : rn(t));
|
|
534
537
|
}
|
|
535
|
-
function
|
|
536
|
-
t.kind !==
|
|
538
|
+
function sn(t) {
|
|
539
|
+
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
537
540
|
}
|
|
538
|
-
function
|
|
541
|
+
function rn(t) {
|
|
539
542
|
if (t instanceof A)
|
|
540
543
|
E(t.type), E(t.name), E(t.as), E(t.alias), E(t.bodyColon), E(t.attributeList), E(t.body);
|
|
541
|
-
else if (t instanceof
|
|
544
|
+
else if (t instanceof $)
|
|
542
545
|
t.identifiers.forEach(E);
|
|
543
546
|
else if (t instanceof se)
|
|
544
547
|
E(t.name), E(t.colon), E(t.value);
|
|
@@ -556,13 +559,13 @@ function nn(t) {
|
|
|
556
559
|
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
557
560
|
else if (t instanceof J)
|
|
558
561
|
E(t.callee), E(t.argumentList);
|
|
559
|
-
else if (t instanceof
|
|
562
|
+
else if (t instanceof w)
|
|
560
563
|
E(t.callee), t.args.forEach(E);
|
|
561
564
|
else if (t instanceof D)
|
|
562
565
|
E(t.expression);
|
|
563
566
|
else if (t instanceof te)
|
|
564
567
|
E(t.value);
|
|
565
|
-
else if (t instanceof
|
|
568
|
+
else if (t instanceof j)
|
|
566
569
|
E(t.variable);
|
|
567
570
|
else if (t instanceof me)
|
|
568
571
|
E(t.literal);
|
|
@@ -575,8 +578,8 @@ function At(t) {
|
|
|
575
578
|
function U(...t) {
|
|
576
579
|
return t.filter((e) => e !== void 0);
|
|
577
580
|
}
|
|
578
|
-
function
|
|
579
|
-
if (t instanceof
|
|
581
|
+
function an(t) {
|
|
582
|
+
if (t instanceof G)
|
|
580
583
|
return U(...t.body, t.eof);
|
|
581
584
|
if (t instanceof A)
|
|
582
585
|
return U(
|
|
@@ -590,11 +593,11 @@ function sn(t) {
|
|
|
590
593
|
);
|
|
591
594
|
if (t instanceof se)
|
|
592
595
|
return U(t.name, t.colon, t.value);
|
|
593
|
-
if (t instanceof
|
|
596
|
+
if (t instanceof $)
|
|
594
597
|
return t.identifiers;
|
|
595
598
|
if (t instanceof me)
|
|
596
599
|
return t.literal ? [t.literal] : [];
|
|
597
|
-
if (t instanceof
|
|
600
|
+
if (t instanceof j)
|
|
598
601
|
return U(t.variable);
|
|
599
602
|
if (t instanceof q)
|
|
600
603
|
return U(t.op, t.expression);
|
|
@@ -604,7 +607,7 @@ function sn(t) {
|
|
|
604
607
|
return U(t.expression, t.op);
|
|
605
608
|
if (t instanceof te)
|
|
606
609
|
return U(t.value);
|
|
607
|
-
if (t instanceof
|
|
610
|
+
if (t instanceof w)
|
|
608
611
|
return U(t.callee, ...t.args);
|
|
609
612
|
if (t instanceof ne)
|
|
610
613
|
return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
@@ -632,30 +635,30 @@ function sn(t) {
|
|
|
632
635
|
throw t instanceof Xe ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
633
636
|
}
|
|
634
637
|
function Be(t) {
|
|
635
|
-
return M(t) ? new
|
|
638
|
+
return M(t) ? new S(t.expression.variable) : new v();
|
|
636
639
|
}
|
|
637
|
-
function
|
|
640
|
+
function Y(t) {
|
|
638
641
|
var e;
|
|
639
|
-
return t instanceof D && (t.expression instanceof
|
|
642
|
+
return t instanceof D && (t.expression instanceof j && t.expression.variable instanceof B && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
640
643
|
}
|
|
641
644
|
function M(t) {
|
|
642
|
-
return t instanceof D && t.expression instanceof
|
|
645
|
+
return t instanceof D && t.expression instanceof j && t.expression.variable instanceof B;
|
|
643
646
|
}
|
|
644
647
|
function Ee(t) {
|
|
645
648
|
var e;
|
|
646
|
-
return t instanceof D && t.expression instanceof
|
|
649
|
+
return t instanceof D && t.expression instanceof j && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
647
650
|
}
|
|
648
651
|
function He(t) {
|
|
649
652
|
var e;
|
|
650
|
-
return t instanceof H && t.leftExpression instanceof
|
|
653
|
+
return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
651
654
|
}
|
|
652
655
|
function Ne(t) {
|
|
653
656
|
if (t === void 0)
|
|
654
657
|
return new v();
|
|
655
658
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
656
|
-
return e === "" ? new v() : new
|
|
659
|
+
return e === "" ? new v() : new S(e);
|
|
657
660
|
}
|
|
658
|
-
class
|
|
661
|
+
class on {
|
|
659
662
|
// list of errors during lexing
|
|
660
663
|
constructor(e) {
|
|
661
664
|
this.start = {
|
|
@@ -704,50 +707,50 @@ class rn {
|
|
|
704
707
|
);
|
|
705
708
|
}
|
|
706
709
|
lex() {
|
|
707
|
-
return this.scanTokens(), this.tokens.push(B.create(
|
|
710
|
+
return this.scanTokens(), this.tokens.push(B.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new F(this.tokens, this.errors);
|
|
708
711
|
}
|
|
709
712
|
scanTokens() {
|
|
710
713
|
for (; !this.isAtEnd(); ) {
|
|
711
714
|
const e = this.advance();
|
|
712
715
|
switch (e) {
|
|
713
716
|
case " ":
|
|
714
|
-
this.addToken(
|
|
717
|
+
this.addToken(u.SPACE);
|
|
715
718
|
break;
|
|
716
719
|
case "\r":
|
|
717
720
|
break;
|
|
718
721
|
case `
|
|
719
722
|
`:
|
|
720
|
-
this.addToken(
|
|
723
|
+
this.addToken(u.NEWLINE);
|
|
721
724
|
break;
|
|
722
725
|
case " ":
|
|
723
|
-
this.addToken(
|
|
726
|
+
this.addToken(u.TAB);
|
|
724
727
|
break;
|
|
725
728
|
case ",":
|
|
726
|
-
this.addToken(
|
|
729
|
+
this.addToken(u.COMMA);
|
|
727
730
|
break;
|
|
728
731
|
case "(":
|
|
729
|
-
this.addToken(
|
|
732
|
+
this.addToken(u.LPAREN);
|
|
730
733
|
break;
|
|
731
734
|
case ")":
|
|
732
|
-
this.addToken(
|
|
735
|
+
this.addToken(u.RPAREN);
|
|
733
736
|
break;
|
|
734
737
|
case "[":
|
|
735
|
-
this.addToken(
|
|
738
|
+
this.addToken(u.LBRACKET);
|
|
736
739
|
break;
|
|
737
740
|
case "]":
|
|
738
|
-
this.addToken(
|
|
741
|
+
this.addToken(u.RBRACKET);
|
|
739
742
|
break;
|
|
740
743
|
case "{":
|
|
741
|
-
this.addToken(
|
|
744
|
+
this.addToken(u.LBRACE);
|
|
742
745
|
break;
|
|
743
746
|
case "}":
|
|
744
|
-
this.addToken(
|
|
747
|
+
this.addToken(u.RBRACE);
|
|
745
748
|
break;
|
|
746
749
|
case ";":
|
|
747
|
-
this.addToken(
|
|
750
|
+
this.addToken(u.SEMICOLON);
|
|
748
751
|
break;
|
|
749
752
|
case ":":
|
|
750
|
-
this.addToken(
|
|
753
|
+
this.addToken(u.COLON);
|
|
751
754
|
break;
|
|
752
755
|
case "'":
|
|
753
756
|
this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
|
|
@@ -773,15 +776,15 @@ class rn {
|
|
|
773
776
|
this.identifier();
|
|
774
777
|
break;
|
|
775
778
|
}
|
|
776
|
-
if (
|
|
779
|
+
if (Se(e)) {
|
|
777
780
|
this.numericLiteralOrIdentifier();
|
|
778
781
|
break;
|
|
779
782
|
}
|
|
780
|
-
this.addToken(
|
|
781
|
-
new
|
|
783
|
+
this.addToken(u.OP, !0), this.errors.push(
|
|
784
|
+
new c(
|
|
782
785
|
o.UNKNOWN_SYMBOL,
|
|
783
786
|
`Unexpected token '${e}'`,
|
|
784
|
-
this.createToken(
|
|
787
|
+
this.createToken(u.OP, !0)
|
|
785
788
|
)
|
|
786
789
|
);
|
|
787
790
|
break;
|
|
@@ -793,7 +796,7 @@ class rn {
|
|
|
793
796
|
let e = !0, n = [], s;
|
|
794
797
|
const i = [];
|
|
795
798
|
for (const r of this.tokens)
|
|
796
|
-
|
|
799
|
+
$t(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
|
|
797
800
|
this.tokens = i;
|
|
798
801
|
}
|
|
799
802
|
gatherInvalid() {
|
|
@@ -825,7 +828,7 @@ class rn {
|
|
|
825
828
|
if (this.isAtEnd() && !i) {
|
|
826
829
|
const p = this.createToken(e, !0);
|
|
827
830
|
this.tokens.push(p), this.errors.push(
|
|
828
|
-
new
|
|
831
|
+
new c(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
|
|
829
832
|
);
|
|
830
833
|
return;
|
|
831
834
|
}
|
|
@@ -833,7 +836,7 @@ class rn {
|
|
|
833
836
|
`) && !s) {
|
|
834
837
|
const p = this.createToken(e, !0);
|
|
835
838
|
this.tokens.push(p), this.errors.push(
|
|
836
|
-
new
|
|
839
|
+
new c(
|
|
837
840
|
o.UNEXPECTED_NEWLINE,
|
|
838
841
|
"Invalid newline encountered while parsing",
|
|
839
842
|
p
|
|
@@ -844,35 +847,35 @@ class rn {
|
|
|
844
847
|
a && this.match(n), this.tokens.push(B.create(e, this.start, this.current, l, !1));
|
|
845
848
|
}
|
|
846
849
|
singleLineStringLiteral() {
|
|
847
|
-
this.consumeUntil(
|
|
850
|
+
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
848
851
|
allowNewline: !1,
|
|
849
852
|
allowEof: !1,
|
|
850
853
|
raw: !1
|
|
851
854
|
});
|
|
852
855
|
}
|
|
853
856
|
multilineStringLiteral() {
|
|
854
|
-
this.consumeUntil(
|
|
857
|
+
this.consumeUntil(u.STRING_LITERAL, "'''", {
|
|
855
858
|
allowNewline: !0,
|
|
856
859
|
allowEof: !1,
|
|
857
860
|
raw: !1
|
|
858
861
|
});
|
|
859
862
|
}
|
|
860
863
|
functionExpression() {
|
|
861
|
-
this.consumeUntil(
|
|
864
|
+
this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
|
|
862
865
|
allowNewline: !1,
|
|
863
866
|
allowEof: !1,
|
|
864
867
|
raw: !0
|
|
865
868
|
});
|
|
866
869
|
}
|
|
867
870
|
quotedVariable() {
|
|
868
|
-
this.consumeUntil(
|
|
871
|
+
this.consumeUntil(u.QUOTED_STRING, '"', {
|
|
869
872
|
allowNewline: !1,
|
|
870
873
|
allowEof: !1,
|
|
871
874
|
raw: !1
|
|
872
875
|
});
|
|
873
876
|
}
|
|
874
877
|
singleLineComment() {
|
|
875
|
-
this.consumeUntil(
|
|
878
|
+
this.consumeUntil(u.SINGLE_LINE_COMMENT, `
|
|
876
879
|
`, {
|
|
877
880
|
allowNewline: !0,
|
|
878
881
|
allowEof: !0,
|
|
@@ -881,7 +884,7 @@ class rn {
|
|
|
881
884
|
});
|
|
882
885
|
}
|
|
883
886
|
multilineComment() {
|
|
884
|
-
this.consumeUntil(
|
|
887
|
+
this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
|
|
885
888
|
allowNewline: !0,
|
|
886
889
|
allowEof: !1,
|
|
887
890
|
raw: !0
|
|
@@ -890,46 +893,46 @@ class rn {
|
|
|
890
893
|
identifier() {
|
|
891
894
|
for (; !this.isAtEnd() && pe(this.peek()); )
|
|
892
895
|
this.advance();
|
|
893
|
-
this.addToken(
|
|
896
|
+
this.addToken(u.IDENTIFIER);
|
|
894
897
|
}
|
|
895
898
|
operator() {
|
|
896
899
|
for (; it(this.peek()); )
|
|
897
900
|
this.advance();
|
|
898
|
-
this.addToken(
|
|
901
|
+
this.addToken(u.OP);
|
|
899
902
|
}
|
|
900
903
|
// we accept identifiers starting with digits but must contain at least one char or underscore
|
|
901
904
|
numericLiteralOrIdentifier() {
|
|
902
905
|
let e = 0;
|
|
903
906
|
if (this.isAtEnd())
|
|
904
|
-
return this.addToken(
|
|
907
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
905
908
|
for (; !this.isAtEnd(); ) {
|
|
906
909
|
const n = this.check(".");
|
|
907
910
|
if (e += n ? 1 : 0, e > 1)
|
|
908
911
|
break;
|
|
909
912
|
if (!n && this.current.offset === this.text.length - 1)
|
|
910
|
-
return this.advance(), this.addToken(
|
|
913
|
+
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
911
914
|
if (!n && !pe(this.peek()))
|
|
912
|
-
return this.addToken(
|
|
913
|
-
if (!n && !
|
|
915
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
916
|
+
if (!n && !Se(this.peek()))
|
|
914
917
|
break;
|
|
915
918
|
this.advance();
|
|
916
919
|
}
|
|
917
920
|
if (e > 0) {
|
|
918
921
|
for (; !this.isAtEnd() && (this.check(".") || pe(this.peek())); )
|
|
919
922
|
this.advance();
|
|
920
|
-
const n = this.createToken(
|
|
921
|
-
this.tokens.push(n), this.errors.push(new
|
|
923
|
+
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
924
|
+
this.tokens.push(n), this.errors.push(new c(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
922
925
|
} else {
|
|
923
926
|
for (; !this.isAtEnd() && pe(this.peek()); )
|
|
924
927
|
this.advance();
|
|
925
|
-
const n = this.createToken(
|
|
928
|
+
const n = this.createToken(u.IDENTIFIER, !1);
|
|
926
929
|
this.tokens.push(n);
|
|
927
930
|
}
|
|
928
931
|
}
|
|
929
932
|
colorLiteral() {
|
|
930
933
|
for (; !this.isAtEnd() && pe(this.peek()); )
|
|
931
934
|
this.advance();
|
|
932
|
-
this.addToken(
|
|
935
|
+
this.addToken(u.COLOR_LITERAL);
|
|
933
936
|
}
|
|
934
937
|
escapedString() {
|
|
935
938
|
if (this.isAtEnd())
|
|
@@ -971,7 +974,7 @@ class rn {
|
|
|
971
974
|
}
|
|
972
975
|
}
|
|
973
976
|
var ke = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ke || {});
|
|
974
|
-
class
|
|
977
|
+
class ln {
|
|
975
978
|
constructor() {
|
|
976
979
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
977
980
|
}
|
|
@@ -1012,7 +1015,7 @@ class an {
|
|
|
1012
1015
|
if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
|
|
1013
1016
|
for (let s = n; s < e.length - 1; s += 1)
|
|
1014
1017
|
switch (e[s].kind) {
|
|
1015
|
-
case
|
|
1018
|
+
case u.COMMA:
|
|
1016
1019
|
if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
|
|
1017
1020
|
return [...this.stack].reverse().find(
|
|
1018
1021
|
(r) => [
|
|
@@ -1022,22 +1025,22 @@ class an {
|
|
|
1022
1025
|
].includes(r)
|
|
1023
1026
|
);
|
|
1024
1027
|
break;
|
|
1025
|
-
case
|
|
1028
|
+
case u.RPAREN:
|
|
1026
1029
|
if (this.isWithinGroupExpressionContext())
|
|
1027
1030
|
return 1;
|
|
1028
1031
|
break;
|
|
1029
|
-
case
|
|
1032
|
+
case u.RBRACE:
|
|
1030
1033
|
if (this.isWithinBlockExpressionContext())
|
|
1031
1034
|
return 2;
|
|
1032
1035
|
break;
|
|
1033
|
-
case
|
|
1036
|
+
case u.RBRACKET:
|
|
1034
1037
|
if (this.isWithinListExpressionContext())
|
|
1035
1038
|
return 0;
|
|
1036
1039
|
break;
|
|
1037
1040
|
}
|
|
1038
1041
|
}
|
|
1039
1042
|
}
|
|
1040
|
-
class
|
|
1043
|
+
class cn {
|
|
1041
1044
|
constructor(e) {
|
|
1042
1045
|
this.generator = e;
|
|
1043
1046
|
}
|
|
@@ -1050,29 +1053,29 @@ class d {
|
|
|
1050
1053
|
this.token = e, this.partialNode = n, this.handlerContext = s;
|
|
1051
1054
|
}
|
|
1052
1055
|
}
|
|
1053
|
-
class
|
|
1056
|
+
class un {
|
|
1054
1057
|
constructor(e, n) {
|
|
1055
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1058
|
+
this.current = 0, this.errors = [], this.contextStack = new ln(), this.synchronizeProgram = () => {
|
|
1056
1059
|
const s = this.peek();
|
|
1057
|
-
s.kind !==
|
|
1060
|
+
s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1058
1061
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1059
1062
|
for (; !this.isAtEnd(); ) {
|
|
1060
1063
|
const s = this.peek();
|
|
1061
|
-
if (lt(s) || this.check(
|
|
1064
|
+
if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1062
1065
|
break;
|
|
1063
1066
|
E(s), this.advance();
|
|
1064
1067
|
}
|
|
1065
1068
|
}, this.synchronizeElementDeclarationAlias = () => {
|
|
1066
1069
|
for (; !this.isAtEnd(); ) {
|
|
1067
1070
|
const s = this.peek();
|
|
1068
|
-
if (this.check(
|
|
1071
|
+
if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1069
1072
|
break;
|
|
1070
1073
|
E(s), this.advance();
|
|
1071
1074
|
}
|
|
1072
1075
|
}, this.blockExpression = this.contextStack.withContextDo(ke.BlockExpression, () => {
|
|
1073
1076
|
const s = { body: [] }, i = () => this.nodeFactory.create(ne, s);
|
|
1074
1077
|
try {
|
|
1075
|
-
this.consume("Expect an opening brace '{'",
|
|
1078
|
+
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
1076
1079
|
} catch (r) {
|
|
1077
1080
|
if (!(r instanceof d))
|
|
1078
1081
|
throw r;
|
|
@@ -1080,7 +1083,7 @@ class ln {
|
|
|
1080
1083
|
throw new d(r.token, i(), r.handlerContext);
|
|
1081
1084
|
this.synchronizeBlock();
|
|
1082
1085
|
}
|
|
1083
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1086
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACE); )
|
|
1084
1087
|
try {
|
|
1085
1088
|
s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
|
|
1086
1089
|
} catch (r) {
|
|
@@ -1091,7 +1094,7 @@ class ln {
|
|
|
1091
1094
|
this.synchronizeBlock();
|
|
1092
1095
|
}
|
|
1093
1096
|
try {
|
|
1094
|
-
this.consume("Expect a closing brace '}'",
|
|
1097
|
+
this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
|
|
1095
1098
|
} catch (r) {
|
|
1096
1099
|
if (!(r instanceof d))
|
|
1097
1100
|
throw r;
|
|
@@ -1101,10 +1104,10 @@ class ln {
|
|
|
1101
1104
|
}
|
|
1102
1105
|
return i();
|
|
1103
1106
|
}), this.synchronizeBlock = () => {
|
|
1104
|
-
if (!this.check(
|
|
1107
|
+
if (!this.check(u.RBRACE))
|
|
1105
1108
|
for (E(this.advance()); !this.isAtEnd(); ) {
|
|
1106
1109
|
const s = this.peek();
|
|
1107
|
-
if (this.check(
|
|
1110
|
+
if (this.check(u.RBRACE) || at(this.previous(), s))
|
|
1108
1111
|
break;
|
|
1109
1112
|
E(s), this.advance();
|
|
1110
1113
|
}
|
|
@@ -1115,7 +1118,7 @@ class ln {
|
|
|
1115
1118
|
expression: s.elementList[0]
|
|
1116
1119
|
}), r = () => this.nodeFactory.create(Z, s);
|
|
1117
1120
|
try {
|
|
1118
|
-
this.consume("Expect an opening parenthesis '('",
|
|
1121
|
+
this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
|
|
1119
1122
|
} catch (a) {
|
|
1120
1123
|
if (!(a instanceof d))
|
|
1121
1124
|
throw a;
|
|
@@ -1123,7 +1126,7 @@ class ln {
|
|
|
1123
1126
|
throw new d(a.token, r(), a.handlerContext);
|
|
1124
1127
|
this.synchronizeTuple();
|
|
1125
1128
|
}
|
|
1126
|
-
if (!this.isAtEnd() && !this.check(
|
|
1129
|
+
if (!this.isAtEnd() && !this.check(u.RPAREN))
|
|
1127
1130
|
try {
|
|
1128
1131
|
s.elementList.push(this.normalExpression());
|
|
1129
1132
|
} catch (a) {
|
|
@@ -1133,18 +1136,18 @@ class ln {
|
|
|
1133
1136
|
throw new d(a.token, i(), a.handlerContext);
|
|
1134
1137
|
this.synchronizeTuple();
|
|
1135
1138
|
}
|
|
1136
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1139
|
+
for (; !this.isAtEnd() && !this.check(u.RPAREN); )
|
|
1137
1140
|
try {
|
|
1138
|
-
this.consume("Expect a comma ','",
|
|
1141
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
|
|
1139
1142
|
} catch (a) {
|
|
1140
1143
|
if (!(a instanceof d))
|
|
1141
1144
|
throw a;
|
|
1142
|
-
if (a.partialNode instanceof
|
|
1145
|
+
if (a.partialNode instanceof k && s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1143
1146
|
throw new d(a.token, r(), a.handlerContext);
|
|
1144
1147
|
this.synchronizeTuple();
|
|
1145
1148
|
}
|
|
1146
1149
|
try {
|
|
1147
|
-
this.consume("Expect a closing parenthesis ')'",
|
|
1150
|
+
this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
|
|
1148
1151
|
} catch (a) {
|
|
1149
1152
|
if (!(a instanceof d))
|
|
1150
1153
|
throw a;
|
|
@@ -1156,14 +1159,14 @@ class ln {
|
|
|
1156
1159
|
}), this.synchronizeTuple = () => {
|
|
1157
1160
|
for (; !this.isAtEnd(); ) {
|
|
1158
1161
|
const s = this.peek();
|
|
1159
|
-
if (this.check(
|
|
1162
|
+
if (this.check(u.RPAREN, u.COMMA))
|
|
1160
1163
|
break;
|
|
1161
1164
|
E(s), this.advance();
|
|
1162
1165
|
}
|
|
1163
1166
|
}, this.listExpression = this.contextStack.withContextDo(ke.ListExpression, () => {
|
|
1164
1167
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(P, s);
|
|
1165
1168
|
try {
|
|
1166
|
-
this.consume("Expect an opening bracket '['",
|
|
1169
|
+
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
1167
1170
|
} catch (r) {
|
|
1168
1171
|
if (!(r instanceof d))
|
|
1169
1172
|
throw r;
|
|
@@ -1171,7 +1174,7 @@ class ln {
|
|
|
1171
1174
|
throw new d(r.token, i(), r.handlerContext);
|
|
1172
1175
|
this.synchronizeList();
|
|
1173
1176
|
}
|
|
1174
|
-
if (!this.isAtEnd() && !this.check(
|
|
1177
|
+
if (!this.isAtEnd() && !this.check(u.RBRACKET))
|
|
1175
1178
|
try {
|
|
1176
1179
|
s.elementList.push(this.attribute());
|
|
1177
1180
|
} catch (r) {
|
|
@@ -1181,18 +1184,18 @@ class ln {
|
|
|
1181
1184
|
throw new d(r.token, i(), r.handlerContext);
|
|
1182
1185
|
this.synchronizeList();
|
|
1183
1186
|
}
|
|
1184
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1187
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
|
|
1185
1188
|
try {
|
|
1186
|
-
this.consume("Expect a comma ','",
|
|
1189
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
|
|
1187
1190
|
} catch (r) {
|
|
1188
1191
|
if (!(r instanceof d))
|
|
1189
1192
|
throw r;
|
|
1190
|
-
if (r.partialNode instanceof
|
|
1193
|
+
if (r.partialNode instanceof k && s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1191
1194
|
throw new d(r.token, i(), r.handlerContext);
|
|
1192
1195
|
this.synchronizeList();
|
|
1193
1196
|
}
|
|
1194
1197
|
try {
|
|
1195
|
-
this.consume("Expect a closing bracket ']'",
|
|
1198
|
+
this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
|
|
1196
1199
|
} catch (r) {
|
|
1197
1200
|
if (!(r instanceof d))
|
|
1198
1201
|
throw r;
|
|
@@ -1204,28 +1207,28 @@ class ln {
|
|
|
1204
1207
|
}), this.synchronizeList = () => {
|
|
1205
1208
|
for (; !this.isAtEnd(); ) {
|
|
1206
1209
|
const s = this.peek();
|
|
1207
|
-
if (this.check(
|
|
1210
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1208
1211
|
break;
|
|
1209
1212
|
E(s), this.advance();
|
|
1210
1213
|
}
|
|
1211
1214
|
}, this.synchronizeAttributeName = () => {
|
|
1212
1215
|
for (; !this.isAtEnd(); ) {
|
|
1213
1216
|
const s = this.peek();
|
|
1214
|
-
if (this.check(
|
|
1217
|
+
if (this.check(u.COMMA, u.RBRACKET, u.COLON))
|
|
1215
1218
|
break;
|
|
1216
1219
|
E(s), this.advance();
|
|
1217
1220
|
}
|
|
1218
1221
|
}, this.synchronizeAttributeValue = () => {
|
|
1219
1222
|
for (; !this.isAtEnd(); ) {
|
|
1220
1223
|
const s = this.peek();
|
|
1221
|
-
if (this.check(
|
|
1224
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1222
1225
|
break;
|
|
1223
1226
|
E(s), this.advance();
|
|
1224
1227
|
}
|
|
1225
|
-
}, this.tokens = e, this.nodeFactory = new
|
|
1228
|
+
}, this.tokens = e, this.nodeFactory = new cn(n);
|
|
1226
1229
|
}
|
|
1227
1230
|
isAtEnd() {
|
|
1228
|
-
return this.current >= this.tokens.length || this.tokens[this.current].kind ===
|
|
1231
|
+
return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
|
|
1229
1232
|
}
|
|
1230
1233
|
advance() {
|
|
1231
1234
|
return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
|
|
@@ -1278,7 +1281,7 @@ class ln {
|
|
|
1278
1281
|
this.tokens = e;
|
|
1279
1282
|
}
|
|
1280
1283
|
parse() {
|
|
1281
|
-
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(
|
|
1284
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(G, { body: e, eof: n });
|
|
1282
1285
|
return this.gatherInvalid(), new F({ ast: s, tokens: this.tokens }, this.errors);
|
|
1283
1286
|
}
|
|
1284
1287
|
/* Parsing and synchronizing ProgramNode */
|
|
@@ -1299,11 +1302,11 @@ class ln {
|
|
|
1299
1302
|
elementDeclaration() {
|
|
1300
1303
|
const e = {}, n = () => this.nodeFactory.create(A, e);
|
|
1301
1304
|
try {
|
|
1302
|
-
this.consume("Expect an identifier",
|
|
1305
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1303
1306
|
} catch (s) {
|
|
1304
1307
|
throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1305
1308
|
}
|
|
1306
|
-
if (!this.check(
|
|
1309
|
+
if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1307
1310
|
try {
|
|
1308
1311
|
e.name = this.normalExpression();
|
|
1309
1312
|
} catch (s) {
|
|
@@ -1314,7 +1317,7 @@ class ln {
|
|
|
1314
1317
|
this.synchronizeElementDeclarationName();
|
|
1315
1318
|
}
|
|
1316
1319
|
if (lt(this.peek()))
|
|
1317
|
-
if (e.as = this.advance(), this.check(
|
|
1320
|
+
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1318
1321
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1319
1322
|
else
|
|
1320
1323
|
try {
|
|
@@ -1327,18 +1330,18 @@ class ln {
|
|
|
1327
1330
|
this.synchronizeElementDeclarationAlias();
|
|
1328
1331
|
}
|
|
1329
1332
|
try {
|
|
1330
|
-
e.attributeList = this.check(
|
|
1333
|
+
e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
|
|
1331
1334
|
} catch (s) {
|
|
1332
1335
|
throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1333
1336
|
}
|
|
1334
1337
|
if (!this.discardUntil(
|
|
1335
1338
|
"Expect an opening brace '{' or a colon ':'",
|
|
1336
|
-
|
|
1337
|
-
|
|
1339
|
+
u.LBRACE,
|
|
1340
|
+
u.COLON
|
|
1338
1341
|
))
|
|
1339
1342
|
return n();
|
|
1340
1343
|
try {
|
|
1341
|
-
if (this.match(
|
|
1344
|
+
if (this.match(u.COLON)) {
|
|
1342
1345
|
e.bodyColon = this.previous();
|
|
1343
1346
|
const s = this.expression();
|
|
1344
1347
|
s instanceof A ? (E(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
|
|
@@ -1358,18 +1361,18 @@ class ln {
|
|
|
1358
1361
|
fieldDeclaration() {
|
|
1359
1362
|
const e = {}, n = () => this.nodeFactory.create(A, e);
|
|
1360
1363
|
try {
|
|
1361
|
-
this.consume("Expect an identifier",
|
|
1364
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1362
1365
|
} catch (s) {
|
|
1363
1366
|
throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1364
1367
|
}
|
|
1365
1368
|
try {
|
|
1366
|
-
this.consume("Expect a colon ':'",
|
|
1369
|
+
this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
|
|
1367
1370
|
} catch (s) {
|
|
1368
1371
|
throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1369
1372
|
}
|
|
1370
1373
|
try {
|
|
1371
1374
|
const s = this.expression();
|
|
1372
|
-
s instanceof A ? this.errors.push(new
|
|
1375
|
+
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;
|
|
1373
1376
|
} catch (s) {
|
|
1374
1377
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1375
1378
|
}
|
|
@@ -1377,8 +1380,8 @@ class ln {
|
|
|
1377
1380
|
}
|
|
1378
1381
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1379
1382
|
expression() {
|
|
1380
|
-
const e = { args: [] }, n = () =>
|
|
1381
|
-
this.nodeFactory.create(
|
|
1383
|
+
const e = { args: [] }, n = () => nn(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1384
|
+
this.nodeFactory.create(w, e)
|
|
1382
1385
|
);
|
|
1383
1386
|
try {
|
|
1384
1387
|
e.callee = this.normalExpression();
|
|
@@ -1402,7 +1405,7 @@ class ln {
|
|
|
1402
1405
|
if (this.isAtEnd() || Tt(this.previous()))
|
|
1403
1406
|
return !0;
|
|
1404
1407
|
const e = this.peek().kind;
|
|
1405
|
-
return e ===
|
|
1408
|
+
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
1406
1409
|
}
|
|
1407
1410
|
normalExpression() {
|
|
1408
1411
|
return this.expression_bp(0);
|
|
@@ -1412,7 +1415,7 @@ class ln {
|
|
|
1412
1415
|
let n = this.leftExpression_bp();
|
|
1413
1416
|
for (; !this.isAtEnd(); ) {
|
|
1414
1417
|
const s = this.peek();
|
|
1415
|
-
if (s.kind ===
|
|
1418
|
+
if (s.kind === u.LPAREN) {
|
|
1416
1419
|
const { left: i } = ct(s);
|
|
1417
1420
|
if (i < e || // When '(' is encountered,
|
|
1418
1421
|
// consider it part of another expression if
|
|
@@ -1431,7 +1434,7 @@ class ln {
|
|
|
1431
1434
|
argumentList: r.partialNode
|
|
1432
1435
|
}), new d(r.token, n, r.handlerContext)) : r;
|
|
1433
1436
|
}
|
|
1434
|
-
} else if (s.kind ===
|
|
1437
|
+
} else if (s.kind === u.LBRACKET) {
|
|
1435
1438
|
if (Ve(this.previous()))
|
|
1436
1439
|
break;
|
|
1437
1440
|
try {
|
|
@@ -1455,7 +1458,7 @@ class ln {
|
|
|
1455
1458
|
op: i
|
|
1456
1459
|
});
|
|
1457
1460
|
} else {
|
|
1458
|
-
const a =
|
|
1461
|
+
const a = fn(i);
|
|
1459
1462
|
if (a.left === null || a.left <= e)
|
|
1460
1463
|
break;
|
|
1461
1464
|
this.advance();
|
|
@@ -1483,7 +1486,7 @@ class ln {
|
|
|
1483
1486
|
if (rt(this.peek())) {
|
|
1484
1487
|
const n = {};
|
|
1485
1488
|
n.op = this.peek();
|
|
1486
|
-
const s =
|
|
1489
|
+
const s = dn(n.op);
|
|
1487
1490
|
if (s.right === null)
|
|
1488
1491
|
throw this.logError(
|
|
1489
1492
|
n.op,
|
|
@@ -1519,12 +1522,12 @@ class ln {
|
|
|
1519
1522
|
// e.g { ... }
|
|
1520
1523
|
extractOperand() {
|
|
1521
1524
|
return this.check(
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
) ? this.primaryExpression() : this.check(
|
|
1525
|
+
u.NUMERIC_LITERAL,
|
|
1526
|
+
u.STRING_LITERAL,
|
|
1527
|
+
u.COLOR_LITERAL,
|
|
1528
|
+
u.QUOTED_STRING,
|
|
1529
|
+
u.IDENTIFIER
|
|
1530
|
+
) ? this.primaryExpression() : this.check(u.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(u.LBRACKET) ? this.listExpression() : this.check(u.LBRACE) ? this.blockExpression() : this.check(u.LPAREN) ? this.tupleExpression() : (this.peek().kind === u.EOF ? this.logError(
|
|
1528
1531
|
this.peek(),
|
|
1529
1532
|
o.UNEXPECTED_EOF,
|
|
1530
1533
|
"Unexpected EOF"
|
|
@@ -1538,7 +1541,7 @@ class ln {
|
|
|
1538
1541
|
functionExpression() {
|
|
1539
1542
|
const e = {};
|
|
1540
1543
|
try {
|
|
1541
|
-
this.consume("Expect a function expression",
|
|
1544
|
+
this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
|
|
1542
1545
|
} catch (n) {
|
|
1543
1546
|
throw n instanceof d ? (e.value = n.partialNode, new d(
|
|
1544
1547
|
n.token,
|
|
@@ -1549,39 +1552,39 @@ class ln {
|
|
|
1549
1552
|
return this.nodeFactory.create(te, e);
|
|
1550
1553
|
}
|
|
1551
1554
|
canBeField() {
|
|
1552
|
-
return this.peek().kind ===
|
|
1555
|
+
return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
|
|
1553
1556
|
}
|
|
1554
1557
|
/* Parsing PrimaryExpression */
|
|
1555
1558
|
primaryExpression() {
|
|
1556
1559
|
if (this.match(
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
+
u.COLOR_LITERAL,
|
|
1561
|
+
u.STRING_LITERAL,
|
|
1562
|
+
u.NUMERIC_LITERAL
|
|
1560
1563
|
))
|
|
1561
1564
|
return this.nodeFactory.create(D, {
|
|
1562
1565
|
expression: this.nodeFactory.create(me, { literal: this.previous() })
|
|
1563
1566
|
});
|
|
1564
|
-
if (this.match(
|
|
1567
|
+
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1565
1568
|
return this.nodeFactory.create(D, {
|
|
1566
|
-
expression: this.nodeFactory.create(
|
|
1569
|
+
expression: this.nodeFactory.create(j, { variable: this.previous() })
|
|
1567
1570
|
});
|
|
1568
1571
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1569
1572
|
this.peek(),
|
|
1570
1573
|
this.nodeFactory.create(D, {
|
|
1571
|
-
expression: this.nodeFactory.create(
|
|
1574
|
+
expression: this.nodeFactory.create(j, {})
|
|
1572
1575
|
}),
|
|
1573
1576
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1574
1577
|
);
|
|
1575
1578
|
}
|
|
1576
1579
|
attribute() {
|
|
1577
1580
|
const e = {};
|
|
1578
|
-
if (this.check(
|
|
1581
|
+
if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
|
|
1579
1582
|
const n = this.peek();
|
|
1580
1583
|
this.logError(
|
|
1581
1584
|
n,
|
|
1582
1585
|
o.EMPTY_ATTRIBUTE_NAME,
|
|
1583
1586
|
"Expect a non-empty attribute name"
|
|
1584
|
-
), e.name = this.nodeFactory.create(
|
|
1587
|
+
), e.name = this.nodeFactory.create($, { identifiers: [] });
|
|
1585
1588
|
} else
|
|
1586
1589
|
try {
|
|
1587
1590
|
e.name = this.attributeName();
|
|
@@ -1596,12 +1599,12 @@ class ln {
|
|
|
1596
1599
|
);
|
|
1597
1600
|
this.synchronizeAttributeName();
|
|
1598
1601
|
}
|
|
1599
|
-
return this.match(
|
|
1602
|
+
return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
|
|
1600
1603
|
}
|
|
1601
1604
|
attributeValue() {
|
|
1602
1605
|
let e;
|
|
1603
1606
|
try {
|
|
1604
|
-
e = this.peek().kind ===
|
|
1607
|
+
e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
|
|
1605
1608
|
} catch (n) {
|
|
1606
1609
|
if (!(n instanceof d) || !this.canHandle(n))
|
|
1607
1610
|
throw n;
|
|
@@ -1611,25 +1614,25 @@ class ln {
|
|
|
1611
1614
|
}
|
|
1612
1615
|
attributeName() {
|
|
1613
1616
|
const e = [];
|
|
1614
|
-
if (this.peek().kind !==
|
|
1617
|
+
if (this.peek().kind !== u.IDENTIFIER)
|
|
1615
1618
|
return this.primaryExpression();
|
|
1616
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1619
|
+
for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
|
|
1617
1620
|
try {
|
|
1618
|
-
this.consume("Expect an identifier",
|
|
1621
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
|
|
1619
1622
|
} catch (n) {
|
|
1620
1623
|
throw n instanceof d ? new d(
|
|
1621
1624
|
n.token,
|
|
1622
|
-
this.nodeFactory.create(
|
|
1625
|
+
this.nodeFactory.create($, { identifiers: e }),
|
|
1623
1626
|
n.handlerContext
|
|
1624
1627
|
) : n;
|
|
1625
1628
|
}
|
|
1626
|
-
return this.nodeFactory.create(
|
|
1629
|
+
return this.nodeFactory.create($, { identifiers: e });
|
|
1627
1630
|
}
|
|
1628
1631
|
logError(e, n, s) {
|
|
1629
|
-
this.errors.push(new
|
|
1632
|
+
this.errors.push(new c(n, s, e));
|
|
1630
1633
|
}
|
|
1631
1634
|
}
|
|
1632
|
-
const
|
|
1635
|
+
const hn = {
|
|
1633
1636
|
"+": { left: 9, right: 10 },
|
|
1634
1637
|
"*": { left: 11, right: 12 },
|
|
1635
1638
|
"-": { left: 9, right: 10 },
|
|
@@ -1645,10 +1648,10 @@ const cn = {
|
|
|
1645
1648
|
"!=": { left: 4, right: 5 },
|
|
1646
1649
|
".": { left: 16, right: 17 }
|
|
1647
1650
|
};
|
|
1648
|
-
function
|
|
1649
|
-
return
|
|
1651
|
+
function fn(t) {
|
|
1652
|
+
return hn[t.value] || { left: null, right: null };
|
|
1650
1653
|
}
|
|
1651
|
-
const
|
|
1654
|
+
const pn = {
|
|
1652
1655
|
"+": { left: null, right: 15 },
|
|
1653
1656
|
"-": { left: null, right: 15 },
|
|
1654
1657
|
"<": { left: null, right: 15 },
|
|
@@ -1656,17 +1659,17 @@ const hn = {
|
|
|
1656
1659
|
"<>": { left: null, right: 15 },
|
|
1657
1660
|
"!": { left: null, right: 15 }
|
|
1658
1661
|
};
|
|
1659
|
-
function
|
|
1660
|
-
return
|
|
1662
|
+
function dn(t) {
|
|
1663
|
+
return pn[t.value] || { left: null, right: null };
|
|
1661
1664
|
}
|
|
1662
|
-
const
|
|
1665
|
+
const En = {
|
|
1663
1666
|
"(": { left: 14, right: null }
|
|
1664
1667
|
};
|
|
1665
1668
|
function ct(t) {
|
|
1666
|
-
return
|
|
1669
|
+
return En[t.value] || { left: null, right: null };
|
|
1667
1670
|
}
|
|
1668
1671
|
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 || {});
|
|
1669
|
-
function
|
|
1672
|
+
function Ae(t) {
|
|
1670
1673
|
var n;
|
|
1671
1674
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1672
1675
|
switch (e) {
|
|
@@ -1677,18 +1680,18 @@ function _e(t) {
|
|
|
1677
1680
|
case b.Project:
|
|
1678
1681
|
case b.Ref:
|
|
1679
1682
|
case b.TableGroup:
|
|
1680
|
-
return new
|
|
1683
|
+
return new S(e);
|
|
1681
1684
|
default:
|
|
1682
1685
|
return new v();
|
|
1683
1686
|
}
|
|
1684
1687
|
}
|
|
1685
1688
|
function he(t) {
|
|
1686
1689
|
if (!He(t))
|
|
1687
|
-
return new
|
|
1690
|
+
return new S([t]);
|
|
1688
1691
|
const e = he(t.leftExpression).unwrap_or(void 0);
|
|
1689
|
-
return e ? (e.push(t.rightExpression), new
|
|
1692
|
+
return e ? (e.push(t.rightExpression), new S(e)) : new v();
|
|
1690
1693
|
}
|
|
1691
|
-
function
|
|
1694
|
+
function C(t) {
|
|
1692
1695
|
if (t === void 0)
|
|
1693
1696
|
return new v();
|
|
1694
1697
|
const e = he(t).unwrap_or(void 0);
|
|
@@ -1696,14 +1699,14 @@ function j(t) {
|
|
|
1696
1699
|
return new v();
|
|
1697
1700
|
const n = [];
|
|
1698
1701
|
for (const s of e) {
|
|
1699
|
-
const i =
|
|
1702
|
+
const i = X(s).unwrap_or(void 0);
|
|
1700
1703
|
if (!i)
|
|
1701
1704
|
return new v();
|
|
1702
1705
|
n.push(i);
|
|
1703
1706
|
}
|
|
1704
|
-
return new
|
|
1707
|
+
return new S(n);
|
|
1705
1708
|
}
|
|
1706
|
-
function
|
|
1709
|
+
function ge(t) {
|
|
1707
1710
|
if (t === void 0)
|
|
1708
1711
|
return new v();
|
|
1709
1712
|
const e = he(t).unwrap_or(void 0);
|
|
@@ -1721,67 +1724,67 @@ function Le(t) {
|
|
|
1721
1724
|
return new v();
|
|
1722
1725
|
}
|
|
1723
1726
|
for (const i of e) {
|
|
1724
|
-
const r =
|
|
1727
|
+
const r = X(i).unwrap_or(void 0);
|
|
1725
1728
|
if (!r)
|
|
1726
1729
|
return new v();
|
|
1727
1730
|
n.push(r);
|
|
1728
1731
|
}
|
|
1729
|
-
return new
|
|
1732
|
+
return new S({
|
|
1730
1733
|
variables: n,
|
|
1731
1734
|
tupleElements: s
|
|
1732
1735
|
});
|
|
1733
1736
|
}
|
|
1734
|
-
function
|
|
1735
|
-
return M(t) ? new
|
|
1737
|
+
function X(t) {
|
|
1738
|
+
return M(t) ? new S(t.expression.variable.value) : new v();
|
|
1736
1739
|
}
|
|
1737
1740
|
function Ge(t) {
|
|
1738
1741
|
if (ut(t))
|
|
1739
|
-
return t instanceof te ? new
|
|
1742
|
+
return t instanceof te ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1740
1743
|
if (t instanceof Z && t.elementList.every(ut)) {
|
|
1741
1744
|
const e = t.elementList.filter(
|
|
1742
1745
|
(s) => s instanceof te
|
|
1743
1746
|
), n = t.elementList.filter(M);
|
|
1744
|
-
return new
|
|
1747
|
+
return new S({ functional: e, nonFunctional: n });
|
|
1745
1748
|
}
|
|
1746
1749
|
return new v();
|
|
1747
1750
|
}
|
|
1748
1751
|
function V(t) {
|
|
1749
1752
|
var n;
|
|
1750
1753
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1751
|
-
return e === void 0 ? new v() : new
|
|
1754
|
+
return e === void 0 ? new v() : new S(e);
|
|
1752
1755
|
}
|
|
1753
|
-
function
|
|
1754
|
-
return
|
|
1756
|
+
function Q(t) {
|
|
1757
|
+
return Y(t) ? t.expression instanceof j ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new v();
|
|
1755
1758
|
}
|
|
1756
|
-
function
|
|
1759
|
+
function Nn(t) {
|
|
1757
1760
|
var e;
|
|
1758
|
-
return !(t instanceof H) || !wt((e = t.op) == null ? void 0 : e.value) ? !1 :
|
|
1761
|
+
return !(t instanceof H) || !wt((e = t.op) == null ? void 0 : e.value) ? !1 : ge(t.leftExpression).and_then(() => ge(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1759
1762
|
}
|
|
1760
|
-
function
|
|
1761
|
-
const e =
|
|
1763
|
+
function mn(t) {
|
|
1764
|
+
const e = ge(t.leftExpression), n = ge(t.rightExpression);
|
|
1762
1765
|
if (!e.isOk() || !n.isOk())
|
|
1763
1766
|
return !1;
|
|
1764
1767
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1765
1768
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1766
1769
|
}
|
|
1767
1770
|
function ut(t) {
|
|
1768
|
-
return t instanceof D && t.expression instanceof
|
|
1771
|
+
return t instanceof D && t.expression instanceof j || t instanceof te;
|
|
1769
1772
|
}
|
|
1770
|
-
function
|
|
1773
|
+
function Tn(t, e) {
|
|
1771
1774
|
var i, r, a, l;
|
|
1772
1775
|
let n = e;
|
|
1773
|
-
const s =
|
|
1776
|
+
const s = zt(t);
|
|
1774
1777
|
for (; n; ) {
|
|
1775
1778
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1776
1779
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1777
|
-
if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof
|
|
1780
|
+
if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof G && s)
|
|
1778
1781
|
return n.symbol;
|
|
1779
|
-
if (n instanceof
|
|
1782
|
+
if (n instanceof G)
|
|
1780
1783
|
return;
|
|
1781
1784
|
n = n.parent;
|
|
1782
1785
|
}
|
|
1783
1786
|
}
|
|
1784
|
-
class
|
|
1787
|
+
class bn {
|
|
1785
1788
|
constructor(e, n, s) {
|
|
1786
1789
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1787
1790
|
}
|
|
@@ -1789,27 +1792,27 @@ class mn {
|
|
|
1789
1792
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1790
1793
|
}
|
|
1791
1794
|
validateContext() {
|
|
1792
|
-
return this.declarationNode.parent instanceof
|
|
1795
|
+
return this.declarationNode.parent instanceof G || Ae(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)] : [];
|
|
1793
1796
|
}
|
|
1794
1797
|
validateName(e) {
|
|
1795
|
-
return e ? [new
|
|
1798
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
1796
1799
|
}
|
|
1797
1800
|
validateAlias(e) {
|
|
1798
|
-
return e ? [new
|
|
1801
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
|
|
1799
1802
|
}
|
|
1800
1803
|
validateSettingList(e) {
|
|
1801
|
-
return e ? [new
|
|
1804
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
|
|
1802
1805
|
}
|
|
1803
1806
|
validateBody(e) {
|
|
1804
1807
|
if (!e)
|
|
1805
1808
|
return [];
|
|
1806
1809
|
if (e instanceof ne)
|
|
1807
|
-
return [new
|
|
1810
|
+
return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1808
1811
|
const n = [];
|
|
1809
|
-
return
|
|
1812
|
+
return Y(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;
|
|
1810
1813
|
}
|
|
1811
1814
|
}
|
|
1812
|
-
class
|
|
1815
|
+
class ve {
|
|
1813
1816
|
constructor() {
|
|
1814
1817
|
this.table = /* @__PURE__ */ new Map();
|
|
1815
1818
|
}
|
|
@@ -1826,7 +1829,7 @@ class Ae {
|
|
|
1826
1829
|
return this.table.entries();
|
|
1827
1830
|
}
|
|
1828
1831
|
}
|
|
1829
|
-
class
|
|
1832
|
+
class In {
|
|
1830
1833
|
constructor(e, n, s) {
|
|
1831
1834
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1832
1835
|
}
|
|
@@ -1834,55 +1837,55 @@ class Tn {
|
|
|
1834
1837
|
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)];
|
|
1835
1838
|
}
|
|
1836
1839
|
validateContext() {
|
|
1837
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
1840
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1838
1841
|
}
|
|
1839
1842
|
validateName(e) {
|
|
1840
|
-
return e ? Je(e) ? [] : [new
|
|
1843
|
+
return e ? Je(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)];
|
|
1841
1844
|
}
|
|
1842
1845
|
validateAlias(e) {
|
|
1843
|
-
return e ? [new
|
|
1846
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1844
1847
|
}
|
|
1845
1848
|
registerElement() {
|
|
1846
1849
|
const e = [];
|
|
1847
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1848
|
-
const { name: n } = this.declarationNode, s =
|
|
1850
|
+
this.declarationNode.symbol = this.symbolFactory.create(Jt, { declaration: this.declarationNode, symbolTable: new ve() });
|
|
1851
|
+
const { name: n } = this.declarationNode, s = C(n);
|
|
1849
1852
|
if (s.isOk()) {
|
|
1850
1853
|
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = je(r);
|
|
1851
|
-
a.has(l) && e.push(new
|
|
1854
|
+
a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
|
|
1852
1855
|
}
|
|
1853
1856
|
return e;
|
|
1854
1857
|
}
|
|
1855
1858
|
validateSettingList(e) {
|
|
1856
|
-
return e ? [new
|
|
1859
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
|
|
1857
1860
|
}
|
|
1858
1861
|
validateBody(e) {
|
|
1859
1862
|
if (!e)
|
|
1860
1863
|
return [];
|
|
1861
|
-
if (e instanceof
|
|
1864
|
+
if (e instanceof w)
|
|
1862
1865
|
return this.validateFields([e]);
|
|
1863
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1866
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
1864
1867
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1865
1868
|
}
|
|
1866
1869
|
validateFields(e) {
|
|
1867
|
-
return e.length === 0 ? [new
|
|
1870
|
+
return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1868
1871
|
const s = [];
|
|
1869
|
-
n.callee && !M(n.callee) && s.push(new
|
|
1872
|
+
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));
|
|
1870
1873
|
const i = [...n.args];
|
|
1871
|
-
return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new
|
|
1874
|
+
return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1872
1875
|
});
|
|
1873
1876
|
}
|
|
1874
1877
|
validateFieldSettings(e) {
|
|
1875
|
-
const n =
|
|
1878
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
1876
1879
|
for (const r in i) {
|
|
1877
1880
|
const a = i[r];
|
|
1878
1881
|
switch (r) {
|
|
1879
1882
|
case "note":
|
|
1880
|
-
a.length > 1 && a.forEach((l) => s.push(new
|
|
1881
|
-
|
|
1883
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
1884
|
+
Y(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
|
|
1882
1885
|
});
|
|
1883
1886
|
break;
|
|
1884
1887
|
default:
|
|
1885
|
-
a.forEach((l) => s.push(new
|
|
1888
|
+
a.forEach((l) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
|
|
1886
1889
|
}
|
|
1887
1890
|
}
|
|
1888
1891
|
return s;
|
|
@@ -1897,14 +1900,14 @@ class Tn {
|
|
|
1897
1900
|
}
|
|
1898
1901
|
registerField(e) {
|
|
1899
1902
|
if (e.callee && M(e.callee)) {
|
|
1900
|
-
const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(
|
|
1903
|
+
const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Zt, { declaration: e });
|
|
1901
1904
|
e.symbol = i;
|
|
1902
1905
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1903
1906
|
if (r.has(s)) {
|
|
1904
1907
|
const a = r.get(s);
|
|
1905
1908
|
return [
|
|
1906
|
-
new
|
|
1907
|
-
new
|
|
1909
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
|
|
1910
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
|
|
1908
1911
|
];
|
|
1909
1912
|
}
|
|
1910
1913
|
r.set(s, i);
|
|
@@ -1912,7 +1915,7 @@ class Tn {
|
|
|
1912
1915
|
return [];
|
|
1913
1916
|
}
|
|
1914
1917
|
}
|
|
1915
|
-
class
|
|
1918
|
+
class Ln {
|
|
1916
1919
|
constructor(e, n, s) {
|
|
1917
1920
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1918
1921
|
}
|
|
@@ -1920,23 +1923,23 @@ class bn {
|
|
|
1920
1923
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1921
1924
|
}
|
|
1922
1925
|
validateContext() {
|
|
1923
|
-
return this.declarationNode.parent instanceof
|
|
1926
|
+
return this.declarationNode.parent instanceof G || Ae(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)] : [];
|
|
1924
1927
|
}
|
|
1925
1928
|
validateName(e) {
|
|
1926
|
-
return e ? [new
|
|
1929
|
+
return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
1927
1930
|
}
|
|
1928
1931
|
validateAlias(e) {
|
|
1929
|
-
return e ? [new
|
|
1932
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
|
|
1930
1933
|
}
|
|
1931
1934
|
validateSettingList(e) {
|
|
1932
|
-
return e ? [new
|
|
1935
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
|
|
1933
1936
|
}
|
|
1934
1937
|
validateBody(e) {
|
|
1935
1938
|
if (!e)
|
|
1936
1939
|
return [];
|
|
1937
|
-
if (e instanceof
|
|
1938
|
-
return [new
|
|
1939
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
1940
|
+
if (e instanceof w)
|
|
1941
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1942
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
1940
1943
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1941
1944
|
}
|
|
1942
1945
|
validateFields(e) {
|
|
@@ -1946,35 +1949,35 @@ class bn {
|
|
|
1946
1949
|
const s = [], i = [n.callee, ...n.args];
|
|
1947
1950
|
return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1948
1951
|
for (; r instanceof J; )
|
|
1949
|
-
r.argumentList && !Ge(r.argumentList).isOk() && s.push(new
|
|
1950
|
-
Ge(r).isOk() || s.push(new
|
|
1952
|
+
r.argumentList && !Ge(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;
|
|
1953
|
+
Ge(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));
|
|
1951
1954
|
}), s;
|
|
1952
1955
|
});
|
|
1953
1956
|
}
|
|
1954
1957
|
validateFieldSetting(e) {
|
|
1955
|
-
const n =
|
|
1958
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
1956
1959
|
for (const r in i) {
|
|
1957
1960
|
const a = i[r];
|
|
1958
1961
|
switch (r) {
|
|
1959
1962
|
case "note":
|
|
1960
1963
|
case "name":
|
|
1961
|
-
a.length > 1 && a.forEach((l) => s.push(new
|
|
1962
|
-
|
|
1964
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1965
|
+
Y(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
|
|
1963
1966
|
});
|
|
1964
1967
|
break;
|
|
1965
1968
|
case "unique":
|
|
1966
1969
|
case "pk":
|
|
1967
|
-
a.length > 1 && a.forEach((l) => s.push(new
|
|
1968
|
-
le(l.value) || s.push(new
|
|
1970
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1971
|
+
le(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
|
|
1969
1972
|
});
|
|
1970
1973
|
break;
|
|
1971
1974
|
case "type":
|
|
1972
|
-
a.length > 1 && a.forEach((l) => s.push(new
|
|
1973
|
-
M(l.value) || s.push(new
|
|
1975
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
|
|
1976
|
+
M(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
|
|
1974
1977
|
});
|
|
1975
1978
|
break;
|
|
1976
1979
|
default:
|
|
1977
|
-
a.forEach((l) => s.push(new
|
|
1980
|
+
a.forEach((l) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
|
|
1978
1981
|
}
|
|
1979
1982
|
}
|
|
1980
1983
|
return s;
|
|
@@ -1988,7 +1991,7 @@ class bn {
|
|
|
1988
1991
|
});
|
|
1989
1992
|
}
|
|
1990
1993
|
}
|
|
1991
|
-
class
|
|
1994
|
+
class gn {
|
|
1992
1995
|
constructor(e, n, s) {
|
|
1993
1996
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1994
1997
|
}
|
|
@@ -1996,28 +1999,36 @@ class In {
|
|
|
1996
1999
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1997
2000
|
}
|
|
1998
2001
|
validateContext() {
|
|
1999
|
-
return this.declarationNode.parent instanceof
|
|
2002
|
+
return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(Ae(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)] : [];
|
|
2000
2003
|
}
|
|
2001
2004
|
validateName(e) {
|
|
2002
|
-
|
|
2005
|
+
if (!(this.declarationNode.parent instanceof G))
|
|
2006
|
+
return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2007
|
+
if (!e)
|
|
2008
|
+
return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2009
|
+
const n = C(e);
|
|
2010
|
+
if (!n.isOk())
|
|
2011
|
+
return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2012
|
+
const i = n.unwrap().join("."), r = Yt(i);
|
|
2013
|
+
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), []);
|
|
2003
2014
|
}
|
|
2004
2015
|
validateAlias(e) {
|
|
2005
|
-
return e ? [new
|
|
2016
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2006
2017
|
}
|
|
2007
2018
|
validateSettingList(e) {
|
|
2008
|
-
return e ? [new
|
|
2019
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
|
|
2009
2020
|
}
|
|
2010
2021
|
validateBody(e) {
|
|
2011
2022
|
if (!e)
|
|
2012
2023
|
return [];
|
|
2013
|
-
if (e instanceof
|
|
2024
|
+
if (e instanceof w)
|
|
2014
2025
|
return this.validateFields([e]);
|
|
2015
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2026
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2016
2027
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2017
2028
|
}
|
|
2018
2029
|
validateFields(e) {
|
|
2019
2030
|
const n = [];
|
|
2020
|
-
return e.length === 0 ? [new
|
|
2031
|
+
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))), Y(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);
|
|
2021
2032
|
}
|
|
2022
2033
|
validateSubElements(e) {
|
|
2023
2034
|
return e.flatMap((n) => {
|
|
@@ -2028,7 +2039,7 @@ class In {
|
|
|
2028
2039
|
});
|
|
2029
2040
|
}
|
|
2030
2041
|
}
|
|
2031
|
-
class
|
|
2042
|
+
class _n {
|
|
2032
2043
|
constructor(e, n, s) {
|
|
2033
2044
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2034
2045
|
}
|
|
@@ -2036,25 +2047,25 @@ class Ln {
|
|
|
2036
2047
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2037
2048
|
}
|
|
2038
2049
|
validateContext() {
|
|
2039
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2050
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2040
2051
|
}
|
|
2041
2052
|
validateName(e) {
|
|
2042
|
-
return e ? Pe(e) ? [] : [new
|
|
2053
|
+
return e ? Pe(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2043
2054
|
}
|
|
2044
2055
|
validateAlias(e) {
|
|
2045
|
-
return e ? [new
|
|
2056
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
2046
2057
|
}
|
|
2047
2058
|
validateSettingList(e) {
|
|
2048
|
-
return e ? [new
|
|
2059
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
|
|
2049
2060
|
}
|
|
2050
2061
|
validateBody(e) {
|
|
2051
2062
|
if (!e)
|
|
2052
2063
|
return [];
|
|
2053
|
-
if (e instanceof
|
|
2054
|
-
return [new
|
|
2055
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2064
|
+
if (e instanceof w)
|
|
2065
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2066
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2056
2067
|
return [
|
|
2057
|
-
...n.map((i) => new
|
|
2068
|
+
...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2058
2069
|
...this.validateSubElements(s)
|
|
2059
2070
|
];
|
|
2060
2071
|
}
|
|
@@ -2067,7 +2078,7 @@ class Ln {
|
|
|
2067
2078
|
});
|
|
2068
2079
|
}
|
|
2069
2080
|
}
|
|
2070
|
-
class
|
|
2081
|
+
class An {
|
|
2071
2082
|
constructor(e, n, s) {
|
|
2072
2083
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2073
2084
|
}
|
|
@@ -2075,48 +2086,48 @@ class gn {
|
|
|
2075
2086
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2076
2087
|
}
|
|
2077
2088
|
validateContext() {
|
|
2078
|
-
return this.declarationNode.parent instanceof
|
|
2089
|
+
return this.declarationNode.parent instanceof G ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2079
2090
|
}
|
|
2080
2091
|
validateName(e) {
|
|
2081
|
-
return e ? Pe(e) ? [] : [new
|
|
2092
|
+
return e ? Pe(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2082
2093
|
}
|
|
2083
2094
|
validateAlias(e) {
|
|
2084
|
-
return e ? [new
|
|
2095
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2085
2096
|
}
|
|
2086
2097
|
validateSettingList(e) {
|
|
2087
|
-
return e ? [new
|
|
2098
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
|
|
2088
2099
|
}
|
|
2089
2100
|
validateBody(e) {
|
|
2090
2101
|
if (!e)
|
|
2091
2102
|
return [];
|
|
2092
|
-
if (e instanceof
|
|
2103
|
+
if (e instanceof w)
|
|
2093
2104
|
return this.validateFields([e]);
|
|
2094
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2105
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2095
2106
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2096
2107
|
}
|
|
2097
2108
|
validateFields(e) {
|
|
2098
2109
|
if (e.length === 0)
|
|
2099
|
-
return [new
|
|
2110
|
+
return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2100
2111
|
const n = [];
|
|
2101
|
-
return e.length > 1 && n.push(...e.slice(1).map((s) => new
|
|
2102
|
-
s.callee && !
|
|
2112
|
+
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) => {
|
|
2113
|
+
s.callee && !Nn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !mn(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2103
2114
|
const i = [...s.args];
|
|
2104
|
-
I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new
|
|
2115
|
+
I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2105
2116
|
}), n;
|
|
2106
2117
|
}
|
|
2107
2118
|
validateFieldSettings(e) {
|
|
2108
|
-
const n =
|
|
2119
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
2109
2120
|
for (const r in i) {
|
|
2110
2121
|
const a = i[r];
|
|
2111
2122
|
switch (r) {
|
|
2112
2123
|
case "delete":
|
|
2113
2124
|
case "update":
|
|
2114
|
-
a.length > 1 && a.forEach((l) => s.push(new
|
|
2115
|
-
|
|
2125
|
+
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
2126
|
+
vn(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
|
|
2116
2127
|
});
|
|
2117
2128
|
break;
|
|
2118
2129
|
default:
|
|
2119
|
-
a.forEach((l) => s.push(new
|
|
2130
|
+
a.forEach((l) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
|
|
2120
2131
|
}
|
|
2121
2132
|
}
|
|
2122
2133
|
return s;
|
|
@@ -2130,11 +2141,11 @@ class gn {
|
|
|
2130
2141
|
});
|
|
2131
2142
|
}
|
|
2132
2143
|
}
|
|
2133
|
-
function
|
|
2134
|
-
if (!(M(t) && t.expression.variable.kind !==
|
|
2144
|
+
function vn(t) {
|
|
2145
|
+
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
|
|
2135
2146
|
return !1;
|
|
2136
2147
|
let e;
|
|
2137
|
-
if (t instanceof
|
|
2148
|
+
if (t instanceof $ ? e = Ne(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2138
2149
|
switch (e.toLowerCase()) {
|
|
2139
2150
|
case "cascade":
|
|
2140
2151
|
case "no action":
|
|
@@ -2147,7 +2158,7 @@ function _n(t) {
|
|
|
2147
2158
|
}
|
|
2148
2159
|
return !1;
|
|
2149
2160
|
}
|
|
2150
|
-
class
|
|
2161
|
+
class wn {
|
|
2151
2162
|
constructor(e, n, s) {
|
|
2152
2163
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2153
2164
|
}
|
|
@@ -2155,77 +2166,77 @@ class An {
|
|
|
2155
2166
|
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)];
|
|
2156
2167
|
}
|
|
2157
2168
|
validateContext() {
|
|
2158
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2169
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2159
2170
|
}
|
|
2160
2171
|
validateName(e) {
|
|
2161
|
-
return e ? e instanceof ce ? [new
|
|
2172
|
+
return e ? e instanceof ce ? [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)] : Je(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)];
|
|
2162
2173
|
}
|
|
2163
2174
|
validateAlias(e) {
|
|
2164
|
-
return e ?
|
|
2175
|
+
return e ? Sn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2165
2176
|
}
|
|
2166
2177
|
validateSettingList(e) {
|
|
2167
|
-
const n =
|
|
2178
|
+
const n = W(e), s = n.getErrors(), i = n.getValue();
|
|
2168
2179
|
for (const r in i) {
|
|
2169
2180
|
const a = i[r];
|
|
2170
2181
|
switch (r) {
|
|
2171
2182
|
case "headercolor":
|
|
2172
|
-
a.length > 1 && s.push(...a.map((l) => new
|
|
2173
|
-
|
|
2183
|
+
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
|
|
2184
|
+
On(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
|
|
2174
2185
|
});
|
|
2175
2186
|
break;
|
|
2176
2187
|
case "note":
|
|
2177
|
-
a.length > 1 && s.push(...a.map((l) => new
|
|
2178
|
-
|
|
2188
|
+
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
2189
|
+
Y(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
|
|
2179
2190
|
});
|
|
2180
2191
|
break;
|
|
2181
2192
|
default:
|
|
2182
|
-
s.push(...a.map((l) => new
|
|
2193
|
+
s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
|
|
2183
2194
|
}
|
|
2184
2195
|
}
|
|
2185
2196
|
return s;
|
|
2186
2197
|
}
|
|
2187
2198
|
registerElement() {
|
|
2188
2199
|
const e = [];
|
|
2189
|
-
this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new
|
|
2190
|
-
const { name: n, alias: s } = this.declarationNode, i =
|
|
2200
|
+
this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new ve() });
|
|
2201
|
+
const { name: n, alias: s } = this.declarationNode, i = C(n);
|
|
2191
2202
|
if (i.isOk()) {
|
|
2192
2203
|
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
|
|
2193
|
-
l.has(p) && e.push(new
|
|
2204
|
+
l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
|
|
2194
2205
|
}
|
|
2195
|
-
if (s && Pe(s) && !
|
|
2206
|
+
if (s && Pe(s) && !kn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2196
2207
|
const r = V(s).unwrap(), a = xe(r);
|
|
2197
|
-
this.publicSymbolTable.has(a) && e.push(new
|
|
2208
|
+
this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2198
2209
|
}
|
|
2199
2210
|
return e;
|
|
2200
2211
|
}
|
|
2201
2212
|
validateBody(e) {
|
|
2202
2213
|
if (!e)
|
|
2203
2214
|
return [];
|
|
2204
|
-
if (e instanceof
|
|
2205
|
-
return [new
|
|
2206
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2215
|
+
if (e instanceof w)
|
|
2216
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2217
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2207
2218
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2208
2219
|
}
|
|
2209
2220
|
validateFields(e) {
|
|
2210
|
-
return e.length === 0 ? [new
|
|
2221
|
+
return e.length === 0 ? [new c(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
|
|
2211
2222
|
if (!n.callee)
|
|
2212
2223
|
return [];
|
|
2213
2224
|
const s = [];
|
|
2214
|
-
n.args.length === 0 && s.push(new
|
|
2225
|
+
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] && !yn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2215
2226
|
const i = n.args.slice(1);
|
|
2216
2227
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2217
2228
|
});
|
|
2218
2229
|
}
|
|
2219
2230
|
registerField(e) {
|
|
2220
2231
|
if (e.callee && M(e.callee)) {
|
|
2221
|
-
const n = V(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(
|
|
2232
|
+
const n = V(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Kt, { declaration: e });
|
|
2222
2233
|
e.symbol = i;
|
|
2223
2234
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2224
2235
|
if (r.has(s)) {
|
|
2225
2236
|
const a = r.get(s);
|
|
2226
2237
|
return [
|
|
2227
|
-
new
|
|
2228
|
-
new
|
|
2238
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
|
|
2239
|
+
new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
|
|
2229
2240
|
];
|
|
2230
2241
|
}
|
|
2231
2242
|
r.set(s, i);
|
|
@@ -2235,74 +2246,74 @@ class An {
|
|
|
2235
2246
|
// This is needed to support legacy inline settings
|
|
2236
2247
|
validateFieldSetting(e) {
|
|
2237
2248
|
if (!e.slice(0, -1).every(Ee) || !e.slice(-1).every((p) => Ee(p) || p instanceof P))
|
|
2238
|
-
return [...e.map((p) => new
|
|
2249
|
+
return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2239
2250
|
if (e.length === 0)
|
|
2240
2251
|
return [];
|
|
2241
2252
|
let n;
|
|
2242
2253
|
I.last(e) instanceof P && (n = e.pop());
|
|
2243
|
-
const s =
|
|
2254
|
+
const s = W(n), i = s.getErrors(), r = s.getValue();
|
|
2244
2255
|
for (const p of e) {
|
|
2245
2256
|
const h = V(p).unwrap_or("").toLowerCase();
|
|
2246
2257
|
if (h !== "pk" && h !== "unique") {
|
|
2247
|
-
i.push(new
|
|
2258
|
+
i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2248
2259
|
continue;
|
|
2249
2260
|
}
|
|
2250
2261
|
r[h] === void 0 ? r[h] = [p] : r[h].push(p);
|
|
2251
2262
|
}
|
|
2252
2263
|
const a = r.pk || [], l = r["primary key"] || [];
|
|
2253
|
-
a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new
|
|
2264
|
+
a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new c(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
|
|
2254
2265
|
for (const p in r) {
|
|
2255
2266
|
const h = r[p];
|
|
2256
2267
|
switch (p) {
|
|
2257
2268
|
case "note":
|
|
2258
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2259
|
-
|
|
2269
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2270
|
+
Y(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2260
2271
|
});
|
|
2261
2272
|
break;
|
|
2262
2273
|
case "ref":
|
|
2263
2274
|
h.forEach((f) => {
|
|
2264
|
-
|
|
2275
|
+
Dn(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
|
|
2265
2276
|
});
|
|
2266
2277
|
break;
|
|
2267
2278
|
case "primary key":
|
|
2268
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2269
|
-
le(f.value) || i.push(new
|
|
2279
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
|
|
2280
|
+
le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
|
|
2270
2281
|
});
|
|
2271
2282
|
break;
|
|
2272
2283
|
case "pk":
|
|
2273
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2274
|
-
f instanceof se && !le(f.value) && i.push(new
|
|
2284
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
|
|
2285
|
+
f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
|
|
2275
2286
|
});
|
|
2276
2287
|
break;
|
|
2277
2288
|
case "not null":
|
|
2278
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2289
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
|
|
2279
2290
|
const T = r.null || [];
|
|
2280
|
-
h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new
|
|
2281
|
-
le(f.value) || i.push(new
|
|
2291
|
+
h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new c(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
|
|
2292
|
+
le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
|
|
2282
2293
|
});
|
|
2283
2294
|
break;
|
|
2284
2295
|
case "null":
|
|
2285
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2286
|
-
le(f.value) || i.push(new
|
|
2296
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
|
|
2297
|
+
le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
|
|
2287
2298
|
});
|
|
2288
2299
|
break;
|
|
2289
2300
|
case "unique":
|
|
2290
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2291
|
-
f instanceof se && !le(f.value) && i.push(new
|
|
2301
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
|
|
2302
|
+
f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
|
|
2292
2303
|
});
|
|
2293
2304
|
break;
|
|
2294
2305
|
case "increment":
|
|
2295
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2296
|
-
f instanceof se && !le(f.value) && i.push(new
|
|
2306
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
|
|
2307
|
+
f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
|
|
2297
2308
|
});
|
|
2298
2309
|
break;
|
|
2299
2310
|
case "default":
|
|
2300
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2301
|
-
|
|
2311
|
+
h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
|
|
2312
|
+
Rn(f.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
|
|
2302
2313
|
});
|
|
2303
2314
|
break;
|
|
2304
2315
|
default:
|
|
2305
|
-
h.forEach((f) => i.push(new
|
|
2316
|
+
h.forEach((f) => i.push(new c(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
|
|
2306
2317
|
}
|
|
2307
2318
|
}
|
|
2308
2319
|
return i;
|
|
@@ -2317,14 +2328,14 @@ class An {
|
|
|
2317
2328
|
var r;
|
|
2318
2329
|
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2319
2330
|
});
|
|
2320
|
-
return s.length > 1 && (n.push(...s.map((i) => new
|
|
2331
|
+
return s.length > 1 && (n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
|
|
2321
2332
|
}
|
|
2322
2333
|
}
|
|
2323
|
-
function
|
|
2334
|
+
function yn(t) {
|
|
2324
2335
|
if (!(t instanceof J || He(t) || t instanceof D || t instanceof ce))
|
|
2325
2336
|
return !1;
|
|
2326
2337
|
if (t instanceof J) {
|
|
2327
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) ||
|
|
2338
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || Y(n) || Ee(n)))
|
|
2328
2339
|
return !1;
|
|
2329
2340
|
t = t.callee;
|
|
2330
2341
|
}
|
|
@@ -2333,13 +2344,13 @@ function vn(t) {
|
|
|
2333
2344
|
return !1;
|
|
2334
2345
|
t = t.array;
|
|
2335
2346
|
}
|
|
2336
|
-
const e =
|
|
2347
|
+
const e = C(t).unwrap_or(void 0);
|
|
2337
2348
|
return e !== void 0 && e.length > 0;
|
|
2338
2349
|
}
|
|
2339
|
-
function
|
|
2350
|
+
function kn(t, e) {
|
|
2340
2351
|
return e.length === 1 && t === e[0];
|
|
2341
2352
|
}
|
|
2342
|
-
class
|
|
2353
|
+
class xn {
|
|
2343
2354
|
constructor(e, n, s) {
|
|
2344
2355
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2345
2356
|
}
|
|
@@ -2347,41 +2358,41 @@ class yn {
|
|
|
2347
2358
|
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)];
|
|
2348
2359
|
}
|
|
2349
2360
|
validateContext() {
|
|
2350
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2361
|
+
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
2351
2362
|
}
|
|
2352
2363
|
validateName(e) {
|
|
2353
|
-
return e ? Je(e) ? [] : [new
|
|
2364
|
+
return e ? Je(e) ? [] : [new c(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new c(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
2354
2365
|
}
|
|
2355
2366
|
validateAlias(e) {
|
|
2356
|
-
return e ? [new
|
|
2367
|
+
return e ? [new c(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
|
|
2357
2368
|
}
|
|
2358
2369
|
registerElement() {
|
|
2359
2370
|
const { name: e } = this.declarationNode;
|
|
2360
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2361
|
-
const n =
|
|
2371
|
+
this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new ve() });
|
|
2372
|
+
const n = C(e);
|
|
2362
2373
|
if (n.isOk()) {
|
|
2363
2374
|
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
|
|
2364
2375
|
if (r.has(a))
|
|
2365
|
-
return [new
|
|
2376
|
+
return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
|
|
2366
2377
|
r.set(a, this.declarationNode.symbol);
|
|
2367
2378
|
}
|
|
2368
2379
|
return [];
|
|
2369
2380
|
}
|
|
2370
2381
|
validateSettingList(e) {
|
|
2371
|
-
return e ? [new
|
|
2382
|
+
return e ? [new c(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
|
|
2372
2383
|
}
|
|
2373
2384
|
validateBody(e) {
|
|
2374
2385
|
if (!e)
|
|
2375
2386
|
return [];
|
|
2376
|
-
if (e instanceof
|
|
2377
|
-
return [new
|
|
2378
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2387
|
+
if (e instanceof w)
|
|
2388
|
+
return [new c(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2389
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2379
2390
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2380
2391
|
}
|
|
2381
2392
|
validateFields(e) {
|
|
2382
2393
|
return e.flatMap((n) => {
|
|
2383
2394
|
const s = [];
|
|
2384
|
-
return n.callee && !
|
|
2395
|
+
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;
|
|
2385
2396
|
});
|
|
2386
2397
|
}
|
|
2387
2398
|
validateSubElements(e) {
|
|
@@ -2394,14 +2405,14 @@ class yn {
|
|
|
2394
2405
|
}
|
|
2395
2406
|
registerField(e) {
|
|
2396
2407
|
if (e.callee && M(e.callee)) {
|
|
2397
|
-
const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(
|
|
2408
|
+
const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
|
|
2398
2409
|
e.symbol = i;
|
|
2399
2410
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2400
2411
|
if (r.has(s)) {
|
|
2401
2412
|
const a = r.get(s);
|
|
2402
2413
|
return [
|
|
2403
|
-
new
|
|
2404
|
-
new
|
|
2414
|
+
new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
|
|
2415
|
+
new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
|
|
2405
2416
|
];
|
|
2406
2417
|
}
|
|
2407
2418
|
r.set(s, i);
|
|
@@ -2413,31 +2424,31 @@ const vt = ["-", "+"];
|
|
|
2413
2424
|
function re(t) {
|
|
2414
2425
|
switch (t.type.value.toLowerCase()) {
|
|
2415
2426
|
case b.Enum:
|
|
2416
|
-
return
|
|
2427
|
+
return In;
|
|
2417
2428
|
case b.Table:
|
|
2418
|
-
return
|
|
2429
|
+
return wn;
|
|
2419
2430
|
case b.TableGroup:
|
|
2420
|
-
return
|
|
2431
|
+
return xn;
|
|
2421
2432
|
case b.Project:
|
|
2422
|
-
return
|
|
2433
|
+
return _n;
|
|
2423
2434
|
case b.Ref:
|
|
2424
|
-
return
|
|
2435
|
+
return An;
|
|
2425
2436
|
case b.Note:
|
|
2426
|
-
return
|
|
2437
|
+
return gn;
|
|
2427
2438
|
case b.Indexes:
|
|
2428
|
-
return
|
|
2439
|
+
return Ln;
|
|
2429
2440
|
default:
|
|
2430
|
-
return
|
|
2441
|
+
return bn;
|
|
2431
2442
|
}
|
|
2432
2443
|
}
|
|
2433
2444
|
function Je(t) {
|
|
2434
|
-
return !!
|
|
2445
|
+
return !!C(t).unwrap_or(!1);
|
|
2435
2446
|
}
|
|
2436
|
-
function
|
|
2447
|
+
function Sn(t) {
|
|
2437
2448
|
return Pe(t);
|
|
2438
2449
|
}
|
|
2439
2450
|
function Pe(t) {
|
|
2440
|
-
return t instanceof D && t.expression instanceof
|
|
2451
|
+
return t instanceof D && t.expression instanceof j;
|
|
2441
2452
|
}
|
|
2442
2453
|
function Ze(t, e, n) {
|
|
2443
2454
|
var i;
|
|
@@ -2450,7 +2461,7 @@ function Ze(t, e, n) {
|
|
|
2450
2461
|
if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
|
|
2451
2462
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2452
2463
|
} else {
|
|
2453
|
-
a = new
|
|
2464
|
+
a = new ve();
|
|
2454
2465
|
const p = n.create(gt, { symbolTable: a });
|
|
2455
2466
|
s.set(l, p);
|
|
2456
2467
|
}
|
|
@@ -2461,40 +2472,40 @@ function Ze(t, e, n) {
|
|
|
2461
2472
|
function wt(t) {
|
|
2462
2473
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2463
2474
|
}
|
|
2464
|
-
function
|
|
2475
|
+
function On(t) {
|
|
2465
2476
|
var n;
|
|
2466
|
-
if (!(t instanceof D) || !(t.expression instanceof me) || ((n = t.expression.literal) == null ? void 0 : n.kind) !==
|
|
2477
|
+
if (!(t instanceof D) || !(t.expression instanceof me) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2467
2478
|
return !1;
|
|
2468
2479
|
const e = t.expression.literal.value;
|
|
2469
2480
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2470
2481
|
return !1;
|
|
2471
2482
|
for (let s = 1; s < e.length; s += 1)
|
|
2472
|
-
if (!
|
|
2483
|
+
if (!qt(e[s]))
|
|
2473
2484
|
return !1;
|
|
2474
2485
|
return !0;
|
|
2475
2486
|
}
|
|
2476
2487
|
function le(t) {
|
|
2477
2488
|
return t === void 0;
|
|
2478
2489
|
}
|
|
2479
|
-
function
|
|
2490
|
+
function Rn(t) {
|
|
2480
2491
|
var e;
|
|
2481
|
-
return !!(
|
|
2492
|
+
return !!(Y(t) || ue(t) || Ee(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && vt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression) || t instanceof te);
|
|
2482
2493
|
}
|
|
2483
2494
|
function ue(t) {
|
|
2484
2495
|
var e;
|
|
2485
|
-
return t instanceof D && t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) ===
|
|
2496
|
+
return t instanceof D && t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
|
|
2486
2497
|
}
|
|
2487
|
-
function
|
|
2498
|
+
function Dn(t) {
|
|
2488
2499
|
var n;
|
|
2489
2500
|
if (!(t instanceof q) || !wt((n = t.op) == null ? void 0 : n.value))
|
|
2490
2501
|
return !1;
|
|
2491
|
-
const e =
|
|
2502
|
+
const e = C(t.expression).unwrap_or(void 0);
|
|
2492
2503
|
return e !== void 0 && e.length > 0;
|
|
2493
2504
|
}
|
|
2494
2505
|
function yt(t) {
|
|
2495
2506
|
return t instanceof Z && t.elementList.every(M);
|
|
2496
2507
|
}
|
|
2497
|
-
function
|
|
2508
|
+
function W(t) {
|
|
2498
2509
|
var s;
|
|
2499
2510
|
const e = {}, n = [];
|
|
2500
2511
|
if (!t)
|
|
@@ -2503,7 +2514,7 @@ function Q(t) {
|
|
|
2503
2514
|
if (!i.name)
|
|
2504
2515
|
continue;
|
|
2505
2516
|
if (i.name instanceof D) {
|
|
2506
|
-
n.push(new
|
|
2517
|
+
n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2507
2518
|
continue;
|
|
2508
2519
|
}
|
|
2509
2520
|
const r = (s = Ne(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
@@ -2514,7 +2525,7 @@ function Q(t) {
|
|
|
2514
2525
|
class ht {
|
|
2515
2526
|
constructor(e, n) {
|
|
2516
2527
|
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(gt, {
|
|
2517
|
-
symbolTable: new
|
|
2528
|
+
symbolTable: new ve()
|
|
2518
2529
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2519
2530
|
}
|
|
2520
2531
|
validate() {
|
|
@@ -2529,8 +2540,8 @@ class ht {
|
|
|
2529
2540
|
);
|
|
2530
2541
|
e.push(...r.validate());
|
|
2531
2542
|
});
|
|
2532
|
-
const n = this.ast.body.filter((s) =>
|
|
2533
|
-
return n.length > 1 && n.forEach((s) => e.push(new
|
|
2543
|
+
const n = this.ast.body.filter((s) => Ae(s).unwrap_or(void 0) === b.Project);
|
|
2544
|
+
return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
|
|
2534
2545
|
}
|
|
2535
2546
|
}
|
|
2536
2547
|
class ae {
|
|
@@ -2581,7 +2592,7 @@ class ae {
|
|
|
2581
2592
|
var s, i;
|
|
2582
2593
|
if (e)
|
|
2583
2594
|
if (e instanceof D) {
|
|
2584
|
-
if (e.expression instanceof
|
|
2595
|
+
if (e.expression instanceof j && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2585
2596
|
return;
|
|
2586
2597
|
this.bindFragments([e], n);
|
|
2587
2598
|
} else
|
|
@@ -2635,7 +2646,7 @@ class ae {
|
|
|
2635
2646
|
resolveIndexStack(e, n) {
|
|
2636
2647
|
if (e.length === 0)
|
|
2637
2648
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
2638
|
-
const [s, ...i] = e, r =
|
|
2649
|
+
const [s, ...i] = e, r = Tn(s.index, this.declarationNode);
|
|
2639
2650
|
if (r === void 0) {
|
|
2640
2651
|
const { kind: h, name: T } = ie(s.index).unwrap();
|
|
2641
2652
|
this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
|
|
@@ -2659,10 +2670,10 @@ class ae {
|
|
|
2659
2670
|
}
|
|
2660
2671
|
}
|
|
2661
2672
|
logError(e, n, s) {
|
|
2662
|
-
s || this.errors.push(new
|
|
2673
|
+
s || this.errors.push(new c(o.BINDING_ERROR, n, e));
|
|
2663
2674
|
}
|
|
2664
2675
|
}
|
|
2665
|
-
class
|
|
2676
|
+
class Pn extends ae {
|
|
2666
2677
|
constructor() {
|
|
2667
2678
|
super(...arguments), this.subfield = {
|
|
2668
2679
|
arg: {
|
|
@@ -2672,7 +2683,7 @@ class Rn extends ae {
|
|
|
2672
2683
|
}, this.settingList = {};
|
|
2673
2684
|
}
|
|
2674
2685
|
}
|
|
2675
|
-
class
|
|
2686
|
+
class Un extends ae {
|
|
2676
2687
|
constructor() {
|
|
2677
2688
|
super(...arguments), this.subfield = {
|
|
2678
2689
|
arg: {
|
|
@@ -2682,7 +2693,7 @@ class Dn extends ae {
|
|
|
2682
2693
|
}, this.settingList = {};
|
|
2683
2694
|
}
|
|
2684
2695
|
}
|
|
2685
|
-
class
|
|
2696
|
+
class Mn extends ae {
|
|
2686
2697
|
constructor() {
|
|
2687
2698
|
super(...arguments), this.subfield = {
|
|
2688
2699
|
arg: {
|
|
@@ -2717,7 +2728,7 @@ class Pn extends ae {
|
|
|
2717
2728
|
}, this.settingList = {};
|
|
2718
2729
|
}
|
|
2719
2730
|
}
|
|
2720
|
-
class
|
|
2731
|
+
class Fn extends ae {
|
|
2721
2732
|
constructor() {
|
|
2722
2733
|
super(...arguments), this.subfield = {
|
|
2723
2734
|
arg: {
|
|
@@ -2727,7 +2738,7 @@ class Un extends ae {
|
|
|
2727
2738
|
}, this.settingList = {};
|
|
2728
2739
|
}
|
|
2729
2740
|
}
|
|
2730
|
-
class
|
|
2741
|
+
class Bn extends ae {
|
|
2731
2742
|
constructor() {
|
|
2732
2743
|
super(...arguments), this.subfield = {
|
|
2733
2744
|
arg: {
|
|
@@ -2737,7 +2748,7 @@ class Mn extends ae {
|
|
|
2737
2748
|
}, this.settingList = {};
|
|
2738
2749
|
}
|
|
2739
2750
|
}
|
|
2740
|
-
class
|
|
2751
|
+
class Vn extends ae {
|
|
2741
2752
|
constructor() {
|
|
2742
2753
|
super(...arguments), this.subfield = {
|
|
2743
2754
|
arg: {
|
|
@@ -2754,7 +2765,7 @@ class Fn extends ae {
|
|
|
2754
2765
|
}, this.settingList = {};
|
|
2755
2766
|
}
|
|
2756
2767
|
}
|
|
2757
|
-
class
|
|
2768
|
+
class Gn extends ae {
|
|
2758
2769
|
constructor() {
|
|
2759
2770
|
super(...arguments), this.subfield = {
|
|
2760
2771
|
arg: {
|
|
@@ -2782,7 +2793,7 @@ class Bn extends ae {
|
|
|
2782
2793
|
}, this.settingList = {};
|
|
2783
2794
|
}
|
|
2784
2795
|
}
|
|
2785
|
-
class
|
|
2796
|
+
class Cn extends ae {
|
|
2786
2797
|
constructor() {
|
|
2787
2798
|
super(...arguments), this.subfield = {
|
|
2788
2799
|
arg: {
|
|
@@ -2802,24 +2813,24 @@ class Vn extends ae {
|
|
|
2802
2813
|
function kt(t) {
|
|
2803
2814
|
switch (t.type.value.toLowerCase()) {
|
|
2804
2815
|
case b.Enum:
|
|
2805
|
-
return
|
|
2816
|
+
return Un;
|
|
2806
2817
|
case b.Table:
|
|
2807
|
-
return
|
|
2818
|
+
return Gn;
|
|
2808
2819
|
case b.TableGroup:
|
|
2809
|
-
return
|
|
2820
|
+
return Cn;
|
|
2810
2821
|
case b.Project:
|
|
2811
|
-
return
|
|
2822
|
+
return Bn;
|
|
2812
2823
|
case b.Ref:
|
|
2813
|
-
return
|
|
2824
|
+
return Vn;
|
|
2814
2825
|
case b.Note:
|
|
2815
|
-
return
|
|
2826
|
+
return Fn;
|
|
2816
2827
|
case b.Indexes:
|
|
2817
|
-
return
|
|
2828
|
+
return Mn;
|
|
2818
2829
|
default:
|
|
2819
|
-
return
|
|
2830
|
+
return Pn;
|
|
2820
2831
|
}
|
|
2821
2832
|
}
|
|
2822
|
-
class
|
|
2833
|
+
class Xn {
|
|
2823
2834
|
constructor(e) {
|
|
2824
2835
|
this.ast = e, this.errors = [];
|
|
2825
2836
|
}
|
|
@@ -2832,7 +2843,7 @@ class Gn {
|
|
|
2832
2843
|
return new F(this.ast, this.errors);
|
|
2833
2844
|
}
|
|
2834
2845
|
}
|
|
2835
|
-
class
|
|
2846
|
+
class $n {
|
|
2836
2847
|
constructor(e) {
|
|
2837
2848
|
this.generator = e;
|
|
2838
2849
|
}
|
|
@@ -2840,13 +2851,13 @@ class Cn {
|
|
|
2840
2851
|
return new e(n, this.generator.nextId());
|
|
2841
2852
|
}
|
|
2842
2853
|
}
|
|
2843
|
-
class
|
|
2854
|
+
class Wn {
|
|
2844
2855
|
constructor(e, n) {
|
|
2845
|
-
this.ast = e, this.symbolFactory = new
|
|
2856
|
+
this.ast = e, this.symbolFactory = new $n(n);
|
|
2846
2857
|
}
|
|
2847
2858
|
// Analyzing: Invoking both the validator and binder
|
|
2848
2859
|
analyze() {
|
|
2849
|
-
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2860
|
+
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new Xn(n).resolve());
|
|
2850
2861
|
}
|
|
2851
2862
|
// For invoking the validator only
|
|
2852
2863
|
validate() {
|
|
@@ -2854,7 +2865,7 @@ class Xn {
|
|
|
2854
2865
|
}
|
|
2855
2866
|
}
|
|
2856
2867
|
function ft(t, e) {
|
|
2857
|
-
const { variables: n, tupleElements: s } =
|
|
2868
|
+
const { variables: n, tupleElements: s } = ge(t).unwrap();
|
|
2858
2869
|
return s ? n.length === 0 ? {
|
|
2859
2870
|
schemaName: e.schemaName,
|
|
2860
2871
|
tableName: e.name,
|
|
@@ -2901,14 +2912,14 @@ function Ce(t) {
|
|
|
2901
2912
|
const e = (n = he(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2902
2913
|
return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2903
2914
|
}
|
|
2904
|
-
function
|
|
2905
|
-
const e =
|
|
2915
|
+
function Te(t) {
|
|
2916
|
+
const e = C(t).unwrap();
|
|
2906
2917
|
return {
|
|
2907
2918
|
name: e.pop(),
|
|
2908
2919
|
schemaName: e
|
|
2909
2920
|
};
|
|
2910
2921
|
}
|
|
2911
|
-
function
|
|
2922
|
+
function St(t) {
|
|
2912
2923
|
return t.expression.literal.value;
|
|
2913
2924
|
}
|
|
2914
2925
|
function Ot(t, e) {
|
|
@@ -2919,7 +2930,7 @@ function Ot(t, e) {
|
|
|
2919
2930
|
const n = t.id, s = e.id;
|
|
2920
2931
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
2921
2932
|
}
|
|
2922
|
-
function
|
|
2933
|
+
function Rt(t, e) {
|
|
2923
2934
|
if (Array.isArray(t)) {
|
|
2924
2935
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2925
2936
|
return I.zip(i, r).every(([a, l]) => a === l);
|
|
@@ -2927,7 +2938,7 @@ function St(t, e) {
|
|
|
2927
2938
|
const n = t.id, s = e.id;
|
|
2928
2939
|
return n === s;
|
|
2929
2940
|
}
|
|
2930
|
-
class
|
|
2941
|
+
class Dt {
|
|
2931
2942
|
constructor(e, n) {
|
|
2932
2943
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2933
2944
|
}
|
|
@@ -2951,8 +2962,8 @@ class Rt {
|
|
|
2951
2962
|
}), this.pkColumns.forEach((n) => n.pk = !1)), e;
|
|
2952
2963
|
}
|
|
2953
2964
|
interpretName(e) {
|
|
2954
|
-
const { name: n, schemaName: s } =
|
|
2955
|
-
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new
|
|
2965
|
+
const { name: n, schemaName: s } = Te(e);
|
|
2966
|
+
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, []);
|
|
2956
2967
|
}
|
|
2957
2968
|
interpretAlias(e) {
|
|
2958
2969
|
if (!e)
|
|
@@ -2969,16 +2980,16 @@ class Rt {
|
|
|
2969
2980
|
}
|
|
2970
2981
|
interpretSettingList(e) {
|
|
2971
2982
|
var r, a, l;
|
|
2972
|
-
const n =
|
|
2973
|
-
this.table.headerColor = (r = n.headercolor) != null && r.length ?
|
|
2974
|
-
const [s] = n.note || [], i =
|
|
2983
|
+
const n = W(e).getValue();
|
|
2984
|
+
this.table.headerColor = (r = n.headercolor) != null && r.length ? St((l = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
|
|
2985
|
+
const [s] = n.note || [], i = Q(s == null ? void 0 : s.value).unwrap_or(void 0);
|
|
2975
2986
|
return this.table.note = s && {
|
|
2976
2987
|
value: i,
|
|
2977
2988
|
token: x(s)
|
|
2978
2989
|
}, [];
|
|
2979
2990
|
}
|
|
2980
2991
|
interpretBody(e) {
|
|
2981
|
-
const [n, s] = I.partition(e.body, (i) => i instanceof
|
|
2992
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2982
2993
|
return [...this.interpretFields(n), ...this.interpretSubElements(s)];
|
|
2983
2994
|
}
|
|
2984
2995
|
interpretSubElements(e) {
|
|
@@ -2987,7 +2998,7 @@ class Rt {
|
|
|
2987
2998
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
2988
2999
|
case "note":
|
|
2989
3000
|
return this.table.note = {
|
|
2990
|
-
value:
|
|
3001
|
+
value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).unwrap(),
|
|
2991
3002
|
token: x(n)
|
|
2992
3003
|
}, [];
|
|
2993
3004
|
case "indexes":
|
|
@@ -3003,23 +3014,23 @@ class Rt {
|
|
|
3003
3014
|
var a, l, p, h, T, f, N, g;
|
|
3004
3015
|
const n = [], s = {};
|
|
3005
3016
|
s.name = V(e.callee).unwrap();
|
|
3006
|
-
const i =
|
|
3017
|
+
const i = jn(e.args[0]);
|
|
3007
3018
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
|
|
3008
3019
|
const r = e.args.slice(1);
|
|
3009
3020
|
if (I.last(r) instanceof P) {
|
|
3010
|
-
const _ =
|
|
3011
|
-
s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault =
|
|
3021
|
+
const _ = W(r.pop()).getValue();
|
|
3022
|
+
s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault = Yn((N = (f = _.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3012
3023
|
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3013
3024
|
s.note = K && {
|
|
3014
|
-
value:
|
|
3025
|
+
value: Q(K.value).unwrap(),
|
|
3015
3026
|
token: x(K)
|
|
3016
3027
|
};
|
|
3017
|
-
const
|
|
3018
|
-
s.inline_refs =
|
|
3019
|
-
const [tt] = Ce(
|
|
3020
|
-
if (
|
|
3021
|
-
return n.push(new
|
|
3022
|
-
const we =
|
|
3028
|
+
const be = _.ref || [];
|
|
3029
|
+
s.inline_refs = be.flatMap((z) => {
|
|
3030
|
+
const [tt] = Ce(z.value.expression);
|
|
3031
|
+
if (Rt(tt, e.symbol))
|
|
3032
|
+
return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
|
|
3033
|
+
const we = z.value.op, ee = C(z.value.expression).unwrap();
|
|
3023
3034
|
let fe;
|
|
3024
3035
|
if (ee.length === 1) {
|
|
3025
3036
|
const [oe] = ee;
|
|
@@ -3028,42 +3039,42 @@ class Rt {
|
|
|
3028
3039
|
tableName: this.table.name,
|
|
3029
3040
|
fieldNames: [oe],
|
|
3030
3041
|
relation: we.value,
|
|
3031
|
-
token: x(
|
|
3042
|
+
token: x(z)
|
|
3032
3043
|
};
|
|
3033
3044
|
} else if (ee.length === 2) {
|
|
3034
|
-
const [oe,
|
|
3045
|
+
const [oe, Ie] = ee;
|
|
3035
3046
|
fe = {
|
|
3036
3047
|
schemaName: null,
|
|
3037
3048
|
tableName: oe,
|
|
3038
|
-
fieldNames: [
|
|
3049
|
+
fieldNames: [Ie],
|
|
3039
3050
|
relation: we.value,
|
|
3040
|
-
token: x(
|
|
3051
|
+
token: x(z)
|
|
3041
3052
|
};
|
|
3042
3053
|
} else if (ee.length === 3) {
|
|
3043
|
-
const [oe,
|
|
3054
|
+
const [oe, Ie, st] = ee;
|
|
3044
3055
|
fe = {
|
|
3045
3056
|
schemaName: oe,
|
|
3046
|
-
tableName:
|
|
3057
|
+
tableName: Ie,
|
|
3047
3058
|
fieldNames: [st],
|
|
3048
3059
|
relation: we.value,
|
|
3049
|
-
token: x(
|
|
3060
|
+
token: x(z)
|
|
3050
3061
|
};
|
|
3051
3062
|
} else {
|
|
3052
|
-
n.push(new
|
|
3053
|
-
const oe = ee.pop(),
|
|
3063
|
+
n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
|
|
3064
|
+
const oe = ee.pop(), Ie = ee.pop();
|
|
3054
3065
|
fe = {
|
|
3055
3066
|
schemaName: ee.join("."),
|
|
3056
|
-
tableName:
|
|
3067
|
+
tableName: Ie,
|
|
3057
3068
|
fieldNames: [oe],
|
|
3058
3069
|
relation: we.value,
|
|
3059
|
-
token: x(
|
|
3070
|
+
token: x(z)
|
|
3060
3071
|
};
|
|
3061
3072
|
}
|
|
3062
|
-
const nt = this.registerInlineRefToEnv(e, tt, fe,
|
|
3073
|
+
const nt = this.registerInlineRefToEnv(e, tt, fe, z);
|
|
3063
3074
|
return n.push(...nt), nt.length === 0 ? fe : [];
|
|
3064
3075
|
});
|
|
3065
3076
|
}
|
|
3066
|
-
return s.pk || (s.pk = r.some((_) =>
|
|
3077
|
+
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;
|
|
3067
3078
|
}
|
|
3068
3079
|
interpretIndexes(e) {
|
|
3069
3080
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
@@ -3072,13 +3083,13 @@ class Rt {
|
|
|
3072
3083
|
s.token = x(e);
|
|
3073
3084
|
const r = [i.callee, ...i.args];
|
|
3074
3085
|
if (I.last(r) instanceof P) {
|
|
3075
|
-
const g =
|
|
3076
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name =
|
|
3086
|
+
const g = W(r.pop()).getValue();
|
|
3087
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = Q((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3077
3088
|
const _ = (T = g.note) == null ? void 0 : T.at(0);
|
|
3078
3089
|
s.note = _ && {
|
|
3079
|
-
value:
|
|
3090
|
+
value: Q(_.value).unwrap(),
|
|
3080
3091
|
token: x(_)
|
|
3081
|
-
}, s.type =
|
|
3092
|
+
}, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3082
3093
|
}
|
|
3083
3094
|
return r.flatMap((g) => {
|
|
3084
3095
|
if (!(g instanceof J))
|
|
@@ -3090,12 +3101,12 @@ class Rt {
|
|
|
3090
3101
|
}).forEach((g) => {
|
|
3091
3102
|
const { functional: _, nonFunctional: K } = Ge(g).unwrap();
|
|
3092
3103
|
s.columns.push(
|
|
3093
|
-
..._.map((
|
|
3094
|
-
value:
|
|
3104
|
+
..._.map((be) => ({
|
|
3105
|
+
value: be.value.value,
|
|
3095
3106
|
type: "expression"
|
|
3096
3107
|
})),
|
|
3097
|
-
...K.map((
|
|
3098
|
-
value: V(
|
|
3108
|
+
...K.map((be) => ({
|
|
3109
|
+
value: V(be).unwrap(),
|
|
3099
3110
|
type: "column"
|
|
3100
3111
|
}))
|
|
3101
3112
|
);
|
|
@@ -3106,8 +3117,8 @@ class Rt {
|
|
|
3106
3117
|
const r = Ot(e.symbol, n);
|
|
3107
3118
|
if (this.env.refIds[r])
|
|
3108
3119
|
return [
|
|
3109
|
-
new
|
|
3110
|
-
new
|
|
3120
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3121
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3111
3122
|
];
|
|
3112
3123
|
const a = xt(s.relation);
|
|
3113
3124
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
@@ -3122,7 +3133,7 @@ class Rt {
|
|
|
3122
3133
|
{
|
|
3123
3134
|
schemaName: this.table.schemaName,
|
|
3124
3135
|
tableName: this.table.name,
|
|
3125
|
-
fieldNames: [
|
|
3136
|
+
fieldNames: [X(e.callee).unwrap()],
|
|
3126
3137
|
token: x(e),
|
|
3127
3138
|
relation: a[0]
|
|
3128
3139
|
}
|
|
@@ -3130,32 +3141,32 @@ class Rt {
|
|
|
3130
3141
|
}), [];
|
|
3131
3142
|
}
|
|
3132
3143
|
}
|
|
3133
|
-
function
|
|
3144
|
+
function jn(t) {
|
|
3134
3145
|
let e = null;
|
|
3135
|
-
t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value :
|
|
3146
|
+
t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value : Y(r) ? Q(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3136
3147
|
let n = "";
|
|
3137
3148
|
for (; t instanceof ce; )
|
|
3138
3149
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3139
|
-
const { name: s, schemaName: i } =
|
|
3150
|
+
const { name: s, schemaName: i } = Te(t);
|
|
3140
3151
|
return i.length > 1 ? new F(
|
|
3141
3152
|
{
|
|
3142
3153
|
schemaName: i.length === 0 ? null : i[0],
|
|
3143
3154
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3144
3155
|
args: e
|
|
3145
3156
|
},
|
|
3146
|
-
[new
|
|
3157
|
+
[new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3147
3158
|
) : new F({
|
|
3148
3159
|
schemaName: i.length === 0 ? null : i[0],
|
|
3149
3160
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3150
3161
|
args: e
|
|
3151
3162
|
});
|
|
3152
3163
|
}
|
|
3153
|
-
function
|
|
3164
|
+
function Yn(t) {
|
|
3154
3165
|
var e, n, s;
|
|
3155
3166
|
if (t) {
|
|
3156
|
-
if (
|
|
3167
|
+
if (Y(t))
|
|
3157
3168
|
return {
|
|
3158
|
-
value:
|
|
3169
|
+
value: Q(t).unwrap(),
|
|
3159
3170
|
type: "string"
|
|
3160
3171
|
};
|
|
3161
3172
|
if (ue(t))
|
|
@@ -3183,7 +3194,38 @@ function jn(t) {
|
|
|
3183
3194
|
throw new Error("Unreachable");
|
|
3184
3195
|
}
|
|
3185
3196
|
}
|
|
3186
|
-
class
|
|
3197
|
+
class zn {
|
|
3198
|
+
constructor(e, n) {
|
|
3199
|
+
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3200
|
+
}
|
|
3201
|
+
interpret() {
|
|
3202
|
+
return this.note.token = x(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
|
|
3203
|
+
...this.interpretName(this.declarationNode.name),
|
|
3204
|
+
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3205
|
+
...this.interpretBody(this.declarationNode.body)
|
|
3206
|
+
];
|
|
3207
|
+
}
|
|
3208
|
+
interpretName(e) {
|
|
3209
|
+
const { name: n } = Te(e);
|
|
3210
|
+
return this.note.name = n, [];
|
|
3211
|
+
}
|
|
3212
|
+
interpretSettingList(e) {
|
|
3213
|
+
var s, i, r;
|
|
3214
|
+
const n = W(e).getValue();
|
|
3215
|
+
return this.note.headerColor = (s = n.headercolor) != null && s.length ? St((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
|
|
3216
|
+
}
|
|
3217
|
+
interpretBody(e) {
|
|
3218
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
3219
|
+
return n.length !== 1 || s.length > 0 ? [
|
|
3220
|
+
new c(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3221
|
+
] : [...this.interpretNote(n[0])];
|
|
3222
|
+
}
|
|
3223
|
+
interpretNote(e) {
|
|
3224
|
+
const n = I.get(e, "callee.expression.literal.value", "");
|
|
3225
|
+
return this.note.content = n, [];
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
class Pt {
|
|
3187
3229
|
constructor(e, n) {
|
|
3188
3230
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3189
3231
|
}
|
|
@@ -3191,28 +3233,28 @@ class Dt {
|
|
|
3191
3233
|
return this.ref.token = x(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3192
3234
|
}
|
|
3193
3235
|
interpretName(e) {
|
|
3194
|
-
const n = [], s =
|
|
3195
|
-
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new
|
|
3236
|
+
const n = [], s = C(this.declarationNode.name).unwrap_or([]);
|
|
3237
|
+
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;
|
|
3196
3238
|
}
|
|
3197
3239
|
interpretBody(e) {
|
|
3198
|
-
return e instanceof
|
|
3240
|
+
return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3199
3241
|
}
|
|
3200
3242
|
interpretField(e) {
|
|
3201
3243
|
var h, T, f, N;
|
|
3202
3244
|
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
|
|
3203
|
-
if (
|
|
3204
|
-
return [new
|
|
3245
|
+
if (Rt(r, a))
|
|
3246
|
+
return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3205
3247
|
const l = Ot(r, a);
|
|
3206
3248
|
if (this.env.refIds[l])
|
|
3207
3249
|
return [
|
|
3208
|
-
new
|
|
3209
|
-
new
|
|
3250
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3251
|
+
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
|
|
3210
3252
|
];
|
|
3211
3253
|
if (e.args[0]) {
|
|
3212
|
-
const g =
|
|
3213
|
-
this.ref.onDelete = _ instanceof
|
|
3254
|
+
const g = W(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
|
|
3255
|
+
this.ref.onDelete = _ instanceof $ ? Ne(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
|
|
3214
3256
|
const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
|
|
3215
|
-
this.ref.onUpdate = K instanceof
|
|
3257
|
+
this.ref.onUpdate = K instanceof $ ? Ne(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
|
|
3216
3258
|
}
|
|
3217
3259
|
const p = xt(n);
|
|
3218
3260
|
return this.ref.endpoints = [
|
|
@@ -3229,7 +3271,7 @@ class Dt {
|
|
|
3229
3271
|
], this.env.refIds[l] = this.declarationNode, [];
|
|
3230
3272
|
}
|
|
3231
3273
|
}
|
|
3232
|
-
class
|
|
3274
|
+
class Ut {
|
|
3233
3275
|
constructor(e, n) {
|
|
3234
3276
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3235
3277
|
}
|
|
@@ -3241,18 +3283,18 @@ class Pt {
|
|
|
3241
3283
|
), e;
|
|
3242
3284
|
}
|
|
3243
3285
|
interpretName(e) {
|
|
3244
|
-
const n = [], { name: s, schemaName: i } =
|
|
3245
|
-
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new
|
|
3286
|
+
const n = [], { name: s, schemaName: i } = Te(e);
|
|
3287
|
+
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;
|
|
3246
3288
|
}
|
|
3247
3289
|
interpretBody(e) {
|
|
3248
3290
|
const n = [];
|
|
3249
3291
|
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3250
|
-
const i =
|
|
3251
|
-
i.length > 2 && n.push(new
|
|
3292
|
+
const i = C(s.callee).unwrap();
|
|
3293
|
+
i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3252
3294
|
const r = he(s.callee).unwrap().pop().referee.id;
|
|
3253
3295
|
if (this.env.groupOfTable[r]) {
|
|
3254
3296
|
const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), h = l ? `${l}.${p}` : p;
|
|
3255
|
-
n.push(new
|
|
3297
|
+
n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
|
|
3256
3298
|
} else
|
|
3257
3299
|
this.env.groupOfTable[r] = this.declarationNode;
|
|
3258
3300
|
return {
|
|
@@ -3262,7 +3304,7 @@ class Pt {
|
|
|
3262
3304
|
}), n;
|
|
3263
3305
|
}
|
|
3264
3306
|
}
|
|
3265
|
-
class
|
|
3307
|
+
class Mt {
|
|
3266
3308
|
constructor(e, n) {
|
|
3267
3309
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3268
3310
|
}
|
|
@@ -3270,23 +3312,23 @@ class Ut {
|
|
|
3270
3312
|
return this.enum.token = x(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3271
3313
|
}
|
|
3272
3314
|
interpretName(e) {
|
|
3273
|
-
const { name: n, schemaName: s } =
|
|
3274
|
-
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new
|
|
3315
|
+
const { name: n, schemaName: s } = Te(e);
|
|
3316
|
+
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, []);
|
|
3275
3317
|
}
|
|
3276
3318
|
interpretBody(e) {
|
|
3277
3319
|
return e.body.flatMap((n) => {
|
|
3278
3320
|
var l;
|
|
3279
3321
|
const s = n, i = {};
|
|
3280
|
-
i.token = x(s), i.name =
|
|
3281
|
-
const a = (l =
|
|
3322
|
+
i.token = x(s), i.name = X(s.callee).unwrap();
|
|
3323
|
+
const a = (l = W(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
|
|
3282
3324
|
return i.note = a && {
|
|
3283
|
-
value:
|
|
3325
|
+
value: Q(a.value).unwrap(),
|
|
3284
3326
|
token: x(a)
|
|
3285
3327
|
}, this.enum.values.push(i), [];
|
|
3286
3328
|
});
|
|
3287
3329
|
}
|
|
3288
3330
|
}
|
|
3289
|
-
class
|
|
3331
|
+
class Qn {
|
|
3290
3332
|
constructor(e, n) {
|
|
3291
3333
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3292
3334
|
}
|
|
@@ -3296,7 +3338,7 @@ class Yn {
|
|
|
3296
3338
|
interpretName(e) {
|
|
3297
3339
|
if (!e)
|
|
3298
3340
|
return this.project.name = null, [];
|
|
3299
|
-
const { name: n } =
|
|
3341
|
+
const { name: n } = Te(e);
|
|
3300
3342
|
return this.project.name = n, [];
|
|
3301
3343
|
}
|
|
3302
3344
|
interpretBody(e) {
|
|
@@ -3305,37 +3347,38 @@ class Yn {
|
|
|
3305
3347
|
const s = n;
|
|
3306
3348
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
3307
3349
|
case "table": {
|
|
3308
|
-
const r = new
|
|
3350
|
+
const r = new Dt(s, this.env).interpret();
|
|
3309
3351
|
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3310
3352
|
}
|
|
3311
3353
|
case "ref": {
|
|
3312
|
-
const r = new
|
|
3354
|
+
const r = new Pt(s, this.env).interpret();
|
|
3313
3355
|
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3314
3356
|
}
|
|
3315
3357
|
case "tablegroup": {
|
|
3316
|
-
const r = new
|
|
3358
|
+
const r = new Ut(s, this.env).interpret();
|
|
3317
3359
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
|
|
3318
3360
|
}
|
|
3319
3361
|
case "enum": {
|
|
3320
|
-
const r = new
|
|
3362
|
+
const r = new Mt(s, this.env).interpret();
|
|
3321
3363
|
return this.project.enums.push(this.env.enums.get(s)), r;
|
|
3322
3364
|
}
|
|
3323
3365
|
case "note":
|
|
3324
3366
|
return this.project.note = {
|
|
3325
|
-
value:
|
|
3367
|
+
value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).unwrap(),
|
|
3326
3368
|
token: x(s)
|
|
3327
3369
|
}, [];
|
|
3328
3370
|
default:
|
|
3329
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
3371
|
+
return this.project[s.type.value.toLowerCase()] = Q(s.body.callee).unwrap(), [];
|
|
3330
3372
|
}
|
|
3331
3373
|
});
|
|
3332
3374
|
}
|
|
3333
3375
|
}
|
|
3334
|
-
class
|
|
3376
|
+
class qn {
|
|
3335
3377
|
constructor(e) {
|
|
3336
3378
|
this.ast = e, this.env = {
|
|
3337
3379
|
schema: [],
|
|
3338
3380
|
tables: /* @__PURE__ */ new Map(),
|
|
3381
|
+
notes: /* @__PURE__ */ new Map(),
|
|
3339
3382
|
refIds: {},
|
|
3340
3383
|
ref: /* @__PURE__ */ new Map(),
|
|
3341
3384
|
enums: /* @__PURE__ */ new Map(),
|
|
@@ -3347,28 +3390,31 @@ class zn {
|
|
|
3347
3390
|
}
|
|
3348
3391
|
interpret() {
|
|
3349
3392
|
const e = this.ast.body.flatMap((n) => {
|
|
3350
|
-
switch (
|
|
3393
|
+
switch (Ae(n).unwrap_or(void 0)) {
|
|
3351
3394
|
case b.Table:
|
|
3352
|
-
return new Rt(n, this.env).interpret();
|
|
3353
|
-
case b.Ref:
|
|
3354
3395
|
return new Dt(n, this.env).interpret();
|
|
3355
|
-
case b.
|
|
3396
|
+
case b.Note:
|
|
3397
|
+
return new zn(n, this.env).interpret();
|
|
3398
|
+
case b.Ref:
|
|
3356
3399
|
return new Pt(n, this.env).interpret();
|
|
3357
|
-
case b.
|
|
3400
|
+
case b.TableGroup:
|
|
3358
3401
|
return new Ut(n, this.env).interpret();
|
|
3402
|
+
case b.Enum:
|
|
3403
|
+
return new Mt(n, this.env).interpret();
|
|
3359
3404
|
case b.Project:
|
|
3360
|
-
return new
|
|
3405
|
+
return new Qn(n, this.env).interpret();
|
|
3361
3406
|
default:
|
|
3362
3407
|
return [];
|
|
3363
3408
|
}
|
|
3364
3409
|
});
|
|
3365
|
-
return new F(
|
|
3410
|
+
return new F(Hn(this.env), e);
|
|
3366
3411
|
}
|
|
3367
3412
|
}
|
|
3368
|
-
function
|
|
3413
|
+
function Hn(t) {
|
|
3369
3414
|
return {
|
|
3370
3415
|
schemas: [],
|
|
3371
3416
|
tables: Array.from(t.tables.values()),
|
|
3417
|
+
notes: Array.from(t.notes.values()),
|
|
3372
3418
|
refs: Array.from(t.ref.values()),
|
|
3373
3419
|
enums: Array.from(t.enums.values()),
|
|
3374
3420
|
tableGroups: Array.from(t.tableGroups.values()),
|
|
@@ -3376,8 +3422,8 @@ function Qn(t) {
|
|
|
3376
3422
|
project: Array.from(t.project.values())[0] || {}
|
|
3377
3423
|
};
|
|
3378
3424
|
}
|
|
3379
|
-
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 || {}),
|
|
3380
|
-
function
|
|
3425
|
+
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
|
|
3426
|
+
function _e(t) {
|
|
3381
3427
|
switch (t) {
|
|
3382
3428
|
case m.Schema:
|
|
3383
3429
|
return L.Module;
|
|
@@ -3397,18 +3443,18 @@ function ge(t) {
|
|
|
3397
3443
|
return L.Text;
|
|
3398
3444
|
}
|
|
3399
3445
|
}
|
|
3400
|
-
function
|
|
3446
|
+
function Oe(t, e) {
|
|
3401
3447
|
if (!t || Ve(t))
|
|
3402
3448
|
return !1;
|
|
3403
3449
|
for (const n of t.trailingTrivia) {
|
|
3404
3450
|
if (n.start > e)
|
|
3405
3451
|
break;
|
|
3406
|
-
if (n.kind ===
|
|
3452
|
+
if (n.kind === u.NEWLINE && n.end <= e)
|
|
3407
3453
|
return !1;
|
|
3408
3454
|
}
|
|
3409
3455
|
return !0;
|
|
3410
3456
|
}
|
|
3411
|
-
function
|
|
3457
|
+
function O() {
|
|
3412
3458
|
return {
|
|
3413
3459
|
suggestions: []
|
|
3414
3460
|
};
|
|
@@ -3434,7 +3480,7 @@ function Ue(t) {
|
|
|
3434
3480
|
function Ke(t, e) {
|
|
3435
3481
|
return t.getOffsetAt(e);
|
|
3436
3482
|
}
|
|
3437
|
-
class
|
|
3483
|
+
class Ft {
|
|
3438
3484
|
constructor(e, n = []) {
|
|
3439
3485
|
this.compiler = e, this.triggerCharacters = n;
|
|
3440
3486
|
}
|
|
@@ -3445,12 +3491,12 @@ class Mt {
|
|
|
3445
3491
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3446
3492
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3447
3493
|
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3448
|
-
].find((N) =>
|
|
3449
|
-
return
|
|
3494
|
+
].find((N) => Wt(N) && Le(s, N)))
|
|
3495
|
+
return O();
|
|
3450
3496
|
if (a === void 0)
|
|
3451
3497
|
return mt();
|
|
3452
|
-
if ([
|
|
3453
|
-
return
|
|
3498
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
|
|
3499
|
+
return O();
|
|
3454
3500
|
const p = this.compiler.container.element(s);
|
|
3455
3501
|
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
|
|
3456
3502
|
return mt();
|
|
@@ -3480,7 +3526,7 @@ class Mt {
|
|
|
3480
3526
|
N
|
|
3481
3527
|
);
|
|
3482
3528
|
case ".":
|
|
3483
|
-
return
|
|
3529
|
+
return Bt(
|
|
3484
3530
|
this.compiler,
|
|
3485
3531
|
s,
|
|
3486
3532
|
N
|
|
@@ -3492,13 +3538,13 @@ class Mt {
|
|
|
3492
3538
|
if (N instanceof P)
|
|
3493
3539
|
return dt(this.compiler, s, N);
|
|
3494
3540
|
if (N instanceof Z)
|
|
3495
|
-
return
|
|
3496
|
-
if (N instanceof
|
|
3541
|
+
return Jn(this.compiler, s);
|
|
3542
|
+
if (N instanceof w)
|
|
3497
3543
|
return Nt(this.compiler, s, N);
|
|
3498
|
-
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body &&
|
|
3544
|
+
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
|
|
3499
3545
|
return Nt(this.compiler, s, void 0);
|
|
3500
3546
|
}
|
|
3501
|
-
return
|
|
3547
|
+
return O();
|
|
3502
3548
|
}
|
|
3503
3549
|
}
|
|
3504
3550
|
function pt(t, e, n) {
|
|
@@ -3509,14 +3555,14 @@ function pt(t, e, n) {
|
|
|
3509
3555
|
m.Schema,
|
|
3510
3556
|
m.Column
|
|
3511
3557
|
]);
|
|
3512
|
-
return
|
|
3558
|
+
return Oe(n.op, e) ? Re(i) : i;
|
|
3513
3559
|
}
|
|
3514
|
-
return
|
|
3560
|
+
return O();
|
|
3515
3561
|
}
|
|
3516
3562
|
function Me(t, e, n, s) {
|
|
3517
3563
|
var a;
|
|
3518
3564
|
if (n === void 0)
|
|
3519
|
-
return
|
|
3565
|
+
return O();
|
|
3520
3566
|
let i = n;
|
|
3521
3567
|
const r = { suggestions: [] };
|
|
3522
3568
|
for (; i; ) {
|
|
@@ -3526,9 +3572,9 @@ function Me(t, e, n, s) {
|
|
|
3526
3572
|
...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
|
|
3527
3573
|
label: p,
|
|
3528
3574
|
insertText: p,
|
|
3529
|
-
insertTextRules:
|
|
3530
|
-
kind:
|
|
3531
|
-
sortText:
|
|
3575
|
+
insertTextRules: y.KeepWhitespace,
|
|
3576
|
+
kind: _e(h),
|
|
3577
|
+
sortText: _e(h).toString().padStart(2, "0"),
|
|
3532
3578
|
range: void 0
|
|
3533
3579
|
}))
|
|
3534
3580
|
);
|
|
@@ -3537,51 +3583,51 @@ function Me(t, e, n, s) {
|
|
|
3537
3583
|
}
|
|
3538
3584
|
return Ue(r);
|
|
3539
3585
|
}
|
|
3540
|
-
function
|
|
3586
|
+
function Jn(t, e) {
|
|
3541
3587
|
var s;
|
|
3542
3588
|
switch (t.container.scopeKind(e)) {
|
|
3543
3589
|
case R.INDEXES:
|
|
3544
|
-
return
|
|
3590
|
+
return Gt(t, e);
|
|
3545
3591
|
case R.REF:
|
|
3546
3592
|
{
|
|
3547
3593
|
const i = [...t.container.stack(e)];
|
|
3548
3594
|
for (; i.length > 0; ) {
|
|
3549
3595
|
const r = i.pop();
|
|
3550
3596
|
if (r instanceof H && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3551
|
-
return
|
|
3597
|
+
return Bt(
|
|
3552
3598
|
t,
|
|
3553
3599
|
e,
|
|
3554
3600
|
r
|
|
3555
3601
|
);
|
|
3556
3602
|
}
|
|
3557
3603
|
}
|
|
3558
|
-
return
|
|
3604
|
+
return Vt(t, e);
|
|
3559
3605
|
}
|
|
3560
|
-
return
|
|
3606
|
+
return O();
|
|
3561
3607
|
}
|
|
3562
3608
|
function dt(t, e, n) {
|
|
3563
3609
|
const { token: s } = t.container.token(e);
|
|
3564
|
-
if ([
|
|
3610
|
+
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3565
3611
|
const i = Et(t, e);
|
|
3566
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3612
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && Oe(s, e) ? Re(i) : i;
|
|
3567
3613
|
}
|
|
3568
3614
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3569
3615
|
return Et(t, e);
|
|
3570
|
-
if (n.name instanceof
|
|
3571
|
-
const i =
|
|
3616
|
+
if (n.name instanceof $) {
|
|
3617
|
+
const i = Zn(
|
|
3572
3618
|
t,
|
|
3573
3619
|
e,
|
|
3574
3620
|
Ne(n.name).unwrap()
|
|
3575
3621
|
);
|
|
3576
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3622
|
+
return (s == null ? void 0 : s.kind) === u.COLON && Oe(s, e) ? Re(i) : i;
|
|
3577
3623
|
}
|
|
3578
|
-
return
|
|
3624
|
+
return O();
|
|
3579
3625
|
}
|
|
3580
3626
|
function Et(t, e) {
|
|
3581
3627
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3582
|
-
if (n instanceof
|
|
3583
|
-
return
|
|
3584
|
-
if (n.body && !
|
|
3628
|
+
if (n instanceof G)
|
|
3629
|
+
return O();
|
|
3630
|
+
if (n.body && !Le(e, n.body))
|
|
3585
3631
|
switch (s) {
|
|
3586
3632
|
case R.TABLE:
|
|
3587
3633
|
return {
|
|
@@ -3590,20 +3636,20 @@ function Et(t, e) {
|
|
|
3590
3636
|
label: "headercolor",
|
|
3591
3637
|
insertText: "headercolor: ",
|
|
3592
3638
|
kind: L.Field,
|
|
3593
|
-
insertTextRules:
|
|
3639
|
+
insertTextRules: y.KeepWhitespace,
|
|
3594
3640
|
range: void 0
|
|
3595
3641
|
},
|
|
3596
3642
|
{
|
|
3597
3643
|
label: "note",
|
|
3598
3644
|
insertText: "note: ",
|
|
3599
3645
|
kind: L.Field,
|
|
3600
|
-
insertTextRules:
|
|
3646
|
+
insertTextRules: y.KeepWhitespace,
|
|
3601
3647
|
range: void 0
|
|
3602
3648
|
}
|
|
3603
3649
|
]
|
|
3604
3650
|
};
|
|
3605
3651
|
default:
|
|
3606
|
-
return
|
|
3652
|
+
return O();
|
|
3607
3653
|
}
|
|
3608
3654
|
switch (s) {
|
|
3609
3655
|
case R.TABLE:
|
|
@@ -3613,21 +3659,21 @@ function Et(t, e) {
|
|
|
3613
3659
|
label: i,
|
|
3614
3660
|
insertText: i,
|
|
3615
3661
|
kind: L.Property,
|
|
3616
|
-
insertTextRules:
|
|
3662
|
+
insertTextRules: y.KeepWhitespace,
|
|
3617
3663
|
range: void 0
|
|
3618
3664
|
})),
|
|
3619
3665
|
...["ref", "default"].map((i) => ({
|
|
3620
3666
|
label: i,
|
|
3621
3667
|
insertText: `${i}: `,
|
|
3622
3668
|
kind: L.Property,
|
|
3623
|
-
insertTextRules:
|
|
3669
|
+
insertTextRules: y.KeepWhitespace,
|
|
3624
3670
|
range: void 0
|
|
3625
3671
|
})),
|
|
3626
3672
|
{
|
|
3627
3673
|
label: "note",
|
|
3628
3674
|
insertText: "note: ",
|
|
3629
3675
|
kind: L.Property,
|
|
3630
|
-
insertTextRules:
|
|
3676
|
+
insertTextRules: y.KeepWhitespace,
|
|
3631
3677
|
range: void 0
|
|
3632
3678
|
}
|
|
3633
3679
|
]
|
|
@@ -3639,7 +3685,7 @@ function Et(t, e) {
|
|
|
3639
3685
|
label: "note",
|
|
3640
3686
|
insertText: "note: ",
|
|
3641
3687
|
kind: L.Property,
|
|
3642
|
-
insertTextRules:
|
|
3688
|
+
insertTextRules: y.KeepWhitespace,
|
|
3643
3689
|
range: void 0
|
|
3644
3690
|
}
|
|
3645
3691
|
]
|
|
@@ -3650,7 +3696,7 @@ function Et(t, e) {
|
|
|
3650
3696
|
...["unique", "pk"].map((i) => ({
|
|
3651
3697
|
label: i,
|
|
3652
3698
|
insertText: i,
|
|
3653
|
-
insertTextRules:
|
|
3699
|
+
insertTextRules: y.KeepWhitespace,
|
|
3654
3700
|
kind: L.Property,
|
|
3655
3701
|
range: void 0
|
|
3656
3702
|
})),
|
|
@@ -3658,7 +3704,7 @@ function Et(t, e) {
|
|
|
3658
3704
|
label: i,
|
|
3659
3705
|
insertText: `${i}: `,
|
|
3660
3706
|
kind: L.Property,
|
|
3661
|
-
insertTextRules:
|
|
3707
|
+
insertTextRules: y.KeepWhitespace,
|
|
3662
3708
|
range: void 0
|
|
3663
3709
|
}))
|
|
3664
3710
|
]
|
|
@@ -3669,14 +3715,14 @@ function Et(t, e) {
|
|
|
3669
3715
|
label: i,
|
|
3670
3716
|
insertText: `${i}: `,
|
|
3671
3717
|
kind: L.Property,
|
|
3672
|
-
insertTextRules:
|
|
3718
|
+
insertTextRules: y.KeepWhitespace,
|
|
3673
3719
|
range: void 0
|
|
3674
3720
|
}))
|
|
3675
3721
|
};
|
|
3676
3722
|
}
|
|
3677
|
-
return
|
|
3723
|
+
return O();
|
|
3678
3724
|
}
|
|
3679
|
-
function
|
|
3725
|
+
function Zn(t, e, n) {
|
|
3680
3726
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
3681
3727
|
case "update":
|
|
3682
3728
|
case "delete":
|
|
@@ -3685,7 +3731,7 @@ function Hn(t, e, n) {
|
|
|
3685
3731
|
label: s,
|
|
3686
3732
|
insertText: s,
|
|
3687
3733
|
kind: L.Value,
|
|
3688
|
-
insertTextRules:
|
|
3734
|
+
insertTextRules: y.KeepWhitespace,
|
|
3689
3735
|
range: void 0
|
|
3690
3736
|
}))
|
|
3691
3737
|
};
|
|
@@ -3695,23 +3741,23 @@ function Hn(t, e, n) {
|
|
|
3695
3741
|
label: s,
|
|
3696
3742
|
insertText: `${s}`,
|
|
3697
3743
|
kind: L.Value,
|
|
3698
|
-
insertTextRules:
|
|
3744
|
+
insertTextRules: y.KeepWhitespace,
|
|
3699
3745
|
range: void 0
|
|
3700
3746
|
}))
|
|
3701
3747
|
};
|
|
3702
3748
|
}
|
|
3703
|
-
return
|
|
3749
|
+
return O();
|
|
3704
3750
|
}
|
|
3705
|
-
function
|
|
3751
|
+
function Bt(t, e, n) {
|
|
3706
3752
|
const s = he(n).unwrap_or([]);
|
|
3707
3753
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3708
|
-
return
|
|
3709
|
-
const i = s.map((r) =>
|
|
3754
|
+
return O();
|
|
3755
|
+
const i = s.map((r) => X(r).unwrap());
|
|
3710
3756
|
return Ue({
|
|
3711
3757
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3712
3758
|
label: a,
|
|
3713
3759
|
insertText: a,
|
|
3714
|
-
kind:
|
|
3760
|
+
kind: _e(r),
|
|
3715
3761
|
range: void 0
|
|
3716
3762
|
}))
|
|
3717
3763
|
});
|
|
@@ -3720,21 +3766,21 @@ function Nt(t, e, n) {
|
|
|
3720
3766
|
var i;
|
|
3721
3767
|
switch (t.container.scopeKind(e)) {
|
|
3722
3768
|
case R.TABLE:
|
|
3723
|
-
return
|
|
3769
|
+
return es(t, e, n);
|
|
3724
3770
|
case R.PROJECT:
|
|
3725
|
-
return
|
|
3771
|
+
return ts(t, e, n);
|
|
3726
3772
|
case R.INDEXES:
|
|
3727
|
-
return
|
|
3773
|
+
return ss(t, e);
|
|
3728
3774
|
case R.ENUM:
|
|
3729
|
-
return
|
|
3775
|
+
return Kn(t, e, n);
|
|
3730
3776
|
case R.REF: {
|
|
3731
|
-
const r =
|
|
3732
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) ===
|
|
3777
|
+
const r = Vt(t, e);
|
|
3778
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Oe(t.container.token(e).token, e) ? Re(r) : r;
|
|
3733
3779
|
}
|
|
3734
3780
|
case R.TABLEGROUP:
|
|
3735
|
-
return
|
|
3781
|
+
return ns(t);
|
|
3736
3782
|
default:
|
|
3737
|
-
return
|
|
3783
|
+
return O();
|
|
3738
3784
|
}
|
|
3739
3785
|
}
|
|
3740
3786
|
function mt() {
|
|
@@ -3742,26 +3788,26 @@ function mt() {
|
|
|
3742
3788
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3743
3789
|
label: t,
|
|
3744
3790
|
insertText: t,
|
|
3745
|
-
insertTextRules:
|
|
3791
|
+
insertTextRules: y.KeepWhitespace,
|
|
3746
3792
|
kind: L.Keyword,
|
|
3747
3793
|
range: void 0
|
|
3748
3794
|
}))
|
|
3749
3795
|
};
|
|
3750
3796
|
}
|
|
3751
|
-
function
|
|
3797
|
+
function Kn(t, e, n) {
|
|
3752
3798
|
return n != null && n.callee && et(e, n) === 1 ? Me(t, e, t.container.element(e), [
|
|
3753
3799
|
m.Schema,
|
|
3754
3800
|
m.Table,
|
|
3755
3801
|
m.Column
|
|
3756
|
-
]) :
|
|
3802
|
+
]) : O();
|
|
3757
3803
|
}
|
|
3758
|
-
function
|
|
3804
|
+
function es(t, e, n) {
|
|
3759
3805
|
if (!(n != null && n.callee))
|
|
3760
3806
|
return {
|
|
3761
3807
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3762
3808
|
label: i,
|
|
3763
3809
|
insertText: i,
|
|
3764
|
-
insertTextRules:
|
|
3810
|
+
insertTextRules: y.KeepWhitespace,
|
|
3765
3811
|
kind: L.Keyword,
|
|
3766
3812
|
range: void 0
|
|
3767
3813
|
}))
|
|
@@ -3771,39 +3817,39 @@ function Zn(t, e, n) {
|
|
|
3771
3817
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3772
3818
|
label: i,
|
|
3773
3819
|
insertText: i,
|
|
3774
|
-
insertTextRules:
|
|
3820
|
+
insertTextRules: y.KeepWhitespace,
|
|
3775
3821
|
kind: L.Keyword,
|
|
3776
3822
|
range: void 0
|
|
3777
3823
|
}))
|
|
3778
|
-
} : s === 1 ?
|
|
3824
|
+
} : s === 1 ? is(t, e) : O();
|
|
3779
3825
|
}
|
|
3780
|
-
function
|
|
3826
|
+
function ts(t, e, n) {
|
|
3781
3827
|
return n != null && n.callee ? et(e, n) === 0 ? {
|
|
3782
3828
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3783
3829
|
label: i,
|
|
3784
3830
|
insertText: i,
|
|
3785
|
-
insertTextRules:
|
|
3831
|
+
insertTextRules: y.KeepWhitespace,
|
|
3786
3832
|
kind: L.Keyword,
|
|
3787
3833
|
range: void 0
|
|
3788
3834
|
}))
|
|
3789
|
-
} :
|
|
3835
|
+
} : O() : {
|
|
3790
3836
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3791
3837
|
label: i,
|
|
3792
3838
|
insertText: i,
|
|
3793
|
-
insertTextRules:
|
|
3839
|
+
insertTextRules: y.KeepWhitespace,
|
|
3794
3840
|
kind: L.Keyword,
|
|
3795
3841
|
range: void 0
|
|
3796
3842
|
}))
|
|
3797
3843
|
};
|
|
3798
3844
|
}
|
|
3799
|
-
function
|
|
3845
|
+
function Vt(t, e) {
|
|
3800
3846
|
return Me(t, e, t.container.element(e), [
|
|
3801
3847
|
m.Schema,
|
|
3802
3848
|
m.Table,
|
|
3803
3849
|
m.Column
|
|
3804
3850
|
]);
|
|
3805
3851
|
}
|
|
3806
|
-
function
|
|
3852
|
+
function ns(t) {
|
|
3807
3853
|
return Ue({
|
|
3808
3854
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3809
3855
|
const n = ie(e).unwrap_or(void 0);
|
|
@@ -3813,17 +3859,17 @@ function es(t) {
|
|
|
3813
3859
|
return s !== m.Table && s !== m.Schema ? [] : {
|
|
3814
3860
|
label: i,
|
|
3815
3861
|
insertText: i,
|
|
3816
|
-
insertTextRules:
|
|
3817
|
-
kind:
|
|
3862
|
+
insertTextRules: y.KeepWhitespace,
|
|
3863
|
+
kind: _e(s),
|
|
3818
3864
|
range: void 0
|
|
3819
3865
|
};
|
|
3820
3866
|
})
|
|
3821
3867
|
});
|
|
3822
3868
|
}
|
|
3823
|
-
function
|
|
3824
|
-
return
|
|
3869
|
+
function ss(t, e) {
|
|
3870
|
+
return Gt(t, e);
|
|
3825
3871
|
}
|
|
3826
|
-
function
|
|
3872
|
+
function is(t, e) {
|
|
3827
3873
|
return {
|
|
3828
3874
|
suggestions: [
|
|
3829
3875
|
...[
|
|
@@ -3886,7 +3932,7 @@ function ns(t, e) {
|
|
|
3886
3932
|
].map((n) => ({
|
|
3887
3933
|
label: n,
|
|
3888
3934
|
insertText: n,
|
|
3889
|
-
insertTextRules:
|
|
3935
|
+
insertTextRules: y.KeepWhitespace,
|
|
3890
3936
|
kind: L.TypeParameter,
|
|
3891
3937
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3892
3938
|
range: void 0
|
|
@@ -3898,10 +3944,10 @@ function ns(t, e) {
|
|
|
3898
3944
|
]
|
|
3899
3945
|
};
|
|
3900
3946
|
}
|
|
3901
|
-
function
|
|
3947
|
+
function Gt(t, e) {
|
|
3902
3948
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
3903
3949
|
if (!((s == null ? void 0 : s.symbol) instanceof _t))
|
|
3904
|
-
return
|
|
3950
|
+
return O();
|
|
3905
3951
|
const { symbolTable: i } = s.symbol;
|
|
3906
3952
|
return Ue({
|
|
3907
3953
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
@@ -3912,8 +3958,8 @@ function Vt(t, e) {
|
|
|
3912
3958
|
return {
|
|
3913
3959
|
label: l,
|
|
3914
3960
|
insertText: l,
|
|
3915
|
-
insertTextRules:
|
|
3916
|
-
kind:
|
|
3961
|
+
insertTextRules: y.KeepWhitespace,
|
|
3962
|
+
kind: _e(m.Column),
|
|
3917
3963
|
range: void 0
|
|
3918
3964
|
};
|
|
3919
3965
|
})
|
|
@@ -3925,7 +3971,7 @@ function et(t, e) {
|
|
|
3925
3971
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
3926
3972
|
return s === -1 ? n.length : s;
|
|
3927
3973
|
}
|
|
3928
|
-
class
|
|
3974
|
+
class Ct {
|
|
3929
3975
|
constructor(e) {
|
|
3930
3976
|
this.compiler = e;
|
|
3931
3977
|
}
|
|
@@ -3952,7 +3998,7 @@ class Gt {
|
|
|
3952
3998
|
return [];
|
|
3953
3999
|
}
|
|
3954
4000
|
}
|
|
3955
|
-
class
|
|
4001
|
+
class Xt {
|
|
3956
4002
|
constructor(e) {
|
|
3957
4003
|
this.compiler = e;
|
|
3958
4004
|
}
|
|
@@ -3981,21 +4027,21 @@ class Ct {
|
|
|
3981
4027
|
return [];
|
|
3982
4028
|
}
|
|
3983
4029
|
}
|
|
3984
|
-
const
|
|
4030
|
+
const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3985
4031
|
__proto__: null,
|
|
3986
|
-
CompletionItemInsertTextRule:
|
|
4032
|
+
CompletionItemInsertTextRule: y,
|
|
3987
4033
|
CompletionItemKind: L,
|
|
3988
|
-
DBMLCompletionItemProvider:
|
|
3989
|
-
DBMLDefinitionProvider:
|
|
3990
|
-
DBMLReferencesProvider:
|
|
4034
|
+
DBMLCompletionItemProvider: Ft,
|
|
4035
|
+
DBMLDefinitionProvider: Ct,
|
|
4036
|
+
DBMLReferencesProvider: Xt
|
|
3991
4037
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3992
4038
|
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 || {});
|
|
3993
|
-
class
|
|
4039
|
+
class ls {
|
|
3994
4040
|
constructor() {
|
|
3995
4041
|
this.source = "", this.cache = new Array(
|
|
3996
4042
|
16
|
|
3997
4043
|
/* TOTAL_QUERY_COUNT */
|
|
3998
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4044
|
+
).fill(null), this.nodeIdGenerator = new jt(), this.symbolIdGenerator = new Ht(), this.token = {
|
|
3999
4045
|
invalidStream: this.createQuery(
|
|
4000
4046
|
6,
|
|
4001
4047
|
() => this.parse.tokens().filter(At)
|
|
@@ -4010,8 +4056,8 @@ class as {
|
|
|
4010
4056
|
_: this.createQuery(
|
|
4011
4057
|
0,
|
|
4012
4058
|
() => {
|
|
4013
|
-
const e = new
|
|
4014
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new
|
|
4059
|
+
const e = new on(this.source).lex().chain((n) => new un(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4060
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new qn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4015
4061
|
}
|
|
4016
4062
|
),
|
|
4017
4063
|
ast: this.createQuery(
|
|
@@ -4048,23 +4094,23 @@ class as {
|
|
|
4048
4094
|
let a = this.parse.ast();
|
|
4049
4095
|
const l = [a];
|
|
4050
4096
|
for (; ; ) {
|
|
4051
|
-
const h =
|
|
4097
|
+
const h = an(a).find((T) => Le(r, T));
|
|
4052
4098
|
if (h === void 0 || h instanceof B)
|
|
4053
4099
|
break;
|
|
4054
4100
|
l.push(h), a = h;
|
|
4055
4101
|
}
|
|
4056
|
-
if ((i == null ? void 0 : i.kind) ===
|
|
4102
|
+
if ((i == null ? void 0 : i.kind) === u.COLON)
|
|
4057
4103
|
return l;
|
|
4058
4104
|
for (; l.length > 0; ) {
|
|
4059
4105
|
let p = !1;
|
|
4060
4106
|
const h = I.last(l);
|
|
4061
|
-
if (h instanceof
|
|
4107
|
+
if (h instanceof w) {
|
|
4062
4108
|
const T = this.parse.source();
|
|
4063
4109
|
for (let f = h.end; f < e; f += 1)
|
|
4064
4110
|
T[f] === `
|
|
4065
4111
|
` && (l.pop(), p = !0);
|
|
4066
4112
|
} else
|
|
4067
|
-
h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof
|
|
4113
|
+
h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof $ || h.end < e && (l.pop(), p = !0);
|
|
4068
4114
|
if (p) {
|
|
4069
4115
|
const T = I.last(l);
|
|
4070
4116
|
T instanceof A && T.end <= e && l.pop();
|
|
@@ -4104,7 +4150,7 @@ class as {
|
|
|
4104
4150
|
),
|
|
4105
4151
|
scopeKind: this.createQuery(15, (e) => {
|
|
4106
4152
|
var s;
|
|
4107
|
-
if (this.container.element(e) instanceof
|
|
4153
|
+
if (this.container.element(e) instanceof G)
|
|
4108
4154
|
return 8;
|
|
4109
4155
|
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4110
4156
|
case "table":
|
|
@@ -4147,7 +4193,7 @@ class as {
|
|
|
4147
4193
|
let l = [a], p = [];
|
|
4148
4194
|
for (const h of e)
|
|
4149
4195
|
p = l.flatMap(
|
|
4150
|
-
(T) =>
|
|
4196
|
+
(T) => Qt(h).flatMap((f) => {
|
|
4151
4197
|
const N = T.get(f), g = ie(f).unwrap_or(void 0);
|
|
4152
4198
|
return !N || !g ? [] : { ...g, symbol: N };
|
|
4153
4199
|
})
|
|
@@ -4190,14 +4236,14 @@ class as {
|
|
|
4190
4236
|
}
|
|
4191
4237
|
initMonacoServices() {
|
|
4192
4238
|
return {
|
|
4193
|
-
definitionProvider: new
|
|
4194
|
-
referenceProvider: new
|
|
4195
|
-
autocompletionProvider: new
|
|
4239
|
+
definitionProvider: new Ct(this),
|
|
4240
|
+
referenceProvider: new Xt(this),
|
|
4241
|
+
autocompletionProvider: new Ft(this)
|
|
4196
4242
|
};
|
|
4197
4243
|
}
|
|
4198
4244
|
}
|
|
4199
4245
|
export {
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4246
|
+
ls as Compiler,
|
|
4247
|
+
as as serialize,
|
|
4248
|
+
os as services
|
|
4203
4249
|
};
|