@dbml/parse 3.9.6 → 3.10.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/LICENSE +0 -0
- package/dist/compiler.d.ts +0 -0
- package/dist/constants.d.ts +0 -0
- package/dist/dbml-parse.js +8 -8
- package/dist/dbml-parse.mjs +494 -481
- package/dist/index.d.ts +0 -0
- package/dist/lib/analyzer/analyzer.d.ts +0 -0
- package/dist/lib/analyzer/binder/binder.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/custom.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/elementBinder.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/enum.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/indexes.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/note.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/project.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/ref.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/table.d.ts +0 -0
- package/dist/lib/analyzer/binder/elementBinder/tableGroup.d.ts +0 -0
- package/dist/lib/analyzer/binder/types.d.ts +0 -0
- package/dist/lib/analyzer/binder/utils.d.ts +0 -0
- package/dist/lib/analyzer/symbol/factory.d.ts +0 -0
- package/dist/lib/analyzer/symbol/symbolIndex.d.ts +0 -0
- package/dist/lib/analyzer/symbol/symbolTable.d.ts +0 -0
- package/dist/lib/analyzer/symbol/symbols.d.ts +0 -0
- package/dist/lib/analyzer/symbol/utils.d.ts +0 -0
- package/dist/lib/analyzer/types.d.ts +0 -0
- package/dist/lib/analyzer/utils.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/custom.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/enum.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/indexes.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/note.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/project.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/ref.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/table.d.ts +0 -0
- package/dist/lib/analyzer/validator/elementValidators/tableGroup.d.ts +0 -0
- package/dist/lib/analyzer/validator/types.d.ts +0 -0
- package/dist/lib/analyzer/validator/utils.d.ts +0 -0
- package/dist/lib/analyzer/validator/validator.d.ts +0 -0
- package/dist/lib/errors.d.ts +0 -0
- package/dist/lib/interpreter/elementInterpreter/enum.d.ts +0 -0
- package/dist/lib/interpreter/elementInterpreter/project.d.ts +0 -0
- package/dist/lib/interpreter/elementInterpreter/ref.d.ts +0 -0
- package/dist/lib/interpreter/elementInterpreter/sticky_note.d.ts +0 -0
- package/dist/lib/interpreter/elementInterpreter/table.d.ts +0 -0
- package/dist/lib/interpreter/elementInterpreter/tableGroup.d.ts +0 -0
- package/dist/lib/interpreter/interpreter.d.ts +0 -0
- package/dist/lib/interpreter/types.d.ts +1 -0
- package/dist/lib/interpreter/utils.d.ts +0 -0
- package/dist/lib/lexer/lexer.d.ts +0 -0
- package/dist/lib/lexer/tokens.d.ts +0 -0
- package/dist/lib/lexer/utils.d.ts +0 -0
- package/dist/lib/option.d.ts +0 -0
- package/dist/lib/parser/contextStack.d.ts +0 -0
- package/dist/lib/parser/factory.d.ts +0 -0
- package/dist/lib/parser/nodes.d.ts +0 -0
- package/dist/lib/parser/parser.d.ts +0 -0
- package/dist/lib/parser/utils.d.ts +0 -0
- package/dist/lib/report.d.ts +0 -0
- package/dist/lib/serialization/serialize.d.ts +0 -0
- package/dist/lib/types.d.ts +0 -0
- package/dist/lib/utils.d.ts +0 -0
- package/dist/services/definition/provider.d.ts +0 -0
- package/dist/services/index.d.ts +0 -0
- package/dist/services/references/provider.d.ts +0 -0
- package/dist/services/suggestions/provider.d.ts +0 -0
- package/dist/services/suggestions/utils.d.ts +0 -0
- package/dist/services/types.d.ts +0 -0
- package/dist/services/utils.d.ts +0 -0
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import I, { last as
|
|
1
|
+
import I, { last as $e, partition as zt, findLastIndex as Qt } from "lodash";
|
|
2
2
|
var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
3
|
function qt(t) {
|
|
4
4
|
switch (t.kind) {
|
|
@@ -12,7 +12,7 @@ function qt(t) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function lt(t) {
|
|
16
16
|
if (!t)
|
|
17
17
|
return !1;
|
|
18
18
|
switch (t) {
|
|
@@ -33,31 +33,31 @@ function at(t) {
|
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function ct(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class G {
|
|
40
40
|
constructor(e, n, s, i, r) {
|
|
41
41
|
this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
|
|
42
42
|
}
|
|
43
43
|
static create(e, n, s, i, r) {
|
|
44
|
-
return new
|
|
44
|
+
return new G(e, n, s, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function gt(t) {
|
|
48
48
|
return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 ||
|
|
50
|
+
function ut(t, e) {
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || gt(t);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function We(t) {
|
|
54
54
|
return t.trailingTrivia.find(({ kind: e }) => [u.SPACE, u.TAB].includes(e)) !== void 0;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return t.trailingTrivia.length === 0 ? t.end :
|
|
56
|
+
function _t(t) {
|
|
57
|
+
return t.trailingTrivia.length === 0 ? t.end : _t($e(t.trailingTrivia));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return t.leadingTrivia.length === 0 ? t.start :
|
|
59
|
+
function At(t) {
|
|
60
|
+
return t.leadingTrivia.length === 0 ? t.start : At(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
62
|
function Ht(t) {
|
|
63
63
|
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
@@ -81,13 +81,13 @@ class k {
|
|
|
81
81
|
constructor(e, n, s) {
|
|
82
82
|
this.id = e, this.kind = n;
|
|
83
83
|
const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof G ? At(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof G ? _t(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
@@ -95,7 +95,7 @@ class k {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
var Ne = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(Ne || {});
|
|
98
|
-
class
|
|
98
|
+
class j extends k {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
@@ -123,7 +123,7 @@ class A extends k {
|
|
|
123
123
|
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = l;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class
|
|
126
|
+
class q extends k {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
@@ -137,12 +137,12 @@ class ie extends k {
|
|
|
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 H extends k {
|
|
141
141
|
constructor({ op: e, expression: n }, s) {
|
|
142
142
|
super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class
|
|
145
|
+
class J extends k {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,7 +151,7 @@ class H extends k {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class Me extends k {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
@@ -166,7 +166,7 @@ class v extends k {
|
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class
|
|
169
|
+
class K extends k {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -175,7 +175,7 @@ class Z extends k {
|
|
|
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 R extends k {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: n = [],
|
|
@@ -184,12 +184,12 @@ class P extends k {
|
|
|
184
184
|
}, r) {
|
|
185
185
|
super(r, "<list-expression>", [
|
|
186
186
|
e,
|
|
187
|
-
...
|
|
187
|
+
...vt(n, s),
|
|
188
188
|
i
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class
|
|
192
|
+
class ee extends k {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -198,12 +198,12 @@ class K extends k {
|
|
|
198
198
|
}, r) {
|
|
199
199
|
super(r, "<tuple-expression>", [
|
|
200
200
|
e,
|
|
201
|
-
...
|
|
201
|
+
...vt(n, s),
|
|
202
202
|
i
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class
|
|
206
|
+
class ze extends ee {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -220,7 +220,7 @@ class je extends K {
|
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class
|
|
223
|
+
class Z extends k {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: n
|
|
@@ -233,7 +233,7 @@ class be extends k {
|
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class te extends k {
|
|
237
237
|
constructor({ variable: e }, n) {
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
@@ -243,9 +243,9 @@ class M extends k {
|
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class Se extends k {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
|
-
const s =
|
|
248
|
+
const s = G.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -254,7 +254,7 @@ class he extends k {
|
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function vt(t, e) {
|
|
258
258
|
if (!t || t.length === 0)
|
|
259
259
|
return e || [];
|
|
260
260
|
if (!e || e.length === 0)
|
|
@@ -269,7 +269,7 @@ function hs(t, e = !1) {
|
|
|
269
269
|
t,
|
|
270
270
|
function(n, s) {
|
|
271
271
|
var i;
|
|
272
|
-
return !(this instanceof
|
|
272
|
+
return !(this instanceof j) && n === "symbol" ? s == null ? void 0 : s.id : (
|
|
273
273
|
/* this instanceof SyntaxNode && */
|
|
274
274
|
n === "symbol" ? {
|
|
275
275
|
symbolTable: s == null ? void 0 : s.symbolTable,
|
|
@@ -335,46 +335,46 @@ class y {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
var T = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t))(T || {});
|
|
338
|
-
function
|
|
338
|
+
function Qe(t) {
|
|
339
339
|
return `Schema:${t}`;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function De(t) {
|
|
342
342
|
return `Table:${t}`;
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function qe(t) {
|
|
345
345
|
return `Column:${t}`;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function He(t) {
|
|
348
348
|
return `Enum:${t}`;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function Je(t) {
|
|
351
351
|
return `Enum field:${t}`;
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function Ze(t) {
|
|
354
354
|
return `TableGroup:${t}`;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function Ke(t) {
|
|
357
357
|
return `TableGroup field:${t}`;
|
|
358
358
|
}
|
|
359
359
|
function Zt(t) {
|
|
360
360
|
return `Note:${t}`;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function Ce(t, e) {
|
|
363
363
|
switch (e) {
|
|
364
364
|
case "Column":
|
|
365
|
-
return
|
|
365
|
+
return qe(t);
|
|
366
366
|
case "Enum":
|
|
367
|
-
return
|
|
367
|
+
return He(t);
|
|
368
368
|
case "Enum field":
|
|
369
|
-
return
|
|
369
|
+
return Je(t);
|
|
370
370
|
case "Schema":
|
|
371
|
-
return
|
|
371
|
+
return Qe(t);
|
|
372
372
|
case "Table":
|
|
373
|
-
return
|
|
373
|
+
return De(t);
|
|
374
374
|
case "TableGroup":
|
|
375
|
-
return
|
|
375
|
+
return Ze(t);
|
|
376
376
|
case "TableGroup field":
|
|
377
|
-
return
|
|
377
|
+
return Ke(t);
|
|
378
378
|
default:
|
|
379
379
|
throw new Error("Unreachable");
|
|
380
380
|
}
|
|
@@ -395,36 +395,36 @@ function Kt(t) {
|
|
|
395
395
|
}
|
|
396
396
|
function en(t) {
|
|
397
397
|
return [
|
|
398
|
-
Ye,
|
|
399
|
-
Oe,
|
|
400
398
|
Qe,
|
|
399
|
+
De,
|
|
401
400
|
He,
|
|
402
|
-
|
|
401
|
+
Ze,
|
|
403
402
|
qe,
|
|
404
|
-
Je
|
|
403
|
+
Je,
|
|
404
|
+
Ke
|
|
405
405
|
].map((e) => e(t));
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function Fe(t) {
|
|
408
408
|
return !!t.match(/(\p{L}|_|\p{M})/gu);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function Re(t) {
|
|
411
411
|
const [e] = t;
|
|
412
412
|
return e >= "0" && e <= "9";
|
|
413
413
|
}
|
|
414
414
|
function tn(t) {
|
|
415
415
|
const [e] = t;
|
|
416
|
-
return
|
|
416
|
+
return Re(e) || Fe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
417
417
|
}
|
|
418
418
|
function Ee(t) {
|
|
419
|
-
return
|
|
419
|
+
return Fe(t) || Re(t);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function ht(t, e) {
|
|
422
422
|
const n = [], s = Math.min(t.length, e.length);
|
|
423
423
|
for (let i = 0; i < s; i += 1)
|
|
424
424
|
n.push(t[i], e[i]);
|
|
425
425
|
return n.push(...t.slice(s), ...e.slice(s)), n;
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function _e(t, e) {
|
|
428
428
|
return t >= e.start && t < e.end;
|
|
429
429
|
}
|
|
430
430
|
class nn {
|
|
@@ -438,7 +438,7 @@ class nn {
|
|
|
438
438
|
return this.id++;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
class
|
|
441
|
+
class wt {
|
|
442
442
|
constructor({ symbolTable: e }, n) {
|
|
443
443
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
444
444
|
}
|
|
@@ -453,7 +453,7 @@ class rn {
|
|
|
453
453
|
this.references = [], this.id = n, this.declaration = e;
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
|
-
class
|
|
456
|
+
class yt {
|
|
457
457
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
458
458
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
459
459
|
}
|
|
@@ -479,7 +479,7 @@ class c extends Error {
|
|
|
479
479
|
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, c.prototype);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
class
|
|
482
|
+
class X {
|
|
483
483
|
constructor(e, n) {
|
|
484
484
|
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
485
485
|
}
|
|
@@ -491,24 +491,24 @@ class G {
|
|
|
491
491
|
}
|
|
492
492
|
chain(e) {
|
|
493
493
|
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
494
|
-
return new
|
|
494
|
+
return new X(n.value, s);
|
|
495
495
|
}
|
|
496
496
|
map(e) {
|
|
497
|
-
return new
|
|
497
|
+
return new X(e(this.value), this.errors);
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
function cn(t, e, n) {
|
|
501
501
|
if (!t || !me(t) || e.length === 0)
|
|
502
502
|
return new y();
|
|
503
|
-
const s = [...e], i =
|
|
504
|
-
if (!(r instanceof
|
|
503
|
+
const s = [...e], i = Xe(t).unwrap(), r = s.pop();
|
|
504
|
+
if (!(r instanceof K))
|
|
505
505
|
return new y();
|
|
506
|
-
const a = I.last(s) instanceof
|
|
507
|
-
return s.length === 3 &&
|
|
506
|
+
const a = I.last(s) instanceof R ? s.pop() : void 0;
|
|
507
|
+
return s.length === 3 && Xe(s[1]).unwrap().value === "as" ? new x(
|
|
508
508
|
n.create(A, {
|
|
509
509
|
type: i,
|
|
510
510
|
name: s[0],
|
|
511
|
-
as:
|
|
511
|
+
as: Xe(s[1]).unwrap(),
|
|
512
512
|
alias: s[2],
|
|
513
513
|
attributeList: a,
|
|
514
514
|
body: r
|
|
@@ -528,11 +528,11 @@ function cn(t, e, n) {
|
|
|
528
528
|
})
|
|
529
529
|
) : new y();
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function ft(t) {
|
|
532
532
|
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
533
533
|
}
|
|
534
534
|
function N(t) {
|
|
535
|
-
t && (t instanceof
|
|
535
|
+
t && (t instanceof G ? un(t) : hn(t));
|
|
536
536
|
}
|
|
537
537
|
function un(t) {
|
|
538
538
|
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
@@ -540,23 +540,23 @@ function un(t) {
|
|
|
540
540
|
function hn(t) {
|
|
541
541
|
if (t instanceof A)
|
|
542
542
|
N(t.type), N(t.name), N(t.as), N(t.alias), N(t.bodyColon), N(t.attributeList), N(t.body);
|
|
543
|
-
else if (t instanceof
|
|
543
|
+
else if (t instanceof q)
|
|
544
544
|
t.identifiers.forEach(N);
|
|
545
545
|
else if (t instanceof ie)
|
|
546
546
|
N(t.name), N(t.colon), N(t.value);
|
|
547
|
-
else if (t instanceof q)
|
|
548
|
-
N(t.op), N(t.expression);
|
|
549
547
|
else if (t instanceof H)
|
|
548
|
+
N(t.op), N(t.expression);
|
|
549
|
+
else if (t instanceof J)
|
|
550
550
|
N(t.leftExpression), N(t.op), N(t.rightExpression);
|
|
551
|
-
else if (t instanceof
|
|
551
|
+
else if (t instanceof Me)
|
|
552
552
|
N(t.op), N(t.expression);
|
|
553
|
-
else if (t instanceof
|
|
553
|
+
else if (t instanceof K)
|
|
554
554
|
N(t.blockOpenBrace), t.body.forEach(N), N(t.blockCloseBrace);
|
|
555
|
-
else if (t instanceof
|
|
555
|
+
else if (t instanceof R)
|
|
556
556
|
N(t.listOpenBracket), t.commaList.forEach(N), t.elementList.forEach(N), N(t.listCloseBracket);
|
|
557
|
-
else if (t instanceof
|
|
557
|
+
else if (t instanceof ee)
|
|
558
558
|
N(t.tupleOpenParen), t.commaList.forEach(N), t.elementList.forEach(N), N(t.tupleCloseParen);
|
|
559
|
-
else if (t instanceof
|
|
559
|
+
else if (t instanceof Z)
|
|
560
560
|
N(t.callee), N(t.argumentList);
|
|
561
561
|
else if (t instanceof v)
|
|
562
562
|
N(t.callee), t.args.forEach(N);
|
|
@@ -564,21 +564,21 @@ function hn(t) {
|
|
|
564
564
|
N(t.expression);
|
|
565
565
|
else if (t instanceof se)
|
|
566
566
|
N(t.value);
|
|
567
|
-
else if (t instanceof
|
|
567
|
+
else if (t instanceof te)
|
|
568
568
|
N(t.variable);
|
|
569
569
|
else if (t instanceof be)
|
|
570
570
|
N(t.literal);
|
|
571
571
|
else
|
|
572
|
-
throw t instanceof
|
|
572
|
+
throw t instanceof ze ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
573
573
|
}
|
|
574
|
-
function
|
|
574
|
+
function kt(t) {
|
|
575
575
|
return !!(t != null && t.isInvalid);
|
|
576
576
|
}
|
|
577
577
|
function U(...t) {
|
|
578
578
|
return t.filter((e) => e !== void 0);
|
|
579
579
|
}
|
|
580
580
|
function fn(t) {
|
|
581
|
-
if (t instanceof
|
|
581
|
+
if (t instanceof j)
|
|
582
582
|
return U(...t.body, t.eof);
|
|
583
583
|
if (t instanceof A)
|
|
584
584
|
return U(
|
|
@@ -592,37 +592,37 @@ function fn(t) {
|
|
|
592
592
|
);
|
|
593
593
|
if (t instanceof ie)
|
|
594
594
|
return U(t.name, t.colon, t.value);
|
|
595
|
-
if (t instanceof
|
|
595
|
+
if (t instanceof q)
|
|
596
596
|
return t.identifiers;
|
|
597
597
|
if (t instanceof be)
|
|
598
598
|
return t.literal ? [t.literal] : [];
|
|
599
|
-
if (t instanceof
|
|
599
|
+
if (t instanceof te)
|
|
600
600
|
return U(t.variable);
|
|
601
|
-
if (t instanceof q)
|
|
602
|
-
return U(t.op, t.expression);
|
|
603
601
|
if (t instanceof H)
|
|
602
|
+
return U(t.op, t.expression);
|
|
603
|
+
if (t instanceof J)
|
|
604
604
|
return U(t.leftExpression, t.op, t.rightExpression);
|
|
605
|
-
if (t instanceof
|
|
605
|
+
if (t instanceof Me)
|
|
606
606
|
return U(t.expression, t.op);
|
|
607
607
|
if (t instanceof se)
|
|
608
608
|
return U(t.value);
|
|
609
609
|
if (t instanceof v)
|
|
610
610
|
return U(t.callee, ...t.args);
|
|
611
|
-
if (t instanceof
|
|
611
|
+
if (t instanceof K)
|
|
612
612
|
return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
613
|
-
if (t instanceof
|
|
613
|
+
if (t instanceof R)
|
|
614
614
|
return U(
|
|
615
615
|
t.listOpenBracket,
|
|
616
|
-
...
|
|
616
|
+
...ht(t.elementList, t.commaList),
|
|
617
617
|
t.listCloseBracket
|
|
618
618
|
);
|
|
619
|
-
if (t instanceof
|
|
619
|
+
if (t instanceof ee)
|
|
620
620
|
return U(
|
|
621
621
|
t.tupleOpenParen,
|
|
622
|
-
...
|
|
622
|
+
...ht(t.elementList, t.commaList),
|
|
623
623
|
t.tupleCloseParen
|
|
624
624
|
);
|
|
625
|
-
if (t instanceof
|
|
625
|
+
if (t instanceof Z)
|
|
626
626
|
return U(t.callee, t.argumentList);
|
|
627
627
|
if (t instanceof M)
|
|
628
628
|
return U(t.expression);
|
|
@@ -631,25 +631,25 @@ function fn(t) {
|
|
|
631
631
|
t.array,
|
|
632
632
|
t.indexer
|
|
633
633
|
);
|
|
634
|
-
throw t instanceof
|
|
634
|
+
throw t instanceof ze ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
635
635
|
}
|
|
636
|
-
function
|
|
637
|
-
return
|
|
636
|
+
function Xe(t) {
|
|
637
|
+
return V(t) ? new x(t.expression.variable) : new y();
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Y(t) {
|
|
640
640
|
var e;
|
|
641
|
-
return t instanceof M && (t.expression instanceof
|
|
641
|
+
return t instanceof M && (t.expression instanceof te && t.expression.variable instanceof G && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
642
642
|
}
|
|
643
|
-
function
|
|
644
|
-
return t instanceof M && t.expression instanceof
|
|
643
|
+
function V(t) {
|
|
644
|
+
return t instanceof M && t.expression instanceof te && t.expression.variable instanceof G;
|
|
645
645
|
}
|
|
646
646
|
function me(t) {
|
|
647
647
|
var e;
|
|
648
|
-
return t instanceof M && t.expression instanceof
|
|
648
|
+
return t instanceof M && t.expression instanceof te && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
650
|
+
function et(t) {
|
|
651
651
|
var e;
|
|
652
|
-
return t instanceof
|
|
652
|
+
return t instanceof J && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
653
653
|
}
|
|
654
654
|
function Te(t) {
|
|
655
655
|
if (t === void 0)
|
|
@@ -697,7 +697,7 @@ class pn {
|
|
|
697
697
|
this.tokens.push(this.createToken(e, n));
|
|
698
698
|
}
|
|
699
699
|
createToken(e, n = !1) {
|
|
700
|
-
return
|
|
700
|
+
return G.create(
|
|
701
701
|
e,
|
|
702
702
|
this.start,
|
|
703
703
|
this.current,
|
|
@@ -706,7 +706,7 @@ class pn {
|
|
|
706
706
|
);
|
|
707
707
|
}
|
|
708
708
|
lex() {
|
|
709
|
-
return this.scanTokens(), this.tokens.push(
|
|
709
|
+
return this.scanTokens(), this.tokens.push(G.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new X(this.tokens, this.errors);
|
|
710
710
|
}
|
|
711
711
|
scanTokens() {
|
|
712
712
|
for (; !this.isAtEnd(); ) {
|
|
@@ -767,15 +767,15 @@ class pn {
|
|
|
767
767
|
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
|
|
768
768
|
break;
|
|
769
769
|
default:
|
|
770
|
-
if (
|
|
770
|
+
if (lt(e)) {
|
|
771
771
|
this.operator();
|
|
772
772
|
break;
|
|
773
773
|
}
|
|
774
|
-
if (
|
|
774
|
+
if (Fe(e)) {
|
|
775
775
|
this.identifier();
|
|
776
776
|
break;
|
|
777
777
|
}
|
|
778
|
-
if (
|
|
778
|
+
if (Re(e)) {
|
|
779
779
|
this.numericLiteralOrIdentifier();
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
@@ -801,7 +801,7 @@ class pn {
|
|
|
801
801
|
gatherInvalid() {
|
|
802
802
|
let e;
|
|
803
803
|
const n = [], s = [];
|
|
804
|
-
for (e = 0; e < this.tokens.length &&
|
|
804
|
+
for (e = 0; e < this.tokens.length && kt(this.tokens[e]); e += 1)
|
|
805
805
|
s.push(this.tokens[e]);
|
|
806
806
|
let i = this.tokens[e];
|
|
807
807
|
for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
@@ -843,7 +843,7 @@ class pn {
|
|
|
843
843
|
);
|
|
844
844
|
return;
|
|
845
845
|
}
|
|
846
|
-
a && this.match(n), this.tokens.push(
|
|
846
|
+
a && this.match(n), this.tokens.push(G.create(e, this.start, this.current, l, !1));
|
|
847
847
|
}
|
|
848
848
|
singleLineStringLiteral() {
|
|
849
849
|
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
@@ -895,7 +895,7 @@ class pn {
|
|
|
895
895
|
this.addToken(u.IDENTIFIER);
|
|
896
896
|
}
|
|
897
897
|
operator() {
|
|
898
|
-
for (;
|
|
898
|
+
for (; lt(this.peek()); )
|
|
899
899
|
this.advance();
|
|
900
900
|
this.addToken(u.OP);
|
|
901
901
|
}
|
|
@@ -912,7 +912,7 @@ class pn {
|
|
|
912
912
|
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
913
913
|
if (!n && !Ee(this.peek()))
|
|
914
914
|
return this.addToken(u.NUMERIC_LITERAL);
|
|
915
|
-
if (!n && !
|
|
915
|
+
if (!n && !Re(this.peek()))
|
|
916
916
|
break;
|
|
917
917
|
this.advance();
|
|
918
918
|
}
|
|
@@ -971,7 +971,7 @@ class pn {
|
|
|
971
971
|
let n = "";
|
|
972
972
|
for (let s = 0; s <= 3; s += 1) {
|
|
973
973
|
if (this.isAtEnd() || !Ee(this.peek()))
|
|
974
|
-
return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,
|
|
974
|
+
return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, G.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
|
|
975
975
|
n += this.advance();
|
|
976
976
|
}
|
|
977
977
|
return String.fromCharCode(parseInt(n, 16));
|
|
@@ -981,7 +981,7 @@ class pn {
|
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
|
-
var
|
|
984
|
+
var Oe = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Oe || {});
|
|
985
985
|
class dn {
|
|
986
986
|
constructor() {
|
|
987
987
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
@@ -1069,7 +1069,7 @@ class Nn {
|
|
|
1069
1069
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1070
1070
|
for (; !this.isAtEnd(); ) {
|
|
1071
1071
|
const s = this.peek();
|
|
1072
|
-
if (
|
|
1072
|
+
if (ft(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1073
1073
|
break;
|
|
1074
1074
|
N(s), this.advance();
|
|
1075
1075
|
}
|
|
@@ -1080,8 +1080,8 @@ class Nn {
|
|
|
1080
1080
|
break;
|
|
1081
1081
|
N(s), this.advance();
|
|
1082
1082
|
}
|
|
1083
|
-
}, this.blockExpression = this.contextStack.withContextDo(
|
|
1084
|
-
const s = { body: [] }, i = () => this.nodeFactory.create(
|
|
1083
|
+
}, this.blockExpression = this.contextStack.withContextDo(Oe.BlockExpression, () => {
|
|
1084
|
+
const s = { body: [] }, i = () => this.nodeFactory.create(K, s);
|
|
1085
1085
|
try {
|
|
1086
1086
|
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
1087
1087
|
} catch (r) {
|
|
@@ -1115,16 +1115,16 @@ class Nn {
|
|
|
1115
1115
|
if (!this.check(u.RBRACE))
|
|
1116
1116
|
for (N(this.advance()); !this.isAtEnd(); ) {
|
|
1117
1117
|
const s = this.peek();
|
|
1118
|
-
if (this.check(u.RBRACE) ||
|
|
1118
|
+
if (this.check(u.RBRACE) || ut(this.previous(), s))
|
|
1119
1119
|
break;
|
|
1120
1120
|
N(s), this.advance();
|
|
1121
1121
|
}
|
|
1122
|
-
}, this.tupleExpression = this.contextStack.withContextDo(
|
|
1123
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1122
|
+
}, this.tupleExpression = this.contextStack.withContextDo(Oe.GroupExpression, () => {
|
|
1123
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(ze, {
|
|
1124
1124
|
groupOpenParen: s.tupleOpenParen,
|
|
1125
1125
|
groupCloseParen: s.tupleCloseParen,
|
|
1126
1126
|
expression: s.elementList[0]
|
|
1127
|
-
}), r = () => this.nodeFactory.create(
|
|
1127
|
+
}), r = () => this.nodeFactory.create(ee, s);
|
|
1128
1128
|
try {
|
|
1129
1129
|
this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
|
|
1130
1130
|
} catch (a) {
|
|
@@ -1171,8 +1171,8 @@ class Nn {
|
|
|
1171
1171
|
break;
|
|
1172
1172
|
N(s), this.advance();
|
|
1173
1173
|
}
|
|
1174
|
-
}, this.listExpression = this.contextStack.withContextDo(
|
|
1175
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1174
|
+
}, this.listExpression = this.contextStack.withContextDo(Oe.ListExpression, () => {
|
|
1175
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(R, s);
|
|
1176
1176
|
try {
|
|
1177
1177
|
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
1178
1178
|
} catch (r) {
|
|
@@ -1289,8 +1289,8 @@ class Nn {
|
|
|
1289
1289
|
this.tokens = e;
|
|
1290
1290
|
}
|
|
1291
1291
|
parse() {
|
|
1292
|
-
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(
|
|
1293
|
-
return this.gatherInvalid(), new
|
|
1292
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(j, { body: e, eof: n });
|
|
1293
|
+
return this.gatherInvalid(), new X({ ast: s, tokens: this.tokens }, this.errors);
|
|
1294
1294
|
}
|
|
1295
1295
|
/* Parsing and synchronizing ProgramNode */
|
|
1296
1296
|
program() {
|
|
@@ -1324,7 +1324,7 @@ class Nn {
|
|
|
1324
1324
|
throw new d(s.token, n(), s.handlerContext);
|
|
1325
1325
|
this.synchronizeElementDeclarationName();
|
|
1326
1326
|
}
|
|
1327
|
-
if (
|
|
1327
|
+
if (ft(this.peek()))
|
|
1328
1328
|
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1329
1329
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1330
1330
|
else
|
|
@@ -1400,7 +1400,7 @@ class Nn {
|
|
|
1400
1400
|
return n();
|
|
1401
1401
|
let s = e.callee;
|
|
1402
1402
|
for (; !this.shouldStopExpression(); ) {
|
|
1403
|
-
|
|
1403
|
+
We(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
|
|
1404
1404
|
try {
|
|
1405
1405
|
s = this.normalExpression(), e.args.push(s);
|
|
1406
1406
|
} catch (i) {
|
|
@@ -1410,7 +1410,7 @@ class Nn {
|
|
|
1410
1410
|
return n();
|
|
1411
1411
|
}
|
|
1412
1412
|
shouldStopExpression() {
|
|
1413
|
-
if (this.isAtEnd() ||
|
|
1413
|
+
if (this.isAtEnd() || gt(this.previous()))
|
|
1414
1414
|
return !0;
|
|
1415
1415
|
const e = this.peek().kind;
|
|
1416
1416
|
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
@@ -1424,26 +1424,26 @@ class Nn {
|
|
|
1424
1424
|
for (; !this.isAtEnd(); ) {
|
|
1425
1425
|
const s = this.peek();
|
|
1426
1426
|
if (s.kind === u.LPAREN) {
|
|
1427
|
-
const { left: i } =
|
|
1427
|
+
const { left: i } = pt(s);
|
|
1428
1428
|
if (i < e || // When '(' is encountered,
|
|
1429
1429
|
// consider it part of another expression if
|
|
1430
1430
|
// it's at the start of a new line
|
|
1431
1431
|
// and we're currently not having unmatched '(' or '['
|
|
1432
|
-
|
|
1432
|
+
ut(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1433
1433
|
break;
|
|
1434
1434
|
try {
|
|
1435
|
-
n = this.nodeFactory.create(
|
|
1435
|
+
n = this.nodeFactory.create(Z, {
|
|
1436
1436
|
callee: n,
|
|
1437
1437
|
argumentList: this.tupleExpression()
|
|
1438
1438
|
});
|
|
1439
1439
|
} catch (r) {
|
|
1440
|
-
throw r instanceof d ? (n = this.nodeFactory.create(
|
|
1440
|
+
throw r instanceof d ? (n = this.nodeFactory.create(Z, {
|
|
1441
1441
|
callee: n,
|
|
1442
1442
|
argumentList: r.partialNode
|
|
1443
1443
|
}), new d(r.token, n, r.handlerContext)) : r;
|
|
1444
1444
|
}
|
|
1445
1445
|
} else if (s.kind === u.LBRACKET) {
|
|
1446
|
-
if (
|
|
1446
|
+
if (We(this.previous()))
|
|
1447
1447
|
break;
|
|
1448
1448
|
try {
|
|
1449
1449
|
n = this.nodeFactory.create(he, {
|
|
@@ -1456,12 +1456,12 @@ class Nn {
|
|
|
1456
1456
|
indexer: i.partialNode
|
|
1457
1457
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
1458
1458
|
}
|
|
1459
|
-
} else if (
|
|
1460
|
-
const i = s, r =
|
|
1459
|
+
} else if (ct(s)) {
|
|
1460
|
+
const i = s, r = pt(i);
|
|
1461
1461
|
if (r.left !== null) {
|
|
1462
1462
|
if (r.left <= e)
|
|
1463
1463
|
break;
|
|
1464
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1464
|
+
this.advance(), n = this.nodeFactory.create(Me, {
|
|
1465
1465
|
expression: n,
|
|
1466
1466
|
op: i
|
|
1467
1467
|
});
|
|
@@ -1471,13 +1471,13 @@ class Nn {
|
|
|
1471
1471
|
break;
|
|
1472
1472
|
this.advance();
|
|
1473
1473
|
try {
|
|
1474
|
-
n = this.nodeFactory.create(
|
|
1474
|
+
n = this.nodeFactory.create(J, {
|
|
1475
1475
|
leftExpression: n,
|
|
1476
1476
|
op: i,
|
|
1477
1477
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1478
1478
|
});
|
|
1479
1479
|
} catch (l) {
|
|
1480
|
-
throw l instanceof d ? (n = this.nodeFactory.create(
|
|
1480
|
+
throw l instanceof d ? (n = this.nodeFactory.create(J, {
|
|
1481
1481
|
leftExpression: n,
|
|
1482
1482
|
op: i,
|
|
1483
1483
|
rightExpression: l.partialNode
|
|
@@ -1491,7 +1491,7 @@ class Nn {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
leftExpression_bp() {
|
|
1493
1493
|
let e;
|
|
1494
|
-
if (
|
|
1494
|
+
if (ct(this.peek())) {
|
|
1495
1495
|
const n = {};
|
|
1496
1496
|
n.op = this.peek();
|
|
1497
1497
|
const s = In(n.op);
|
|
@@ -1502,7 +1502,7 @@ class Nn {
|
|
|
1502
1502
|
`Unexpected '${n.op.value}' in an expression`
|
|
1503
1503
|
), new d(
|
|
1504
1504
|
n.op,
|
|
1505
|
-
this.nodeFactory.create(
|
|
1505
|
+
this.nodeFactory.create(Se, { pre: n.op }),
|
|
1506
1506
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1507
1507
|
);
|
|
1508
1508
|
this.advance();
|
|
@@ -1511,15 +1511,15 @@ class Nn {
|
|
|
1511
1511
|
} catch (i) {
|
|
1512
1512
|
throw i instanceof d ? (n.expression = i.partialNode, new d(
|
|
1513
1513
|
i.token,
|
|
1514
|
-
this.nodeFactory.create(
|
|
1514
|
+
this.nodeFactory.create(H, n),
|
|
1515
1515
|
i.handlerContext
|
|
1516
1516
|
)) : i;
|
|
1517
1517
|
}
|
|
1518
|
-
e = this.nodeFactory.create(
|
|
1519
|
-
} else if (e = this.extractOperand(), e instanceof
|
|
1518
|
+
e = this.nodeFactory.create(H, n);
|
|
1519
|
+
} else if (e = this.extractOperand(), e instanceof Se)
|
|
1520
1520
|
throw new d(
|
|
1521
1521
|
this.peek(),
|
|
1522
|
-
this.nodeFactory.create(
|
|
1522
|
+
this.nodeFactory.create(Se, { pre: this.peek() }),
|
|
1523
1523
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1524
1524
|
);
|
|
1525
1525
|
return e;
|
|
@@ -1543,7 +1543,7 @@ class Nn {
|
|
|
1543
1543
|
this.peek(),
|
|
1544
1544
|
o.INVALID_OPERAND,
|
|
1545
1545
|
`Invalid start of operand "${this.peek().value}"`
|
|
1546
|
-
), this.nodeFactory.create(
|
|
1546
|
+
), this.nodeFactory.create(Se, { pre: this.previous() }));
|
|
1547
1547
|
}
|
|
1548
1548
|
/* Parsing FunctionExpression */
|
|
1549
1549
|
functionExpression() {
|
|
@@ -1574,7 +1574,7 @@ class Nn {
|
|
|
1574
1574
|
});
|
|
1575
1575
|
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1576
1576
|
return this.nodeFactory.create(M, {
|
|
1577
|
-
expression: this.nodeFactory.create(
|
|
1577
|
+
expression: this.nodeFactory.create(te, { variable: this.previous() })
|
|
1578
1578
|
});
|
|
1579
1579
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1580
1580
|
this.peek(),
|
|
@@ -1590,7 +1590,7 @@ class Nn {
|
|
|
1590
1590
|
n,
|
|
1591
1591
|
o.EMPTY_ATTRIBUTE_NAME,
|
|
1592
1592
|
"Expect a non-empty attribute name"
|
|
1593
|
-
), e.name = this.nodeFactory.create(
|
|
1593
|
+
), e.name = this.nodeFactory.create(q, { identifiers: [] });
|
|
1594
1594
|
} else
|
|
1595
1595
|
try {
|
|
1596
1596
|
e.name = this.attributeName();
|
|
@@ -1628,11 +1628,11 @@ class Nn {
|
|
|
1628
1628
|
} catch (n) {
|
|
1629
1629
|
throw n instanceof d ? new d(
|
|
1630
1630
|
n.token,
|
|
1631
|
-
this.nodeFactory.create(
|
|
1631
|
+
this.nodeFactory.create(q, { identifiers: e }),
|
|
1632
1632
|
n.handlerContext
|
|
1633
1633
|
) : n;
|
|
1634
1634
|
}
|
|
1635
|
-
return this.nodeFactory.create(
|
|
1635
|
+
return this.nodeFactory.create(q, { identifiers: e });
|
|
1636
1636
|
}
|
|
1637
1637
|
logError(e, n, s) {
|
|
1638
1638
|
this.errors.push(new c(n, s, e));
|
|
@@ -1671,11 +1671,11 @@ function In(t) {
|
|
|
1671
1671
|
const Ln = {
|
|
1672
1672
|
"(": { left: 14, right: null }
|
|
1673
1673
|
};
|
|
1674
|
-
function
|
|
1674
|
+
function pt(t) {
|
|
1675
1675
|
return Ln[t.value] || { left: null, right: null };
|
|
1676
1676
|
}
|
|
1677
1677
|
var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
|
|
1678
|
-
function
|
|
1678
|
+
function we(t) {
|
|
1679
1679
|
var n;
|
|
1680
1680
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1681
1681
|
switch (e) {
|
|
@@ -1692,12 +1692,12 @@ function ve(t) {
|
|
|
1692
1692
|
}
|
|
1693
1693
|
}
|
|
1694
1694
|
function pe(t) {
|
|
1695
|
-
if (!
|
|
1695
|
+
if (!et(t))
|
|
1696
1696
|
return new x([t]);
|
|
1697
1697
|
const e = pe(t.leftExpression).unwrap_or(void 0);
|
|
1698
1698
|
return e ? (e.push(t.rightExpression), new x(e)) : new y();
|
|
1699
1699
|
}
|
|
1700
|
-
function
|
|
1700
|
+
function z(t) {
|
|
1701
1701
|
if (t === void 0)
|
|
1702
1702
|
return new y();
|
|
1703
1703
|
const e = pe(t).unwrap_or(void 0);
|
|
@@ -1705,14 +1705,14 @@ function j(t) {
|
|
|
1705
1705
|
return new y();
|
|
1706
1706
|
const n = [];
|
|
1707
1707
|
for (const s of e) {
|
|
1708
|
-
const i =
|
|
1708
|
+
const i = Q(s).unwrap_or(void 0);
|
|
1709
1709
|
if (!i)
|
|
1710
1710
|
return new y();
|
|
1711
1711
|
n.push(i);
|
|
1712
1712
|
}
|
|
1713
1713
|
return new x(n);
|
|
1714
1714
|
}
|
|
1715
|
-
function
|
|
1715
|
+
function Ae(t) {
|
|
1716
1716
|
if (t === void 0)
|
|
1717
1717
|
return new y();
|
|
1718
1718
|
const e = pe(t).unwrap_or(void 0);
|
|
@@ -1720,17 +1720,17 @@ function _e(t) {
|
|
|
1720
1720
|
return new y();
|
|
1721
1721
|
const n = [];
|
|
1722
1722
|
let s;
|
|
1723
|
-
if (!
|
|
1723
|
+
if (!V(I.last(e))) {
|
|
1724
1724
|
const i = e.pop();
|
|
1725
|
-
if (
|
|
1725
|
+
if (Dt(i))
|
|
1726
1726
|
s = i.elementList.map(
|
|
1727
|
-
(r) =>
|
|
1727
|
+
(r) => W(r).unwrap()
|
|
1728
1728
|
);
|
|
1729
1729
|
else
|
|
1730
1730
|
return new y();
|
|
1731
1731
|
}
|
|
1732
1732
|
for (const i of e) {
|
|
1733
|
-
const r =
|
|
1733
|
+
const r = Q(i).unwrap_or(void 0);
|
|
1734
1734
|
if (!r)
|
|
1735
1735
|
return new y();
|
|
1736
1736
|
n.push(r);
|
|
@@ -1740,41 +1740,41 @@ function _e(t) {
|
|
|
1740
1740
|
tupleElements: s
|
|
1741
1741
|
});
|
|
1742
1742
|
}
|
|
1743
|
-
function
|
|
1744
|
-
return
|
|
1743
|
+
function Q(t) {
|
|
1744
|
+
return V(t) ? new x(t.expression.variable.value) : new y();
|
|
1745
1745
|
}
|
|
1746
|
-
function
|
|
1747
|
-
if (
|
|
1746
|
+
function je(t) {
|
|
1747
|
+
if (dt(t))
|
|
1748
1748
|
return t instanceof se ? new x({ functional: [t], nonFunctional: [] }) : new x({ functional: [], nonFunctional: [t] });
|
|
1749
|
-
if (t instanceof
|
|
1749
|
+
if (t instanceof ee && t.elementList.every(dt)) {
|
|
1750
1750
|
const e = t.elementList.filter(
|
|
1751
1751
|
(s) => s instanceof se
|
|
1752
|
-
), n = t.elementList.filter(
|
|
1752
|
+
), n = t.elementList.filter(V);
|
|
1753
1753
|
return new x({ functional: e, nonFunctional: n });
|
|
1754
1754
|
}
|
|
1755
1755
|
return new y();
|
|
1756
1756
|
}
|
|
1757
|
-
function
|
|
1757
|
+
function W(t) {
|
|
1758
1758
|
var n;
|
|
1759
1759
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1760
1760
|
return e === void 0 ? new y() : new x(e);
|
|
1761
1761
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return
|
|
1762
|
+
function $(t) {
|
|
1763
|
+
return Y(t) ? t.expression instanceof te ? new x(t.expression.variable.value) : new x(t.expression.literal.value) : new y();
|
|
1764
1764
|
}
|
|
1765
1765
|
function gn(t) {
|
|
1766
1766
|
var e;
|
|
1767
|
-
return !(t instanceof
|
|
1767
|
+
return !(t instanceof J) || !Ot((e = t.op) == null ? void 0 : e.value) ? !1 : Ae(t.leftExpression).and_then(() => Ae(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1768
1768
|
}
|
|
1769
1769
|
function _n(t) {
|
|
1770
|
-
const e =
|
|
1770
|
+
const e = Ae(t.leftExpression), n = Ae(t.rightExpression);
|
|
1771
1771
|
if (!e.isOk() || !n.isOk())
|
|
1772
1772
|
return !1;
|
|
1773
1773
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1774
1774
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1775
1775
|
}
|
|
1776
|
-
function
|
|
1777
|
-
return t instanceof M && t.expression instanceof
|
|
1776
|
+
function dt(t) {
|
|
1777
|
+
return t instanceof M && t.expression instanceof te || t instanceof se;
|
|
1778
1778
|
}
|
|
1779
1779
|
function An(t, e) {
|
|
1780
1780
|
var i, r, a, l;
|
|
@@ -1783,9 +1783,9 @@ function An(t, e) {
|
|
|
1783
1783
|
for (; n; ) {
|
|
1784
1784
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1785
1785
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1786
|
-
if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof
|
|
1786
|
+
if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof j && s)
|
|
1787
1787
|
return n.symbol;
|
|
1788
|
-
if (n instanceof
|
|
1788
|
+
if (n instanceof j)
|
|
1789
1789
|
return;
|
|
1790
1790
|
n = n.parent;
|
|
1791
1791
|
}
|
|
@@ -1798,7 +1798,7 @@ class vn {
|
|
|
1798
1798
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1799
1799
|
}
|
|
1800
1800
|
validateContext() {
|
|
1801
|
-
return this.declarationNode.parent instanceof
|
|
1801
|
+
return this.declarationNode.parent instanceof j || we(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1802
1802
|
}
|
|
1803
1803
|
validateName(e) {
|
|
1804
1804
|
return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1812,13 +1812,13 @@ class vn {
|
|
|
1812
1812
|
validateBody(e) {
|
|
1813
1813
|
if (!e)
|
|
1814
1814
|
return [];
|
|
1815
|
-
if (e instanceof
|
|
1815
|
+
if (e instanceof K)
|
|
1816
1816
|
return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1817
1817
|
const n = [];
|
|
1818
|
-
return
|
|
1818
|
+
return Y(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
|
-
class
|
|
1821
|
+
class ye {
|
|
1822
1822
|
constructor() {
|
|
1823
1823
|
this.table = /* @__PURE__ */ new Map();
|
|
1824
1824
|
}
|
|
@@ -1846,17 +1846,17 @@ class wn {
|
|
|
1846
1846
|
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1847
1847
|
}
|
|
1848
1848
|
validateName(e) {
|
|
1849
|
-
return e ?
|
|
1849
|
+
return e ? St(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
1850
1850
|
}
|
|
1851
1851
|
validateAlias(e) {
|
|
1852
1852
|
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1853
1853
|
}
|
|
1854
1854
|
registerElement() {
|
|
1855
1855
|
const e = [];
|
|
1856
|
-
this.declarationNode.symbol = this.symbolFactory.create(sn, { declaration: this.declarationNode, symbolTable: new
|
|
1857
|
-
const { name: n } = this.declarationNode, s =
|
|
1856
|
+
this.declarationNode.symbol = this.symbolFactory.create(sn, { declaration: this.declarationNode, symbolTable: new ye() });
|
|
1857
|
+
const { name: n } = this.declarationNode, s = z(n);
|
|
1858
1858
|
if (s.isOk()) {
|
|
1859
|
-
const i = s.unwrap(), r = i.pop(), a =
|
|
1859
|
+
const i = s.unwrap(), r = i.pop(), a = tt(i, this.publicSymbolTable, this.symbolFactory), l = He(r);
|
|
1860
1860
|
a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
|
|
1861
1861
|
}
|
|
1862
1862
|
return e;
|
|
@@ -1875,19 +1875,19 @@ class wn {
|
|
|
1875
1875
|
validateFields(e) {
|
|
1876
1876
|
return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1877
1877
|
const s = [];
|
|
1878
|
-
n.callee && !
|
|
1878
|
+
n.callee && !V(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1879
1879
|
const i = [...n.args];
|
|
1880
|
-
return I.last(i) instanceof
|
|
1880
|
+
return I.last(i) instanceof R ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof R && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1881
1881
|
});
|
|
1882
1882
|
}
|
|
1883
1883
|
validateFieldSettings(e) {
|
|
1884
|
-
const n =
|
|
1884
|
+
const n = C(e), s = n.getErrors(), i = n.getValue();
|
|
1885
1885
|
for (const r in i) {
|
|
1886
1886
|
const a = i[r];
|
|
1887
1887
|
switch (r) {
|
|
1888
1888
|
case "note":
|
|
1889
1889
|
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
1890
|
-
|
|
1890
|
+
Y(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
|
|
1891
1891
|
});
|
|
1892
1892
|
break;
|
|
1893
1893
|
default:
|
|
@@ -1905,8 +1905,8 @@ class wn {
|
|
|
1905
1905
|
});
|
|
1906
1906
|
}
|
|
1907
1907
|
registerField(e) {
|
|
1908
|
-
if (e.callee &&
|
|
1909
|
-
const n =
|
|
1908
|
+
if (e.callee && V(e.callee)) {
|
|
1909
|
+
const n = W(e.callee).unwrap(), s = Je(n), i = this.symbolFactory.create(rn, { declaration: e });
|
|
1910
1910
|
e.symbol = i;
|
|
1911
1911
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1912
1912
|
if (r.has(s)) {
|
|
@@ -1929,7 +1929,7 @@ class yn {
|
|
|
1929
1929
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1930
1930
|
}
|
|
1931
1931
|
validateContext() {
|
|
1932
|
-
return this.declarationNode.parent instanceof
|
|
1932
|
+
return this.declarationNode.parent instanceof j || we(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1933
1933
|
}
|
|
1934
1934
|
validateName(e) {
|
|
1935
1935
|
return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
@@ -1953,22 +1953,22 @@ class yn {
|
|
|
1953
1953
|
if (!n.callee)
|
|
1954
1954
|
return [];
|
|
1955
1955
|
const s = [], i = [n.callee, ...n.args];
|
|
1956
|
-
return I.last(i) instanceof
|
|
1957
|
-
for (; r instanceof
|
|
1958
|
-
r.argumentList &&
|
|
1959
|
-
|
|
1956
|
+
return I.last(i) instanceof R && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1957
|
+
for (; r instanceof Z; )
|
|
1958
|
+
r.argumentList && !je(r.argumentList).isOk() && s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
|
|
1959
|
+
je(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
|
|
1960
1960
|
}), s;
|
|
1961
1961
|
});
|
|
1962
1962
|
}
|
|
1963
1963
|
validateFieldSetting(e) {
|
|
1964
|
-
const n =
|
|
1964
|
+
const n = C(e), s = n.getErrors(), i = n.getValue();
|
|
1965
1965
|
for (const r in i) {
|
|
1966
1966
|
const a = i[r];
|
|
1967
1967
|
switch (r) {
|
|
1968
1968
|
case "note":
|
|
1969
1969
|
case "name":
|
|
1970
1970
|
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
|
|
1971
|
-
|
|
1971
|
+
Y(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
|
|
1972
1972
|
});
|
|
1973
1973
|
break;
|
|
1974
1974
|
case "unique":
|
|
@@ -1979,7 +1979,7 @@ class yn {
|
|
|
1979
1979
|
break;
|
|
1980
1980
|
case "type":
|
|
1981
1981
|
a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
|
|
1982
|
-
|
|
1982
|
+
V(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
|
|
1983
1983
|
});
|
|
1984
1984
|
break;
|
|
1985
1985
|
default:
|
|
@@ -2011,22 +2011,22 @@ class kn {
|
|
|
2011
2011
|
];
|
|
2012
2012
|
}
|
|
2013
2013
|
validateContext() {
|
|
2014
|
-
return !(this.declarationNode.parent instanceof
|
|
2014
|
+
return !(this.declarationNode.parent instanceof j) && ![
|
|
2015
2015
|
b.Table,
|
|
2016
2016
|
b.TableGroup,
|
|
2017
2017
|
b.Project
|
|
2018
|
-
].includes(
|
|
2018
|
+
].includes(we(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(
|
|
2019
2019
|
o.INVALID_NOTE_CONTEXT,
|
|
2020
2020
|
"A Note can only appear inside a Table, a Table Group or a Project. Sticky note can only appear at the global scope.",
|
|
2021
2021
|
this.declarationNode
|
|
2022
2022
|
)] : [];
|
|
2023
2023
|
}
|
|
2024
2024
|
validateName(e) {
|
|
2025
|
-
if (!(this.declarationNode.parent instanceof
|
|
2025
|
+
if (!(this.declarationNode.parent instanceof j))
|
|
2026
2026
|
return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2027
2027
|
if (!e)
|
|
2028
2028
|
return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2029
|
-
const n =
|
|
2029
|
+
const n = z(e);
|
|
2030
2030
|
if (!n.isOk())
|
|
2031
2031
|
return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2032
2032
|
const i = n.unwrap().join("."), r = Zt(i);
|
|
@@ -2048,7 +2048,7 @@ class kn {
|
|
|
2048
2048
|
}
|
|
2049
2049
|
validateFields(e) {
|
|
2050
2050
|
const n = [];
|
|
2051
|
-
return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))),
|
|
2051
|
+
return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), Y(e[0].callee) || n.push(new c(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2052
2052
|
}
|
|
2053
2053
|
validateSubElements(e) {
|
|
2054
2054
|
return e.flatMap((n) => {
|
|
@@ -2070,7 +2070,7 @@ class xn {
|
|
|
2070
2070
|
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2071
2071
|
}
|
|
2072
2072
|
validateName(e) {
|
|
2073
|
-
return e ?
|
|
2073
|
+
return e ? ke(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2074
2074
|
}
|
|
2075
2075
|
validateAlias(e) {
|
|
2076
2076
|
return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
@@ -2106,10 +2106,10 @@ class Sn {
|
|
|
2106
2106
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2107
2107
|
}
|
|
2108
2108
|
validateContext() {
|
|
2109
|
-
return this.declarationNode.parent instanceof
|
|
2109
|
+
return this.declarationNode.parent instanceof j ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2110
2110
|
}
|
|
2111
2111
|
validateName(e) {
|
|
2112
|
-
return e ?
|
|
2112
|
+
return e ? ke(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2113
2113
|
}
|
|
2114
2114
|
validateAlias(e) {
|
|
2115
2115
|
return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
@@ -2132,11 +2132,16 @@ class Sn {
|
|
|
2132
2132
|
return e.length > 1 && n.push(...e.slice(1).map((s) => new c(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2133
2133
|
s.callee && !gn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !_n(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2134
2134
|
const i = [...s.args];
|
|
2135
|
-
|
|
2135
|
+
if (I.last(i) instanceof R) {
|
|
2136
|
+
const r = this.validateFieldSettings(I.last(i));
|
|
2137
|
+
n.push(...r), i.pop();
|
|
2138
|
+
} else
|
|
2139
|
+
i[0] instanceof R && (n.push(...this.validateFieldSettings(i[0])), i.shift());
|
|
2140
|
+
i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2136
2141
|
}), n;
|
|
2137
2142
|
}
|
|
2138
2143
|
validateFieldSettings(e) {
|
|
2139
|
-
const n =
|
|
2144
|
+
const n = C(e), s = n.getErrors(), i = n.getValue();
|
|
2140
2145
|
for (const r in i) {
|
|
2141
2146
|
const a = i[r];
|
|
2142
2147
|
switch (r) {
|
|
@@ -2146,6 +2151,11 @@ class Sn {
|
|
|
2146
2151
|
On(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
|
|
2147
2152
|
});
|
|
2148
2153
|
break;
|
|
2154
|
+
case "color":
|
|
2155
|
+
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_REF_SETTING, "'color' can only appear once", l))), a.forEach((l) => {
|
|
2156
|
+
nt(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, "'color' must be a color literal", l));
|
|
2157
|
+
});
|
|
2158
|
+
break;
|
|
2149
2159
|
default:
|
|
2150
2160
|
a.forEach((l) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
|
|
2151
2161
|
}
|
|
@@ -2162,10 +2172,10 @@ class Sn {
|
|
|
2162
2172
|
}
|
|
2163
2173
|
}
|
|
2164
2174
|
function On(t) {
|
|
2165
|
-
if (!(
|
|
2175
|
+
if (!(V(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof q))
|
|
2166
2176
|
return !1;
|
|
2167
2177
|
let e;
|
|
2168
|
-
if (t instanceof
|
|
2178
|
+
if (t instanceof q ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
2169
2179
|
switch (e.toLowerCase()) {
|
|
2170
2180
|
case "cascade":
|
|
2171
2181
|
case "no action":
|
|
@@ -2189,24 +2199,24 @@ class Dn {
|
|
|
2189
2199
|
return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2190
2200
|
}
|
|
2191
2201
|
validateName(e) {
|
|
2192
|
-
return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] :
|
|
2202
|
+
return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : St(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2193
2203
|
}
|
|
2194
2204
|
validateAlias(e) {
|
|
2195
2205
|
return e ? Mn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2196
2206
|
}
|
|
2197
2207
|
validateSettingList(e) {
|
|
2198
|
-
const n =
|
|
2208
|
+
const n = C(e), s = n.getErrors(), i = n.getValue();
|
|
2199
2209
|
for (const r in i) {
|
|
2200
2210
|
const a = i[r];
|
|
2201
2211
|
switch (r) {
|
|
2202
2212
|
case "headercolor":
|
|
2203
2213
|
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
|
|
2204
|
-
|
|
2214
|
+
nt(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
|
|
2205
2215
|
});
|
|
2206
2216
|
break;
|
|
2207
2217
|
case "note":
|
|
2208
2218
|
a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
|
|
2209
|
-
|
|
2219
|
+
Y(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
|
|
2210
2220
|
});
|
|
2211
2221
|
break;
|
|
2212
2222
|
default:
|
|
@@ -2217,14 +2227,14 @@ class Dn {
|
|
|
2217
2227
|
}
|
|
2218
2228
|
registerElement() {
|
|
2219
2229
|
const e = [];
|
|
2220
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2221
|
-
const { name: n, alias: s } = this.declarationNode, i =
|
|
2230
|
+
this.declarationNode.symbol = this.symbolFactory.create(yt, { declaration: this.declarationNode, symbolTable: new ye() });
|
|
2231
|
+
const { name: n, alias: s } = this.declarationNode, i = z(n);
|
|
2222
2232
|
if (i.isOk()) {
|
|
2223
|
-
const r = [...i.unwrap()], a = r.pop(), l =
|
|
2233
|
+
const r = [...i.unwrap()], a = r.pop(), l = tt(r, this.publicSymbolTable, this.symbolFactory), p = De(a);
|
|
2224
2234
|
l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
|
|
2225
2235
|
}
|
|
2226
|
-
if (s &&
|
|
2227
|
-
const r =
|
|
2236
|
+
if (s && ke(s) && !Pn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2237
|
+
const r = W(s).unwrap(), a = De(r);
|
|
2228
2238
|
this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2229
2239
|
}
|
|
2230
2240
|
return e;
|
|
@@ -2242,14 +2252,14 @@ class Dn {
|
|
|
2242
2252
|
if (!n.callee)
|
|
2243
2253
|
return [];
|
|
2244
2254
|
const s = [];
|
|
2245
|
-
n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)),
|
|
2255
|
+
n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), V(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Rn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2246
2256
|
const i = n.args.slice(1);
|
|
2247
2257
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2248
2258
|
});
|
|
2249
2259
|
}
|
|
2250
2260
|
registerField(e) {
|
|
2251
|
-
if (e.callee &&
|
|
2252
|
-
const n =
|
|
2261
|
+
if (e.callee && V(e.callee)) {
|
|
2262
|
+
const n = W(e.callee).unwrap(), s = qe(n), i = this.symbolFactory.create(an, { declaration: e });
|
|
2253
2263
|
e.symbol = i;
|
|
2254
2264
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2255
2265
|
if (r.has(s)) {
|
|
@@ -2265,15 +2275,15 @@ class Dn {
|
|
|
2265
2275
|
}
|
|
2266
2276
|
// This is needed to support legacy inline settings
|
|
2267
2277
|
validateFieldSetting(e) {
|
|
2268
|
-
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof
|
|
2278
|
+
if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof R))
|
|
2269
2279
|
return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2270
2280
|
if (e.length === 0)
|
|
2271
2281
|
return [];
|
|
2272
2282
|
let n;
|
|
2273
|
-
I.last(e) instanceof
|
|
2274
|
-
const s =
|
|
2283
|
+
I.last(e) instanceof R && (n = e.pop());
|
|
2284
|
+
const s = C(n), i = s.getErrors(), r = s.getValue();
|
|
2275
2285
|
for (const p of e) {
|
|
2276
|
-
const f =
|
|
2286
|
+
const f = W(p).unwrap_or("").toLowerCase();
|
|
2277
2287
|
if (f !== "pk" && f !== "unique") {
|
|
2278
2288
|
i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2279
2289
|
continue;
|
|
@@ -2287,7 +2297,7 @@ class Dn {
|
|
|
2287
2297
|
switch (p) {
|
|
2288
2298
|
case "note":
|
|
2289
2299
|
f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
|
|
2290
|
-
|
|
2300
|
+
Y(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
|
|
2291
2301
|
});
|
|
2292
2302
|
break;
|
|
2293
2303
|
case "ref":
|
|
@@ -2352,10 +2362,10 @@ class Dn {
|
|
|
2352
2362
|
}
|
|
2353
2363
|
}
|
|
2354
2364
|
function Rn(t) {
|
|
2355
|
-
if (!(t instanceof
|
|
2365
|
+
if (!(t instanceof Z || et(t) || t instanceof M || t instanceof he))
|
|
2356
2366
|
return !1;
|
|
2357
|
-
if (t instanceof
|
|
2358
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => fe(n) ||
|
|
2367
|
+
if (t instanceof Z) {
|
|
2368
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => fe(n) || Y(n) || me(n)))
|
|
2359
2369
|
return !1;
|
|
2360
2370
|
t = t.callee;
|
|
2361
2371
|
}
|
|
@@ -2364,7 +2374,7 @@ function Rn(t) {
|
|
|
2364
2374
|
return !1;
|
|
2365
2375
|
t = t.array;
|
|
2366
2376
|
}
|
|
2367
|
-
const e =
|
|
2377
|
+
const e = z(t).unwrap_or(void 0);
|
|
2368
2378
|
return e !== void 0 && e.length > 0;
|
|
2369
2379
|
}
|
|
2370
2380
|
function Pn(t, e) {
|
|
@@ -2392,7 +2402,7 @@ class Un {
|
|
|
2392
2402
|
)] : [];
|
|
2393
2403
|
}
|
|
2394
2404
|
validateName(e) {
|
|
2395
|
-
return e ?
|
|
2405
|
+
return e ? ke(e) ? [] : [new c(
|
|
2396
2406
|
o.INVALID_NAME,
|
|
2397
2407
|
"A TableGroup name must be a single identifier",
|
|
2398
2408
|
e
|
|
@@ -2411,10 +2421,10 @@ class Un {
|
|
|
2411
2421
|
}
|
|
2412
2422
|
registerElement() {
|
|
2413
2423
|
const { name: e } = this.declarationNode;
|
|
2414
|
-
this.declarationNode.symbol = this.symbolFactory.create(on, { declaration: this.declarationNode, symbolTable: new
|
|
2415
|
-
const n =
|
|
2424
|
+
this.declarationNode.symbol = this.symbolFactory.create(on, { declaration: this.declarationNode, symbolTable: new ye() });
|
|
2425
|
+
const n = z(e);
|
|
2416
2426
|
if (n.isOk()) {
|
|
2417
|
-
const s = n.unwrap(), i = s.pop(), r =
|
|
2427
|
+
const s = n.unwrap(), i = s.pop(), r = tt(s, this.publicSymbolTable, this.symbolFactory), a = Ze(i);
|
|
2418
2428
|
if (r.has(a))
|
|
2419
2429
|
return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
|
|
2420
2430
|
r.set(a, this.declarationNode.symbol);
|
|
@@ -2422,7 +2432,7 @@ class Un {
|
|
|
2422
2432
|
return [];
|
|
2423
2433
|
}
|
|
2424
2434
|
validateSettingList(e) {
|
|
2425
|
-
const n =
|
|
2435
|
+
const n = C(e), s = n.getErrors(), i = n.getValue();
|
|
2426
2436
|
return I.forIn(i, (r, a) => {
|
|
2427
2437
|
switch (a) {
|
|
2428
2438
|
case "color":
|
|
@@ -2431,7 +2441,7 @@ class Un {
|
|
|
2431
2441
|
"'color' can only appear once",
|
|
2432
2442
|
l
|
|
2433
2443
|
))), r.forEach((l) => {
|
|
2434
|
-
|
|
2444
|
+
nt(l.value) || s.push(new c(
|
|
2435
2445
|
o.INVALID_TABLE_SETTING,
|
|
2436
2446
|
"'color' must be a color literal",
|
|
2437
2447
|
l.value || l.name
|
|
@@ -2443,7 +2453,7 @@ class Un {
|
|
|
2443
2453
|
o.DUPLICATE_TABLE_SETTING,
|
|
2444
2454
|
"'note' can only appear once",
|
|
2445
2455
|
l
|
|
2446
|
-
))), r.filter((l) => !
|
|
2456
|
+
))), r.filter((l) => !Y(l.value)).forEach((l) => {
|
|
2447
2457
|
s.push(new c(
|
|
2448
2458
|
o.INVALID_TABLE_SETTING,
|
|
2449
2459
|
"'note' must be a string literal",
|
|
@@ -2479,7 +2489,7 @@ class Un {
|
|
|
2479
2489
|
validateFields(e) {
|
|
2480
2490
|
return e.flatMap((n) => {
|
|
2481
2491
|
const s = [];
|
|
2482
|
-
return n.callee && !
|
|
2492
|
+
return n.callee && !z(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2483
2493
|
});
|
|
2484
2494
|
}
|
|
2485
2495
|
validateSubElements(e) {
|
|
@@ -2495,8 +2505,8 @@ class Un {
|
|
|
2495
2505
|
return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2496
2506
|
}
|
|
2497
2507
|
registerField(e) {
|
|
2498
|
-
if (e.callee &&
|
|
2499
|
-
const n =
|
|
2508
|
+
if (e.callee && V(e.callee)) {
|
|
2509
|
+
const n = W(e.callee).unwrap(), s = Ke(n), i = this.symbolFactory.create(ln, { declaration: e });
|
|
2500
2510
|
e.symbol = i;
|
|
2501
2511
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2502
2512
|
if (r.has(s)) {
|
|
@@ -2511,7 +2521,7 @@ class Un {
|
|
|
2511
2521
|
return [];
|
|
2512
2522
|
}
|
|
2513
2523
|
}
|
|
2514
|
-
const
|
|
2524
|
+
const xt = ["-", "+"];
|
|
2515
2525
|
function oe(t) {
|
|
2516
2526
|
switch (t.type.value.toLowerCase()) {
|
|
2517
2527
|
case b.Enum:
|
|
@@ -2532,38 +2542,38 @@ function oe(t) {
|
|
|
2532
2542
|
return vn;
|
|
2533
2543
|
}
|
|
2534
2544
|
}
|
|
2535
|
-
function
|
|
2536
|
-
return !!
|
|
2545
|
+
function St(t) {
|
|
2546
|
+
return !!z(t).unwrap_or(!1);
|
|
2537
2547
|
}
|
|
2538
2548
|
function Mn(t) {
|
|
2539
|
-
return
|
|
2549
|
+
return ke(t);
|
|
2540
2550
|
}
|
|
2541
|
-
function
|
|
2542
|
-
return t instanceof M && t.expression instanceof
|
|
2551
|
+
function ke(t) {
|
|
2552
|
+
return t instanceof M && t.expression instanceof te;
|
|
2543
2553
|
}
|
|
2544
|
-
function
|
|
2554
|
+
function tt(t, e, n) {
|
|
2545
2555
|
var i;
|
|
2546
2556
|
t[0] === "public" && (t = t.slice(1));
|
|
2547
2557
|
let s = e;
|
|
2548
2558
|
for (const r of t) {
|
|
2549
2559
|
let a;
|
|
2550
|
-
const l =
|
|
2560
|
+
const l = Qe(r);
|
|
2551
2561
|
if (s.has(l)) {
|
|
2552
2562
|
if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
|
|
2553
2563
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2554
2564
|
} else {
|
|
2555
|
-
a = new
|
|
2556
|
-
const p = n.create(
|
|
2565
|
+
a = new ye();
|
|
2566
|
+
const p = n.create(wt, { symbolTable: a });
|
|
2557
2567
|
s.set(l, p);
|
|
2558
2568
|
}
|
|
2559
2569
|
s = a;
|
|
2560
2570
|
}
|
|
2561
2571
|
return s;
|
|
2562
2572
|
}
|
|
2563
|
-
function
|
|
2573
|
+
function Ot(t) {
|
|
2564
2574
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2565
2575
|
}
|
|
2566
|
-
function
|
|
2576
|
+
function nt(t) {
|
|
2567
2577
|
var n;
|
|
2568
2578
|
if (!(t instanceof M) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2569
2579
|
return !1;
|
|
@@ -2580,7 +2590,7 @@ function ue(t) {
|
|
|
2580
2590
|
}
|
|
2581
2591
|
function Fn(t) {
|
|
2582
2592
|
var e;
|
|
2583
|
-
return !!(
|
|
2593
|
+
return !!(Y(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof H && xt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof se);
|
|
2584
2594
|
}
|
|
2585
2595
|
function fe(t) {
|
|
2586
2596
|
var e;
|
|
@@ -2588,19 +2598,19 @@ function fe(t) {
|
|
|
2588
2598
|
}
|
|
2589
2599
|
function Bn(t) {
|
|
2590
2600
|
var n;
|
|
2591
|
-
if (!(t instanceof
|
|
2601
|
+
if (!(t instanceof H) || !Ot((n = t.op) == null ? void 0 : n.value))
|
|
2592
2602
|
return !1;
|
|
2593
|
-
const e =
|
|
2603
|
+
const e = z(t.expression).unwrap_or(void 0);
|
|
2594
2604
|
return e !== void 0 && e.length > 0;
|
|
2595
2605
|
}
|
|
2596
|
-
function
|
|
2597
|
-
return t instanceof
|
|
2606
|
+
function Dt(t) {
|
|
2607
|
+
return t instanceof ee && t.elementList.every(V);
|
|
2598
2608
|
}
|
|
2599
|
-
function
|
|
2609
|
+
function C(t) {
|
|
2600
2610
|
var s;
|
|
2601
2611
|
const e = {}, n = [];
|
|
2602
2612
|
if (!t)
|
|
2603
|
-
return new
|
|
2613
|
+
return new X({});
|
|
2604
2614
|
for (const i of t.elementList) {
|
|
2605
2615
|
if (!i.name)
|
|
2606
2616
|
continue;
|
|
@@ -2611,12 +2621,12 @@ function V(t) {
|
|
|
2611
2621
|
const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2612
2622
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2613
2623
|
}
|
|
2614
|
-
return new
|
|
2624
|
+
return new X(e, n);
|
|
2615
2625
|
}
|
|
2616
|
-
class
|
|
2626
|
+
class Et {
|
|
2617
2627
|
constructor(e, n) {
|
|
2618
|
-
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(
|
|
2619
|
-
symbolTable: new
|
|
2628
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(wt, {
|
|
2629
|
+
symbolTable: new ye()
|
|
2620
2630
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2621
2631
|
}
|
|
2622
2632
|
validate() {
|
|
@@ -2631,8 +2641,8 @@ class pt {
|
|
|
2631
2641
|
);
|
|
2632
2642
|
e.push(...r.validate());
|
|
2633
2643
|
});
|
|
2634
|
-
const n = this.ast.body.filter((s) =>
|
|
2635
|
-
return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new
|
|
2644
|
+
const n = this.ast.body.filter((s) => we(s).unwrap_or(void 0) === b.Project);
|
|
2645
|
+
return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new X(this.ast, e);
|
|
2636
2646
|
}
|
|
2637
2647
|
}
|
|
2638
2648
|
class le {
|
|
@@ -2659,12 +2669,12 @@ class le {
|
|
|
2659
2669
|
if (!e.body)
|
|
2660
2670
|
return;
|
|
2661
2671
|
const { body: n } = e;
|
|
2662
|
-
if (n instanceof
|
|
2672
|
+
if (n instanceof K)
|
|
2663
2673
|
for (const s of n.body)
|
|
2664
2674
|
if (s instanceof A) {
|
|
2665
2675
|
if (!s.type)
|
|
2666
2676
|
continue;
|
|
2667
|
-
const i =
|
|
2677
|
+
const i = Rt(s);
|
|
2668
2678
|
new i(s, this.errors).bind();
|
|
2669
2679
|
} else
|
|
2670
2680
|
this.bindSubfield(s);
|
|
@@ -2673,7 +2683,7 @@ class le {
|
|
|
2673
2683
|
}
|
|
2674
2684
|
bindSubfield(e) {
|
|
2675
2685
|
const n = [e.callee, ...e.args], s = I.last(n);
|
|
2676
|
-
s instanceof
|
|
2686
|
+
s instanceof R && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
|
|
2677
2687
|
const { argBinderRules: i } = this.subfield.arg;
|
|
2678
2688
|
for (let r = 0; r < Math.min(n.length, i.length); r += 1)
|
|
2679
2689
|
i[r].shouldBind && this.scanAndBind(n[r], i[r]);
|
|
@@ -2683,11 +2693,11 @@ class le {
|
|
|
2683
2693
|
var s, i;
|
|
2684
2694
|
if (e)
|
|
2685
2695
|
if (e instanceof M) {
|
|
2686
|
-
if (e.expression instanceof
|
|
2696
|
+
if (e.expression instanceof te && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2687
2697
|
return;
|
|
2688
2698
|
this.bindFragments([e], n);
|
|
2689
2699
|
} else
|
|
2690
|
-
e instanceof
|
|
2700
|
+
e instanceof J ? et(e) ? this.bindFragments(pe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof H ? this.scanAndBind(e.expression, n) : e instanceof Me ? this.scanAndBind(e.expression, n) : e instanceof ee && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2691
2701
|
}
|
|
2692
2702
|
// Bind the fragments of a member access expression
|
|
2693
2703
|
// which can be a simple expression like v1.User,
|
|
@@ -2695,7 +2705,7 @@ class le {
|
|
|
2695
2705
|
bindFragments(e, n) {
|
|
2696
2706
|
if (e.length === 0)
|
|
2697
2707
|
return;
|
|
2698
|
-
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !
|
|
2708
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !V(h)), l = r !== -1 && Dt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
|
|
2699
2709
|
0,
|
|
2700
2710
|
r === -1 ? void 0 : r
|
|
2701
2711
|
);
|
|
@@ -2703,16 +2713,16 @@ class le {
|
|
|
2703
2713
|
return;
|
|
2704
2714
|
const E = [];
|
|
2705
2715
|
for (; s.length && f.length; ) {
|
|
2706
|
-
const h = s.pop(), m = f.pop(), g =
|
|
2716
|
+
const h = s.pop(), m = f.pop(), g = W(m).unwrap();
|
|
2707
2717
|
E.unshift({
|
|
2708
|
-
index:
|
|
2718
|
+
index: Ce(g, h),
|
|
2709
2719
|
referrer: m
|
|
2710
2720
|
});
|
|
2711
2721
|
}
|
|
2712
2722
|
for (; f.length; ) {
|
|
2713
|
-
const h = f.pop(), m =
|
|
2723
|
+
const h = f.pop(), m = W(h).unwrap();
|
|
2714
2724
|
E.unshift({
|
|
2715
|
-
index:
|
|
2725
|
+
index: Ce(m, i),
|
|
2716
2726
|
referrer: h
|
|
2717
2727
|
});
|
|
2718
2728
|
}
|
|
@@ -2721,8 +2731,8 @@ class le {
|
|
|
2721
2731
|
[
|
|
2722
2732
|
...E,
|
|
2723
2733
|
{
|
|
2724
|
-
index:
|
|
2725
|
-
|
|
2734
|
+
index: Ce(
|
|
2735
|
+
W(h).unwrap(),
|
|
2726
2736
|
p
|
|
2727
2737
|
),
|
|
2728
2738
|
referrer: h
|
|
@@ -2901,7 +2911,7 @@ class Yn extends le {
|
|
|
2901
2911
|
}, this.settingList = {};
|
|
2902
2912
|
}
|
|
2903
2913
|
}
|
|
2904
|
-
function
|
|
2914
|
+
function Rt(t) {
|
|
2905
2915
|
switch (t.type.value.toLowerCase()) {
|
|
2906
2916
|
case b.Enum:
|
|
2907
2917
|
return Gn;
|
|
@@ -2928,10 +2938,10 @@ class zn {
|
|
|
2928
2938
|
resolve() {
|
|
2929
2939
|
for (const e of this.ast.body)
|
|
2930
2940
|
if (e.type) {
|
|
2931
|
-
const n =
|
|
2941
|
+
const n = Rt(e);
|
|
2932
2942
|
new n(e, this.errors).bind();
|
|
2933
2943
|
}
|
|
2934
|
-
return new
|
|
2944
|
+
return new X(this.ast, this.errors);
|
|
2935
2945
|
}
|
|
2936
2946
|
}
|
|
2937
2947
|
class Qn {
|
|
@@ -2948,15 +2958,15 @@ class qn {
|
|
|
2948
2958
|
}
|
|
2949
2959
|
// Analyzing: Invoking both the validator and binder
|
|
2950
2960
|
analyze() {
|
|
2951
|
-
return new
|
|
2961
|
+
return new Et(this.ast, this.symbolFactory).validate().chain((n) => new zn(n).resolve());
|
|
2952
2962
|
}
|
|
2953
2963
|
// For invoking the validator only
|
|
2954
2964
|
validate() {
|
|
2955
|
-
return new
|
|
2965
|
+
return new Et(this.ast, this.symbolFactory).validate().chain((n) => new X(n, []));
|
|
2956
2966
|
}
|
|
2957
2967
|
}
|
|
2958
|
-
function
|
|
2959
|
-
const { variables: n, tupleElements: s } =
|
|
2968
|
+
function Nt(t, e) {
|
|
2969
|
+
const { variables: n, tupleElements: s } = Ae(t).unwrap();
|
|
2960
2970
|
return s ? n.length === 0 ? {
|
|
2961
2971
|
schemaName: e.schemaName,
|
|
2962
2972
|
tableName: e.name,
|
|
@@ -2975,7 +2985,7 @@ function dt(t, e) {
|
|
|
2975
2985
|
schemaName: n.pop() || null
|
|
2976
2986
|
};
|
|
2977
2987
|
}
|
|
2978
|
-
function
|
|
2988
|
+
function Pt(t) {
|
|
2979
2989
|
switch (t) {
|
|
2980
2990
|
case "<":
|
|
2981
2991
|
return ["1", "*"];
|
|
@@ -2998,22 +3008,22 @@ function _(t) {
|
|
|
2998
3008
|
end: { offset: t.endPos.offset, line: t.endPos.line + 1, column: t.endPos.column + 1 }
|
|
2999
3009
|
};
|
|
3000
3010
|
}
|
|
3001
|
-
function
|
|
3011
|
+
function Ye(t) {
|
|
3002
3012
|
var n;
|
|
3003
3013
|
const e = (n = pe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
3004
|
-
return e instanceof
|
|
3014
|
+
return e instanceof ee ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
3005
3015
|
}
|
|
3006
3016
|
function Ie(t) {
|
|
3007
|
-
const e =
|
|
3017
|
+
const e = z(t).unwrap();
|
|
3008
3018
|
return {
|
|
3009
3019
|
name: e.pop(),
|
|
3010
3020
|
schemaName: e
|
|
3011
3021
|
};
|
|
3012
3022
|
}
|
|
3013
|
-
function
|
|
3023
|
+
function Be(t) {
|
|
3014
3024
|
return t.expression.literal.value;
|
|
3015
3025
|
}
|
|
3016
|
-
function
|
|
3026
|
+
function Ut(t, e) {
|
|
3017
3027
|
if (Array.isArray(t)) {
|
|
3018
3028
|
const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
|
|
3019
3029
|
return i < r ? `${i}-${r}` : `${r}-${i}`;
|
|
@@ -3021,7 +3031,7 @@ function Pt(t, e) {
|
|
|
3021
3031
|
const n = t.id.toString(), s = e.id.toString();
|
|
3022
3032
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
3023
3033
|
}
|
|
3024
|
-
function
|
|
3034
|
+
function Mt(t, e) {
|
|
3025
3035
|
if (Array.isArray(t)) {
|
|
3026
3036
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
3027
3037
|
return I.zip(i, r).every(([a, l]) => a === l);
|
|
@@ -3035,7 +3045,7 @@ function ae(t) {
|
|
|
3035
3045
|
return n.map((r) => r.slice(i)).join(`
|
|
3036
3046
|
`);
|
|
3037
3047
|
}
|
|
3038
|
-
class
|
|
3048
|
+
class Ft {
|
|
3039
3049
|
constructor(e, n) {
|
|
3040
3050
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
3041
3051
|
}
|
|
@@ -3065,7 +3075,7 @@ class Mt {
|
|
|
3065
3075
|
interpretAlias(e) {
|
|
3066
3076
|
if (!e)
|
|
3067
3077
|
return [];
|
|
3068
|
-
const n =
|
|
3078
|
+
const n = W(e).unwrap_or(null);
|
|
3069
3079
|
return n && (this.env.aliases.push({
|
|
3070
3080
|
name: n,
|
|
3071
3081
|
kind: "table",
|
|
@@ -3077,11 +3087,11 @@ class Mt {
|
|
|
3077
3087
|
}
|
|
3078
3088
|
interpretSettingList(e) {
|
|
3079
3089
|
var i, r, a;
|
|
3080
|
-
const n =
|
|
3081
|
-
this.table.headerColor = (i = n.headercolor) != null && i.length ?
|
|
3090
|
+
const n = C(e).getValue();
|
|
3091
|
+
this.table.headerColor = (i = n.headercolor) != null && i.length ? Be((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
|
|
3082
3092
|
const [s] = n.note || [];
|
|
3083
3093
|
return this.table.note = s && {
|
|
3084
|
-
value:
|
|
3094
|
+
value: $(s == null ? void 0 : s.value).map(ae).unwrap(),
|
|
3085
3095
|
token: _(s)
|
|
3086
3096
|
}, [];
|
|
3087
3097
|
}
|
|
@@ -3095,7 +3105,7 @@ class Mt {
|
|
|
3095
3105
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3096
3106
|
case "note":
|
|
3097
3107
|
return this.table.note = {
|
|
3098
|
-
value:
|
|
3108
|
+
value: $(n.body instanceof K ? n.body.body[0].callee : n.body.callee).map(ae).unwrap(),
|
|
3099
3109
|
token: _(n)
|
|
3100
3110
|
}, [];
|
|
3101
3111
|
case "indexes":
|
|
@@ -3108,26 +3118,26 @@ class Mt {
|
|
|
3108
3118
|
return e.flatMap((n) => this.interpretColumn(n));
|
|
3109
3119
|
}
|
|
3110
3120
|
interpretColumn(e) {
|
|
3111
|
-
var a, l, p, f, E, h, m, g,
|
|
3121
|
+
var a, l, p, f, E, h, m, g, P;
|
|
3112
3122
|
const n = [], s = {};
|
|
3113
|
-
s.name =
|
|
3123
|
+
s.name = W(e.callee).unwrap();
|
|
3114
3124
|
const i = Hn(e.args[0]);
|
|
3115
3125
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = _(e), s.inline_refs = [];
|
|
3116
3126
|
const r = e.args.slice(1);
|
|
3117
|
-
if (I.last(r) instanceof
|
|
3118
|
-
const S =
|
|
3127
|
+
if (I.last(r) instanceof R) {
|
|
3128
|
+
const S = C(r.pop()).getValue();
|
|
3119
3129
|
s.pk = !!((a = S.pk) != null && a.length) || !!((l = S["primary key"]) != null && l.length), s.increment = !!((p = S.increment) != null && p.length), s.unique = !!((f = S.unique) != null && f.length), s.not_null = (E = S["not null"]) != null && E.length ? !0 : (h = S.null) != null && h.length ? !1 : void 0, s.dbdefault = Jn((g = (m = S.default) == null ? void 0 : m.at(0)) == null ? void 0 : g.value);
|
|
3120
|
-
const
|
|
3121
|
-
s.note =
|
|
3122
|
-
value:
|
|
3123
|
-
token: _(
|
|
3130
|
+
const F = (P = S.note) == null ? void 0 : P.at(0);
|
|
3131
|
+
s.note = F && {
|
|
3132
|
+
value: $(F.value).map(ae).unwrap(),
|
|
3133
|
+
token: _(F)
|
|
3124
3134
|
};
|
|
3125
|
-
const
|
|
3126
|
-
s.inline_refs =
|
|
3127
|
-
const [
|
|
3128
|
-
if (
|
|
3129
|
-
return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
3130
|
-
const
|
|
3135
|
+
const Le = S.ref || [];
|
|
3136
|
+
s.inline_refs = Le.flatMap((B) => {
|
|
3137
|
+
const [rt] = Ye(B.value.expression);
|
|
3138
|
+
if (Mt(rt, e.symbol))
|
|
3139
|
+
return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", B)), [];
|
|
3140
|
+
const xe = B.value.op, ne = z(B.value.expression).unwrap();
|
|
3131
3141
|
let de;
|
|
3132
3142
|
if (ne.length === 1) {
|
|
3133
3143
|
const [ce] = ne;
|
|
@@ -3135,43 +3145,43 @@ class Mt {
|
|
|
3135
3145
|
schemaName: this.table.schemaName,
|
|
3136
3146
|
tableName: this.table.name,
|
|
3137
3147
|
fieldNames: [ce],
|
|
3138
|
-
relation:
|
|
3139
|
-
token: _(
|
|
3148
|
+
relation: xe.value,
|
|
3149
|
+
token: _(B)
|
|
3140
3150
|
};
|
|
3141
3151
|
} else if (ne.length === 2) {
|
|
3142
|
-
const [ce,
|
|
3152
|
+
const [ce, ge] = ne;
|
|
3143
3153
|
de = {
|
|
3144
3154
|
schemaName: null,
|
|
3145
3155
|
tableName: ce,
|
|
3146
|
-
fieldNames: [
|
|
3147
|
-
relation:
|
|
3148
|
-
token: _(
|
|
3156
|
+
fieldNames: [ge],
|
|
3157
|
+
relation: xe.value,
|
|
3158
|
+
token: _(B)
|
|
3149
3159
|
};
|
|
3150
3160
|
} else if (ne.length === 3) {
|
|
3151
|
-
const [ce,
|
|
3161
|
+
const [ce, ge, ot] = ne;
|
|
3152
3162
|
de = {
|
|
3153
3163
|
schemaName: ce,
|
|
3154
|
-
tableName:
|
|
3155
|
-
fieldNames: [
|
|
3156
|
-
relation:
|
|
3157
|
-
token: _(
|
|
3164
|
+
tableName: ge,
|
|
3165
|
+
fieldNames: [ot],
|
|
3166
|
+
relation: xe.value,
|
|
3167
|
+
token: _(B)
|
|
3158
3168
|
};
|
|
3159
3169
|
} else {
|
|
3160
|
-
n.push(new c(o.UNSUPPORTED, "Nested schema is not supported",
|
|
3161
|
-
const ce = ne.pop(),
|
|
3170
|
+
n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", B));
|
|
3171
|
+
const ce = ne.pop(), ge = ne.pop();
|
|
3162
3172
|
de = {
|
|
3163
3173
|
schemaName: ne.join("."),
|
|
3164
|
-
tableName:
|
|
3174
|
+
tableName: ge,
|
|
3165
3175
|
fieldNames: [ce],
|
|
3166
|
-
relation:
|
|
3167
|
-
token: _(
|
|
3176
|
+
relation: xe.value,
|
|
3177
|
+
token: _(B)
|
|
3168
3178
|
};
|
|
3169
3179
|
}
|
|
3170
|
-
const
|
|
3171
|
-
return n.push(...
|
|
3180
|
+
const at = this.registerInlineRefToEnv(e, rt, de, B);
|
|
3181
|
+
return n.push(...at), at.length === 0 ? de : [];
|
|
3172
3182
|
});
|
|
3173
3183
|
}
|
|
3174
|
-
return s.pk || (s.pk = r.some((S) =>
|
|
3184
|
+
return s.pk || (s.pk = r.some((S) => Q(S).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((S) => Q(S).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3175
3185
|
}
|
|
3176
3186
|
interpretIndexes(e) {
|
|
3177
3187
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
@@ -3179,47 +3189,47 @@ class Mt {
|
|
|
3179
3189
|
const s = { columns: [] }, i = n;
|
|
3180
3190
|
s.token = _(i);
|
|
3181
3191
|
const r = [i.callee, ...i.args];
|
|
3182
|
-
if (I.last(r) instanceof
|
|
3183
|
-
const g =
|
|
3184
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name =
|
|
3185
|
-
const
|
|
3186
|
-
s.note =
|
|
3187
|
-
value:
|
|
3188
|
-
token: _(
|
|
3189
|
-
}, s.type =
|
|
3192
|
+
if (I.last(r) instanceof R) {
|
|
3193
|
+
const g = C(r.pop()).getValue();
|
|
3194
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = $((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
|
|
3195
|
+
const P = (E = g.note) == null ? void 0 : E.at(0);
|
|
3196
|
+
s.note = P && {
|
|
3197
|
+
value: $(P.value).unwrap(),
|
|
3198
|
+
token: _(P)
|
|
3199
|
+
}, s.type = Q((m = (h = g.type) == null ? void 0 : h.at(0)) == null ? void 0 : m.value).unwrap_or(void 0);
|
|
3190
3200
|
}
|
|
3191
3201
|
return r.flatMap((g) => {
|
|
3192
|
-
if (!(g instanceof
|
|
3202
|
+
if (!(g instanceof Z))
|
|
3193
3203
|
return g;
|
|
3194
|
-
const
|
|
3195
|
-
for (; g instanceof
|
|
3196
|
-
|
|
3197
|
-
return
|
|
3204
|
+
const P = [];
|
|
3205
|
+
for (; g instanceof Z; )
|
|
3206
|
+
P.push(g.argumentList), g = g.callee;
|
|
3207
|
+
return P.push(g), P;
|
|
3198
3208
|
}).forEach((g) => {
|
|
3199
|
-
const { functional:
|
|
3209
|
+
const { functional: P, nonFunctional: S } = je(g).unwrap();
|
|
3200
3210
|
s.columns.push(
|
|
3201
|
-
...
|
|
3202
|
-
value:
|
|
3211
|
+
...P.map((F) => ({
|
|
3212
|
+
value: F.value.value,
|
|
3203
3213
|
type: "expression",
|
|
3204
|
-
token: _(
|
|
3214
|
+
token: _(F)
|
|
3205
3215
|
})),
|
|
3206
|
-
...S.map((
|
|
3207
|
-
value:
|
|
3216
|
+
...S.map((F) => ({
|
|
3217
|
+
value: W(F).unwrap(),
|
|
3208
3218
|
type: "column",
|
|
3209
|
-
token: _(
|
|
3219
|
+
token: _(F)
|
|
3210
3220
|
}))
|
|
3211
3221
|
);
|
|
3212
3222
|
}), s;
|
|
3213
3223
|
})), [];
|
|
3214
3224
|
}
|
|
3215
3225
|
registerInlineRefToEnv(e, n, s, i) {
|
|
3216
|
-
const r =
|
|
3226
|
+
const r = Ut(e.symbol, n);
|
|
3217
3227
|
if (this.env.refIds[r])
|
|
3218
3228
|
return [
|
|
3219
3229
|
new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3220
3230
|
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3221
3231
|
];
|
|
3222
|
-
const a =
|
|
3232
|
+
const a = Pt(s.relation);
|
|
3223
3233
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
3224
3234
|
name: null,
|
|
3225
3235
|
schemaName: null,
|
|
@@ -3232,7 +3242,7 @@ class Mt {
|
|
|
3232
3242
|
{
|
|
3233
3243
|
schemaName: this.table.schemaName,
|
|
3234
3244
|
tableName: this.table.name,
|
|
3235
|
-
fieldNames: [
|
|
3245
|
+
fieldNames: [Q(e.callee).unwrap()],
|
|
3236
3246
|
token: _(e),
|
|
3237
3247
|
relation: a[0]
|
|
3238
3248
|
}
|
|
@@ -3242,19 +3252,19 @@ class Mt {
|
|
|
3242
3252
|
}
|
|
3243
3253
|
function Hn(t) {
|
|
3244
3254
|
let e = null;
|
|
3245
|
-
t instanceof
|
|
3255
|
+
t instanceof Z && (e = t.argumentList.elementList.map((r) => fe(r) ? r.expression.literal.value : Y(r) ? $(r).unwrap() : Q(r).unwrap()).join(","), t = t.callee);
|
|
3246
3256
|
let n = "";
|
|
3247
3257
|
for (; t instanceof he; )
|
|
3248
3258
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3249
3259
|
const { name: s, schemaName: i } = Ie(t);
|
|
3250
|
-
return i.length > 1 ? new
|
|
3260
|
+
return i.length > 1 ? new X(
|
|
3251
3261
|
{
|
|
3252
3262
|
schemaName: i.length === 0 ? null : i[0],
|
|
3253
3263
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3254
3264
|
args: e
|
|
3255
3265
|
},
|
|
3256
3266
|
[new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3257
|
-
) : new
|
|
3267
|
+
) : new X({
|
|
3258
3268
|
schemaName: i.length === 0 ? null : i[0],
|
|
3259
3269
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3260
3270
|
args: e
|
|
@@ -3263,9 +3273,9 @@ function Hn(t) {
|
|
|
3263
3273
|
function Jn(t) {
|
|
3264
3274
|
var e, n, s;
|
|
3265
3275
|
if (t) {
|
|
3266
|
-
if (
|
|
3276
|
+
if (Y(t))
|
|
3267
3277
|
return {
|
|
3268
|
-
value:
|
|
3278
|
+
value: $(t).unwrap(),
|
|
3269
3279
|
type: "string"
|
|
3270
3280
|
};
|
|
3271
3281
|
if (fe(t))
|
|
@@ -3278,7 +3288,7 @@ function Jn(t) {
|
|
|
3278
3288
|
value: t.expression.variable.value.toLowerCase(),
|
|
3279
3289
|
type: "boolean"
|
|
3280
3290
|
};
|
|
3281
|
-
if (t instanceof
|
|
3291
|
+
if (t instanceof H && xt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
|
|
3282
3292
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3283
3293
|
return {
|
|
3284
3294
|
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
@@ -3310,8 +3320,8 @@ class Zn {
|
|
|
3310
3320
|
}
|
|
3311
3321
|
interpretSettingList(e) {
|
|
3312
3322
|
var s, i, r;
|
|
3313
|
-
const n =
|
|
3314
|
-
return this.note.headerColor = (s = n.headercolor) != null && s.length ?
|
|
3323
|
+
const n = C(e).getValue();
|
|
3324
|
+
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Be((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
|
|
3315
3325
|
}
|
|
3316
3326
|
interpretBody(e) {
|
|
3317
3327
|
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
@@ -3324,53 +3334,56 @@ class Zn {
|
|
|
3324
3334
|
return this.note.content = ae(n), [];
|
|
3325
3335
|
}
|
|
3326
3336
|
}
|
|
3327
|
-
class
|
|
3337
|
+
class Bt {
|
|
3328
3338
|
constructor(e, n) {
|
|
3329
3339
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3330
3340
|
}
|
|
3331
3341
|
interpret() {
|
|
3332
|
-
return this.ref.token = _(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [
|
|
3342
|
+
return this.ref.token = _(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [
|
|
3343
|
+
...this.interpretName(this.declarationNode.name),
|
|
3344
|
+
...this.interpretBody(this.declarationNode.body)
|
|
3345
|
+
];
|
|
3333
3346
|
}
|
|
3334
3347
|
interpretName(e) {
|
|
3335
|
-
const n = [], s =
|
|
3348
|
+
const n = [], s = z(this.declarationNode.name).unwrap_or([]);
|
|
3336
3349
|
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3337
3350
|
}
|
|
3338
3351
|
interpretBody(e) {
|
|
3339
3352
|
return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3340
3353
|
}
|
|
3341
3354
|
interpretField(e) {
|
|
3342
|
-
var f, E, h, m;
|
|
3343
|
-
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r =
|
|
3344
|
-
if (
|
|
3355
|
+
var f, E, h, m, g, P, S;
|
|
3356
|
+
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ye(s), a = Ye(i);
|
|
3357
|
+
if (Mt(r, a))
|
|
3345
3358
|
return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3346
|
-
const l =
|
|
3359
|
+
const l = Ut(r, a);
|
|
3347
3360
|
if (this.env.refIds[l])
|
|
3348
3361
|
return [
|
|
3349
3362
|
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3350
3363
|
new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
|
|
3351
3364
|
];
|
|
3352
3365
|
if (e.args[0]) {
|
|
3353
|
-
const
|
|
3354
|
-
this.ref.onDelete =
|
|
3355
|
-
const
|
|
3356
|
-
this.ref.onUpdate =
|
|
3366
|
+
const F = C(e.args[0]).getValue(), Le = (E = (f = F.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
|
|
3367
|
+
this.ref.onDelete = Le instanceof q ? Te(Le).unwrap_or(void 0) : Q(Le).unwrap_or(void 0);
|
|
3368
|
+
const B = (m = (h = F.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
|
|
3369
|
+
this.ref.onUpdate = B instanceof q ? Te(B).unwrap_or(void 0) : Q(B).unwrap_or(void 0), this.ref.color = (g = F.color) != null && g.length ? Be((S = (P = F.color) == null ? void 0 : P.at(0)) == null ? void 0 : S.value) : void 0;
|
|
3357
3370
|
}
|
|
3358
|
-
const p =
|
|
3371
|
+
const p = Pt(n);
|
|
3359
3372
|
return this.ref.endpoints = [
|
|
3360
3373
|
{
|
|
3361
|
-
...
|
|
3374
|
+
...Nt(s, this.container),
|
|
3362
3375
|
relation: p[0],
|
|
3363
3376
|
token: _(s)
|
|
3364
3377
|
},
|
|
3365
3378
|
{
|
|
3366
|
-
...
|
|
3379
|
+
...Nt(i, this.container),
|
|
3367
3380
|
relation: p[1],
|
|
3368
3381
|
token: _(i)
|
|
3369
3382
|
}
|
|
3370
3383
|
], this.env.refIds[l] = this.declarationNode, [];
|
|
3371
3384
|
}
|
|
3372
3385
|
}
|
|
3373
|
-
class
|
|
3386
|
+
class Vt {
|
|
3374
3387
|
constructor(e, n) {
|
|
3375
3388
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3376
3389
|
}
|
|
@@ -3399,8 +3412,8 @@ class Bt {
|
|
|
3399
3412
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3400
3413
|
case "note":
|
|
3401
3414
|
this.tableGroup.note = {
|
|
3402
|
-
value:
|
|
3403
|
-
n.body instanceof
|
|
3415
|
+
value: $(
|
|
3416
|
+
n.body instanceof K ? n.body.body[0].callee : n.body.callee
|
|
3404
3417
|
).map(ae).unwrap(),
|
|
3405
3418
|
token: _(n)
|
|
3406
3419
|
};
|
|
@@ -3412,7 +3425,7 @@ class Bt {
|
|
|
3412
3425
|
interpretFields(e) {
|
|
3413
3426
|
const n = [];
|
|
3414
3427
|
return this.tableGroup.tables = e.map((s) => {
|
|
3415
|
-
const i =
|
|
3428
|
+
const i = z(s.callee).unwrap();
|
|
3416
3429
|
i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3417
3430
|
const r = pe(s.callee).unwrap().pop().referee.id;
|
|
3418
3431
|
if (this.env.groupOfTable[r]) {
|
|
@@ -3428,16 +3441,16 @@ class Bt {
|
|
|
3428
3441
|
}
|
|
3429
3442
|
interpretSettingList(e) {
|
|
3430
3443
|
var i, r, a;
|
|
3431
|
-
const n =
|
|
3432
|
-
this.tableGroup.color = (i = n.color) != null && i.length ?
|
|
3444
|
+
const n = C(e).getValue();
|
|
3445
|
+
this.tableGroup.color = (i = n.color) != null && i.length ? Be((a = (r = n.color) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
|
|
3433
3446
|
const [s] = n.note || [];
|
|
3434
3447
|
return this.tableGroup.note = s && {
|
|
3435
|
-
value:
|
|
3448
|
+
value: $(s == null ? void 0 : s.value).map(ae).unwrap(),
|
|
3436
3449
|
token: _(s)
|
|
3437
3450
|
}, [];
|
|
3438
3451
|
}
|
|
3439
3452
|
}
|
|
3440
|
-
class
|
|
3453
|
+
class Gt {
|
|
3441
3454
|
constructor(e, n) {
|
|
3442
3455
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3443
3456
|
}
|
|
@@ -3452,10 +3465,10 @@ class Vt {
|
|
|
3452
3465
|
return e.body.flatMap((n) => {
|
|
3453
3466
|
var l;
|
|
3454
3467
|
const s = n, i = {};
|
|
3455
|
-
i.token = _(s), i.name =
|
|
3456
|
-
const a = (l =
|
|
3468
|
+
i.token = _(s), i.name = Q(s.callee).unwrap();
|
|
3469
|
+
const a = (l = C(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
|
|
3457
3470
|
return i.note = a && {
|
|
3458
|
-
value:
|
|
3471
|
+
value: $(a.value).map(ae).unwrap(),
|
|
3459
3472
|
token: _(a)
|
|
3460
3473
|
}, this.enum.values.push(i), [];
|
|
3461
3474
|
});
|
|
@@ -3480,28 +3493,28 @@ class Kn {
|
|
|
3480
3493
|
const s = n;
|
|
3481
3494
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
3482
3495
|
case "table": {
|
|
3483
|
-
const r = new
|
|
3496
|
+
const r = new Ft(s, this.env).interpret();
|
|
3484
3497
|
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3485
3498
|
}
|
|
3486
3499
|
case "ref": {
|
|
3487
|
-
const r = new
|
|
3500
|
+
const r = new Bt(s, this.env).interpret();
|
|
3488
3501
|
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3489
3502
|
}
|
|
3490
3503
|
case "tablegroup": {
|
|
3491
|
-
const r = new
|
|
3504
|
+
const r = new Vt(s, this.env).interpret();
|
|
3492
3505
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
|
|
3493
3506
|
}
|
|
3494
3507
|
case "enum": {
|
|
3495
|
-
const r = new
|
|
3508
|
+
const r = new Gt(s, this.env).interpret();
|
|
3496
3509
|
return this.project.enums.push(this.env.enums.get(s)), r;
|
|
3497
3510
|
}
|
|
3498
3511
|
case "note":
|
|
3499
3512
|
return this.project.note = {
|
|
3500
|
-
value:
|
|
3513
|
+
value: $(s.body instanceof K ? s.body.body[0].callee : s.body.callee).map(ae).unwrap(),
|
|
3501
3514
|
token: _(s)
|
|
3502
3515
|
}, [];
|
|
3503
3516
|
default:
|
|
3504
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
3517
|
+
return this.project[s.type.value.toLowerCase()] = $(s.body.callee).unwrap(), [];
|
|
3505
3518
|
}
|
|
3506
3519
|
});
|
|
3507
3520
|
}
|
|
@@ -3523,24 +3536,24 @@ class es {
|
|
|
3523
3536
|
}
|
|
3524
3537
|
interpret() {
|
|
3525
3538
|
const e = this.ast.body.flatMap((n) => {
|
|
3526
|
-
switch (
|
|
3539
|
+
switch (we(n).unwrap_or(void 0)) {
|
|
3527
3540
|
case b.Table:
|
|
3528
|
-
return new
|
|
3541
|
+
return new Ft(n, this.env).interpret();
|
|
3529
3542
|
case b.Note:
|
|
3530
3543
|
return new Zn(n, this.env).interpret();
|
|
3531
3544
|
case b.Ref:
|
|
3532
|
-
return new Ft(n, this.env).interpret();
|
|
3533
|
-
case b.TableGroup:
|
|
3534
3545
|
return new Bt(n, this.env).interpret();
|
|
3535
|
-
case b.
|
|
3546
|
+
case b.TableGroup:
|
|
3536
3547
|
return new Vt(n, this.env).interpret();
|
|
3548
|
+
case b.Enum:
|
|
3549
|
+
return new Gt(n, this.env).interpret();
|
|
3537
3550
|
case b.Project:
|
|
3538
3551
|
return new Kn(n, this.env).interpret();
|
|
3539
3552
|
default:
|
|
3540
3553
|
return [];
|
|
3541
3554
|
}
|
|
3542
3555
|
});
|
|
3543
|
-
return new
|
|
3556
|
+
return new X(ts(this.env), e);
|
|
3544
3557
|
}
|
|
3545
3558
|
}
|
|
3546
3559
|
function ts(t) {
|
|
@@ -3556,7 +3569,7 @@ function ts(t) {
|
|
|
3556
3569
|
};
|
|
3557
3570
|
}
|
|
3558
3571
|
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
|
|
3559
|
-
function
|
|
3572
|
+
function ve(t) {
|
|
3560
3573
|
switch (t) {
|
|
3561
3574
|
case T.Schema:
|
|
3562
3575
|
return L.Module;
|
|
@@ -3576,8 +3589,8 @@ function Ae(t) {
|
|
|
3576
3589
|
return L.Text;
|
|
3577
3590
|
}
|
|
3578
3591
|
}
|
|
3579
|
-
function
|
|
3580
|
-
if (!t ||
|
|
3592
|
+
function Pe(t, e) {
|
|
3593
|
+
if (!t || We(t))
|
|
3581
3594
|
return !1;
|
|
3582
3595
|
for (const n of t.trailingTrivia) {
|
|
3583
3596
|
if (n.start > e)
|
|
@@ -3592,7 +3605,7 @@ function D() {
|
|
|
3592
3605
|
suggestions: []
|
|
3593
3606
|
};
|
|
3594
3607
|
}
|
|
3595
|
-
function
|
|
3608
|
+
function Ue(t) {
|
|
3596
3609
|
return {
|
|
3597
3610
|
...t,
|
|
3598
3611
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -3601,65 +3614,65 @@ function Pe(t) {
|
|
|
3601
3614
|
}))
|
|
3602
3615
|
};
|
|
3603
3616
|
}
|
|
3604
|
-
function
|
|
3617
|
+
function Ve(t) {
|
|
3605
3618
|
return {
|
|
3606
3619
|
...t,
|
|
3607
3620
|
suggestions: t.suggestions.map((e) => ({
|
|
3608
3621
|
...e,
|
|
3609
|
-
insertText: e.insertText.split("").every(
|
|
3622
|
+
insertText: e.insertText.split("").every(Fe) ? e.insertText : `"${e.insertText}"`
|
|
3610
3623
|
}))
|
|
3611
3624
|
};
|
|
3612
3625
|
}
|
|
3613
|
-
function
|
|
3626
|
+
function st(t, e) {
|
|
3614
3627
|
return t.getOffsetAt(e);
|
|
3615
3628
|
}
|
|
3616
|
-
class
|
|
3629
|
+
class Ct {
|
|
3617
3630
|
constructor(e, n = []) {
|
|
3618
3631
|
this.compiler = e, this.triggerCharacters = n;
|
|
3619
3632
|
}
|
|
3620
3633
|
provideCompletionItems(e, n) {
|
|
3621
3634
|
var E, h;
|
|
3622
|
-
const s =
|
|
3635
|
+
const s = st(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
|
|
3623
3636
|
if ([
|
|
3624
3637
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3625
3638
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3626
3639
|
...(l == null ? void 0 : l.leadingTrivia) || []
|
|
3627
|
-
].find((m) => Ht(m) &&
|
|
3640
|
+
].find((m) => Ht(m) && _e(s, m)))
|
|
3628
3641
|
return D();
|
|
3629
3642
|
if (a === void 0)
|
|
3630
|
-
return
|
|
3631
|
-
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) &&
|
|
3643
|
+
return Lt();
|
|
3644
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && _e(s, r))
|
|
3632
3645
|
return D();
|
|
3633
3646
|
const p = this.compiler.container.element(s);
|
|
3634
3647
|
if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
|
|
3635
|
-
return
|
|
3648
|
+
return Lt();
|
|
3636
3649
|
const f = [...this.compiler.container.stack(s)].reverse();
|
|
3637
3650
|
for (const m of f)
|
|
3638
|
-
if (m instanceof
|
|
3651
|
+
if (m instanceof H)
|
|
3639
3652
|
switch ((E = m.op) == null ? void 0 : E.value) {
|
|
3640
3653
|
case ">":
|
|
3641
3654
|
case "<":
|
|
3642
3655
|
case "<>":
|
|
3643
3656
|
case "-":
|
|
3644
|
-
return
|
|
3657
|
+
return mt(
|
|
3645
3658
|
this.compiler,
|
|
3646
3659
|
s,
|
|
3647
3660
|
m
|
|
3648
3661
|
);
|
|
3649
3662
|
}
|
|
3650
|
-
else if (m instanceof
|
|
3663
|
+
else if (m instanceof J)
|
|
3651
3664
|
switch ((h = m.op) == null ? void 0 : h.value) {
|
|
3652
3665
|
case ">":
|
|
3653
3666
|
case "<":
|
|
3654
3667
|
case "<>":
|
|
3655
3668
|
case "-":
|
|
3656
|
-
return
|
|
3669
|
+
return mt(
|
|
3657
3670
|
this.compiler,
|
|
3658
3671
|
s,
|
|
3659
3672
|
m
|
|
3660
3673
|
);
|
|
3661
3674
|
case ".":
|
|
3662
|
-
return
|
|
3675
|
+
return Xt(
|
|
3663
3676
|
this.compiler,
|
|
3664
3677
|
s,
|
|
3665
3678
|
m
|
|
@@ -3667,32 +3680,32 @@ class Gt {
|
|
|
3667
3680
|
}
|
|
3668
3681
|
else {
|
|
3669
3682
|
if (m instanceof ie)
|
|
3670
|
-
return
|
|
3671
|
-
if (m instanceof
|
|
3672
|
-
return
|
|
3673
|
-
if (m instanceof
|
|
3683
|
+
return Tt(this.compiler, s, m);
|
|
3684
|
+
if (m instanceof R)
|
|
3685
|
+
return Tt(this.compiler, s, m);
|
|
3686
|
+
if (m instanceof ee)
|
|
3674
3687
|
return ns(this.compiler, s);
|
|
3675
3688
|
if (m instanceof v)
|
|
3676
|
-
return
|
|
3677
|
-
if (m instanceof A && (m.bodyColon && s >= m.bodyColon.end || m.body &&
|
|
3678
|
-
return
|
|
3689
|
+
return It(this.compiler, s, m);
|
|
3690
|
+
if (m instanceof A && (m.bodyColon && s >= m.bodyColon.end || m.body && _e(s, m.body)))
|
|
3691
|
+
return It(this.compiler, s, void 0);
|
|
3679
3692
|
}
|
|
3680
3693
|
return D();
|
|
3681
3694
|
}
|
|
3682
3695
|
}
|
|
3683
|
-
function
|
|
3696
|
+
function mt(t, e, n) {
|
|
3684
3697
|
const s = t.container.scopeKind(e);
|
|
3685
3698
|
if ([O.REF, O.TABLE].includes(s)) {
|
|
3686
|
-
const i =
|
|
3699
|
+
const i = Ge(t, e, t.container.element(e), [
|
|
3687
3700
|
T.Table,
|
|
3688
3701
|
T.Schema,
|
|
3689
3702
|
T.Column
|
|
3690
3703
|
]);
|
|
3691
|
-
return
|
|
3704
|
+
return Pe(n.op, e) ? Ue(i) : i;
|
|
3692
3705
|
}
|
|
3693
3706
|
return D();
|
|
3694
3707
|
}
|
|
3695
|
-
function
|
|
3708
|
+
function Ge(t, e, n, s) {
|
|
3696
3709
|
var a;
|
|
3697
3710
|
if (n === void 0)
|
|
3698
3711
|
return D();
|
|
@@ -3706,61 +3719,61 @@ function Be(t, e, n, s) {
|
|
|
3706
3719
|
label: p,
|
|
3707
3720
|
insertText: p,
|
|
3708
3721
|
insertTextRules: w.KeepWhitespace,
|
|
3709
|
-
kind:
|
|
3710
|
-
sortText:
|
|
3722
|
+
kind: ve(f),
|
|
3723
|
+
sortText: ve(f).toString().padStart(2, "0"),
|
|
3711
3724
|
range: void 0
|
|
3712
3725
|
}))
|
|
3713
3726
|
);
|
|
3714
3727
|
}
|
|
3715
3728
|
i = i instanceof A ? i.parent : void 0;
|
|
3716
3729
|
}
|
|
3717
|
-
return
|
|
3730
|
+
return Ve(r);
|
|
3718
3731
|
}
|
|
3719
3732
|
function ns(t, e) {
|
|
3720
3733
|
var s;
|
|
3721
3734
|
switch (t.container.scopeKind(e)) {
|
|
3722
3735
|
case O.INDEXES:
|
|
3723
|
-
return
|
|
3736
|
+
return Wt(t, e);
|
|
3724
3737
|
case O.REF:
|
|
3725
3738
|
{
|
|
3726
3739
|
const i = [...t.container.stack(e)];
|
|
3727
3740
|
for (; i.length > 0; ) {
|
|
3728
3741
|
const r = i.pop();
|
|
3729
|
-
if (r instanceof
|
|
3730
|
-
return
|
|
3742
|
+
if (r instanceof J && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3743
|
+
return Xt(
|
|
3731
3744
|
t,
|
|
3732
3745
|
e,
|
|
3733
3746
|
r
|
|
3734
3747
|
);
|
|
3735
3748
|
}
|
|
3736
3749
|
}
|
|
3737
|
-
return
|
|
3750
|
+
return $t(t, e);
|
|
3738
3751
|
}
|
|
3739
3752
|
return D();
|
|
3740
3753
|
}
|
|
3741
|
-
function
|
|
3754
|
+
function Tt(t, e, n) {
|
|
3742
3755
|
const { token: s } = t.container.token(e);
|
|
3743
3756
|
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3744
|
-
const i =
|
|
3745
|
-
return (s == null ? void 0 : s.kind) === u.COMMA &&
|
|
3757
|
+
const i = bt(t, e);
|
|
3758
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && Pe(s, e) ? Ue(i) : i;
|
|
3746
3759
|
}
|
|
3747
3760
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3748
|
-
return
|
|
3749
|
-
if (n.name instanceof
|
|
3761
|
+
return bt(t, e);
|
|
3762
|
+
if (n.name instanceof q) {
|
|
3750
3763
|
const i = ss(
|
|
3751
3764
|
t,
|
|
3752
3765
|
e,
|
|
3753
3766
|
Te(n.name).unwrap_or("")
|
|
3754
3767
|
);
|
|
3755
|
-
return (s == null ? void 0 : s.kind) === u.COLON &&
|
|
3768
|
+
return (s == null ? void 0 : s.kind) === u.COLON && Pe(s, e) ? Ue(i) : i;
|
|
3756
3769
|
}
|
|
3757
3770
|
return D();
|
|
3758
3771
|
}
|
|
3759
|
-
function
|
|
3772
|
+
function bt(t, e) {
|
|
3760
3773
|
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3761
|
-
if (n instanceof
|
|
3774
|
+
if (n instanceof j)
|
|
3762
3775
|
return D();
|
|
3763
|
-
if (n.body && !
|
|
3776
|
+
if (n.body && !_e(e, n.body))
|
|
3764
3777
|
switch (s) {
|
|
3765
3778
|
case O.TABLE:
|
|
3766
3779
|
return {
|
|
@@ -3882,21 +3895,21 @@ function ss(t, e, n) {
|
|
|
3882
3895
|
}
|
|
3883
3896
|
return D();
|
|
3884
3897
|
}
|
|
3885
|
-
function
|
|
3898
|
+
function Xt(t, e, n) {
|
|
3886
3899
|
const s = pe(n).unwrap_or([]);
|
|
3887
|
-
if (s.pop(), s.some((r) => !
|
|
3900
|
+
if (s.pop(), s.some((r) => !V(r)))
|
|
3888
3901
|
return D();
|
|
3889
|
-
const i = s.map((r) =>
|
|
3890
|
-
return
|
|
3902
|
+
const i = s.map((r) => Q(r).unwrap());
|
|
3903
|
+
return Ve({
|
|
3891
3904
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3892
3905
|
label: a,
|
|
3893
3906
|
insertText: a,
|
|
3894
|
-
kind:
|
|
3907
|
+
kind: ve(r),
|
|
3895
3908
|
range: void 0
|
|
3896
3909
|
}))
|
|
3897
3910
|
});
|
|
3898
3911
|
}
|
|
3899
|
-
function
|
|
3912
|
+
function It(t, e, n) {
|
|
3900
3913
|
var i;
|
|
3901
3914
|
switch (t.container.scopeKind(e)) {
|
|
3902
3915
|
case O.TABLE:
|
|
@@ -3908,8 +3921,8 @@ function Tt(t, e, n) {
|
|
|
3908
3921
|
case O.ENUM:
|
|
3909
3922
|
return is(t, e, n);
|
|
3910
3923
|
case O.REF: {
|
|
3911
|
-
const r =
|
|
3912
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON &&
|
|
3924
|
+
const r = $t(t, e);
|
|
3925
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Pe(t.container.token(e).token, e) ? Ue(r) : r;
|
|
3913
3926
|
}
|
|
3914
3927
|
case O.TABLEGROUP:
|
|
3915
3928
|
return os(t);
|
|
@@ -3917,7 +3930,7 @@ function Tt(t, e, n) {
|
|
|
3917
3930
|
return D();
|
|
3918
3931
|
}
|
|
3919
3932
|
}
|
|
3920
|
-
function
|
|
3933
|
+
function Lt() {
|
|
3921
3934
|
return {
|
|
3922
3935
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3923
3936
|
label: t,
|
|
@@ -3929,7 +3942,7 @@ function bt() {
|
|
|
3929
3942
|
};
|
|
3930
3943
|
}
|
|
3931
3944
|
function is(t, e, n) {
|
|
3932
|
-
return n != null && n.callee &&
|
|
3945
|
+
return n != null && n.callee && it(e, n) === 1 ? Ge(t, e, t.container.element(e), [
|
|
3933
3946
|
T.Schema,
|
|
3934
3947
|
T.Table,
|
|
3935
3948
|
T.Column
|
|
@@ -3946,7 +3959,7 @@ function rs(t, e, n) {
|
|
|
3946
3959
|
range: void 0
|
|
3947
3960
|
}))
|
|
3948
3961
|
};
|
|
3949
|
-
const s =
|
|
3962
|
+
const s = it(e, n);
|
|
3950
3963
|
return s === 0 ? {
|
|
3951
3964
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3952
3965
|
label: i,
|
|
@@ -3958,7 +3971,7 @@ function rs(t, e, n) {
|
|
|
3958
3971
|
} : s === 1 ? cs(t, e) : D();
|
|
3959
3972
|
}
|
|
3960
3973
|
function as(t, e, n) {
|
|
3961
|
-
return n != null && n.callee ?
|
|
3974
|
+
return n != null && n.callee ? it(e, n) === 0 ? {
|
|
3962
3975
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3963
3976
|
label: i,
|
|
3964
3977
|
insertText: i,
|
|
@@ -3976,8 +3989,8 @@ function as(t, e, n) {
|
|
|
3976
3989
|
}))
|
|
3977
3990
|
};
|
|
3978
3991
|
}
|
|
3979
|
-
function
|
|
3980
|
-
return
|
|
3992
|
+
function $t(t, e) {
|
|
3993
|
+
return Ge(t, e, t.container.element(e), [
|
|
3981
3994
|
T.Schema,
|
|
3982
3995
|
T.Table,
|
|
3983
3996
|
T.Column
|
|
@@ -3986,7 +3999,7 @@ function Xt(t, e) {
|
|
|
3986
3999
|
function os(t) {
|
|
3987
4000
|
return {
|
|
3988
4001
|
suggestions: [
|
|
3989
|
-
...
|
|
4002
|
+
...Ve({
|
|
3990
4003
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3991
4004
|
const n = re(e).unwrap_or(void 0);
|
|
3992
4005
|
if (n === void 0)
|
|
@@ -3996,7 +4009,7 @@ function os(t) {
|
|
|
3996
4009
|
label: i,
|
|
3997
4010
|
insertText: i,
|
|
3998
4011
|
insertTextRules: w.KeepWhitespace,
|
|
3999
|
-
kind:
|
|
4012
|
+
kind: ve(s),
|
|
4000
4013
|
range: void 0
|
|
4001
4014
|
};
|
|
4002
4015
|
})
|
|
@@ -4012,7 +4025,7 @@ function os(t) {
|
|
|
4012
4025
|
};
|
|
4013
4026
|
}
|
|
4014
4027
|
function ls(t, e) {
|
|
4015
|
-
return
|
|
4028
|
+
return Wt(t, e);
|
|
4016
4029
|
}
|
|
4017
4030
|
function cs(t, e) {
|
|
4018
4031
|
return {
|
|
@@ -4082,19 +4095,19 @@ function cs(t, e) {
|
|
|
4082
4095
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
4083
4096
|
range: void 0
|
|
4084
4097
|
})),
|
|
4085
|
-
...
|
|
4098
|
+
...Ge(t, e, t.container.element(e), [
|
|
4086
4099
|
T.Enum,
|
|
4087
4100
|
T.Schema
|
|
4088
4101
|
]).suggestions
|
|
4089
4102
|
]
|
|
4090
4103
|
};
|
|
4091
4104
|
}
|
|
4092
|
-
function
|
|
4105
|
+
function Wt(t, e) {
|
|
4093
4106
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
4094
|
-
if (!((s == null ? void 0 : s.symbol) instanceof
|
|
4107
|
+
if (!((s == null ? void 0 : s.symbol) instanceof yt))
|
|
4095
4108
|
return D();
|
|
4096
4109
|
const { symbolTable: i } = s.symbol;
|
|
4097
|
-
return
|
|
4110
|
+
return Ve({
|
|
4098
4111
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
4099
4112
|
const a = re(r).unwrap_or(void 0);
|
|
4100
4113
|
if (a === void 0)
|
|
@@ -4104,25 +4117,25 @@ function $t(t, e) {
|
|
|
4104
4117
|
label: l,
|
|
4105
4118
|
insertText: l,
|
|
4106
4119
|
insertTextRules: w.KeepWhitespace,
|
|
4107
|
-
kind:
|
|
4120
|
+
kind: ve(T.Column),
|
|
4108
4121
|
range: void 0
|
|
4109
4122
|
};
|
|
4110
4123
|
})
|
|
4111
4124
|
});
|
|
4112
4125
|
}
|
|
4113
|
-
function
|
|
4126
|
+
function it(t, e) {
|
|
4114
4127
|
if (!e.callee)
|
|
4115
4128
|
return -1;
|
|
4116
4129
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
4117
4130
|
return s === -1 ? n.length : s;
|
|
4118
4131
|
}
|
|
4119
|
-
class
|
|
4132
|
+
class jt {
|
|
4120
4133
|
constructor(e) {
|
|
4121
4134
|
this.compiler = e;
|
|
4122
4135
|
}
|
|
4123
4136
|
provideDefinition(e, n) {
|
|
4124
4137
|
var a;
|
|
4125
|
-
const { uri: s } = e, i =
|
|
4138
|
+
const { uri: s } = e, i = st(e, n), r = [...this.compiler.container.stack(i)];
|
|
4126
4139
|
for (; r.length !== 0; ) {
|
|
4127
4140
|
const l = r.pop();
|
|
4128
4141
|
if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(l == null ? void 0 : l.kind)) {
|
|
@@ -4143,12 +4156,12 @@ class Wt {
|
|
|
4143
4156
|
return [];
|
|
4144
4157
|
}
|
|
4145
4158
|
}
|
|
4146
|
-
class
|
|
4159
|
+
class Yt {
|
|
4147
4160
|
constructor(e) {
|
|
4148
4161
|
this.compiler = e;
|
|
4149
4162
|
}
|
|
4150
4163
|
provideReferences(e, n) {
|
|
4151
|
-
const { uri: s } = e, i =
|
|
4164
|
+
const { uri: s } = e, i = st(e, n), r = [...this.compiler.container.stack(i)];
|
|
4152
4165
|
for (; r.length !== 0; ) {
|
|
4153
4166
|
const a = r.pop();
|
|
4154
4167
|
if (a && [
|
|
@@ -4176,9 +4189,9 @@ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4176
4189
|
__proto__: null,
|
|
4177
4190
|
CompletionItemInsertTextRule: w,
|
|
4178
4191
|
CompletionItemKind: L,
|
|
4179
|
-
DBMLCompletionItemProvider:
|
|
4180
|
-
DBMLDefinitionProvider:
|
|
4181
|
-
DBMLReferencesProvider:
|
|
4192
|
+
DBMLCompletionItemProvider: Ct,
|
|
4193
|
+
DBMLDefinitionProvider: jt,
|
|
4194
|
+
DBMLReferencesProvider: Yt
|
|
4182
4195
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4183
4196
|
var O = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(O || {});
|
|
4184
4197
|
class ps {
|
|
@@ -4189,7 +4202,7 @@ class ps {
|
|
|
4189
4202
|
).fill(null), this.nodeIdGenerator = new Jt(), this.symbolIdGenerator = new nn(), this.token = {
|
|
4190
4203
|
invalidStream: this.createQuery(
|
|
4191
4204
|
6,
|
|
4192
|
-
() => this.parse.tokens().filter(
|
|
4205
|
+
() => this.parse.tokens().filter(kt)
|
|
4193
4206
|
),
|
|
4194
4207
|
// Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
|
|
4195
4208
|
flatStream: this.createQuery(
|
|
@@ -4233,8 +4246,8 @@ class ps {
|
|
|
4233
4246
|
let l = this.parse.ast();
|
|
4234
4247
|
const p = [l];
|
|
4235
4248
|
for (; ; ) {
|
|
4236
|
-
const E = fn(l).find((h) =>
|
|
4237
|
-
if (E === void 0 || E instanceof
|
|
4249
|
+
const E = fn(l).find((h) => _e(a, h));
|
|
4250
|
+
if (E === void 0 || E instanceof G)
|
|
4238
4251
|
break;
|
|
4239
4252
|
p.push(E), l = E;
|
|
4240
4253
|
}
|
|
@@ -4242,16 +4255,16 @@ class ps {
|
|
|
4242
4255
|
return p;
|
|
4243
4256
|
for (; p.length > 0; ) {
|
|
4244
4257
|
let f = !1;
|
|
4245
|
-
const E =
|
|
4258
|
+
const E = $e(p);
|
|
4246
4259
|
if (E instanceof v) {
|
|
4247
4260
|
const h = this.parse.source();
|
|
4248
4261
|
for (let m = E.end; m < e; m += 1)
|
|
4249
4262
|
h[m] === `
|
|
4250
4263
|
` && (p.pop(), f = !0);
|
|
4251
4264
|
} else
|
|
4252
|
-
E instanceof
|
|
4265
|
+
E instanceof H || E instanceof J ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof R ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof ee ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof K ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof q || E.end < e && (p.pop(), f = !0);
|
|
4253
4266
|
if (f) {
|
|
4254
|
-
const h =
|
|
4267
|
+
const h = $e(p);
|
|
4255
4268
|
h instanceof A && h.end <= e && p.pop();
|
|
4256
4269
|
}
|
|
4257
4270
|
if (!f)
|
|
@@ -4289,7 +4302,7 @@ class ps {
|
|
|
4289
4302
|
),
|
|
4290
4303
|
scopeKind: this.createQuery(15, (e) => {
|
|
4291
4304
|
var s;
|
|
4292
|
-
if (this.container.element(e) instanceof
|
|
4305
|
+
if (this.container.element(e) instanceof j)
|
|
4293
4306
|
return 8;
|
|
4294
4307
|
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4295
4308
|
case "table":
|
|
@@ -4375,9 +4388,9 @@ class ps {
|
|
|
4375
4388
|
}
|
|
4376
4389
|
initMonacoServices() {
|
|
4377
4390
|
return {
|
|
4378
|
-
definitionProvider: new
|
|
4379
|
-
referenceProvider: new
|
|
4380
|
-
autocompletionProvider: new
|
|
4391
|
+
definitionProvider: new jt(this),
|
|
4392
|
+
referenceProvider: new Yt(this),
|
|
4393
|
+
autocompletionProvider: new Ct(this)
|
|
4381
4394
|
};
|
|
4382
4395
|
}
|
|
4383
4396
|
}
|