@dbml/parse 3.1.6 → 3.1.8-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 +875 -827
- 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>":
|
|
@@ -36,22 +36,22 @@ function it(t) {
|
|
|
36
36
|
function rt(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class V {
|
|
40
40
|
constructor(e, n, s, i, r) {
|
|
41
41
|
this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
|
|
42
42
|
}
|
|
43
43
|
static create(e, n, s, i, r) {
|
|
44
|
-
return new
|
|
44
|
+
return new V(e, n, s, i, r);
|
|
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,32 +75,32 @@ 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) {
|
|
82
82
|
this.id = e, this.kind = n;
|
|
83
83
|
const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof V ? It(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof V ? bt(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
94
94
|
}, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
var
|
|
98
|
-
class
|
|
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 F 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
|
|
103
|
+
class A extends k {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -118,17 +118,17 @@ class _ 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
|
|
131
|
+
class se extends k {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: n,
|
|
@@ -137,12 +137,12 @@ class ne 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
|
|
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
|
|
145
|
+
class H extends k {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,22 +151,22 @@ class q extends y {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class 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
|
|
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
|
|
169
|
+
class ne extends k {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -175,7 +175,7 @@ class te extends y {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class 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
|
|
192
|
+
class Z extends k {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -203,7 +203,7 @@ class J extends y {
|
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class Xe extends
|
|
206
|
+
class Xe extends Z {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -220,7 +220,7 @@ class Xe extends J {
|
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class
|
|
223
|
+
class J extends k {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: n
|
|
@@ -228,28 +228,28 @@ class H extends y {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class 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
|
|
246
|
+
class ye extends k {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
|
-
const s =
|
|
248
|
+
const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
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 F) && 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,14 +305,14 @@ 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() {
|
|
312
312
|
return !0;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class v {
|
|
316
316
|
// eslint-disable-next-line class-methods-use-this
|
|
317
317
|
unwrap() {
|
|
318
318
|
throw new Error("Trying to unwrap a None value");
|
|
@@ -323,22 +323,22 @@ class A {
|
|
|
323
323
|
}
|
|
324
324
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
|
325
325
|
and_then(e) {
|
|
326
|
-
return new
|
|
326
|
+
return new v();
|
|
327
327
|
}
|
|
328
328
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
|
329
329
|
map(e) {
|
|
330
|
-
return new
|
|
330
|
+
return new v();
|
|
331
331
|
}
|
|
332
332
|
// eslint-disable-next-line class-methods-use-this
|
|
333
333
|
isOk() {
|
|
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
|
}
|
|
341
|
-
function
|
|
341
|
+
function xe(t) {
|
|
342
342
|
return `Table:${t}`;
|
|
343
343
|
}
|
|
344
344
|
function We(t) {
|
|
@@ -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":
|
|
@@ -367,7 +370,7 @@ function Fe(t, e) {
|
|
|
367
370
|
case "Schema":
|
|
368
371
|
return $e(t);
|
|
369
372
|
case "Table":
|
|
370
|
-
return
|
|
373
|
+
return xe(t);
|
|
371
374
|
case "TableGroup":
|
|
372
375
|
return ze(t);
|
|
373
376
|
case "TableGroup field":
|
|
@@ -376,24 +379,24 @@ function Fe(t, e) {
|
|
|
376
379
|
throw new Error("Unreachable");
|
|
377
380
|
}
|
|
378
381
|
}
|
|
379
|
-
function
|
|
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
|
-
}) : new
|
|
387
|
+
}) : new v();
|
|
385
388
|
}
|
|
386
|
-
function
|
|
387
|
-
const e =
|
|
389
|
+
function zt(t) {
|
|
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,
|
|
397
400
|
je,
|
|
398
401
|
ze,
|
|
399
402
|
We,
|
|
@@ -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
|
-
function
|
|
417
|
-
return qe(t) ||
|
|
419
|
+
function pe(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,28 +459,28 @@ 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
|
-
class
|
|
483
|
+
class B {
|
|
481
484
|
constructor(e, n) {
|
|
482
485
|
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
483
486
|
}
|
|
@@ -489,21 +492,21 @@ class F {
|
|
|
489
492
|
}
|
|
490
493
|
chain(e) {
|
|
491
494
|
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
492
|
-
return new
|
|
495
|
+
return new B(n.value, s);
|
|
493
496
|
}
|
|
494
497
|
map(e) {
|
|
495
|
-
return new
|
|
498
|
+
return new B(e(this.value), this.errors);
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
|
-
function
|
|
499
|
-
if (!t || !
|
|
500
|
-
return new
|
|
501
|
+
function nn(t, e, n) {
|
|
502
|
+
if (!t || !Ee(t) || e.length === 0)
|
|
503
|
+
return new v();
|
|
501
504
|
const s = [...e], i = Be(t).unwrap(), r = s.pop();
|
|
502
|
-
if (!(r instanceof
|
|
503
|
-
return new
|
|
505
|
+
if (!(r instanceof ne))
|
|
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
|
|
506
|
-
n.create(
|
|
508
|
+
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
|
|
509
|
+
n.create(A, {
|
|
507
510
|
type: i,
|
|
508
511
|
name: s[0],
|
|
509
512
|
as: Be(s[1]).unwrap(),
|
|
@@ -511,60 +514,60 @@ function en(t, e, n) {
|
|
|
511
514
|
attributeList: a,
|
|
512
515
|
body: r
|
|
513
516
|
})
|
|
514
|
-
) : s.length === 1 ? new
|
|
515
|
-
n.create(
|
|
517
|
+
) : s.length === 1 ? new S(
|
|
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
|
|
522
|
-
n.create(
|
|
524
|
+
) : s.length === 0 ? new S(
|
|
525
|
+
n.create(A, {
|
|
523
526
|
type: i,
|
|
524
527
|
attributeList: a,
|
|
525
528
|
body: r
|
|
526
529
|
})
|
|
527
|
-
) : new
|
|
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
|
|
536
|
+
t && (t instanceof V ? 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
|
|
539
|
-
if (t instanceof
|
|
541
|
+
function rn(t) {
|
|
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
|
-
else if (t instanceof
|
|
546
|
+
else if (t instanceof se)
|
|
544
547
|
E(t.name), E(t.colon), E(t.value);
|
|
545
|
-
else if (t instanceof Q)
|
|
546
|
-
E(t.op), E(t.expression);
|
|
547
548
|
else if (t instanceof q)
|
|
549
|
+
E(t.op), E(t.expression);
|
|
550
|
+
else if (t instanceof H)
|
|
548
551
|
E(t.leftExpression), E(t.op), E(t.rightExpression);
|
|
549
|
-
else if (t instanceof
|
|
552
|
+
else if (t instanceof De)
|
|
550
553
|
E(t.op), E(t.expression);
|
|
551
|
-
else if (t instanceof
|
|
554
|
+
else if (t instanceof ne)
|
|
552
555
|
E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
|
|
553
556
|
else if (t instanceof P)
|
|
554
557
|
E(t.listOpenBracket), t.commaList.forEach(E), t.elementList.forEach(E), E(t.listCloseBracket);
|
|
555
|
-
else if (t instanceof
|
|
558
|
+
else if (t instanceof Z)
|
|
556
559
|
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
557
|
-
else if (t instanceof
|
|
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
|
-
else if (t instanceof
|
|
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
|
-
else if (t instanceof
|
|
570
|
+
else if (t instanceof me)
|
|
568
571
|
E(t.literal);
|
|
569
572
|
else
|
|
570
573
|
throw t instanceof Xe ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
@@ -575,10 +578,10 @@ 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 F)
|
|
580
583
|
return U(...t.body, t.eof);
|
|
581
|
-
if (t instanceof
|
|
584
|
+
if (t instanceof A)
|
|
582
585
|
return U(
|
|
583
586
|
t.type,
|
|
584
587
|
t.name,
|
|
@@ -588,25 +591,25 @@ function sn(t) {
|
|
|
588
591
|
t.bodyColon,
|
|
589
592
|
t.body
|
|
590
593
|
);
|
|
591
|
-
if (t instanceof
|
|
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
|
-
if (t instanceof
|
|
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
|
-
if (t instanceof Q)
|
|
600
|
-
return U(t.op, t.expression);
|
|
601
602
|
if (t instanceof q)
|
|
603
|
+
return U(t.op, t.expression);
|
|
604
|
+
if (t instanceof H)
|
|
602
605
|
return U(t.leftExpression, t.op, t.rightExpression);
|
|
603
|
-
if (t instanceof
|
|
606
|
+
if (t instanceof De)
|
|
604
607
|
return U(t.expression, t.op);
|
|
605
|
-
if (t instanceof
|
|
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
|
-
if (t instanceof
|
|
612
|
+
if (t instanceof ne)
|
|
610
613
|
return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
611
614
|
if (t instanceof P)
|
|
612
615
|
return U(
|
|
@@ -614,17 +617,17 @@ function sn(t) {
|
|
|
614
617
|
...ot(t.elementList, t.commaList),
|
|
615
618
|
t.listCloseBracket
|
|
616
619
|
);
|
|
617
|
-
if (t instanceof
|
|
620
|
+
if (t instanceof Z)
|
|
618
621
|
return U(
|
|
619
622
|
t.tupleOpenParen,
|
|
620
623
|
...ot(t.elementList, t.commaList),
|
|
621
624
|
t.tupleCloseParen
|
|
622
625
|
);
|
|
623
|
-
if (t instanceof
|
|
626
|
+
if (t instanceof J)
|
|
624
627
|
return U(t.callee, t.argumentList);
|
|
625
628
|
if (t instanceof D)
|
|
626
629
|
return U(t.expression);
|
|
627
|
-
if (t instanceof
|
|
630
|
+
if (t instanceof ce)
|
|
628
631
|
return U(
|
|
629
632
|
t.array,
|
|
630
633
|
t.indexer
|
|
@@ -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 V && 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 V;
|
|
643
646
|
}
|
|
644
|
-
function
|
|
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
|
|
653
|
+
return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
651
654
|
}
|
|
652
|
-
function
|
|
655
|
+
function Ne(t) {
|
|
653
656
|
if (t === void 0)
|
|
654
|
-
return new
|
|
657
|
+
return new v();
|
|
655
658
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
656
|
-
return e === "" ? 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 = {
|
|
@@ -695,7 +698,7 @@ class rn {
|
|
|
695
698
|
this.tokens.push(this.createToken(e, n));
|
|
696
699
|
}
|
|
697
700
|
createToken(e, n = !1) {
|
|
698
|
-
return
|
|
701
|
+
return V.create(
|
|
699
702
|
e,
|
|
700
703
|
this.start,
|
|
701
704
|
this.current,
|
|
@@ -704,50 +707,50 @@ class rn {
|
|
|
704
707
|
);
|
|
705
708
|
}
|
|
706
709
|
lex() {
|
|
707
|
-
return this.scanTokens(), this.tokens.push(
|
|
710
|
+
return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(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
|
|
@@ -841,38 +844,38 @@ class rn {
|
|
|
841
844
|
);
|
|
842
845
|
return;
|
|
843
846
|
}
|
|
844
|
-
a && this.match(n), this.tokens.push(
|
|
847
|
+
a && this.match(n), this.tokens.push(V.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,55 +884,55 @@ 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
|
|
888
891
|
});
|
|
889
892
|
}
|
|
890
893
|
identifier() {
|
|
891
|
-
for (; !this.isAtEnd() &&
|
|
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(
|
|
911
|
-
if (!n && !
|
|
912
|
-
return this.addToken(
|
|
913
|
-
if (!n && !
|
|
913
|
+
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
914
|
+
if (!n && !pe(this.peek()))
|
|
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
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
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
|
-
for (; !this.isAtEnd() &&
|
|
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
|
-
for (; !this.isAtEnd() &&
|
|
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())
|
|
@@ -959,7 +962,7 @@ class rn {
|
|
|
959
962
|
case "u": {
|
|
960
963
|
let e = "";
|
|
961
964
|
for (let n = 0; n <= 3; n += 1) {
|
|
962
|
-
if (this.isAtEnd() || !
|
|
965
|
+
if (this.isAtEnd() || !pe(this.peek()))
|
|
963
966
|
return `\\u${e}`;
|
|
964
967
|
e += this.advance();
|
|
965
968
|
}
|
|
@@ -970,8 +973,8 @@ class rn {
|
|
|
970
973
|
}
|
|
971
974
|
}
|
|
972
975
|
}
|
|
973
|
-
var
|
|
974
|
-
class
|
|
976
|
+
var ke = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ke || {});
|
|
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
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1073
|
-
const s = { body: [] }, i = () => this.nodeFactory.create(
|
|
1075
|
+
}, this.blockExpression = this.contextStack.withContextDo(ke.BlockExpression, () => {
|
|
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,21 +1104,21 @@ 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
|
}
|
|
1111
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1114
|
+
}, this.tupleExpression = this.contextStack.withContextDo(ke.GroupExpression, () => {
|
|
1112
1115
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Xe, {
|
|
1113
1116
|
groupOpenParen: s.tupleOpenParen,
|
|
1114
1117
|
groupCloseParen: s.tupleCloseParen,
|
|
1115
1118
|
expression: s.elementList[0]
|
|
1116
|
-
}), r = () => this.nodeFactory.create(
|
|
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
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
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,8 +1281,8 @@ class ln {
|
|
|
1278
1281
|
this.tokens = e;
|
|
1279
1282
|
}
|
|
1280
1283
|
parse() {
|
|
1281
|
-
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(
|
|
1282
|
-
return this.gatherInvalid(), new
|
|
1284
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(F, { body: e, eof: n });
|
|
1285
|
+
return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
|
|
1283
1286
|
}
|
|
1284
1287
|
/* Parsing and synchronizing ProgramNode */
|
|
1285
1288
|
program() {
|
|
@@ -1297,13 +1300,13 @@ class ln {
|
|
|
1297
1300
|
}
|
|
1298
1301
|
/* Parsing and synchronizing top-level ElementDeclarationNode */
|
|
1299
1302
|
elementDeclaration() {
|
|
1300
|
-
const e = {}, n = () => this.nodeFactory.create(
|
|
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,27 +1330,27 @@ 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
|
-
s instanceof
|
|
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;
|
|
1345
1348
|
} else
|
|
1346
1349
|
e.body = this.blockExpression();
|
|
1347
1350
|
} catch (s) {
|
|
1348
1351
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1349
1352
|
}
|
|
1350
|
-
return this.nodeFactory.create(
|
|
1353
|
+
return this.nodeFactory.create(A, e);
|
|
1351
1354
|
}
|
|
1352
1355
|
/* Parsing nested element declarations with simple body */
|
|
1353
1356
|
// e.g
|
|
@@ -1356,29 +1359,29 @@ class ln {
|
|
|
1356
1359
|
// Note: 'This is a note' // fieldDeclaration() handles this
|
|
1357
1360
|
// }
|
|
1358
1361
|
fieldDeclaration() {
|
|
1359
|
-
const e = {}, n = () => this.nodeFactory.create(
|
|
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
|
|
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
|
}
|
|
1376
|
-
return this.nodeFactory.create(
|
|
1379
|
+
return this.nodeFactory.create(A, e);
|
|
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
|
|
@@ -1421,26 +1424,26 @@ class ln {
|
|
|
1421
1424
|
at(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1422
1425
|
break;
|
|
1423
1426
|
try {
|
|
1424
|
-
n = this.nodeFactory.create(
|
|
1427
|
+
n = this.nodeFactory.create(J, {
|
|
1425
1428
|
callee: n,
|
|
1426
1429
|
argumentList: this.tupleExpression()
|
|
1427
1430
|
});
|
|
1428
1431
|
} catch (r) {
|
|
1429
|
-
throw r instanceof d ? (n = this.nodeFactory.create(
|
|
1432
|
+
throw r instanceof d ? (n = this.nodeFactory.create(J, {
|
|
1430
1433
|
callee: n,
|
|
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 {
|
|
1438
|
-
n = this.nodeFactory.create(
|
|
1441
|
+
n = this.nodeFactory.create(ce, {
|
|
1439
1442
|
expression: n,
|
|
1440
1443
|
indexer: this.listExpression()
|
|
1441
1444
|
});
|
|
1442
1445
|
} catch (i) {
|
|
1443
|
-
throw i instanceof d ? (n = this.nodeFactory.create(
|
|
1446
|
+
throw i instanceof d ? (n = this.nodeFactory.create(ce, {
|
|
1444
1447
|
expression: n,
|
|
1445
1448
|
indexer: i.partialNode
|
|
1446
1449
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
@@ -1450,23 +1453,23 @@ class ln {
|
|
|
1450
1453
|
if (r.left !== null) {
|
|
1451
1454
|
if (r.left <= e)
|
|
1452
1455
|
break;
|
|
1453
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1456
|
+
this.advance(), n = this.nodeFactory.create(De, {
|
|
1454
1457
|
expression: n,
|
|
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();
|
|
1462
1465
|
try {
|
|
1463
|
-
n = this.nodeFactory.create(
|
|
1466
|
+
n = this.nodeFactory.create(H, {
|
|
1464
1467
|
leftExpression: n,
|
|
1465
1468
|
op: i,
|
|
1466
1469
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1467
1470
|
});
|
|
1468
1471
|
} catch (l) {
|
|
1469
|
-
throw l instanceof d ? (n = this.nodeFactory.create(
|
|
1472
|
+
throw l instanceof d ? (n = this.nodeFactory.create(H, {
|
|
1470
1473
|
leftExpression: n,
|
|
1471
1474
|
op: i,
|
|
1472
1475
|
rightExpression: l.partialNode
|
|
@@ -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,
|
|
@@ -1491,7 +1494,7 @@ class ln {
|
|
|
1491
1494
|
`Unexpected '${n.op.value}' in an expression`
|
|
1492
1495
|
), new d(
|
|
1493
1496
|
n.op,
|
|
1494
|
-
this.nodeFactory.create(
|
|
1497
|
+
this.nodeFactory.create(ye, { pre: n.op }),
|
|
1495
1498
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1496
1499
|
);
|
|
1497
1500
|
this.advance();
|
|
@@ -1500,15 +1503,15 @@ class ln {
|
|
|
1500
1503
|
} catch (i) {
|
|
1501
1504
|
throw i instanceof d ? (n.expression = i.partialNode, new d(
|
|
1502
1505
|
i.token,
|
|
1503
|
-
this.nodeFactory.create(
|
|
1506
|
+
this.nodeFactory.create(q, n),
|
|
1504
1507
|
i.handlerContext
|
|
1505
1508
|
)) : i;
|
|
1506
1509
|
}
|
|
1507
|
-
e = this.nodeFactory.create(
|
|
1508
|
-
} else if (e = this.extractOperand(), e instanceof
|
|
1510
|
+
e = this.nodeFactory.create(q, n);
|
|
1511
|
+
} else if (e = this.extractOperand(), e instanceof ye)
|
|
1509
1512
|
throw new d(
|
|
1510
1513
|
this.peek(),
|
|
1511
|
-
this.nodeFactory.create(
|
|
1514
|
+
this.nodeFactory.create(ye, { pre: this.peek() }),
|
|
1512
1515
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1513
1516
|
);
|
|
1514
1517
|
return e;
|
|
@@ -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"
|
|
@@ -1532,56 +1535,56 @@ class ln {
|
|
|
1532
1535
|
this.peek(),
|
|
1533
1536
|
o.INVALID_OPERAND,
|
|
1534
1537
|
`Invalid start of operand "${this.peek().value}"`
|
|
1535
|
-
), this.nodeFactory.create(
|
|
1538
|
+
), this.nodeFactory.create(ye, { pre: this.previous() }));
|
|
1536
1539
|
}
|
|
1537
1540
|
/* Parsing FunctionExpression */
|
|
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,
|
|
1545
|
-
this.nodeFactory.create(
|
|
1548
|
+
this.nodeFactory.create(te, e),
|
|
1546
1549
|
n.handlerContext
|
|
1547
1550
|
)) : n;
|
|
1548
1551
|
}
|
|
1549
|
-
return this.nodeFactory.create(
|
|
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
|
-
expression: this.nodeFactory.create(
|
|
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();
|
|
@@ -1591,17 +1594,17 @@ class ln {
|
|
|
1591
1594
|
if (e.name = n.partialNode, !this.canHandle(n))
|
|
1592
1595
|
throw new d(
|
|
1593
1596
|
n.token,
|
|
1594
|
-
this.nodeFactory.create(
|
|
1597
|
+
this.nodeFactory.create(se, e),
|
|
1595
1598
|
n.handlerContext
|
|
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,111 +1680,111 @@ function ge(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
|
-
return new
|
|
1685
|
+
return new v();
|
|
1683
1686
|
}
|
|
1684
1687
|
}
|
|
1685
|
-
function
|
|
1688
|
+
function he(t) {
|
|
1686
1689
|
if (!He(t))
|
|
1687
|
-
return new
|
|
1688
|
-
const e =
|
|
1689
|
-
return e ? (e.push(t.rightExpression), new
|
|
1690
|
+
return new S([t]);
|
|
1691
|
+
const e = he(t.leftExpression).unwrap_or(void 0);
|
|
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
|
-
return new
|
|
1694
|
-
const e =
|
|
1696
|
+
return new v();
|
|
1697
|
+
const e = he(t).unwrap_or(void 0);
|
|
1695
1698
|
if (!e)
|
|
1696
|
-
return new
|
|
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
|
-
return new
|
|
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
|
-
return new
|
|
1709
|
-
const e =
|
|
1711
|
+
return new v();
|
|
1712
|
+
const e = he(t).unwrap_or(void 0);
|
|
1710
1713
|
if (!e || e.length === 0)
|
|
1711
|
-
return new
|
|
1714
|
+
return new v();
|
|
1712
1715
|
const n = [];
|
|
1713
1716
|
let s;
|
|
1714
1717
|
if (!M(I.last(e))) {
|
|
1715
1718
|
const i = e.pop();
|
|
1716
1719
|
if (yt(i))
|
|
1717
1720
|
s = i.elementList.map(
|
|
1718
|
-
(r) =>
|
|
1721
|
+
(r) => G(r).unwrap()
|
|
1719
1722
|
);
|
|
1720
1723
|
else
|
|
1721
|
-
return new
|
|
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
|
-
return new
|
|
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
|
|
1740
|
-
if (t instanceof
|
|
1742
|
+
return t instanceof te ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1743
|
+
if (t instanceof Z && t.elementList.every(ut)) {
|
|
1741
1744
|
const e = t.elementList.filter(
|
|
1742
|
-
(s) => s instanceof
|
|
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
|
-
return new
|
|
1749
|
+
return new v();
|
|
1747
1750
|
}
|
|
1748
|
-
function
|
|
1751
|
+
function G(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
|
|
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
|
|
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 F && s)
|
|
1778
1781
|
return n.symbol;
|
|
1779
|
-
if (n instanceof
|
|
1782
|
+
if (n instanceof F)
|
|
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 F || 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
|
-
if (e instanceof
|
|
1807
|
-
return [new
|
|
1809
|
+
if (e instanceof ne)
|
|
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 _e {
|
|
|
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
|
|
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;
|
|
@@ -1891,20 +1894,20 @@ class Tn {
|
|
|
1891
1894
|
return e.flatMap((n) => {
|
|
1892
1895
|
if (n.parent = this.declarationNode, !n.type)
|
|
1893
1896
|
return [];
|
|
1894
|
-
const s =
|
|
1897
|
+
const s = re(n);
|
|
1895
1898
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1896
1899
|
});
|
|
1897
1900
|
}
|
|
1898
1901
|
registerField(e) {
|
|
1899
1902
|
if (e.callee && M(e.callee)) {
|
|
1900
|
-
const n =
|
|
1903
|
+
const n = G(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 F || 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) {
|
|
@@ -1945,36 +1948,36 @@ class bn {
|
|
|
1945
1948
|
return [];
|
|
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
|
-
for (; r instanceof
|
|
1949
|
-
r.argumentList && !Ge(r.argumentList).isOk() && s.push(new
|
|
1950
|
-
Ge(r).isOk() || s.push(new
|
|
1951
|
+
for (; r instanceof J; )
|
|
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
|
-
|
|
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;
|
|
@@ -1983,12 +1986,12 @@ class bn {
|
|
|
1983
1986
|
return e.flatMap((n) => {
|
|
1984
1987
|
if (n.parent = this.declarationNode, !n.type)
|
|
1985
1988
|
return [];
|
|
1986
|
-
const s =
|
|
1989
|
+
const s = re(n);
|
|
1987
1990
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
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,39 +1999,47 @@ 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 F) && ![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 F))
|
|
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 [];
|
|
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 && !(this.declarationNode.parent instanceof F) ? [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) => {
|
|
2024
2035
|
if (n.parent = this.declarationNode, !n.type)
|
|
2025
2036
|
return [];
|
|
2026
|
-
const s =
|
|
2037
|
+
const s = re(n);
|
|
2027
2038
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
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
|
|
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
|
}
|
|
@@ -2062,12 +2073,12 @@ class Ln {
|
|
|
2062
2073
|
return e.flatMap((n) => {
|
|
2063
2074
|
if (n.parent = this.declarationNode, !n.type)
|
|
2064
2075
|
return [];
|
|
2065
|
-
const s =
|
|
2076
|
+
const s = re(n);
|
|
2066
2077
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
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 F ? [] : [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;
|
|
@@ -2125,16 +2136,16 @@ class gn {
|
|
|
2125
2136
|
return e.flatMap((n) => {
|
|
2126
2137
|
if (n.parent = this.declarationNode, !n.type)
|
|
2127
2138
|
return [];
|
|
2128
|
-
const s =
|
|
2139
|
+
const s = re(n);
|
|
2129
2140
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
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
|
|
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
|
|
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
|
-
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p =
|
|
2193
|
-
l.has(p) && e.push(new
|
|
2203
|
+
const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
|
|
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) && !
|
|
2196
|
-
const r =
|
|
2197
|
-
this.publicSymbolTable.has(a) && e.push(new
|
|
2206
|
+
if (s && Pe(s) && !kn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2207
|
+
const r = G(s).unwrap(), a = xe(r);
|
|
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 =
|
|
2232
|
+
const n = G(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);
|
|
@@ -2234,75 +2245,75 @@ class An {
|
|
|
2234
2245
|
}
|
|
2235
2246
|
// This is needed to support legacy inline settings
|
|
2236
2247
|
validateFieldSetting(e) {
|
|
2237
|
-
if (!e.slice(0, -1).every(
|
|
2238
|
-
return [...e.map((p) => new
|
|
2248
|
+
if (!e.slice(0, -1).every(Ee) || !e.slice(-1).every((p) => Ee(p) || p instanceof P))
|
|
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
|
-
const h =
|
|
2256
|
+
const h = G(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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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;
|
|
@@ -2311,35 +2322,35 @@ class An {
|
|
|
2311
2322
|
const n = e.flatMap((i) => {
|
|
2312
2323
|
if (i.parent = this.declarationNode, !i.type)
|
|
2313
2324
|
return [];
|
|
2314
|
-
const r =
|
|
2325
|
+
const r = re(i);
|
|
2315
2326
|
return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2316
2327
|
}), s = e.filter((i) => {
|
|
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
|
|
2324
|
-
if (!(t instanceof
|
|
2334
|
+
function yn(t) {
|
|
2335
|
+
if (!(t instanceof J || He(t) || t instanceof D || t instanceof ce))
|
|
2325
2336
|
return !1;
|
|
2326
|
-
if (t instanceof
|
|
2327
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2337
|
+
if (t instanceof J) {
|
|
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
|
}
|
|
2331
|
-
for (; t instanceof
|
|
2332
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value &&
|
|
2342
|
+
for (; t instanceof ce; ) {
|
|
2343
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ue(n.name)))
|
|
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,61 +2358,61 @@ 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
|
|
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) {
|
|
2388
2399
|
return e.flatMap((n) => {
|
|
2389
2400
|
if (n.parent = this.declarationNode, !n.type)
|
|
2390
2401
|
return [];
|
|
2391
|
-
const s =
|
|
2402
|
+
const s = re(n);
|
|
2392
2403
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2393
2404
|
});
|
|
2394
2405
|
}
|
|
2395
2406
|
registerField(e) {
|
|
2396
2407
|
if (e.callee && M(e.callee)) {
|
|
2397
|
-
const n =
|
|
2408
|
+
const n = G(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);
|
|
@@ -2410,34 +2421,34 @@ class yn {
|
|
|
2410
2421
|
}
|
|
2411
2422
|
}
|
|
2412
2423
|
const vt = ["-", "+"];
|
|
2413
|
-
function
|
|
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,60 +2472,60 @@ 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
|
|
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
|
-
function
|
|
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
|
-
function
|
|
2494
|
+
function ue(t) {
|
|
2484
2495
|
var e;
|
|
2485
|
-
return t instanceof D && t.expression instanceof
|
|
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
|
-
if (!(t instanceof
|
|
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
|
-
return t instanceof
|
|
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)
|
|
2501
|
-
return new
|
|
2512
|
+
return new B({});
|
|
2502
2513
|
for (const i of t.elementList) {
|
|
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
|
-
const r = (s =
|
|
2520
|
+
const r = (s = Ne(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2510
2521
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2511
2522
|
}
|
|
2512
|
-
return new
|
|
2523
|
+
return new B(e, n);
|
|
2513
2524
|
}
|
|
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() {
|
|
@@ -2522,18 +2533,18 @@ class ht {
|
|
|
2522
2533
|
this.ast.body.forEach((s) => {
|
|
2523
2534
|
if (s.parent = this.ast, s.type === void 0)
|
|
2524
2535
|
return;
|
|
2525
|
-
const i =
|
|
2536
|
+
const i = re(s), r = new i(
|
|
2526
2537
|
s,
|
|
2527
2538
|
this.publicSchemaSymbol.symbolTable,
|
|
2528
2539
|
this.symbolFactory
|
|
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 B(this.ast, e);
|
|
2534
2545
|
}
|
|
2535
2546
|
}
|
|
2536
|
-
class
|
|
2547
|
+
class ae {
|
|
2537
2548
|
constructor(e, n) {
|
|
2538
2549
|
this.declarationNode = e, this.errors = n;
|
|
2539
2550
|
}
|
|
@@ -2545,7 +2556,7 @@ class re {
|
|
|
2545
2556
|
for (const s of e.elementList) {
|
|
2546
2557
|
if (s.name instanceof D)
|
|
2547
2558
|
continue;
|
|
2548
|
-
const i =
|
|
2559
|
+
const i = Ne(s.name).unwrap_or(void 0);
|
|
2549
2560
|
if (!i)
|
|
2550
2561
|
continue;
|
|
2551
2562
|
const r = n[i.toLowerCase()];
|
|
@@ -2557,9 +2568,9 @@ class re {
|
|
|
2557
2568
|
if (!e.body)
|
|
2558
2569
|
return;
|
|
2559
2570
|
const { body: n } = e;
|
|
2560
|
-
if (n instanceof
|
|
2571
|
+
if (n instanceof ne)
|
|
2561
2572
|
for (const s of n.body)
|
|
2562
|
-
if (s instanceof
|
|
2573
|
+
if (s instanceof A) {
|
|
2563
2574
|
if (!s.type)
|
|
2564
2575
|
continue;
|
|
2565
2576
|
const i = kt(s);
|
|
@@ -2581,11 +2592,11 @@ class re {
|
|
|
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
|
|
2588
|
-
e instanceof
|
|
2599
|
+
e instanceof H ? He(e) ? this.bindFragments(he(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof Z && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2589
2600
|
}
|
|
2590
2601
|
// Bind the fragments of a member access expression
|
|
2591
2602
|
// which can be a simple expression like v1.User,
|
|
@@ -2601,14 +2612,14 @@ class re {
|
|
|
2601
2612
|
return;
|
|
2602
2613
|
const T = [];
|
|
2603
2614
|
for (; s.length && h.length; ) {
|
|
2604
|
-
const f = s.pop(), N = h.pop(), g =
|
|
2615
|
+
const f = s.pop(), N = h.pop(), g = G(N).unwrap();
|
|
2605
2616
|
T.unshift({
|
|
2606
2617
|
index: Fe(g, f),
|
|
2607
2618
|
referrer: N
|
|
2608
2619
|
});
|
|
2609
2620
|
}
|
|
2610
2621
|
for (; h.length; ) {
|
|
2611
|
-
const f = h.pop(), N =
|
|
2622
|
+
const f = h.pop(), N = G(f).unwrap();
|
|
2612
2623
|
T.unshift({
|
|
2613
2624
|
index: Fe(N, i),
|
|
2614
2625
|
referrer: f
|
|
@@ -2620,7 +2631,7 @@ class re {
|
|
|
2620
2631
|
...T,
|
|
2621
2632
|
{
|
|
2622
2633
|
index: Fe(
|
|
2623
|
-
|
|
2634
|
+
G(f).unwrap(),
|
|
2624
2635
|
p
|
|
2625
2636
|
),
|
|
2626
2637
|
referrer: f
|
|
@@ -2635,16 +2646,16 @@ class re {
|
|
|
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
|
-
const { kind: h, name: T } =
|
|
2651
|
+
const { kind: h, name: T } = ie(s.index).unwrap();
|
|
2641
2652
|
this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
|
|
2642
2653
|
return;
|
|
2643
2654
|
}
|
|
2644
2655
|
r.references.push(s.referrer), s.referrer.referee = r;
|
|
2645
|
-
let a = r.symbolTable, { kind: l, name: p } =
|
|
2656
|
+
let a = r.symbolTable, { kind: l, name: p } = ie(s.index).unwrap();
|
|
2646
2657
|
for (const h of i) {
|
|
2647
|
-
const { kind: T, name: f } =
|
|
2658
|
+
const { kind: T, name: f } = ie(h.index).unwrap(), N = a.get(h.index);
|
|
2648
2659
|
if (!N) {
|
|
2649
2660
|
this.logError(
|
|
2650
2661
|
h.referrer,
|
|
@@ -2659,10 +2670,10 @@ class re {
|
|
|
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 re {
|
|
|
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 re {
|
|
|
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 re {
|
|
|
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 re {
|
|
|
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 re {
|
|
|
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 re {
|
|
|
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 re {
|
|
|
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 re {
|
|
|
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
|
}
|
|
@@ -2829,10 +2840,10 @@ class Gn {
|
|
|
2829
2840
|
const n = kt(e);
|
|
2830
2841
|
new n(e, this.errors).bind();
|
|
2831
2842
|
}
|
|
2832
|
-
return new
|
|
2843
|
+
return new B(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,21 +2851,21 @@ 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() {
|
|
2853
|
-
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2864
|
+
return new ht(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
|
|
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,
|
|
@@ -2898,17 +2909,17 @@ function x(t) {
|
|
|
2898
2909
|
}
|
|
2899
2910
|
function Ce(t) {
|
|
2900
2911
|
var n;
|
|
2901
|
-
const e = (n =
|
|
2902
|
-
return e instanceof
|
|
2912
|
+
const e = (n = he(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
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,13 +2962,13 @@ 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)
|
|
2959
2970
|
return [];
|
|
2960
|
-
const n =
|
|
2971
|
+
const n = G(e).unwrap_or(null);
|
|
2961
2972
|
return n && (this.env.aliases.push({
|
|
2962
2973
|
name: n,
|
|
2963
2974
|
kind: "table",
|
|
@@ -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":
|
|
@@ -3002,68 +3013,68 @@ class Rt {
|
|
|
3002
3013
|
interpretColumn(e) {
|
|
3003
3014
|
var a, l, p, h, T, f, N, g;
|
|
3004
3015
|
const n = [], s = {};
|
|
3005
|
-
s.name =
|
|
3006
|
-
const i =
|
|
3016
|
+
s.name = G(e.callee).unwrap();
|
|
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 =
|
|
3012
|
-
const
|
|
3013
|
-
s.note =
|
|
3014
|
-
value:
|
|
3015
|
-
token: x(
|
|
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);
|
|
3023
|
+
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3024
|
+
s.note = K && {
|
|
3025
|
+
value: Q(K.value).unwrap(),
|
|
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
|
|
3023
|
-
let
|
|
3024
|
-
if (
|
|
3025
|
-
const [
|
|
3026
|
-
|
|
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();
|
|
3034
|
+
let fe;
|
|
3035
|
+
if (ee.length === 1) {
|
|
3036
|
+
const [oe] = ee;
|
|
3037
|
+
fe = {
|
|
3027
3038
|
schemaName: this.table.schemaName,
|
|
3028
3039
|
tableName: this.table.name,
|
|
3029
|
-
fieldNames: [
|
|
3030
|
-
relation:
|
|
3031
|
-
token: x(
|
|
3040
|
+
fieldNames: [oe],
|
|
3041
|
+
relation: we.value,
|
|
3042
|
+
token: x(z)
|
|
3032
3043
|
};
|
|
3033
|
-
} else if (
|
|
3034
|
-
const [
|
|
3035
|
-
|
|
3044
|
+
} else if (ee.length === 2) {
|
|
3045
|
+
const [oe, Ie] = ee;
|
|
3046
|
+
fe = {
|
|
3036
3047
|
schemaName: null,
|
|
3037
|
-
tableName:
|
|
3038
|
-
fieldNames: [
|
|
3039
|
-
relation:
|
|
3040
|
-
token: x(
|
|
3048
|
+
tableName: oe,
|
|
3049
|
+
fieldNames: [Ie],
|
|
3050
|
+
relation: we.value,
|
|
3051
|
+
token: x(z)
|
|
3041
3052
|
};
|
|
3042
|
-
} else if (
|
|
3043
|
-
const [
|
|
3044
|
-
|
|
3045
|
-
schemaName:
|
|
3046
|
-
tableName:
|
|
3053
|
+
} else if (ee.length === 3) {
|
|
3054
|
+
const [oe, Ie, st] = ee;
|
|
3055
|
+
fe = {
|
|
3056
|
+
schemaName: oe,
|
|
3057
|
+
tableName: Ie,
|
|
3047
3058
|
fieldNames: [st],
|
|
3048
|
-
relation:
|
|
3049
|
-
token: x(
|
|
3059
|
+
relation: we.value,
|
|
3060
|
+
token: x(z)
|
|
3050
3061
|
};
|
|
3051
3062
|
} else {
|
|
3052
|
-
n.push(new
|
|
3053
|
-
const
|
|
3054
|
-
|
|
3055
|
-
schemaName:
|
|
3056
|
-
tableName:
|
|
3057
|
-
fieldNames: [
|
|
3058
|
-
relation:
|
|
3059
|
-
token: x(
|
|
3063
|
+
n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
|
|
3064
|
+
const oe = ee.pop(), Ie = ee.pop();
|
|
3065
|
+
fe = {
|
|
3066
|
+
schemaName: ee.join("."),
|
|
3067
|
+
tableName: Ie,
|
|
3068
|
+
fieldNames: [oe],
|
|
3069
|
+
relation: we.value,
|
|
3070
|
+
token: x(z)
|
|
3060
3071
|
};
|
|
3061
3072
|
}
|
|
3062
|
-
const nt = this.registerInlineRefToEnv(e, tt,
|
|
3063
|
-
return n.push(...nt), nt.length === 0 ?
|
|
3073
|
+
const nt = this.registerInlineRefToEnv(e, tt, fe, z);
|
|
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,30 +3083,30 @@ 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 =
|
|
3077
|
-
const
|
|
3078
|
-
s.note =
|
|
3079
|
-
value:
|
|
3080
|
-
token: x(
|
|
3081
|
-
}, s.type =
|
|
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);
|
|
3088
|
+
const _ = (T = g.note) == null ? void 0 : T.at(0);
|
|
3089
|
+
s.note = _ && {
|
|
3090
|
+
value: Q(_.value).unwrap(),
|
|
3091
|
+
token: x(_)
|
|
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
|
-
if (!(g instanceof
|
|
3095
|
+
if (!(g instanceof J))
|
|
3085
3096
|
return g;
|
|
3086
|
-
const
|
|
3087
|
-
for (; g instanceof
|
|
3088
|
-
|
|
3089
|
-
return
|
|
3097
|
+
const _ = [];
|
|
3098
|
+
for (; g instanceof J; )
|
|
3099
|
+
_.push(g.argumentList), g = g.callee;
|
|
3100
|
+
return _.push(g), _;
|
|
3090
3101
|
}).forEach((g) => {
|
|
3091
|
-
const { functional:
|
|
3102
|
+
const { functional: _, nonFunctional: K } = Ge(g).unwrap();
|
|
3092
3103
|
s.columns.push(
|
|
3093
|
-
...
|
|
3094
|
-
value:
|
|
3104
|
+
..._.map((be) => ({
|
|
3105
|
+
value: be.value.value,
|
|
3095
3106
|
type: "expression"
|
|
3096
3107
|
})),
|
|
3097
|
-
...
|
|
3098
|
-
value:
|
|
3108
|
+
...K.map((be) => ({
|
|
3109
|
+
value: G(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,52 +3141,52 @@ class Rt {
|
|
|
3130
3141
|
}), [];
|
|
3131
3142
|
}
|
|
3132
3143
|
}
|
|
3133
|
-
function
|
|
3144
|
+
function jn(t) {
|
|
3134
3145
|
let e = null;
|
|
3135
|
-
t instanceof
|
|
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
|
-
for (; t instanceof
|
|
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 } =
|
|
3140
|
-
return i.length > 1 ? new
|
|
3150
|
+
const { name: s, schemaName: i } = Te(t);
|
|
3151
|
+
return i.length > 1 ? new B(
|
|
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
|
|
3147
|
-
) : new
|
|
3157
|
+
[new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3158
|
+
) : new B({
|
|
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
|
-
if (
|
|
3172
|
+
if (ue(t))
|
|
3162
3173
|
return {
|
|
3163
3174
|
type: "number",
|
|
3164
3175
|
value: Number.parseFloat(t.expression.literal.value)
|
|
3165
3176
|
};
|
|
3166
|
-
if (
|
|
3177
|
+
if (Ee(t))
|
|
3167
3178
|
return {
|
|
3168
3179
|
value: t.expression.variable.value.toLowerCase(),
|
|
3169
3180
|
type: "boolean"
|
|
3170
3181
|
};
|
|
3171
|
-
if (t instanceof
|
|
3182
|
+
if (t instanceof q && vt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression)) {
|
|
3172
3183
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3173
3184
|
return {
|
|
3174
3185
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
3175
3186
|
type: "number"
|
|
3176
3187
|
};
|
|
3177
3188
|
}
|
|
3178
|
-
if (t instanceof
|
|
3189
|
+
if (t instanceof te)
|
|
3179
3190
|
return {
|
|
3180
3191
|
value: (s = t.value) == null ? void 0 : s.value,
|
|
3181
3192
|
type: "expression"
|
|
@@ -3183,34 +3194,67 @@ function jn(t) {
|
|
|
3183
3194
|
throw new Error("Unreachable");
|
|
3184
3195
|
}
|
|
3185
3196
|
}
|
|
3186
|
-
class
|
|
3197
|
+
class zn {
|
|
3187
3198
|
constructor(e, n) {
|
|
3188
|
-
this.declarationNode = e, this.env = n, this.
|
|
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 {
|
|
3229
|
+
constructor(e, n) {
|
|
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
|
}
|
|
3190
3232
|
interpret() {
|
|
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 =
|
|
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);
|
|
3256
|
+
const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
|
|
3257
|
+
this.ref.onUpdate = K instanceof $ ? Ne(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
|
|
3214
3258
|
}
|
|
3215
3259
|
const p = xt(n);
|
|
3216
3260
|
return this.ref.endpoints = [
|
|
@@ -3227,7 +3271,7 @@ class Dt {
|
|
|
3227
3271
|
], this.env.refIds[l] = this.declarationNode, [];
|
|
3228
3272
|
}
|
|
3229
3273
|
}
|
|
3230
|
-
class
|
|
3274
|
+
class Ut {
|
|
3231
3275
|
constructor(e, n) {
|
|
3232
3276
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3233
3277
|
}
|
|
@@ -3239,18 +3283,18 @@ class Pt {
|
|
|
3239
3283
|
), e;
|
|
3240
3284
|
}
|
|
3241
3285
|
interpretName(e) {
|
|
3242
|
-
const n = [], { name: s, schemaName: i } =
|
|
3243
|
-
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;
|
|
3244
3288
|
}
|
|
3245
3289
|
interpretBody(e) {
|
|
3246
3290
|
const n = [];
|
|
3247
3291
|
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3248
|
-
const i =
|
|
3249
|
-
i.length > 2 && n.push(new
|
|
3250
|
-
const r =
|
|
3292
|
+
const i = C(s.callee).unwrap();
|
|
3293
|
+
i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3294
|
+
const r = he(s.callee).unwrap().pop().referee.id;
|
|
3251
3295
|
if (this.env.groupOfTable[r]) {
|
|
3252
3296
|
const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), h = l ? `${l}.${p}` : p;
|
|
3253
|
-
n.push(new
|
|
3297
|
+
n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
|
|
3254
3298
|
} else
|
|
3255
3299
|
this.env.groupOfTable[r] = this.declarationNode;
|
|
3256
3300
|
return {
|
|
@@ -3260,7 +3304,7 @@ class Pt {
|
|
|
3260
3304
|
}), n;
|
|
3261
3305
|
}
|
|
3262
3306
|
}
|
|
3263
|
-
class
|
|
3307
|
+
class Mt {
|
|
3264
3308
|
constructor(e, n) {
|
|
3265
3309
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3266
3310
|
}
|
|
@@ -3268,23 +3312,23 @@ class Ut {
|
|
|
3268
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)];
|
|
3269
3313
|
}
|
|
3270
3314
|
interpretName(e) {
|
|
3271
|
-
const { name: n, schemaName: s } =
|
|
3272
|
-
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, []);
|
|
3273
3317
|
}
|
|
3274
3318
|
interpretBody(e) {
|
|
3275
3319
|
return e.body.flatMap((n) => {
|
|
3276
3320
|
var l;
|
|
3277
3321
|
const s = n, i = {};
|
|
3278
|
-
i.token = x(s), i.name =
|
|
3279
|
-
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);
|
|
3280
3324
|
return i.note = a && {
|
|
3281
|
-
value:
|
|
3325
|
+
value: Q(a.value).unwrap(),
|
|
3282
3326
|
token: x(a)
|
|
3283
3327
|
}, this.enum.values.push(i), [];
|
|
3284
3328
|
});
|
|
3285
3329
|
}
|
|
3286
3330
|
}
|
|
3287
|
-
class
|
|
3331
|
+
class Qn {
|
|
3288
3332
|
constructor(e, n) {
|
|
3289
3333
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3290
3334
|
}
|
|
@@ -3294,7 +3338,7 @@ class Yn {
|
|
|
3294
3338
|
interpretName(e) {
|
|
3295
3339
|
if (!e)
|
|
3296
3340
|
return this.project.name = null, [];
|
|
3297
|
-
const { name: n } =
|
|
3341
|
+
const { name: n } = Te(e);
|
|
3298
3342
|
return this.project.name = n, [];
|
|
3299
3343
|
}
|
|
3300
3344
|
interpretBody(e) {
|
|
@@ -3303,37 +3347,38 @@ class Yn {
|
|
|
3303
3347
|
const s = n;
|
|
3304
3348
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
3305
3349
|
case "table": {
|
|
3306
|
-
const r = new
|
|
3350
|
+
const r = new Dt(s, this.env).interpret();
|
|
3307
3351
|
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3308
3352
|
}
|
|
3309
3353
|
case "ref": {
|
|
3310
|
-
const r = new
|
|
3354
|
+
const r = new Pt(s, this.env).interpret();
|
|
3311
3355
|
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3312
3356
|
}
|
|
3313
3357
|
case "tablegroup": {
|
|
3314
|
-
const r = new
|
|
3358
|
+
const r = new Ut(s, this.env).interpret();
|
|
3315
3359
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
|
|
3316
3360
|
}
|
|
3317
3361
|
case "enum": {
|
|
3318
|
-
const r = new
|
|
3362
|
+
const r = new Mt(s, this.env).interpret();
|
|
3319
3363
|
return this.project.enums.push(this.env.enums.get(s)), r;
|
|
3320
3364
|
}
|
|
3321
3365
|
case "note":
|
|
3322
3366
|
return this.project.note = {
|
|
3323
|
-
value:
|
|
3367
|
+
value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).unwrap(),
|
|
3324
3368
|
token: x(s)
|
|
3325
3369
|
}, [];
|
|
3326
3370
|
default:
|
|
3327
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
3371
|
+
return this.project[s.type.value.toLowerCase()] = Q(s.body.callee).unwrap(), [];
|
|
3328
3372
|
}
|
|
3329
3373
|
});
|
|
3330
3374
|
}
|
|
3331
3375
|
}
|
|
3332
|
-
class
|
|
3376
|
+
class qn {
|
|
3333
3377
|
constructor(e) {
|
|
3334
3378
|
this.ast = e, this.env = {
|
|
3335
3379
|
schema: [],
|
|
3336
3380
|
tables: /* @__PURE__ */ new Map(),
|
|
3381
|
+
notes: /* @__PURE__ */ new Map(),
|
|
3337
3382
|
refIds: {},
|
|
3338
3383
|
ref: /* @__PURE__ */ new Map(),
|
|
3339
3384
|
enums: /* @__PURE__ */ new Map(),
|
|
@@ -3345,28 +3390,31 @@ class zn {
|
|
|
3345
3390
|
}
|
|
3346
3391
|
interpret() {
|
|
3347
3392
|
const e = this.ast.body.flatMap((n) => {
|
|
3348
|
-
switch (
|
|
3393
|
+
switch (Ae(n).unwrap_or(void 0)) {
|
|
3349
3394
|
case b.Table:
|
|
3350
|
-
return new Rt(n, this.env).interpret();
|
|
3351
|
-
case b.Ref:
|
|
3352
3395
|
return new Dt(n, this.env).interpret();
|
|
3353
|
-
case b.
|
|
3396
|
+
case b.Note:
|
|
3397
|
+
return new zn(n, this.env).interpret();
|
|
3398
|
+
case b.Ref:
|
|
3354
3399
|
return new Pt(n, this.env).interpret();
|
|
3355
|
-
case b.
|
|
3400
|
+
case b.TableGroup:
|
|
3356
3401
|
return new Ut(n, this.env).interpret();
|
|
3402
|
+
case b.Enum:
|
|
3403
|
+
return new Mt(n, this.env).interpret();
|
|
3357
3404
|
case b.Project:
|
|
3358
|
-
return new
|
|
3405
|
+
return new Qn(n, this.env).interpret();
|
|
3359
3406
|
default:
|
|
3360
3407
|
return [];
|
|
3361
3408
|
}
|
|
3362
3409
|
});
|
|
3363
|
-
return new
|
|
3410
|
+
return new B(Hn(this.env), e);
|
|
3364
3411
|
}
|
|
3365
3412
|
}
|
|
3366
|
-
function
|
|
3413
|
+
function Hn(t) {
|
|
3367
3414
|
return {
|
|
3368
3415
|
schemas: [],
|
|
3369
3416
|
tables: Array.from(t.tables.values()),
|
|
3417
|
+
notes: Array.from(t.notes.values()),
|
|
3370
3418
|
refs: Array.from(t.ref.values()),
|
|
3371
3419
|
enums: Array.from(t.enums.values()),
|
|
3372
3420
|
tableGroups: Array.from(t.tableGroups.values()),
|
|
@@ -3374,8 +3422,8 @@ function Qn(t) {
|
|
|
3374
3422
|
project: Array.from(t.project.values())[0] || {}
|
|
3375
3423
|
};
|
|
3376
3424
|
}
|
|
3377
|
-
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}),
|
|
3378
|
-
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) {
|
|
3379
3427
|
switch (t) {
|
|
3380
3428
|
case m.Schema:
|
|
3381
3429
|
return L.Module;
|
|
@@ -3401,17 +3449,17 @@ function Oe(t, e) {
|
|
|
3401
3449
|
for (const n of t.trailingTrivia) {
|
|
3402
3450
|
if (n.start > e)
|
|
3403
3451
|
break;
|
|
3404
|
-
if (n.kind ===
|
|
3452
|
+
if (n.kind === u.NEWLINE && n.end <= e)
|
|
3405
3453
|
return !1;
|
|
3406
3454
|
}
|
|
3407
3455
|
return !0;
|
|
3408
3456
|
}
|
|
3409
|
-
function
|
|
3457
|
+
function O() {
|
|
3410
3458
|
return {
|
|
3411
3459
|
suggestions: []
|
|
3412
3460
|
};
|
|
3413
3461
|
}
|
|
3414
|
-
function
|
|
3462
|
+
function Re(t) {
|
|
3415
3463
|
return {
|
|
3416
3464
|
...t,
|
|
3417
3465
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3432,7 +3480,7 @@ function Ue(t) {
|
|
|
3432
3480
|
function Ke(t, e) {
|
|
3433
3481
|
return t.getOffsetAt(e);
|
|
3434
3482
|
}
|
|
3435
|
-
class
|
|
3483
|
+
class Ft {
|
|
3436
3484
|
constructor(e, n = []) {
|
|
3437
3485
|
this.compiler = e, this.triggerCharacters = n;
|
|
3438
3486
|
}
|
|
@@ -3443,18 +3491,18 @@ class Mt {
|
|
|
3443
3491
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3444
3492
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3445
3493
|
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3446
|
-
].find((N) =>
|
|
3447
|
-
return
|
|
3494
|
+
].find((N) => Wt(N) && Le(s, N)))
|
|
3495
|
+
return O();
|
|
3448
3496
|
if (a === void 0)
|
|
3449
3497
|
return mt();
|
|
3450
|
-
if ([
|
|
3451
|
-
return
|
|
3498
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
|
|
3499
|
+
return O();
|
|
3452
3500
|
const p = this.compiler.container.element(s);
|
|
3453
|
-
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof
|
|
3501
|
+
if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
|
|
3454
3502
|
return mt();
|
|
3455
3503
|
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3456
3504
|
for (const N of h)
|
|
3457
|
-
if (N instanceof
|
|
3505
|
+
if (N instanceof q)
|
|
3458
3506
|
switch ((T = N.op) == null ? void 0 : T.value) {
|
|
3459
3507
|
case ">":
|
|
3460
3508
|
case "<":
|
|
@@ -3466,7 +3514,7 @@ class Mt {
|
|
|
3466
3514
|
N
|
|
3467
3515
|
);
|
|
3468
3516
|
}
|
|
3469
|
-
else if (N instanceof
|
|
3517
|
+
else if (N instanceof H)
|
|
3470
3518
|
switch ((f = N.op) == null ? void 0 : f.value) {
|
|
3471
3519
|
case ">":
|
|
3472
3520
|
case "<":
|
|
@@ -3478,25 +3526,25 @@ class Mt {
|
|
|
3478
3526
|
N
|
|
3479
3527
|
);
|
|
3480
3528
|
case ".":
|
|
3481
|
-
return
|
|
3529
|
+
return Bt(
|
|
3482
3530
|
this.compiler,
|
|
3483
3531
|
s,
|
|
3484
3532
|
N
|
|
3485
3533
|
);
|
|
3486
3534
|
}
|
|
3487
3535
|
else {
|
|
3488
|
-
if (N instanceof
|
|
3536
|
+
if (N instanceof se)
|
|
3489
3537
|
return dt(this.compiler, s, N);
|
|
3490
3538
|
if (N instanceof P)
|
|
3491
3539
|
return dt(this.compiler, s, N);
|
|
3492
|
-
if (N instanceof
|
|
3493
|
-
return
|
|
3494
|
-
if (N instanceof
|
|
3540
|
+
if (N instanceof Z)
|
|
3541
|
+
return Jn(this.compiler, s);
|
|
3542
|
+
if (N instanceof w)
|
|
3495
3543
|
return Nt(this.compiler, s, N);
|
|
3496
|
-
if (N instanceof
|
|
3544
|
+
if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
|
|
3497
3545
|
return Nt(this.compiler, s, void 0);
|
|
3498
3546
|
}
|
|
3499
|
-
return
|
|
3547
|
+
return O();
|
|
3500
3548
|
}
|
|
3501
3549
|
}
|
|
3502
3550
|
function pt(t, e, n) {
|
|
@@ -3507,14 +3555,14 @@ function pt(t, e, n) {
|
|
|
3507
3555
|
m.Schema,
|
|
3508
3556
|
m.Column
|
|
3509
3557
|
]);
|
|
3510
|
-
return Oe(n.op, e) ?
|
|
3558
|
+
return Oe(n.op, e) ? Re(i) : i;
|
|
3511
3559
|
}
|
|
3512
|
-
return
|
|
3560
|
+
return O();
|
|
3513
3561
|
}
|
|
3514
3562
|
function Me(t, e, n, s) {
|
|
3515
3563
|
var a;
|
|
3516
3564
|
if (n === void 0)
|
|
3517
|
-
return
|
|
3565
|
+
return O();
|
|
3518
3566
|
let i = n;
|
|
3519
3567
|
const r = { suggestions: [] };
|
|
3520
3568
|
for (; i; ) {
|
|
@@ -3524,62 +3572,62 @@ function Me(t, e, n, s) {
|
|
|
3524
3572
|
...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
|
|
3525
3573
|
label: p,
|
|
3526
3574
|
insertText: p,
|
|
3527
|
-
insertTextRules:
|
|
3528
|
-
kind:
|
|
3529
|
-
sortText:
|
|
3575
|
+
insertTextRules: y.KeepWhitespace,
|
|
3576
|
+
kind: _e(h),
|
|
3577
|
+
sortText: _e(h).toString().padStart(2, "0"),
|
|
3530
3578
|
range: void 0
|
|
3531
3579
|
}))
|
|
3532
3580
|
);
|
|
3533
3581
|
}
|
|
3534
|
-
i = i instanceof
|
|
3582
|
+
i = i instanceof A ? i.parent : void 0;
|
|
3535
3583
|
}
|
|
3536
3584
|
return Ue(r);
|
|
3537
3585
|
}
|
|
3538
|
-
function
|
|
3586
|
+
function Jn(t, e) {
|
|
3539
3587
|
var s;
|
|
3540
3588
|
switch (t.container.scopeKind(e)) {
|
|
3541
3589
|
case R.INDEXES:
|
|
3542
|
-
return
|
|
3590
|
+
return Gt(t, e);
|
|
3543
3591
|
case R.REF:
|
|
3544
3592
|
{
|
|
3545
3593
|
const i = [...t.container.stack(e)];
|
|
3546
3594
|
for (; i.length > 0; ) {
|
|
3547
3595
|
const r = i.pop();
|
|
3548
|
-
if (r instanceof
|
|
3549
|
-
return
|
|
3596
|
+
if (r instanceof H && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3597
|
+
return Bt(
|
|
3550
3598
|
t,
|
|
3551
3599
|
e,
|
|
3552
3600
|
r
|
|
3553
3601
|
);
|
|
3554
3602
|
}
|
|
3555
3603
|
}
|
|
3556
|
-
return
|
|
3604
|
+
return Vt(t, e);
|
|
3557
3605
|
}
|
|
3558
|
-
return
|
|
3606
|
+
return O();
|
|
3559
3607
|
}
|
|
3560
3608
|
function dt(t, e, n) {
|
|
3561
3609
|
const { token: s } = t.container.token(e);
|
|
3562
|
-
if ([
|
|
3610
|
+
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3563
3611
|
const i = Et(t, e);
|
|
3564
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3612
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && Oe(s, e) ? Re(i) : i;
|
|
3565
3613
|
}
|
|
3566
3614
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3567
3615
|
return Et(t, e);
|
|
3568
|
-
if (n.name instanceof
|
|
3569
|
-
const i =
|
|
3616
|
+
if (n.name instanceof $) {
|
|
3617
|
+
const i = Zn(
|
|
3570
3618
|
t,
|
|
3571
3619
|
e,
|
|
3572
|
-
|
|
3620
|
+
Ne(n.name).unwrap()
|
|
3573
3621
|
);
|
|
3574
|
-
return (s == null ? void 0 : s.kind) ===
|
|
3622
|
+
return (s == null ? void 0 : s.kind) === u.COLON && Oe(s, e) ? Re(i) : i;
|
|
3575
3623
|
}
|
|
3576
|
-
return
|
|
3624
|
+
return O();
|
|
3577
3625
|
}
|
|
3578
3626
|
function Et(t, e) {
|
|
3579
3627
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3580
|
-
if (n instanceof
|
|
3581
|
-
return
|
|
3582
|
-
if (n.body && !
|
|
3628
|
+
if (n instanceof F)
|
|
3629
|
+
return O();
|
|
3630
|
+
if (n.body && !Le(e, n.body))
|
|
3583
3631
|
switch (s) {
|
|
3584
3632
|
case R.TABLE:
|
|
3585
3633
|
return {
|
|
@@ -3588,20 +3636,20 @@ function Et(t, e) {
|
|
|
3588
3636
|
label: "headercolor",
|
|
3589
3637
|
insertText: "headercolor: ",
|
|
3590
3638
|
kind: L.Field,
|
|
3591
|
-
insertTextRules:
|
|
3639
|
+
insertTextRules: y.KeepWhitespace,
|
|
3592
3640
|
range: void 0
|
|
3593
3641
|
},
|
|
3594
3642
|
{
|
|
3595
3643
|
label: "note",
|
|
3596
3644
|
insertText: "note: ",
|
|
3597
3645
|
kind: L.Field,
|
|
3598
|
-
insertTextRules:
|
|
3646
|
+
insertTextRules: y.KeepWhitespace,
|
|
3599
3647
|
range: void 0
|
|
3600
3648
|
}
|
|
3601
3649
|
]
|
|
3602
3650
|
};
|
|
3603
3651
|
default:
|
|
3604
|
-
return
|
|
3652
|
+
return O();
|
|
3605
3653
|
}
|
|
3606
3654
|
switch (s) {
|
|
3607
3655
|
case R.TABLE:
|
|
@@ -3611,21 +3659,21 @@ function Et(t, e) {
|
|
|
3611
3659
|
label: i,
|
|
3612
3660
|
insertText: i,
|
|
3613
3661
|
kind: L.Property,
|
|
3614
|
-
insertTextRules:
|
|
3662
|
+
insertTextRules: y.KeepWhitespace,
|
|
3615
3663
|
range: void 0
|
|
3616
3664
|
})),
|
|
3617
3665
|
...["ref", "default"].map((i) => ({
|
|
3618
3666
|
label: i,
|
|
3619
3667
|
insertText: `${i}: `,
|
|
3620
3668
|
kind: L.Property,
|
|
3621
|
-
insertTextRules:
|
|
3669
|
+
insertTextRules: y.KeepWhitespace,
|
|
3622
3670
|
range: void 0
|
|
3623
3671
|
})),
|
|
3624
3672
|
{
|
|
3625
3673
|
label: "note",
|
|
3626
3674
|
insertText: "note: ",
|
|
3627
3675
|
kind: L.Property,
|
|
3628
|
-
insertTextRules:
|
|
3676
|
+
insertTextRules: y.KeepWhitespace,
|
|
3629
3677
|
range: void 0
|
|
3630
3678
|
}
|
|
3631
3679
|
]
|
|
@@ -3637,7 +3685,7 @@ function Et(t, e) {
|
|
|
3637
3685
|
label: "note",
|
|
3638
3686
|
insertText: "note: ",
|
|
3639
3687
|
kind: L.Property,
|
|
3640
|
-
insertTextRules:
|
|
3688
|
+
insertTextRules: y.KeepWhitespace,
|
|
3641
3689
|
range: void 0
|
|
3642
3690
|
}
|
|
3643
3691
|
]
|
|
@@ -3648,7 +3696,7 @@ function Et(t, e) {
|
|
|
3648
3696
|
...["unique", "pk"].map((i) => ({
|
|
3649
3697
|
label: i,
|
|
3650
3698
|
insertText: i,
|
|
3651
|
-
insertTextRules:
|
|
3699
|
+
insertTextRules: y.KeepWhitespace,
|
|
3652
3700
|
kind: L.Property,
|
|
3653
3701
|
range: void 0
|
|
3654
3702
|
})),
|
|
@@ -3656,7 +3704,7 @@ function Et(t, e) {
|
|
|
3656
3704
|
label: i,
|
|
3657
3705
|
insertText: `${i}: `,
|
|
3658
3706
|
kind: L.Property,
|
|
3659
|
-
insertTextRules:
|
|
3707
|
+
insertTextRules: y.KeepWhitespace,
|
|
3660
3708
|
range: void 0
|
|
3661
3709
|
}))
|
|
3662
3710
|
]
|
|
@@ -3667,14 +3715,14 @@ function Et(t, e) {
|
|
|
3667
3715
|
label: i,
|
|
3668
3716
|
insertText: `${i}: `,
|
|
3669
3717
|
kind: L.Property,
|
|
3670
|
-
insertTextRules:
|
|
3718
|
+
insertTextRules: y.KeepWhitespace,
|
|
3671
3719
|
range: void 0
|
|
3672
3720
|
}))
|
|
3673
3721
|
};
|
|
3674
3722
|
}
|
|
3675
|
-
return
|
|
3723
|
+
return O();
|
|
3676
3724
|
}
|
|
3677
|
-
function
|
|
3725
|
+
function Zn(t, e, n) {
|
|
3678
3726
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
3679
3727
|
case "update":
|
|
3680
3728
|
case "delete":
|
|
@@ -3683,7 +3731,7 @@ function Hn(t, e, n) {
|
|
|
3683
3731
|
label: s,
|
|
3684
3732
|
insertText: s,
|
|
3685
3733
|
kind: L.Value,
|
|
3686
|
-
insertTextRules:
|
|
3734
|
+
insertTextRules: y.KeepWhitespace,
|
|
3687
3735
|
range: void 0
|
|
3688
3736
|
}))
|
|
3689
3737
|
};
|
|
@@ -3693,23 +3741,23 @@ function Hn(t, e, n) {
|
|
|
3693
3741
|
label: s,
|
|
3694
3742
|
insertText: `${s}`,
|
|
3695
3743
|
kind: L.Value,
|
|
3696
|
-
insertTextRules:
|
|
3744
|
+
insertTextRules: y.KeepWhitespace,
|
|
3697
3745
|
range: void 0
|
|
3698
3746
|
}))
|
|
3699
3747
|
};
|
|
3700
3748
|
}
|
|
3701
|
-
return
|
|
3749
|
+
return O();
|
|
3702
3750
|
}
|
|
3703
|
-
function
|
|
3704
|
-
const s =
|
|
3751
|
+
function Bt(t, e, n) {
|
|
3752
|
+
const s = he(n).unwrap_or([]);
|
|
3705
3753
|
if (s.pop(), s.some((r) => !M(r)))
|
|
3706
|
-
return
|
|
3707
|
-
const i = s.map((r) =>
|
|
3754
|
+
return O();
|
|
3755
|
+
const i = s.map((r) => X(r).unwrap());
|
|
3708
3756
|
return Ue({
|
|
3709
3757
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3710
3758
|
label: a,
|
|
3711
3759
|
insertText: a,
|
|
3712
|
-
kind:
|
|
3760
|
+
kind: _e(r),
|
|
3713
3761
|
range: void 0
|
|
3714
3762
|
}))
|
|
3715
3763
|
});
|
|
@@ -3718,21 +3766,21 @@ function Nt(t, e, n) {
|
|
|
3718
3766
|
var i;
|
|
3719
3767
|
switch (t.container.scopeKind(e)) {
|
|
3720
3768
|
case R.TABLE:
|
|
3721
|
-
return
|
|
3769
|
+
return es(t, e, n);
|
|
3722
3770
|
case R.PROJECT:
|
|
3723
|
-
return
|
|
3771
|
+
return ts(t, e, n);
|
|
3724
3772
|
case R.INDEXES:
|
|
3725
|
-
return
|
|
3773
|
+
return ss(t, e);
|
|
3726
3774
|
case R.ENUM:
|
|
3727
|
-
return
|
|
3775
|
+
return Kn(t, e, n);
|
|
3728
3776
|
case R.REF: {
|
|
3729
|
-
const r =
|
|
3730
|
-
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;
|
|
3731
3779
|
}
|
|
3732
3780
|
case R.TABLEGROUP:
|
|
3733
|
-
return
|
|
3781
|
+
return ns(t);
|
|
3734
3782
|
default:
|
|
3735
|
-
return
|
|
3783
|
+
return O();
|
|
3736
3784
|
}
|
|
3737
3785
|
}
|
|
3738
3786
|
function mt() {
|
|
@@ -3740,26 +3788,26 @@ function mt() {
|
|
|
3740
3788
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3741
3789
|
label: t,
|
|
3742
3790
|
insertText: t,
|
|
3743
|
-
insertTextRules:
|
|
3791
|
+
insertTextRules: y.KeepWhitespace,
|
|
3744
3792
|
kind: L.Keyword,
|
|
3745
3793
|
range: void 0
|
|
3746
3794
|
}))
|
|
3747
3795
|
};
|
|
3748
3796
|
}
|
|
3749
|
-
function
|
|
3797
|
+
function Kn(t, e, n) {
|
|
3750
3798
|
return n != null && n.callee && et(e, n) === 1 ? Me(t, e, t.container.element(e), [
|
|
3751
3799
|
m.Schema,
|
|
3752
3800
|
m.Table,
|
|
3753
3801
|
m.Column
|
|
3754
|
-
]) :
|
|
3802
|
+
]) : O();
|
|
3755
3803
|
}
|
|
3756
|
-
function
|
|
3804
|
+
function es(t, e, n) {
|
|
3757
3805
|
if (!(n != null && n.callee))
|
|
3758
3806
|
return {
|
|
3759
3807
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3760
3808
|
label: i,
|
|
3761
3809
|
insertText: i,
|
|
3762
|
-
insertTextRules:
|
|
3810
|
+
insertTextRules: y.KeepWhitespace,
|
|
3763
3811
|
kind: L.Keyword,
|
|
3764
3812
|
range: void 0
|
|
3765
3813
|
}))
|
|
@@ -3769,59 +3817,59 @@ function Zn(t, e, n) {
|
|
|
3769
3817
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3770
3818
|
label: i,
|
|
3771
3819
|
insertText: i,
|
|
3772
|
-
insertTextRules:
|
|
3820
|
+
insertTextRules: y.KeepWhitespace,
|
|
3773
3821
|
kind: L.Keyword,
|
|
3774
3822
|
range: void 0
|
|
3775
3823
|
}))
|
|
3776
|
-
} : s === 1 ?
|
|
3824
|
+
} : s === 1 ? is(t, e) : O();
|
|
3777
3825
|
}
|
|
3778
|
-
function
|
|
3826
|
+
function ts(t, e, n) {
|
|
3779
3827
|
return n != null && n.callee ? et(e, n) === 0 ? {
|
|
3780
3828
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3781
3829
|
label: i,
|
|
3782
3830
|
insertText: i,
|
|
3783
|
-
insertTextRules:
|
|
3831
|
+
insertTextRules: y.KeepWhitespace,
|
|
3784
3832
|
kind: L.Keyword,
|
|
3785
3833
|
range: void 0
|
|
3786
3834
|
}))
|
|
3787
|
-
} :
|
|
3835
|
+
} : O() : {
|
|
3788
3836
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3789
3837
|
label: i,
|
|
3790
3838
|
insertText: i,
|
|
3791
|
-
insertTextRules:
|
|
3839
|
+
insertTextRules: y.KeepWhitespace,
|
|
3792
3840
|
kind: L.Keyword,
|
|
3793
3841
|
range: void 0
|
|
3794
3842
|
}))
|
|
3795
3843
|
};
|
|
3796
3844
|
}
|
|
3797
|
-
function
|
|
3845
|
+
function Vt(t, e) {
|
|
3798
3846
|
return Me(t, e, t.container.element(e), [
|
|
3799
3847
|
m.Schema,
|
|
3800
3848
|
m.Table,
|
|
3801
3849
|
m.Column
|
|
3802
3850
|
]);
|
|
3803
3851
|
}
|
|
3804
|
-
function
|
|
3852
|
+
function ns(t) {
|
|
3805
3853
|
return Ue({
|
|
3806
3854
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3807
|
-
const n =
|
|
3855
|
+
const n = ie(e).unwrap_or(void 0);
|
|
3808
3856
|
if (n === void 0)
|
|
3809
3857
|
return [];
|
|
3810
3858
|
const { kind: s, name: i } = n;
|
|
3811
3859
|
return s !== m.Table && s !== m.Schema ? [] : {
|
|
3812
3860
|
label: i,
|
|
3813
3861
|
insertText: i,
|
|
3814
|
-
insertTextRules:
|
|
3815
|
-
kind:
|
|
3862
|
+
insertTextRules: y.KeepWhitespace,
|
|
3863
|
+
kind: _e(s),
|
|
3816
3864
|
range: void 0
|
|
3817
3865
|
};
|
|
3818
3866
|
})
|
|
3819
3867
|
});
|
|
3820
3868
|
}
|
|
3821
|
-
function
|
|
3822
|
-
return
|
|
3869
|
+
function ss(t, e) {
|
|
3870
|
+
return Gt(t, e);
|
|
3823
3871
|
}
|
|
3824
|
-
function
|
|
3872
|
+
function is(t, e) {
|
|
3825
3873
|
return {
|
|
3826
3874
|
suggestions: [
|
|
3827
3875
|
...[
|
|
@@ -3884,7 +3932,7 @@ function ns(t, e) {
|
|
|
3884
3932
|
].map((n) => ({
|
|
3885
3933
|
label: n,
|
|
3886
3934
|
insertText: n,
|
|
3887
|
-
insertTextRules:
|
|
3935
|
+
insertTextRules: y.KeepWhitespace,
|
|
3888
3936
|
kind: L.TypeParameter,
|
|
3889
3937
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3890
3938
|
range: void 0
|
|
@@ -3896,22 +3944,22 @@ function ns(t, e) {
|
|
|
3896
3944
|
]
|
|
3897
3945
|
};
|
|
3898
3946
|
}
|
|
3899
|
-
function
|
|
3947
|
+
function Gt(t, e) {
|
|
3900
3948
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
3901
3949
|
if (!((s == null ? void 0 : s.symbol) instanceof _t))
|
|
3902
|
-
return
|
|
3950
|
+
return O();
|
|
3903
3951
|
const { symbolTable: i } = s.symbol;
|
|
3904
3952
|
return Ue({
|
|
3905
3953
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
3906
|
-
const a =
|
|
3954
|
+
const a = ie(r).unwrap_or(void 0);
|
|
3907
3955
|
if (a === void 0)
|
|
3908
3956
|
return [];
|
|
3909
3957
|
const { name: l } = a;
|
|
3910
3958
|
return {
|
|
3911
3959
|
label: l,
|
|
3912
3960
|
insertText: l,
|
|
3913
|
-
insertTextRules:
|
|
3914
|
-
kind:
|
|
3961
|
+
insertTextRules: y.KeepWhitespace,
|
|
3962
|
+
kind: _e(m.Column),
|
|
3915
3963
|
range: void 0
|
|
3916
3964
|
};
|
|
3917
3965
|
})
|
|
@@ -3923,7 +3971,7 @@ function et(t, e) {
|
|
|
3923
3971
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
3924
3972
|
return s === -1 ? n.length : s;
|
|
3925
3973
|
}
|
|
3926
|
-
class
|
|
3974
|
+
class Ct {
|
|
3927
3975
|
constructor(e) {
|
|
3928
3976
|
this.compiler = e;
|
|
3929
3977
|
}
|
|
@@ -3932,7 +3980,7 @@ class Gt {
|
|
|
3932
3980
|
const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
|
|
3933
3981
|
for (; r.length !== 0; ) {
|
|
3934
3982
|
const l = r.pop();
|
|
3935
|
-
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [
|
|
3983
|
+
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [de.PRIMARY_EXPRESSION, de.VARIABLE].includes(l == null ? void 0 : l.kind)) {
|
|
3936
3984
|
const { startPos: p, endPos: h } = l.referee.declaration;
|
|
3937
3985
|
return [
|
|
3938
3986
|
{
|
|
@@ -3950,7 +3998,7 @@ class Gt {
|
|
|
3950
3998
|
return [];
|
|
3951
3999
|
}
|
|
3952
4000
|
}
|
|
3953
|
-
class
|
|
4001
|
+
class Xt {
|
|
3954
4002
|
constructor(e) {
|
|
3955
4003
|
this.compiler = e;
|
|
3956
4004
|
}
|
|
@@ -3959,9 +4007,9 @@ class Ct {
|
|
|
3959
4007
|
for (; r.length !== 0; ) {
|
|
3960
4008
|
const a = r.pop();
|
|
3961
4009
|
if (a && [
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
4010
|
+
de.ELEMENT_DECLARATION,
|
|
4011
|
+
de.FUNCTION_APPLICATION,
|
|
4012
|
+
de.PRIMARY_EXPRESSION
|
|
3965
4013
|
].includes(a == null ? void 0 : a.kind)) {
|
|
3966
4014
|
const { symbol: l } = a;
|
|
3967
4015
|
if (l != null && l.references.length)
|
|
@@ -3979,21 +4027,21 @@ class Ct {
|
|
|
3979
4027
|
return [];
|
|
3980
4028
|
}
|
|
3981
4029
|
}
|
|
3982
|
-
const
|
|
4030
|
+
const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3983
4031
|
__proto__: null,
|
|
3984
|
-
CompletionItemInsertTextRule:
|
|
4032
|
+
CompletionItemInsertTextRule: y,
|
|
3985
4033
|
CompletionItemKind: L,
|
|
3986
|
-
DBMLCompletionItemProvider:
|
|
3987
|
-
DBMLDefinitionProvider:
|
|
3988
|
-
DBMLReferencesProvider:
|
|
4034
|
+
DBMLCompletionItemProvider: Ft,
|
|
4035
|
+
DBMLDefinitionProvider: Ct,
|
|
4036
|
+
DBMLReferencesProvider: Xt
|
|
3989
4037
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3990
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 || {});
|
|
3991
|
-
class
|
|
4039
|
+
class ls {
|
|
3992
4040
|
constructor() {
|
|
3993
4041
|
this.source = "", this.cache = new Array(
|
|
3994
4042
|
16
|
|
3995
4043
|
/* TOTAL_QUERY_COUNT */
|
|
3996
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4044
|
+
).fill(null), this.nodeIdGenerator = new jt(), this.symbolIdGenerator = new Ht(), this.token = {
|
|
3997
4045
|
invalidStream: this.createQuery(
|
|
3998
4046
|
6,
|
|
3999
4047
|
() => this.parse.tokens().filter(At)
|
|
@@ -4008,8 +4056,8 @@ class as {
|
|
|
4008
4056
|
_: this.createQuery(
|
|
4009
4057
|
0,
|
|
4010
4058
|
() => {
|
|
4011
|
-
const e = new
|
|
4012
|
-
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 })));
|
|
4013
4061
|
}
|
|
4014
4062
|
),
|
|
4015
4063
|
ast: this.createQuery(
|
|
@@ -4046,26 +4094,26 @@ class as {
|
|
|
4046
4094
|
let a = this.parse.ast();
|
|
4047
4095
|
const l = [a];
|
|
4048
4096
|
for (; ; ) {
|
|
4049
|
-
const h =
|
|
4050
|
-
if (h === void 0 || h instanceof
|
|
4097
|
+
const h = an(a).find((T) => Le(r, T));
|
|
4098
|
+
if (h === void 0 || h instanceof V)
|
|
4051
4099
|
break;
|
|
4052
4100
|
l.push(h), a = h;
|
|
4053
4101
|
}
|
|
4054
|
-
if ((i == null ? void 0 : i.kind) ===
|
|
4102
|
+
if ((i == null ? void 0 : i.kind) === u.COLON)
|
|
4055
4103
|
return l;
|
|
4056
4104
|
for (; l.length > 0; ) {
|
|
4057
4105
|
let p = !1;
|
|
4058
4106
|
const h = I.last(l);
|
|
4059
|
-
if (h instanceof
|
|
4107
|
+
if (h instanceof w) {
|
|
4060
4108
|
const T = this.parse.source();
|
|
4061
4109
|
for (let f = h.end; f < e; f += 1)
|
|
4062
4110
|
T[f] === `
|
|
4063
4111
|
` && (l.pop(), p = !0);
|
|
4064
4112
|
} else
|
|
4065
|
-
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);
|
|
4066
4114
|
if (p) {
|
|
4067
4115
|
const T = I.last(l);
|
|
4068
|
-
T instanceof
|
|
4116
|
+
T instanceof A && T.end <= e && l.pop();
|
|
4069
4117
|
}
|
|
4070
4118
|
if (!p)
|
|
4071
4119
|
break;
|
|
@@ -4088,7 +4136,7 @@ class as {
|
|
|
4088
4136
|
(e) => {
|
|
4089
4137
|
const n = this.container.stack(e);
|
|
4090
4138
|
for (let s = n.length - 1; s >= 0; s -= 1)
|
|
4091
|
-
if (n[s] instanceof
|
|
4139
|
+
if (n[s] instanceof A)
|
|
4092
4140
|
return n[s];
|
|
4093
4141
|
return this.parse.ast();
|
|
4094
4142
|
}
|
|
@@ -4102,7 +4150,7 @@ class as {
|
|
|
4102
4150
|
),
|
|
4103
4151
|
scopeKind: this.createQuery(15, (e) => {
|
|
4104
4152
|
var s;
|
|
4105
|
-
if (this.container.element(e) instanceof
|
|
4153
|
+
if (this.container.element(e) instanceof F)
|
|
4106
4154
|
return 8;
|
|
4107
4155
|
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4108
4156
|
case "table":
|
|
@@ -4138,15 +4186,15 @@ class as {
|
|
|
4138
4186
|
if (e.length === 0)
|
|
4139
4187
|
return [];
|
|
4140
4188
|
const s = [];
|
|
4141
|
-
for (let r = n; r; r = r instanceof
|
|
4189
|
+
for (let r = n; r; r = r instanceof A ? r.parent : void 0) {
|
|
4142
4190
|
if (!((i = r.symbol) != null && i.symbolTable))
|
|
4143
4191
|
continue;
|
|
4144
4192
|
const { symbolTable: a } = r.symbol;
|
|
4145
4193
|
let l = [a], p = [];
|
|
4146
4194
|
for (const h of e)
|
|
4147
4195
|
p = l.flatMap(
|
|
4148
|
-
(T) =>
|
|
4149
|
-
const N = T.get(f), g =
|
|
4196
|
+
(T) => Qt(h).flatMap((f) => {
|
|
4197
|
+
const N = T.get(f), g = ie(f).unwrap_or(void 0);
|
|
4150
4198
|
return !N || !g ? [] : { ...g, symbol: N };
|
|
4151
4199
|
})
|
|
4152
4200
|
), l = p.flatMap(
|
|
@@ -4161,7 +4209,7 @@ class as {
|
|
|
4161
4209
|
members: this.createQuery(
|
|
4162
4210
|
9,
|
|
4163
4211
|
(e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
|
|
4164
|
-
...
|
|
4212
|
+
...ie(n).unwrap(),
|
|
4165
4213
|
symbol: s
|
|
4166
4214
|
})) : []
|
|
4167
4215
|
)
|
|
@@ -4188,14 +4236,14 @@ class as {
|
|
|
4188
4236
|
}
|
|
4189
4237
|
initMonacoServices() {
|
|
4190
4238
|
return {
|
|
4191
|
-
definitionProvider: new
|
|
4192
|
-
referenceProvider: new
|
|
4193
|
-
autocompletionProvider: new
|
|
4239
|
+
definitionProvider: new Ct(this),
|
|
4240
|
+
referenceProvider: new Xt(this),
|
|
4241
|
+
autocompletionProvider: new Ft(this)
|
|
4194
4242
|
};
|
|
4195
4243
|
}
|
|
4196
4244
|
}
|
|
4197
4245
|
export {
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4246
|
+
ls as Compiler,
|
|
4247
|
+
as as serialize,
|
|
4248
|
+
os as services
|
|
4201
4249
|
};
|