@dbml/parse 3.13.3-alpha.0 → 3.13.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +8 -8
- package/dist/dbml-parse.mjs +782 -828
- package/dist/src/lib/interpreter/utils.d.ts +8 -1
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import g, { last as Ve, forIn as
|
|
1
|
+
import g, { last as Ve, forIn as pt, partition as Pt, head as on, findLastIndex as ln } from "lodash";
|
|
2
2
|
var h = /* @__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.TILDE = "<tilde>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(h || {});
|
|
3
|
-
function
|
|
3
|
+
function cn(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -12,7 +12,7 @@ function on(t) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function dt(t) {
|
|
16
16
|
if (!t)
|
|
17
17
|
return !1;
|
|
18
18
|
switch (t) {
|
|
@@ -33,22 +33,22 @@ function Et(t) {
|
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Et(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class J {
|
|
40
40
|
constructor(e, n, s, i, a) {
|
|
41
41
|
this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = a, this.start = n.offset, this.end = s.offset;
|
|
42
42
|
}
|
|
43
43
|
static create(e, n, s, i, a) {
|
|
44
|
-
return new
|
|
44
|
+
return new J(e, n, s, i, a);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function St(t) {
|
|
48
48
|
return t.trailingTrivia.find(({ kind: e }) => e === h.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s === h.NEWLINE) !== void 0 ||
|
|
50
|
+
function Nt(t, e) {
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === h.NEWLINE) !== void 0 || St(t);
|
|
52
52
|
}
|
|
53
53
|
function et(t) {
|
|
54
54
|
return t.trailingTrivia.find(({ kind: e }) => [h.SPACE, h.TAB].includes(e)) !== void 0;
|
|
@@ -56,15 +56,15 @@ function et(t) {
|
|
|
56
56
|
function Dt(t) {
|
|
57
57
|
return t.trailingTrivia.length === 0 ? t.end : Dt(Ve(t.trailingTrivia));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return t.leadingTrivia.length === 0 ? t.start :
|
|
59
|
+
function xt(t) {
|
|
60
|
+
return t.leadingTrivia.length === 0 ? t.start : xt(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function un(t) {
|
|
63
63
|
return [h.SINGLE_LINE_COMMENT, h.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class hn {
|
|
68
68
|
constructor() {
|
|
69
69
|
this.id = 0;
|
|
70
70
|
}
|
|
@@ -75,32 +75,32 @@ class cn {
|
|
|
75
75
|
return this.id++;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class x {
|
|
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((r) => r !== void 0 && !Number.isNaN(r.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof J ? xt(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 a = [...s].reverse().find((r) => r !== void 0 && !Number.isNaN(r.end));
|
|
90
|
-
a ? (this.endPos = a.endPos, this.fullEnd = a instanceof
|
|
90
|
+
a ? (this.endPos = a.endPos, this.fullEnd = a instanceof J ? Dt(a) : a.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 Z extends
|
|
97
|
+
var Ie = /* @__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.PARTIAL_INJECTION = "<partial-injection>", t))(Ie || {});
|
|
98
|
+
class Z extends x {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class y extends
|
|
103
|
+
class y extends x {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -123,12 +123,12 @@ class y extends D {
|
|
|
123
123
|
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = a, this.bodyColon = r, this.body = c;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class
|
|
126
|
+
class te extends x {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class
|
|
131
|
+
class ne extends x {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: n,
|
|
@@ -137,12 +137,12 @@ class se extends D {
|
|
|
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 oe extends x {
|
|
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 le extends x {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,22 +151,22 @@ class ce extends D {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class Ye extends
|
|
154
|
+
class Ye extends x {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class ue extends
|
|
159
|
+
class ue extends x {
|
|
160
160
|
constructor({ value: e }, n) {
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class w extends
|
|
164
|
+
class w extends x {
|
|
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 ae extends x {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -175,12 +175,12 @@ class oe extends D {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class
|
|
178
|
+
class Le extends x {
|
|
179
179
|
constructor({ op: e, partial: n }, s) {
|
|
180
180
|
super(s, "<partial-injection>", [e, n]), this.partial = n;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
class M extends
|
|
183
|
+
class M extends x {
|
|
184
184
|
constructor({
|
|
185
185
|
listOpenBracket: e,
|
|
186
186
|
elementList: n = [],
|
|
@@ -189,12 +189,12 @@ class M extends D {
|
|
|
189
189
|
}, a) {
|
|
190
190
|
super(a, "<list-expression>", [
|
|
191
191
|
e,
|
|
192
|
-
...
|
|
192
|
+
...Ot(n, s),
|
|
193
193
|
i
|
|
194
194
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
class
|
|
197
|
+
class ce extends x {
|
|
198
198
|
constructor({
|
|
199
199
|
tupleOpenParen: e,
|
|
200
200
|
elementList: n = [],
|
|
@@ -203,12 +203,12 @@ class pe extends D {
|
|
|
203
203
|
}, a) {
|
|
204
204
|
super(a, "<tuple-expression>", [
|
|
205
205
|
e,
|
|
206
|
-
...
|
|
206
|
+
...Ot(n, s),
|
|
207
207
|
i
|
|
208
208
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
class tt extends
|
|
211
|
+
class tt extends ce {
|
|
212
212
|
constructor({
|
|
213
213
|
groupOpenParen: e,
|
|
214
214
|
expression: n,
|
|
@@ -225,7 +225,7 @@ class tt extends pe {
|
|
|
225
225
|
), this.kind = "<group-expression>";
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class H extends x {
|
|
229
229
|
constructor({
|
|
230
230
|
callee: e,
|
|
231
231
|
argumentList: n
|
|
@@ -233,33 +233,33 @@ class q extends D {
|
|
|
233
233
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class ye extends
|
|
236
|
+
class ye extends x {
|
|
237
237
|
constructor({ literal: e }, n) {
|
|
238
238
|
super(n, "<literal>", [e]), this.literal = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class
|
|
241
|
+
class ie extends x {
|
|
242
242
|
constructor({ variable: e }, n) {
|
|
243
243
|
super(n, "<variable>", [e]), this.variable = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class $ extends x {
|
|
247
247
|
constructor({ expression: e }, n) {
|
|
248
248
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
class Me extends
|
|
251
|
+
class Me extends x {
|
|
252
252
|
constructor({ pre: e }, n) {
|
|
253
|
-
const s =
|
|
253
|
+
const s = J.create(h.SPACE, e.endPos, e.endPos, " ", !1);
|
|
254
254
|
super(n, "<dummy>", [s]);
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
class he extends
|
|
257
|
+
class he extends x {
|
|
258
258
|
constructor({ expression: e, indexer: n }, s) {
|
|
259
259
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function Ot(t, e) {
|
|
263
263
|
if (!t || t.length === 0)
|
|
264
264
|
return e || [];
|
|
265
265
|
if (!e || e.length === 0)
|
|
@@ -269,7 +269,7 @@ function Rt(t, e) {
|
|
|
269
269
|
(i) => i !== null
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function Ps(t, e = !1) {
|
|
273
273
|
return JSON.stringify(
|
|
274
274
|
t,
|
|
275
275
|
function(n, s) {
|
|
@@ -361,13 +361,13 @@ function at(t) {
|
|
|
361
361
|
function rt(t) {
|
|
362
362
|
return `TableGroup field:${t}`;
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function fn(t) {
|
|
365
365
|
return `Note:${t}`;
|
|
366
366
|
}
|
|
367
367
|
function ot(t) {
|
|
368
368
|
return `TablePartial:${t}`;
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function Rt(t) {
|
|
371
371
|
return `TablePartialInjection:${t}`;
|
|
372
372
|
}
|
|
373
373
|
function Fe(t, e) {
|
|
@@ -392,29 +392,29 @@ function Fe(t, e) {
|
|
|
392
392
|
throw new Error("Unreachable");
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function re(t) {
|
|
396
396
|
const [e, n] = t.split(":");
|
|
397
397
|
return Object.values(m).includes(e) ? new U({
|
|
398
398
|
name: n,
|
|
399
399
|
kind: e
|
|
400
400
|
}) : new S();
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
const e =
|
|
402
|
+
function pn(t) {
|
|
403
|
+
const e = re(t).unwrap_or(void 0);
|
|
404
404
|
if (!e)
|
|
405
405
|
return !1;
|
|
406
406
|
const { kind: n, name: s } = e;
|
|
407
407
|
return n === "Schema" && s === "public";
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
const e =
|
|
409
|
+
function dn(t) {
|
|
410
|
+
const e = re(t).unwrap_or(void 0);
|
|
411
411
|
if (!e)
|
|
412
412
|
return !1;
|
|
413
413
|
const { kind: n } = e;
|
|
414
414
|
return n === "TablePartialInjection";
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
const e =
|
|
416
|
+
function En(t) {
|
|
417
|
+
const e = re(t).unwrap_or(void 0);
|
|
418
418
|
if (!e)
|
|
419
419
|
return null;
|
|
420
420
|
const { kind: n, name: s } = e;
|
|
@@ -424,7 +424,7 @@ function pn(t) {
|
|
|
424
424
|
/* TablePartial */
|
|
425
425
|
) : null;
|
|
426
426
|
}
|
|
427
|
-
class
|
|
427
|
+
class Nn {
|
|
428
428
|
constructor() {
|
|
429
429
|
this.id = 0;
|
|
430
430
|
}
|
|
@@ -435,22 +435,22 @@ class dn {
|
|
|
435
435
|
return this.id++;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
class
|
|
438
|
+
class Ut {
|
|
439
439
|
constructor({ symbolTable: e }, n) {
|
|
440
440
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
class
|
|
443
|
+
class Tn {
|
|
444
444
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
445
445
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
class
|
|
448
|
+
class mn {
|
|
449
449
|
constructor({ declaration: e }, n) {
|
|
450
450
|
this.references = [], this.id = n, this.declaration = e;
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
class
|
|
453
|
+
class Mt {
|
|
454
454
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
455
455
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
456
456
|
}
|
|
@@ -460,32 +460,32 @@ class lt {
|
|
|
460
460
|
this.references = [], this.id = n, this.declaration = e;
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
|
-
class
|
|
463
|
+
class bn {
|
|
464
464
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
465
465
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
class
|
|
468
|
+
class In {
|
|
469
469
|
constructor({ declaration: e }, n) {
|
|
470
470
|
this.references = [], this.id = n, this.declaration = e;
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
class
|
|
473
|
+
class Ln {
|
|
474
474
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
475
475
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
class
|
|
478
|
+
class An {
|
|
479
479
|
constructor({ declaration: e }, n) {
|
|
480
480
|
this.references = [], this.id = n, this.declaration = e;
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
class
|
|
483
|
+
class _n {
|
|
484
484
|
constructor({ injectorFieldSymbol: e, injectorDeclaration: n }, s) {
|
|
485
485
|
this.references = [], this.id = s, this.injectorDeclaration = n, this.injectorFieldSymbol = e;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function gn(t) {
|
|
489
489
|
return [
|
|
490
490
|
nt,
|
|
491
491
|
Ge,
|
|
@@ -495,27 +495,27 @@ function An(t) {
|
|
|
495
495
|
it,
|
|
496
496
|
rt,
|
|
497
497
|
ot,
|
|
498
|
-
|
|
498
|
+
Rt
|
|
499
499
|
].map((e) => e(t));
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
return t instanceof lt ?
|
|
501
|
+
function vn(t) {
|
|
502
|
+
return t instanceof lt ? _n : null;
|
|
503
503
|
}
|
|
504
|
-
function
|
|
504
|
+
function He(t) {
|
|
505
505
|
return !!t.match(/(\p{L}|_|\p{M})/gu);
|
|
506
506
|
}
|
|
507
507
|
function Ce(t) {
|
|
508
508
|
const [e] = t;
|
|
509
509
|
return e >= "0" && e <= "9";
|
|
510
510
|
}
|
|
511
|
-
function
|
|
511
|
+
function wn(t) {
|
|
512
512
|
const [e] = t;
|
|
513
|
-
return Ce(e) ||
|
|
513
|
+
return Ce(e) || He(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
514
514
|
}
|
|
515
515
|
function ve(t) {
|
|
516
|
-
return
|
|
516
|
+
return He(t) || Ce(t);
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Tt(t, e) {
|
|
519
519
|
const n = [], s = Math.min(t.length, e.length);
|
|
520
520
|
for (let i = 0; i < s; i += 1)
|
|
521
521
|
n.push(t[i], e[i]);
|
|
@@ -530,7 +530,7 @@ class l extends Error {
|
|
|
530
530
|
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, l.prototype);
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
class
|
|
533
|
+
class K {
|
|
534
534
|
constructor(e, n) {
|
|
535
535
|
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
536
536
|
}
|
|
@@ -542,17 +542,17 @@ class z {
|
|
|
542
542
|
}
|
|
543
543
|
chain(e) {
|
|
544
544
|
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
545
|
-
return new
|
|
545
|
+
return new K(n.value, s);
|
|
546
546
|
}
|
|
547
547
|
map(e) {
|
|
548
|
-
return new
|
|
548
|
+
return new K(e(this.value), this.errors);
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
|
-
function
|
|
551
|
+
function yn(t, e, n) {
|
|
552
552
|
if (!t || !fe(t) || e.length === 0)
|
|
553
553
|
return new S();
|
|
554
554
|
const s = [...e], i = Ze(t).unwrap(), a = s.pop();
|
|
555
|
-
if (!(a instanceof
|
|
555
|
+
if (!(a instanceof ae))
|
|
556
556
|
return new S();
|
|
557
557
|
const r = g.last(s) instanceof M ? s.pop() : void 0;
|
|
558
558
|
return s.length === 3 && Ze(s[1]).unwrap().value === "as" ? new U(
|
|
@@ -579,60 +579,60 @@ function vn(t, e, n) {
|
|
|
579
579
|
})
|
|
580
580
|
) : new S();
|
|
581
581
|
}
|
|
582
|
-
function
|
|
582
|
+
function mt(t) {
|
|
583
583
|
return t.kind === h.IDENTIFIER && t.value === "as";
|
|
584
584
|
}
|
|
585
585
|
function b(t) {
|
|
586
|
-
t && (t instanceof
|
|
586
|
+
t && (t instanceof J ? kn(t) : Pn(t));
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function kn(t) {
|
|
589
589
|
t.kind !== h.EOF && (t.isInvalid = !0);
|
|
590
590
|
}
|
|
591
|
-
function
|
|
591
|
+
function Pn(t) {
|
|
592
592
|
if (t instanceof y)
|
|
593
593
|
b(t.type), b(t.name), b(t.as), b(t.alias), b(t.bodyColon), b(t.attributeList), b(t.body);
|
|
594
|
-
else if (t instanceof
|
|
594
|
+
else if (t instanceof te)
|
|
595
595
|
t.identifiers.forEach(b);
|
|
596
|
-
else if (t instanceof
|
|
596
|
+
else if (t instanceof ne)
|
|
597
597
|
b(t.name), b(t.colon), b(t.value);
|
|
598
|
-
else if (t instanceof
|
|
598
|
+
else if (t instanceof oe)
|
|
599
599
|
b(t.op), b(t.expression);
|
|
600
|
-
else if (t instanceof
|
|
600
|
+
else if (t instanceof le)
|
|
601
601
|
b(t.leftExpression), b(t.op), b(t.rightExpression);
|
|
602
602
|
else if (t instanceof Ye)
|
|
603
603
|
b(t.op), b(t.expression);
|
|
604
|
-
else if (t instanceof
|
|
604
|
+
else if (t instanceof ae)
|
|
605
605
|
b(t.blockOpenBrace), t.body.forEach(b), b(t.blockCloseBrace);
|
|
606
606
|
else if (t instanceof M)
|
|
607
607
|
b(t.listOpenBracket), t.commaList.forEach(b), t.elementList.forEach(b), b(t.listCloseBracket);
|
|
608
|
-
else if (t instanceof
|
|
608
|
+
else if (t instanceof ce)
|
|
609
609
|
b(t.tupleOpenParen), t.commaList.forEach(b), t.elementList.forEach(b), b(t.tupleCloseParen);
|
|
610
|
-
else if (t instanceof
|
|
610
|
+
else if (t instanceof H)
|
|
611
611
|
b(t.callee), b(t.argumentList);
|
|
612
612
|
else if (t instanceof w)
|
|
613
613
|
b(t.callee), t.args.forEach(b);
|
|
614
|
-
else if (t instanceof
|
|
614
|
+
else if (t instanceof $)
|
|
615
615
|
b(t.expression);
|
|
616
616
|
else if (t instanceof ue)
|
|
617
617
|
b(t.value);
|
|
618
|
-
else if (t instanceof
|
|
618
|
+
else if (t instanceof ie)
|
|
619
619
|
b(t.variable);
|
|
620
620
|
else if (t instanceof ye)
|
|
621
621
|
b(t.literal);
|
|
622
622
|
else
|
|
623
623
|
throw t instanceof tt ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
624
624
|
}
|
|
625
|
-
function
|
|
625
|
+
function Ft(t) {
|
|
626
626
|
return !!(t != null && t.isInvalid);
|
|
627
627
|
}
|
|
628
|
-
function
|
|
628
|
+
function C(...t) {
|
|
629
629
|
return t.filter((e) => e !== void 0);
|
|
630
630
|
}
|
|
631
|
-
function
|
|
631
|
+
function Sn(t) {
|
|
632
632
|
if (t instanceof Z)
|
|
633
|
-
return
|
|
633
|
+
return C(...t.body, t.eof);
|
|
634
634
|
if (t instanceof y)
|
|
635
|
-
return
|
|
635
|
+
return C(
|
|
636
636
|
t.type,
|
|
637
637
|
t.name,
|
|
638
638
|
t.as,
|
|
@@ -641,68 +641,68 @@ function kn(t) {
|
|
|
641
641
|
t.bodyColon,
|
|
642
642
|
t.body
|
|
643
643
|
);
|
|
644
|
-
if (t instanceof se)
|
|
645
|
-
return X(t.name, t.colon, t.value);
|
|
646
644
|
if (t instanceof ne)
|
|
645
|
+
return C(t.name, t.colon, t.value);
|
|
646
|
+
if (t instanceof te)
|
|
647
647
|
return t.identifiers;
|
|
648
648
|
if (t instanceof ye)
|
|
649
649
|
return t.literal ? [t.literal] : [];
|
|
650
|
-
if (t instanceof
|
|
651
|
-
return
|
|
652
|
-
if (t instanceof
|
|
653
|
-
return
|
|
654
|
-
if (t instanceof
|
|
655
|
-
return
|
|
650
|
+
if (t instanceof ie)
|
|
651
|
+
return C(t.variable);
|
|
652
|
+
if (t instanceof oe)
|
|
653
|
+
return C(t.op, t.expression);
|
|
654
|
+
if (t instanceof le)
|
|
655
|
+
return C(t.leftExpression, t.op, t.rightExpression);
|
|
656
656
|
if (t instanceof Ye)
|
|
657
|
-
return
|
|
657
|
+
return C(t.expression, t.op);
|
|
658
658
|
if (t instanceof ue)
|
|
659
|
-
return
|
|
659
|
+
return C(t.value);
|
|
660
660
|
if (t instanceof w)
|
|
661
|
-
return
|
|
662
|
-
if (t instanceof
|
|
663
|
-
return
|
|
661
|
+
return C(t.callee, ...t.args);
|
|
662
|
+
if (t instanceof ae)
|
|
663
|
+
return C(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
664
664
|
if (t instanceof M)
|
|
665
|
-
return
|
|
665
|
+
return C(
|
|
666
666
|
t.listOpenBracket,
|
|
667
|
-
...
|
|
667
|
+
...Tt(t.elementList, t.commaList),
|
|
668
668
|
t.listCloseBracket
|
|
669
669
|
);
|
|
670
|
-
if (t instanceof
|
|
671
|
-
return
|
|
670
|
+
if (t instanceof ce)
|
|
671
|
+
return C(
|
|
672
672
|
t.tupleOpenParen,
|
|
673
|
-
...
|
|
673
|
+
...Tt(t.elementList, t.commaList),
|
|
674
674
|
t.tupleCloseParen
|
|
675
675
|
);
|
|
676
|
-
if (t instanceof
|
|
677
|
-
return
|
|
678
|
-
if (t instanceof
|
|
679
|
-
return
|
|
676
|
+
if (t instanceof H)
|
|
677
|
+
return C(t.callee, t.argumentList);
|
|
678
|
+
if (t instanceof $)
|
|
679
|
+
return C(t.expression);
|
|
680
680
|
if (t instanceof he)
|
|
681
|
-
return
|
|
681
|
+
return C(
|
|
682
682
|
t.array,
|
|
683
683
|
t.indexer
|
|
684
684
|
);
|
|
685
|
-
if (t instanceof
|
|
686
|
-
return
|
|
685
|
+
if (t instanceof Le)
|
|
686
|
+
return C(t.partial);
|
|
687
687
|
throw t instanceof tt ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
688
688
|
}
|
|
689
689
|
function Ze(t) {
|
|
690
|
-
return
|
|
690
|
+
return j(t) ? new U(t.expression.variable) : new S();
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function W(t) {
|
|
693
693
|
var e;
|
|
694
|
-
return t instanceof
|
|
694
|
+
return t instanceof $ && (t.expression instanceof ie && t.expression.variable instanceof J && t.expression.variable.kind === h.QUOTED_STRING || t.expression instanceof ye && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.STRING_LITERAL);
|
|
695
695
|
}
|
|
696
|
-
function
|
|
697
|
-
return t instanceof
|
|
696
|
+
function j(t) {
|
|
697
|
+
return t instanceof $ && t.expression instanceof ie && t.expression.variable instanceof J;
|
|
698
698
|
}
|
|
699
699
|
function fe(t) {
|
|
700
700
|
var e;
|
|
701
|
-
return t instanceof
|
|
701
|
+
return t instanceof $ && t.expression instanceof ie && ((e = t.expression.variable) == null ? void 0 : e.kind) === h.IDENTIFIER;
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function ze(t) {
|
|
704
704
|
var e;
|
|
705
|
-
return t instanceof
|
|
705
|
+
return t instanceof le && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
706
706
|
}
|
|
707
707
|
function we(t) {
|
|
708
708
|
if (t === void 0)
|
|
@@ -710,7 +710,7 @@ function we(t) {
|
|
|
710
710
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
711
711
|
return e === "" ? new S() : new U(e);
|
|
712
712
|
}
|
|
713
|
-
class
|
|
713
|
+
class Dn {
|
|
714
714
|
// list of errors during lexing
|
|
715
715
|
constructor(e) {
|
|
716
716
|
this.start = {
|
|
@@ -750,7 +750,7 @@ class Pn {
|
|
|
750
750
|
this.tokens.push(this.createToken(e, n));
|
|
751
751
|
}
|
|
752
752
|
createToken(e, n = !1) {
|
|
753
|
-
return
|
|
753
|
+
return J.create(
|
|
754
754
|
e,
|
|
755
755
|
this.start,
|
|
756
756
|
this.current,
|
|
@@ -759,7 +759,7 @@ class Pn {
|
|
|
759
759
|
);
|
|
760
760
|
}
|
|
761
761
|
lex() {
|
|
762
|
-
return this.scanTokens(), this.tokens.push(
|
|
762
|
+
return this.scanTokens(), this.tokens.push(J.create(h.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new K(this.tokens, this.errors);
|
|
763
763
|
}
|
|
764
764
|
scanTokens() {
|
|
765
765
|
for (; !this.isAtEnd(); ) {
|
|
@@ -823,11 +823,11 @@ class Pn {
|
|
|
823
823
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
|
|
824
824
|
break;
|
|
825
825
|
default:
|
|
826
|
-
if (
|
|
826
|
+
if (dt(e)) {
|
|
827
827
|
this.operator();
|
|
828
828
|
break;
|
|
829
829
|
}
|
|
830
|
-
if (
|
|
830
|
+
if (He(e)) {
|
|
831
831
|
this.identifier();
|
|
832
832
|
break;
|
|
833
833
|
}
|
|
@@ -851,13 +851,13 @@ class Pn {
|
|
|
851
851
|
let e = !0, n = [], s;
|
|
852
852
|
const i = [];
|
|
853
853
|
for (const a of this.tokens)
|
|
854
|
-
|
|
854
|
+
cn(a) ? (n.push(a), a.kind === h.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? a.leadingTrivia = n : s.trailingTrivia = n, i.push(a), n = [], s = a, e = !1);
|
|
855
855
|
this.tokens = i;
|
|
856
856
|
}
|
|
857
857
|
gatherInvalid() {
|
|
858
858
|
let e;
|
|
859
859
|
const n = [], s = [];
|
|
860
|
-
for (e = 0; e < this.tokens.length &&
|
|
860
|
+
for (e = 0; e < this.tokens.length && Ft(this.tokens[e]); e += 1)
|
|
861
861
|
s.push(this.tokens[e]);
|
|
862
862
|
let i = this.tokens[e];
|
|
863
863
|
for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
@@ -899,7 +899,7 @@ class Pn {
|
|
|
899
899
|
);
|
|
900
900
|
return;
|
|
901
901
|
}
|
|
902
|
-
r && this.match(n), this.tokens.push(
|
|
902
|
+
r && this.match(n), this.tokens.push(J.create(e, this.start, this.current, c, !1));
|
|
903
903
|
}
|
|
904
904
|
singleLineStringLiteral() {
|
|
905
905
|
this.consumeUntil(h.STRING_LITERAL, "'", {
|
|
@@ -951,7 +951,7 @@ class Pn {
|
|
|
951
951
|
this.addToken(h.IDENTIFIER);
|
|
952
952
|
}
|
|
953
953
|
operator() {
|
|
954
|
-
for (;
|
|
954
|
+
for (; dt(this.peek()); )
|
|
955
955
|
this.advance();
|
|
956
956
|
this.addToken(h.OP);
|
|
957
957
|
}
|
|
@@ -1027,7 +1027,7 @@ class Pn {
|
|
|
1027
1027
|
let n = "";
|
|
1028
1028
|
for (let s = 0; s <= 3; s += 1) {
|
|
1029
1029
|
if (this.isAtEnd() || !ve(this.peek()))
|
|
1030
|
-
return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,
|
|
1030
|
+
return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, J.create(h.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
|
|
1031
1031
|
n += this.advance();
|
|
1032
1032
|
}
|
|
1033
1033
|
return String.fromCharCode(parseInt(n, 16));
|
|
@@ -1038,7 +1038,7 @@ class Pn {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
1040
|
var Be = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Be || {});
|
|
1041
|
-
class
|
|
1041
|
+
class xn {
|
|
1042
1042
|
constructor() {
|
|
1043
1043
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
1044
1044
|
}
|
|
@@ -1104,7 +1104,7 @@ class Sn {
|
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
1106
1106
|
}
|
|
1107
|
-
class
|
|
1107
|
+
class On {
|
|
1108
1108
|
constructor(e) {
|
|
1109
1109
|
this.generator = e;
|
|
1110
1110
|
}
|
|
@@ -1112,20 +1112,20 @@ class xn {
|
|
|
1112
1112
|
return new e(n, this.generator.nextId());
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
|
-
class
|
|
1115
|
+
class T {
|
|
1116
1116
|
constructor(e, n, s) {
|
|
1117
1117
|
this.token = e, this.partialNode = n, this.handlerContext = s;
|
|
1118
1118
|
}
|
|
1119
1119
|
}
|
|
1120
|
-
class
|
|
1120
|
+
class Rn {
|
|
1121
1121
|
constructor(e, n) {
|
|
1122
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1122
|
+
this.current = 0, this.errors = [], this.contextStack = new xn(), this.synchronizeProgram = () => {
|
|
1123
1123
|
const s = this.peek();
|
|
1124
1124
|
s.kind !== h.EOF ? b(this.advance()) : (b(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1125
1125
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1126
1126
|
for (; !this.isAtEnd(); ) {
|
|
1127
1127
|
const s = this.peek();
|
|
1128
|
-
if (
|
|
1128
|
+
if (mt(s) || this.check(h.COLON, h.LBRACE, h.LBRACKET))
|
|
1129
1129
|
break;
|
|
1130
1130
|
b(s), this.advance();
|
|
1131
1131
|
}
|
|
@@ -1137,37 +1137,37 @@ class Dn {
|
|
|
1137
1137
|
b(s), this.advance();
|
|
1138
1138
|
}
|
|
1139
1139
|
}, this.blockExpression = this.contextStack.withContextDo(Be.BlockExpression, () => {
|
|
1140
|
-
const s = { body: [] }, i = () => this.nodeFactory.create(
|
|
1140
|
+
const s = { body: [] }, i = () => this.nodeFactory.create(ae, s);
|
|
1141
1141
|
try {
|
|
1142
1142
|
this.consume("Expect an opening brace '{'", h.LBRACE), s.blockOpenBrace = this.previous();
|
|
1143
1143
|
} catch (a) {
|
|
1144
|
-
if (!(a instanceof
|
|
1144
|
+
if (!(a instanceof T))
|
|
1145
1145
|
throw a;
|
|
1146
1146
|
if (s.blockOpenBrace = a.partialNode, !this.canHandle(a))
|
|
1147
|
-
throw new
|
|
1147
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1148
1148
|
this.synchronizeBlock();
|
|
1149
1149
|
}
|
|
1150
1150
|
for (; !this.isAtEnd() && !this.check(h.RBRACE); )
|
|
1151
1151
|
try {
|
|
1152
1152
|
if (this.match(h.TILDE)) {
|
|
1153
|
-
const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(
|
|
1153
|
+
const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(Le, { op: a, partial: r });
|
|
1154
1154
|
s.body.push(c);
|
|
1155
1155
|
} else
|
|
1156
1156
|
s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
|
|
1157
1157
|
} catch (a) {
|
|
1158
|
-
if (!(a instanceof
|
|
1158
|
+
if (!(a instanceof T))
|
|
1159
1159
|
throw a;
|
|
1160
1160
|
if (s.body.push(a.partialNode), !this.canHandle(a))
|
|
1161
|
-
throw new
|
|
1161
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1162
1162
|
this.synchronizeBlock();
|
|
1163
1163
|
}
|
|
1164
1164
|
try {
|
|
1165
1165
|
this.consume("Expect a closing brace '}'", h.RBRACE), s.blockCloseBrace = this.previous();
|
|
1166
1166
|
} catch (a) {
|
|
1167
|
-
if (!(a instanceof
|
|
1167
|
+
if (!(a instanceof T))
|
|
1168
1168
|
throw a;
|
|
1169
1169
|
if (s.blockCloseBrace = a.partialNode, !this.canHandle(a))
|
|
1170
|
-
throw new
|
|
1170
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1171
1171
|
this.synchronizeBlock();
|
|
1172
1172
|
}
|
|
1173
1173
|
return i();
|
|
@@ -1175,7 +1175,7 @@ class Dn {
|
|
|
1175
1175
|
if (!this.check(h.RBRACE))
|
|
1176
1176
|
for (b(this.advance()); !this.isAtEnd(); ) {
|
|
1177
1177
|
const s = this.peek();
|
|
1178
|
-
if (this.check(h.RBRACE) ||
|
|
1178
|
+
if (this.check(h.RBRACE) || Nt(this.previous(), s))
|
|
1179
1179
|
break;
|
|
1180
1180
|
b(s), this.advance();
|
|
1181
1181
|
}
|
|
@@ -1184,43 +1184,43 @@ class Dn {
|
|
|
1184
1184
|
groupOpenParen: s.tupleOpenParen,
|
|
1185
1185
|
groupCloseParen: s.tupleCloseParen,
|
|
1186
1186
|
expression: s.elementList[0]
|
|
1187
|
-
}), a = () => this.nodeFactory.create(
|
|
1187
|
+
}), a = () => this.nodeFactory.create(ce, s);
|
|
1188
1188
|
try {
|
|
1189
1189
|
this.consume("Expect an opening parenthesis '('", h.LPAREN), s.tupleOpenParen = this.previous();
|
|
1190
1190
|
} catch (r) {
|
|
1191
|
-
if (!(r instanceof
|
|
1191
|
+
if (!(r instanceof T))
|
|
1192
1192
|
throw r;
|
|
1193
1193
|
if (s.tupleOpenParen = r.partialNode, !this.canHandle(r))
|
|
1194
|
-
throw new
|
|
1194
|
+
throw new T(r.token, a(), r.handlerContext);
|
|
1195
1195
|
this.synchronizeTuple();
|
|
1196
1196
|
}
|
|
1197
1197
|
if (!this.isAtEnd() && !this.check(h.RPAREN))
|
|
1198
1198
|
try {
|
|
1199
1199
|
s.elementList.push(this.normalExpression());
|
|
1200
1200
|
} catch (r) {
|
|
1201
|
-
if (!(r instanceof
|
|
1201
|
+
if (!(r instanceof T))
|
|
1202
1202
|
throw r;
|
|
1203
1203
|
if (s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1204
|
-
throw new
|
|
1204
|
+
throw new T(r.token, i(), r.handlerContext);
|
|
1205
1205
|
this.synchronizeTuple();
|
|
1206
1206
|
}
|
|
1207
1207
|
for (; !this.isAtEnd() && !this.check(h.RPAREN); )
|
|
1208
1208
|
try {
|
|
1209
1209
|
this.consume("Expect a comma ','", h.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
|
|
1210
1210
|
} catch (r) {
|
|
1211
|
-
if (!(r instanceof
|
|
1211
|
+
if (!(r instanceof T))
|
|
1212
1212
|
throw r;
|
|
1213
|
-
if (r.partialNode instanceof
|
|
1214
|
-
throw new
|
|
1213
|
+
if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1214
|
+
throw new T(r.token, a(), r.handlerContext);
|
|
1215
1215
|
this.synchronizeTuple();
|
|
1216
1216
|
}
|
|
1217
1217
|
try {
|
|
1218
1218
|
this.consume("Expect a closing parenthesis ')'", h.RPAREN), s.tupleCloseParen = this.previous();
|
|
1219
1219
|
} catch (r) {
|
|
1220
|
-
if (!(r instanceof
|
|
1220
|
+
if (!(r instanceof T))
|
|
1221
1221
|
throw r;
|
|
1222
1222
|
if (s.tupleCloseParen = r.partialNode, !this.canHandle(r))
|
|
1223
|
-
throw new
|
|
1223
|
+
throw new T(r.token, a(), r.handlerContext);
|
|
1224
1224
|
this.synchronizeTuple();
|
|
1225
1225
|
}
|
|
1226
1226
|
return s.elementList.length === 1 ? i() : a();
|
|
@@ -1236,39 +1236,39 @@ class Dn {
|
|
|
1236
1236
|
try {
|
|
1237
1237
|
this.consume("Expect an opening bracket '['", h.LBRACKET), s.listOpenBracket = this.previous();
|
|
1238
1238
|
} catch (a) {
|
|
1239
|
-
if (!(a instanceof
|
|
1239
|
+
if (!(a instanceof T))
|
|
1240
1240
|
throw a;
|
|
1241
1241
|
if (s.listOpenBracket = a.partialNode, !this.canHandle(a))
|
|
1242
|
-
throw new
|
|
1242
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1243
1243
|
this.synchronizeList();
|
|
1244
1244
|
}
|
|
1245
1245
|
if (!this.isAtEnd() && !this.check(h.RBRACKET))
|
|
1246
1246
|
try {
|
|
1247
1247
|
s.elementList.push(this.attribute());
|
|
1248
1248
|
} catch (a) {
|
|
1249
|
-
if (!(a instanceof
|
|
1249
|
+
if (!(a instanceof T))
|
|
1250
1250
|
throw a;
|
|
1251
1251
|
if (s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1252
|
-
throw new
|
|
1252
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1253
1253
|
this.synchronizeList();
|
|
1254
1254
|
}
|
|
1255
1255
|
for (; !this.isAtEnd() && !this.check(h.RBRACKET); )
|
|
1256
1256
|
try {
|
|
1257
1257
|
this.consume("Expect a comma ','", h.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
|
|
1258
1258
|
} catch (a) {
|
|
1259
|
-
if (!(a instanceof
|
|
1259
|
+
if (!(a instanceof T))
|
|
1260
1260
|
throw a;
|
|
1261
|
-
if (a.partialNode instanceof
|
|
1262
|
-
throw new
|
|
1261
|
+
if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1262
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1263
1263
|
this.synchronizeList();
|
|
1264
1264
|
}
|
|
1265
1265
|
try {
|
|
1266
1266
|
this.consume("Expect a closing bracket ']'", h.RBRACKET), s.listCloseBracket = this.previous();
|
|
1267
1267
|
} catch (a) {
|
|
1268
|
-
if (!(a instanceof
|
|
1268
|
+
if (!(a instanceof T))
|
|
1269
1269
|
throw a;
|
|
1270
1270
|
if (s.listCloseBracket = a.partialNode, !this.canHandle(a))
|
|
1271
|
-
throw new
|
|
1271
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1272
1272
|
this.synchronizeList();
|
|
1273
1273
|
}
|
|
1274
1274
|
return i();
|
|
@@ -1293,7 +1293,7 @@ class Dn {
|
|
|
1293
1293
|
break;
|
|
1294
1294
|
b(s), this.advance();
|
|
1295
1295
|
}
|
|
1296
|
-
}, this.tokens = e, this.nodeFactory = new
|
|
1296
|
+
}, this.tokens = e, this.nodeFactory = new On(n);
|
|
1297
1297
|
}
|
|
1298
1298
|
isAtEnd() {
|
|
1299
1299
|
return this.current >= this.tokens.length || this.tokens[this.current].kind === h.EOF;
|
|
@@ -1320,7 +1320,7 @@ class Dn {
|
|
|
1320
1320
|
}
|
|
1321
1321
|
consume(e, ...n) {
|
|
1322
1322
|
if (!this.match(...n))
|
|
1323
|
-
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, e), new
|
|
1323
|
+
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, e), new T(
|
|
1324
1324
|
this.peek(),
|
|
1325
1325
|
void 0,
|
|
1326
1326
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1350,7 +1350,7 @@ class Dn {
|
|
|
1350
1350
|
}
|
|
1351
1351
|
parse() {
|
|
1352
1352
|
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(Z, { body: e, eof: n });
|
|
1353
|
-
return this.gatherInvalid(), new
|
|
1353
|
+
return this.gatherInvalid(), new K({ ast: s, tokens: this.tokens }, this.errors);
|
|
1354
1354
|
}
|
|
1355
1355
|
/* Parsing and synchronizing ProgramNode */
|
|
1356
1356
|
program() {
|
|
@@ -1360,7 +1360,7 @@ class Dn {
|
|
|
1360
1360
|
const n = this.elementDeclaration();
|
|
1361
1361
|
e.push(n);
|
|
1362
1362
|
} catch (n) {
|
|
1363
|
-
if (!(n instanceof
|
|
1363
|
+
if (!(n instanceof T))
|
|
1364
1364
|
throw n;
|
|
1365
1365
|
e.push(n.partialNode), this.synchronizeProgram();
|
|
1366
1366
|
}
|
|
@@ -1372,35 +1372,35 @@ class Dn {
|
|
|
1372
1372
|
try {
|
|
1373
1373
|
this.consume("Expect an identifier", h.IDENTIFIER), e.type = this.previous();
|
|
1374
1374
|
} catch (s) {
|
|
1375
|
-
throw s instanceof
|
|
1375
|
+
throw s instanceof T ? (e.type = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1376
1376
|
}
|
|
1377
1377
|
if (!this.check(h.COLON, h.LBRACE, h.LBRACKET))
|
|
1378
1378
|
try {
|
|
1379
1379
|
e.name = this.normalExpression();
|
|
1380
1380
|
} catch (s) {
|
|
1381
|
-
if (!(s instanceof
|
|
1381
|
+
if (!(s instanceof T))
|
|
1382
1382
|
throw s;
|
|
1383
1383
|
if (e.name = s.partialNode, !this.canHandle(s))
|
|
1384
|
-
throw new
|
|
1384
|
+
throw new T(s.token, n(), s.handlerContext);
|
|
1385
1385
|
this.synchronizeElementDeclarationName();
|
|
1386
1386
|
}
|
|
1387
|
-
if (
|
|
1387
|
+
if (mt(this.peek()))
|
|
1388
1388
|
if (e.as = this.advance(), this.check(h.COLON, h.LBRACE, h.LBRACKET))
|
|
1389
1389
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1390
1390
|
else
|
|
1391
1391
|
try {
|
|
1392
1392
|
e.alias = this.normalExpression();
|
|
1393
1393
|
} catch (s) {
|
|
1394
|
-
if (!(s instanceof
|
|
1394
|
+
if (!(s instanceof T))
|
|
1395
1395
|
throw s;
|
|
1396
1396
|
if (e.alias = s.partialNode, !this.canHandle(s))
|
|
1397
|
-
throw new
|
|
1397
|
+
throw new T(s.token, n(), s.handlerContext);
|
|
1398
1398
|
this.synchronizeElementDeclarationAlias();
|
|
1399
1399
|
}
|
|
1400
1400
|
try {
|
|
1401
1401
|
e.attributeList = this.check(h.LBRACKET) ? this.listExpression() : void 0;
|
|
1402
1402
|
} catch (s) {
|
|
1403
|
-
throw s instanceof
|
|
1403
|
+
throw s instanceof T ? (e.attributeList = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1404
1404
|
}
|
|
1405
1405
|
if (!this.discardUntil(
|
|
1406
1406
|
"Expect an opening brace '{' or a colon ':'",
|
|
@@ -1416,7 +1416,7 @@ class Dn {
|
|
|
1416
1416
|
} else
|
|
1417
1417
|
e.body = this.blockExpression();
|
|
1418
1418
|
} catch (s) {
|
|
1419
|
-
throw s instanceof
|
|
1419
|
+
throw s instanceof T ? (e.body = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1420
1420
|
}
|
|
1421
1421
|
return this.nodeFactory.create(y, e);
|
|
1422
1422
|
}
|
|
@@ -1431,30 +1431,30 @@ class Dn {
|
|
|
1431
1431
|
try {
|
|
1432
1432
|
this.consume("Expect an identifier", h.IDENTIFIER), e.type = this.previous();
|
|
1433
1433
|
} catch (s) {
|
|
1434
|
-
throw s instanceof
|
|
1434
|
+
throw s instanceof T ? (e.type = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1435
1435
|
}
|
|
1436
1436
|
try {
|
|
1437
1437
|
this.consume("Expect a colon ':'", h.COLON), e.bodyColon = this.previous();
|
|
1438
1438
|
} catch (s) {
|
|
1439
|
-
throw s instanceof
|
|
1439
|
+
throw s instanceof T ? (e.bodyColon = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1440
1440
|
}
|
|
1441
1441
|
try {
|
|
1442
1442
|
const s = this.expression();
|
|
1443
1443
|
s instanceof y ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1444
1444
|
} catch (s) {
|
|
1445
|
-
throw s instanceof
|
|
1445
|
+
throw s instanceof T ? (e.body = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1446
1446
|
}
|
|
1447
1447
|
return this.nodeFactory.create(y, e);
|
|
1448
1448
|
}
|
|
1449
1449
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1450
1450
|
expression() {
|
|
1451
|
-
const e = { args: [] }, n = () =>
|
|
1451
|
+
const e = { args: [] }, n = () => yn(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1452
1452
|
this.nodeFactory.create(w, e)
|
|
1453
1453
|
);
|
|
1454
1454
|
try {
|
|
1455
1455
|
e.callee = this.normalExpression();
|
|
1456
1456
|
} catch (i) {
|
|
1457
|
-
throw i instanceof
|
|
1457
|
+
throw i instanceof T ? (e.callee = i.partialNode, new T(i.token, n(), i.handlerContext)) : i;
|
|
1458
1458
|
}
|
|
1459
1459
|
if (this.shouldStopExpression())
|
|
1460
1460
|
return n();
|
|
@@ -1464,13 +1464,13 @@ class Dn {
|
|
|
1464
1464
|
try {
|
|
1465
1465
|
s = this.normalExpression(), e.args.push(s);
|
|
1466
1466
|
} catch (i) {
|
|
1467
|
-
throw i instanceof
|
|
1467
|
+
throw i instanceof T ? (s = i.partialNode, e.args.push(s), new T(i.token, n(), i.handlerContext)) : i;
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
1470
|
return n();
|
|
1471
1471
|
}
|
|
1472
1472
|
shouldStopExpression() {
|
|
1473
|
-
if (this.isAtEnd() ||
|
|
1473
|
+
if (this.isAtEnd() || St(this.previous()))
|
|
1474
1474
|
return !0;
|
|
1475
1475
|
const e = this.peek().kind;
|
|
1476
1476
|
return e === h.RBRACE || e === h.RBRACKET || e === h.RPAREN || e === h.COMMA || e === h.COLON;
|
|
@@ -1484,23 +1484,23 @@ class Dn {
|
|
|
1484
1484
|
for (; !this.isAtEnd(); ) {
|
|
1485
1485
|
const s = this.peek();
|
|
1486
1486
|
if (s.kind === h.LPAREN) {
|
|
1487
|
-
const { left: i } =
|
|
1487
|
+
const { left: i } = bt(s);
|
|
1488
1488
|
if (i < e || // When '(' is encountered,
|
|
1489
1489
|
// consider it part of another expression if
|
|
1490
1490
|
// it's at the start of a new line
|
|
1491
1491
|
// and we're currently not having unmatched '(' or '['
|
|
1492
|
-
|
|
1492
|
+
Nt(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1493
1493
|
break;
|
|
1494
1494
|
try {
|
|
1495
|
-
n = this.nodeFactory.create(
|
|
1495
|
+
n = this.nodeFactory.create(H, {
|
|
1496
1496
|
callee: n,
|
|
1497
1497
|
argumentList: this.tupleExpression()
|
|
1498
1498
|
});
|
|
1499
1499
|
} catch (a) {
|
|
1500
|
-
throw a instanceof
|
|
1500
|
+
throw a instanceof T ? (n = this.nodeFactory.create(H, {
|
|
1501
1501
|
callee: n,
|
|
1502
1502
|
argumentList: a.partialNode
|
|
1503
|
-
}), new
|
|
1503
|
+
}), new T(a.token, n, a.handlerContext)) : a;
|
|
1504
1504
|
}
|
|
1505
1505
|
} else if (s.kind === h.LBRACKET) {
|
|
1506
1506
|
if (et(this.previous()))
|
|
@@ -1511,13 +1511,13 @@ class Dn {
|
|
|
1511
1511
|
indexer: this.listExpression()
|
|
1512
1512
|
});
|
|
1513
1513
|
} catch (i) {
|
|
1514
|
-
throw i instanceof
|
|
1514
|
+
throw i instanceof T ? (n = this.nodeFactory.create(he, {
|
|
1515
1515
|
expression: n,
|
|
1516
1516
|
indexer: i.partialNode
|
|
1517
|
-
}), new
|
|
1517
|
+
}), new T(i.token, n, i.handlerContext)) : i;
|
|
1518
1518
|
}
|
|
1519
|
-
} else if (
|
|
1520
|
-
const i = s, a =
|
|
1519
|
+
} else if (Et(s)) {
|
|
1520
|
+
const i = s, a = bt(i);
|
|
1521
1521
|
if (a.left !== null) {
|
|
1522
1522
|
if (a.left <= e)
|
|
1523
1523
|
break;
|
|
@@ -1526,22 +1526,22 @@ class Dn {
|
|
|
1526
1526
|
op: i
|
|
1527
1527
|
});
|
|
1528
1528
|
} else {
|
|
1529
|
-
const r =
|
|
1529
|
+
const r = Mn(i);
|
|
1530
1530
|
if (r.left === null || r.left <= e)
|
|
1531
1531
|
break;
|
|
1532
1532
|
this.advance();
|
|
1533
1533
|
try {
|
|
1534
|
-
n = this.nodeFactory.create(
|
|
1534
|
+
n = this.nodeFactory.create(le, {
|
|
1535
1535
|
leftExpression: n,
|
|
1536
1536
|
op: i,
|
|
1537
1537
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(r.right)
|
|
1538
1538
|
});
|
|
1539
1539
|
} catch (c) {
|
|
1540
|
-
throw c instanceof
|
|
1540
|
+
throw c instanceof T ? (n = this.nodeFactory.create(le, {
|
|
1541
1541
|
leftExpression: n,
|
|
1542
1542
|
op: i,
|
|
1543
1543
|
rightExpression: c.partialNode
|
|
1544
|
-
}), new
|
|
1544
|
+
}), new T(c.token, n, c.handlerContext)) : c;
|
|
1545
1545
|
}
|
|
1546
1546
|
}
|
|
1547
1547
|
} else
|
|
@@ -1551,16 +1551,16 @@ class Dn {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
leftExpression_bp() {
|
|
1553
1553
|
let e;
|
|
1554
|
-
if (
|
|
1554
|
+
if (Et(this.peek())) {
|
|
1555
1555
|
const n = {};
|
|
1556
1556
|
n.op = this.peek();
|
|
1557
|
-
const s =
|
|
1557
|
+
const s = Bn(n.op);
|
|
1558
1558
|
if (s.right === null)
|
|
1559
1559
|
throw this.logError(
|
|
1560
1560
|
n.op,
|
|
1561
1561
|
o.UNKNOWN_PREFIX_OP,
|
|
1562
1562
|
`Unexpected '${n.op.value}' in an expression`
|
|
1563
|
-
), new
|
|
1563
|
+
), new T(
|
|
1564
1564
|
n.op,
|
|
1565
1565
|
this.nodeFactory.create(Me, { pre: n.op }),
|
|
1566
1566
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1569,15 +1569,15 @@ class Dn {
|
|
|
1569
1569
|
try {
|
|
1570
1570
|
n.expression = this.expression_bp(s.right);
|
|
1571
1571
|
} catch (i) {
|
|
1572
|
-
throw i instanceof
|
|
1572
|
+
throw i instanceof T ? (n.expression = i.partialNode, new T(
|
|
1573
1573
|
i.token,
|
|
1574
|
-
this.nodeFactory.create(
|
|
1574
|
+
this.nodeFactory.create(oe, n),
|
|
1575
1575
|
i.handlerContext
|
|
1576
1576
|
)) : i;
|
|
1577
1577
|
}
|
|
1578
|
-
e = this.nodeFactory.create(
|
|
1578
|
+
e = this.nodeFactory.create(oe, n);
|
|
1579
1579
|
} else if (e = this.extractOperand(), e instanceof Me)
|
|
1580
|
-
throw new
|
|
1580
|
+
throw new T(
|
|
1581
1581
|
this.peek(),
|
|
1582
1582
|
this.nodeFactory.create(Me, { pre: this.peek() }),
|
|
1583
1583
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1611,7 +1611,7 @@ class Dn {
|
|
|
1611
1611
|
try {
|
|
1612
1612
|
this.consume("Expect a function expression", h.FUNCTION_EXPRESSION), e.value = this.previous();
|
|
1613
1613
|
} catch (n) {
|
|
1614
|
-
throw n instanceof
|
|
1614
|
+
throw n instanceof T ? (e.value = n.partialNode, new T(
|
|
1615
1615
|
n.token,
|
|
1616
1616
|
this.nodeFactory.create(ue, e),
|
|
1617
1617
|
n.handlerContext
|
|
@@ -1622,7 +1622,7 @@ class Dn {
|
|
|
1622
1622
|
variable() {
|
|
1623
1623
|
this.consume("Expect a variable", h.IDENTIFIER);
|
|
1624
1624
|
const e = this.previous();
|
|
1625
|
-
return this.nodeFactory.create(
|
|
1625
|
+
return this.nodeFactory.create(ie, { variable: e });
|
|
1626
1626
|
}
|
|
1627
1627
|
canBeField() {
|
|
1628
1628
|
return this.peek().kind === h.IDENTIFIER && this.peek(1).kind === h.COLON;
|
|
@@ -1634,14 +1634,14 @@ class Dn {
|
|
|
1634
1634
|
h.STRING_LITERAL,
|
|
1635
1635
|
h.NUMERIC_LITERAL
|
|
1636
1636
|
))
|
|
1637
|
-
return this.nodeFactory.create(
|
|
1637
|
+
return this.nodeFactory.create($, {
|
|
1638
1638
|
expression: this.nodeFactory.create(ye, { literal: this.previous() })
|
|
1639
1639
|
});
|
|
1640
1640
|
if (this.match(h.QUOTED_STRING, h.IDENTIFIER))
|
|
1641
|
-
return this.nodeFactory.create(
|
|
1642
|
-
expression: this.nodeFactory.create(
|
|
1641
|
+
return this.nodeFactory.create($, {
|
|
1642
|
+
expression: this.nodeFactory.create(ie, { variable: this.previous() })
|
|
1643
1643
|
});
|
|
1644
|
-
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new
|
|
1644
|
+
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new T(
|
|
1645
1645
|
this.peek(),
|
|
1646
1646
|
void 0,
|
|
1647
1647
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1655,29 +1655,29 @@ class Dn {
|
|
|
1655
1655
|
n,
|
|
1656
1656
|
o.EMPTY_ATTRIBUTE_NAME,
|
|
1657
1657
|
"Expect a non-empty attribute name"
|
|
1658
|
-
), e.name = this.nodeFactory.create(
|
|
1658
|
+
), e.name = this.nodeFactory.create(te, { identifiers: [] });
|
|
1659
1659
|
} else
|
|
1660
1660
|
try {
|
|
1661
1661
|
e.name = this.attributeName();
|
|
1662
1662
|
} catch (n) {
|
|
1663
|
-
if (!(n instanceof
|
|
1663
|
+
if (!(n instanceof T))
|
|
1664
1664
|
throw n;
|
|
1665
1665
|
if (e.name = n.partialNode, !this.canHandle(n))
|
|
1666
|
-
throw new
|
|
1666
|
+
throw new T(
|
|
1667
1667
|
n.token,
|
|
1668
|
-
this.nodeFactory.create(
|
|
1668
|
+
this.nodeFactory.create(ne, e),
|
|
1669
1669
|
n.handlerContext
|
|
1670
1670
|
);
|
|
1671
1671
|
this.synchronizeAttributeName();
|
|
1672
1672
|
}
|
|
1673
|
-
return this.match(h.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(
|
|
1673
|
+
return this.match(h.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ne, e);
|
|
1674
1674
|
}
|
|
1675
1675
|
attributeValue() {
|
|
1676
1676
|
let e;
|
|
1677
1677
|
try {
|
|
1678
1678
|
e = this.peek().kind === h.IDENTIFIER && this.peek(1).kind === h.IDENTIFIER ? this.attributeName() : this.normalExpression();
|
|
1679
1679
|
} catch (n) {
|
|
1680
|
-
if (!(n instanceof
|
|
1680
|
+
if (!(n instanceof T) || !this.canHandle(n))
|
|
1681
1681
|
throw n;
|
|
1682
1682
|
e = n.partialNode, this.synchronizeAttributeValue();
|
|
1683
1683
|
}
|
|
@@ -1691,19 +1691,19 @@ class Dn {
|
|
|
1691
1691
|
try {
|
|
1692
1692
|
this.consume("Expect an identifier", h.IDENTIFIER), e.push(this.previous());
|
|
1693
1693
|
} catch (n) {
|
|
1694
|
-
throw n instanceof
|
|
1694
|
+
throw n instanceof T ? new T(
|
|
1695
1695
|
n.token,
|
|
1696
|
-
this.nodeFactory.create(
|
|
1696
|
+
this.nodeFactory.create(te, { identifiers: e }),
|
|
1697
1697
|
n.handlerContext
|
|
1698
1698
|
) : n;
|
|
1699
1699
|
}
|
|
1700
|
-
return this.nodeFactory.create(
|
|
1700
|
+
return this.nodeFactory.create(te, { identifiers: e });
|
|
1701
1701
|
}
|
|
1702
1702
|
logError(e, n, s) {
|
|
1703
1703
|
this.errors.push(new l(n, s, e));
|
|
1704
1704
|
}
|
|
1705
1705
|
}
|
|
1706
|
-
const
|
|
1706
|
+
const Un = {
|
|
1707
1707
|
"+": { left: 9, right: 10 },
|
|
1708
1708
|
"*": { left: 11, right: 12 },
|
|
1709
1709
|
"-": { left: 9, right: 10 },
|
|
@@ -1719,10 +1719,10 @@ const On = {
|
|
|
1719
1719
|
"!=": { left: 4, right: 5 },
|
|
1720
1720
|
".": { left: 16, right: 17 }
|
|
1721
1721
|
};
|
|
1722
|
-
function
|
|
1723
|
-
return
|
|
1722
|
+
function Mn(t) {
|
|
1723
|
+
return Un[t.value] || { left: null, right: null };
|
|
1724
1724
|
}
|
|
1725
|
-
const
|
|
1725
|
+
const Fn = {
|
|
1726
1726
|
"+": { left: null, right: 15 },
|
|
1727
1727
|
"-": { left: null, right: 15 },
|
|
1728
1728
|
"<": { left: null, right: 15 },
|
|
@@ -1730,17 +1730,17 @@ const Un = {
|
|
|
1730
1730
|
"<>": { left: null, right: 15 },
|
|
1731
1731
|
"!": { left: null, right: 15 }
|
|
1732
1732
|
};
|
|
1733
|
-
function
|
|
1734
|
-
return
|
|
1733
|
+
function Bn(t) {
|
|
1734
|
+
return Fn[t.value] || { left: null, right: null };
|
|
1735
1735
|
}
|
|
1736
|
-
const
|
|
1736
|
+
const Vn = {
|
|
1737
1737
|
"(": { left: 14, right: null }
|
|
1738
1738
|
};
|
|
1739
|
-
function
|
|
1740
|
-
return
|
|
1739
|
+
function bt(t) {
|
|
1740
|
+
return Vn[t.value] || { left: null, right: null };
|
|
1741
1741
|
}
|
|
1742
|
-
var I = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t.TablePartial = "tablepartial", t))(I || {}),
|
|
1743
|
-
function
|
|
1742
|
+
var I = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t.TablePartial = "tablepartial", t))(I || {}), N = /* @__PURE__ */ ((t) => (t.Color = "color", t.HeaderColor = "headercolor", t.Note = "note", t.PK = "pk", t.PKey = "primary key", t.Unique = "unique", t.Ref = "ref", t.NotNull = "not null", t.Null = "null", t.Increment = "increment", t.Default = "default", t.Name = "name", t.Type = "type", t.Update = "update", t.Delete = "delete", t))(N || {});
|
|
1743
|
+
function Ae(t) {
|
|
1744
1744
|
var n;
|
|
1745
1745
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1746
1746
|
switch (e) {
|
|
@@ -1757,46 +1757,46 @@ function _e(t) {
|
|
|
1757
1757
|
return new S();
|
|
1758
1758
|
}
|
|
1759
1759
|
}
|
|
1760
|
-
function
|
|
1761
|
-
if (!
|
|
1760
|
+
function _e(t) {
|
|
1761
|
+
if (!ze(t))
|
|
1762
1762
|
return new U([t]);
|
|
1763
|
-
const e =
|
|
1763
|
+
const e = _e(t.leftExpression).unwrap_or(void 0);
|
|
1764
1764
|
return e ? (e.push(t.rightExpression), new U(e)) : new S();
|
|
1765
1765
|
}
|
|
1766
|
-
function
|
|
1766
|
+
function Y(t) {
|
|
1767
1767
|
if (t === void 0)
|
|
1768
1768
|
return new S();
|
|
1769
|
-
const e =
|
|
1769
|
+
const e = _e(t).unwrap_or(void 0);
|
|
1770
1770
|
if (!e)
|
|
1771
1771
|
return new S();
|
|
1772
1772
|
const n = [];
|
|
1773
1773
|
for (const s of e) {
|
|
1774
|
-
const i =
|
|
1774
|
+
const i = q(s).unwrap_or(void 0);
|
|
1775
1775
|
if (!i)
|
|
1776
1776
|
return new S();
|
|
1777
1777
|
n.push(i);
|
|
1778
1778
|
}
|
|
1779
1779
|
return new U(n);
|
|
1780
1780
|
}
|
|
1781
|
-
function
|
|
1781
|
+
function De(t) {
|
|
1782
1782
|
if (t === void 0)
|
|
1783
1783
|
return new S();
|
|
1784
|
-
const e =
|
|
1784
|
+
const e = _e(t).unwrap_or(void 0);
|
|
1785
1785
|
if (!e || e.length === 0)
|
|
1786
1786
|
return new S();
|
|
1787
1787
|
const n = [];
|
|
1788
1788
|
let s;
|
|
1789
|
-
if (!
|
|
1789
|
+
if (!j(g.last(e))) {
|
|
1790
1790
|
const i = e.pop();
|
|
1791
1791
|
if ($t(i))
|
|
1792
1792
|
s = i.elementList.map(
|
|
1793
|
-
(a) =>
|
|
1793
|
+
(a) => X(a).unwrap()
|
|
1794
1794
|
);
|
|
1795
1795
|
else
|
|
1796
1796
|
return new S();
|
|
1797
1797
|
}
|
|
1798
1798
|
for (const i of e) {
|
|
1799
|
-
const a =
|
|
1799
|
+
const a = q(i).unwrap_or(void 0);
|
|
1800
1800
|
if (!a)
|
|
1801
1801
|
return new S();
|
|
1802
1802
|
n.push(a);
|
|
@@ -1806,51 +1806,51 @@ function xe(t) {
|
|
|
1806
1806
|
tupleElements: s
|
|
1807
1807
|
});
|
|
1808
1808
|
}
|
|
1809
|
-
function
|
|
1810
|
-
return
|
|
1809
|
+
function q(t) {
|
|
1810
|
+
return j(t) ? new U(t.expression.variable.value) : new S();
|
|
1811
1811
|
}
|
|
1812
1812
|
function Xe(t) {
|
|
1813
|
-
if (
|
|
1813
|
+
if (It(t))
|
|
1814
1814
|
return t instanceof ue ? new U({ functional: [t], nonFunctional: [] }) : new U({ functional: [], nonFunctional: [t] });
|
|
1815
|
-
if (t instanceof
|
|
1815
|
+
if (t instanceof ce && t.elementList.every(It)) {
|
|
1816
1816
|
const e = t.elementList.filter(
|
|
1817
1817
|
(s) => s instanceof ue
|
|
1818
|
-
), n = t.elementList.filter(
|
|
1818
|
+
), n = t.elementList.filter(j);
|
|
1819
1819
|
return new U({ functional: e, nonFunctional: n });
|
|
1820
1820
|
}
|
|
1821
1821
|
return new S();
|
|
1822
1822
|
}
|
|
1823
|
-
function
|
|
1823
|
+
function X(t) {
|
|
1824
1824
|
var n;
|
|
1825
1825
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1826
1826
|
return e === void 0 ? new S() : new U(e);
|
|
1827
1827
|
}
|
|
1828
|
-
function
|
|
1828
|
+
function Gn(t) {
|
|
1829
1829
|
var n, s;
|
|
1830
1830
|
const e = (s = (n = t == null ? void 0 : t.partial) == null ? void 0 : n.variable) == null ? void 0 : s.value;
|
|
1831
1831
|
return e === void 0 ? new S() : new U(e);
|
|
1832
1832
|
}
|
|
1833
|
-
function
|
|
1834
|
-
return
|
|
1833
|
+
function V(t) {
|
|
1834
|
+
return W(t) ? t.expression instanceof ie ? new U(t.expression.variable.value) : new U(t.expression.literal.value) : new S();
|
|
1835
1835
|
}
|
|
1836
|
-
function
|
|
1836
|
+
function Cn(t) {
|
|
1837
1837
|
var e;
|
|
1838
|
-
return !(t instanceof
|
|
1838
|
+
return !(t instanceof le) || !Gt((e = t.op) == null ? void 0 : e.value) ? !1 : De(t.leftExpression).and_then(() => De(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1839
1839
|
}
|
|
1840
|
-
function
|
|
1841
|
-
const e =
|
|
1840
|
+
function Xn(t) {
|
|
1841
|
+
const e = De(t.leftExpression), n = De(t.rightExpression);
|
|
1842
1842
|
if (!e.isOk() || !n.isOk())
|
|
1843
1843
|
return !1;
|
|
1844
1844
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1845
1845
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1846
1846
|
}
|
|
1847
|
-
function
|
|
1848
|
-
return t instanceof
|
|
1847
|
+
function It(t) {
|
|
1848
|
+
return t instanceof $ && t.expression instanceof ie || t instanceof ue;
|
|
1849
1849
|
}
|
|
1850
|
-
function
|
|
1850
|
+
function Lt(t, e) {
|
|
1851
1851
|
var i, a, r, c;
|
|
1852
1852
|
let n = e;
|
|
1853
|
-
const s =
|
|
1853
|
+
const s = pn(t);
|
|
1854
1854
|
for (; n; ) {
|
|
1855
1855
|
if ((a = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && a.has(t))
|
|
1856
1856
|
return (r = n.symbol.symbolTable) == null ? void 0 : r.get(t);
|
|
@@ -1861,7 +1861,7 @@ function At(t, e) {
|
|
|
1861
1861
|
n = n.parent;
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
|
-
class
|
|
1864
|
+
class $n {
|
|
1865
1865
|
constructor(e, n, s) {
|
|
1866
1866
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1867
1867
|
}
|
|
@@ -1869,7 +1869,7 @@ class Cn {
|
|
|
1869
1869
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1870
1870
|
}
|
|
1871
1871
|
validateContext() {
|
|
1872
|
-
return this.declarationNode.parent instanceof Z ||
|
|
1872
|
+
return this.declarationNode.parent instanceof Z || Ae(this.declarationNode.parent).unwrap_or(void 0) !== I.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1873
1873
|
}
|
|
1874
1874
|
validateName(e) {
|
|
1875
1875
|
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1883,10 +1883,10 @@ class Cn {
|
|
|
1883
1883
|
validateBody(e) {
|
|
1884
1884
|
if (!e)
|
|
1885
1885
|
return [];
|
|
1886
|
-
if (e instanceof
|
|
1886
|
+
if (e instanceof ae)
|
|
1887
1887
|
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1888
1888
|
const n = [];
|
|
1889
|
-
return
|
|
1889
|
+
return W(e.callee) || n.push(new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1890
1890
|
}
|
|
1891
1891
|
}
|
|
1892
1892
|
class ke {
|
|
@@ -1909,7 +1909,7 @@ class ke {
|
|
|
1909
1909
|
return this.table.forEach(e);
|
|
1910
1910
|
}
|
|
1911
1911
|
}
|
|
1912
|
-
class
|
|
1912
|
+
class jn {
|
|
1913
1913
|
constructor(e, n, s) {
|
|
1914
1914
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1915
1915
|
}
|
|
@@ -1927,8 +1927,8 @@ class Xn {
|
|
|
1927
1927
|
}
|
|
1928
1928
|
registerElement() {
|
|
1929
1929
|
const e = [];
|
|
1930
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1931
|
-
const { name: n } = this.declarationNode, s =
|
|
1930
|
+
this.declarationNode.symbol = this.symbolFactory.create(Tn, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
1931
|
+
const { name: n } = this.declarationNode, s = Y(n);
|
|
1932
1932
|
if (s.isOk()) {
|
|
1933
1933
|
const i = s.unwrap(), a = i.pop(), r = Qe(i, this.publicSymbolTable, this.symbolFactory), c = st(a);
|
|
1934
1934
|
r.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${a} already exists in schema '${i.join(".") || "public"}'`, n)), r.set(c, this.declarationNode.symbol);
|
|
@@ -1949,19 +1949,19 @@ class Xn {
|
|
|
1949
1949
|
validateFields(e) {
|
|
1950
1950
|
return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1951
1951
|
const s = [];
|
|
1952
|
-
n.callee && !
|
|
1952
|
+
n.callee && !j(n.callee) && s.push(new l(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1953
1953
|
const i = [...n.args];
|
|
1954
1954
|
return g.last(i) instanceof M ? (s.push(...this.validateFieldSettings(g.last(i))), i.pop()) : i[0] instanceof M && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((a) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", a))), s.push(...this.registerField(n)), s;
|
|
1955
1955
|
});
|
|
1956
1956
|
}
|
|
1957
1957
|
validateFieldSettings(e) {
|
|
1958
|
-
const n =
|
|
1958
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
1959
1959
|
for (const a in i) {
|
|
1960
1960
|
const r = i[a];
|
|
1961
1961
|
switch (a) {
|
|
1962
1962
|
case "note":
|
|
1963
1963
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), r.forEach((c) => {
|
|
1964
|
-
|
|
1964
|
+
W(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1965
1965
|
});
|
|
1966
1966
|
break;
|
|
1967
1967
|
default:
|
|
@@ -1979,8 +1979,8 @@ class Xn {
|
|
|
1979
1979
|
});
|
|
1980
1980
|
}
|
|
1981
1981
|
registerField(e) {
|
|
1982
|
-
if (e.callee &&
|
|
1983
|
-
const n =
|
|
1982
|
+
if (e.callee && j(e.callee)) {
|
|
1983
|
+
const n = X(e.callee).unwrap(), s = it(n), i = this.symbolFactory.create(mn, { declaration: e });
|
|
1984
1984
|
e.symbol = i;
|
|
1985
1985
|
const a = this.declarationNode.symbol.symbolTable;
|
|
1986
1986
|
if (a.has(s)) {
|
|
@@ -1995,7 +1995,7 @@ class Xn {
|
|
|
1995
1995
|
return [];
|
|
1996
1996
|
}
|
|
1997
1997
|
}
|
|
1998
|
-
class
|
|
1998
|
+
class Wn {
|
|
1999
1999
|
constructor(e, n, s) {
|
|
2000
2000
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2001
2001
|
}
|
|
@@ -2016,7 +2016,7 @@ class $n {
|
|
|
2016
2016
|
);
|
|
2017
2017
|
if (this.declarationNode.parent instanceof Z)
|
|
2018
2018
|
return [e];
|
|
2019
|
-
const n =
|
|
2019
|
+
const n = Ae(this.declarationNode.parent).unwrap_or(void 0);
|
|
2020
2020
|
return n && [I.Table, I.TablePartial].includes(n) ? [] : [e];
|
|
2021
2021
|
}
|
|
2022
2022
|
validateName(e) {
|
|
@@ -2042,32 +2042,32 @@ class $n {
|
|
|
2042
2042
|
return [];
|
|
2043
2043
|
const s = [], i = [n.callee, ...n.args];
|
|
2044
2044
|
return g.last(i) instanceof M && s.push(...this.validateFieldSetting(i.pop())), i.forEach((a) => {
|
|
2045
|
-
for (; a instanceof
|
|
2045
|
+
for (; a instanceof H; )
|
|
2046
2046
|
a.argumentList && !Xe(a.argumentList).isOk() && s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", a.argumentList)), a = a.callee;
|
|
2047
2047
|
Xe(a).isOk() || s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", a));
|
|
2048
2048
|
}), s;
|
|
2049
2049
|
});
|
|
2050
2050
|
}
|
|
2051
2051
|
validateFieldSetting(e) {
|
|
2052
|
-
const n =
|
|
2052
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2053
2053
|
for (const a in i) {
|
|
2054
2054
|
const r = i[a];
|
|
2055
2055
|
switch (a) {
|
|
2056
2056
|
case "note":
|
|
2057
2057
|
case "name":
|
|
2058
2058
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
|
|
2059
|
-
|
|
2059
|
+
W(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${a}' must be a string`, c));
|
|
2060
2060
|
});
|
|
2061
2061
|
break;
|
|
2062
2062
|
case "unique":
|
|
2063
2063
|
case "pk":
|
|
2064
2064
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
|
|
2065
|
-
|
|
2065
|
+
Q(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${a}' must not have a value`, c));
|
|
2066
2066
|
});
|
|
2067
2067
|
break;
|
|
2068
2068
|
case "type":
|
|
2069
2069
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), r.forEach((c) => {
|
|
2070
|
-
|
|
2070
|
+
j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
|
|
2071
2071
|
});
|
|
2072
2072
|
break;
|
|
2073
2073
|
default:
|
|
@@ -2085,7 +2085,7 @@ class $n {
|
|
|
2085
2085
|
});
|
|
2086
2086
|
}
|
|
2087
2087
|
}
|
|
2088
|
-
class
|
|
2088
|
+
class Yn {
|
|
2089
2089
|
constructor(e, n, s) {
|
|
2090
2090
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2091
2091
|
}
|
|
@@ -2104,7 +2104,7 @@ class jn {
|
|
|
2104
2104
|
I.TableGroup,
|
|
2105
2105
|
I.TablePartial,
|
|
2106
2106
|
I.Project
|
|
2107
|
-
].includes(
|
|
2107
|
+
].includes(Ae(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
|
|
2108
2108
|
o.INVALID_NOTE_CONTEXT,
|
|
2109
2109
|
"A Note can only appear inside a Table, a TableGroup, a TablePartial or a Project. Sticky note can only appear at the global scope.",
|
|
2110
2110
|
this.declarationNode
|
|
@@ -2115,10 +2115,10 @@ class jn {
|
|
|
2115
2115
|
return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2116
2116
|
if (!e)
|
|
2117
2117
|
return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2118
|
-
const n =
|
|
2118
|
+
const n = Y(e);
|
|
2119
2119
|
if (!n.isOk())
|
|
2120
2120
|
return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2121
|
-
const i = n.unwrap().join("."), a =
|
|
2121
|
+
const i = n.unwrap().join("."), a = fn(i);
|
|
2122
2122
|
return this.publicSymbolTable.has(a) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(a, this.declarationNode.symbol), []);
|
|
2123
2123
|
}
|
|
2124
2124
|
validateAlias(e) {
|
|
@@ -2137,7 +2137,7 @@ class jn {
|
|
|
2137
2137
|
}
|
|
2138
2138
|
validateFields(e) {
|
|
2139
2139
|
const n = [];
|
|
2140
|
-
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))),
|
|
2140
|
+
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), W(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2141
2141
|
}
|
|
2142
2142
|
validateSubElements(e) {
|
|
2143
2143
|
return e.flatMap((n) => {
|
|
@@ -2148,7 +2148,7 @@ class jn {
|
|
|
2148
2148
|
});
|
|
2149
2149
|
}
|
|
2150
2150
|
}
|
|
2151
|
-
class
|
|
2151
|
+
class qn {
|
|
2152
2152
|
constructor(e, n, s) {
|
|
2153
2153
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2154
2154
|
}
|
|
@@ -2187,7 +2187,7 @@ class Wn {
|
|
|
2187
2187
|
});
|
|
2188
2188
|
}
|
|
2189
2189
|
}
|
|
2190
|
-
class
|
|
2190
|
+
class Hn {
|
|
2191
2191
|
constructor(e, n, s) {
|
|
2192
2192
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2193
2193
|
}
|
|
@@ -2219,7 +2219,7 @@ class Yn {
|
|
|
2219
2219
|
return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2220
2220
|
const n = [];
|
|
2221
2221
|
return e.length > 1 && n.push(...e.slice(1).map((s) => new l(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2222
|
-
s.callee && !
|
|
2222
|
+
s.callee && !Cn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Xn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2223
2223
|
const i = [...s.args];
|
|
2224
2224
|
if (g.last(i) instanceof M) {
|
|
2225
2225
|
const a = this.validateFieldSettings(g.last(i));
|
|
@@ -2230,14 +2230,14 @@ class Yn {
|
|
|
2230
2230
|
}), n;
|
|
2231
2231
|
}
|
|
2232
2232
|
validateFieldSettings(e) {
|
|
2233
|
-
const n =
|
|
2233
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2234
2234
|
for (const a in i) {
|
|
2235
2235
|
const r = i[a];
|
|
2236
2236
|
switch (a) {
|
|
2237
2237
|
case "delete":
|
|
2238
2238
|
case "update":
|
|
2239
2239
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
|
|
2240
|
-
|
|
2240
|
+
zn(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${a}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
|
|
2241
2241
|
});
|
|
2242
2242
|
break;
|
|
2243
2243
|
case "color":
|
|
@@ -2260,11 +2260,11 @@ class Yn {
|
|
|
2260
2260
|
});
|
|
2261
2261
|
}
|
|
2262
2262
|
}
|
|
2263
|
-
function
|
|
2264
|
-
if (!(
|
|
2263
|
+
function zn(t) {
|
|
2264
|
+
if (!(j(t) && t.expression.variable.kind !== h.QUOTED_STRING) && !(t instanceof te))
|
|
2265
2265
|
return !1;
|
|
2266
2266
|
let e;
|
|
2267
|
-
if (t instanceof
|
|
2267
|
+
if (t instanceof te ? e = we(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2268
2268
|
switch (e.toLowerCase()) {
|
|
2269
2269
|
case "cascade":
|
|
2270
2270
|
case "no action":
|
|
@@ -2277,7 +2277,7 @@ function qn(t) {
|
|
|
2277
2277
|
}
|
|
2278
2278
|
return !1;
|
|
2279
2279
|
}
|
|
2280
|
-
class
|
|
2280
|
+
class Qn {
|
|
2281
2281
|
constructor(e, n, s) {
|
|
2282
2282
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2283
2283
|
}
|
|
@@ -2298,10 +2298,10 @@ class zn {
|
|
|
2298
2298
|
return e ? e instanceof he ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Vt(e) ? [] : [new l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2299
2299
|
}
|
|
2300
2300
|
validateAlias(e) {
|
|
2301
|
-
return e ?
|
|
2301
|
+
return e ? ns(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2302
2302
|
}
|
|
2303
2303
|
validateSettingList(e) {
|
|
2304
|
-
const n =
|
|
2304
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2305
2305
|
for (const a in i) {
|
|
2306
2306
|
const r = i[a];
|
|
2307
2307
|
switch (a) {
|
|
@@ -2312,7 +2312,7 @@ class zn {
|
|
|
2312
2312
|
break;
|
|
2313
2313
|
case "note":
|
|
2314
2314
|
r.length > 1 && s.push(...r.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), r.forEach((c) => {
|
|
2315
|
-
|
|
2315
|
+
W(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2316
2316
|
});
|
|
2317
2317
|
break;
|
|
2318
2318
|
default:
|
|
@@ -2323,14 +2323,14 @@ class zn {
|
|
|
2323
2323
|
}
|
|
2324
2324
|
registerElement() {
|
|
2325
2325
|
const e = [];
|
|
2326
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2327
|
-
const { name: n, alias: s } = this.declarationNode, i =
|
|
2326
|
+
this.declarationNode.symbol = this.symbolFactory.create(Mt, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
2327
|
+
const { name: n, alias: s } = this.declarationNode, i = Y(n);
|
|
2328
2328
|
if (i.isOk()) {
|
|
2329
2329
|
const a = [...i.unwrap()], r = a.pop(), c = Qe(a, this.publicSymbolTable, this.symbolFactory), p = Ge(r);
|
|
2330
2330
|
c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists in schema '${a.join(".") || "public"}'`, n)), c.set(p, this.declarationNode.symbol);
|
|
2331
2331
|
}
|
|
2332
|
-
if (s && Pe(s) && !
|
|
2333
|
-
const a =
|
|
2332
|
+
if (s && Pe(s) && !Kn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2333
|
+
const a = X(s).unwrap(), r = Ge(a);
|
|
2334
2334
|
this.publicSymbolTable.has(r) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists`, n)), this.publicSymbolTable.set(r, this.declarationNode.symbol);
|
|
2335
2335
|
}
|
|
2336
2336
|
return e;
|
|
@@ -2340,7 +2340,7 @@ class zn {
|
|
|
2340
2340
|
return [];
|
|
2341
2341
|
if (e instanceof w)
|
|
2342
2342
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2343
|
-
const [n, s, i] = e.body.reduce((a, r) => (r instanceof w ? a[0].push(r) : r instanceof
|
|
2343
|
+
const [n, s, i] = e.body.reduce((a, r) => (r instanceof w ? a[0].push(r) : r instanceof Le ? a[1].push(r) : r instanceof y && a[2].push(r), a), [[], [], []]);
|
|
2344
2344
|
return [
|
|
2345
2345
|
...this.validateFields(n),
|
|
2346
2346
|
...this.validateInjections(s),
|
|
@@ -2354,7 +2354,7 @@ class zn {
|
|
|
2354
2354
|
var c, p, f;
|
|
2355
2355
|
if (!((p = (c = e.partial) == null ? void 0 : c.variable) != null && p.value))
|
|
2356
2356
|
return [];
|
|
2357
|
-
const n = (f = e.partial.variable) == null ? void 0 : f.value, s =
|
|
2357
|
+
const n = (f = e.partial.variable) == null ? void 0 : f.value, s = Rt(n), i = this.symbolFactory.create(An, { declaration: e });
|
|
2358
2358
|
e.symbol = i;
|
|
2359
2359
|
const a = this.declarationNode.symbol.symbolTable, r = a.get(s);
|
|
2360
2360
|
return r ? [
|
|
@@ -2367,14 +2367,14 @@ class zn {
|
|
|
2367
2367
|
if (!n.callee)
|
|
2368
2368
|
return [];
|
|
2369
2369
|
const s = [];
|
|
2370
|
-
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)),
|
|
2370
|
+
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), j(n.callee) || s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Jn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2371
2371
|
const i = n.args.slice(1);
|
|
2372
2372
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2373
2373
|
});
|
|
2374
2374
|
}
|
|
2375
2375
|
registerField(e) {
|
|
2376
|
-
if (e.callee &&
|
|
2377
|
-
const n =
|
|
2376
|
+
if (e.callee && j(e.callee)) {
|
|
2377
|
+
const n = X(e.callee).unwrap(), s = qe(n), i = this.symbolFactory.create(lt, { declaration: e });
|
|
2378
2378
|
e.symbol = i;
|
|
2379
2379
|
const a = this.declarationNode.symbol.symbolTable;
|
|
2380
2380
|
if (a.has(s)) {
|
|
@@ -2396,9 +2396,9 @@ class zn {
|
|
|
2396
2396
|
return [];
|
|
2397
2397
|
let n;
|
|
2398
2398
|
g.last(e) instanceof M && (n = e.pop());
|
|
2399
|
-
const s =
|
|
2399
|
+
const s = F(n), i = s.getErrors(), a = s.getValue();
|
|
2400
2400
|
for (const p of e) {
|
|
2401
|
-
const f =
|
|
2401
|
+
const f = X(p).unwrap_or("").toLowerCase();
|
|
2402
2402
|
if (f !== "pk" && f !== "unique") {
|
|
2403
2403
|
i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2404
2404
|
continue;
|
|
@@ -2412,7 +2412,7 @@ class zn {
|
|
|
2412
2412
|
switch (p) {
|
|
2413
2413
|
case "note":
|
|
2414
2414
|
f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", u))), f.forEach((u) => {
|
|
2415
|
-
|
|
2415
|
+
W(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", u.value || u.name));
|
|
2416
2416
|
});
|
|
2417
2417
|
break;
|
|
2418
2418
|
case "ref":
|
|
@@ -2422,34 +2422,34 @@ class zn {
|
|
|
2422
2422
|
break;
|
|
2423
2423
|
case "primary key":
|
|
2424
2424
|
f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", u))), f.forEach((u) => {
|
|
2425
|
-
|
|
2425
|
+
Q(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", u.value || u.name));
|
|
2426
2426
|
});
|
|
2427
2427
|
break;
|
|
2428
2428
|
case "pk":
|
|
2429
2429
|
f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", u))), f.forEach((u) => {
|
|
2430
|
-
u instanceof
|
|
2430
|
+
u instanceof ne && !Q(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", u.value || u.name));
|
|
2431
2431
|
});
|
|
2432
2432
|
break;
|
|
2433
2433
|
case "not null":
|
|
2434
2434
|
f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", u)));
|
|
2435
2435
|
const d = a.null || [];
|
|
2436
2436
|
f.length >= 1 && d.length >= 1 && i.push(...[...f, ...d].map((u) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", u))), f.forEach((u) => {
|
|
2437
|
-
|
|
2437
|
+
Q(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", u.value || u.name));
|
|
2438
2438
|
});
|
|
2439
2439
|
break;
|
|
2440
2440
|
case "null":
|
|
2441
2441
|
f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", u))), f.forEach((u) => {
|
|
2442
|
-
|
|
2442
|
+
Q(u.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", u.value || u.name));
|
|
2443
2443
|
});
|
|
2444
2444
|
break;
|
|
2445
2445
|
case "unique":
|
|
2446
2446
|
f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", u))), f.forEach((u) => {
|
|
2447
|
-
u instanceof
|
|
2447
|
+
u instanceof ne && !Q(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", u.value || u.name));
|
|
2448
2448
|
});
|
|
2449
2449
|
break;
|
|
2450
2450
|
case "increment":
|
|
2451
2451
|
f.length > 1 && i.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", u))), f.forEach((u) => {
|
|
2452
|
-
u instanceof
|
|
2452
|
+
u instanceof ne && !Q(u.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", u.value || u.name));
|
|
2453
2453
|
});
|
|
2454
2454
|
break;
|
|
2455
2455
|
case "default":
|
|
@@ -2476,26 +2476,26 @@ class zn {
|
|
|
2476
2476
|
return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
2479
|
-
function
|
|
2480
|
-
if (!(t instanceof
|
|
2479
|
+
function Jn(t) {
|
|
2480
|
+
if (!(t instanceof H || ze(t) || t instanceof $ || t instanceof he))
|
|
2481
2481
|
return !1;
|
|
2482
|
-
if (t instanceof
|
|
2483
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2482
|
+
if (t instanceof H) {
|
|
2483
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => pe(n) || W(n) || fe(n)))
|
|
2484
2484
|
return !1;
|
|
2485
2485
|
t = t.callee;
|
|
2486
2486
|
}
|
|
2487
2487
|
for (; t instanceof he; ) {
|
|
2488
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value &&
|
|
2488
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && pe(n.name)))
|
|
2489
2489
|
return !1;
|
|
2490
2490
|
t = t.array;
|
|
2491
2491
|
}
|
|
2492
|
-
const e =
|
|
2492
|
+
const e = Y(t).unwrap_or(void 0);
|
|
2493
2493
|
return e !== void 0 && e.length > 0;
|
|
2494
2494
|
}
|
|
2495
|
-
function
|
|
2495
|
+
function Kn(t, e) {
|
|
2496
2496
|
return e.length === 1 && t === e[0];
|
|
2497
2497
|
}
|
|
2498
|
-
class
|
|
2498
|
+
class Zn {
|
|
2499
2499
|
constructor(e, n, s) {
|
|
2500
2500
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2501
2501
|
}
|
|
@@ -2536,8 +2536,8 @@ class Jn {
|
|
|
2536
2536
|
}
|
|
2537
2537
|
registerElement() {
|
|
2538
2538
|
const { name: e } = this.declarationNode;
|
|
2539
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2540
|
-
const n =
|
|
2539
|
+
this.declarationNode.symbol = this.symbolFactory.create(bn, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
2540
|
+
const n = Y(e);
|
|
2541
2541
|
if (n.isOk()) {
|
|
2542
2542
|
const s = n.unwrap(), i = s.pop(), a = Qe(s, this.publicSymbolTable, this.symbolFactory), r = at(i);
|
|
2543
2543
|
if (a.has(r))
|
|
@@ -2547,7 +2547,7 @@ class Jn {
|
|
|
2547
2547
|
return [];
|
|
2548
2548
|
}
|
|
2549
2549
|
validateSettingList(e) {
|
|
2550
|
-
const n =
|
|
2550
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2551
2551
|
return g.forIn(i, (a, r) => {
|
|
2552
2552
|
switch (r) {
|
|
2553
2553
|
case "color":
|
|
@@ -2568,7 +2568,7 @@ class Jn {
|
|
|
2568
2568
|
o.DUPLICATE_TABLE_SETTING,
|
|
2569
2569
|
"'note' can only appear once",
|
|
2570
2570
|
c
|
|
2571
|
-
))), a.filter((c) => !
|
|
2571
|
+
))), a.filter((c) => !W(c.value)).forEach((c) => {
|
|
2572
2572
|
s.push(new l(
|
|
2573
2573
|
o.INVALID_TABLE_SETTING,
|
|
2574
2574
|
"'note' must be a string literal",
|
|
@@ -2604,7 +2604,7 @@ class Jn {
|
|
|
2604
2604
|
validateFields(e) {
|
|
2605
2605
|
return e.flatMap((n) => {
|
|
2606
2606
|
const s = [];
|
|
2607
|
-
return n.callee && !
|
|
2607
|
+
return n.callee && !Y(n.callee).isOk() && s.push(new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2608
2608
|
});
|
|
2609
2609
|
}
|
|
2610
2610
|
validateSubElements(e) {
|
|
@@ -2620,8 +2620,8 @@ class Jn {
|
|
|
2620
2620
|
return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2621
2621
|
}
|
|
2622
2622
|
registerField(e) {
|
|
2623
|
-
if (e.callee &&
|
|
2624
|
-
const n =
|
|
2623
|
+
if (e.callee && j(e.callee)) {
|
|
2624
|
+
const n = X(e.callee).unwrap(), s = rt(n), i = this.symbolFactory.create(In, { declaration: e });
|
|
2625
2625
|
e.symbol = i;
|
|
2626
2626
|
const a = this.declarationNode.symbol.symbolTable;
|
|
2627
2627
|
if (a.has(s)) {
|
|
@@ -2636,24 +2636,24 @@ class Jn {
|
|
|
2636
2636
|
return [];
|
|
2637
2637
|
}
|
|
2638
2638
|
}
|
|
2639
|
-
const
|
|
2640
|
-
function
|
|
2641
|
-
if (!(t instanceof
|
|
2639
|
+
const Bt = ["-", "+"];
|
|
2640
|
+
function es(t) {
|
|
2641
|
+
if (!(t instanceof H || ze(t) || t instanceof $ || t instanceof he))
|
|
2642
2642
|
return !1;
|
|
2643
|
-
if (t instanceof
|
|
2644
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) =>
|
|
2643
|
+
if (t instanceof H) {
|
|
2644
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => pe(n) || W(n) || fe(n)))
|
|
2645
2645
|
return !1;
|
|
2646
2646
|
t = t.callee;
|
|
2647
2647
|
}
|
|
2648
2648
|
for (; t instanceof he; ) {
|
|
2649
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value &&
|
|
2649
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && pe(n.name)))
|
|
2650
2650
|
return !1;
|
|
2651
2651
|
t = t.array;
|
|
2652
2652
|
}
|
|
2653
|
-
const e =
|
|
2653
|
+
const e = Y(t).unwrap_or(void 0);
|
|
2654
2654
|
return e !== void 0 && e.length > 0;
|
|
2655
2655
|
}
|
|
2656
|
-
class
|
|
2656
|
+
class ts {
|
|
2657
2657
|
constructor(e, n, s) {
|
|
2658
2658
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2659
2659
|
}
|
|
@@ -2693,17 +2693,17 @@ class Zn {
|
|
|
2693
2693
|
)] : [];
|
|
2694
2694
|
}
|
|
2695
2695
|
validateSettingList(e) {
|
|
2696
|
-
const n =
|
|
2697
|
-
return
|
|
2696
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2697
|
+
return pt(i, (a, r) => {
|
|
2698
2698
|
switch (r) {
|
|
2699
|
-
case
|
|
2699
|
+
case N.HeaderColor:
|
|
2700
2700
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_PARTIAL_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
2701
2701
|
Je(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, `'${r}' must be a color literal`, c.value || c.name));
|
|
2702
2702
|
});
|
|
2703
2703
|
break;
|
|
2704
|
-
case
|
|
2704
|
+
case N.Note:
|
|
2705
2705
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_PARTIAL_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
2706
|
-
|
|
2706
|
+
W(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, `'${r}' must be a string literal`, c.value || c.name));
|
|
2707
2707
|
});
|
|
2708
2708
|
break;
|
|
2709
2709
|
default:
|
|
@@ -2713,8 +2713,8 @@ class Zn {
|
|
|
2713
2713
|
}
|
|
2714
2714
|
registerElement() {
|
|
2715
2715
|
const { name: e } = this.declarationNode;
|
|
2716
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2717
|
-
const n =
|
|
2716
|
+
this.declarationNode.symbol = this.symbolFactory.create(Ln, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
2717
|
+
const n = Y(e);
|
|
2718
2718
|
if (!n.isOk())
|
|
2719
2719
|
return [];
|
|
2720
2720
|
const s = n.unwrap(), i = s.pop(), a = Qe(s, this.publicSymbolTable, this.symbolFactory), r = ot(i);
|
|
@@ -2736,7 +2736,7 @@ class Zn {
|
|
|
2736
2736
|
if (!n.callee)
|
|
2737
2737
|
return [];
|
|
2738
2738
|
const s = [];
|
|
2739
|
-
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)),
|
|
2739
|
+
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), j(n.callee) || s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !es(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2740
2740
|
const i = n.args.slice(1);
|
|
2741
2741
|
return s.push(
|
|
2742
2742
|
...this.validateFieldSetting(i),
|
|
@@ -2745,9 +2745,9 @@ class Zn {
|
|
|
2745
2745
|
});
|
|
2746
2746
|
}
|
|
2747
2747
|
registerField(e) {
|
|
2748
|
-
if (!e.callee || !
|
|
2748
|
+
if (!e.callee || !j(e.callee))
|
|
2749
2749
|
return [];
|
|
2750
|
-
const n =
|
|
2750
|
+
const n = X(e.callee).unwrap(), s = qe(n), i = this.symbolFactory.create(lt, { declaration: e });
|
|
2751
2751
|
e.symbol = i;
|
|
2752
2752
|
const a = this.declarationNode.symbol.symbolTable;
|
|
2753
2753
|
if (a.has(s)) {
|
|
@@ -2768,70 +2768,70 @@ class Zn {
|
|
|
2768
2768
|
return [];
|
|
2769
2769
|
let s;
|
|
2770
2770
|
g.last(e) instanceof M && (s = e.pop());
|
|
2771
|
-
const i =
|
|
2771
|
+
const i = F(s), a = i.getErrors(), r = i.getValue();
|
|
2772
2772
|
e.forEach((f) => {
|
|
2773
|
-
const d =
|
|
2774
|
-
if (d !==
|
|
2773
|
+
const d = X(f).unwrap_or("").toLowerCase();
|
|
2774
|
+
if (d !== N.PK && d !== N.Unique) {
|
|
2775
2775
|
a.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", f));
|
|
2776
2776
|
return;
|
|
2777
2777
|
}
|
|
2778
2778
|
r[d] === void 0 ? r[d] = [f] : r[d].push(f);
|
|
2779
2779
|
});
|
|
2780
|
-
const c = r[
|
|
2780
|
+
const c = r[N.PK] || [], p = r[N.PKey] || [];
|
|
2781
2781
|
return c.length >= 1 && p.length >= 1 && a.push(...[...c, ...p].map((f) => new l(
|
|
2782
2782
|
o.DUPLICATE_COLUMN_SETTING,
|
|
2783
2783
|
"Either one of 'primary key' and 'pk' can appear",
|
|
2784
2784
|
f
|
|
2785
|
-
))),
|
|
2785
|
+
))), pt(r, (f, d) => {
|
|
2786
2786
|
switch (d) {
|
|
2787
|
-
case
|
|
2787
|
+
case N.Note:
|
|
2788
2788
|
f.length > 1 && a.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, u))), f.forEach((u) => {
|
|
2789
|
-
|
|
2789
|
+
W(u.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must be a quoted string`, u.value || u.name));
|
|
2790
2790
|
});
|
|
2791
2791
|
break;
|
|
2792
|
-
case
|
|
2792
|
+
case N.Ref:
|
|
2793
2793
|
f.forEach((u) => {
|
|
2794
2794
|
Xt(u.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must be a valid unary relationship`, u.value || u.name));
|
|
2795
2795
|
});
|
|
2796
2796
|
break;
|
|
2797
|
-
case
|
|
2797
|
+
case N.PKey:
|
|
2798
2798
|
f.length > 1 && a.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, u))), f.forEach((u) => {
|
|
2799
|
-
|
|
2799
|
+
Q(u.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must not have a value`, u.value || u.name));
|
|
2800
2800
|
});
|
|
2801
2801
|
break;
|
|
2802
|
-
case
|
|
2802
|
+
case N.PK:
|
|
2803
2803
|
f.length > 1 && a.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, u))), f.forEach((u) => {
|
|
2804
|
-
u instanceof
|
|
2804
|
+
u instanceof ne && !Q(u.value) && a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must not have a value`, u.value || u.name));
|
|
2805
2805
|
});
|
|
2806
2806
|
break;
|
|
2807
|
-
case
|
|
2807
|
+
case N.NotNull: {
|
|
2808
2808
|
f.length > 1 && a.push(...f.map((E) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, E)));
|
|
2809
|
-
const u = r[
|
|
2809
|
+
const u = r[N.Null] || [];
|
|
2810
2810
|
f.length >= 1 && u.length >= 1 && a.push(...[...f, ...u].map((E) => new l(
|
|
2811
2811
|
o.CONFLICTING_SETTING,
|
|
2812
2812
|
"'not null' and 'null' can not be set at the same time",
|
|
2813
2813
|
E
|
|
2814
2814
|
))), f.forEach((E) => {
|
|
2815
|
-
|
|
2815
|
+
Q(E.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must not have a value`, E.value || E.name));
|
|
2816
2816
|
});
|
|
2817
2817
|
break;
|
|
2818
2818
|
}
|
|
2819
|
-
case
|
|
2819
|
+
case N.Null:
|
|
2820
2820
|
f.length > 1 && a.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, u))), f.forEach((u) => {
|
|
2821
|
-
|
|
2821
|
+
Q(u.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must not have a value`, u.value || u.name));
|
|
2822
2822
|
});
|
|
2823
2823
|
break;
|
|
2824
|
-
case
|
|
2824
|
+
case N.Unique:
|
|
2825
2825
|
f.length > 1 && a.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, u))), f.forEach((u) => {
|
|
2826
|
-
u instanceof
|
|
2826
|
+
u instanceof ne && !Q(u.value) && a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must not have a value`, u.value || u.name));
|
|
2827
2827
|
});
|
|
2828
2828
|
break;
|
|
2829
|
-
case
|
|
2829
|
+
case N.Increment:
|
|
2830
2830
|
f.length > 1 && a.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, u))), f.forEach((u) => {
|
|
2831
|
-
u instanceof
|
|
2831
|
+
u instanceof ne && !Q(u.value) && a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${d}' must not have a value`, u.value || u.name));
|
|
2832
2832
|
});
|
|
2833
2833
|
break;
|
|
2834
|
-
case
|
|
2834
|
+
case N.Default:
|
|
2835
2835
|
f.length > 1 && a.push(...f.map((u) => new l(o.DUPLICATE_COLUMN_SETTING, `'${d}' can only appear once`, u))), f.forEach((u) => {
|
|
2836
2836
|
Ct(u.value) || a.push(new l(
|
|
2837
2837
|
o.INVALID_COLUMN_SETTING_VALUE,
|
|
@@ -2861,33 +2861,33 @@ class Zn {
|
|
|
2861
2861
|
function de(t) {
|
|
2862
2862
|
switch (t.type.value.toLowerCase()) {
|
|
2863
2863
|
case I.Enum:
|
|
2864
|
-
return
|
|
2864
|
+
return jn;
|
|
2865
2865
|
case I.Table:
|
|
2866
|
-
return
|
|
2866
|
+
return Qn;
|
|
2867
2867
|
case I.TableGroup:
|
|
2868
|
-
return
|
|
2868
|
+
return Zn;
|
|
2869
2869
|
case I.Project:
|
|
2870
|
-
return
|
|
2870
|
+
return qn;
|
|
2871
2871
|
case I.Ref:
|
|
2872
|
-
return
|
|
2872
|
+
return Hn;
|
|
2873
2873
|
case I.Note:
|
|
2874
|
-
return
|
|
2874
|
+
return Yn;
|
|
2875
2875
|
case I.Indexes:
|
|
2876
|
-
return
|
|
2876
|
+
return Wn;
|
|
2877
2877
|
case I.TablePartial:
|
|
2878
|
-
return
|
|
2878
|
+
return ts;
|
|
2879
2879
|
default:
|
|
2880
|
-
return
|
|
2880
|
+
return $n;
|
|
2881
2881
|
}
|
|
2882
2882
|
}
|
|
2883
2883
|
function Vt(t) {
|
|
2884
|
-
return !!
|
|
2884
|
+
return !!Y(t).unwrap_or(!1);
|
|
2885
2885
|
}
|
|
2886
|
-
function
|
|
2886
|
+
function ns(t) {
|
|
2887
2887
|
return Pe(t);
|
|
2888
2888
|
}
|
|
2889
2889
|
function Pe(t) {
|
|
2890
|
-
return t instanceof
|
|
2890
|
+
return t instanceof $ && t.expression instanceof ie;
|
|
2891
2891
|
}
|
|
2892
2892
|
function Qe(t, e, n) {
|
|
2893
2893
|
var i;
|
|
@@ -2901,7 +2901,7 @@ function Qe(t, e, n) {
|
|
|
2901
2901
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2902
2902
|
} else {
|
|
2903
2903
|
r = new ke();
|
|
2904
|
-
const p = n.create(
|
|
2904
|
+
const p = n.create(Ut, { symbolTable: r });
|
|
2905
2905
|
s.set(c, p);
|
|
2906
2906
|
}
|
|
2907
2907
|
s = r;
|
|
@@ -2913,57 +2913,57 @@ function Gt(t) {
|
|
|
2913
2913
|
}
|
|
2914
2914
|
function Je(t) {
|
|
2915
2915
|
var n;
|
|
2916
|
-
if (!(t instanceof
|
|
2916
|
+
if (!(t instanceof $) || !(t.expression instanceof ye) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== h.COLOR_LITERAL)
|
|
2917
2917
|
return !1;
|
|
2918
2918
|
const e = t.expression.literal.value;
|
|
2919
2919
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2920
2920
|
return !1;
|
|
2921
2921
|
for (let s = 1; s < e.length; s += 1)
|
|
2922
|
-
if (!
|
|
2922
|
+
if (!wn(e[s]))
|
|
2923
2923
|
return !1;
|
|
2924
2924
|
return !0;
|
|
2925
2925
|
}
|
|
2926
|
-
function
|
|
2926
|
+
function Q(t) {
|
|
2927
2927
|
return t === void 0;
|
|
2928
2928
|
}
|
|
2929
2929
|
function Ct(t) {
|
|
2930
2930
|
var e;
|
|
2931
|
-
return !!(
|
|
2931
|
+
return !!(W(t) || pe(t) || fe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof oe && Bt.includes((e = t.op) == null ? void 0 : e.value) && pe(t.expression) || t instanceof ue);
|
|
2932
2932
|
}
|
|
2933
|
-
function
|
|
2933
|
+
function pe(t) {
|
|
2934
2934
|
var e;
|
|
2935
|
-
return t instanceof
|
|
2935
|
+
return t instanceof $ && t.expression instanceof ye && ((e = t.expression.literal) == null ? void 0 : e.kind) === h.NUMERIC_LITERAL;
|
|
2936
2936
|
}
|
|
2937
2937
|
function Xt(t) {
|
|
2938
2938
|
var n;
|
|
2939
|
-
if (!(t instanceof
|
|
2939
|
+
if (!(t instanceof oe) || !Gt((n = t.op) == null ? void 0 : n.value))
|
|
2940
2940
|
return !1;
|
|
2941
|
-
const e =
|
|
2941
|
+
const e = Y(t.expression).unwrap_or(void 0);
|
|
2942
2942
|
return e !== void 0 && e.length > 0;
|
|
2943
2943
|
}
|
|
2944
2944
|
function $t(t) {
|
|
2945
|
-
return t instanceof
|
|
2945
|
+
return t instanceof ce && t.elementList.every(j);
|
|
2946
2946
|
}
|
|
2947
|
-
function
|
|
2947
|
+
function F(t) {
|
|
2948
2948
|
var s;
|
|
2949
2949
|
const e = {}, n = [];
|
|
2950
2950
|
if (!t)
|
|
2951
|
-
return new
|
|
2951
|
+
return new K({});
|
|
2952
2952
|
for (const i of t.elementList) {
|
|
2953
2953
|
if (!i.name)
|
|
2954
2954
|
continue;
|
|
2955
|
-
if (i.name instanceof
|
|
2955
|
+
if (i.name instanceof $) {
|
|
2956
2956
|
n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2957
2957
|
continue;
|
|
2958
2958
|
}
|
|
2959
2959
|
const a = (s = we(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2960
2960
|
a && (e[a] === void 0 ? e[a] = [i] : e[a].push(i));
|
|
2961
2961
|
}
|
|
2962
|
-
return new
|
|
2962
|
+
return new K(e, n);
|
|
2963
2963
|
}
|
|
2964
|
-
class
|
|
2964
|
+
class At {
|
|
2965
2965
|
constructor(e, n) {
|
|
2966
|
-
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(
|
|
2966
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(Ut, {
|
|
2967
2967
|
symbolTable: new ke()
|
|
2968
2968
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2969
2969
|
}
|
|
@@ -2979,8 +2979,8 @@ class _t {
|
|
|
2979
2979
|
);
|
|
2980
2980
|
e.push(...a.validate());
|
|
2981
2981
|
});
|
|
2982
|
-
const n = this.ast.body.filter((s) =>
|
|
2983
|
-
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new
|
|
2982
|
+
const n = this.ast.body.filter((s) => Ae(s).unwrap_or(void 0) === I.Project);
|
|
2983
|
+
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new K(this.ast, e);
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
2986
2986
|
class Ee {
|
|
@@ -2992,7 +2992,7 @@ class Ee {
|
|
|
2992
2992
|
}
|
|
2993
2993
|
bindSettingList(e, n) {
|
|
2994
2994
|
e && e.elementList.forEach((s) => {
|
|
2995
|
-
if (s.name instanceof
|
|
2995
|
+
if (s.name instanceof $)
|
|
2996
2996
|
return;
|
|
2997
2997
|
const i = we(s.name).unwrap_or(void 0);
|
|
2998
2998
|
if (!i)
|
|
@@ -3006,9 +3006,9 @@ class Ee {
|
|
|
3006
3006
|
if (!e.body)
|
|
3007
3007
|
return;
|
|
3008
3008
|
const { body: n } = e;
|
|
3009
|
-
n instanceof
|
|
3009
|
+
n instanceof ae ? n.body.forEach((s) => {
|
|
3010
3010
|
if (s instanceof y) {
|
|
3011
|
-
if (!s.type ||
|
|
3011
|
+
if (!s.type || Ae(this.declarationNode).unwrap_or(null) === I.TablePartial && Ae(s).unwrap_or(null) === I.Indexes)
|
|
3012
3012
|
return;
|
|
3013
3013
|
const i = jt(s);
|
|
3014
3014
|
new i(s, this.errors).bind();
|
|
@@ -3031,12 +3031,12 @@ class Ee {
|
|
|
3031
3031
|
scanAndBind(e, n) {
|
|
3032
3032
|
var s, i;
|
|
3033
3033
|
if (e)
|
|
3034
|
-
if (e instanceof
|
|
3035
|
-
if (e.expression instanceof
|
|
3034
|
+
if (e instanceof $) {
|
|
3035
|
+
if (e.expression instanceof ie && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
3036
3036
|
return;
|
|
3037
3037
|
this.bindFragments([e], n);
|
|
3038
3038
|
} else
|
|
3039
|
-
e instanceof
|
|
3039
|
+
e instanceof le ? ze(e) ? this.bindFragments(_e(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof oe ? this.scanAndBind(e.expression, n) : e instanceof Ye ? this.scanAndBind(e.expression, n) : e instanceof ce ? e.elementList.forEach((a) => this.scanAndBind(a, n)) : e instanceof Le && this.bindFragments([e], n);
|
|
3040
3040
|
}
|
|
3041
3041
|
// Bind the fragments of a member access expression
|
|
3042
3042
|
// which can be a simple expression like v1.User,
|
|
@@ -3044,7 +3044,7 @@ class Ee {
|
|
|
3044
3044
|
bindFragments(e, n) {
|
|
3045
3045
|
if (e.length === 0)
|
|
3046
3046
|
return;
|
|
3047
|
-
const s = e.length === 1 && e[0] instanceof
|
|
3047
|
+
const s = e.length === 1 && e[0] instanceof Le, i = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: a } = n, r = s ? -1 : e.findIndex((E) => !j(E)), p = r !== -1 && $t(e[r]) ? e[r] : void 0, f = r >= 0 ? i.pop() : void 0, d = e.slice(
|
|
3048
3048
|
0,
|
|
3049
3049
|
r === -1 ? void 0 : r
|
|
3050
3050
|
);
|
|
@@ -3052,14 +3052,14 @@ class Ee {
|
|
|
3052
3052
|
return;
|
|
3053
3053
|
const u = [];
|
|
3054
3054
|
for (; i.length && d.length; ) {
|
|
3055
|
-
const E = i.pop(), L = d.pop(), v =
|
|
3055
|
+
const E = i.pop(), L = d.pop(), v = X(L).unwrap();
|
|
3056
3056
|
u.unshift({
|
|
3057
3057
|
index: Fe(v, E),
|
|
3058
3058
|
referrer: L
|
|
3059
3059
|
});
|
|
3060
3060
|
}
|
|
3061
3061
|
for (; d.length; ) {
|
|
3062
|
-
const E = d.pop(), L = s ?
|
|
3062
|
+
const E = d.pop(), L = s ? Gn(E).unwrap() : X(E).unwrap();
|
|
3063
3063
|
u.unshift({
|
|
3064
3064
|
index: Fe(L, a),
|
|
3065
3065
|
referrer: E
|
|
@@ -3070,7 +3070,7 @@ class Ee {
|
|
|
3070
3070
|
...u,
|
|
3071
3071
|
{
|
|
3072
3072
|
index: Fe(
|
|
3073
|
-
|
|
3073
|
+
X(E).unwrap(),
|
|
3074
3074
|
f
|
|
3075
3075
|
),
|
|
3076
3076
|
referrer: E
|
|
@@ -3084,16 +3084,16 @@ class Ee {
|
|
|
3084
3084
|
resolveIndexStack(e, n) {
|
|
3085
3085
|
if (e.length === 0)
|
|
3086
3086
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
3087
|
-
const [s, ...i] = e, a =
|
|
3087
|
+
const [s, ...i] = e, a = Lt(s.index, this.declarationNode);
|
|
3088
3088
|
if (a === void 0) {
|
|
3089
|
-
const { kind: f, name: d } =
|
|
3089
|
+
const { kind: f, name: d } = re(s.index).unwrap();
|
|
3090
3090
|
this.logError(s.referrer, `Can not find ${f} '${d}'`, n);
|
|
3091
3091
|
return;
|
|
3092
3092
|
}
|
|
3093
3093
|
a.references.push(s.referrer), s.referrer.referee = a;
|
|
3094
|
-
let r = a.symbolTable, { kind: c, name: p } =
|
|
3094
|
+
let r = a.symbolTable, { kind: c, name: p } = re(s.index).unwrap();
|
|
3095
3095
|
for (const f of i) {
|
|
3096
|
-
const { kind: d, name: u } =
|
|
3096
|
+
const { kind: d, name: u } = re(f.index).unwrap(), E = r.get(f.index);
|
|
3097
3097
|
if (!E) {
|
|
3098
3098
|
this.logError(
|
|
3099
3099
|
f.referrer,
|
|
@@ -3119,14 +3119,14 @@ class Ee {
|
|
|
3119
3119
|
const s = /* @__PURE__ */ new Map();
|
|
3120
3120
|
n.forEach((a, r) => {
|
|
3121
3121
|
var f, d;
|
|
3122
|
-
if (!
|
|
3122
|
+
if (!dn(r))
|
|
3123
3123
|
return;
|
|
3124
|
-
const c =
|
|
3124
|
+
const c = Lt(En(r), this.declarationNode), p = (d = (f = c == null ? void 0 : c.declaration) == null ? void 0 : f.symbol) == null ? void 0 : d.symbolTable;
|
|
3125
3125
|
p && p.forEach((u, E) => {
|
|
3126
3126
|
n.has(E) || s.set(E, { injectorFieldSymbol: u, injectorDeclaration: a.declaration });
|
|
3127
3127
|
});
|
|
3128
3128
|
}), s.forEach((a, r) => {
|
|
3129
|
-
const c =
|
|
3129
|
+
const c = vn(a.injectorFieldSymbol);
|
|
3130
3130
|
if (!c)
|
|
3131
3131
|
return;
|
|
3132
3132
|
const p = e.create(c, a);
|
|
@@ -3134,7 +3134,7 @@ class Ee {
|
|
|
3134
3134
|
});
|
|
3135
3135
|
}
|
|
3136
3136
|
}
|
|
3137
|
-
class
|
|
3137
|
+
class ss extends Ee {
|
|
3138
3138
|
constructor() {
|
|
3139
3139
|
super(...arguments), this.subfield = {
|
|
3140
3140
|
arg: {
|
|
@@ -3144,7 +3144,7 @@ class ts extends Ee {
|
|
|
3144
3144
|
}, this.settingList = {};
|
|
3145
3145
|
}
|
|
3146
3146
|
}
|
|
3147
|
-
class
|
|
3147
|
+
class is extends Ee {
|
|
3148
3148
|
constructor() {
|
|
3149
3149
|
super(...arguments), this.subfield = {
|
|
3150
3150
|
arg: {
|
|
@@ -3154,7 +3154,7 @@ class ns extends Ee {
|
|
|
3154
3154
|
}, this.settingList = {};
|
|
3155
3155
|
}
|
|
3156
3156
|
}
|
|
3157
|
-
class
|
|
3157
|
+
class as extends Ee {
|
|
3158
3158
|
constructor() {
|
|
3159
3159
|
super(...arguments), this.subfield = {
|
|
3160
3160
|
arg: {
|
|
@@ -3189,7 +3189,7 @@ class ss extends Ee {
|
|
|
3189
3189
|
}, this.settingList = {};
|
|
3190
3190
|
}
|
|
3191
3191
|
}
|
|
3192
|
-
class
|
|
3192
|
+
class rs extends Ee {
|
|
3193
3193
|
constructor() {
|
|
3194
3194
|
super(...arguments), this.subfield = {
|
|
3195
3195
|
arg: {
|
|
@@ -3199,7 +3199,7 @@ class is extends Ee {
|
|
|
3199
3199
|
}, this.settingList = {};
|
|
3200
3200
|
}
|
|
3201
3201
|
}
|
|
3202
|
-
class
|
|
3202
|
+
class os extends Ee {
|
|
3203
3203
|
constructor() {
|
|
3204
3204
|
super(...arguments), this.subfield = {
|
|
3205
3205
|
arg: {
|
|
@@ -3209,7 +3209,7 @@ class as extends Ee {
|
|
|
3209
3209
|
}, this.settingList = {};
|
|
3210
3210
|
}
|
|
3211
3211
|
}
|
|
3212
|
-
class
|
|
3212
|
+
class ls extends Ee {
|
|
3213
3213
|
constructor() {
|
|
3214
3214
|
super(...arguments), this.subfield = {
|
|
3215
3215
|
arg: {
|
|
@@ -3226,7 +3226,7 @@ class rs extends Ee {
|
|
|
3226
3226
|
}, this.settingList = {};
|
|
3227
3227
|
}
|
|
3228
3228
|
}
|
|
3229
|
-
class
|
|
3229
|
+
class cs extends Ee {
|
|
3230
3230
|
constructor() {
|
|
3231
3231
|
super(...arguments), this.subfield = {
|
|
3232
3232
|
arg: {
|
|
@@ -3259,7 +3259,7 @@ class os extends Ee {
|
|
|
3259
3259
|
};
|
|
3260
3260
|
}
|
|
3261
3261
|
}
|
|
3262
|
-
class
|
|
3262
|
+
class us extends Ee {
|
|
3263
3263
|
constructor() {
|
|
3264
3264
|
super(...arguments), this.subfield = {
|
|
3265
3265
|
arg: {
|
|
@@ -3276,7 +3276,7 @@ class ls extends Ee {
|
|
|
3276
3276
|
}, this.settingList = {};
|
|
3277
3277
|
}
|
|
3278
3278
|
}
|
|
3279
|
-
class
|
|
3279
|
+
class hs extends Ee {
|
|
3280
3280
|
constructor() {
|
|
3281
3281
|
super(...arguments), this.subfield = {
|
|
3282
3282
|
arg: {
|
|
@@ -3307,26 +3307,26 @@ class cs extends Ee {
|
|
|
3307
3307
|
function jt(t) {
|
|
3308
3308
|
switch (t.type.value.toLowerCase()) {
|
|
3309
3309
|
case I.Enum:
|
|
3310
|
-
return
|
|
3310
|
+
return is;
|
|
3311
3311
|
case I.Table:
|
|
3312
|
-
return
|
|
3312
|
+
return cs;
|
|
3313
3313
|
case I.TableGroup:
|
|
3314
|
-
return
|
|
3314
|
+
return us;
|
|
3315
3315
|
case I.Project:
|
|
3316
|
-
return
|
|
3316
|
+
return os;
|
|
3317
3317
|
case I.Ref:
|
|
3318
|
-
return
|
|
3318
|
+
return ls;
|
|
3319
3319
|
case I.Note:
|
|
3320
|
-
return
|
|
3320
|
+
return rs;
|
|
3321
3321
|
case I.Indexes:
|
|
3322
|
-
return
|
|
3322
|
+
return as;
|
|
3323
3323
|
case I.TablePartial:
|
|
3324
|
-
return
|
|
3324
|
+
return hs;
|
|
3325
3325
|
default:
|
|
3326
|
-
return
|
|
3326
|
+
return ss;
|
|
3327
3327
|
}
|
|
3328
3328
|
}
|
|
3329
|
-
class
|
|
3329
|
+
class fs {
|
|
3330
3330
|
constructor(e) {
|
|
3331
3331
|
this.ast = e, this.errors = [];
|
|
3332
3332
|
}
|
|
@@ -3336,10 +3336,10 @@ class us {
|
|
|
3336
3336
|
return null;
|
|
3337
3337
|
const s = jt(n), i = new s(n, this.errors);
|
|
3338
3338
|
return i.resolveInjections(e), i;
|
|
3339
|
-
}).forEach((n) => n == null ? void 0 : n.bind()), new
|
|
3339
|
+
}).forEach((n) => n == null ? void 0 : n.bind()), new K(this.ast, this.errors);
|
|
3340
3340
|
}
|
|
3341
3341
|
}
|
|
3342
|
-
class
|
|
3342
|
+
class ps {
|
|
3343
3343
|
constructor(e) {
|
|
3344
3344
|
this.generator = e;
|
|
3345
3345
|
}
|
|
@@ -3347,21 +3347,21 @@ class hs {
|
|
|
3347
3347
|
return new e(n, this.generator.nextId());
|
|
3348
3348
|
}
|
|
3349
3349
|
}
|
|
3350
|
-
class
|
|
3350
|
+
class ds {
|
|
3351
3351
|
constructor(e, n) {
|
|
3352
|
-
this.ast = e, this.symbolFactory = new
|
|
3352
|
+
this.ast = e, this.symbolFactory = new ps(n);
|
|
3353
3353
|
}
|
|
3354
3354
|
// Analyzing: Invoking both the validator and binder
|
|
3355
3355
|
analyze() {
|
|
3356
|
-
return new
|
|
3356
|
+
return new At(this.ast, this.symbolFactory).validate().chain((n) => new fs(n).resolve(this.symbolFactory));
|
|
3357
3357
|
}
|
|
3358
3358
|
// For invoking the validator only
|
|
3359
3359
|
validate() {
|
|
3360
|
-
return new
|
|
3360
|
+
return new At(this.ast, this.symbolFactory).validate().chain((n) => new K(n, []));
|
|
3361
3361
|
}
|
|
3362
3362
|
}
|
|
3363
|
-
function
|
|
3364
|
-
const { variables: n, tupleElements: s } =
|
|
3363
|
+
function _t(t, e) {
|
|
3364
|
+
const { variables: n, tupleElements: s } = De(t).unwrap();
|
|
3365
3365
|
return s ? n.length === 0 ? {
|
|
3366
3366
|
schemaName: e.schemaName,
|
|
3367
3367
|
tableName: e.name,
|
|
@@ -3390,8 +3390,9 @@ function Wt(t) {
|
|
|
3390
3390
|
return ["*", "1"];
|
|
3391
3391
|
case "-":
|
|
3392
3392
|
return ["1", "1"];
|
|
3393
|
+
default:
|
|
3394
|
+
throw new Error("Invalid relation op");
|
|
3393
3395
|
}
|
|
3394
|
-
throw new Error("Invalid relation op");
|
|
3395
3396
|
}
|
|
3396
3397
|
function _(t) {
|
|
3397
3398
|
return {
|
|
@@ -3400,16 +3401,20 @@ function _(t) {
|
|
|
3400
3401
|
line: t.startPos.line + 1,
|
|
3401
3402
|
column: t.startPos.column + 1
|
|
3402
3403
|
},
|
|
3403
|
-
end: {
|
|
3404
|
+
end: {
|
|
3405
|
+
offset: t.endPos.offset,
|
|
3406
|
+
line: t.endPos.line + 1,
|
|
3407
|
+
column: t.endPos.column + 1
|
|
3408
|
+
}
|
|
3404
3409
|
};
|
|
3405
3410
|
}
|
|
3406
3411
|
function $e(t) {
|
|
3407
3412
|
var n;
|
|
3408
|
-
const e = (n =
|
|
3409
|
-
return e instanceof
|
|
3413
|
+
const e = (n = _e(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
3414
|
+
return e instanceof ce ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
3410
3415
|
}
|
|
3411
|
-
function
|
|
3412
|
-
const e =
|
|
3416
|
+
function ge(t) {
|
|
3417
|
+
const e = Y(t).unwrap();
|
|
3413
3418
|
return {
|
|
3414
3419
|
name: e.pop(),
|
|
3415
3420
|
schemaName: e
|
|
@@ -3426,7 +3431,7 @@ function Yt(t, e) {
|
|
|
3426
3431
|
const n = t.id.toString(), s = e.id.toString();
|
|
3427
3432
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
3428
3433
|
}
|
|
3429
|
-
function
|
|
3434
|
+
function ct(t, e) {
|
|
3430
3435
|
if (Array.isArray(t)) {
|
|
3431
3436
|
const i = t.map(({ id: r }) => r).sort(), a = e.map(({ id: r }) => r).sort();
|
|
3432
3437
|
return g.zip(i, a).every(([r, c]) => r === c);
|
|
@@ -3434,13 +3439,66 @@ function ut(t, e) {
|
|
|
3434
3439
|
const n = t.id, s = e.id;
|
|
3435
3440
|
return n === s;
|
|
3436
3441
|
}
|
|
3437
|
-
function
|
|
3442
|
+
function se(t) {
|
|
3438
3443
|
const e = t.split(`
|
|
3439
3444
|
`), n = e.slice(e.findIndex((a) => a.trimStart() !== "")), s = n.filter((a) => a.trimStart()), i = Math.min(...s.map((a) => a.length - a.trimStart().length));
|
|
3440
3445
|
return n.map((a) => a.slice(i)).join(`
|
|
3441
3446
|
`);
|
|
3442
3447
|
}
|
|
3443
|
-
|
|
3448
|
+
function qt(t) {
|
|
3449
|
+
var e, n;
|
|
3450
|
+
if (t) {
|
|
3451
|
+
if (W(t))
|
|
3452
|
+
return {
|
|
3453
|
+
value: V(t).unwrap(),
|
|
3454
|
+
type: "string"
|
|
3455
|
+
};
|
|
3456
|
+
if (pe(t))
|
|
3457
|
+
return {
|
|
3458
|
+
type: "number",
|
|
3459
|
+
value: Number.parseFloat(t.expression.literal.value)
|
|
3460
|
+
};
|
|
3461
|
+
if (fe(t))
|
|
3462
|
+
return {
|
|
3463
|
+
value: t.expression.variable.value.toLowerCase(),
|
|
3464
|
+
type: "boolean"
|
|
3465
|
+
};
|
|
3466
|
+
if (t instanceof oe && Bt.includes((e = t.op) == null ? void 0 : e.value) && pe(t.expression)) {
|
|
3467
|
+
const s = Number.parseFloat(t.expression.expression.literal.value);
|
|
3468
|
+
return {
|
|
3469
|
+
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - s : s,
|
|
3470
|
+
type: "number"
|
|
3471
|
+
};
|
|
3472
|
+
}
|
|
3473
|
+
if (t instanceof ue && t.value)
|
|
3474
|
+
return {
|
|
3475
|
+
value: t.value.value,
|
|
3476
|
+
type: "expression"
|
|
3477
|
+
};
|
|
3478
|
+
throw new Error("Unreachable");
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
function Ht(t) {
|
|
3482
|
+
let e = null;
|
|
3483
|
+
t instanceof H && (e = t.argumentList.elementList.map((a) => pe(a) ? a.expression.literal.value : W(a) ? V(a).unwrap() : q(a).unwrap()).join(","), t = t.callee);
|
|
3484
|
+
let n = "";
|
|
3485
|
+
for (; t instanceof he; )
|
|
3486
|
+
n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3487
|
+
const { name: s, schemaName: i } = ge(t);
|
|
3488
|
+
return i.length > 1 ? new K(
|
|
3489
|
+
{
|
|
3490
|
+
schemaName: i.length === 0 ? null : i[0],
|
|
3491
|
+
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3492
|
+
args: e
|
|
3493
|
+
},
|
|
3494
|
+
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3495
|
+
) : new K({
|
|
3496
|
+
schemaName: i.length === 0 ? null : i[0],
|
|
3497
|
+
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3498
|
+
args: e
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
class zt {
|
|
3444
3502
|
constructor(e, n) {
|
|
3445
3503
|
this.declarationNode = e, this.env = n, this.table = {
|
|
3446
3504
|
name: void 0,
|
|
@@ -3469,16 +3527,18 @@ class qt {
|
|
|
3469
3527
|
// do not make sense to have a meaningful end (?)
|
|
3470
3528
|
},
|
|
3471
3529
|
pk: !0
|
|
3472
|
-
}), this.pkColumns.forEach((n) =>
|
|
3530
|
+
}), this.pkColumns.forEach((n) => {
|
|
3531
|
+
n.pk = !1;
|
|
3532
|
+
})), e;
|
|
3473
3533
|
}
|
|
3474
3534
|
interpretName(e) {
|
|
3475
|
-
const { name: n, schemaName: s } =
|
|
3535
|
+
const { name: n, schemaName: s } = ge(e);
|
|
3476
3536
|
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
3477
3537
|
}
|
|
3478
3538
|
interpretAlias(e) {
|
|
3479
3539
|
if (!e)
|
|
3480
3540
|
return [];
|
|
3481
|
-
const n =
|
|
3541
|
+
const n = X(e).unwrap_or(null);
|
|
3482
3542
|
return n && (this.env.aliases.push({
|
|
3483
3543
|
name: n,
|
|
3484
3544
|
kind: "table",
|
|
@@ -3490,16 +3550,16 @@ class qt {
|
|
|
3490
3550
|
}
|
|
3491
3551
|
interpretSettingList(e) {
|
|
3492
3552
|
var i, a, r;
|
|
3493
|
-
const n =
|
|
3494
|
-
this.table.headerColor = (i = n.
|
|
3495
|
-
const [s] = n.
|
|
3553
|
+
const n = F(e).getValue();
|
|
3554
|
+
this.table.headerColor = (i = n[N.HeaderColor]) != null && i.length ? Oe((r = (a = n[N.HeaderColor]) == null ? void 0 : a.at(0)) == null ? void 0 : r.value) : void 0;
|
|
3555
|
+
const [s] = n[N.Note] || [];
|
|
3496
3556
|
return this.table.note = s && {
|
|
3497
|
-
value:
|
|
3557
|
+
value: V(s == null ? void 0 : s.value).map(se).unwrap(),
|
|
3498
3558
|
token: _(s)
|
|
3499
3559
|
}, [];
|
|
3500
3560
|
}
|
|
3501
3561
|
interpretBody(e) {
|
|
3502
|
-
const [n, s] = g.partition(e.body, (i) => i instanceof w || i instanceof
|
|
3562
|
+
const [n, s] = g.partition(e.body, (i) => i instanceof w || i instanceof Le);
|
|
3503
3563
|
return [
|
|
3504
3564
|
...this.interpretFields(n),
|
|
3505
3565
|
...this.interpretSubElements(s)
|
|
@@ -3511,9 +3571,9 @@ class qt {
|
|
|
3511
3571
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3512
3572
|
case I.Note:
|
|
3513
3573
|
return this.table.note = {
|
|
3514
|
-
value:
|
|
3515
|
-
n.body instanceof
|
|
3516
|
-
).map(
|
|
3574
|
+
value: V(
|
|
3575
|
+
n.body instanceof ae ? n.body.body[0].callee : n.body.callee
|
|
3576
|
+
).map(se).unwrap(),
|
|
3517
3577
|
token: _(n)
|
|
3518
3578
|
}, [];
|
|
3519
3579
|
case I.Indexes:
|
|
@@ -3533,68 +3593,68 @@ class qt {
|
|
|
3533
3593
|
interpretColumn(e) {
|
|
3534
3594
|
var r, c, p, f, d, u, E, L, v;
|
|
3535
3595
|
const n = [], s = {};
|
|
3536
|
-
s.name =
|
|
3537
|
-
const i =
|
|
3596
|
+
s.name = X(e.callee).unwrap();
|
|
3597
|
+
const i = Ht(e.args[0]);
|
|
3538
3598
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = _(e), s.inline_refs = [];
|
|
3539
3599
|
const a = e.args.slice(1);
|
|
3540
3600
|
if (g.last(a) instanceof M) {
|
|
3541
|
-
const A =
|
|
3542
|
-
s.pk = !!((r = A.
|
|
3543
|
-
const P = (v = A.
|
|
3601
|
+
const A = F(a.pop()).getValue();
|
|
3602
|
+
s.pk = !!((r = A[N.PK]) != null && r.length) || !!((c = A[N.PKey]) != null && c.length), s.increment = !!((p = A[N.Increment]) != null && p.length), s.unique = !!((f = A[N.Unique]) != null && f.length), s.not_null = (d = A[N.NotNull]) != null && d.length ? !0 : (u = A[N.Null]) != null && u.length ? !1 : void 0, s.dbdefault = qt((L = (E = A[N.Default]) == null ? void 0 : E.at(0)) == null ? void 0 : L.value);
|
|
3603
|
+
const P = (v = A[N.Note]) == null ? void 0 : v.at(0);
|
|
3544
3604
|
s.note = P && {
|
|
3545
|
-
value:
|
|
3605
|
+
value: V(P.value).map(se).unwrap(),
|
|
3546
3606
|
token: _(P)
|
|
3547
3607
|
};
|
|
3548
|
-
const
|
|
3549
|
-
s.inline_refs =
|
|
3550
|
-
const [Ue] = $e(
|
|
3551
|
-
if (
|
|
3552
|
-
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
3553
|
-
const Ne =
|
|
3554
|
-
let
|
|
3555
|
-
if (
|
|
3556
|
-
const [
|
|
3557
|
-
|
|
3608
|
+
const be = A[N.Ref] || [];
|
|
3609
|
+
s.inline_refs = be.flatMap((D) => {
|
|
3610
|
+
const [Ue] = $e(D.value.expression);
|
|
3611
|
+
if (ct(Ue, e.symbol))
|
|
3612
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", D)), [];
|
|
3613
|
+
const Ne = D.value.op, B = Y(D.value.expression).unwrap();
|
|
3614
|
+
let ee;
|
|
3615
|
+
if (B.length === 1) {
|
|
3616
|
+
const [z] = B;
|
|
3617
|
+
ee = {
|
|
3558
3618
|
schemaName: this.table.schemaName,
|
|
3559
3619
|
tableName: this.table.name,
|
|
3560
|
-
fieldNames: [
|
|
3620
|
+
fieldNames: [z],
|
|
3561
3621
|
relation: Ne.value,
|
|
3562
|
-
token: _(
|
|
3622
|
+
token: _(D)
|
|
3563
3623
|
};
|
|
3564
|
-
} else if (
|
|
3565
|
-
const [
|
|
3566
|
-
|
|
3624
|
+
} else if (B.length === 2) {
|
|
3625
|
+
const [z, me] = B;
|
|
3626
|
+
ee = {
|
|
3567
3627
|
schemaName: null,
|
|
3568
|
-
tableName:
|
|
3628
|
+
tableName: z,
|
|
3569
3629
|
fieldNames: [me],
|
|
3570
3630
|
relation: Ne.value,
|
|
3571
|
-
token: _(
|
|
3631
|
+
token: _(D)
|
|
3572
3632
|
};
|
|
3573
|
-
} else if (
|
|
3574
|
-
const [
|
|
3575
|
-
|
|
3576
|
-
schemaName:
|
|
3633
|
+
} else if (B.length === 3) {
|
|
3634
|
+
const [z, me, ft] = B;
|
|
3635
|
+
ee = {
|
|
3636
|
+
schemaName: z,
|
|
3577
3637
|
tableName: me,
|
|
3578
|
-
fieldNames: [
|
|
3638
|
+
fieldNames: [ft],
|
|
3579
3639
|
relation: Ne.value,
|
|
3580
|
-
token: _(
|
|
3640
|
+
token: _(D)
|
|
3581
3641
|
};
|
|
3582
3642
|
} else {
|
|
3583
|
-
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported",
|
|
3584
|
-
const
|
|
3585
|
-
|
|
3586
|
-
schemaName:
|
|
3643
|
+
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", D));
|
|
3644
|
+
const z = B.pop(), me = B.pop();
|
|
3645
|
+
ee = {
|
|
3646
|
+
schemaName: B.join("."),
|
|
3587
3647
|
tableName: me,
|
|
3588
|
-
fieldNames: [
|
|
3648
|
+
fieldNames: [z],
|
|
3589
3649
|
relation: Ne.value,
|
|
3590
|
-
token: _(
|
|
3650
|
+
token: _(D)
|
|
3591
3651
|
};
|
|
3592
3652
|
}
|
|
3593
|
-
const Te = this.registerInlineRefToEnv(e, Ue,
|
|
3594
|
-
return n.push(...Te), Te.length === 0 ?
|
|
3653
|
+
const Te = this.registerInlineRefToEnv(e, Ue, ee, D);
|
|
3654
|
+
return n.push(...Te), Te.length === 0 ? ee : [];
|
|
3595
3655
|
});
|
|
3596
3656
|
}
|
|
3597
|
-
return s.pk || (s.pk = a.some((A) =>
|
|
3657
|
+
return s.pk || (s.pk = a.some((A) => q(A).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = a.some((A) => q(A).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3598
3658
|
}
|
|
3599
3659
|
interpretIndexes(e) {
|
|
3600
3660
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
@@ -3603,19 +3663,19 @@ class qt {
|
|
|
3603
3663
|
s.token = _(i);
|
|
3604
3664
|
const a = [i.callee, ...i.args];
|
|
3605
3665
|
if (g.last(a) instanceof M) {
|
|
3606
|
-
const L =
|
|
3607
|
-
s.pk = !!((r = L.
|
|
3608
|
-
const v = (d = L.
|
|
3666
|
+
const L = F(a.pop()).getValue();
|
|
3667
|
+
s.pk = !!((r = L[N.PK]) != null && r.length), s.unique = !!((c = L[N.Unique]) != null && c.length), s.name = V((f = (p = L[N.Name]) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
|
|
3668
|
+
const v = (d = L[N.Note]) == null ? void 0 : d.at(0);
|
|
3609
3669
|
s.note = v && {
|
|
3610
|
-
value:
|
|
3670
|
+
value: V(v.value).unwrap(),
|
|
3611
3671
|
token: _(v)
|
|
3612
|
-
}, s.type =
|
|
3672
|
+
}, s.type = q((E = (u = L[N.Type]) == null ? void 0 : u.at(0)) == null ? void 0 : E.value).unwrap_or(void 0);
|
|
3613
3673
|
}
|
|
3614
3674
|
return a.flatMap((L) => {
|
|
3615
|
-
if (!(L instanceof
|
|
3675
|
+
if (!(L instanceof H))
|
|
3616
3676
|
return L;
|
|
3617
3677
|
const v = [];
|
|
3618
|
-
for (; L instanceof
|
|
3678
|
+
for (; L instanceof H; )
|
|
3619
3679
|
v.push(L.argumentList), L = L.callee;
|
|
3620
3680
|
return v.push(L), v;
|
|
3621
3681
|
}).forEach((L) => {
|
|
@@ -3627,7 +3687,7 @@ class qt {
|
|
|
3627
3687
|
token: _(P)
|
|
3628
3688
|
})),
|
|
3629
3689
|
...A.map((P) => ({
|
|
3630
|
-
value:
|
|
3690
|
+
value: X(P).unwrap(),
|
|
3631
3691
|
type: "column",
|
|
3632
3692
|
token: _(P)
|
|
3633
3693
|
}))
|
|
@@ -3655,7 +3715,7 @@ class qt {
|
|
|
3655
3715
|
{
|
|
3656
3716
|
schemaName: this.table.schemaName,
|
|
3657
3717
|
tableName: this.table.name,
|
|
3658
|
-
fieldNames: [
|
|
3718
|
+
fieldNames: [q(e.callee).unwrap()],
|
|
3659
3719
|
token: _(e),
|
|
3660
3720
|
relation: r[0]
|
|
3661
3721
|
}
|
|
@@ -3663,59 +3723,6 @@ class qt {
|
|
|
3663
3723
|
}), [];
|
|
3664
3724
|
}
|
|
3665
3725
|
}
|
|
3666
|
-
function ps(t) {
|
|
3667
|
-
let e = null;
|
|
3668
|
-
t instanceof q && (e = t.argumentList.elementList.map((a) => ee(a) ? a.expression.literal.value : C(a) ? F(a).unwrap() : Y(a).unwrap()).join(","), t = t.callee);
|
|
3669
|
-
let n = "";
|
|
3670
|
-
for (; t instanceof he; )
|
|
3671
|
-
n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3672
|
-
const { name: s, schemaName: i } = be(t);
|
|
3673
|
-
return i.length > 1 ? new z(
|
|
3674
|
-
{
|
|
3675
|
-
schemaName: i.length === 0 ? null : i[0],
|
|
3676
|
-
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3677
|
-
args: e
|
|
3678
|
-
},
|
|
3679
|
-
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3680
|
-
) : new z({
|
|
3681
|
-
schemaName: i.length === 0 ? null : i[0],
|
|
3682
|
-
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3683
|
-
args: e
|
|
3684
|
-
});
|
|
3685
|
-
}
|
|
3686
|
-
function ds(t) {
|
|
3687
|
-
var e, n, s;
|
|
3688
|
-
if (t) {
|
|
3689
|
-
if (C(t))
|
|
3690
|
-
return {
|
|
3691
|
-
value: F(t).unwrap(),
|
|
3692
|
-
type: "string"
|
|
3693
|
-
};
|
|
3694
|
-
if (ee(t))
|
|
3695
|
-
return {
|
|
3696
|
-
type: "number",
|
|
3697
|
-
value: Number.parseFloat(t.expression.literal.value)
|
|
3698
|
-
};
|
|
3699
|
-
if (fe(t))
|
|
3700
|
-
return {
|
|
3701
|
-
value: t.expression.variable.value.toLowerCase(),
|
|
3702
|
-
type: "boolean"
|
|
3703
|
-
};
|
|
3704
|
-
if (t instanceof ae && ct.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
|
|
3705
|
-
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3706
|
-
return {
|
|
3707
|
-
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
3708
|
-
type: "number"
|
|
3709
|
-
};
|
|
3710
|
-
}
|
|
3711
|
-
if (t instanceof ue)
|
|
3712
|
-
return {
|
|
3713
|
-
value: (s = t.value) == null ? void 0 : s.value,
|
|
3714
|
-
type: "expression"
|
|
3715
|
-
};
|
|
3716
|
-
throw new Error("Unreachable");
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
3726
|
class Es {
|
|
3720
3727
|
constructor(e, n) {
|
|
3721
3728
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
@@ -3728,12 +3735,12 @@ class Es {
|
|
|
3728
3735
|
];
|
|
3729
3736
|
}
|
|
3730
3737
|
interpretName(e) {
|
|
3731
|
-
const { name: n } =
|
|
3738
|
+
const { name: n } = ge(e);
|
|
3732
3739
|
return this.note.name = n, [];
|
|
3733
3740
|
}
|
|
3734
3741
|
interpretSettingList(e) {
|
|
3735
3742
|
var s, i, a;
|
|
3736
|
-
const n =
|
|
3743
|
+
const n = F(e).getValue();
|
|
3737
3744
|
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Oe((a = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : a.value) : void 0, [];
|
|
3738
3745
|
}
|
|
3739
3746
|
interpretBody(e) {
|
|
@@ -3744,10 +3751,10 @@ class Es {
|
|
|
3744
3751
|
}
|
|
3745
3752
|
interpretNote(e) {
|
|
3746
3753
|
const n = g.get(e, "callee.expression.literal.value", "");
|
|
3747
|
-
return this.note.content =
|
|
3754
|
+
return this.note.content = se(n), [];
|
|
3748
3755
|
}
|
|
3749
3756
|
}
|
|
3750
|
-
class
|
|
3757
|
+
class Qt {
|
|
3751
3758
|
constructor(e, n) {
|
|
3752
3759
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof y ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3753
3760
|
}
|
|
@@ -3758,7 +3765,7 @@ class zt {
|
|
|
3758
3765
|
];
|
|
3759
3766
|
}
|
|
3760
3767
|
interpretName(e) {
|
|
3761
|
-
const n = [], s =
|
|
3768
|
+
const n = [], s = Y(this.declarationNode.name).unwrap_or([]);
|
|
3762
3769
|
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3763
3770
|
}
|
|
3764
3771
|
interpretBody(e) {
|
|
@@ -3767,7 +3774,7 @@ class zt {
|
|
|
3767
3774
|
interpretField(e) {
|
|
3768
3775
|
var f, d, u, E, L, v, A;
|
|
3769
3776
|
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, a = $e(s), r = $e(i);
|
|
3770
|
-
if (
|
|
3777
|
+
if (ct(a, r))
|
|
3771
3778
|
return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3772
3779
|
const c = Yt(a, r);
|
|
3773
3780
|
if (this.env.refIds[c])
|
|
@@ -3776,27 +3783,27 @@ class zt {
|
|
|
3776
3783
|
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
|
|
3777
3784
|
];
|
|
3778
3785
|
if (e.args[0]) {
|
|
3779
|
-
const P =
|
|
3780
|
-
this.ref.onDelete =
|
|
3781
|
-
const
|
|
3782
|
-
this.ref.onUpdate =
|
|
3786
|
+
const P = F(e.args[0]).getValue(), be = (d = (f = P.delete) == null ? void 0 : f.at(0)) == null ? void 0 : d.value;
|
|
3787
|
+
this.ref.onDelete = be instanceof te ? we(be).unwrap_or(void 0) : q(be).unwrap_or(void 0);
|
|
3788
|
+
const D = (E = (u = P.update) == null ? void 0 : u.at(0)) == null ? void 0 : E.value;
|
|
3789
|
+
this.ref.onUpdate = D instanceof te ? we(D).unwrap_or(void 0) : q(D).unwrap_or(void 0), this.ref.color = (L = P.color) != null && L.length ? Oe((A = (v = P.color) == null ? void 0 : v.at(0)) == null ? void 0 : A.value) : void 0;
|
|
3783
3790
|
}
|
|
3784
3791
|
const p = Wt(n);
|
|
3785
3792
|
return this.ref.endpoints = [
|
|
3786
3793
|
{
|
|
3787
|
-
...
|
|
3794
|
+
..._t(s, this.container),
|
|
3788
3795
|
relation: p[0],
|
|
3789
3796
|
token: _(s)
|
|
3790
3797
|
},
|
|
3791
3798
|
{
|
|
3792
|
-
...
|
|
3799
|
+
..._t(i, this.container),
|
|
3793
3800
|
relation: p[1],
|
|
3794
3801
|
token: _(i)
|
|
3795
3802
|
}
|
|
3796
3803
|
], this.env.refIds[c] = this.declarationNode, [];
|
|
3797
3804
|
}
|
|
3798
3805
|
}
|
|
3799
|
-
class
|
|
3806
|
+
class Jt {
|
|
3800
3807
|
constructor(e, n) {
|
|
3801
3808
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3802
3809
|
}
|
|
@@ -3809,11 +3816,11 @@ class Ht {
|
|
|
3809
3816
|
), e;
|
|
3810
3817
|
}
|
|
3811
3818
|
interpretName(e) {
|
|
3812
|
-
const n = [], { name: s, schemaName: i } =
|
|
3819
|
+
const n = [], { name: s, schemaName: i } = ge(e);
|
|
3813
3820
|
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3814
3821
|
}
|
|
3815
3822
|
interpretBody(e) {
|
|
3816
|
-
const [n, s] =
|
|
3823
|
+
const [n, s] = Pt(e.body, (i) => i instanceof w);
|
|
3817
3824
|
return [
|
|
3818
3825
|
...this.interpretFields(n),
|
|
3819
3826
|
...this.interpretSubElements(s)
|
|
@@ -3825,9 +3832,9 @@ class Ht {
|
|
|
3825
3832
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3826
3833
|
case "note":
|
|
3827
3834
|
this.tableGroup.note = {
|
|
3828
|
-
value:
|
|
3829
|
-
n.body instanceof
|
|
3830
|
-
).map(
|
|
3835
|
+
value: V(
|
|
3836
|
+
n.body instanceof ae ? n.body.body[0].callee : n.body.callee
|
|
3837
|
+
).map(se).unwrap(),
|
|
3831
3838
|
token: _(n)
|
|
3832
3839
|
};
|
|
3833
3840
|
break;
|
|
@@ -3838,9 +3845,9 @@ class Ht {
|
|
|
3838
3845
|
interpretFields(e) {
|
|
3839
3846
|
const n = [];
|
|
3840
3847
|
return this.tableGroup.tables = e.map((s) => {
|
|
3841
|
-
const i =
|
|
3848
|
+
const i = Y(s.callee).unwrap();
|
|
3842
3849
|
i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3843
|
-
const a =
|
|
3850
|
+
const a = _e(s.callee).unwrap().pop().referee.id;
|
|
3844
3851
|
if (this.env.groupOfTable[a]) {
|
|
3845
3852
|
const r = this.env.groupOfTable[a], { schemaName: c, name: p } = this.env.tableGroups.get(r), f = c ? `${c}.${p}` : p;
|
|
3846
3853
|
n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${f}"`, s));
|
|
@@ -3854,16 +3861,16 @@ class Ht {
|
|
|
3854
3861
|
}
|
|
3855
3862
|
interpretSettingList(e) {
|
|
3856
3863
|
var i, a, r;
|
|
3857
|
-
const n =
|
|
3864
|
+
const n = F(e).getValue();
|
|
3858
3865
|
this.tableGroup.color = (i = n.color) != null && i.length ? Oe((r = (a = n.color) == null ? void 0 : a.at(0)) == null ? void 0 : r.value) : void 0;
|
|
3859
3866
|
const [s] = n.note || [];
|
|
3860
3867
|
return this.tableGroup.note = s && {
|
|
3861
|
-
value:
|
|
3868
|
+
value: V(s == null ? void 0 : s.value).map(se).unwrap(),
|
|
3862
3869
|
token: _(s)
|
|
3863
3870
|
}, [];
|
|
3864
3871
|
}
|
|
3865
3872
|
}
|
|
3866
|
-
class
|
|
3873
|
+
class Kt {
|
|
3867
3874
|
constructor(e, n) {
|
|
3868
3875
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3869
3876
|
}
|
|
@@ -3871,76 +3878,23 @@ class Qt {
|
|
|
3871
3878
|
return this.enum.token = _(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3872
3879
|
}
|
|
3873
3880
|
interpretName(e) {
|
|
3874
|
-
const { name: n, schemaName: s } =
|
|
3881
|
+
const { name: n, schemaName: s } = ge(e);
|
|
3875
3882
|
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3876
3883
|
}
|
|
3877
3884
|
interpretBody(e) {
|
|
3878
3885
|
return e.body.flatMap((n) => {
|
|
3879
3886
|
var c;
|
|
3880
3887
|
const s = n, i = {};
|
|
3881
|
-
i.token = _(s), i.name =
|
|
3882
|
-
const r = (c =
|
|
3888
|
+
i.token = _(s), i.name = q(s.callee).unwrap();
|
|
3889
|
+
const r = (c = F(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3883
3890
|
return i.note = r && {
|
|
3884
|
-
value:
|
|
3891
|
+
value: V(r.value).map(se).unwrap(),
|
|
3885
3892
|
token: _(r)
|
|
3886
3893
|
}, this.enum.values.push(i), [];
|
|
3887
3894
|
});
|
|
3888
3895
|
}
|
|
3889
3896
|
}
|
|
3890
|
-
|
|
3891
|
-
let e = null, n = t;
|
|
3892
|
-
n instanceof q && (e = n.argumentList.elementList.map((r) => ee(r) ? r.expression.literal.value : C(r) ? F(r).unwrap() : Y(r).unwrap()).join(","), n = n.callee);
|
|
3893
|
-
let s = "";
|
|
3894
|
-
for (; n instanceof he; )
|
|
3895
|
-
s = `[${n.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${s}`, n = n.array;
|
|
3896
|
-
const { name: i, schemaName: a } = be(t);
|
|
3897
|
-
return a.length > 1 ? new z(
|
|
3898
|
-
{
|
|
3899
|
-
schemaName: a.length === 0 ? null : a[0],
|
|
3900
|
-
type_name: `${i}${s}${e ? `(${e})` : ""}`,
|
|
3901
|
-
args: e
|
|
3902
|
-
},
|
|
3903
|
-
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3904
|
-
) : new z({
|
|
3905
|
-
schemaName: a.length === 0 ? null : a[0],
|
|
3906
|
-
type_name: `${i}${s}${e ? `(${e})` : ""}`,
|
|
3907
|
-
args: e
|
|
3908
|
-
});
|
|
3909
|
-
}
|
|
3910
|
-
function Ts(t) {
|
|
3911
|
-
var e, n;
|
|
3912
|
-
if (t) {
|
|
3913
|
-
if (C(t))
|
|
3914
|
-
return {
|
|
3915
|
-
value: F(t).unwrap(),
|
|
3916
|
-
type: "string"
|
|
3917
|
-
};
|
|
3918
|
-
if (ee(t))
|
|
3919
|
-
return {
|
|
3920
|
-
type: "number",
|
|
3921
|
-
value: Number.parseFloat(t.expression.literal.value)
|
|
3922
|
-
};
|
|
3923
|
-
if (fe(t))
|
|
3924
|
-
return {
|
|
3925
|
-
value: t.expression.variable.value.toLowerCase(),
|
|
3926
|
-
type: "boolean"
|
|
3927
|
-
};
|
|
3928
|
-
if (t instanceof ae && ct.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
|
|
3929
|
-
const s = Number.parseFloat(t.expression.expression.literal.value);
|
|
3930
|
-
return {
|
|
3931
|
-
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - s : s,
|
|
3932
|
-
type: "number"
|
|
3933
|
-
};
|
|
3934
|
-
}
|
|
3935
|
-
if (t instanceof ue && t.value)
|
|
3936
|
-
return {
|
|
3937
|
-
value: t.value.value,
|
|
3938
|
-
type: "expression"
|
|
3939
|
-
};
|
|
3940
|
-
throw new Error("Unreachable");
|
|
3941
|
-
}
|
|
3942
|
-
}
|
|
3943
|
-
class Jt {
|
|
3897
|
+
class Zt {
|
|
3944
3898
|
constructor(e, n) {
|
|
3945
3899
|
this.declarationNode = e, this.env = n, this.tablePartial = {
|
|
3946
3900
|
name: void 0,
|
|
@@ -3970,20 +3924,20 @@ class Jt {
|
|
|
3970
3924
|
})), e;
|
|
3971
3925
|
}
|
|
3972
3926
|
interpretName(e) {
|
|
3973
|
-
const { name: n } =
|
|
3927
|
+
const { name: n } = ge(e);
|
|
3974
3928
|
return this.tablePartial.name = n, [];
|
|
3975
3929
|
}
|
|
3976
3930
|
interpretSettingList(e) {
|
|
3977
|
-
const n =
|
|
3931
|
+
const n = F(e).getValue(), s = on(n[N.HeaderColor]);
|
|
3978
3932
|
this.tablePartial.headerColor = s ? Oe(s.value) : void 0;
|
|
3979
|
-
const [i] = n[
|
|
3933
|
+
const [i] = n[N.Note] || [];
|
|
3980
3934
|
return this.tablePartial.note = i && {
|
|
3981
|
-
value:
|
|
3935
|
+
value: V(i == null ? void 0 : i.value).map(se).unwrap(),
|
|
3982
3936
|
token: _(i)
|
|
3983
3937
|
}, [];
|
|
3984
3938
|
}
|
|
3985
3939
|
interpretBody(e) {
|
|
3986
|
-
const [n, s] =
|
|
3940
|
+
const [n, s] = Pt(e.body, (i) => i instanceof w);
|
|
3987
3941
|
return [
|
|
3988
3942
|
...this.interpretFields(n),
|
|
3989
3943
|
...this.interpretSubElements(s)
|
|
@@ -3995,9 +3949,9 @@ class Jt {
|
|
|
3995
3949
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3996
3950
|
case I.Note:
|
|
3997
3951
|
return this.tablePartial.note = {
|
|
3998
|
-
value:
|
|
3999
|
-
n.body instanceof
|
|
4000
|
-
).map(
|
|
3952
|
+
value: V(
|
|
3953
|
+
n.body instanceof ae ? n.body.body[0].callee : n.body.callee
|
|
3954
|
+
).map(se).unwrap(),
|
|
4001
3955
|
token: _(n)
|
|
4002
3956
|
}, [];
|
|
4003
3957
|
case I.Indexes:
|
|
@@ -4013,58 +3967,58 @@ class Jt {
|
|
|
4013
3967
|
interpretColumn(e) {
|
|
4014
3968
|
var r, c, p, f, d, u, E, L, v;
|
|
4015
3969
|
const n = [], s = {};
|
|
4016
|
-
s.name =
|
|
4017
|
-
const i =
|
|
3970
|
+
s.name = X(e.callee).unwrap();
|
|
3971
|
+
const i = Ht(e.args[0]);
|
|
4018
3972
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = _(e), s.inline_refs = [];
|
|
4019
3973
|
const a = e.args.slice(1);
|
|
4020
3974
|
if (g.last(a) instanceof M) {
|
|
4021
|
-
const A =
|
|
4022
|
-
s.pk = !!((r = A[
|
|
4023
|
-
const P = (v = A[
|
|
3975
|
+
const A = F(a.pop()).getValue();
|
|
3976
|
+
s.pk = !!((r = A[N.PK]) != null && r.length) || !!((c = A[N.PKey]) != null && c.length), s.increment = !!((p = A[N.Increment]) != null && p.length), s.unique = !!((f = A[N.Unique]) != null && f.length), s.not_null = (d = A[N.NotNull]) != null && d.length ? !0 : (u = A[N.Null]) != null && u.length ? !1 : void 0, s.dbdefault = qt((L = (E = A[N.Default]) == null ? void 0 : E.at(0)) == null ? void 0 : L.value);
|
|
3977
|
+
const P = (v = A[N.Note]) == null ? void 0 : v.at(0);
|
|
4024
3978
|
s.note = P && {
|
|
4025
|
-
value:
|
|
3979
|
+
value: V(P.value).map(se).unwrap(),
|
|
4026
3980
|
token: _(P)
|
|
4027
3981
|
};
|
|
4028
|
-
const
|
|
4029
|
-
s.inline_refs =
|
|
4030
|
-
const [Ue] = $e(
|
|
4031
|
-
if (
|
|
4032
|
-
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
4033
|
-
const Ne =
|
|
4034
|
-
let
|
|
4035
|
-
if (
|
|
4036
|
-
const [Te,
|
|
4037
|
-
|
|
3982
|
+
const be = A[N.Ref] || [];
|
|
3983
|
+
s.inline_refs = be.flatMap((D) => {
|
|
3984
|
+
const [Ue] = $e(D.value.expression);
|
|
3985
|
+
if (ct(Ue, e.symbol))
|
|
3986
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", D)), [];
|
|
3987
|
+
const Ne = D.value.op, B = Y(D.value.expression).unwrap();
|
|
3988
|
+
let ee;
|
|
3989
|
+
if (B.length === 2) {
|
|
3990
|
+
const [Te, z] = B;
|
|
3991
|
+
ee = {
|
|
4038
3992
|
schemaName: null,
|
|
4039
3993
|
tableName: Te,
|
|
4040
|
-
fieldNames: [
|
|
3994
|
+
fieldNames: [z],
|
|
4041
3995
|
relation: Ne.value,
|
|
4042
|
-
token: _(
|
|
3996
|
+
token: _(D)
|
|
4043
3997
|
};
|
|
4044
|
-
} else if (
|
|
4045
|
-
const [Te,
|
|
4046
|
-
|
|
3998
|
+
} else if (B.length === 3) {
|
|
3999
|
+
const [Te, z, me] = B;
|
|
4000
|
+
ee = {
|
|
4047
4001
|
schemaName: Te,
|
|
4048
|
-
tableName:
|
|
4002
|
+
tableName: z,
|
|
4049
4003
|
fieldNames: [me],
|
|
4050
4004
|
relation: Ne.value,
|
|
4051
|
-
token: _(
|
|
4005
|
+
token: _(D)
|
|
4052
4006
|
};
|
|
4053
4007
|
} else {
|
|
4054
|
-
n.push(new l(o.UNSUPPORTED, "Unsupported",
|
|
4055
|
-
const Te =
|
|
4056
|
-
|
|
4057
|
-
schemaName:
|
|
4058
|
-
tableName:
|
|
4008
|
+
n.push(new l(o.UNSUPPORTED, "Unsupported", D));
|
|
4009
|
+
const Te = B.pop(), z = B.pop();
|
|
4010
|
+
ee = {
|
|
4011
|
+
schemaName: B.join("."),
|
|
4012
|
+
tableName: z,
|
|
4059
4013
|
fieldNames: [Te],
|
|
4060
4014
|
relation: Ne.value,
|
|
4061
|
-
token: _(
|
|
4015
|
+
token: _(D)
|
|
4062
4016
|
};
|
|
4063
4017
|
}
|
|
4064
|
-
return
|
|
4018
|
+
return ee;
|
|
4065
4019
|
});
|
|
4066
4020
|
}
|
|
4067
|
-
return s.pk || (s.pk = a.some((A) =>
|
|
4021
|
+
return s.pk || (s.pk = a.some((A) => q(A).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = a.some((A) => q(A).unwrap().toLowerCase() === "unique")), this.tablePartial.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
4068
4022
|
}
|
|
4069
4023
|
interpretIndexes(e) {
|
|
4070
4024
|
return this.tablePartial.indexes.push(...e.body.body.map((n) => {
|
|
@@ -4073,20 +4027,20 @@ class Jt {
|
|
|
4073
4027
|
s.token = _(i);
|
|
4074
4028
|
const a = [i.callee, ...i.args];
|
|
4075
4029
|
if (g.last(a) instanceof M) {
|
|
4076
|
-
const L =
|
|
4077
|
-
s.pk = !!((r = L[
|
|
4078
|
-
const v = (d = L[
|
|
4030
|
+
const L = F(a.pop()).getValue();
|
|
4031
|
+
s.pk = !!((r = L[N.PK]) != null && r.length), s.unique = !!((c = L[N.Unique]) != null && c.length), s.name = V((f = (p = L[N.Name]) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
|
|
4032
|
+
const v = (d = L[N.Note]) == null ? void 0 : d.at(0);
|
|
4079
4033
|
s.note = v && {
|
|
4080
|
-
value:
|
|
4034
|
+
value: V(v.value).unwrap(),
|
|
4081
4035
|
token: _(v)
|
|
4082
|
-
}, s.type =
|
|
4036
|
+
}, s.type = q((E = (u = L[N.Type]) == null ? void 0 : u.at(0)) == null ? void 0 : E.value).unwrap_or(void 0);
|
|
4083
4037
|
}
|
|
4084
4038
|
return a.flatMap((L) => {
|
|
4085
|
-
if (!(L instanceof
|
|
4039
|
+
if (!(L instanceof H))
|
|
4086
4040
|
return L;
|
|
4087
4041
|
const v = [];
|
|
4088
4042
|
let A = L;
|
|
4089
|
-
for (; A instanceof
|
|
4043
|
+
for (; A instanceof H; )
|
|
4090
4044
|
v.push(A.argumentList), A = A.callee;
|
|
4091
4045
|
return v.push(A), v;
|
|
4092
4046
|
}).forEach((L) => {
|
|
@@ -4098,7 +4052,7 @@ class Jt {
|
|
|
4098
4052
|
token: _(P)
|
|
4099
4053
|
})),
|
|
4100
4054
|
...A.map((P) => ({
|
|
4101
|
-
value:
|
|
4055
|
+
value: X(P).unwrap(),
|
|
4102
4056
|
type: "column",
|
|
4103
4057
|
token: _(P)
|
|
4104
4058
|
}))
|
|
@@ -4107,7 +4061,7 @@ class Jt {
|
|
|
4107
4061
|
})), [];
|
|
4108
4062
|
}
|
|
4109
4063
|
}
|
|
4110
|
-
class
|
|
4064
|
+
class Ns {
|
|
4111
4065
|
constructor(e, n) {
|
|
4112
4066
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [], tablePartials: [] };
|
|
4113
4067
|
}
|
|
@@ -4117,7 +4071,7 @@ class ms {
|
|
|
4117
4071
|
interpretName(e) {
|
|
4118
4072
|
if (!e)
|
|
4119
4073
|
return this.project.name = null, [];
|
|
4120
|
-
const { name: n } =
|
|
4074
|
+
const { name: n } = ge(e);
|
|
4121
4075
|
return this.project.name = n, [];
|
|
4122
4076
|
}
|
|
4123
4077
|
interpretBody(e) {
|
|
@@ -4126,37 +4080,37 @@ class ms {
|
|
|
4126
4080
|
const s = n;
|
|
4127
4081
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
4128
4082
|
case "table": {
|
|
4129
|
-
const a = new
|
|
4083
|
+
const a = new zt(s, this.env).interpret();
|
|
4130
4084
|
return this.project.tables.push(this.env.tables.get(s)), a;
|
|
4131
4085
|
}
|
|
4132
4086
|
case "ref": {
|
|
4133
|
-
const a = new
|
|
4087
|
+
const a = new Qt(s, this.env).interpret();
|
|
4134
4088
|
return this.project.refs.push(this.env.ref.get(s)), a;
|
|
4135
4089
|
}
|
|
4136
4090
|
case "tablegroup": {
|
|
4137
|
-
const a = new
|
|
4091
|
+
const a = new Jt(s, this.env).interpret();
|
|
4138
4092
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), a;
|
|
4139
4093
|
}
|
|
4140
4094
|
case "enum": {
|
|
4141
|
-
const a = new
|
|
4095
|
+
const a = new Kt(s, this.env).interpret();
|
|
4142
4096
|
return this.project.enums.push(this.env.enums.get(s)), a;
|
|
4143
4097
|
}
|
|
4144
4098
|
case "note":
|
|
4145
4099
|
return this.project.note = {
|
|
4146
|
-
value:
|
|
4100
|
+
value: V(s.body instanceof ae ? s.body.body[0].callee : s.body.callee).map(se).unwrap(),
|
|
4147
4101
|
token: _(s)
|
|
4148
4102
|
}, [];
|
|
4149
4103
|
case "tablepartial": {
|
|
4150
|
-
const a = new
|
|
4104
|
+
const a = new Zt(s, this.env).interpret();
|
|
4151
4105
|
return this.project.tablePartials.push(this.env.tablePartials.get(s)), a;
|
|
4152
4106
|
}
|
|
4153
4107
|
default:
|
|
4154
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
4108
|
+
return this.project[s.type.value.toLowerCase()] = V(s.body.callee).unwrap(), [];
|
|
4155
4109
|
}
|
|
4156
4110
|
});
|
|
4157
4111
|
}
|
|
4158
4112
|
}
|
|
4159
|
-
function
|
|
4113
|
+
function Ts(t) {
|
|
4160
4114
|
return {
|
|
4161
4115
|
schemas: [],
|
|
4162
4116
|
tables: Array.from(t.tables.values()),
|
|
@@ -4169,7 +4123,7 @@ function bs(t) {
|
|
|
4169
4123
|
tablePartials: Array.from(t.tablePartials.values())
|
|
4170
4124
|
};
|
|
4171
4125
|
}
|
|
4172
|
-
class
|
|
4126
|
+
class ms {
|
|
4173
4127
|
constructor(e) {
|
|
4174
4128
|
this.ast = e, this.env = {
|
|
4175
4129
|
schema: [],
|
|
@@ -4187,30 +4141,30 @@ class Is {
|
|
|
4187
4141
|
}
|
|
4188
4142
|
interpret() {
|
|
4189
4143
|
const e = this.ast.body.flatMap((n) => {
|
|
4190
|
-
switch (
|
|
4144
|
+
switch (Ae(n).unwrap_or(void 0)) {
|
|
4191
4145
|
case I.Table:
|
|
4192
|
-
return new
|
|
4146
|
+
return new zt(n, this.env).interpret();
|
|
4193
4147
|
case I.Note:
|
|
4194
4148
|
return new Es(n, this.env).interpret();
|
|
4195
4149
|
case I.Ref:
|
|
4196
|
-
return new
|
|
4150
|
+
return new Qt(n, this.env).interpret();
|
|
4197
4151
|
case I.TableGroup:
|
|
4198
|
-
return new Ht(n, this.env).interpret();
|
|
4199
|
-
case I.TablePartial:
|
|
4200
4152
|
return new Jt(n, this.env).interpret();
|
|
4153
|
+
case I.TablePartial:
|
|
4154
|
+
return new Zt(n, this.env).interpret();
|
|
4201
4155
|
case I.Enum:
|
|
4202
|
-
return new
|
|
4156
|
+
return new Kt(n, this.env).interpret();
|
|
4203
4157
|
case I.Project:
|
|
4204
|
-
return new
|
|
4158
|
+
return new Ns(n, this.env).interpret();
|
|
4205
4159
|
default:
|
|
4206
4160
|
return [];
|
|
4207
4161
|
}
|
|
4208
4162
|
});
|
|
4209
|
-
return new
|
|
4163
|
+
return new K(Ts(this.env), e);
|
|
4210
4164
|
}
|
|
4211
4165
|
}
|
|
4212
4166
|
var k = /* @__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))(k || {}), R = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(R || {});
|
|
4213
|
-
function
|
|
4167
|
+
function xe(t) {
|
|
4214
4168
|
switch (t) {
|
|
4215
4169
|
case m.Schema:
|
|
4216
4170
|
return k.Module;
|
|
@@ -4260,87 +4214,87 @@ function Ke(t) {
|
|
|
4260
4214
|
...t,
|
|
4261
4215
|
suggestions: t.suggestions.map((e) => ({
|
|
4262
4216
|
...e,
|
|
4263
|
-
insertText: e.insertText.split("").every(
|
|
4217
|
+
insertText: e.insertText.split("").every(He) ? e.insertText : `"${e.insertText}"`
|
|
4264
4218
|
}))
|
|
4265
4219
|
};
|
|
4266
4220
|
}
|
|
4267
|
-
function
|
|
4221
|
+
function ut(t, e) {
|
|
4268
4222
|
return t.getOffsetAt(e);
|
|
4269
4223
|
}
|
|
4270
|
-
class
|
|
4224
|
+
class en {
|
|
4271
4225
|
constructor(e, n = []) {
|
|
4272
4226
|
this.compiler = e, this.triggerCharacters = n;
|
|
4273
4227
|
}
|
|
4274
4228
|
provideCompletionItems(e, n) {
|
|
4275
4229
|
var d, u;
|
|
4276
|
-
const s =
|
|
4230
|
+
const s = ut(e, n), i = this.compiler.token.flatStream(), { token: a, index: r } = this.compiler.container.token(s), c = r === void 0 ? i[0] : i[r + 1];
|
|
4277
4231
|
if ([
|
|
4278
4232
|
...(a == null ? void 0 : a.trailingTrivia) || [],
|
|
4279
4233
|
...(a == null ? void 0 : a.leadingTrivia) || [],
|
|
4280
4234
|
...(c == null ? void 0 : c.leadingTrivia) || []
|
|
4281
|
-
].find((E) =>
|
|
4235
|
+
].find((E) => un(E) && Se(s, E)))
|
|
4282
4236
|
return G();
|
|
4283
4237
|
if (r === void 0)
|
|
4284
|
-
return
|
|
4238
|
+
return kt();
|
|
4285
4239
|
if ([h.STRING_LITERAL, h.QUOTED_STRING].includes(a.kind) && Se(s, a))
|
|
4286
4240
|
return G();
|
|
4287
4241
|
const p = this.compiler.container.element(s);
|
|
4288
4242
|
if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof y && p.type && p.type.start <= s && p.type.end >= s)
|
|
4289
|
-
return
|
|
4243
|
+
return kt();
|
|
4290
4244
|
const f = [...this.compiler.container.stack(s)].reverse();
|
|
4291
4245
|
for (const E of f)
|
|
4292
|
-
if (E instanceof
|
|
4246
|
+
if (E instanceof oe)
|
|
4293
4247
|
switch ((d = E.op) == null ? void 0 : d.value) {
|
|
4294
4248
|
case ">":
|
|
4295
4249
|
case "<":
|
|
4296
4250
|
case "<>":
|
|
4297
4251
|
case "-":
|
|
4298
|
-
return
|
|
4252
|
+
return gt(
|
|
4299
4253
|
this.compiler,
|
|
4300
4254
|
s,
|
|
4301
4255
|
E
|
|
4302
4256
|
);
|
|
4303
4257
|
}
|
|
4304
|
-
else if (E instanceof
|
|
4258
|
+
else if (E instanceof le)
|
|
4305
4259
|
switch ((u = E.op) == null ? void 0 : u.value) {
|
|
4306
4260
|
case ">":
|
|
4307
4261
|
case "<":
|
|
4308
4262
|
case "<>":
|
|
4309
4263
|
case "-":
|
|
4310
|
-
return
|
|
4264
|
+
return gt(
|
|
4311
4265
|
this.compiler,
|
|
4312
4266
|
s,
|
|
4313
4267
|
E
|
|
4314
4268
|
);
|
|
4315
4269
|
case ".":
|
|
4316
|
-
return
|
|
4270
|
+
return tn(
|
|
4317
4271
|
this.compiler,
|
|
4318
4272
|
s,
|
|
4319
4273
|
E
|
|
4320
4274
|
);
|
|
4321
4275
|
}
|
|
4322
4276
|
else {
|
|
4323
|
-
if (E instanceof
|
|
4324
|
-
return
|
|
4277
|
+
if (E instanceof ne)
|
|
4278
|
+
return vt(this.compiler, s, E);
|
|
4325
4279
|
if (E instanceof M)
|
|
4326
|
-
return
|
|
4327
|
-
if (E instanceof
|
|
4328
|
-
return
|
|
4329
|
-
if (E instanceof
|
|
4330
|
-
return
|
|
4280
|
+
return vt(this.compiler, s, E);
|
|
4281
|
+
if (E instanceof ce)
|
|
4282
|
+
return Is(this.compiler, s);
|
|
4283
|
+
if (E instanceof Le)
|
|
4284
|
+
return bs(this.compiler, s);
|
|
4331
4285
|
if (E instanceof w)
|
|
4332
|
-
return
|
|
4286
|
+
return yt(this.compiler, s, E);
|
|
4333
4287
|
if (E instanceof y && (E.bodyColon && s >= E.bodyColon.end || E.body && Se(s, E.body)))
|
|
4334
|
-
return
|
|
4288
|
+
return yt(this.compiler, s, void 0);
|
|
4335
4289
|
}
|
|
4336
4290
|
return G();
|
|
4337
4291
|
}
|
|
4338
4292
|
}
|
|
4339
|
-
function
|
|
4293
|
+
function bs(t, e) {
|
|
4340
4294
|
const n = t.container.element(e);
|
|
4341
4295
|
return Re(t, e, n, [m.TablePartial]);
|
|
4342
4296
|
}
|
|
4343
|
-
function
|
|
4297
|
+
function gt(t, e, n) {
|
|
4344
4298
|
const s = t.container.scopeKind(e);
|
|
4345
4299
|
if ([
|
|
4346
4300
|
O.REF,
|
|
@@ -4370,8 +4324,8 @@ function Re(t, e, n, s) {
|
|
|
4370
4324
|
label: p,
|
|
4371
4325
|
insertText: p,
|
|
4372
4326
|
insertTextRules: R.KeepWhitespace,
|
|
4373
|
-
kind:
|
|
4374
|
-
sortText:
|
|
4327
|
+
kind: xe(f),
|
|
4328
|
+
sortText: xe(f).toString().padStart(2, "0"),
|
|
4375
4329
|
range: void 0
|
|
4376
4330
|
}))
|
|
4377
4331
|
);
|
|
@@ -4380,38 +4334,38 @@ function Re(t, e, n, s) {
|
|
|
4380
4334
|
}
|
|
4381
4335
|
return Ke(a);
|
|
4382
4336
|
}
|
|
4383
|
-
function
|
|
4337
|
+
function Is(t, e) {
|
|
4384
4338
|
var s;
|
|
4385
4339
|
switch (t.container.scopeKind(e)) {
|
|
4386
4340
|
case O.INDEXES:
|
|
4387
|
-
return
|
|
4341
|
+
return sn(t, e);
|
|
4388
4342
|
case O.REF:
|
|
4389
4343
|
{
|
|
4390
4344
|
const i = [...t.container.stack(e)];
|
|
4391
4345
|
for (; i.length > 0; ) {
|
|
4392
4346
|
const a = i.pop();
|
|
4393
|
-
if (a instanceof
|
|
4394
|
-
return
|
|
4347
|
+
if (a instanceof le && ((s = a.op) == null ? void 0 : s.value) === ".")
|
|
4348
|
+
return tn(
|
|
4395
4349
|
t,
|
|
4396
4350
|
e,
|
|
4397
4351
|
a
|
|
4398
4352
|
);
|
|
4399
4353
|
}
|
|
4400
4354
|
}
|
|
4401
|
-
return
|
|
4355
|
+
return nn(t, e);
|
|
4402
4356
|
}
|
|
4403
4357
|
return G();
|
|
4404
4358
|
}
|
|
4405
|
-
function
|
|
4359
|
+
function vt(t, e, n) {
|
|
4406
4360
|
const { token: s } = t.container.token(e);
|
|
4407
4361
|
if ([h.COMMA, h.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
4408
|
-
const i =
|
|
4362
|
+
const i = wt(t, e);
|
|
4409
4363
|
return (s == null ? void 0 : s.kind) === h.COMMA && je(s, e) ? We(i) : i;
|
|
4410
4364
|
}
|
|
4411
4365
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
4412
|
-
return
|
|
4413
|
-
if (n.name instanceof
|
|
4414
|
-
const i =
|
|
4366
|
+
return wt(t, e);
|
|
4367
|
+
if (n.name instanceof te) {
|
|
4368
|
+
const i = Ls(
|
|
4415
4369
|
t,
|
|
4416
4370
|
e,
|
|
4417
4371
|
we(n.name).unwrap_or("")
|
|
@@ -4420,7 +4374,7 @@ function wt(t, e, n) {
|
|
|
4420
4374
|
}
|
|
4421
4375
|
return G();
|
|
4422
4376
|
}
|
|
4423
|
-
function
|
|
4377
|
+
function wt(t, e) {
|
|
4424
4378
|
const n = t.container.element(e);
|
|
4425
4379
|
if (n instanceof Z)
|
|
4426
4380
|
return G();
|
|
@@ -4430,10 +4384,10 @@ function yt(t, e) {
|
|
|
4430
4384
|
switch (s) {
|
|
4431
4385
|
case O.TABLE:
|
|
4432
4386
|
case O.TABLEPARTIAL:
|
|
4433
|
-
i = [
|
|
4387
|
+
i = [N.HeaderColor, N.Note];
|
|
4434
4388
|
break;
|
|
4435
4389
|
case O.TABLEGROUP:
|
|
4436
|
-
i = [
|
|
4390
|
+
i = [N.Color, N.Note];
|
|
4437
4391
|
break;
|
|
4438
4392
|
default:
|
|
4439
4393
|
i = [];
|
|
@@ -4454,12 +4408,12 @@ function yt(t, e) {
|
|
|
4454
4408
|
return {
|
|
4455
4409
|
suggestions: [
|
|
4456
4410
|
...[
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4411
|
+
N.PK,
|
|
4412
|
+
N.PKey,
|
|
4413
|
+
N.Null,
|
|
4414
|
+
N.NotNull,
|
|
4415
|
+
N.Increment,
|
|
4416
|
+
N.Unique
|
|
4463
4417
|
].map((i) => ({
|
|
4464
4418
|
label: i,
|
|
4465
4419
|
insertText: i,
|
|
@@ -4467,7 +4421,7 @@ function yt(t, e) {
|
|
|
4467
4421
|
insertTextRules: R.KeepWhitespace,
|
|
4468
4422
|
range: void 0
|
|
4469
4423
|
})),
|
|
4470
|
-
...[
|
|
4424
|
+
...[N.Ref, N.Default, N.Note].map((i) => ({
|
|
4471
4425
|
label: i,
|
|
4472
4426
|
insertText: `${i}: `,
|
|
4473
4427
|
kind: k.Property,
|
|
@@ -4479,7 +4433,7 @@ function yt(t, e) {
|
|
|
4479
4433
|
case O.ENUM:
|
|
4480
4434
|
return {
|
|
4481
4435
|
suggestions: [
|
|
4482
|
-
...[
|
|
4436
|
+
...[N.Note].map((i) => ({
|
|
4483
4437
|
label: i,
|
|
4484
4438
|
insertText: `${i}: `,
|
|
4485
4439
|
kind: k.Property,
|
|
@@ -4491,14 +4445,14 @@ function yt(t, e) {
|
|
|
4491
4445
|
case O.INDEXES:
|
|
4492
4446
|
return {
|
|
4493
4447
|
suggestions: [
|
|
4494
|
-
...[
|
|
4448
|
+
...[N.Unique, N.PK].map((i) => ({
|
|
4495
4449
|
label: i,
|
|
4496
4450
|
insertText: i,
|
|
4497
4451
|
insertTextRules: R.KeepWhitespace,
|
|
4498
4452
|
kind: k.Property,
|
|
4499
4453
|
range: void 0
|
|
4500
4454
|
})),
|
|
4501
|
-
...[
|
|
4455
|
+
...[N.Note, N.Name, N.Type].map((i) => ({
|
|
4502
4456
|
label: i,
|
|
4503
4457
|
insertText: `${i}: `,
|
|
4504
4458
|
kind: k.Property,
|
|
@@ -4509,7 +4463,7 @@ function yt(t, e) {
|
|
|
4509
4463
|
};
|
|
4510
4464
|
case O.REF:
|
|
4511
4465
|
return {
|
|
4512
|
-
suggestions: [
|
|
4466
|
+
suggestions: [N.Update, N.Delete].map((i) => ({
|
|
4513
4467
|
label: i,
|
|
4514
4468
|
insertText: `${i}: `,
|
|
4515
4469
|
kind: k.Property,
|
|
@@ -4520,7 +4474,7 @@ function yt(t, e) {
|
|
|
4520
4474
|
}
|
|
4521
4475
|
return G();
|
|
4522
4476
|
}
|
|
4523
|
-
function
|
|
4477
|
+
function Ls(t, e, n) {
|
|
4524
4478
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
4525
4479
|
case "update":
|
|
4526
4480
|
case "delete":
|
|
@@ -4546,43 +4500,43 @@ function _s(t, e, n) {
|
|
|
4546
4500
|
}
|
|
4547
4501
|
return G();
|
|
4548
4502
|
}
|
|
4549
|
-
function
|
|
4550
|
-
const s =
|
|
4551
|
-
if (s.pop(), s.some((a) => !
|
|
4503
|
+
function tn(t, e, n) {
|
|
4504
|
+
const s = _e(n).unwrap_or([]);
|
|
4505
|
+
if (s.pop(), s.some((a) => !j(a)))
|
|
4552
4506
|
return G();
|
|
4553
|
-
const i = s.map((a) =>
|
|
4507
|
+
const i = s.map((a) => q(a).unwrap());
|
|
4554
4508
|
return Ke({
|
|
4555
4509
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: a }) => t.symbol.members(a)).map(({ kind: a, name: r }) => ({
|
|
4556
4510
|
label: r,
|
|
4557
4511
|
insertText: r,
|
|
4558
|
-
kind:
|
|
4512
|
+
kind: xe(a),
|
|
4559
4513
|
range: void 0
|
|
4560
4514
|
}))
|
|
4561
4515
|
});
|
|
4562
4516
|
}
|
|
4563
|
-
function
|
|
4517
|
+
function yt(t, e, n) {
|
|
4564
4518
|
var i;
|
|
4565
4519
|
switch (t.container.scopeKind(e)) {
|
|
4566
4520
|
case O.TABLE:
|
|
4567
4521
|
case O.TABLEPARTIAL:
|
|
4568
|
-
return
|
|
4522
|
+
return _s(t, e, n);
|
|
4569
4523
|
case O.PROJECT:
|
|
4570
|
-
return
|
|
4524
|
+
return gs(t, e, n);
|
|
4571
4525
|
case O.INDEXES:
|
|
4572
|
-
return
|
|
4526
|
+
return ws(t, e);
|
|
4573
4527
|
case O.ENUM:
|
|
4574
|
-
return
|
|
4528
|
+
return As(t, e, n);
|
|
4575
4529
|
case O.REF: {
|
|
4576
|
-
const a =
|
|
4530
|
+
const a = nn(t, e);
|
|
4577
4531
|
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === h.COLON && je(t.container.token(e).token, e) ? We(a) : a;
|
|
4578
4532
|
}
|
|
4579
4533
|
case O.TABLEGROUP:
|
|
4580
|
-
return
|
|
4534
|
+
return vs(t);
|
|
4581
4535
|
default:
|
|
4582
4536
|
return G();
|
|
4583
4537
|
}
|
|
4584
4538
|
}
|
|
4585
|
-
function
|
|
4539
|
+
function kt() {
|
|
4586
4540
|
return {
|
|
4587
4541
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref", "TablePartial"].map((t) => ({
|
|
4588
4542
|
label: t,
|
|
@@ -4593,14 +4547,14 @@ function Pt() {
|
|
|
4593
4547
|
}))
|
|
4594
4548
|
};
|
|
4595
4549
|
}
|
|
4596
|
-
function
|
|
4597
|
-
return n != null && n.callee &&
|
|
4550
|
+
function As(t, e, n) {
|
|
4551
|
+
return n != null && n.callee && ht(e, n) === 1 ? Re(t, e, t.container.element(e), [
|
|
4598
4552
|
m.Schema,
|
|
4599
4553
|
m.Table,
|
|
4600
4554
|
m.Column
|
|
4601
4555
|
]) : G();
|
|
4602
4556
|
}
|
|
4603
|
-
function
|
|
4557
|
+
function _s(t, e, n) {
|
|
4604
4558
|
const s = ["Note", "indexes"];
|
|
4605
4559
|
if (!(n != null && n.callee))
|
|
4606
4560
|
return {
|
|
@@ -4612,7 +4566,7 @@ function vs(t, e, n) {
|
|
|
4612
4566
|
range: void 0
|
|
4613
4567
|
}))
|
|
4614
4568
|
};
|
|
4615
|
-
const i =
|
|
4569
|
+
const i = ht(e, n);
|
|
4616
4570
|
return i === 0 ? {
|
|
4617
4571
|
suggestions: s.map((a) => ({
|
|
4618
4572
|
label: a,
|
|
@@ -4621,11 +4575,11 @@ function vs(t, e, n) {
|
|
|
4621
4575
|
kind: k.Keyword,
|
|
4622
4576
|
range: void 0
|
|
4623
4577
|
}))
|
|
4624
|
-
} : i === 1 ?
|
|
4578
|
+
} : i === 1 ? ys(t, e) : G();
|
|
4625
4579
|
}
|
|
4626
|
-
function
|
|
4580
|
+
function gs(t, e, n) {
|
|
4627
4581
|
const s = ["Table", "TableGroup", "Enum", "Note", "Ref", "TablePartial"];
|
|
4628
|
-
return n != null && n.callee ?
|
|
4582
|
+
return n != null && n.callee ? ht(e, n) === 0 ? {
|
|
4629
4583
|
suggestions: s.map((a) => ({
|
|
4630
4584
|
label: a,
|
|
4631
4585
|
insertText: a,
|
|
@@ -4643,19 +4597,19 @@ function ws(t, e, n) {
|
|
|
4643
4597
|
}))
|
|
4644
4598
|
};
|
|
4645
4599
|
}
|
|
4646
|
-
function
|
|
4600
|
+
function nn(t, e) {
|
|
4647
4601
|
return Re(t, e, t.container.element(e), [
|
|
4648
4602
|
m.Schema,
|
|
4649
4603
|
m.Table,
|
|
4650
4604
|
m.Column
|
|
4651
4605
|
]);
|
|
4652
4606
|
}
|
|
4653
|
-
function
|
|
4607
|
+
function vs(t) {
|
|
4654
4608
|
return {
|
|
4655
4609
|
suggestions: [
|
|
4656
4610
|
...Ke({
|
|
4657
4611
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
4658
|
-
const n =
|
|
4612
|
+
const n = re(e).unwrap_or(void 0);
|
|
4659
4613
|
if (n === void 0)
|
|
4660
4614
|
return [];
|
|
4661
4615
|
const { kind: s, name: i } = n;
|
|
@@ -4663,7 +4617,7 @@ function ys(t) {
|
|
|
4663
4617
|
label: i,
|
|
4664
4618
|
insertText: i,
|
|
4665
4619
|
insertTextRules: R.KeepWhitespace,
|
|
4666
|
-
kind:
|
|
4620
|
+
kind: xe(s),
|
|
4667
4621
|
range: void 0
|
|
4668
4622
|
};
|
|
4669
4623
|
})
|
|
@@ -4678,10 +4632,10 @@ function ys(t) {
|
|
|
4678
4632
|
]
|
|
4679
4633
|
};
|
|
4680
4634
|
}
|
|
4681
|
-
function
|
|
4682
|
-
return
|
|
4635
|
+
function ws(t, e) {
|
|
4636
|
+
return sn(t, e);
|
|
4683
4637
|
}
|
|
4684
|
-
function
|
|
4638
|
+
function ys(t, e) {
|
|
4685
4639
|
return {
|
|
4686
4640
|
suggestions: [
|
|
4687
4641
|
...[
|
|
@@ -4756,14 +4710,14 @@ function Ps(t, e) {
|
|
|
4756
4710
|
]
|
|
4757
4711
|
};
|
|
4758
4712
|
}
|
|
4759
|
-
function
|
|
4713
|
+
function sn(t, e) {
|
|
4760
4714
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
4761
|
-
if (!((s == null ? void 0 : s.symbol) instanceof
|
|
4715
|
+
if (!((s == null ? void 0 : s.symbol) instanceof Mt))
|
|
4762
4716
|
return G();
|
|
4763
4717
|
const { symbolTable: i } = s.symbol;
|
|
4764
4718
|
return Ke({
|
|
4765
4719
|
suggestions: [...i.entries()].flatMap(([a]) => {
|
|
4766
|
-
const r =
|
|
4720
|
+
const r = re(a).unwrap_or(void 0);
|
|
4767
4721
|
if (r === void 0)
|
|
4768
4722
|
return [];
|
|
4769
4723
|
const { name: c } = r;
|
|
@@ -4771,34 +4725,34 @@ function tn(t, e) {
|
|
|
4771
4725
|
label: c,
|
|
4772
4726
|
insertText: c,
|
|
4773
4727
|
insertTextRules: R.KeepWhitespace,
|
|
4774
|
-
kind:
|
|
4728
|
+
kind: xe(m.Column),
|
|
4775
4729
|
range: void 0
|
|
4776
4730
|
};
|
|
4777
4731
|
})
|
|
4778
4732
|
});
|
|
4779
4733
|
}
|
|
4780
|
-
function
|
|
4734
|
+
function ht(t, e) {
|
|
4781
4735
|
if (!e.callee)
|
|
4782
4736
|
return -1;
|
|
4783
4737
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
4784
4738
|
return s === -1 ? n.length : s;
|
|
4785
4739
|
}
|
|
4786
|
-
class
|
|
4740
|
+
class an {
|
|
4787
4741
|
constructor(e) {
|
|
4788
4742
|
this.compiler = e;
|
|
4789
4743
|
}
|
|
4790
4744
|
provideDefinition(e, n) {
|
|
4791
4745
|
var r, c;
|
|
4792
|
-
const { uri: s } = e, i =
|
|
4746
|
+
const { uri: s } = e, i = ut(e, n), a = [...this.compiler.container.stack(i)];
|
|
4793
4747
|
for (; a.length !== 0; ) {
|
|
4794
4748
|
const p = a.pop();
|
|
4795
4749
|
if (!(p != null && p.referee))
|
|
4796
4750
|
continue;
|
|
4797
4751
|
let f;
|
|
4798
4752
|
if ((r = p.referee) != null && r.declaration && [
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4753
|
+
Ie.PRIMARY_EXPRESSION,
|
|
4754
|
+
Ie.VARIABLE,
|
|
4755
|
+
Ie.PARTIAL_INJECTION
|
|
4802
4756
|
].includes(p == null ? void 0 : p.kind) ? { declaration: f } = p.referee : (c = p.referee) != null && c.injectorDeclaration && (f = p.referee.injectorDeclaration), f) {
|
|
4803
4757
|
const { startPos: d, endPos: u } = f;
|
|
4804
4758
|
return [
|
|
@@ -4817,18 +4771,18 @@ class nn {
|
|
|
4817
4771
|
return [];
|
|
4818
4772
|
}
|
|
4819
4773
|
}
|
|
4820
|
-
class
|
|
4774
|
+
class rn {
|
|
4821
4775
|
constructor(e) {
|
|
4822
4776
|
this.compiler = e;
|
|
4823
4777
|
}
|
|
4824
4778
|
provideReferences(e, n) {
|
|
4825
|
-
const { uri: s } = e, i =
|
|
4779
|
+
const { uri: s } = e, i = ut(e, n), a = [...this.compiler.container.stack(i)];
|
|
4826
4780
|
for (; a.length !== 0; ) {
|
|
4827
4781
|
const r = a.pop();
|
|
4828
4782
|
if (r && [
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4783
|
+
Ie.ELEMENT_DECLARATION,
|
|
4784
|
+
Ie.FUNCTION_APPLICATION,
|
|
4785
|
+
Ie.PRIMARY_EXPRESSION
|
|
4832
4786
|
].includes(r == null ? void 0 : r.kind)) {
|
|
4833
4787
|
const { symbol: c } = r;
|
|
4834
4788
|
if (c != null && c.references.length)
|
|
@@ -4846,24 +4800,24 @@ class sn {
|
|
|
4846
4800
|
return [];
|
|
4847
4801
|
}
|
|
4848
4802
|
}
|
|
4849
|
-
const
|
|
4803
|
+
const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4850
4804
|
__proto__: null,
|
|
4851
4805
|
CompletionItemInsertTextRule: R,
|
|
4852
4806
|
CompletionItemKind: k,
|
|
4853
|
-
DBMLCompletionItemProvider:
|
|
4854
|
-
DBMLDefinitionProvider:
|
|
4855
|
-
DBMLReferencesProvider:
|
|
4807
|
+
DBMLCompletionItemProvider: en,
|
|
4808
|
+
DBMLDefinitionProvider: an,
|
|
4809
|
+
DBMLReferencesProvider: rn
|
|
4856
4810
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4857
4811
|
var O = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t[t.TABLEPARTIAL = 9] = "TABLEPARTIAL", t))(O || {});
|
|
4858
|
-
class
|
|
4812
|
+
class Ds {
|
|
4859
4813
|
constructor() {
|
|
4860
4814
|
this.source = "", this.cache = new Array(
|
|
4861
4815
|
16
|
|
4862
4816
|
/* TOTAL_QUERY_COUNT */
|
|
4863
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4817
|
+
).fill(null), this.nodeIdGenerator = new hn(), this.symbolIdGenerator = new Nn(), this.token = {
|
|
4864
4818
|
invalidStream: this.createQuery(
|
|
4865
4819
|
6,
|
|
4866
|
-
() => this.parse.tokens().filter(
|
|
4820
|
+
() => this.parse.tokens().filter(Ft)
|
|
4867
4821
|
),
|
|
4868
4822
|
// Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
|
|
4869
4823
|
flatStream: this.createQuery(
|
|
@@ -4875,8 +4829,8 @@ class Os {
|
|
|
4875
4829
|
_: this.createQuery(
|
|
4876
4830
|
0,
|
|
4877
4831
|
() => {
|
|
4878
|
-
const e = new
|
|
4879
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new
|
|
4832
|
+
const e = new Dn(this.source).lex().chain((n) => new Rn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new ds(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4833
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new ms(n).interpret().map((a) => ({ ast: n, tokens: s, rawDb: a })));
|
|
4880
4834
|
}
|
|
4881
4835
|
),
|
|
4882
4836
|
ast: this.createQuery(
|
|
@@ -4900,15 +4854,15 @@ class Os {
|
|
|
4900
4854
|
stack: this.createQuery(
|
|
4901
4855
|
10,
|
|
4902
4856
|
(e) => {
|
|
4903
|
-
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), a = s === void 0 ? -1 :
|
|
4857
|
+
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), a = s === void 0 ? -1 : ln(n, (f) => !f.isInvalid, s);
|
|
4904
4858
|
if (a === -1)
|
|
4905
4859
|
return [this.parse.ast()];
|
|
4906
4860
|
const r = n[a].start;
|
|
4907
4861
|
let c = this.parse.ast();
|
|
4908
4862
|
const p = [c];
|
|
4909
4863
|
for (; ; ) {
|
|
4910
|
-
const d =
|
|
4911
|
-
if (d === void 0 || d instanceof
|
|
4864
|
+
const d = Sn(c).find((u) => Se(r, u));
|
|
4865
|
+
if (d === void 0 || d instanceof J)
|
|
4912
4866
|
break;
|
|
4913
4867
|
p.push(d), c = d;
|
|
4914
4868
|
}
|
|
@@ -4923,7 +4877,7 @@ class Os {
|
|
|
4923
4877
|
u[E] === `
|
|
4924
4878
|
` && (p.pop(), f = !0);
|
|
4925
4879
|
} else
|
|
4926
|
-
d instanceof
|
|
4880
|
+
d instanceof oe || d instanceof le ? this.container.token(e).token !== d.op && (p.pop(), f = !0) : d instanceof M ? d.listCloseBracket && d.end <= e && (p.pop(), f = !0) : d instanceof ce ? d.tupleCloseParen && d.end <= e && (p.pop(), f = !0) : d instanceof ae ? d.blockCloseBrace && d.end <= e && (p.pop(), f = !0) : d instanceof te || d.end < e && (p.pop(), f = !0);
|
|
4927
4881
|
if (f) {
|
|
4928
4882
|
const u = Ve(p);
|
|
4929
4883
|
u instanceof y && u.end <= e && p.pop();
|
|
@@ -5008,8 +4962,8 @@ class Os {
|
|
|
5008
4962
|
let c = [r], p = [];
|
|
5009
4963
|
for (const f of e)
|
|
5010
4964
|
p = c.flatMap(
|
|
5011
|
-
(d) =>
|
|
5012
|
-
const E = d.get(u), L =
|
|
4965
|
+
(d) => gn(f).flatMap((u) => {
|
|
4966
|
+
const E = d.get(u), L = re(u).unwrap_or(void 0);
|
|
5013
4967
|
return !E || !L ? [] : { ...L, symbol: E };
|
|
5014
4968
|
})
|
|
5015
4969
|
), c = p.flatMap(
|
|
@@ -5024,7 +4978,7 @@ class Os {
|
|
|
5024
4978
|
members: this.createQuery(
|
|
5025
4979
|
9,
|
|
5026
4980
|
(e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
|
|
5027
|
-
...
|
|
4981
|
+
...re(n).unwrap(),
|
|
5028
4982
|
symbol: s
|
|
5029
4983
|
})) : []
|
|
5030
4984
|
)
|
|
@@ -5051,14 +5005,14 @@ class Os {
|
|
|
5051
5005
|
}
|
|
5052
5006
|
initMonacoServices() {
|
|
5053
5007
|
return {
|
|
5054
|
-
definitionProvider: new
|
|
5055
|
-
referenceProvider: new
|
|
5056
|
-
autocompletionProvider: new
|
|
5008
|
+
definitionProvider: new an(this),
|
|
5009
|
+
referenceProvider: new rn(this),
|
|
5010
|
+
autocompletionProvider: new en(this)
|
|
5057
5011
|
};
|
|
5058
5012
|
}
|
|
5059
5013
|
}
|
|
5060
5014
|
export {
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5015
|
+
Ds as Compiler,
|
|
5016
|
+
Ps as serialize,
|
|
5017
|
+
Ss as services
|
|
5064
5018
|
};
|