@dbml/parse 3.13.3-alpha.0 → 3.13.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/dist/dbml-parse.js +9 -9
- package/dist/dbml-parse.mjs +1133 -1171
- package/dist/src/compiler.d.ts +0 -0
- package/dist/src/constants.d.ts +0 -0
- package/dist/src/index.d.ts +0 -0
- package/dist/src/lib/analyzer/analyzer.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/binder.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/custom.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/elementBinder.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/enum.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/indexes.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/note.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/project.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/ref.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/table.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/tableGroup.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/elementBinder/tablePartial.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/types.d.ts +0 -0
- package/dist/src/lib/analyzer/binder/utils.d.ts +0 -0
- package/dist/src/lib/analyzer/symbol/factory.d.ts +0 -0
- package/dist/src/lib/analyzer/symbol/symbolIndex.d.ts +0 -0
- package/dist/src/lib/analyzer/symbol/symbolTable.d.ts +0 -0
- package/dist/src/lib/analyzer/symbol/symbols.d.ts +0 -0
- package/dist/src/lib/analyzer/symbol/utils.d.ts +0 -0
- package/dist/src/lib/analyzer/types.d.ts +0 -0
- package/dist/src/lib/analyzer/utils.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/custom.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/enum.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/indexes.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/note.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/project.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/ref.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/table.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/tableGroup.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/elementValidators/tablePartial.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/types.d.ts +0 -0
- package/dist/src/lib/analyzer/validator/utils.d.ts +4 -9
- package/dist/src/lib/analyzer/validator/validator.d.ts +0 -0
- package/dist/src/lib/errors.d.ts +0 -0
- package/dist/src/lib/interpreter/elementInterpreter/enum.d.ts +0 -0
- package/dist/src/lib/interpreter/elementInterpreter/project.d.ts +0 -0
- package/dist/src/lib/interpreter/elementInterpreter/ref.d.ts +0 -0
- package/dist/src/lib/interpreter/elementInterpreter/sticky_note.d.ts +0 -0
- package/dist/src/lib/interpreter/elementInterpreter/table.d.ts +0 -0
- package/dist/src/lib/interpreter/elementInterpreter/tableGroup.d.ts +0 -0
- package/dist/src/lib/interpreter/elementInterpreter/tablePartial.d.ts +0 -0
- package/dist/src/lib/interpreter/interpreter.d.ts +0 -0
- package/dist/src/lib/interpreter/types.d.ts +0 -0
- package/dist/src/lib/interpreter/utils.d.ts +8 -1
- package/dist/src/lib/lexer/lexer.d.ts +1 -1
- package/dist/src/lib/lexer/tokens.d.ts +0 -0
- package/dist/src/lib/lexer/utils.d.ts +0 -0
- package/dist/src/lib/option.d.ts +0 -0
- package/dist/src/lib/parser/contextStack.d.ts +0 -0
- package/dist/src/lib/parser/factory.d.ts +0 -0
- package/dist/src/lib/parser/nodes.d.ts +0 -0
- package/dist/src/lib/parser/parser.d.ts +0 -0
- package/dist/src/lib/parser/utils.d.ts +0 -0
- package/dist/src/lib/report.d.ts +0 -0
- package/dist/src/lib/serialization/serialize.d.ts +0 -0
- package/dist/src/lib/types.d.ts +0 -0
- package/dist/src/lib/utils.d.ts +3 -1
- package/dist/src/services/definition/provider.d.ts +0 -0
- package/dist/src/services/index.d.ts +0 -0
- package/dist/src/services/references/provider.d.ts +0 -0
- package/dist/src/services/suggestions/provider.d.ts +0 -0
- package/dist/src/services/suggestions/utils.d.ts +0 -0
- package/dist/src/services/types.d.ts +0 -0
- package/dist/src/services/utils.d.ts +0 -0
- package/dist/tests/NaN_errors/interpreter_NaN.test.d.ts +0 -0
- package/dist/tests/binder/binder.test.d.ts +0 -0
- package/dist/tests/interpreter/interpreter.test.d.ts +0 -0
- package/dist/tests/jestHelpers.d.ts +0 -0
- package/dist/tests/lexer/lexer.test.d.ts +0 -0
- package/dist/tests/parser/parser.test.d.ts +0 -0
- package/dist/tests/validator/validator.test.d.ts +0 -0
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import g, { last as Ve, forIn as
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import g, { last as Ve, forIn as Ge, partition as Pt, head as ln, findLastIndex as cn } from "lodash";
|
|
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.TILDE = "<tilde>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
|
+
function un(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -12,7 +12,7 @@ function on(t) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function hn(t) {
|
|
16
16
|
if (!t)
|
|
17
17
|
return !1;
|
|
18
18
|
switch (t) {
|
|
@@ -33,38 +33,38 @@ function Et(t) {
|
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Et(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class Q {
|
|
40
40
|
constructor(e, n, s, i, a) {
|
|
41
41
|
this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = a, this.start = n.offset, this.end = s.offset;
|
|
42
42
|
}
|
|
43
43
|
static create(e, n, s, i, a) {
|
|
44
|
-
return new
|
|
44
|
+
return new Q(e, n, s, i, a);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return t.trailingTrivia.find(({ kind: e }) => e ===
|
|
47
|
+
function St(t) {
|
|
48
|
+
return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return e.leadingTrivia.find(({ kind: s }) => s ===
|
|
50
|
+
function Nt(t, e) {
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || St(t);
|
|
52
52
|
}
|
|
53
53
|
function et(t) {
|
|
54
|
-
return t.trailingTrivia.find(({ kind: e }) => [
|
|
54
|
+
return t.trailingTrivia.find(({ kind: e }) => [u.SPACE, u.TAB].includes(e)) !== void 0;
|
|
55
55
|
}
|
|
56
56
|
function Dt(t) {
|
|
57
57
|
return t.trailingTrivia.length === 0 ? t.end : Dt(Ve(t.trailingTrivia));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return t.leadingTrivia.length === 0 ? t.start :
|
|
59
|
+
function xt(t) {
|
|
60
|
+
return t.leadingTrivia.length === 0 ? t.start : xt(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return [
|
|
62
|
+
function fn(t) {
|
|
63
|
+
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class pn {
|
|
68
68
|
constructor() {
|
|
69
69
|
this.id = 0;
|
|
70
70
|
}
|
|
@@ -75,32 +75,32 @@ class cn {
|
|
|
75
75
|
return this.id++;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class x {
|
|
79
79
|
// The symbol that this syntax node refers to
|
|
80
80
|
// args must be passed in order of appearance in the node
|
|
81
81
|
constructor(e, n, s) {
|
|
82
82
|
this.id = e, this.kind = n;
|
|
83
83
|
const i = s.find((r) => r !== void 0 && !Number.isNaN(r.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof Q ? xt(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const a = [...s].reverse().find((r) => r !== void 0 && !Number.isNaN(r.end));
|
|
90
|
-
a ? (this.endPos = a.endPos, this.fullEnd = a instanceof
|
|
90
|
+
a ? (this.endPos = a.endPos, this.fullEnd = a instanceof Q ? Dt(a) : a.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
94
94
|
}, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
var
|
|
98
|
-
class
|
|
97
|
+
var me = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t.PARTIAL_INJECTION = "<partial-injection>", t))(me || {});
|
|
98
|
+
class K extends x {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class y extends
|
|
103
|
+
class y extends x {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -109,8 +109,8 @@ class y extends D {
|
|
|
109
109
|
attributeList: a,
|
|
110
110
|
bodyColon: r,
|
|
111
111
|
body: c
|
|
112
|
-
},
|
|
113
|
-
if (super(
|
|
112
|
+
}, f) {
|
|
113
|
+
if (super(f, "<element-declaration>", [
|
|
114
114
|
e,
|
|
115
115
|
n,
|
|
116
116
|
s,
|
|
@@ -123,12 +123,12 @@ class y extends D {
|
|
|
123
123
|
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = a, this.bodyColon = r, this.body = c;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class ne extends
|
|
126
|
+
class ne extends x {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class se extends
|
|
131
|
+
class se extends x {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: n,
|
|
@@ -137,12 +137,12 @@ class se extends D {
|
|
|
137
137
|
super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class
|
|
140
|
+
class Z extends x {
|
|
141
141
|
constructor({ op: e, expression: n }, s) {
|
|
142
142
|
super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class
|
|
145
|
+
class le extends x {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,22 +151,22 @@ class ce extends D {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class
|
|
154
|
+
class qe extends x {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class ue extends
|
|
159
|
+
class ue extends x {
|
|
160
160
|
constructor({ value: e }, n) {
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class w extends
|
|
164
|
+
class w extends x {
|
|
165
165
|
constructor({ callee: e, args: n = [] }, s) {
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class oe extends
|
|
169
|
+
class oe extends x {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -175,12 +175,12 @@ class oe extends D {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class
|
|
178
|
+
class be extends x {
|
|
179
179
|
constructor({ op: e, partial: n }, s) {
|
|
180
180
|
super(s, "<partial-injection>", [e, n]), this.partial = n;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
class M extends
|
|
183
|
+
class M extends x {
|
|
184
184
|
constructor({
|
|
185
185
|
listOpenBracket: e,
|
|
186
186
|
elementList: n = [],
|
|
@@ -189,12 +189,12 @@ class M extends D {
|
|
|
189
189
|
}, a) {
|
|
190
190
|
super(a, "<list-expression>", [
|
|
191
191
|
e,
|
|
192
|
-
...
|
|
192
|
+
...Ot(n, s),
|
|
193
193
|
i
|
|
194
194
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
class
|
|
197
|
+
class ce extends x {
|
|
198
198
|
constructor({
|
|
199
199
|
tupleOpenParen: e,
|
|
200
200
|
elementList: n = [],
|
|
@@ -203,12 +203,12 @@ class pe extends D {
|
|
|
203
203
|
}, a) {
|
|
204
204
|
super(a, "<tuple-expression>", [
|
|
205
205
|
e,
|
|
206
|
-
...
|
|
206
|
+
...Ot(n, s),
|
|
207
207
|
i
|
|
208
208
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
class
|
|
211
|
+
class nt extends ce {
|
|
212
212
|
constructor({
|
|
213
213
|
groupOpenParen: e,
|
|
214
214
|
expression: n,
|
|
@@ -225,7 +225,7 @@ class tt extends pe {
|
|
|
225
225
|
), this.kind = "<group-expression>";
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class ee extends x {
|
|
229
229
|
constructor({
|
|
230
230
|
callee: e,
|
|
231
231
|
argumentList: n
|
|
@@ -233,33 +233,33 @@ class q extends D {
|
|
|
233
233
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class ye extends
|
|
236
|
+
class ye extends x {
|
|
237
237
|
constructor({ literal: e }, n) {
|
|
238
238
|
super(n, "<literal>", [e]), this.literal = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class re extends
|
|
241
|
+
class re extends x {
|
|
242
242
|
constructor({ variable: e }, n) {
|
|
243
243
|
super(n, "<variable>", [e]), this.variable = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class j extends
|
|
246
|
+
class j extends x {
|
|
247
247
|
constructor({ expression: e }, n) {
|
|
248
248
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
class Me extends
|
|
251
|
+
class Me extends x {
|
|
252
252
|
constructor({ pre: e }, n) {
|
|
253
|
-
const s =
|
|
253
|
+
const s = Q.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
254
254
|
super(n, "<dummy>", [s]);
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
class
|
|
257
|
+
class Ie extends x {
|
|
258
258
|
constructor({ expression: e, indexer: n }, s) {
|
|
259
259
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function Ot(t, e) {
|
|
263
263
|
if (!t || t.length === 0)
|
|
264
264
|
return e || [];
|
|
265
265
|
if (!e || e.length === 0)
|
|
@@ -269,12 +269,12 @@ function Rt(t, e) {
|
|
|
269
269
|
(i) => i !== null
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function Ss(t, e = !1) {
|
|
273
273
|
return JSON.stringify(
|
|
274
274
|
t,
|
|
275
275
|
function(n, s) {
|
|
276
276
|
var i;
|
|
277
|
-
return !(this instanceof
|
|
277
|
+
return !(this instanceof K) && n === "symbol" ? s == null ? void 0 : s.id : (
|
|
278
278
|
/* this instanceof SyntaxNode && */
|
|
279
279
|
n === "symbol" ? {
|
|
280
280
|
symbolTable: s == null ? void 0 : s.symbolTable,
|
|
@@ -340,81 +340,81 @@ class S {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t.TablePartial = "TablePartial", t.TablePartialInjection = "TablePartialInjection", t))(m || {});
|
|
343
|
-
function
|
|
343
|
+
function st(t) {
|
|
344
344
|
return `Schema:${t}`;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function Ce(t) {
|
|
347
347
|
return `Table:${t}`;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function He(t) {
|
|
350
350
|
return `Column:${t}`;
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function it(t) {
|
|
353
353
|
return `Enum:${t}`;
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function at(t) {
|
|
356
356
|
return `Enum field:${t}`;
|
|
357
357
|
}
|
|
358
|
-
function
|
|
358
|
+
function rt(t) {
|
|
359
359
|
return `TableGroup:${t}`;
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function ot(t) {
|
|
362
362
|
return `TableGroup field:${t}`;
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function dn(t) {
|
|
365
365
|
return `Note:${t}`;
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function lt(t) {
|
|
368
368
|
return `TablePartial:${t}`;
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function Rt(t) {
|
|
371
371
|
return `TablePartialInjection:${t}`;
|
|
372
372
|
}
|
|
373
373
|
function Fe(t, e) {
|
|
374
374
|
switch (e) {
|
|
375
375
|
case "Column":
|
|
376
|
-
return
|
|
376
|
+
return He(t);
|
|
377
377
|
case "Enum":
|
|
378
|
-
return st(t);
|
|
379
|
-
case "Enum field":
|
|
380
378
|
return it(t);
|
|
379
|
+
case "Enum field":
|
|
380
|
+
return at(t);
|
|
381
381
|
case "Schema":
|
|
382
|
-
return
|
|
382
|
+
return st(t);
|
|
383
383
|
case "Table":
|
|
384
|
-
return
|
|
384
|
+
return Ce(t);
|
|
385
385
|
case "TableGroup":
|
|
386
|
-
return at(t);
|
|
387
|
-
case "TableGroup field":
|
|
388
386
|
return rt(t);
|
|
389
|
-
case "
|
|
387
|
+
case "TableGroup field":
|
|
390
388
|
return ot(t);
|
|
389
|
+
case "TablePartial":
|
|
390
|
+
return lt(t);
|
|
391
391
|
default:
|
|
392
392
|
throw new Error("Unreachable");
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function ie(t) {
|
|
396
396
|
const [e, n] = t.split(":");
|
|
397
397
|
return Object.values(m).includes(e) ? new U({
|
|
398
398
|
name: n,
|
|
399
399
|
kind: e
|
|
400
400
|
}) : new S();
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
const e =
|
|
402
|
+
function En(t) {
|
|
403
|
+
const e = ie(t).unwrap_or(void 0);
|
|
404
404
|
if (!e)
|
|
405
405
|
return !1;
|
|
406
406
|
const { kind: n, name: s } = e;
|
|
407
407
|
return n === "Schema" && s === "public";
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
const e =
|
|
409
|
+
function Nn(t) {
|
|
410
|
+
const e = ie(t).unwrap_or(void 0);
|
|
411
411
|
if (!e)
|
|
412
412
|
return !1;
|
|
413
413
|
const { kind: n } = e;
|
|
414
414
|
return n === "TablePartialInjection";
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
const e =
|
|
416
|
+
function Tn(t) {
|
|
417
|
+
const e = ie(t).unwrap_or(void 0);
|
|
418
418
|
if (!e)
|
|
419
419
|
return null;
|
|
420
420
|
const { kind: n, name: s } = e;
|
|
@@ -424,7 +424,7 @@ function pn(t) {
|
|
|
424
424
|
/* TablePartial */
|
|
425
425
|
) : null;
|
|
426
426
|
}
|
|
427
|
-
class
|
|
427
|
+
class mn {
|
|
428
428
|
constructor() {
|
|
429
429
|
this.id = 0;
|
|
430
430
|
}
|
|
@@ -435,87 +435,87 @@ class dn {
|
|
|
435
435
|
return this.id++;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
class
|
|
438
|
+
class Ut {
|
|
439
439
|
constructor({ symbolTable: e }, n) {
|
|
440
440
|
this.references = [], this.id = n, this.symbolTable = e;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
class
|
|
443
|
+
class bn {
|
|
444
444
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
445
445
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
class
|
|
448
|
+
class In {
|
|
449
449
|
constructor({ declaration: e }, n) {
|
|
450
450
|
this.references = [], this.id = n, this.declaration = e;
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
class
|
|
453
|
+
class Mt {
|
|
454
454
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
455
455
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
class
|
|
458
|
+
class ct {
|
|
459
459
|
constructor({ declaration: e }, n) {
|
|
460
460
|
this.references = [], this.id = n, this.declaration = e;
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
|
-
class
|
|
463
|
+
class Ln {
|
|
464
464
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
465
465
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
class
|
|
468
|
+
class An {
|
|
469
469
|
constructor({ declaration: e }, n) {
|
|
470
470
|
this.references = [], this.id = n, this.declaration = e;
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
class
|
|
473
|
+
class _n {
|
|
474
474
|
constructor({ symbolTable: e, declaration: n }, s) {
|
|
475
475
|
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
class
|
|
478
|
+
class gn {
|
|
479
479
|
constructor({ declaration: e }, n) {
|
|
480
480
|
this.references = [], this.id = n, this.declaration = e;
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
class
|
|
483
|
+
class vn {
|
|
484
484
|
constructor({ injectorFieldSymbol: e, injectorDeclaration: n }, s) {
|
|
485
485
|
this.references = [], this.id = s, this.injectorDeclaration = n, this.injectorFieldSymbol = e;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function wn(t) {
|
|
489
489
|
return [
|
|
490
|
-
nt,
|
|
491
|
-
Ge,
|
|
492
490
|
st,
|
|
493
|
-
|
|
494
|
-
qe,
|
|
491
|
+
Ce,
|
|
495
492
|
it,
|
|
496
493
|
rt,
|
|
494
|
+
He,
|
|
495
|
+
at,
|
|
497
496
|
ot,
|
|
498
|
-
|
|
497
|
+
lt,
|
|
498
|
+
Rt
|
|
499
499
|
].map((e) => e(t));
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
return t instanceof
|
|
501
|
+
function yn(t) {
|
|
502
|
+
return t instanceof ct ? vn : null;
|
|
503
503
|
}
|
|
504
504
|
function ze(t) {
|
|
505
505
|
return !!t.match(/(\p{L}|_|\p{M})/gu);
|
|
506
506
|
}
|
|
507
|
-
function
|
|
507
|
+
function Xe(t) {
|
|
508
508
|
const [e] = t;
|
|
509
509
|
return e >= "0" && e <= "9";
|
|
510
510
|
}
|
|
511
|
-
function
|
|
511
|
+
function kn(t) {
|
|
512
512
|
const [e] = t;
|
|
513
|
-
return
|
|
513
|
+
return Xe(e) || ze(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
514
514
|
}
|
|
515
515
|
function ve(t) {
|
|
516
|
-
return ze(t) ||
|
|
516
|
+
return ze(t) || Xe(t);
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Tt(t, e) {
|
|
519
519
|
const n = [], s = Math.min(t.length, e.length);
|
|
520
520
|
for (let i = 0; i < s; i += 1)
|
|
521
521
|
n.push(t[i], e[i]);
|
|
@@ -524,13 +524,21 @@ function mt(t, e) {
|
|
|
524
524
|
function Se(t, e) {
|
|
525
525
|
return t >= e.start && t < e.end;
|
|
526
526
|
}
|
|
527
|
+
function Ft(t) {
|
|
528
|
+
var e;
|
|
529
|
+
return t instanceof Z ? `${(e = t.op) == null ? void 0 : e.value}${Ft(t.expression)}` : t.expression.literal.value;
|
|
530
|
+
}
|
|
531
|
+
function tt(t) {
|
|
532
|
+
var e;
|
|
533
|
+
return t instanceof Z ? ((e = t.op) == null ? void 0 : e.value) === "-" ? -tt(t.expression) : tt(t.expression) : Number.parseFloat(t.expression.literal.value);
|
|
534
|
+
}
|
|
527
535
|
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.INVALID_TABLE_PARTIAL_CONTEXT = 3060] = "INVALID_TABLE_PARTIAL_CONTEXT", t[t.INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3061] = "INVALID_TABLE_PARTIAL_ELEMENT_NAME", t[t.INVALID_TABLE_PARTIAL_SETTING = 3062] = "INVALID_TABLE_PARTIAL_SETTING", t[t.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3063] = "DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME", t[t.DUPLICATE_TABLE_PARTIAL_SETTING = 3064] = "DUPLICATE_TABLE_PARTIAL_SETTING", t[t.INVALID_TABLE_PARTIAL_INJECTION = 3065] = "INVALID_TABLE_PARTIAL_INJECTION", t[t.INVALID_TABLE_PARTIAL_INJECTION_OP = 3066] = "INVALID_TABLE_PARTIAL_INJECTION_OP", t[t.INVALID_TABLE_PARTIAL_INJECTION_NAME = 3067] = "INVALID_TABLE_PARTIAL_INJECTION_NAME", t[t.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3068] = "DUPLICATE_TABLE_PARTIAL_INJECTION_NAME", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
|
|
528
536
|
class l extends Error {
|
|
529
537
|
constructor(e, n, s) {
|
|
530
538
|
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, l.prototype);
|
|
531
539
|
}
|
|
532
540
|
}
|
|
533
|
-
class
|
|
541
|
+
class J {
|
|
534
542
|
constructor(e, n) {
|
|
535
543
|
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
536
544
|
}
|
|
@@ -542,14 +550,14 @@ class z {
|
|
|
542
550
|
}
|
|
543
551
|
chain(e) {
|
|
544
552
|
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
545
|
-
return new
|
|
553
|
+
return new J(n.value, s);
|
|
546
554
|
}
|
|
547
555
|
map(e) {
|
|
548
|
-
return new
|
|
556
|
+
return new J(e(this.value), this.errors);
|
|
549
557
|
}
|
|
550
558
|
}
|
|
551
|
-
function
|
|
552
|
-
if (!t || !
|
|
559
|
+
function Pn(t, e, n) {
|
|
560
|
+
if (!t || !Ne(t) || e.length === 0)
|
|
553
561
|
return new S();
|
|
554
562
|
const s = [...e], i = Ze(t).unwrap(), a = s.pop();
|
|
555
563
|
if (!(a instanceof oe))
|
|
@@ -579,35 +587,35 @@ function vn(t, e, n) {
|
|
|
579
587
|
})
|
|
580
588
|
) : new S();
|
|
581
589
|
}
|
|
582
|
-
function
|
|
583
|
-
return t.kind ===
|
|
590
|
+
function mt(t) {
|
|
591
|
+
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
584
592
|
}
|
|
585
593
|
function b(t) {
|
|
586
|
-
t && (t instanceof
|
|
594
|
+
t && (t instanceof Q ? Sn(t) : Dn(t));
|
|
587
595
|
}
|
|
588
|
-
function
|
|
589
|
-
t.kind !==
|
|
596
|
+
function Sn(t) {
|
|
597
|
+
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
590
598
|
}
|
|
591
|
-
function
|
|
599
|
+
function Dn(t) {
|
|
592
600
|
if (t instanceof y)
|
|
593
601
|
b(t.type), b(t.name), b(t.as), b(t.alias), b(t.bodyColon), b(t.attributeList), b(t.body);
|
|
594
602
|
else if (t instanceof ne)
|
|
595
603
|
t.identifiers.forEach(b);
|
|
596
604
|
else if (t instanceof se)
|
|
597
605
|
b(t.name), b(t.colon), b(t.value);
|
|
598
|
-
else if (t instanceof
|
|
606
|
+
else if (t instanceof Z)
|
|
599
607
|
b(t.op), b(t.expression);
|
|
600
|
-
else if (t instanceof
|
|
608
|
+
else if (t instanceof le)
|
|
601
609
|
b(t.leftExpression), b(t.op), b(t.rightExpression);
|
|
602
|
-
else if (t instanceof
|
|
610
|
+
else if (t instanceof qe)
|
|
603
611
|
b(t.op), b(t.expression);
|
|
604
612
|
else if (t instanceof oe)
|
|
605
613
|
b(t.blockOpenBrace), t.body.forEach(b), b(t.blockCloseBrace);
|
|
606
614
|
else if (t instanceof M)
|
|
607
615
|
b(t.listOpenBracket), t.commaList.forEach(b), t.elementList.forEach(b), b(t.listCloseBracket);
|
|
608
|
-
else if (t instanceof
|
|
616
|
+
else if (t instanceof ce)
|
|
609
617
|
b(t.tupleOpenParen), t.commaList.forEach(b), t.elementList.forEach(b), b(t.tupleCloseParen);
|
|
610
|
-
else if (t instanceof
|
|
618
|
+
else if (t instanceof ee)
|
|
611
619
|
b(t.callee), b(t.argumentList);
|
|
612
620
|
else if (t instanceof w)
|
|
613
621
|
b(t.callee), t.args.forEach(b);
|
|
@@ -620,19 +628,19 @@ function yn(t) {
|
|
|
620
628
|
else if (t instanceof ye)
|
|
621
629
|
b(t.literal);
|
|
622
630
|
else
|
|
623
|
-
throw t instanceof
|
|
631
|
+
throw t instanceof nt ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
624
632
|
}
|
|
625
633
|
function Bt(t) {
|
|
626
634
|
return !!(t != null && t.isInvalid);
|
|
627
635
|
}
|
|
628
|
-
function
|
|
636
|
+
function C(...t) {
|
|
629
637
|
return t.filter((e) => e !== void 0);
|
|
630
638
|
}
|
|
631
|
-
function
|
|
632
|
-
if (t instanceof
|
|
633
|
-
return
|
|
639
|
+
function xn(t) {
|
|
640
|
+
if (t instanceof K)
|
|
641
|
+
return C(...t.body, t.eof);
|
|
634
642
|
if (t instanceof y)
|
|
635
|
-
return
|
|
643
|
+
return C(
|
|
636
644
|
t.type,
|
|
637
645
|
t.name,
|
|
638
646
|
t.as,
|
|
@@ -642,67 +650,67 @@ function kn(t) {
|
|
|
642
650
|
t.body
|
|
643
651
|
);
|
|
644
652
|
if (t instanceof se)
|
|
645
|
-
return
|
|
653
|
+
return C(t.name, t.colon, t.value);
|
|
646
654
|
if (t instanceof ne)
|
|
647
655
|
return t.identifiers;
|
|
648
656
|
if (t instanceof ye)
|
|
649
657
|
return t.literal ? [t.literal] : [];
|
|
650
658
|
if (t instanceof re)
|
|
651
|
-
return
|
|
652
|
-
if (t instanceof
|
|
653
|
-
return
|
|
654
|
-
if (t instanceof
|
|
655
|
-
return
|
|
656
|
-
if (t instanceof
|
|
657
|
-
return
|
|
659
|
+
return C(t.variable);
|
|
660
|
+
if (t instanceof Z)
|
|
661
|
+
return C(t.op, t.expression);
|
|
662
|
+
if (t instanceof le)
|
|
663
|
+
return C(t.leftExpression, t.op, t.rightExpression);
|
|
664
|
+
if (t instanceof qe)
|
|
665
|
+
return C(t.expression, t.op);
|
|
658
666
|
if (t instanceof ue)
|
|
659
|
-
return
|
|
667
|
+
return C(t.value);
|
|
660
668
|
if (t instanceof w)
|
|
661
|
-
return
|
|
669
|
+
return C(t.callee, ...t.args);
|
|
662
670
|
if (t instanceof oe)
|
|
663
|
-
return
|
|
671
|
+
return C(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
664
672
|
if (t instanceof M)
|
|
665
|
-
return
|
|
673
|
+
return C(
|
|
666
674
|
t.listOpenBracket,
|
|
667
|
-
...
|
|
675
|
+
...Tt(t.elementList, t.commaList),
|
|
668
676
|
t.listCloseBracket
|
|
669
677
|
);
|
|
670
|
-
if (t instanceof
|
|
671
|
-
return
|
|
678
|
+
if (t instanceof ce)
|
|
679
|
+
return C(
|
|
672
680
|
t.tupleOpenParen,
|
|
673
|
-
...
|
|
681
|
+
...Tt(t.elementList, t.commaList),
|
|
674
682
|
t.tupleCloseParen
|
|
675
683
|
);
|
|
676
|
-
if (t instanceof
|
|
677
|
-
return
|
|
684
|
+
if (t instanceof ee)
|
|
685
|
+
return C(t.callee, t.argumentList);
|
|
678
686
|
if (t instanceof j)
|
|
679
|
-
return
|
|
680
|
-
if (t instanceof
|
|
681
|
-
return
|
|
687
|
+
return C(t.expression);
|
|
688
|
+
if (t instanceof Ie)
|
|
689
|
+
return C(
|
|
682
690
|
t.array,
|
|
683
691
|
t.indexer
|
|
684
692
|
);
|
|
685
|
-
if (t instanceof
|
|
686
|
-
return
|
|
687
|
-
throw t instanceof
|
|
693
|
+
if (t instanceof be)
|
|
694
|
+
return C(t.partial);
|
|
695
|
+
throw t instanceof nt ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
688
696
|
}
|
|
689
697
|
function Ze(t) {
|
|
690
|
-
return
|
|
698
|
+
return $(t) ? new U(t.expression.variable) : new S();
|
|
691
699
|
}
|
|
692
|
-
function
|
|
700
|
+
function Y(t) {
|
|
693
701
|
var e;
|
|
694
|
-
return t instanceof j && (t.expression instanceof re && t.expression.variable instanceof
|
|
702
|
+
return t instanceof j && (t.expression instanceof re && t.expression.variable instanceof Q && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof ye && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
695
703
|
}
|
|
696
|
-
function
|
|
697
|
-
return t instanceof j && t.expression instanceof re && t.expression.variable instanceof
|
|
704
|
+
function $(t) {
|
|
705
|
+
return t instanceof j && t.expression instanceof re && t.expression.variable instanceof Q;
|
|
698
706
|
}
|
|
699
|
-
function
|
|
707
|
+
function Ne(t) {
|
|
700
708
|
var e;
|
|
701
|
-
return t instanceof j && t.expression instanceof re && ((e = t.expression.variable) == null ? void 0 : e.kind) ===
|
|
709
|
+
return t instanceof j && t.expression instanceof re && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
702
710
|
}
|
|
703
|
-
function
|
|
711
|
+
function ut(t) {
|
|
704
712
|
var e;
|
|
705
|
-
return t instanceof
|
|
713
|
+
return t instanceof le && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
706
714
|
}
|
|
707
715
|
function we(t) {
|
|
708
716
|
if (t === void 0)
|
|
@@ -710,7 +718,7 @@ function we(t) {
|
|
|
710
718
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
711
719
|
return e === "" ? new S() : new U(e);
|
|
712
720
|
}
|
|
713
|
-
class
|
|
721
|
+
class On {
|
|
714
722
|
// list of errors during lexing
|
|
715
723
|
constructor(e) {
|
|
716
724
|
this.start = {
|
|
@@ -750,7 +758,7 @@ class Pn {
|
|
|
750
758
|
this.tokens.push(this.createToken(e, n));
|
|
751
759
|
}
|
|
752
760
|
createToken(e, n = !1) {
|
|
753
|
-
return
|
|
761
|
+
return Q.create(
|
|
754
762
|
e,
|
|
755
763
|
this.start,
|
|
756
764
|
this.current,
|
|
@@ -759,53 +767,53 @@ class Pn {
|
|
|
759
767
|
);
|
|
760
768
|
}
|
|
761
769
|
lex() {
|
|
762
|
-
return this.scanTokens(), this.tokens.push(
|
|
770
|
+
return this.scanTokens(), this.tokens.push(Q.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new J(this.tokens, this.errors);
|
|
763
771
|
}
|
|
764
772
|
scanTokens() {
|
|
765
773
|
for (; !this.isAtEnd(); ) {
|
|
766
774
|
const e = this.advance();
|
|
767
775
|
switch (e) {
|
|
768
776
|
case " ":
|
|
769
|
-
this.addToken(
|
|
777
|
+
this.addToken(u.SPACE);
|
|
770
778
|
break;
|
|
771
779
|
case "\r":
|
|
772
780
|
break;
|
|
773
781
|
case `
|
|
774
782
|
`:
|
|
775
|
-
this.addToken(
|
|
783
|
+
this.addToken(u.NEWLINE);
|
|
776
784
|
break;
|
|
777
785
|
case " ":
|
|
778
|
-
this.addToken(
|
|
786
|
+
this.addToken(u.TAB);
|
|
779
787
|
break;
|
|
780
788
|
case ",":
|
|
781
|
-
this.addToken(
|
|
789
|
+
this.addToken(u.COMMA);
|
|
782
790
|
break;
|
|
783
791
|
case "(":
|
|
784
|
-
this.addToken(
|
|
792
|
+
this.addToken(u.LPAREN);
|
|
785
793
|
break;
|
|
786
794
|
case ")":
|
|
787
|
-
this.addToken(
|
|
795
|
+
this.addToken(u.RPAREN);
|
|
788
796
|
break;
|
|
789
797
|
case "[":
|
|
790
|
-
this.addToken(
|
|
798
|
+
this.addToken(u.LBRACKET);
|
|
791
799
|
break;
|
|
792
800
|
case "]":
|
|
793
|
-
this.addToken(
|
|
801
|
+
this.addToken(u.RBRACKET);
|
|
794
802
|
break;
|
|
795
803
|
case "{":
|
|
796
|
-
this.addToken(
|
|
804
|
+
this.addToken(u.LBRACE);
|
|
797
805
|
break;
|
|
798
806
|
case "}":
|
|
799
|
-
this.addToken(
|
|
807
|
+
this.addToken(u.RBRACE);
|
|
800
808
|
break;
|
|
801
809
|
case ";":
|
|
802
|
-
this.addToken(
|
|
810
|
+
this.addToken(u.SEMICOLON);
|
|
803
811
|
break;
|
|
804
812
|
case ":":
|
|
805
|
-
this.addToken(
|
|
813
|
+
this.addToken(u.COLON);
|
|
806
814
|
break;
|
|
807
815
|
case "~":
|
|
808
|
-
this.addToken(
|
|
816
|
+
this.addToken(u.TILDE);
|
|
809
817
|
break;
|
|
810
818
|
case "'":
|
|
811
819
|
this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
|
|
@@ -820,26 +828,26 @@ class Pn {
|
|
|
820
828
|
this.colorLiteral();
|
|
821
829
|
break;
|
|
822
830
|
case "/":
|
|
823
|
-
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
|
|
831
|
+
this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator(e);
|
|
824
832
|
break;
|
|
825
833
|
default:
|
|
826
|
-
if (
|
|
827
|
-
this.operator();
|
|
834
|
+
if (hn(e)) {
|
|
835
|
+
this.operator(e);
|
|
828
836
|
break;
|
|
829
837
|
}
|
|
830
838
|
if (ze(e)) {
|
|
831
839
|
this.identifier();
|
|
832
840
|
break;
|
|
833
841
|
}
|
|
834
|
-
if (
|
|
842
|
+
if (Xe(e)) {
|
|
835
843
|
this.numericLiteralOrIdentifier();
|
|
836
844
|
break;
|
|
837
845
|
}
|
|
838
|
-
this.addToken(
|
|
846
|
+
this.addToken(u.OP, !0), this.errors.push(
|
|
839
847
|
new l(
|
|
840
848
|
o.UNKNOWN_SYMBOL,
|
|
841
849
|
`Unexpected token '${e}'`,
|
|
842
|
-
this.createToken(
|
|
850
|
+
this.createToken(u.OP, !0)
|
|
843
851
|
)
|
|
844
852
|
);
|
|
845
853
|
break;
|
|
@@ -851,7 +859,7 @@ class Pn {
|
|
|
851
859
|
let e = !0, n = [], s;
|
|
852
860
|
const i = [];
|
|
853
861
|
for (const a of this.tokens)
|
|
854
|
-
|
|
862
|
+
un(a) ? (n.push(a), a.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? a.leadingTrivia = n : s.trailingTrivia = n, i.push(a), n = [], s = a, e = !1);
|
|
855
863
|
this.tokens = i;
|
|
856
864
|
}
|
|
857
865
|
gatherInvalid() {
|
|
@@ -881,56 +889,56 @@ class Pn {
|
|
|
881
889
|
`)) && !this.check(n); )
|
|
882
890
|
this.peek() === "\\" && !a ? (this.advance(), c += this.escapedString()) : c += this.advance();
|
|
883
891
|
if (this.isAtEnd() && !i) {
|
|
884
|
-
const
|
|
885
|
-
this.tokens.push(
|
|
886
|
-
new l(o.UNEXPECTED_EOF, "EOF reached while parsing",
|
|
892
|
+
const f = this.createToken(e, !0);
|
|
893
|
+
this.tokens.push(f), this.errors.push(
|
|
894
|
+
new l(o.UNEXPECTED_EOF, "EOF reached while parsing", f)
|
|
887
895
|
);
|
|
888
896
|
return;
|
|
889
897
|
}
|
|
890
898
|
if (this.check(`
|
|
891
899
|
`) && !s) {
|
|
892
|
-
const
|
|
893
|
-
this.tokens.push(
|
|
900
|
+
const f = this.createToken(e, !0);
|
|
901
|
+
this.tokens.push(f), this.errors.push(
|
|
894
902
|
new l(
|
|
895
903
|
o.UNEXPECTED_NEWLINE,
|
|
896
904
|
"Invalid newline encountered while parsing",
|
|
897
|
-
|
|
905
|
+
f
|
|
898
906
|
)
|
|
899
907
|
);
|
|
900
908
|
return;
|
|
901
909
|
}
|
|
902
|
-
r && this.match(n), this.tokens.push(
|
|
910
|
+
r && this.match(n), this.tokens.push(Q.create(e, this.start, this.current, c, !1));
|
|
903
911
|
}
|
|
904
912
|
singleLineStringLiteral() {
|
|
905
|
-
this.consumeUntil(
|
|
913
|
+
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
906
914
|
allowNewline: !1,
|
|
907
915
|
allowEof: !1,
|
|
908
916
|
raw: !1
|
|
909
917
|
});
|
|
910
918
|
}
|
|
911
919
|
multilineStringLiteral() {
|
|
912
|
-
this.consumeUntil(
|
|
920
|
+
this.consumeUntil(u.STRING_LITERAL, "'''", {
|
|
913
921
|
allowNewline: !0,
|
|
914
922
|
allowEof: !1,
|
|
915
923
|
raw: !1
|
|
916
924
|
});
|
|
917
925
|
}
|
|
918
926
|
functionExpression() {
|
|
919
|
-
this.consumeUntil(
|
|
927
|
+
this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
|
|
920
928
|
allowNewline: !1,
|
|
921
929
|
allowEof: !1,
|
|
922
930
|
raw: !0
|
|
923
931
|
});
|
|
924
932
|
}
|
|
925
933
|
quotedVariable() {
|
|
926
|
-
this.consumeUntil(
|
|
934
|
+
this.consumeUntil(u.QUOTED_STRING, '"', {
|
|
927
935
|
allowNewline: !1,
|
|
928
936
|
allowEof: !1,
|
|
929
937
|
raw: !1
|
|
930
938
|
});
|
|
931
939
|
}
|
|
932
940
|
singleLineComment() {
|
|
933
|
-
this.consumeUntil(
|
|
941
|
+
this.consumeUntil(u.SINGLE_LINE_COMMENT, `
|
|
934
942
|
`, {
|
|
935
943
|
allowNewline: !0,
|
|
936
944
|
allowEof: !0,
|
|
@@ -939,7 +947,7 @@ class Pn {
|
|
|
939
947
|
});
|
|
940
948
|
}
|
|
941
949
|
multilineComment() {
|
|
942
|
-
this.consumeUntil(
|
|
950
|
+
this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
|
|
943
951
|
allowNewline: !0,
|
|
944
952
|
allowEof: !1,
|
|
945
953
|
raw: !0
|
|
@@ -948,46 +956,58 @@ class Pn {
|
|
|
948
956
|
identifier() {
|
|
949
957
|
for (; !this.isAtEnd() && ve(this.peek()); )
|
|
950
958
|
this.advance();
|
|
951
|
-
this.addToken(
|
|
959
|
+
this.addToken(u.IDENTIFIER);
|
|
952
960
|
}
|
|
953
|
-
operator() {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
961
|
+
operator(e) {
|
|
962
|
+
switch (e) {
|
|
963
|
+
case "<":
|
|
964
|
+
[">", "="].includes(this.peek()) && this.advance();
|
|
965
|
+
break;
|
|
966
|
+
case ">":
|
|
967
|
+
this.peek() === "=" && this.advance();
|
|
968
|
+
break;
|
|
969
|
+
case "=":
|
|
970
|
+
this.peek() === "=" && this.advance();
|
|
971
|
+
break;
|
|
972
|
+
case "!":
|
|
973
|
+
this.peek() === "=" && this.advance();
|
|
974
|
+
break;
|
|
975
|
+
}
|
|
976
|
+
this.addToken(u.OP);
|
|
957
977
|
}
|
|
958
978
|
// we accept identifiers starting with digits but must contain at least one char or underscore
|
|
959
979
|
numericLiteralOrIdentifier() {
|
|
960
980
|
let e = 0;
|
|
961
981
|
if (this.isAtEnd())
|
|
962
|
-
return this.addToken(
|
|
982
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
963
983
|
for (; !this.isAtEnd(); ) {
|
|
964
984
|
const n = this.check(".");
|
|
965
985
|
if (e += n ? 1 : 0, e > 1)
|
|
966
986
|
break;
|
|
967
987
|
if (!n && this.current.offset === this.text.length - 1)
|
|
968
|
-
return this.advance(), this.addToken(
|
|
988
|
+
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
969
989
|
if (!n && !ve(this.peek()))
|
|
970
|
-
return this.addToken(
|
|
971
|
-
if (!n && !
|
|
990
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
991
|
+
if (!n && !Xe(this.peek()))
|
|
972
992
|
break;
|
|
973
993
|
this.advance();
|
|
974
994
|
}
|
|
975
995
|
if (e > 0) {
|
|
976
996
|
for (; !this.isAtEnd() && (this.check(".") || ve(this.peek())); )
|
|
977
997
|
this.advance();
|
|
978
|
-
const n = this.createToken(
|
|
998
|
+
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
979
999
|
this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
980
1000
|
} else {
|
|
981
1001
|
for (; !this.isAtEnd() && ve(this.peek()); )
|
|
982
1002
|
this.advance();
|
|
983
|
-
const n = this.createToken(
|
|
1003
|
+
const n = this.createToken(u.IDENTIFIER, !1);
|
|
984
1004
|
this.tokens.push(n);
|
|
985
1005
|
}
|
|
986
1006
|
}
|
|
987
1007
|
colorLiteral() {
|
|
988
1008
|
for (; !this.isAtEnd() && ve(this.peek()); )
|
|
989
1009
|
this.advance();
|
|
990
|
-
this.addToken(
|
|
1010
|
+
this.addToken(u.COLOR_LITERAL);
|
|
991
1011
|
}
|
|
992
1012
|
escapedString() {
|
|
993
1013
|
const e = { column: this.current.column - 1, offset: this.current.offset - 1, line: this.current.line };
|
|
@@ -1027,7 +1047,7 @@ class Pn {
|
|
|
1027
1047
|
let n = "";
|
|
1028
1048
|
for (let s = 0; s <= 3; s += 1) {
|
|
1029
1049
|
if (this.isAtEnd() || !ve(this.peek()))
|
|
1030
|
-
return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,
|
|
1050
|
+
return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, Q.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
|
|
1031
1051
|
n += this.advance();
|
|
1032
1052
|
}
|
|
1033
1053
|
return String.fromCharCode(parseInt(n, 16));
|
|
@@ -1038,7 +1058,7 @@ class Pn {
|
|
|
1038
1058
|
}
|
|
1039
1059
|
}
|
|
1040
1060
|
var Be = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(Be || {});
|
|
1041
|
-
class
|
|
1061
|
+
class Rn {
|
|
1042
1062
|
constructor() {
|
|
1043
1063
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
1044
1064
|
}
|
|
@@ -1079,7 +1099,7 @@ class Sn {
|
|
|
1079
1099
|
if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
|
|
1080
1100
|
for (let s = n; s < e.length - 1; s += 1)
|
|
1081
1101
|
switch (e[s].kind) {
|
|
1082
|
-
case
|
|
1102
|
+
case u.COMMA:
|
|
1083
1103
|
if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
|
|
1084
1104
|
return [...this.stack].reverse().find(
|
|
1085
1105
|
(a) => [
|
|
@@ -1089,22 +1109,22 @@ class Sn {
|
|
|
1089
1109
|
].includes(a)
|
|
1090
1110
|
);
|
|
1091
1111
|
break;
|
|
1092
|
-
case
|
|
1112
|
+
case u.RPAREN:
|
|
1093
1113
|
if (this.isWithinGroupExpressionContext())
|
|
1094
1114
|
return 1;
|
|
1095
1115
|
break;
|
|
1096
|
-
case
|
|
1116
|
+
case u.RBRACE:
|
|
1097
1117
|
if (this.isWithinBlockExpressionContext())
|
|
1098
1118
|
return 2;
|
|
1099
1119
|
break;
|
|
1100
|
-
case
|
|
1120
|
+
case u.RBRACKET:
|
|
1101
1121
|
if (this.isWithinListExpressionContext())
|
|
1102
1122
|
return 0;
|
|
1103
1123
|
break;
|
|
1104
1124
|
}
|
|
1105
1125
|
}
|
|
1106
1126
|
}
|
|
1107
|
-
class
|
|
1127
|
+
class Un {
|
|
1108
1128
|
constructor(e) {
|
|
1109
1129
|
this.generator = e;
|
|
1110
1130
|
}
|
|
@@ -1112,191 +1132,191 @@ class xn {
|
|
|
1112
1132
|
return new e(n, this.generator.nextId());
|
|
1113
1133
|
}
|
|
1114
1134
|
}
|
|
1115
|
-
class
|
|
1135
|
+
class T {
|
|
1116
1136
|
constructor(e, n, s) {
|
|
1117
1137
|
this.token = e, this.partialNode = n, this.handlerContext = s;
|
|
1118
1138
|
}
|
|
1119
1139
|
}
|
|
1120
|
-
class
|
|
1140
|
+
class Mn {
|
|
1121
1141
|
constructor(e, n) {
|
|
1122
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1142
|
+
this.current = 0, this.errors = [], this.contextStack = new Rn(), this.synchronizeProgram = () => {
|
|
1123
1143
|
const s = this.peek();
|
|
1124
|
-
s.kind !==
|
|
1144
|
+
s.kind !== u.EOF ? b(this.advance()) : (b(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1125
1145
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1126
1146
|
for (; !this.isAtEnd(); ) {
|
|
1127
1147
|
const s = this.peek();
|
|
1128
|
-
if (
|
|
1148
|
+
if (mt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1129
1149
|
break;
|
|
1130
1150
|
b(s), this.advance();
|
|
1131
1151
|
}
|
|
1132
1152
|
}, this.synchronizeElementDeclarationAlias = () => {
|
|
1133
1153
|
for (; !this.isAtEnd(); ) {
|
|
1134
1154
|
const s = this.peek();
|
|
1135
|
-
if (this.check(
|
|
1155
|
+
if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1136
1156
|
break;
|
|
1137
1157
|
b(s), this.advance();
|
|
1138
1158
|
}
|
|
1139
1159
|
}, this.blockExpression = this.contextStack.withContextDo(Be.BlockExpression, () => {
|
|
1140
1160
|
const s = { body: [] }, i = () => this.nodeFactory.create(oe, s);
|
|
1141
1161
|
try {
|
|
1142
|
-
this.consume("Expect an opening brace '{'",
|
|
1162
|
+
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
1143
1163
|
} catch (a) {
|
|
1144
|
-
if (!(a instanceof
|
|
1164
|
+
if (!(a instanceof T))
|
|
1145
1165
|
throw a;
|
|
1146
1166
|
if (s.blockOpenBrace = a.partialNode, !this.canHandle(a))
|
|
1147
|
-
throw new
|
|
1167
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1148
1168
|
this.synchronizeBlock();
|
|
1149
1169
|
}
|
|
1150
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1170
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACE); )
|
|
1151
1171
|
try {
|
|
1152
|
-
if (this.match(
|
|
1153
|
-
const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(
|
|
1172
|
+
if (this.match(u.TILDE)) {
|
|
1173
|
+
const a = this.previous(), r = this.variable(), c = this.nodeFactory.create(be, { op: a, partial: r });
|
|
1154
1174
|
s.body.push(c);
|
|
1155
1175
|
} else
|
|
1156
1176
|
s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
|
|
1157
1177
|
} catch (a) {
|
|
1158
|
-
if (!(a instanceof
|
|
1178
|
+
if (!(a instanceof T))
|
|
1159
1179
|
throw a;
|
|
1160
1180
|
if (s.body.push(a.partialNode), !this.canHandle(a))
|
|
1161
|
-
throw new
|
|
1181
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1162
1182
|
this.synchronizeBlock();
|
|
1163
1183
|
}
|
|
1164
1184
|
try {
|
|
1165
|
-
this.consume("Expect a closing brace '}'",
|
|
1185
|
+
this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
|
|
1166
1186
|
} catch (a) {
|
|
1167
|
-
if (!(a instanceof
|
|
1187
|
+
if (!(a instanceof T))
|
|
1168
1188
|
throw a;
|
|
1169
1189
|
if (s.blockCloseBrace = a.partialNode, !this.canHandle(a))
|
|
1170
|
-
throw new
|
|
1190
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1171
1191
|
this.synchronizeBlock();
|
|
1172
1192
|
}
|
|
1173
1193
|
return i();
|
|
1174
1194
|
}), this.synchronizeBlock = () => {
|
|
1175
|
-
if (!this.check(
|
|
1195
|
+
if (!this.check(u.RBRACE))
|
|
1176
1196
|
for (b(this.advance()); !this.isAtEnd(); ) {
|
|
1177
1197
|
const s = this.peek();
|
|
1178
|
-
if (this.check(
|
|
1198
|
+
if (this.check(u.RBRACE) || Nt(this.previous(), s))
|
|
1179
1199
|
break;
|
|
1180
1200
|
b(s), this.advance();
|
|
1181
1201
|
}
|
|
1182
1202
|
}, this.tupleExpression = this.contextStack.withContextDo(Be.GroupExpression, () => {
|
|
1183
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1203
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(nt, {
|
|
1184
1204
|
groupOpenParen: s.tupleOpenParen,
|
|
1185
1205
|
groupCloseParen: s.tupleCloseParen,
|
|
1186
1206
|
expression: s.elementList[0]
|
|
1187
|
-
}), a = () => this.nodeFactory.create(
|
|
1207
|
+
}), a = () => this.nodeFactory.create(ce, s);
|
|
1188
1208
|
try {
|
|
1189
|
-
this.consume("Expect an opening parenthesis '('",
|
|
1209
|
+
this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
|
|
1190
1210
|
} catch (r) {
|
|
1191
|
-
if (!(r instanceof
|
|
1211
|
+
if (!(r instanceof T))
|
|
1192
1212
|
throw r;
|
|
1193
1213
|
if (s.tupleOpenParen = r.partialNode, !this.canHandle(r))
|
|
1194
|
-
throw new
|
|
1214
|
+
throw new T(r.token, a(), r.handlerContext);
|
|
1195
1215
|
this.synchronizeTuple();
|
|
1196
1216
|
}
|
|
1197
|
-
if (!this.isAtEnd() && !this.check(
|
|
1217
|
+
if (!this.isAtEnd() && !this.check(u.RPAREN))
|
|
1198
1218
|
try {
|
|
1199
1219
|
s.elementList.push(this.normalExpression());
|
|
1200
1220
|
} catch (r) {
|
|
1201
|
-
if (!(r instanceof
|
|
1221
|
+
if (!(r instanceof T))
|
|
1202
1222
|
throw r;
|
|
1203
1223
|
if (s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1204
|
-
throw new
|
|
1224
|
+
throw new T(r.token, i(), r.handlerContext);
|
|
1205
1225
|
this.synchronizeTuple();
|
|
1206
1226
|
}
|
|
1207
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1227
|
+
for (; !this.isAtEnd() && !this.check(u.RPAREN); )
|
|
1208
1228
|
try {
|
|
1209
|
-
this.consume("Expect a comma ','",
|
|
1229
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
|
|
1210
1230
|
} catch (r) {
|
|
1211
|
-
if (!(r instanceof
|
|
1231
|
+
if (!(r instanceof T))
|
|
1212
1232
|
throw r;
|
|
1213
|
-
if (r.partialNode instanceof
|
|
1214
|
-
throw new
|
|
1233
|
+
if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1234
|
+
throw new T(r.token, a(), r.handlerContext);
|
|
1215
1235
|
this.synchronizeTuple();
|
|
1216
1236
|
}
|
|
1217
1237
|
try {
|
|
1218
|
-
this.consume("Expect a closing parenthesis ')'",
|
|
1238
|
+
this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
|
|
1219
1239
|
} catch (r) {
|
|
1220
|
-
if (!(r instanceof
|
|
1240
|
+
if (!(r instanceof T))
|
|
1221
1241
|
throw r;
|
|
1222
1242
|
if (s.tupleCloseParen = r.partialNode, !this.canHandle(r))
|
|
1223
|
-
throw new
|
|
1243
|
+
throw new T(r.token, a(), r.handlerContext);
|
|
1224
1244
|
this.synchronizeTuple();
|
|
1225
1245
|
}
|
|
1226
1246
|
return s.elementList.length === 1 ? i() : a();
|
|
1227
1247
|
}), this.synchronizeTuple = () => {
|
|
1228
1248
|
for (; !this.isAtEnd(); ) {
|
|
1229
1249
|
const s = this.peek();
|
|
1230
|
-
if (this.check(
|
|
1250
|
+
if (this.check(u.RPAREN, u.COMMA))
|
|
1231
1251
|
break;
|
|
1232
1252
|
b(s), this.advance();
|
|
1233
1253
|
}
|
|
1234
1254
|
}, this.listExpression = this.contextStack.withContextDo(Be.ListExpression, () => {
|
|
1235
1255
|
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(M, s);
|
|
1236
1256
|
try {
|
|
1237
|
-
this.consume("Expect an opening bracket '['",
|
|
1257
|
+
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
1238
1258
|
} catch (a) {
|
|
1239
|
-
if (!(a instanceof
|
|
1259
|
+
if (!(a instanceof T))
|
|
1240
1260
|
throw a;
|
|
1241
1261
|
if (s.listOpenBracket = a.partialNode, !this.canHandle(a))
|
|
1242
|
-
throw new
|
|
1262
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1243
1263
|
this.synchronizeList();
|
|
1244
1264
|
}
|
|
1245
|
-
if (!this.isAtEnd() && !this.check(
|
|
1265
|
+
if (!this.isAtEnd() && !this.check(u.RBRACKET))
|
|
1246
1266
|
try {
|
|
1247
1267
|
s.elementList.push(this.attribute());
|
|
1248
1268
|
} catch (a) {
|
|
1249
|
-
if (!(a instanceof
|
|
1269
|
+
if (!(a instanceof T))
|
|
1250
1270
|
throw a;
|
|
1251
1271
|
if (s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1252
|
-
throw new
|
|
1272
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1253
1273
|
this.synchronizeList();
|
|
1254
1274
|
}
|
|
1255
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1275
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
|
|
1256
1276
|
try {
|
|
1257
|
-
this.consume("Expect a comma ','",
|
|
1277
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
|
|
1258
1278
|
} catch (a) {
|
|
1259
|
-
if (!(a instanceof
|
|
1279
|
+
if (!(a instanceof T))
|
|
1260
1280
|
throw a;
|
|
1261
|
-
if (a.partialNode instanceof
|
|
1262
|
-
throw new
|
|
1281
|
+
if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1282
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1263
1283
|
this.synchronizeList();
|
|
1264
1284
|
}
|
|
1265
1285
|
try {
|
|
1266
|
-
this.consume("Expect a closing bracket ']'",
|
|
1286
|
+
this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
|
|
1267
1287
|
} catch (a) {
|
|
1268
|
-
if (!(a instanceof
|
|
1288
|
+
if (!(a instanceof T))
|
|
1269
1289
|
throw a;
|
|
1270
1290
|
if (s.listCloseBracket = a.partialNode, !this.canHandle(a))
|
|
1271
|
-
throw new
|
|
1291
|
+
throw new T(a.token, i(), a.handlerContext);
|
|
1272
1292
|
this.synchronizeList();
|
|
1273
1293
|
}
|
|
1274
1294
|
return i();
|
|
1275
1295
|
}), this.synchronizeList = () => {
|
|
1276
1296
|
for (; !this.isAtEnd(); ) {
|
|
1277
1297
|
const s = this.peek();
|
|
1278
|
-
if (this.check(
|
|
1298
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1279
1299
|
break;
|
|
1280
1300
|
b(s), this.advance();
|
|
1281
1301
|
}
|
|
1282
1302
|
}, this.synchronizeAttributeName = () => {
|
|
1283
1303
|
for (; !this.isAtEnd(); ) {
|
|
1284
1304
|
const s = this.peek();
|
|
1285
|
-
if (this.check(
|
|
1305
|
+
if (this.check(u.COMMA, u.RBRACKET, u.COLON))
|
|
1286
1306
|
break;
|
|
1287
1307
|
b(s), this.advance();
|
|
1288
1308
|
}
|
|
1289
1309
|
}, this.synchronizeAttributeValue = () => {
|
|
1290
1310
|
for (; !this.isAtEnd(); ) {
|
|
1291
1311
|
const s = this.peek();
|
|
1292
|
-
if (this.check(
|
|
1312
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1293
1313
|
break;
|
|
1294
1314
|
b(s), this.advance();
|
|
1295
1315
|
}
|
|
1296
|
-
}, this.tokens = e, this.nodeFactory = new
|
|
1316
|
+
}, this.tokens = e, this.nodeFactory = new Un(n);
|
|
1297
1317
|
}
|
|
1298
1318
|
isAtEnd() {
|
|
1299
|
-
return this.current >= this.tokens.length || this.tokens[this.current].kind ===
|
|
1319
|
+
return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
|
|
1300
1320
|
}
|
|
1301
1321
|
advance() {
|
|
1302
1322
|
return this.isAtEnd() ? g.last(this.tokens) : this.tokens[this.current++];
|
|
@@ -1320,7 +1340,7 @@ class Dn {
|
|
|
1320
1340
|
}
|
|
1321
1341
|
consume(e, ...n) {
|
|
1322
1342
|
if (!this.match(...n))
|
|
1323
|
-
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, e), new
|
|
1343
|
+
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, e), new T(
|
|
1324
1344
|
this.peek(),
|
|
1325
1345
|
void 0,
|
|
1326
1346
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1349,8 +1369,8 @@ class Dn {
|
|
|
1349
1369
|
this.tokens = e;
|
|
1350
1370
|
}
|
|
1351
1371
|
parse() {
|
|
1352
|
-
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(
|
|
1353
|
-
return this.gatherInvalid(), new
|
|
1372
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(K, { body: e, eof: n });
|
|
1373
|
+
return this.gatherInvalid(), new J({ ast: s, tokens: this.tokens }, this.errors);
|
|
1354
1374
|
}
|
|
1355
1375
|
/* Parsing and synchronizing ProgramNode */
|
|
1356
1376
|
program() {
|
|
@@ -1360,7 +1380,7 @@ class Dn {
|
|
|
1360
1380
|
const n = this.elementDeclaration();
|
|
1361
1381
|
e.push(n);
|
|
1362
1382
|
} catch (n) {
|
|
1363
|
-
if (!(n instanceof
|
|
1383
|
+
if (!(n instanceof T))
|
|
1364
1384
|
throw n;
|
|
1365
1385
|
e.push(n.partialNode), this.synchronizeProgram();
|
|
1366
1386
|
}
|
|
@@ -1370,53 +1390,53 @@ class Dn {
|
|
|
1370
1390
|
elementDeclaration() {
|
|
1371
1391
|
const e = {}, n = () => this.nodeFactory.create(y, e);
|
|
1372
1392
|
try {
|
|
1373
|
-
this.consume("Expect an identifier",
|
|
1393
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1374
1394
|
} catch (s) {
|
|
1375
|
-
throw s instanceof
|
|
1395
|
+
throw s instanceof T ? (e.type = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1376
1396
|
}
|
|
1377
|
-
if (!this.check(
|
|
1397
|
+
if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1378
1398
|
try {
|
|
1379
1399
|
e.name = this.normalExpression();
|
|
1380
1400
|
} catch (s) {
|
|
1381
|
-
if (!(s instanceof
|
|
1401
|
+
if (!(s instanceof T))
|
|
1382
1402
|
throw s;
|
|
1383
1403
|
if (e.name = s.partialNode, !this.canHandle(s))
|
|
1384
|
-
throw new
|
|
1404
|
+
throw new T(s.token, n(), s.handlerContext);
|
|
1385
1405
|
this.synchronizeElementDeclarationName();
|
|
1386
1406
|
}
|
|
1387
|
-
if (
|
|
1388
|
-
if (e.as = this.advance(), this.check(
|
|
1407
|
+
if (mt(this.peek()))
|
|
1408
|
+
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1389
1409
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1390
1410
|
else
|
|
1391
1411
|
try {
|
|
1392
1412
|
e.alias = this.normalExpression();
|
|
1393
1413
|
} catch (s) {
|
|
1394
|
-
if (!(s instanceof
|
|
1414
|
+
if (!(s instanceof T))
|
|
1395
1415
|
throw s;
|
|
1396
1416
|
if (e.alias = s.partialNode, !this.canHandle(s))
|
|
1397
|
-
throw new
|
|
1417
|
+
throw new T(s.token, n(), s.handlerContext);
|
|
1398
1418
|
this.synchronizeElementDeclarationAlias();
|
|
1399
1419
|
}
|
|
1400
1420
|
try {
|
|
1401
|
-
e.attributeList = this.check(
|
|
1421
|
+
e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
|
|
1402
1422
|
} catch (s) {
|
|
1403
|
-
throw s instanceof
|
|
1423
|
+
throw s instanceof T ? (e.attributeList = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1404
1424
|
}
|
|
1405
1425
|
if (!this.discardUntil(
|
|
1406
1426
|
"Expect an opening brace '{' or a colon ':'",
|
|
1407
|
-
|
|
1408
|
-
|
|
1427
|
+
u.LBRACE,
|
|
1428
|
+
u.COLON
|
|
1409
1429
|
))
|
|
1410
1430
|
return n();
|
|
1411
1431
|
try {
|
|
1412
|
-
if (this.match(
|
|
1432
|
+
if (this.match(u.COLON)) {
|
|
1413
1433
|
e.bodyColon = this.previous();
|
|
1414
1434
|
const s = this.expression();
|
|
1415
1435
|
s instanceof y ? (b(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
|
|
1416
1436
|
} else
|
|
1417
1437
|
e.body = this.blockExpression();
|
|
1418
1438
|
} catch (s) {
|
|
1419
|
-
throw s instanceof
|
|
1439
|
+
throw s instanceof T ? (e.body = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1420
1440
|
}
|
|
1421
1441
|
return this.nodeFactory.create(y, e);
|
|
1422
1442
|
}
|
|
@@ -1429,32 +1449,32 @@ class Dn {
|
|
|
1429
1449
|
fieldDeclaration() {
|
|
1430
1450
|
const e = {}, n = () => this.nodeFactory.create(y, e);
|
|
1431
1451
|
try {
|
|
1432
|
-
this.consume("Expect an identifier",
|
|
1452
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1433
1453
|
} catch (s) {
|
|
1434
|
-
throw s instanceof
|
|
1454
|
+
throw s instanceof T ? (e.type = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1435
1455
|
}
|
|
1436
1456
|
try {
|
|
1437
|
-
this.consume("Expect a colon ':'",
|
|
1457
|
+
this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
|
|
1438
1458
|
} catch (s) {
|
|
1439
|
-
throw s instanceof
|
|
1459
|
+
throw s instanceof T ? (e.bodyColon = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1440
1460
|
}
|
|
1441
1461
|
try {
|
|
1442
1462
|
const s = this.expression();
|
|
1443
1463
|
s instanceof y ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1444
1464
|
} catch (s) {
|
|
1445
|
-
throw s instanceof
|
|
1465
|
+
throw s instanceof T ? (e.body = s.partialNode, new T(s.token, n(), s.handlerContext)) : s;
|
|
1446
1466
|
}
|
|
1447
1467
|
return this.nodeFactory.create(y, e);
|
|
1448
1468
|
}
|
|
1449
1469
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1450
1470
|
expression() {
|
|
1451
|
-
const e = { args: [] }, n = () =>
|
|
1471
|
+
const e = { args: [] }, n = () => Pn(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1452
1472
|
this.nodeFactory.create(w, e)
|
|
1453
1473
|
);
|
|
1454
1474
|
try {
|
|
1455
1475
|
e.callee = this.normalExpression();
|
|
1456
1476
|
} catch (i) {
|
|
1457
|
-
throw i instanceof
|
|
1477
|
+
throw i instanceof T ? (e.callee = i.partialNode, new T(i.token, n(), i.handlerContext)) : i;
|
|
1458
1478
|
}
|
|
1459
1479
|
if (this.shouldStopExpression())
|
|
1460
1480
|
return n();
|
|
@@ -1464,16 +1484,16 @@ class Dn {
|
|
|
1464
1484
|
try {
|
|
1465
1485
|
s = this.normalExpression(), e.args.push(s);
|
|
1466
1486
|
} catch (i) {
|
|
1467
|
-
throw i instanceof
|
|
1487
|
+
throw i instanceof T ? (s = i.partialNode, e.args.push(s), new T(i.token, n(), i.handlerContext)) : i;
|
|
1468
1488
|
}
|
|
1469
1489
|
}
|
|
1470
1490
|
return n();
|
|
1471
1491
|
}
|
|
1472
1492
|
shouldStopExpression() {
|
|
1473
|
-
if (this.isAtEnd() ||
|
|
1493
|
+
if (this.isAtEnd() || St(this.previous()))
|
|
1474
1494
|
return !0;
|
|
1475
1495
|
const e = this.peek().kind;
|
|
1476
|
-
return e ===
|
|
1496
|
+
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
1477
1497
|
}
|
|
1478
1498
|
normalExpression() {
|
|
1479
1499
|
return this.expression_bp(0);
|
|
@@ -1483,65 +1503,65 @@ class Dn {
|
|
|
1483
1503
|
let n = this.leftExpression_bp();
|
|
1484
1504
|
for (; !this.isAtEnd(); ) {
|
|
1485
1505
|
const s = this.peek();
|
|
1486
|
-
if (s.kind ===
|
|
1487
|
-
const { left: i } =
|
|
1506
|
+
if (s.kind === u.LPAREN) {
|
|
1507
|
+
const { left: i } = bt(s);
|
|
1488
1508
|
if (i < e || // When '(' is encountered,
|
|
1489
1509
|
// consider it part of another expression if
|
|
1490
1510
|
// it's at the start of a new line
|
|
1491
1511
|
// and we're currently not having unmatched '(' or '['
|
|
1492
|
-
|
|
1512
|
+
Nt(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1493
1513
|
break;
|
|
1494
1514
|
try {
|
|
1495
|
-
n = this.nodeFactory.create(
|
|
1515
|
+
n = this.nodeFactory.create(ee, {
|
|
1496
1516
|
callee: n,
|
|
1497
1517
|
argumentList: this.tupleExpression()
|
|
1498
1518
|
});
|
|
1499
1519
|
} catch (a) {
|
|
1500
|
-
throw a instanceof
|
|
1520
|
+
throw a instanceof T ? (n = this.nodeFactory.create(ee, {
|
|
1501
1521
|
callee: n,
|
|
1502
1522
|
argumentList: a.partialNode
|
|
1503
|
-
}), new
|
|
1523
|
+
}), new T(a.token, n, a.handlerContext)) : a;
|
|
1504
1524
|
}
|
|
1505
|
-
} else if (s.kind ===
|
|
1525
|
+
} else if (s.kind === u.LBRACKET) {
|
|
1506
1526
|
if (et(this.previous()))
|
|
1507
1527
|
break;
|
|
1508
1528
|
try {
|
|
1509
|
-
n = this.nodeFactory.create(
|
|
1529
|
+
n = this.nodeFactory.create(Ie, {
|
|
1510
1530
|
expression: n,
|
|
1511
1531
|
indexer: this.listExpression()
|
|
1512
1532
|
});
|
|
1513
1533
|
} catch (i) {
|
|
1514
|
-
throw i instanceof
|
|
1534
|
+
throw i instanceof T ? (n = this.nodeFactory.create(Ie, {
|
|
1515
1535
|
expression: n,
|
|
1516
1536
|
indexer: i.partialNode
|
|
1517
|
-
}), new
|
|
1537
|
+
}), new T(i.token, n, i.handlerContext)) : i;
|
|
1518
1538
|
}
|
|
1519
|
-
} else if (
|
|
1520
|
-
const i = s, a =
|
|
1539
|
+
} else if (Et(s)) {
|
|
1540
|
+
const i = s, a = bt(i);
|
|
1521
1541
|
if (a.left !== null) {
|
|
1522
1542
|
if (a.left <= e)
|
|
1523
1543
|
break;
|
|
1524
|
-
this.advance(), n = this.nodeFactory.create(
|
|
1544
|
+
this.advance(), n = this.nodeFactory.create(qe, {
|
|
1525
1545
|
expression: n,
|
|
1526
1546
|
op: i
|
|
1527
1547
|
});
|
|
1528
1548
|
} else {
|
|
1529
|
-
const r =
|
|
1549
|
+
const r = Bn(i);
|
|
1530
1550
|
if (r.left === null || r.left <= e)
|
|
1531
1551
|
break;
|
|
1532
1552
|
this.advance();
|
|
1533
1553
|
try {
|
|
1534
|
-
n = this.nodeFactory.create(
|
|
1554
|
+
n = this.nodeFactory.create(le, {
|
|
1535
1555
|
leftExpression: n,
|
|
1536
1556
|
op: i,
|
|
1537
1557
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(r.right)
|
|
1538
1558
|
});
|
|
1539
1559
|
} catch (c) {
|
|
1540
|
-
throw c instanceof
|
|
1560
|
+
throw c instanceof T ? (n = this.nodeFactory.create(le, {
|
|
1541
1561
|
leftExpression: n,
|
|
1542
1562
|
op: i,
|
|
1543
1563
|
rightExpression: c.partialNode
|
|
1544
|
-
}), new
|
|
1564
|
+
}), new T(c.token, n, c.handlerContext)) : c;
|
|
1545
1565
|
}
|
|
1546
1566
|
}
|
|
1547
1567
|
} else
|
|
@@ -1551,16 +1571,16 @@ class Dn {
|
|
|
1551
1571
|
}
|
|
1552
1572
|
leftExpression_bp() {
|
|
1553
1573
|
let e;
|
|
1554
|
-
if (
|
|
1574
|
+
if (Et(this.peek())) {
|
|
1555
1575
|
const n = {};
|
|
1556
1576
|
n.op = this.peek();
|
|
1557
|
-
const s =
|
|
1577
|
+
const s = Gn(n.op);
|
|
1558
1578
|
if (s.right === null)
|
|
1559
1579
|
throw this.logError(
|
|
1560
1580
|
n.op,
|
|
1561
1581
|
o.UNKNOWN_PREFIX_OP,
|
|
1562
1582
|
`Unexpected '${n.op.value}' in an expression`
|
|
1563
|
-
), new
|
|
1583
|
+
), new T(
|
|
1564
1584
|
n.op,
|
|
1565
1585
|
this.nodeFactory.create(Me, { pre: n.op }),
|
|
1566
1586
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1569,15 +1589,15 @@ class Dn {
|
|
|
1569
1589
|
try {
|
|
1570
1590
|
n.expression = this.expression_bp(s.right);
|
|
1571
1591
|
} catch (i) {
|
|
1572
|
-
throw i instanceof
|
|
1592
|
+
throw i instanceof T ? (n.expression = i.partialNode, new T(
|
|
1573
1593
|
i.token,
|
|
1574
|
-
this.nodeFactory.create(
|
|
1594
|
+
this.nodeFactory.create(Z, n),
|
|
1575
1595
|
i.handlerContext
|
|
1576
1596
|
)) : i;
|
|
1577
1597
|
}
|
|
1578
|
-
e = this.nodeFactory.create(
|
|
1598
|
+
e = this.nodeFactory.create(Z, n);
|
|
1579
1599
|
} else if (e = this.extractOperand(), e instanceof Me)
|
|
1580
|
-
throw new
|
|
1600
|
+
throw new T(
|
|
1581
1601
|
this.peek(),
|
|
1582
1602
|
this.nodeFactory.create(Me, { pre: this.peek() }),
|
|
1583
1603
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1590,12 +1610,12 @@ class Dn {
|
|
|
1590
1610
|
// e.g { ... }
|
|
1591
1611
|
extractOperand() {
|
|
1592
1612
|
return this.check(
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
) ? this.primaryExpression() : this.check(
|
|
1613
|
+
u.NUMERIC_LITERAL,
|
|
1614
|
+
u.STRING_LITERAL,
|
|
1615
|
+
u.COLOR_LITERAL,
|
|
1616
|
+
u.QUOTED_STRING,
|
|
1617
|
+
u.IDENTIFIER
|
|
1618
|
+
) ? this.primaryExpression() : this.check(u.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(u.LBRACKET) ? this.listExpression() : this.check(u.LBRACE) ? this.blockExpression() : this.check(u.LPAREN) ? this.tupleExpression() : (this.peek().kind === u.EOF ? this.logError(
|
|
1599
1619
|
this.peek(),
|
|
1600
1620
|
o.UNEXPECTED_EOF,
|
|
1601
1621
|
"Unexpected EOF"
|
|
@@ -1609,9 +1629,9 @@ class Dn {
|
|
|
1609
1629
|
functionExpression() {
|
|
1610
1630
|
const e = {};
|
|
1611
1631
|
try {
|
|
1612
|
-
this.consume("Expect a function expression",
|
|
1632
|
+
this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
|
|
1613
1633
|
} catch (n) {
|
|
1614
|
-
throw n instanceof
|
|
1634
|
+
throw n instanceof T ? (e.value = n.partialNode, new T(
|
|
1615
1635
|
n.token,
|
|
1616
1636
|
this.nodeFactory.create(ue, e),
|
|
1617
1637
|
n.handlerContext
|
|
@@ -1620,28 +1640,28 @@ class Dn {
|
|
|
1620
1640
|
return this.nodeFactory.create(ue, e);
|
|
1621
1641
|
}
|
|
1622
1642
|
variable() {
|
|
1623
|
-
this.consume("Expect a variable",
|
|
1643
|
+
this.consume("Expect a variable", u.IDENTIFIER);
|
|
1624
1644
|
const e = this.previous();
|
|
1625
1645
|
return this.nodeFactory.create(re, { variable: e });
|
|
1626
1646
|
}
|
|
1627
1647
|
canBeField() {
|
|
1628
|
-
return this.peek().kind ===
|
|
1648
|
+
return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
|
|
1629
1649
|
}
|
|
1630
1650
|
/* Parsing PrimaryExpression */
|
|
1631
1651
|
primaryExpression() {
|
|
1632
1652
|
if (this.match(
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1653
|
+
u.COLOR_LITERAL,
|
|
1654
|
+
u.STRING_LITERAL,
|
|
1655
|
+
u.NUMERIC_LITERAL
|
|
1636
1656
|
))
|
|
1637
1657
|
return this.nodeFactory.create(j, {
|
|
1638
1658
|
expression: this.nodeFactory.create(ye, { literal: this.previous() })
|
|
1639
1659
|
});
|
|
1640
|
-
if (this.match(
|
|
1660
|
+
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1641
1661
|
return this.nodeFactory.create(j, {
|
|
1642
1662
|
expression: this.nodeFactory.create(re, { variable: this.previous() })
|
|
1643
1663
|
});
|
|
1644
|
-
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new
|
|
1664
|
+
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new T(
|
|
1645
1665
|
this.peek(),
|
|
1646
1666
|
void 0,
|
|
1647
1667
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
@@ -1649,7 +1669,7 @@ class Dn {
|
|
|
1649
1669
|
}
|
|
1650
1670
|
attribute() {
|
|
1651
1671
|
const e = {};
|
|
1652
|
-
if (this.check(
|
|
1672
|
+
if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
|
|
1653
1673
|
const n = this.peek();
|
|
1654
1674
|
this.logError(
|
|
1655
1675
|
n,
|
|
@@ -1660,24 +1680,24 @@ class Dn {
|
|
|
1660
1680
|
try {
|
|
1661
1681
|
e.name = this.attributeName();
|
|
1662
1682
|
} catch (n) {
|
|
1663
|
-
if (!(n instanceof
|
|
1683
|
+
if (!(n instanceof T))
|
|
1664
1684
|
throw n;
|
|
1665
1685
|
if (e.name = n.partialNode, !this.canHandle(n))
|
|
1666
|
-
throw new
|
|
1686
|
+
throw new T(
|
|
1667
1687
|
n.token,
|
|
1668
1688
|
this.nodeFactory.create(se, e),
|
|
1669
1689
|
n.handlerContext
|
|
1670
1690
|
);
|
|
1671
1691
|
this.synchronizeAttributeName();
|
|
1672
1692
|
}
|
|
1673
|
-
return this.match(
|
|
1693
|
+
return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
|
|
1674
1694
|
}
|
|
1675
1695
|
attributeValue() {
|
|
1676
1696
|
let e;
|
|
1677
1697
|
try {
|
|
1678
|
-
e = this.peek().kind ===
|
|
1698
|
+
e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
|
|
1679
1699
|
} catch (n) {
|
|
1680
|
-
if (!(n instanceof
|
|
1700
|
+
if (!(n instanceof T) || !this.canHandle(n))
|
|
1681
1701
|
throw n;
|
|
1682
1702
|
e = n.partialNode, this.synchronizeAttributeValue();
|
|
1683
1703
|
}
|
|
@@ -1685,13 +1705,13 @@ class Dn {
|
|
|
1685
1705
|
}
|
|
1686
1706
|
attributeName() {
|
|
1687
1707
|
const e = [];
|
|
1688
|
-
if (this.peek().kind !==
|
|
1708
|
+
if (this.peek().kind !== u.IDENTIFIER)
|
|
1689
1709
|
return this.primaryExpression();
|
|
1690
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1710
|
+
for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
|
|
1691
1711
|
try {
|
|
1692
|
-
this.consume("Expect an identifier",
|
|
1712
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
|
|
1693
1713
|
} catch (n) {
|
|
1694
|
-
throw n instanceof
|
|
1714
|
+
throw n instanceof T ? new T(
|
|
1695
1715
|
n.token,
|
|
1696
1716
|
this.nodeFactory.create(ne, { identifiers: e }),
|
|
1697
1717
|
n.handlerContext
|
|
@@ -1703,7 +1723,7 @@ class Dn {
|
|
|
1703
1723
|
this.errors.push(new l(n, s, e));
|
|
1704
1724
|
}
|
|
1705
1725
|
}
|
|
1706
|
-
const
|
|
1726
|
+
const Fn = {
|
|
1707
1727
|
"+": { left: 9, right: 10 },
|
|
1708
1728
|
"*": { left: 11, right: 12 },
|
|
1709
1729
|
"-": { left: 9, right: 10 },
|
|
@@ -1719,10 +1739,10 @@ const On = {
|
|
|
1719
1739
|
"!=": { left: 4, right: 5 },
|
|
1720
1740
|
".": { left: 16, right: 17 }
|
|
1721
1741
|
};
|
|
1722
|
-
function
|
|
1723
|
-
return
|
|
1742
|
+
function Bn(t) {
|
|
1743
|
+
return Fn[t.value] || { left: null, right: null };
|
|
1724
1744
|
}
|
|
1725
|
-
const
|
|
1745
|
+
const Vn = {
|
|
1726
1746
|
"+": { left: null, right: 15 },
|
|
1727
1747
|
"-": { left: null, right: 15 },
|
|
1728
1748
|
"<": { left: null, right: 15 },
|
|
@@ -1730,17 +1750,17 @@ const Un = {
|
|
|
1730
1750
|
"<>": { left: null, right: 15 },
|
|
1731
1751
|
"!": { left: null, right: 15 }
|
|
1732
1752
|
};
|
|
1733
|
-
function
|
|
1734
|
-
return
|
|
1753
|
+
function Gn(t) {
|
|
1754
|
+
return Vn[t.value] || { left: null, right: null };
|
|
1735
1755
|
}
|
|
1736
|
-
const
|
|
1756
|
+
const Cn = {
|
|
1737
1757
|
"(": { left: 14, right: null }
|
|
1738
1758
|
};
|
|
1739
|
-
function
|
|
1740
|
-
return
|
|
1759
|
+
function bt(t) {
|
|
1760
|
+
return Cn[t.value] || { left: null, right: null };
|
|
1741
1761
|
}
|
|
1742
|
-
var I = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t.TablePartial = "tablepartial", t))(I || {}),
|
|
1743
|
-
function
|
|
1762
|
+
var I = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t.TablePartial = "tablepartial", t))(I || {}), E = /* @__PURE__ */ ((t) => (t.Color = "color", t.HeaderColor = "headercolor", t.Note = "note", t.PK = "pk", t.PKey = "primary key", t.Unique = "unique", t.Ref = "ref", t.NotNull = "not null", t.Null = "null", t.Increment = "increment", t.Default = "default", t.Name = "name", t.Type = "type", t.Update = "update", t.Delete = "delete", t))(E || {});
|
|
1763
|
+
function Le(t) {
|
|
1744
1764
|
var n;
|
|
1745
1765
|
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1746
1766
|
switch (e) {
|
|
@@ -1757,46 +1777,46 @@ function _e(t) {
|
|
|
1757
1777
|
return new S();
|
|
1758
1778
|
}
|
|
1759
1779
|
}
|
|
1760
|
-
function
|
|
1761
|
-
if (!
|
|
1780
|
+
function _e(t) {
|
|
1781
|
+
if (!ut(t))
|
|
1762
1782
|
return new U([t]);
|
|
1763
|
-
const e =
|
|
1783
|
+
const e = _e(t.leftExpression).unwrap_or(void 0);
|
|
1764
1784
|
return e ? (e.push(t.rightExpression), new U(e)) : new S();
|
|
1765
1785
|
}
|
|
1766
|
-
function
|
|
1786
|
+
function q(t) {
|
|
1767
1787
|
if (t === void 0)
|
|
1768
1788
|
return new S();
|
|
1769
|
-
const e =
|
|
1789
|
+
const e = _e(t).unwrap_or(void 0);
|
|
1770
1790
|
if (!e)
|
|
1771
1791
|
return new S();
|
|
1772
1792
|
const n = [];
|
|
1773
1793
|
for (const s of e) {
|
|
1774
|
-
const i =
|
|
1794
|
+
const i = W(s).unwrap_or(void 0);
|
|
1775
1795
|
if (!i)
|
|
1776
1796
|
return new S();
|
|
1777
1797
|
n.push(i);
|
|
1778
1798
|
}
|
|
1779
1799
|
return new U(n);
|
|
1780
1800
|
}
|
|
1781
|
-
function
|
|
1801
|
+
function De(t) {
|
|
1782
1802
|
if (t === void 0)
|
|
1783
1803
|
return new S();
|
|
1784
|
-
const e =
|
|
1804
|
+
const e = _e(t).unwrap_or(void 0);
|
|
1785
1805
|
if (!e || e.length === 0)
|
|
1786
1806
|
return new S();
|
|
1787
1807
|
const n = [];
|
|
1788
1808
|
let s;
|
|
1789
|
-
if (
|
|
1809
|
+
if (!$(g.last(e))) {
|
|
1790
1810
|
const i = e.pop();
|
|
1791
1811
|
if ($t(i))
|
|
1792
1812
|
s = i.elementList.map(
|
|
1793
|
-
(a) =>
|
|
1813
|
+
(a) => X(a).unwrap()
|
|
1794
1814
|
);
|
|
1795
1815
|
else
|
|
1796
1816
|
return new S();
|
|
1797
1817
|
}
|
|
1798
1818
|
for (const i of e) {
|
|
1799
|
-
const a =
|
|
1819
|
+
const a = W(i).unwrap_or(void 0);
|
|
1800
1820
|
if (!a)
|
|
1801
1821
|
return new S();
|
|
1802
1822
|
n.push(a);
|
|
@@ -1806,62 +1826,62 @@ function xe(t) {
|
|
|
1806
1826
|
tupleElements: s
|
|
1807
1827
|
});
|
|
1808
1828
|
}
|
|
1809
|
-
function
|
|
1810
|
-
return
|
|
1829
|
+
function W(t) {
|
|
1830
|
+
return $(t) ? new U(t.expression.variable.value) : new S();
|
|
1811
1831
|
}
|
|
1812
|
-
function
|
|
1813
|
-
if (
|
|
1832
|
+
function $e(t) {
|
|
1833
|
+
if (It(t))
|
|
1814
1834
|
return t instanceof ue ? new U({ functional: [t], nonFunctional: [] }) : new U({ functional: [], nonFunctional: [t] });
|
|
1815
|
-
if (t instanceof
|
|
1835
|
+
if (t instanceof ce && t.elementList.every(It)) {
|
|
1816
1836
|
const e = t.elementList.filter(
|
|
1817
1837
|
(s) => s instanceof ue
|
|
1818
|
-
), n = t.elementList.filter(
|
|
1838
|
+
), n = t.elementList.filter($);
|
|
1819
1839
|
return new U({ functional: e, nonFunctional: n });
|
|
1820
1840
|
}
|
|
1821
1841
|
return new S();
|
|
1822
1842
|
}
|
|
1823
|
-
function
|
|
1843
|
+
function X(t) {
|
|
1824
1844
|
var n;
|
|
1825
1845
|
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1826
1846
|
return e === void 0 ? new S() : new U(e);
|
|
1827
1847
|
}
|
|
1828
|
-
function
|
|
1848
|
+
function Xn(t) {
|
|
1829
1849
|
var n, s;
|
|
1830
1850
|
const e = (s = (n = t == null ? void 0 : t.partial) == null ? void 0 : n.variable) == null ? void 0 : s.value;
|
|
1831
1851
|
return e === void 0 ? new S() : new U(e);
|
|
1832
1852
|
}
|
|
1833
|
-
function
|
|
1834
|
-
return
|
|
1853
|
+
function V(t) {
|
|
1854
|
+
return Y(t) ? t.expression instanceof re ? new U(t.expression.variable.value) : new U(t.expression.literal.value) : new S();
|
|
1835
1855
|
}
|
|
1836
|
-
function
|
|
1856
|
+
function $n(t) {
|
|
1837
1857
|
var e;
|
|
1838
|
-
return !(t instanceof
|
|
1858
|
+
return !(t instanceof le) || !Gt((e = t.op) == null ? void 0 : e.value) ? !1 : De(t.leftExpression).and_then(() => De(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1839
1859
|
}
|
|
1840
|
-
function
|
|
1841
|
-
const e =
|
|
1860
|
+
function jn(t) {
|
|
1861
|
+
const e = De(t.leftExpression), n = De(t.rightExpression);
|
|
1842
1862
|
if (!e.isOk() || !n.isOk())
|
|
1843
1863
|
return !1;
|
|
1844
1864
|
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1845
1865
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1846
1866
|
}
|
|
1847
|
-
function
|
|
1867
|
+
function It(t) {
|
|
1848
1868
|
return t instanceof j && t.expression instanceof re || t instanceof ue;
|
|
1849
1869
|
}
|
|
1850
|
-
function
|
|
1870
|
+
function Lt(t, e) {
|
|
1851
1871
|
var i, a, r, c;
|
|
1852
1872
|
let n = e;
|
|
1853
|
-
const s =
|
|
1873
|
+
const s = En(t);
|
|
1854
1874
|
for (; n; ) {
|
|
1855
1875
|
if ((a = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && a.has(t))
|
|
1856
1876
|
return (r = n.symbol.symbolTable) == null ? void 0 : r.get(t);
|
|
1857
|
-
if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof
|
|
1877
|
+
if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof K && s)
|
|
1858
1878
|
return n.symbol;
|
|
1859
|
-
if (n instanceof
|
|
1879
|
+
if (n instanceof K)
|
|
1860
1880
|
return;
|
|
1861
1881
|
n = n.parent;
|
|
1862
1882
|
}
|
|
1863
1883
|
}
|
|
1864
|
-
class
|
|
1884
|
+
class Wn {
|
|
1865
1885
|
constructor(e, n, s) {
|
|
1866
1886
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1867
1887
|
}
|
|
@@ -1869,7 +1889,7 @@ class Cn {
|
|
|
1869
1889
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1870
1890
|
}
|
|
1871
1891
|
validateContext() {
|
|
1872
|
-
return this.declarationNode.parent instanceof
|
|
1892
|
+
return this.declarationNode.parent instanceof K || Le(this.declarationNode.parent).unwrap_or(void 0) !== I.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1873
1893
|
}
|
|
1874
1894
|
validateName(e) {
|
|
1875
1895
|
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
@@ -1886,7 +1906,7 @@ class Cn {
|
|
|
1886
1906
|
if (e instanceof oe)
|
|
1887
1907
|
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1888
1908
|
const n = [];
|
|
1889
|
-
return
|
|
1909
|
+
return Y(e.callee) || n.push(new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1890
1910
|
}
|
|
1891
1911
|
}
|
|
1892
1912
|
class ke {
|
|
@@ -1909,7 +1929,7 @@ class ke {
|
|
|
1909
1929
|
return this.table.forEach(e);
|
|
1910
1930
|
}
|
|
1911
1931
|
}
|
|
1912
|
-
class
|
|
1932
|
+
class Yn {
|
|
1913
1933
|
constructor(e, n, s) {
|
|
1914
1934
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1915
1935
|
}
|
|
@@ -1927,10 +1947,10 @@ class Xn {
|
|
|
1927
1947
|
}
|
|
1928
1948
|
registerElement() {
|
|
1929
1949
|
const e = [];
|
|
1930
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1931
|
-
const { name: n } = this.declarationNode, s =
|
|
1950
|
+
this.declarationNode.symbol = this.symbolFactory.create(bn, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
1951
|
+
const { name: n } = this.declarationNode, s = q(n);
|
|
1932
1952
|
if (s.isOk()) {
|
|
1933
|
-
const i = s.unwrap(), a = i.pop(), r = Qe(i, this.publicSymbolTable, this.symbolFactory), c =
|
|
1953
|
+
const i = s.unwrap(), a = i.pop(), r = Qe(i, this.publicSymbolTable, this.symbolFactory), c = it(a);
|
|
1934
1954
|
r.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${a} already exists in schema '${i.join(".") || "public"}'`, n)), r.set(c, this.declarationNode.symbol);
|
|
1935
1955
|
}
|
|
1936
1956
|
return e;
|
|
@@ -1949,19 +1969,19 @@ class Xn {
|
|
|
1949
1969
|
validateFields(e) {
|
|
1950
1970
|
return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1951
1971
|
const s = [];
|
|
1952
|
-
n.callee &&
|
|
1972
|
+
n.callee && !$(n.callee) && s.push(new l(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1953
1973
|
const i = [...n.args];
|
|
1954
1974
|
return g.last(i) instanceof M ? (s.push(...this.validateFieldSettings(g.last(i))), i.pop()) : i[0] instanceof M && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((a) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", a))), s.push(...this.registerField(n)), s;
|
|
1955
1975
|
});
|
|
1956
1976
|
}
|
|
1957
1977
|
validateFieldSettings(e) {
|
|
1958
|
-
const n =
|
|
1978
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
1959
1979
|
for (const a in i) {
|
|
1960
1980
|
const r = i[a];
|
|
1961
1981
|
switch (a) {
|
|
1962
1982
|
case "note":
|
|
1963
1983
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), r.forEach((c) => {
|
|
1964
|
-
|
|
1984
|
+
Y(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1965
1985
|
});
|
|
1966
1986
|
break;
|
|
1967
1987
|
default:
|
|
@@ -1974,13 +1994,13 @@ class Xn {
|
|
|
1974
1994
|
return e.flatMap((n) => {
|
|
1975
1995
|
if (n.parent = this.declarationNode, !n.type)
|
|
1976
1996
|
return [];
|
|
1977
|
-
const s =
|
|
1997
|
+
const s = he(n);
|
|
1978
1998
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1979
1999
|
});
|
|
1980
2000
|
}
|
|
1981
2001
|
registerField(e) {
|
|
1982
|
-
if (e.callee &&
|
|
1983
|
-
const n =
|
|
2002
|
+
if (e.callee && $(e.callee)) {
|
|
2003
|
+
const n = X(e.callee).unwrap(), s = at(n), i = this.symbolFactory.create(In, { declaration: e });
|
|
1984
2004
|
e.symbol = i;
|
|
1985
2005
|
const a = this.declarationNode.symbol.symbolTable;
|
|
1986
2006
|
if (a.has(s)) {
|
|
@@ -1995,7 +2015,7 @@ class Xn {
|
|
|
1995
2015
|
return [];
|
|
1996
2016
|
}
|
|
1997
2017
|
}
|
|
1998
|
-
class
|
|
2018
|
+
class qn {
|
|
1999
2019
|
constructor(e, n, s) {
|
|
2000
2020
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2001
2021
|
}
|
|
@@ -2014,9 +2034,9 @@ class $n {
|
|
|
2014
2034
|
"An Indexes can only appear inside a Table or a TablePartial",
|
|
2015
2035
|
this.declarationNode
|
|
2016
2036
|
);
|
|
2017
|
-
if (this.declarationNode.parent instanceof
|
|
2037
|
+
if (this.declarationNode.parent instanceof K)
|
|
2018
2038
|
return [e];
|
|
2019
|
-
const n =
|
|
2039
|
+
const n = Le(this.declarationNode.parent).unwrap_or(void 0);
|
|
2020
2040
|
return n && [I.Table, I.TablePartial].includes(n) ? [] : [e];
|
|
2021
2041
|
}
|
|
2022
2042
|
validateName(e) {
|
|
@@ -2042,32 +2062,32 @@ class $n {
|
|
|
2042
2062
|
return [];
|
|
2043
2063
|
const s = [], i = [n.callee, ...n.args];
|
|
2044
2064
|
return g.last(i) instanceof M && s.push(...this.validateFieldSetting(i.pop())), i.forEach((a) => {
|
|
2045
|
-
for (; a instanceof
|
|
2046
|
-
a.argumentList &&
|
|
2047
|
-
|
|
2065
|
+
for (; a instanceof ee; )
|
|
2066
|
+
a.argumentList && !$e(a.argumentList).isOk() && s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", a.argumentList)), a = a.callee;
|
|
2067
|
+
$e(a).isOk() || s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", a));
|
|
2048
2068
|
}), s;
|
|
2049
2069
|
});
|
|
2050
2070
|
}
|
|
2051
2071
|
validateFieldSetting(e) {
|
|
2052
|
-
const n =
|
|
2072
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2053
2073
|
for (const a in i) {
|
|
2054
2074
|
const r = i[a];
|
|
2055
2075
|
switch (a) {
|
|
2056
2076
|
case "note":
|
|
2057
2077
|
case "name":
|
|
2058
2078
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
|
|
2059
|
-
|
|
2079
|
+
Y(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${a}' must be a string`, c));
|
|
2060
2080
|
});
|
|
2061
2081
|
break;
|
|
2062
2082
|
case "unique":
|
|
2063
2083
|
case "pk":
|
|
2064
2084
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
|
|
2065
|
-
|
|
2085
|
+
z(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${a}' must not have a value`, c));
|
|
2066
2086
|
});
|
|
2067
2087
|
break;
|
|
2068
2088
|
case "type":
|
|
2069
2089
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), r.forEach((c) => {
|
|
2070
|
-
|
|
2090
|
+
$(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
|
|
2071
2091
|
});
|
|
2072
2092
|
break;
|
|
2073
2093
|
default:
|
|
@@ -2080,12 +2100,12 @@ class $n {
|
|
|
2080
2100
|
return e.flatMap((n) => {
|
|
2081
2101
|
if (n.parent = this.declarationNode, !n.type)
|
|
2082
2102
|
return [];
|
|
2083
|
-
const s =
|
|
2103
|
+
const s = he(n);
|
|
2084
2104
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2085
2105
|
});
|
|
2086
2106
|
}
|
|
2087
2107
|
}
|
|
2088
|
-
class
|
|
2108
|
+
class Hn {
|
|
2089
2109
|
constructor(e, n, s) {
|
|
2090
2110
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2091
2111
|
}
|
|
@@ -2099,26 +2119,26 @@ class jn {
|
|
|
2099
2119
|
];
|
|
2100
2120
|
}
|
|
2101
2121
|
validateContext() {
|
|
2102
|
-
return !(this.declarationNode.parent instanceof
|
|
2122
|
+
return !(this.declarationNode.parent instanceof K) && ![
|
|
2103
2123
|
I.Table,
|
|
2104
2124
|
I.TableGroup,
|
|
2105
2125
|
I.TablePartial,
|
|
2106
2126
|
I.Project
|
|
2107
|
-
].includes(
|
|
2127
|
+
].includes(Le(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
|
|
2108
2128
|
o.INVALID_NOTE_CONTEXT,
|
|
2109
2129
|
"A Note can only appear inside a Table, a TableGroup, a TablePartial or a Project. Sticky note can only appear at the global scope.",
|
|
2110
2130
|
this.declarationNode
|
|
2111
2131
|
)] : [];
|
|
2112
2132
|
}
|
|
2113
2133
|
validateName(e) {
|
|
2114
|
-
if (!(this.declarationNode.parent instanceof
|
|
2134
|
+
if (!(this.declarationNode.parent instanceof K))
|
|
2115
2135
|
return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2116
2136
|
if (!e)
|
|
2117
2137
|
return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2118
|
-
const n =
|
|
2138
|
+
const n = q(e);
|
|
2119
2139
|
if (!n.isOk())
|
|
2120
2140
|
return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2121
|
-
const i = n.unwrap().join("."), a =
|
|
2141
|
+
const i = n.unwrap().join("."), a = dn(i);
|
|
2122
2142
|
return this.publicSymbolTable.has(a) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(a, this.declarationNode.symbol), []);
|
|
2123
2143
|
}
|
|
2124
2144
|
validateAlias(e) {
|
|
@@ -2137,18 +2157,18 @@ class jn {
|
|
|
2137
2157
|
}
|
|
2138
2158
|
validateFields(e) {
|
|
2139
2159
|
const n = [];
|
|
2140
|
-
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))),
|
|
2160
|
+
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), Y(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2141
2161
|
}
|
|
2142
2162
|
validateSubElements(e) {
|
|
2143
2163
|
return e.flatMap((n) => {
|
|
2144
2164
|
if (n.parent = this.declarationNode, !n.type)
|
|
2145
2165
|
return [];
|
|
2146
|
-
const s =
|
|
2166
|
+
const s = he(n);
|
|
2147
2167
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2148
2168
|
});
|
|
2149
2169
|
}
|
|
2150
2170
|
}
|
|
2151
|
-
class
|
|
2171
|
+
class zn {
|
|
2152
2172
|
constructor(e, n, s) {
|
|
2153
2173
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2154
2174
|
}
|
|
@@ -2182,12 +2202,12 @@ class Wn {
|
|
|
2182
2202
|
return e.flatMap((n) => {
|
|
2183
2203
|
if (n.parent = this.declarationNode, !n.type)
|
|
2184
2204
|
return [];
|
|
2185
|
-
const s =
|
|
2205
|
+
const s = he(n);
|
|
2186
2206
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2187
2207
|
});
|
|
2188
2208
|
}
|
|
2189
2209
|
}
|
|
2190
|
-
class
|
|
2210
|
+
class Qn {
|
|
2191
2211
|
constructor(e, n, s) {
|
|
2192
2212
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2193
2213
|
}
|
|
@@ -2195,7 +2215,7 @@ class Yn {
|
|
|
2195
2215
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2196
2216
|
}
|
|
2197
2217
|
validateContext() {
|
|
2198
|
-
return this.declarationNode.parent instanceof
|
|
2218
|
+
return this.declarationNode.parent instanceof K ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2199
2219
|
}
|
|
2200
2220
|
validateName(e) {
|
|
2201
2221
|
return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
@@ -2219,7 +2239,7 @@ class Yn {
|
|
|
2219
2239
|
return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2220
2240
|
const n = [];
|
|
2221
2241
|
return e.length > 1 && n.push(...e.slice(1).map((s) => new l(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
|
|
2222
|
-
s.callee &&
|
|
2242
|
+
s.callee && !$n(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !jn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2223
2243
|
const i = [...s.args];
|
|
2224
2244
|
if (g.last(i) instanceof M) {
|
|
2225
2245
|
const a = this.validateFieldSettings(g.last(i));
|
|
@@ -2230,14 +2250,14 @@ class Yn {
|
|
|
2230
2250
|
}), n;
|
|
2231
2251
|
}
|
|
2232
2252
|
validateFieldSettings(e) {
|
|
2233
|
-
const n =
|
|
2253
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2234
2254
|
for (const a in i) {
|
|
2235
2255
|
const r = i[a];
|
|
2236
2256
|
switch (a) {
|
|
2237
2257
|
case "delete":
|
|
2238
2258
|
case "update":
|
|
2239
2259
|
r.length > 1 && r.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${a}' can only appear once`, c))), r.forEach((c) => {
|
|
2240
|
-
|
|
2260
|
+
Jn(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${a}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
|
|
2241
2261
|
});
|
|
2242
2262
|
break;
|
|
2243
2263
|
case "color":
|
|
@@ -2255,13 +2275,13 @@ class Yn {
|
|
|
2255
2275
|
return e.flatMap((n) => {
|
|
2256
2276
|
if (n.parent = this.declarationNode, !n.type)
|
|
2257
2277
|
return [];
|
|
2258
|
-
const s =
|
|
2278
|
+
const s = he(n);
|
|
2259
2279
|
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2260
2280
|
});
|
|
2261
2281
|
}
|
|
2262
2282
|
}
|
|
2263
|
-
function
|
|
2264
|
-
if (!(
|
|
2283
|
+
function Jn(t) {
|
|
2284
|
+
if (!($(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof ne))
|
|
2265
2285
|
return !1;
|
|
2266
2286
|
let e;
|
|
2267
2287
|
if (t instanceof ne ? e = we(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
@@ -2277,7 +2297,7 @@ function qn(t) {
|
|
|
2277
2297
|
}
|
|
2278
2298
|
return !1;
|
|
2279
2299
|
}
|
|
2280
|
-
class
|
|
2300
|
+
class Kn {
|
|
2281
2301
|
constructor(e, n, s) {
|
|
2282
2302
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2283
2303
|
}
|
|
@@ -2295,42 +2315,40 @@ class zn {
|
|
|
2295
2315
|
return this.declarationNode.parent instanceof y ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2296
2316
|
}
|
|
2297
2317
|
validateName(e) {
|
|
2298
|
-
return e ? e instanceof
|
|
2318
|
+
return e ? e instanceof Ie ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Vt(e) ? [] : [new l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
|
|
2299
2319
|
}
|
|
2300
2320
|
validateAlias(e) {
|
|
2301
|
-
return e ?
|
|
2321
|
+
return e ? ss(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2302
2322
|
}
|
|
2303
2323
|
validateSettingList(e) {
|
|
2304
|
-
const n =
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
r.length > 1 && s.push(...r.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), r.forEach((c) => {
|
|
2324
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2325
|
+
return Ge(i, (a, r) => {
|
|
2326
|
+
switch (r) {
|
|
2327
|
+
case E.HeaderColor:
|
|
2328
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
|
|
2310
2329
|
Je(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
|
|
2311
2330
|
});
|
|
2312
2331
|
break;
|
|
2313
|
-
case
|
|
2314
|
-
|
|
2315
|
-
|
|
2332
|
+
case E.Note:
|
|
2333
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
2334
|
+
Y(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2316
2335
|
});
|
|
2317
2336
|
break;
|
|
2318
2337
|
default:
|
|
2319
|
-
s.push(...
|
|
2338
|
+
s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
|
|
2320
2339
|
}
|
|
2321
|
-
}
|
|
2322
|
-
return s;
|
|
2340
|
+
}), s;
|
|
2323
2341
|
}
|
|
2324
2342
|
registerElement() {
|
|
2325
2343
|
const e = [];
|
|
2326
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2327
|
-
const { name: n, alias: s } = this.declarationNode, i =
|
|
2344
|
+
this.declarationNode.symbol = this.symbolFactory.create(Mt, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
2345
|
+
const { name: n, alias: s } = this.declarationNode, i = q(n);
|
|
2328
2346
|
if (i.isOk()) {
|
|
2329
|
-
const a = [...i.unwrap()], r = a.pop(), c = Qe(a, this.publicSymbolTable, this.symbolFactory),
|
|
2330
|
-
c.has(
|
|
2347
|
+
const a = [...i.unwrap()], r = a.pop(), c = Qe(a, this.publicSymbolTable, this.symbolFactory), f = Ce(r);
|
|
2348
|
+
c.has(f) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists in schema '${a.join(".") || "public"}'`, n)), c.set(f, this.declarationNode.symbol);
|
|
2331
2349
|
}
|
|
2332
|
-
if (s && Pe(s) && !
|
|
2333
|
-
const a =
|
|
2350
|
+
if (s && Pe(s) && !Zn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2351
|
+
const a = X(s).unwrap(), r = Ce(a);
|
|
2334
2352
|
this.publicSymbolTable.has(r) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists`, n)), this.publicSymbolTable.set(r, this.declarationNode.symbol);
|
|
2335
2353
|
}
|
|
2336
2354
|
return e;
|
|
@@ -2340,7 +2358,7 @@ class zn {
|
|
|
2340
2358
|
return [];
|
|
2341
2359
|
if (e instanceof w)
|
|
2342
2360
|
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2343
|
-
const [n, s, i] = e.body.reduce((a, r) => (r instanceof w ? a[0].push(r) : r instanceof
|
|
2361
|
+
const [n, s, i] = e.body.reduce((a, r) => (r instanceof w ? a[0].push(r) : r instanceof be ? a[1].push(r) : r instanceof y && a[2].push(r), a), [[], [], []]);
|
|
2344
2362
|
return [
|
|
2345
2363
|
...this.validateFields(n),
|
|
2346
2364
|
...this.validateInjections(s),
|
|
@@ -2351,10 +2369,10 @@ class zn {
|
|
|
2351
2369
|
return e.flatMap((n) => this.registerInjection(n));
|
|
2352
2370
|
}
|
|
2353
2371
|
registerInjection(e) {
|
|
2354
|
-
var c,
|
|
2355
|
-
if (!((
|
|
2372
|
+
var c, f, p;
|
|
2373
|
+
if (!((f = (c = e.partial) == null ? void 0 : c.variable) != null && f.value))
|
|
2356
2374
|
return [];
|
|
2357
|
-
const n = (
|
|
2375
|
+
const n = (p = e.partial.variable) == null ? void 0 : p.value, s = Rt(n), i = this.symbolFactory.create(gn, { declaration: e });
|
|
2358
2376
|
e.symbol = i;
|
|
2359
2377
|
const a = this.declarationNode.symbol.symbolTable, r = a.get(s);
|
|
2360
2378
|
return r ? [
|
|
@@ -2363,18 +2381,18 @@ class zn {
|
|
|
2363
2381
|
] : (a.set(s, i), []);
|
|
2364
2382
|
}
|
|
2365
2383
|
validateFields(e) {
|
|
2366
|
-
return e.
|
|
2384
|
+
return e.flatMap((n) => {
|
|
2367
2385
|
if (!n.callee)
|
|
2368
2386
|
return [];
|
|
2369
2387
|
const s = [];
|
|
2370
|
-
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)),
|
|
2388
|
+
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), $(n.callee) || s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !jt(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2371
2389
|
const i = n.args.slice(1);
|
|
2372
2390
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2373
2391
|
});
|
|
2374
2392
|
}
|
|
2375
2393
|
registerField(e) {
|
|
2376
|
-
if (e.callee &&
|
|
2377
|
-
const n =
|
|
2394
|
+
if (e.callee && $(e.callee)) {
|
|
2395
|
+
const n = X(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(ct, { declaration: e });
|
|
2378
2396
|
e.symbol = i;
|
|
2379
2397
|
const a = this.declarationNode.symbol.symbolTable;
|
|
2380
2398
|
if (a.has(s)) {
|
|
@@ -2390,84 +2408,90 @@ class zn {
|
|
|
2390
2408
|
}
|
|
2391
2409
|
// This is needed to support legacy inline settings
|
|
2392
2410
|
validateFieldSetting(e) {
|
|
2393
|
-
if (!e.slice(0, -1).every(
|
|
2394
|
-
return [...e.map((
|
|
2411
|
+
if (!e.slice(0, -1).every(Ne) || !e.slice(-1).every((f) => Ne(f) || f instanceof M))
|
|
2412
|
+
return [...e.map((f) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", f))];
|
|
2395
2413
|
if (e.length === 0)
|
|
2396
2414
|
return [];
|
|
2397
2415
|
let n;
|
|
2398
2416
|
g.last(e) instanceof M && (n = e.pop());
|
|
2399
|
-
const s =
|
|
2400
|
-
|
|
2401
|
-
const
|
|
2402
|
-
if (
|
|
2403
|
-
i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`",
|
|
2404
|
-
|
|
2417
|
+
const s = F(n), i = s.getErrors(), a = s.getValue();
|
|
2418
|
+
e.forEach((f) => {
|
|
2419
|
+
const p = X(f).unwrap_or("").toLowerCase();
|
|
2420
|
+
if (p !== "pk" && p !== "unique") {
|
|
2421
|
+
i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", f));
|
|
2422
|
+
return;
|
|
2405
2423
|
}
|
|
2406
|
-
a[
|
|
2407
|
-
}
|
|
2408
|
-
const r = a.
|
|
2409
|
-
r.length >= 1 && c.length >= 1 && i.push(
|
|
2410
|
-
|
|
2411
|
-
|
|
2424
|
+
a[p] === void 0 ? a[p] = [f] : a[p].push(f);
|
|
2425
|
+
});
|
|
2426
|
+
const r = a[E.PK] || [], c = a[E.PKey] || [];
|
|
2427
|
+
return r.length >= 1 && c.length >= 1 && i.push(
|
|
2428
|
+
...[...r, ...c].map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", f))
|
|
2429
|
+
), Ge(a, (f, p) => {
|
|
2412
2430
|
switch (p) {
|
|
2413
|
-
case
|
|
2414
|
-
f.length > 1 && i.push(...f.map((
|
|
2415
|
-
|
|
2431
|
+
case E.Note:
|
|
2432
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
|
|
2433
|
+
Y(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
|
|
2416
2434
|
});
|
|
2417
2435
|
break;
|
|
2418
|
-
case
|
|
2419
|
-
f.forEach((
|
|
2420
|
-
Xt(
|
|
2436
|
+
case E.Ref:
|
|
2437
|
+
f.forEach((h) => {
|
|
2438
|
+
Xt(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
|
|
2421
2439
|
});
|
|
2422
2440
|
break;
|
|
2423
|
-
case
|
|
2424
|
-
f.length > 1 && i.push(...f.map((
|
|
2425
|
-
|
|
2441
|
+
case E.PKey:
|
|
2442
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", h))), f.forEach((h) => {
|
|
2443
|
+
z(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
|
|
2426
2444
|
});
|
|
2427
2445
|
break;
|
|
2428
|
-
case
|
|
2429
|
-
f.length > 1 && i.push(...f.map((
|
|
2430
|
-
|
|
2446
|
+
case E.PK:
|
|
2447
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
|
|
2448
|
+
h instanceof se && !z(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
|
|
2431
2449
|
});
|
|
2432
2450
|
break;
|
|
2433
|
-
case
|
|
2434
|
-
f.length > 1 && i.push(...f.map((
|
|
2435
|
-
const
|
|
2436
|
-
f.length >= 1 &&
|
|
2437
|
-
|
|
2451
|
+
case E.NotNull: {
|
|
2452
|
+
f.length > 1 && i.push(...f.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", d)));
|
|
2453
|
+
const h = a[E.Null] || [];
|
|
2454
|
+
f.length >= 1 && h.length >= 1 && i.push(
|
|
2455
|
+
...[...f, ...h].map((d) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", d))
|
|
2456
|
+
), f.forEach((d) => {
|
|
2457
|
+
z(d.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", d.value || d.name));
|
|
2438
2458
|
});
|
|
2439
2459
|
break;
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2460
|
+
}
|
|
2461
|
+
case E.Null:
|
|
2462
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", h))), f.forEach((h) => {
|
|
2463
|
+
z(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
|
|
2443
2464
|
});
|
|
2444
2465
|
break;
|
|
2445
|
-
case
|
|
2446
|
-
f.length > 1 && i.push(...f.map((
|
|
2447
|
-
|
|
2466
|
+
case E.Unique:
|
|
2467
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
|
|
2468
|
+
h instanceof se && !z(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
|
|
2448
2469
|
});
|
|
2449
2470
|
break;
|
|
2450
|
-
case
|
|
2451
|
-
f.length > 1 && i.push(...f.map((
|
|
2452
|
-
|
|
2471
|
+
case E.Increment:
|
|
2472
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
|
|
2473
|
+
h instanceof se && !z(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
|
|
2453
2474
|
});
|
|
2454
2475
|
break;
|
|
2455
|
-
case
|
|
2456
|
-
f.length > 1 && i.push(...f.map((
|
|
2457
|
-
Ct(
|
|
2476
|
+
case E.Default:
|
|
2477
|
+
f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
|
|
2478
|
+
Ct(h.value) || i.push(new l(
|
|
2479
|
+
o.INVALID_TABLE_SETTING,
|
|
2480
|
+
"'default' must be a string literal, number literal, function expression, true, false or null",
|
|
2481
|
+
h.value || h.name
|
|
2482
|
+
));
|
|
2458
2483
|
});
|
|
2459
2484
|
break;
|
|
2460
2485
|
default:
|
|
2461
|
-
f.forEach((
|
|
2486
|
+
f.forEach((h) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, h)));
|
|
2462
2487
|
}
|
|
2463
|
-
}
|
|
2464
|
-
return i;
|
|
2488
|
+
}), i;
|
|
2465
2489
|
}
|
|
2466
2490
|
validateSubElements(e) {
|
|
2467
2491
|
const n = e.flatMap((i) => {
|
|
2468
2492
|
if (i.parent = this.declarationNode, !i.type)
|
|
2469
2493
|
return [];
|
|
2470
|
-
const a =
|
|
2494
|
+
const a = he(i);
|
|
2471
2495
|
return new a(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2472
2496
|
}), s = e.filter((i) => {
|
|
2473
2497
|
var a;
|
|
@@ -2476,26 +2500,10 @@ class zn {
|
|
|
2476
2500
|
return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2477
2501
|
}
|
|
2478
2502
|
}
|
|
2479
|
-
function
|
|
2480
|
-
if (!(t instanceof q || He(t) || t instanceof j || t instanceof he))
|
|
2481
|
-
return !1;
|
|
2482
|
-
if (t instanceof q) {
|
|
2483
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ee(n) || C(n) || fe(n)))
|
|
2484
|
-
return !1;
|
|
2485
|
-
t = t.callee;
|
|
2486
|
-
}
|
|
2487
|
-
for (; t instanceof he; ) {
|
|
2488
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ee(n.name)))
|
|
2489
|
-
return !1;
|
|
2490
|
-
t = t.array;
|
|
2491
|
-
}
|
|
2492
|
-
const e = H(t).unwrap_or(void 0);
|
|
2493
|
-
return e !== void 0 && e.length > 0;
|
|
2494
|
-
}
|
|
2495
|
-
function Qn(t, e) {
|
|
2503
|
+
function Zn(t, e) {
|
|
2496
2504
|
return e.length === 1 && t === e[0];
|
|
2497
2505
|
}
|
|
2498
|
-
class
|
|
2506
|
+
class es {
|
|
2499
2507
|
constructor(e, n, s) {
|
|
2500
2508
|
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2501
2509
|
}
|
|
@@ -2536,10 +2544,10 @@ class Jn {
|
|
|
2536
2544
|
}
|
|
2537
2545
|
registerElement() {
|
|
2538
2546
|
const { name: e } = this.declarationNode;
|
|
2539
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2540
|
-
const n =
|
|
2547
|
+
this.declarationNode.symbol = this.symbolFactory.create(Ln, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
2548
|
+
const n = q(e);
|
|
2541
2549
|
if (n.isOk()) {
|
|
2542
|
-
const s = n.unwrap(), i = s.pop(), a = Qe(s, this.publicSymbolTable, this.symbolFactory), r =
|
|
2550
|
+
const s = n.unwrap(), i = s.pop(), a = Qe(s, this.publicSymbolTable, this.symbolFactory), r = rt(i);
|
|
2543
2551
|
if (a.has(r))
|
|
2544
2552
|
return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
|
|
2545
2553
|
a.set(r, this.declarationNode.symbol);
|
|
@@ -2547,7 +2555,7 @@ class Jn {
|
|
|
2547
2555
|
return [];
|
|
2548
2556
|
}
|
|
2549
2557
|
validateSettingList(e) {
|
|
2550
|
-
const n =
|
|
2558
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2551
2559
|
return g.forIn(i, (a, r) => {
|
|
2552
2560
|
switch (r) {
|
|
2553
2561
|
case "color":
|
|
@@ -2568,7 +2576,7 @@ class Jn {
|
|
|
2568
2576
|
o.DUPLICATE_TABLE_SETTING,
|
|
2569
2577
|
"'note' can only appear once",
|
|
2570
2578
|
c
|
|
2571
|
-
))), a.filter((c) => !
|
|
2579
|
+
))), a.filter((c) => !Y(c.value)).forEach((c) => {
|
|
2572
2580
|
s.push(new l(
|
|
2573
2581
|
o.INVALID_TABLE_SETTING,
|
|
2574
2582
|
"'note' must be a string literal",
|
|
@@ -2604,14 +2612,14 @@ class Jn {
|
|
|
2604
2612
|
validateFields(e) {
|
|
2605
2613
|
return e.flatMap((n) => {
|
|
2606
2614
|
const s = [];
|
|
2607
|
-
return n.callee && !
|
|
2615
|
+
return n.callee && !q(n.callee).isOk() && s.push(new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
|
|
2608
2616
|
});
|
|
2609
2617
|
}
|
|
2610
2618
|
validateSubElements(e) {
|
|
2611
2619
|
const n = e.flatMap((i) => {
|
|
2612
2620
|
if (i.parent = this.declarationNode, !i.type)
|
|
2613
2621
|
return [];
|
|
2614
|
-
const a =
|
|
2622
|
+
const a = he(i);
|
|
2615
2623
|
return new a(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2616
2624
|
}), s = e.filter((i) => {
|
|
2617
2625
|
var a;
|
|
@@ -2620,8 +2628,8 @@ class Jn {
|
|
|
2620
2628
|
return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2621
2629
|
}
|
|
2622
2630
|
registerField(e) {
|
|
2623
|
-
if (e.callee &&
|
|
2624
|
-
const n =
|
|
2631
|
+
if (e.callee && $(e.callee)) {
|
|
2632
|
+
const n = X(e.callee).unwrap(), s = ot(n), i = this.symbolFactory.create(An, { declaration: e });
|
|
2625
2633
|
e.symbol = i;
|
|
2626
2634
|
const a = this.declarationNode.symbol.symbolTable;
|
|
2627
2635
|
if (a.has(s)) {
|
|
@@ -2636,24 +2644,8 @@ class Jn {
|
|
|
2636
2644
|
return [];
|
|
2637
2645
|
}
|
|
2638
2646
|
}
|
|
2639
|
-
const
|
|
2640
|
-
|
|
2641
|
-
if (!(t instanceof q || He(t) || t instanceof j || t instanceof he))
|
|
2642
|
-
return !1;
|
|
2643
|
-
if (t instanceof q) {
|
|
2644
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ee(n) || C(n) || fe(n)))
|
|
2645
|
-
return !1;
|
|
2646
|
-
t = t.callee;
|
|
2647
|
-
}
|
|
2648
|
-
for (; t instanceof he; ) {
|
|
2649
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ee(n.name)))
|
|
2650
|
-
return !1;
|
|
2651
|
-
t = t.array;
|
|
2652
|
-
}
|
|
2653
|
-
const e = H(t).unwrap_or(void 0);
|
|
2654
|
-
return e !== void 0 && e.length > 0;
|
|
2655
|
-
}
|
|
2656
|
-
class Zn {
|
|
2647
|
+
const ts = ["-", "+"];
|
|
2648
|
+
class ns {
|
|
2657
2649
|
constructor(e, n, s) {
|
|
2658
2650
|
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2659
2651
|
}
|
|
@@ -2693,17 +2685,17 @@ class Zn {
|
|
|
2693
2685
|
)] : [];
|
|
2694
2686
|
}
|
|
2695
2687
|
validateSettingList(e) {
|
|
2696
|
-
const n =
|
|
2697
|
-
return
|
|
2688
|
+
const n = F(e), s = n.getErrors(), i = n.getValue();
|
|
2689
|
+
return Ge(i, (a, r) => {
|
|
2698
2690
|
switch (r) {
|
|
2699
|
-
case
|
|
2691
|
+
case E.HeaderColor:
|
|
2700
2692
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_PARTIAL_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
2701
2693
|
Je(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, `'${r}' must be a color literal`, c.value || c.name));
|
|
2702
2694
|
});
|
|
2703
2695
|
break;
|
|
2704
|
-
case
|
|
2696
|
+
case E.Note:
|
|
2705
2697
|
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_PARTIAL_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
2706
|
-
|
|
2698
|
+
Y(c.value) || s.push(new l(o.INVALID_TABLE_PARTIAL_SETTING, `'${r}' must be a string literal`, c.value || c.name));
|
|
2707
2699
|
});
|
|
2708
2700
|
break;
|
|
2709
2701
|
default:
|
|
@@ -2713,11 +2705,11 @@ class Zn {
|
|
|
2713
2705
|
}
|
|
2714
2706
|
registerElement() {
|
|
2715
2707
|
const { name: e } = this.declarationNode;
|
|
2716
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2717
|
-
const n =
|
|
2708
|
+
this.declarationNode.symbol = this.symbolFactory.create(_n, { declaration: this.declarationNode, symbolTable: new ke() });
|
|
2709
|
+
const n = q(e);
|
|
2718
2710
|
if (!n.isOk())
|
|
2719
2711
|
return [];
|
|
2720
|
-
const s = n.unwrap(), i = s.pop(), a = Qe(s, this.publicSymbolTable, this.symbolFactory), r =
|
|
2712
|
+
const s = n.unwrap(), i = s.pop(), a = Qe(s, this.publicSymbolTable, this.symbolFactory), r = lt(i);
|
|
2721
2713
|
return a.has(r) ? [new l(o.DUPLICATE_NAME, `TablePartial name '${i}' already exists`, e)] : (a.set(r, this.declarationNode.symbol), []);
|
|
2722
2714
|
}
|
|
2723
2715
|
validateBody(e) {
|
|
@@ -2736,7 +2728,7 @@ class Zn {
|
|
|
2736
2728
|
if (!n.callee)
|
|
2737
2729
|
return [];
|
|
2738
2730
|
const s = [];
|
|
2739
|
-
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)),
|
|
2731
|
+
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), $(n.callee) || s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !jt(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2740
2732
|
const i = n.args.slice(1);
|
|
2741
2733
|
return s.push(
|
|
2742
2734
|
...this.validateFieldSetting(i),
|
|
@@ -2745,9 +2737,9 @@ class Zn {
|
|
|
2745
2737
|
});
|
|
2746
2738
|
}
|
|
2747
2739
|
registerField(e) {
|
|
2748
|
-
if (!e.callee ||
|
|
2740
|
+
if (!e.callee || !$(e.callee))
|
|
2749
2741
|
return [];
|
|
2750
|
-
const n =
|
|
2742
|
+
const n = X(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(ct, { declaration: e });
|
|
2751
2743
|
e.symbol = i;
|
|
2752
2744
|
const a = this.declarationNode.symbol.symbolTable;
|
|
2753
2745
|
if (a.has(s)) {
|
|
@@ -2762,86 +2754,86 @@ class Zn {
|
|
|
2762
2754
|
// This is needed to support legacy inline settings
|
|
2763
2755
|
validateFieldSetting(e) {
|
|
2764
2756
|
const n = Ve(e);
|
|
2765
|
-
if (!e.slice(0, -1).every(
|
|
2766
|
-
return [...e.map((
|
|
2757
|
+
if (!e.slice(0, -1).every(Ne) || !(Ne(n) || n instanceof M))
|
|
2758
|
+
return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2767
2759
|
if (e.length === 0)
|
|
2768
2760
|
return [];
|
|
2769
2761
|
let s;
|
|
2770
2762
|
g.last(e) instanceof M && (s = e.pop());
|
|
2771
|
-
const i =
|
|
2772
|
-
e.forEach((
|
|
2773
|
-
const
|
|
2774
|
-
if (
|
|
2775
|
-
a.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`",
|
|
2763
|
+
const i = F(s), a = i.getErrors(), r = i.getValue();
|
|
2764
|
+
e.forEach((p) => {
|
|
2765
|
+
const h = X(p).unwrap_or("").toLowerCase();
|
|
2766
|
+
if (h !== E.PK && h !== E.Unique) {
|
|
2767
|
+
a.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2776
2768
|
return;
|
|
2777
2769
|
}
|
|
2778
|
-
r[
|
|
2770
|
+
r[h] === void 0 ? r[h] = [p] : r[h].push(p);
|
|
2779
2771
|
});
|
|
2780
|
-
const c = r[
|
|
2781
|
-
return c.length >= 1 &&
|
|
2772
|
+
const c = r[E.PK] || [], f = r[E.PKey] || [];
|
|
2773
|
+
return c.length >= 1 && f.length >= 1 && a.push(...[...c, ...f].map((p) => new l(
|
|
2782
2774
|
o.DUPLICATE_COLUMN_SETTING,
|
|
2783
2775
|
"Either one of 'primary key' and 'pk' can appear",
|
|
2784
|
-
|
|
2785
|
-
))),
|
|
2786
|
-
switch (
|
|
2787
|
-
case
|
|
2788
|
-
|
|
2789
|
-
|
|
2776
|
+
p
|
|
2777
|
+
))), Ge(r, (p, h) => {
|
|
2778
|
+
switch (h) {
|
|
2779
|
+
case E.Note:
|
|
2780
|
+
p.length > 1 && a.push(...p.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, d))), p.forEach((d) => {
|
|
2781
|
+
Y(d.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must be a quoted string`, d.value || d.name));
|
|
2790
2782
|
});
|
|
2791
2783
|
break;
|
|
2792
|
-
case
|
|
2793
|
-
|
|
2794
|
-
Xt(
|
|
2784
|
+
case E.Ref:
|
|
2785
|
+
p.forEach((d) => {
|
|
2786
|
+
Xt(d.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must be a valid unary relationship`, d.value || d.name));
|
|
2795
2787
|
});
|
|
2796
2788
|
break;
|
|
2797
|
-
case
|
|
2798
|
-
|
|
2799
|
-
|
|
2789
|
+
case E.PKey:
|
|
2790
|
+
p.length > 1 && a.push(...p.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, d))), p.forEach((d) => {
|
|
2791
|
+
z(d.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must not have a value`, d.value || d.name));
|
|
2800
2792
|
});
|
|
2801
2793
|
break;
|
|
2802
|
-
case
|
|
2803
|
-
|
|
2804
|
-
|
|
2794
|
+
case E.PK:
|
|
2795
|
+
p.length > 1 && a.push(...p.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, d))), p.forEach((d) => {
|
|
2796
|
+
d instanceof se && !z(d.value) && a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must not have a value`, d.value || d.name));
|
|
2805
2797
|
});
|
|
2806
2798
|
break;
|
|
2807
|
-
case
|
|
2808
|
-
|
|
2809
|
-
const
|
|
2810
|
-
|
|
2799
|
+
case E.NotNull: {
|
|
2800
|
+
p.length > 1 && a.push(...p.map((N) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, N)));
|
|
2801
|
+
const d = r[E.Null] || [];
|
|
2802
|
+
p.length >= 1 && d.length >= 1 && a.push(...[...p, ...d].map((N) => new l(
|
|
2811
2803
|
o.CONFLICTING_SETTING,
|
|
2812
2804
|
"'not null' and 'null' can not be set at the same time",
|
|
2813
|
-
|
|
2814
|
-
))),
|
|
2815
|
-
|
|
2805
|
+
N
|
|
2806
|
+
))), p.forEach((N) => {
|
|
2807
|
+
z(N.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must not have a value`, N.value || N.name));
|
|
2816
2808
|
});
|
|
2817
2809
|
break;
|
|
2818
2810
|
}
|
|
2819
|
-
case
|
|
2820
|
-
|
|
2821
|
-
|
|
2811
|
+
case E.Null:
|
|
2812
|
+
p.length > 1 && a.push(...p.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, d))), p.forEach((d) => {
|
|
2813
|
+
z(d.value) || a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must not have a value`, d.value || d.name));
|
|
2822
2814
|
});
|
|
2823
2815
|
break;
|
|
2824
|
-
case
|
|
2825
|
-
|
|
2826
|
-
|
|
2816
|
+
case E.Unique:
|
|
2817
|
+
p.length > 1 && a.push(...p.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, d))), p.forEach((d) => {
|
|
2818
|
+
d instanceof se && !z(d.value) && a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must not have a value`, d.value || d.name));
|
|
2827
2819
|
});
|
|
2828
2820
|
break;
|
|
2829
|
-
case
|
|
2830
|
-
|
|
2831
|
-
|
|
2821
|
+
case E.Increment:
|
|
2822
|
+
p.length > 1 && a.push(...p.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, d))), p.forEach((d) => {
|
|
2823
|
+
d instanceof se && !z(d.value) && a.push(new l(o.INVALID_COLUMN_SETTING_VALUE, `'${h}' must not have a value`, d.value || d.name));
|
|
2832
2824
|
});
|
|
2833
2825
|
break;
|
|
2834
|
-
case
|
|
2835
|
-
|
|
2836
|
-
Ct(
|
|
2826
|
+
case E.Default:
|
|
2827
|
+
p.length > 1 && a.push(...p.map((d) => new l(o.DUPLICATE_COLUMN_SETTING, `'${h}' can only appear once`, d))), p.forEach((d) => {
|
|
2828
|
+
Ct(d.value) || a.push(new l(
|
|
2837
2829
|
o.INVALID_COLUMN_SETTING_VALUE,
|
|
2838
|
-
`'${
|
|
2839
|
-
|
|
2830
|
+
`'${h}' must be a string literal, number literal, function expression, true, false or null`,
|
|
2831
|
+
d.value || d.name
|
|
2840
2832
|
));
|
|
2841
2833
|
});
|
|
2842
2834
|
break;
|
|
2843
2835
|
default:
|
|
2844
|
-
|
|
2836
|
+
p.forEach((d) => a.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${h}'`, d)));
|
|
2845
2837
|
}
|
|
2846
2838
|
}), a;
|
|
2847
2839
|
}
|
|
@@ -2849,7 +2841,7 @@ class Zn {
|
|
|
2849
2841
|
const n = e.flatMap((i) => {
|
|
2850
2842
|
if (i.parent = this.declarationNode, !i.type)
|
|
2851
2843
|
return [];
|
|
2852
|
-
const a =
|
|
2844
|
+
const a = he(i);
|
|
2853
2845
|
return new a(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2854
2846
|
}), s = e.filter((i) => {
|
|
2855
2847
|
var a;
|
|
@@ -2858,32 +2850,32 @@ class Zn {
|
|
|
2858
2850
|
return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
|
|
2859
2851
|
}
|
|
2860
2852
|
}
|
|
2861
|
-
function
|
|
2853
|
+
function he(t) {
|
|
2862
2854
|
switch (t.type.value.toLowerCase()) {
|
|
2863
2855
|
case I.Enum:
|
|
2864
|
-
return
|
|
2856
|
+
return Yn;
|
|
2865
2857
|
case I.Table:
|
|
2866
|
-
return
|
|
2858
|
+
return Kn;
|
|
2867
2859
|
case I.TableGroup:
|
|
2868
|
-
return
|
|
2860
|
+
return es;
|
|
2869
2861
|
case I.Project:
|
|
2870
|
-
return
|
|
2862
|
+
return zn;
|
|
2871
2863
|
case I.Ref:
|
|
2872
|
-
return
|
|
2864
|
+
return Qn;
|
|
2873
2865
|
case I.Note:
|
|
2874
|
-
return
|
|
2866
|
+
return Hn;
|
|
2875
2867
|
case I.Indexes:
|
|
2876
|
-
return
|
|
2868
|
+
return qn;
|
|
2877
2869
|
case I.TablePartial:
|
|
2878
|
-
return
|
|
2870
|
+
return ns;
|
|
2879
2871
|
default:
|
|
2880
|
-
return
|
|
2872
|
+
return Wn;
|
|
2881
2873
|
}
|
|
2882
2874
|
}
|
|
2883
2875
|
function Vt(t) {
|
|
2884
|
-
return !!
|
|
2876
|
+
return !!q(t).unwrap_or(!1);
|
|
2885
2877
|
}
|
|
2886
|
-
function
|
|
2878
|
+
function ss(t) {
|
|
2887
2879
|
return Pe(t);
|
|
2888
2880
|
}
|
|
2889
2881
|
function Pe(t) {
|
|
@@ -2895,14 +2887,14 @@ function Qe(t, e, n) {
|
|
|
2895
2887
|
let s = e;
|
|
2896
2888
|
for (const a of t) {
|
|
2897
2889
|
let r;
|
|
2898
|
-
const c =
|
|
2890
|
+
const c = st(a);
|
|
2899
2891
|
if (s.has(c)) {
|
|
2900
2892
|
if (r = (i = s.get(c)) == null ? void 0 : i.symbolTable, !r)
|
|
2901
2893
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2902
2894
|
} else {
|
|
2903
2895
|
r = new ke();
|
|
2904
|
-
const
|
|
2905
|
-
s.set(c,
|
|
2896
|
+
const f = n.create(Ut, { symbolTable: r });
|
|
2897
|
+
s.set(c, f);
|
|
2906
2898
|
}
|
|
2907
2899
|
s = r;
|
|
2908
2900
|
}
|
|
@@ -2913,42 +2905,58 @@ function Gt(t) {
|
|
|
2913
2905
|
}
|
|
2914
2906
|
function Je(t) {
|
|
2915
2907
|
var n;
|
|
2916
|
-
if (!(t instanceof j) || !(t.expression instanceof ye) || ((n = t.expression.literal) == null ? void 0 : n.kind) !==
|
|
2908
|
+
if (!(t instanceof j) || !(t.expression instanceof ye) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2917
2909
|
return !1;
|
|
2918
2910
|
const e = t.expression.literal.value;
|
|
2919
2911
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2920
2912
|
return !1;
|
|
2921
2913
|
for (let s = 1; s < e.length; s += 1)
|
|
2922
|
-
if (!
|
|
2914
|
+
if (!kn(e[s]))
|
|
2923
2915
|
return !1;
|
|
2924
2916
|
return !0;
|
|
2925
2917
|
}
|
|
2926
|
-
function
|
|
2918
|
+
function z(t) {
|
|
2927
2919
|
return t === void 0;
|
|
2928
2920
|
}
|
|
2929
2921
|
function Ct(t) {
|
|
2930
2922
|
var e;
|
|
2931
|
-
return !!(
|
|
2923
|
+
return !!(Y(t) || Ae(t) || Ne(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Z && ts.includes((e = t.op) == null ? void 0 : e.value) && Ae(t.expression) || t instanceof ue);
|
|
2932
2924
|
}
|
|
2933
|
-
function
|
|
2934
|
-
var e;
|
|
2935
|
-
return t instanceof j && t.expression instanceof ye && ((
|
|
2925
|
+
function Ae(t) {
|
|
2926
|
+
var e, n, s;
|
|
2927
|
+
return t instanceof Z ? ((e = t.op) == null ? void 0 : e.value) !== "-" && ((n = t.op) == null ? void 0 : n.value) !== "+" ? !1 : Ae(t.expression) : t instanceof j && t.expression instanceof ye && ((s = t.expression.literal) == null ? void 0 : s.kind) === u.NUMERIC_LITERAL;
|
|
2936
2928
|
}
|
|
2937
2929
|
function Xt(t) {
|
|
2938
2930
|
var n;
|
|
2939
|
-
if (!(t instanceof
|
|
2931
|
+
if (!(t instanceof Z) || !Gt((n = t.op) == null ? void 0 : n.value))
|
|
2940
2932
|
return !1;
|
|
2941
|
-
const e =
|
|
2933
|
+
const e = q(t.expression).unwrap_or(void 0);
|
|
2942
2934
|
return e !== void 0 && e.length > 0;
|
|
2943
2935
|
}
|
|
2944
2936
|
function $t(t) {
|
|
2945
|
-
return t instanceof
|
|
2937
|
+
return t instanceof ce && t.elementList.every($);
|
|
2946
2938
|
}
|
|
2947
|
-
function
|
|
2939
|
+
function jt(t) {
|
|
2940
|
+
if (!(t instanceof ee || ut(t) || t instanceof j || t instanceof Ie))
|
|
2941
|
+
return !1;
|
|
2942
|
+
if (t instanceof ee) {
|
|
2943
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => Ae(n) || Y(n) || Ne(n)))
|
|
2944
|
+
return !1;
|
|
2945
|
+
t = t.callee;
|
|
2946
|
+
}
|
|
2947
|
+
for (; t instanceof Ie; ) {
|
|
2948
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && Ae(n.name)))
|
|
2949
|
+
return !1;
|
|
2950
|
+
t = t.array;
|
|
2951
|
+
}
|
|
2952
|
+
const e = q(t).unwrap_or(void 0);
|
|
2953
|
+
return e !== void 0 && e.length > 0;
|
|
2954
|
+
}
|
|
2955
|
+
function F(t) {
|
|
2948
2956
|
var s;
|
|
2949
2957
|
const e = {}, n = [];
|
|
2950
2958
|
if (!t)
|
|
2951
|
-
return new
|
|
2959
|
+
return new J({});
|
|
2952
2960
|
for (const i of t.elementList) {
|
|
2953
2961
|
if (!i.name)
|
|
2954
2962
|
continue;
|
|
@@ -2959,11 +2967,11 @@ function B(t) {
|
|
|
2959
2967
|
const a = (s = we(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2960
2968
|
a && (e[a] === void 0 ? e[a] = [i] : e[a].push(i));
|
|
2961
2969
|
}
|
|
2962
|
-
return new
|
|
2970
|
+
return new J(e, n);
|
|
2963
2971
|
}
|
|
2964
|
-
class
|
|
2972
|
+
class At {
|
|
2965
2973
|
constructor(e, n) {
|
|
2966
|
-
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(
|
|
2974
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(Ut, {
|
|
2967
2975
|
symbolTable: new ke()
|
|
2968
2976
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2969
2977
|
}
|
|
@@ -2972,18 +2980,18 @@ class _t {
|
|
|
2972
2980
|
this.ast.body.forEach((s) => {
|
|
2973
2981
|
if (s.parent = this.ast, s.type === void 0)
|
|
2974
2982
|
return;
|
|
2975
|
-
const i =
|
|
2983
|
+
const i = he(s), a = new i(
|
|
2976
2984
|
s,
|
|
2977
2985
|
this.publicSchemaSymbol.symbolTable,
|
|
2978
2986
|
this.symbolFactory
|
|
2979
2987
|
);
|
|
2980
2988
|
e.push(...a.validate());
|
|
2981
2989
|
});
|
|
2982
|
-
const n = this.ast.body.filter((s) =>
|
|
2983
|
-
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new
|
|
2990
|
+
const n = this.ast.body.filter((s) => Le(s).unwrap_or(void 0) === I.Project);
|
|
2991
|
+
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new J(this.ast, e);
|
|
2984
2992
|
}
|
|
2985
2993
|
}
|
|
2986
|
-
class
|
|
2994
|
+
class fe {
|
|
2987
2995
|
constructor(e, n) {
|
|
2988
2996
|
this.declarationNode = e, this.errors = n;
|
|
2989
2997
|
}
|
|
@@ -3008,9 +3016,9 @@ class Ee {
|
|
|
3008
3016
|
const { body: n } = e;
|
|
3009
3017
|
n instanceof oe ? n.body.forEach((s) => {
|
|
3010
3018
|
if (s instanceof y) {
|
|
3011
|
-
if (!s.type ||
|
|
3019
|
+
if (!s.type || Le(this.declarationNode).unwrap_or(null) === I.TablePartial && Le(s).unwrap_or(null) === I.Indexes)
|
|
3012
3020
|
return;
|
|
3013
|
-
const i =
|
|
3021
|
+
const i = Wt(s);
|
|
3014
3022
|
new i(s, this.errors).bind();
|
|
3015
3023
|
} else
|
|
3016
3024
|
s instanceof w ? this.bindSubfield(s) : this.bindPartialInjection(s);
|
|
@@ -3036,7 +3044,7 @@ class Ee {
|
|
|
3036
3044
|
return;
|
|
3037
3045
|
this.bindFragments([e], n);
|
|
3038
3046
|
} else
|
|
3039
|
-
e instanceof
|
|
3047
|
+
e instanceof le ? ut(e) ? this.bindFragments(_e(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Z ? this.scanAndBind(e.expression, n) : e instanceof qe ? this.scanAndBind(e.expression, n) : e instanceof ce ? e.elementList.forEach((a) => this.scanAndBind(a, n)) : e instanceof be && this.bindFragments([e], n);
|
|
3040
3048
|
}
|
|
3041
3049
|
// Bind the fragments of a member access expression
|
|
3042
3050
|
// which can be a simple expression like v1.User,
|
|
@@ -3044,67 +3052,67 @@ class Ee {
|
|
|
3044
3052
|
bindFragments(e, n) {
|
|
3045
3053
|
if (e.length === 0)
|
|
3046
3054
|
return;
|
|
3047
|
-
const s = e.length === 1 && e[0] instanceof
|
|
3055
|
+
const s = e.length === 1 && e[0] instanceof be, i = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: a } = n, r = s ? -1 : e.findIndex((N) => !$(N)), f = r !== -1 && $t(e[r]) ? e[r] : void 0, p = r >= 0 ? i.pop() : void 0, h = e.slice(
|
|
3048
3056
|
0,
|
|
3049
3057
|
r === -1 ? void 0 : r
|
|
3050
3058
|
);
|
|
3051
|
-
if (
|
|
3059
|
+
if (h.length === 0)
|
|
3052
3060
|
return;
|
|
3053
|
-
const
|
|
3054
|
-
for (; i.length &&
|
|
3055
|
-
const
|
|
3056
|
-
|
|
3057
|
-
index: Fe(v,
|
|
3061
|
+
const d = [];
|
|
3062
|
+
for (; i.length && h.length; ) {
|
|
3063
|
+
const N = i.pop(), L = h.pop(), v = X(L).unwrap();
|
|
3064
|
+
d.unshift({
|
|
3065
|
+
index: Fe(v, N),
|
|
3058
3066
|
referrer: L
|
|
3059
3067
|
});
|
|
3060
3068
|
}
|
|
3061
|
-
for (;
|
|
3062
|
-
const
|
|
3063
|
-
|
|
3069
|
+
for (; h.length; ) {
|
|
3070
|
+
const N = h.pop(), L = s ? Xn(N).unwrap() : X(N).unwrap();
|
|
3071
|
+
d.unshift({
|
|
3064
3072
|
index: Fe(L, a),
|
|
3065
|
-
referrer:
|
|
3073
|
+
referrer: N
|
|
3066
3074
|
});
|
|
3067
3075
|
}
|
|
3068
|
-
return
|
|
3076
|
+
return f ? f.elementList.forEach((N) => this.resolveIndexStack(
|
|
3069
3077
|
[
|
|
3070
|
-
...
|
|
3078
|
+
...d,
|
|
3071
3079
|
{
|
|
3072
3080
|
index: Fe(
|
|
3073
|
-
|
|
3074
|
-
|
|
3081
|
+
X(N).unwrap(),
|
|
3082
|
+
p
|
|
3075
3083
|
),
|
|
3076
|
-
referrer:
|
|
3084
|
+
referrer: N
|
|
3077
3085
|
}
|
|
3078
3086
|
],
|
|
3079
3087
|
n.ignoreNameNotFound
|
|
3080
|
-
)) : this.resolveIndexStack(
|
|
3088
|
+
)) : this.resolveIndexStack(d, n.ignoreNameNotFound);
|
|
3081
3089
|
}
|
|
3082
3090
|
// Looking up the indexes in the subname stack from the current declaration node
|
|
3083
3091
|
// Each time the index resolves to a symbol, the referrer's symbol is bound to it
|
|
3084
3092
|
resolveIndexStack(e, n) {
|
|
3085
3093
|
if (e.length === 0)
|
|
3086
3094
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
3087
|
-
const [s, ...i] = e, a =
|
|
3095
|
+
const [s, ...i] = e, a = Lt(s.index, this.declarationNode);
|
|
3088
3096
|
if (a === void 0) {
|
|
3089
|
-
const { kind:
|
|
3090
|
-
this.logError(s.referrer, `Can not find ${
|
|
3097
|
+
const { kind: p, name: h } = ie(s.index).unwrap();
|
|
3098
|
+
this.logError(s.referrer, `Can not find ${p} '${h}'`, n);
|
|
3091
3099
|
return;
|
|
3092
3100
|
}
|
|
3093
3101
|
a.references.push(s.referrer), s.referrer.referee = a;
|
|
3094
|
-
let r = a.symbolTable, { kind: c, name:
|
|
3095
|
-
for (const
|
|
3096
|
-
const { kind:
|
|
3097
|
-
if (!
|
|
3102
|
+
let r = a.symbolTable, { kind: c, name: f } = ie(s.index).unwrap();
|
|
3103
|
+
for (const p of i) {
|
|
3104
|
+
const { kind: h, name: d } = ie(p.index).unwrap(), N = r.get(p.index);
|
|
3105
|
+
if (!N) {
|
|
3098
3106
|
this.logError(
|
|
3099
|
-
|
|
3100
|
-
`${c} '${
|
|
3107
|
+
p.referrer,
|
|
3108
|
+
`${c} '${f}' does not have ${h} '${d}'`,
|
|
3101
3109
|
n
|
|
3102
3110
|
);
|
|
3103
3111
|
return;
|
|
3104
3112
|
}
|
|
3105
|
-
if (c =
|
|
3113
|
+
if (c = h, f = d, p.referrer.referee = N, N.references.push(p.referrer), !N.symbolTable)
|
|
3106
3114
|
break;
|
|
3107
|
-
r =
|
|
3115
|
+
r = N.symbolTable;
|
|
3108
3116
|
}
|
|
3109
3117
|
}
|
|
3110
3118
|
logError(e, n, s) {
|
|
@@ -3118,23 +3126,23 @@ class Ee {
|
|
|
3118
3126
|
return;
|
|
3119
3127
|
const s = /* @__PURE__ */ new Map();
|
|
3120
3128
|
n.forEach((a, r) => {
|
|
3121
|
-
var
|
|
3122
|
-
if (!
|
|
3129
|
+
var p, h;
|
|
3130
|
+
if (!Nn(r))
|
|
3123
3131
|
return;
|
|
3124
|
-
const c =
|
|
3125
|
-
|
|
3126
|
-
n.has(
|
|
3132
|
+
const c = Lt(Tn(r), this.declarationNode), f = (h = (p = c == null ? void 0 : c.declaration) == null ? void 0 : p.symbol) == null ? void 0 : h.symbolTable;
|
|
3133
|
+
f && f.forEach((d, N) => {
|
|
3134
|
+
n.has(N) || s.set(N, { injectorFieldSymbol: d, injectorDeclaration: a.declaration });
|
|
3127
3135
|
});
|
|
3128
3136
|
}), s.forEach((a, r) => {
|
|
3129
|
-
const c =
|
|
3137
|
+
const c = yn(a.injectorFieldSymbol);
|
|
3130
3138
|
if (!c)
|
|
3131
3139
|
return;
|
|
3132
|
-
const
|
|
3133
|
-
n.set(r,
|
|
3140
|
+
const f = e.create(c, a);
|
|
3141
|
+
n.set(r, f);
|
|
3134
3142
|
});
|
|
3135
3143
|
}
|
|
3136
3144
|
}
|
|
3137
|
-
class
|
|
3145
|
+
class is extends fe {
|
|
3138
3146
|
constructor() {
|
|
3139
3147
|
super(...arguments), this.subfield = {
|
|
3140
3148
|
arg: {
|
|
@@ -3144,7 +3152,7 @@ class ts extends Ee {
|
|
|
3144
3152
|
}, this.settingList = {};
|
|
3145
3153
|
}
|
|
3146
3154
|
}
|
|
3147
|
-
class
|
|
3155
|
+
class as extends fe {
|
|
3148
3156
|
constructor() {
|
|
3149
3157
|
super(...arguments), this.subfield = {
|
|
3150
3158
|
arg: {
|
|
@@ -3154,7 +3162,7 @@ class ns extends Ee {
|
|
|
3154
3162
|
}, this.settingList = {};
|
|
3155
3163
|
}
|
|
3156
3164
|
}
|
|
3157
|
-
class
|
|
3165
|
+
class rs extends fe {
|
|
3158
3166
|
constructor() {
|
|
3159
3167
|
super(...arguments), this.subfield = {
|
|
3160
3168
|
arg: {
|
|
@@ -3189,7 +3197,7 @@ class ss extends Ee {
|
|
|
3189
3197
|
}, this.settingList = {};
|
|
3190
3198
|
}
|
|
3191
3199
|
}
|
|
3192
|
-
class
|
|
3200
|
+
class os extends fe {
|
|
3193
3201
|
constructor() {
|
|
3194
3202
|
super(...arguments), this.subfield = {
|
|
3195
3203
|
arg: {
|
|
@@ -3199,7 +3207,7 @@ class is extends Ee {
|
|
|
3199
3207
|
}, this.settingList = {};
|
|
3200
3208
|
}
|
|
3201
3209
|
}
|
|
3202
|
-
class
|
|
3210
|
+
class ls extends fe {
|
|
3203
3211
|
constructor() {
|
|
3204
3212
|
super(...arguments), this.subfield = {
|
|
3205
3213
|
arg: {
|
|
@@ -3209,7 +3217,7 @@ class as extends Ee {
|
|
|
3209
3217
|
}, this.settingList = {};
|
|
3210
3218
|
}
|
|
3211
3219
|
}
|
|
3212
|
-
class
|
|
3220
|
+
class cs extends fe {
|
|
3213
3221
|
constructor() {
|
|
3214
3222
|
super(...arguments), this.subfield = {
|
|
3215
3223
|
arg: {
|
|
@@ -3226,7 +3234,7 @@ class rs extends Ee {
|
|
|
3226
3234
|
}, this.settingList = {};
|
|
3227
3235
|
}
|
|
3228
3236
|
}
|
|
3229
|
-
class
|
|
3237
|
+
class us extends fe {
|
|
3230
3238
|
constructor() {
|
|
3231
3239
|
super(...arguments), this.subfield = {
|
|
3232
3240
|
arg: {
|
|
@@ -3259,7 +3267,7 @@ class os extends Ee {
|
|
|
3259
3267
|
};
|
|
3260
3268
|
}
|
|
3261
3269
|
}
|
|
3262
|
-
class
|
|
3270
|
+
class hs extends fe {
|
|
3263
3271
|
constructor() {
|
|
3264
3272
|
super(...arguments), this.subfield = {
|
|
3265
3273
|
arg: {
|
|
@@ -3276,7 +3284,7 @@ class ls extends Ee {
|
|
|
3276
3284
|
}, this.settingList = {};
|
|
3277
3285
|
}
|
|
3278
3286
|
}
|
|
3279
|
-
class
|
|
3287
|
+
class fs extends fe {
|
|
3280
3288
|
constructor() {
|
|
3281
3289
|
super(...arguments), this.subfield = {
|
|
3282
3290
|
arg: {
|
|
@@ -3304,29 +3312,29 @@ class cs extends Ee {
|
|
|
3304
3312
|
}, this.settingList = {};
|
|
3305
3313
|
}
|
|
3306
3314
|
}
|
|
3307
|
-
function
|
|
3315
|
+
function Wt(t) {
|
|
3308
3316
|
switch (t.type.value.toLowerCase()) {
|
|
3309
3317
|
case I.Enum:
|
|
3310
|
-
return
|
|
3318
|
+
return as;
|
|
3311
3319
|
case I.Table:
|
|
3312
|
-
return
|
|
3320
|
+
return us;
|
|
3313
3321
|
case I.TableGroup:
|
|
3314
|
-
return
|
|
3322
|
+
return hs;
|
|
3315
3323
|
case I.Project:
|
|
3316
|
-
return
|
|
3324
|
+
return ls;
|
|
3317
3325
|
case I.Ref:
|
|
3318
|
-
return
|
|
3326
|
+
return cs;
|
|
3319
3327
|
case I.Note:
|
|
3320
|
-
return
|
|
3328
|
+
return os;
|
|
3321
3329
|
case I.Indexes:
|
|
3322
|
-
return
|
|
3330
|
+
return rs;
|
|
3323
3331
|
case I.TablePartial:
|
|
3324
|
-
return
|
|
3332
|
+
return fs;
|
|
3325
3333
|
default:
|
|
3326
|
-
return
|
|
3334
|
+
return is;
|
|
3327
3335
|
}
|
|
3328
3336
|
}
|
|
3329
|
-
class
|
|
3337
|
+
class ps {
|
|
3330
3338
|
constructor(e) {
|
|
3331
3339
|
this.ast = e, this.errors = [];
|
|
3332
3340
|
}
|
|
@@ -3334,12 +3342,12 @@ class us {
|
|
|
3334
3342
|
return this.ast.body.map((n) => {
|
|
3335
3343
|
if (!n.type)
|
|
3336
3344
|
return null;
|
|
3337
|
-
const s =
|
|
3345
|
+
const s = Wt(n), i = new s(n, this.errors);
|
|
3338
3346
|
return i.resolveInjections(e), i;
|
|
3339
|
-
}).forEach((n) => n == null ? void 0 : n.bind()), new
|
|
3347
|
+
}).forEach((n) => n == null ? void 0 : n.bind()), new J(this.ast, this.errors);
|
|
3340
3348
|
}
|
|
3341
3349
|
}
|
|
3342
|
-
class
|
|
3350
|
+
class ds {
|
|
3343
3351
|
constructor(e) {
|
|
3344
3352
|
this.generator = e;
|
|
3345
3353
|
}
|
|
@@ -3347,21 +3355,21 @@ class hs {
|
|
|
3347
3355
|
return new e(n, this.generator.nextId());
|
|
3348
3356
|
}
|
|
3349
3357
|
}
|
|
3350
|
-
class
|
|
3358
|
+
class Es {
|
|
3351
3359
|
constructor(e, n) {
|
|
3352
|
-
this.ast = e, this.symbolFactory = new
|
|
3360
|
+
this.ast = e, this.symbolFactory = new ds(n);
|
|
3353
3361
|
}
|
|
3354
3362
|
// Analyzing: Invoking both the validator and binder
|
|
3355
3363
|
analyze() {
|
|
3356
|
-
return new
|
|
3364
|
+
return new At(this.ast, this.symbolFactory).validate().chain((n) => new ps(n).resolve(this.symbolFactory));
|
|
3357
3365
|
}
|
|
3358
3366
|
// For invoking the validator only
|
|
3359
3367
|
validate() {
|
|
3360
|
-
return new
|
|
3368
|
+
return new At(this.ast, this.symbolFactory).validate().chain((n) => new J(n, []));
|
|
3361
3369
|
}
|
|
3362
3370
|
}
|
|
3363
|
-
function
|
|
3364
|
-
const { variables: n, tupleElements: s } =
|
|
3371
|
+
function _t(t, e) {
|
|
3372
|
+
const { variables: n, tupleElements: s } = De(t).unwrap();
|
|
3365
3373
|
return s ? n.length === 0 ? {
|
|
3366
3374
|
schemaName: e.schemaName,
|
|
3367
3375
|
tableName: e.name,
|
|
@@ -3380,7 +3388,7 @@ function gt(t, e) {
|
|
|
3380
3388
|
schemaName: n.pop() || null
|
|
3381
3389
|
};
|
|
3382
3390
|
}
|
|
3383
|
-
function
|
|
3391
|
+
function Yt(t) {
|
|
3384
3392
|
switch (t) {
|
|
3385
3393
|
case "<":
|
|
3386
3394
|
return ["1", "*"];
|
|
@@ -3390,8 +3398,9 @@ function Wt(t) {
|
|
|
3390
3398
|
return ["*", "1"];
|
|
3391
3399
|
case "-":
|
|
3392
3400
|
return ["1", "1"];
|
|
3401
|
+
default:
|
|
3402
|
+
throw new Error("Invalid relation op");
|
|
3393
3403
|
}
|
|
3394
|
-
throw new Error("Invalid relation op");
|
|
3395
3404
|
}
|
|
3396
3405
|
function _(t) {
|
|
3397
3406
|
return {
|
|
@@ -3400,16 +3409,20 @@ function _(t) {
|
|
|
3400
3409
|
line: t.startPos.line + 1,
|
|
3401
3410
|
column: t.startPos.column + 1
|
|
3402
3411
|
},
|
|
3403
|
-
end: {
|
|
3412
|
+
end: {
|
|
3413
|
+
offset: t.endPos.offset,
|
|
3414
|
+
line: t.endPos.line + 1,
|
|
3415
|
+
column: t.endPos.column + 1
|
|
3416
|
+
}
|
|
3404
3417
|
};
|
|
3405
3418
|
}
|
|
3406
|
-
function
|
|
3419
|
+
function je(t) {
|
|
3407
3420
|
var n;
|
|
3408
|
-
const e = (n =
|
|
3409
|
-
return e instanceof
|
|
3421
|
+
const e = (n = _e(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
3422
|
+
return e instanceof ce ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
3410
3423
|
}
|
|
3411
|
-
function
|
|
3412
|
-
const e =
|
|
3424
|
+
function ge(t) {
|
|
3425
|
+
const e = q(t).unwrap();
|
|
3413
3426
|
return {
|
|
3414
3427
|
name: e.pop(),
|
|
3415
3428
|
schemaName: e
|
|
@@ -3418,7 +3431,7 @@ function be(t) {
|
|
|
3418
3431
|
function Oe(t) {
|
|
3419
3432
|
return t.expression.literal.value;
|
|
3420
3433
|
}
|
|
3421
|
-
function
|
|
3434
|
+
function qt(t, e) {
|
|
3422
3435
|
if (Array.isArray(t)) {
|
|
3423
3436
|
const i = t.map(({ id: r }) => r).sort().join(","), a = e.map(({ id: r }) => r).sort().join(",");
|
|
3424
3437
|
return i < a ? `${i}-${a}` : `${a}-${i}`;
|
|
@@ -3426,7 +3439,7 @@ function Yt(t, e) {
|
|
|
3426
3439
|
const n = t.id.toString(), s = e.id.toString();
|
|
3427
3440
|
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
3428
3441
|
}
|
|
3429
|
-
function
|
|
3442
|
+
function ht(t, e) {
|
|
3430
3443
|
if (Array.isArray(t)) {
|
|
3431
3444
|
const i = t.map(({ id: r }) => r).sort(), a = e.map(({ id: r }) => r).sort();
|
|
3432
3445
|
return g.zip(i, a).every(([r, c]) => r === c);
|
|
@@ -3434,13 +3447,58 @@ function ut(t, e) {
|
|
|
3434
3447
|
const n = t.id, s = e.id;
|
|
3435
3448
|
return n === s;
|
|
3436
3449
|
}
|
|
3437
|
-
function
|
|
3450
|
+
function ae(t) {
|
|
3438
3451
|
const e = t.split(`
|
|
3439
3452
|
`), n = e.slice(e.findIndex((a) => a.trimStart() !== "")), s = n.filter((a) => a.trimStart()), i = Math.min(...s.map((a) => a.length - a.trimStart().length));
|
|
3440
3453
|
return n.map((a) => a.slice(i)).join(`
|
|
3441
3454
|
`);
|
|
3442
3455
|
}
|
|
3443
|
-
|
|
3456
|
+
function Ht(t) {
|
|
3457
|
+
if (t) {
|
|
3458
|
+
if (Y(t))
|
|
3459
|
+
return {
|
|
3460
|
+
value: V(t).unwrap(),
|
|
3461
|
+
type: "string"
|
|
3462
|
+
};
|
|
3463
|
+
if (Ae(t))
|
|
3464
|
+
return {
|
|
3465
|
+
type: "number",
|
|
3466
|
+
value: tt(t)
|
|
3467
|
+
};
|
|
3468
|
+
if (Ne(t))
|
|
3469
|
+
return {
|
|
3470
|
+
value: t.expression.variable.value.toLowerCase(),
|
|
3471
|
+
type: "boolean"
|
|
3472
|
+
};
|
|
3473
|
+
if (t instanceof ue && t.value)
|
|
3474
|
+
return {
|
|
3475
|
+
value: t.value.value,
|
|
3476
|
+
type: "expression"
|
|
3477
|
+
};
|
|
3478
|
+
throw new Error("Unreachable");
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
function zt(t) {
|
|
3482
|
+
let e = null;
|
|
3483
|
+
t instanceof ee && (e = t.argumentList.elementList.map((a) => Ae(a) ? Ft(a) : Y(a) ? V(a).unwrap() : W(a).unwrap()).join(","), t = t.callee);
|
|
3484
|
+
let n = "";
|
|
3485
|
+
for (; t instanceof Ie; )
|
|
3486
|
+
n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3487
|
+
const { name: s, schemaName: i } = ge(t);
|
|
3488
|
+
return i.length > 1 ? new J(
|
|
3489
|
+
{
|
|
3490
|
+
schemaName: i.length === 0 ? null : i[0],
|
|
3491
|
+
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3492
|
+
args: e
|
|
3493
|
+
},
|
|
3494
|
+
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3495
|
+
) : new J({
|
|
3496
|
+
schemaName: i.length === 0 ? null : i[0],
|
|
3497
|
+
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3498
|
+
args: e
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
class Qt {
|
|
3444
3502
|
constructor(e, n) {
|
|
3445
3503
|
this.declarationNode = e, this.env = n, this.table = {
|
|
3446
3504
|
name: void 0,
|
|
@@ -3469,16 +3527,18 @@ class qt {
|
|
|
3469
3527
|
// do not make sense to have a meaningful end (?)
|
|
3470
3528
|
},
|
|
3471
3529
|
pk: !0
|
|
3472
|
-
}), this.pkColumns.forEach((n) =>
|
|
3530
|
+
}), this.pkColumns.forEach((n) => {
|
|
3531
|
+
n.pk = !1;
|
|
3532
|
+
})), e;
|
|
3473
3533
|
}
|
|
3474
3534
|
interpretName(e) {
|
|
3475
|
-
const { name: n, schemaName: s } =
|
|
3535
|
+
const { name: n, schemaName: s } = ge(e);
|
|
3476
3536
|
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
|
|
3477
3537
|
}
|
|
3478
3538
|
interpretAlias(e) {
|
|
3479
3539
|
if (!e)
|
|
3480
3540
|
return [];
|
|
3481
|
-
const n =
|
|
3541
|
+
const n = X(e).unwrap_or(null);
|
|
3482
3542
|
return n && (this.env.aliases.push({
|
|
3483
3543
|
name: n,
|
|
3484
3544
|
kind: "table",
|
|
@@ -3490,16 +3550,16 @@ class qt {
|
|
|
3490
3550
|
}
|
|
3491
3551
|
interpretSettingList(e) {
|
|
3492
3552
|
var i, a, r;
|
|
3493
|
-
const n =
|
|
3494
|
-
this.table.headerColor = (i = n.
|
|
3495
|
-
const [s] = n.
|
|
3553
|
+
const n = F(e).getValue();
|
|
3554
|
+
this.table.headerColor = (i = n[E.HeaderColor]) != null && i.length ? Oe((r = (a = n[E.HeaderColor]) == null ? void 0 : a.at(0)) == null ? void 0 : r.value) : void 0;
|
|
3555
|
+
const [s] = n[E.Note] || [];
|
|
3496
3556
|
return this.table.note = s && {
|
|
3497
|
-
value:
|
|
3557
|
+
value: V(s == null ? void 0 : s.value).map(ae).unwrap(),
|
|
3498
3558
|
token: _(s)
|
|
3499
3559
|
}, [];
|
|
3500
3560
|
}
|
|
3501
3561
|
interpretBody(e) {
|
|
3502
|
-
const [n, s] = g.partition(e.body, (i) => i instanceof w || i instanceof
|
|
3562
|
+
const [n, s] = g.partition(e.body, (i) => i instanceof w || i instanceof be);
|
|
3503
3563
|
return [
|
|
3504
3564
|
...this.interpretFields(n),
|
|
3505
3565
|
...this.interpretSubElements(s)
|
|
@@ -3511,9 +3571,9 @@ class qt {
|
|
|
3511
3571
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3512
3572
|
case I.Note:
|
|
3513
3573
|
return this.table.note = {
|
|
3514
|
-
value:
|
|
3574
|
+
value: V(
|
|
3515
3575
|
n.body instanceof oe ? n.body.body[0].callee : n.body.callee
|
|
3516
|
-
).map(
|
|
3576
|
+
).map(ae).unwrap(),
|
|
3517
3577
|
token: _(n)
|
|
3518
3578
|
}, [];
|
|
3519
3579
|
case I.Indexes:
|
|
@@ -3528,98 +3588,106 @@ class qt {
|
|
|
3528
3588
|
return s.name = e.partial.variable.value, this.table.partials.push(s), [];
|
|
3529
3589
|
}
|
|
3530
3590
|
interpretFields(e) {
|
|
3531
|
-
|
|
3591
|
+
var r;
|
|
3592
|
+
const i = ((r = this.declarationNode.symbol) != null && r.symbolTable ? [...this.declarationNode.symbol.symbolTable.entries()] : []).filter(([c]) => {
|
|
3593
|
+
const f = ie(c).unwrap_or(null);
|
|
3594
|
+
return (f == null ? void 0 : f.kind) === m.Column;
|
|
3595
|
+
}).length ? [] : [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)], a = e.flatMap((c, f) => c instanceof w ? this.interpretColumn(c) : this.interpretInjection(c, f));
|
|
3596
|
+
return [
|
|
3597
|
+
...i,
|
|
3598
|
+
...a
|
|
3599
|
+
];
|
|
3532
3600
|
}
|
|
3533
3601
|
interpretColumn(e) {
|
|
3534
|
-
var r, c, p,
|
|
3602
|
+
var r, c, f, p, h, d, N, L, v;
|
|
3535
3603
|
const n = [], s = {};
|
|
3536
|
-
s.name =
|
|
3537
|
-
const i =
|
|
3604
|
+
s.name = X(e.callee).unwrap();
|
|
3605
|
+
const i = zt(e.args[0]);
|
|
3538
3606
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = _(e), s.inline_refs = [];
|
|
3539
3607
|
const a = e.args.slice(1);
|
|
3540
3608
|
if (g.last(a) instanceof M) {
|
|
3541
|
-
const A =
|
|
3542
|
-
s.pk = !!((r = A.
|
|
3543
|
-
const P = (v = A.
|
|
3609
|
+
const A = F(a.pop()).getValue();
|
|
3610
|
+
s.pk = !!((r = A[E.PK]) != null && r.length) || !!((c = A[E.PKey]) != null && c.length), s.increment = !!((f = A[E.Increment]) != null && f.length), s.unique = !!((p = A[E.Unique]) != null && p.length), s.not_null = (h = A[E.NotNull]) != null && h.length ? !0 : (d = A[E.Null]) != null && d.length ? !1 : void 0, s.dbdefault = Ht((L = (N = A[E.Default]) == null ? void 0 : N.at(0)) == null ? void 0 : L.value);
|
|
3611
|
+
const P = (v = A[E.Note]) == null ? void 0 : v.at(0);
|
|
3544
3612
|
s.note = P && {
|
|
3545
|
-
value:
|
|
3613
|
+
value: V(P.value).map(ae).unwrap(),
|
|
3546
3614
|
token: _(P)
|
|
3547
3615
|
};
|
|
3548
|
-
const
|
|
3549
|
-
s.inline_refs =
|
|
3550
|
-
const [Ue] =
|
|
3551
|
-
if (
|
|
3552
|
-
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
3553
|
-
const
|
|
3616
|
+
const Te = A[E.Ref] || [];
|
|
3617
|
+
s.inline_refs = Te.flatMap((D) => {
|
|
3618
|
+
const [Ue] = je(D.value.expression);
|
|
3619
|
+
if (ht(Ue, e.symbol))
|
|
3620
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", D)), [];
|
|
3621
|
+
const pe = D.value.op, B = q(D.value.expression).unwrap();
|
|
3554
3622
|
let te;
|
|
3555
|
-
if (
|
|
3556
|
-
const [
|
|
3623
|
+
if (B.length === 1) {
|
|
3624
|
+
const [H] = B;
|
|
3557
3625
|
te = {
|
|
3558
3626
|
schemaName: this.table.schemaName,
|
|
3559
3627
|
tableName: this.table.name,
|
|
3560
|
-
fieldNames: [
|
|
3561
|
-
relation:
|
|
3562
|
-
token: _(
|
|
3628
|
+
fieldNames: [H],
|
|
3629
|
+
relation: pe.value,
|
|
3630
|
+
token: _(D)
|
|
3563
3631
|
};
|
|
3564
|
-
} else if (
|
|
3565
|
-
const [
|
|
3632
|
+
} else if (B.length === 2) {
|
|
3633
|
+
const [H, Ee] = B;
|
|
3566
3634
|
te = {
|
|
3567
3635
|
schemaName: null,
|
|
3568
|
-
tableName:
|
|
3569
|
-
fieldNames: [
|
|
3570
|
-
relation:
|
|
3571
|
-
token: _(
|
|
3636
|
+
tableName: H,
|
|
3637
|
+
fieldNames: [Ee],
|
|
3638
|
+
relation: pe.value,
|
|
3639
|
+
token: _(D)
|
|
3572
3640
|
};
|
|
3573
|
-
} else if (
|
|
3574
|
-
const [
|
|
3641
|
+
} else if (B.length === 3) {
|
|
3642
|
+
const [H, Ee, dt] = B;
|
|
3575
3643
|
te = {
|
|
3576
|
-
schemaName:
|
|
3577
|
-
tableName:
|
|
3578
|
-
fieldNames: [
|
|
3579
|
-
relation:
|
|
3580
|
-
token: _(
|
|
3644
|
+
schemaName: H,
|
|
3645
|
+
tableName: Ee,
|
|
3646
|
+
fieldNames: [dt],
|
|
3647
|
+
relation: pe.value,
|
|
3648
|
+
token: _(D)
|
|
3581
3649
|
};
|
|
3582
3650
|
} else {
|
|
3583
|
-
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported",
|
|
3584
|
-
const
|
|
3651
|
+
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", D));
|
|
3652
|
+
const H = B.pop(), Ee = B.pop();
|
|
3585
3653
|
te = {
|
|
3586
|
-
schemaName:
|
|
3587
|
-
tableName:
|
|
3588
|
-
fieldNames: [
|
|
3589
|
-
relation:
|
|
3590
|
-
token: _(
|
|
3654
|
+
schemaName: B.join("."),
|
|
3655
|
+
tableName: Ee,
|
|
3656
|
+
fieldNames: [H],
|
|
3657
|
+
relation: pe.value,
|
|
3658
|
+
token: _(D)
|
|
3591
3659
|
};
|
|
3592
3660
|
}
|
|
3593
|
-
const
|
|
3594
|
-
return n.push(...
|
|
3661
|
+
const de = this.registerInlineRefToEnv(e, Ue, te, D);
|
|
3662
|
+
return n.push(...de), de.length === 0 ? te : [];
|
|
3595
3663
|
});
|
|
3596
3664
|
}
|
|
3597
|
-
return s.pk || (s.pk = a.some((A) =>
|
|
3665
|
+
return s.pk || (s.pk = a.some((A) => W(A).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = a.some((A) => W(A).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3598
3666
|
}
|
|
3599
3667
|
interpretIndexes(e) {
|
|
3600
3668
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3601
|
-
var r, c, p,
|
|
3669
|
+
var r, c, f, p, h, d, N;
|
|
3602
3670
|
const s = { columns: [] }, i = n;
|
|
3603
3671
|
s.token = _(i);
|
|
3604
3672
|
const a = [i.callee, ...i.args];
|
|
3605
3673
|
if (g.last(a) instanceof M) {
|
|
3606
|
-
const L =
|
|
3607
|
-
s.pk = !!((r = L.
|
|
3608
|
-
const v = (
|
|
3674
|
+
const L = F(a.pop()).getValue();
|
|
3675
|
+
s.pk = !!((r = L[E.PK]) != null && r.length), s.unique = !!((c = L[E.Unique]) != null && c.length), s.name = V((p = (f = L[E.Name]) == null ? void 0 : f.at(0)) == null ? void 0 : p.value).unwrap_or(void 0);
|
|
3676
|
+
const v = (h = L[E.Note]) == null ? void 0 : h.at(0);
|
|
3609
3677
|
s.note = v && {
|
|
3610
|
-
value:
|
|
3678
|
+
value: V(v.value).unwrap(),
|
|
3611
3679
|
token: _(v)
|
|
3612
|
-
}, s.type =
|
|
3680
|
+
}, s.type = W((N = (d = L[E.Type]) == null ? void 0 : d.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3613
3681
|
}
|
|
3614
3682
|
return a.flatMap((L) => {
|
|
3615
|
-
if (!(L instanceof
|
|
3683
|
+
if (!(L instanceof ee))
|
|
3616
3684
|
return L;
|
|
3617
3685
|
const v = [];
|
|
3618
|
-
for (; L instanceof
|
|
3686
|
+
for (; L instanceof ee; )
|
|
3619
3687
|
v.push(L.argumentList), L = L.callee;
|
|
3620
3688
|
return v.push(L), v;
|
|
3621
3689
|
}).forEach((L) => {
|
|
3622
|
-
const { functional: v, nonFunctional: A } =
|
|
3690
|
+
const { functional: v, nonFunctional: A } = $e(L).unwrap();
|
|
3623
3691
|
s.columns.push(
|
|
3624
3692
|
...v.map((P) => ({
|
|
3625
3693
|
value: P.value.value,
|
|
@@ -3627,7 +3695,7 @@ class qt {
|
|
|
3627
3695
|
token: _(P)
|
|
3628
3696
|
})),
|
|
3629
3697
|
...A.map((P) => ({
|
|
3630
|
-
value:
|
|
3698
|
+
value: X(P).unwrap(),
|
|
3631
3699
|
type: "column",
|
|
3632
3700
|
token: _(P)
|
|
3633
3701
|
}))
|
|
@@ -3636,13 +3704,13 @@ class qt {
|
|
|
3636
3704
|
})), [];
|
|
3637
3705
|
}
|
|
3638
3706
|
registerInlineRefToEnv(e, n, s, i) {
|
|
3639
|
-
const a =
|
|
3707
|
+
const a = qt(e.symbol, n);
|
|
3640
3708
|
if (this.env.refIds[a])
|
|
3641
3709
|
return [
|
|
3642
3710
|
new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3643
3711
|
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[a])
|
|
3644
3712
|
];
|
|
3645
|
-
const r =
|
|
3713
|
+
const r = Yt(s.relation);
|
|
3646
3714
|
return this.env.refIds[a] = i, this.env.ref.set(i, {
|
|
3647
3715
|
name: null,
|
|
3648
3716
|
schemaName: null,
|
|
@@ -3655,7 +3723,7 @@ class qt {
|
|
|
3655
3723
|
{
|
|
3656
3724
|
schemaName: this.table.schemaName,
|
|
3657
3725
|
tableName: this.table.name,
|
|
3658
|
-
fieldNames: [
|
|
3726
|
+
fieldNames: [W(e.callee).unwrap()],
|
|
3659
3727
|
token: _(e),
|
|
3660
3728
|
relation: r[0]
|
|
3661
3729
|
}
|
|
@@ -3663,60 +3731,7 @@ class qt {
|
|
|
3663
3731
|
}), [];
|
|
3664
3732
|
}
|
|
3665
3733
|
}
|
|
3666
|
-
|
|
3667
|
-
let e = null;
|
|
3668
|
-
t instanceof q && (e = t.argumentList.elementList.map((a) => ee(a) ? a.expression.literal.value : C(a) ? F(a).unwrap() : Y(a).unwrap()).join(","), t = t.callee);
|
|
3669
|
-
let n = "";
|
|
3670
|
-
for (; t instanceof he; )
|
|
3671
|
-
n = `[${t.indexer.elementList.map((a) => a.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3672
|
-
const { name: s, schemaName: i } = be(t);
|
|
3673
|
-
return i.length > 1 ? new z(
|
|
3674
|
-
{
|
|
3675
|
-
schemaName: i.length === 0 ? null : i[0],
|
|
3676
|
-
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3677
|
-
args: e
|
|
3678
|
-
},
|
|
3679
|
-
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3680
|
-
) : new z({
|
|
3681
|
-
schemaName: i.length === 0 ? null : i[0],
|
|
3682
|
-
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3683
|
-
args: e
|
|
3684
|
-
});
|
|
3685
|
-
}
|
|
3686
|
-
function ds(t) {
|
|
3687
|
-
var e, n, s;
|
|
3688
|
-
if (t) {
|
|
3689
|
-
if (C(t))
|
|
3690
|
-
return {
|
|
3691
|
-
value: F(t).unwrap(),
|
|
3692
|
-
type: "string"
|
|
3693
|
-
};
|
|
3694
|
-
if (ee(t))
|
|
3695
|
-
return {
|
|
3696
|
-
type: "number",
|
|
3697
|
-
value: Number.parseFloat(t.expression.literal.value)
|
|
3698
|
-
};
|
|
3699
|
-
if (fe(t))
|
|
3700
|
-
return {
|
|
3701
|
-
value: t.expression.variable.value.toLowerCase(),
|
|
3702
|
-
type: "boolean"
|
|
3703
|
-
};
|
|
3704
|
-
if (t instanceof ae && ct.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
|
|
3705
|
-
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3706
|
-
return {
|
|
3707
|
-
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
3708
|
-
type: "number"
|
|
3709
|
-
};
|
|
3710
|
-
}
|
|
3711
|
-
if (t instanceof ue)
|
|
3712
|
-
return {
|
|
3713
|
-
value: (s = t.value) == null ? void 0 : s.value,
|
|
3714
|
-
type: "expression"
|
|
3715
|
-
};
|
|
3716
|
-
throw new Error("Unreachable");
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
|
-
class Es {
|
|
3734
|
+
class Ns {
|
|
3720
3735
|
constructor(e, n) {
|
|
3721
3736
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3722
3737
|
}
|
|
@@ -3728,12 +3743,12 @@ class Es {
|
|
|
3728
3743
|
];
|
|
3729
3744
|
}
|
|
3730
3745
|
interpretName(e) {
|
|
3731
|
-
const { name: n } =
|
|
3746
|
+
const { name: n } = ge(e);
|
|
3732
3747
|
return this.note.name = n, [];
|
|
3733
3748
|
}
|
|
3734
3749
|
interpretSettingList(e) {
|
|
3735
3750
|
var s, i, a;
|
|
3736
|
-
const n =
|
|
3751
|
+
const n = F(e).getValue();
|
|
3737
3752
|
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Oe((a = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : a.value) : void 0, [];
|
|
3738
3753
|
}
|
|
3739
3754
|
interpretBody(e) {
|
|
@@ -3744,10 +3759,10 @@ class Es {
|
|
|
3744
3759
|
}
|
|
3745
3760
|
interpretNote(e) {
|
|
3746
3761
|
const n = g.get(e, "callee.expression.literal.value", "");
|
|
3747
|
-
return this.note.content =
|
|
3762
|
+
return this.note.content = ae(n), [];
|
|
3748
3763
|
}
|
|
3749
3764
|
}
|
|
3750
|
-
class
|
|
3765
|
+
class Jt {
|
|
3751
3766
|
constructor(e, n) {
|
|
3752
3767
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof y ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3753
3768
|
}
|
|
@@ -3758,45 +3773,45 @@ class zt {
|
|
|
3758
3773
|
];
|
|
3759
3774
|
}
|
|
3760
3775
|
interpretName(e) {
|
|
3761
|
-
const n = [], s =
|
|
3776
|
+
const n = [], s = q(this.declarationNode.name).unwrap_or([]);
|
|
3762
3777
|
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
|
|
3763
3778
|
}
|
|
3764
3779
|
interpretBody(e) {
|
|
3765
3780
|
return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
3766
3781
|
}
|
|
3767
3782
|
interpretField(e) {
|
|
3768
|
-
var
|
|
3769
|
-
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, a =
|
|
3770
|
-
if (
|
|
3783
|
+
var p, h, d, N, L, v, A;
|
|
3784
|
+
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, a = je(s), r = je(i);
|
|
3785
|
+
if (ht(a, r))
|
|
3771
3786
|
return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3772
|
-
const c =
|
|
3787
|
+
const c = qt(a, r);
|
|
3773
3788
|
if (this.env.refIds[c])
|
|
3774
3789
|
return [
|
|
3775
3790
|
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3776
3791
|
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
|
|
3777
3792
|
];
|
|
3778
3793
|
if (e.args[0]) {
|
|
3779
|
-
const P =
|
|
3780
|
-
this.ref.onDelete =
|
|
3781
|
-
const
|
|
3782
|
-
this.ref.onUpdate =
|
|
3794
|
+
const P = F(e.args[0]).getValue(), Te = (h = (p = P.delete) == null ? void 0 : p.at(0)) == null ? void 0 : h.value;
|
|
3795
|
+
this.ref.onDelete = Te instanceof ne ? we(Te).unwrap_or(void 0) : W(Te).unwrap_or(void 0);
|
|
3796
|
+
const D = (N = (d = P.update) == null ? void 0 : d.at(0)) == null ? void 0 : N.value;
|
|
3797
|
+
this.ref.onUpdate = D instanceof ne ? we(D).unwrap_or(void 0) : W(D).unwrap_or(void 0), this.ref.color = (L = P.color) != null && L.length ? Oe((A = (v = P.color) == null ? void 0 : v.at(0)) == null ? void 0 : A.value) : void 0;
|
|
3783
3798
|
}
|
|
3784
|
-
const
|
|
3799
|
+
const f = Yt(n);
|
|
3785
3800
|
return this.ref.endpoints = [
|
|
3786
3801
|
{
|
|
3787
|
-
...
|
|
3788
|
-
relation:
|
|
3802
|
+
..._t(s, this.container),
|
|
3803
|
+
relation: f[0],
|
|
3789
3804
|
token: _(s)
|
|
3790
3805
|
},
|
|
3791
3806
|
{
|
|
3792
|
-
...
|
|
3793
|
-
relation:
|
|
3807
|
+
..._t(i, this.container),
|
|
3808
|
+
relation: f[1],
|
|
3794
3809
|
token: _(i)
|
|
3795
3810
|
}
|
|
3796
3811
|
], this.env.refIds[c] = this.declarationNode, [];
|
|
3797
3812
|
}
|
|
3798
3813
|
}
|
|
3799
|
-
class
|
|
3814
|
+
class Kt {
|
|
3800
3815
|
constructor(e, n) {
|
|
3801
3816
|
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3802
3817
|
}
|
|
@@ -3809,11 +3824,11 @@ class Ht {
|
|
|
3809
3824
|
), e;
|
|
3810
3825
|
}
|
|
3811
3826
|
interpretName(e) {
|
|
3812
|
-
const n = [], { name: s, schemaName: i } =
|
|
3827
|
+
const n = [], { name: s, schemaName: i } = ge(e);
|
|
3813
3828
|
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3814
3829
|
}
|
|
3815
3830
|
interpretBody(e) {
|
|
3816
|
-
const [n, s] =
|
|
3831
|
+
const [n, s] = Pt(e.body, (i) => i instanceof w);
|
|
3817
3832
|
return [
|
|
3818
3833
|
...this.interpretFields(n),
|
|
3819
3834
|
...this.interpretSubElements(s)
|
|
@@ -3825,9 +3840,9 @@ class Ht {
|
|
|
3825
3840
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3826
3841
|
case "note":
|
|
3827
3842
|
this.tableGroup.note = {
|
|
3828
|
-
value:
|
|
3843
|
+
value: V(
|
|
3829
3844
|
n.body instanceof oe ? n.body.body[0].callee : n.body.callee
|
|
3830
|
-
).map(
|
|
3845
|
+
).map(ae).unwrap(),
|
|
3831
3846
|
token: _(n)
|
|
3832
3847
|
};
|
|
3833
3848
|
break;
|
|
@@ -3838,12 +3853,12 @@ class Ht {
|
|
|
3838
3853
|
interpretFields(e) {
|
|
3839
3854
|
const n = [];
|
|
3840
3855
|
return this.tableGroup.tables = e.map((s) => {
|
|
3841
|
-
const i =
|
|
3856
|
+
const i = q(s.callee).unwrap();
|
|
3842
3857
|
i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3843
|
-
const a =
|
|
3858
|
+
const a = _e(s.callee).unwrap().pop().referee.id;
|
|
3844
3859
|
if (this.env.groupOfTable[a]) {
|
|
3845
|
-
const r = this.env.groupOfTable[a], { schemaName: c, name:
|
|
3846
|
-
n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${
|
|
3860
|
+
const r = this.env.groupOfTable[a], { schemaName: c, name: f } = this.env.tableGroups.get(r), p = c ? `${c}.${f}` : f;
|
|
3861
|
+
n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${p}"`, s));
|
|
3847
3862
|
} else
|
|
3848
3863
|
this.env.groupOfTable[a] = this.declarationNode;
|
|
3849
3864
|
return {
|
|
@@ -3854,16 +3869,16 @@ class Ht {
|
|
|
3854
3869
|
}
|
|
3855
3870
|
interpretSettingList(e) {
|
|
3856
3871
|
var i, a, r;
|
|
3857
|
-
const n =
|
|
3872
|
+
const n = F(e).getValue();
|
|
3858
3873
|
this.tableGroup.color = (i = n.color) != null && i.length ? Oe((r = (a = n.color) == null ? void 0 : a.at(0)) == null ? void 0 : r.value) : void 0;
|
|
3859
3874
|
const [s] = n.note || [];
|
|
3860
3875
|
return this.tableGroup.note = s && {
|
|
3861
|
-
value:
|
|
3876
|
+
value: V(s == null ? void 0 : s.value).map(ae).unwrap(),
|
|
3862
3877
|
token: _(s)
|
|
3863
3878
|
}, [];
|
|
3864
3879
|
}
|
|
3865
3880
|
}
|
|
3866
|
-
class
|
|
3881
|
+
class Zt {
|
|
3867
3882
|
constructor(e, n) {
|
|
3868
3883
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3869
3884
|
}
|
|
@@ -3871,76 +3886,23 @@ class Qt {
|
|
|
3871
3886
|
return this.enum.token = _(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3872
3887
|
}
|
|
3873
3888
|
interpretName(e) {
|
|
3874
|
-
const { name: n, schemaName: s } =
|
|
3889
|
+
const { name: n, schemaName: s } = ge(e);
|
|
3875
3890
|
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
|
|
3876
3891
|
}
|
|
3877
3892
|
interpretBody(e) {
|
|
3878
3893
|
return e.body.flatMap((n) => {
|
|
3879
3894
|
var c;
|
|
3880
3895
|
const s = n, i = {};
|
|
3881
|
-
i.token = _(s), i.name =
|
|
3882
|
-
const r = (c =
|
|
3896
|
+
i.token = _(s), i.name = W(s.callee).unwrap();
|
|
3897
|
+
const r = (c = F(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3883
3898
|
return i.note = r && {
|
|
3884
|
-
value:
|
|
3899
|
+
value: V(r.value).map(ae).unwrap(),
|
|
3885
3900
|
token: _(r)
|
|
3886
3901
|
}, this.enum.values.push(i), [];
|
|
3887
3902
|
});
|
|
3888
3903
|
}
|
|
3889
3904
|
}
|
|
3890
|
-
|
|
3891
|
-
let e = null, n = t;
|
|
3892
|
-
n instanceof q && (e = n.argumentList.elementList.map((r) => ee(r) ? r.expression.literal.value : C(r) ? F(r).unwrap() : Y(r).unwrap()).join(","), n = n.callee);
|
|
3893
|
-
let s = "";
|
|
3894
|
-
for (; n instanceof he; )
|
|
3895
|
-
s = `[${n.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${s}`, n = n.array;
|
|
3896
|
-
const { name: i, schemaName: a } = be(t);
|
|
3897
|
-
return a.length > 1 ? new z(
|
|
3898
|
-
{
|
|
3899
|
-
schemaName: a.length === 0 ? null : a[0],
|
|
3900
|
-
type_name: `${i}${s}${e ? `(${e})` : ""}`,
|
|
3901
|
-
args: e
|
|
3902
|
-
},
|
|
3903
|
-
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3904
|
-
) : new z({
|
|
3905
|
-
schemaName: a.length === 0 ? null : a[0],
|
|
3906
|
-
type_name: `${i}${s}${e ? `(${e})` : ""}`,
|
|
3907
|
-
args: e
|
|
3908
|
-
});
|
|
3909
|
-
}
|
|
3910
|
-
function Ts(t) {
|
|
3911
|
-
var e, n;
|
|
3912
|
-
if (t) {
|
|
3913
|
-
if (C(t))
|
|
3914
|
-
return {
|
|
3915
|
-
value: F(t).unwrap(),
|
|
3916
|
-
type: "string"
|
|
3917
|
-
};
|
|
3918
|
-
if (ee(t))
|
|
3919
|
-
return {
|
|
3920
|
-
type: "number",
|
|
3921
|
-
value: Number.parseFloat(t.expression.literal.value)
|
|
3922
|
-
};
|
|
3923
|
-
if (fe(t))
|
|
3924
|
-
return {
|
|
3925
|
-
value: t.expression.variable.value.toLowerCase(),
|
|
3926
|
-
type: "boolean"
|
|
3927
|
-
};
|
|
3928
|
-
if (t instanceof ae && ct.includes((e = t.op) == null ? void 0 : e.value) && ee(t.expression)) {
|
|
3929
|
-
const s = Number.parseFloat(t.expression.expression.literal.value);
|
|
3930
|
-
return {
|
|
3931
|
-
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - s : s,
|
|
3932
|
-
type: "number"
|
|
3933
|
-
};
|
|
3934
|
-
}
|
|
3935
|
-
if (t instanceof ue && t.value)
|
|
3936
|
-
return {
|
|
3937
|
-
value: t.value.value,
|
|
3938
|
-
type: "expression"
|
|
3939
|
-
};
|
|
3940
|
-
throw new Error("Unreachable");
|
|
3941
|
-
}
|
|
3942
|
-
}
|
|
3943
|
-
class Jt {
|
|
3905
|
+
class en {
|
|
3944
3906
|
constructor(e, n) {
|
|
3945
3907
|
this.declarationNode = e, this.env = n, this.tablePartial = {
|
|
3946
3908
|
name: void 0,
|
|
@@ -3970,20 +3932,20 @@ class Jt {
|
|
|
3970
3932
|
})), e;
|
|
3971
3933
|
}
|
|
3972
3934
|
interpretName(e) {
|
|
3973
|
-
const { name: n } =
|
|
3935
|
+
const { name: n } = ge(e);
|
|
3974
3936
|
return this.tablePartial.name = n, [];
|
|
3975
3937
|
}
|
|
3976
3938
|
interpretSettingList(e) {
|
|
3977
|
-
const n =
|
|
3939
|
+
const n = F(e).getValue(), s = ln(n[E.HeaderColor]);
|
|
3978
3940
|
this.tablePartial.headerColor = s ? Oe(s.value) : void 0;
|
|
3979
|
-
const [i] = n[
|
|
3941
|
+
const [i] = n[E.Note] || [];
|
|
3980
3942
|
return this.tablePartial.note = i && {
|
|
3981
|
-
value:
|
|
3943
|
+
value: V(i == null ? void 0 : i.value).map(ae).unwrap(),
|
|
3982
3944
|
token: _(i)
|
|
3983
3945
|
}, [];
|
|
3984
3946
|
}
|
|
3985
3947
|
interpretBody(e) {
|
|
3986
|
-
const [n, s] =
|
|
3948
|
+
const [n, s] = Pt(e.body, (i) => i instanceof w);
|
|
3987
3949
|
return [
|
|
3988
3950
|
...this.interpretFields(n),
|
|
3989
3951
|
...this.interpretSubElements(s)
|
|
@@ -3995,9 +3957,9 @@ class Jt {
|
|
|
3995
3957
|
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3996
3958
|
case I.Note:
|
|
3997
3959
|
return this.tablePartial.note = {
|
|
3998
|
-
value:
|
|
3960
|
+
value: V(
|
|
3999
3961
|
n.body instanceof oe ? n.body.body[0].callee : n.body.callee
|
|
4000
|
-
).map(
|
|
3962
|
+
).map(ae).unwrap(),
|
|
4001
3963
|
token: _(n)
|
|
4002
3964
|
}, [];
|
|
4003
3965
|
case I.Indexes:
|
|
@@ -4011,86 +3973,86 @@ class Jt {
|
|
|
4011
3973
|
return e.flatMap((n) => this.interpretColumn(n));
|
|
4012
3974
|
}
|
|
4013
3975
|
interpretColumn(e) {
|
|
4014
|
-
var r, c, p,
|
|
3976
|
+
var r, c, f, p, h, d, N, L, v;
|
|
4015
3977
|
const n = [], s = {};
|
|
4016
|
-
s.name =
|
|
4017
|
-
const i =
|
|
3978
|
+
s.name = X(e.callee).unwrap();
|
|
3979
|
+
const i = zt(e.args[0]);
|
|
4018
3980
|
s.type = i.getValue(), n.push(...i.getErrors()), s.token = _(e), s.inline_refs = [];
|
|
4019
3981
|
const a = e.args.slice(1);
|
|
4020
3982
|
if (g.last(a) instanceof M) {
|
|
4021
|
-
const A =
|
|
4022
|
-
s.pk = !!((r = A[
|
|
4023
|
-
const P = (v = A[
|
|
3983
|
+
const A = F(a.pop()).getValue();
|
|
3984
|
+
s.pk = !!((r = A[E.PK]) != null && r.length) || !!((c = A[E.PKey]) != null && c.length), s.increment = !!((f = A[E.Increment]) != null && f.length), s.unique = !!((p = A[E.Unique]) != null && p.length), s.not_null = (h = A[E.NotNull]) != null && h.length ? !0 : (d = A[E.Null]) != null && d.length ? !1 : void 0, s.dbdefault = Ht((L = (N = A[E.Default]) == null ? void 0 : N.at(0)) == null ? void 0 : L.value);
|
|
3985
|
+
const P = (v = A[E.Note]) == null ? void 0 : v.at(0);
|
|
4024
3986
|
s.note = P && {
|
|
4025
|
-
value:
|
|
3987
|
+
value: V(P.value).map(ae).unwrap(),
|
|
4026
3988
|
token: _(P)
|
|
4027
3989
|
};
|
|
4028
|
-
const
|
|
4029
|
-
s.inline_refs =
|
|
4030
|
-
const [Ue] =
|
|
4031
|
-
if (
|
|
4032
|
-
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same",
|
|
4033
|
-
const
|
|
3990
|
+
const Te = A[E.Ref] || [];
|
|
3991
|
+
s.inline_refs = Te.flatMap((D) => {
|
|
3992
|
+
const [Ue] = je(D.value.expression);
|
|
3993
|
+
if (ht(Ue, e.symbol))
|
|
3994
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", D)), [];
|
|
3995
|
+
const pe = D.value.op, B = q(D.value.expression).unwrap();
|
|
4034
3996
|
let te;
|
|
4035
|
-
if (
|
|
4036
|
-
const [
|
|
3997
|
+
if (B.length === 2) {
|
|
3998
|
+
const [de, H] = B;
|
|
4037
3999
|
te = {
|
|
4038
4000
|
schemaName: null,
|
|
4039
|
-
tableName:
|
|
4040
|
-
fieldNames: [
|
|
4041
|
-
relation:
|
|
4042
|
-
token: _(
|
|
4001
|
+
tableName: de,
|
|
4002
|
+
fieldNames: [H],
|
|
4003
|
+
relation: pe.value,
|
|
4004
|
+
token: _(D)
|
|
4043
4005
|
};
|
|
4044
|
-
} else if (
|
|
4045
|
-
const [
|
|
4006
|
+
} else if (B.length === 3) {
|
|
4007
|
+
const [de, H, Ee] = B;
|
|
4046
4008
|
te = {
|
|
4047
|
-
schemaName:
|
|
4048
|
-
tableName:
|
|
4049
|
-
fieldNames: [
|
|
4050
|
-
relation:
|
|
4051
|
-
token: _(
|
|
4009
|
+
schemaName: de,
|
|
4010
|
+
tableName: H,
|
|
4011
|
+
fieldNames: [Ee],
|
|
4012
|
+
relation: pe.value,
|
|
4013
|
+
token: _(D)
|
|
4052
4014
|
};
|
|
4053
4015
|
} else {
|
|
4054
|
-
n.push(new l(o.UNSUPPORTED, "Unsupported",
|
|
4055
|
-
const
|
|
4016
|
+
n.push(new l(o.UNSUPPORTED, "Unsupported", D));
|
|
4017
|
+
const de = B.pop(), H = B.pop();
|
|
4056
4018
|
te = {
|
|
4057
|
-
schemaName:
|
|
4058
|
-
tableName:
|
|
4059
|
-
fieldNames: [
|
|
4060
|
-
relation:
|
|
4061
|
-
token: _(
|
|
4019
|
+
schemaName: B.join("."),
|
|
4020
|
+
tableName: H,
|
|
4021
|
+
fieldNames: [de],
|
|
4022
|
+
relation: pe.value,
|
|
4023
|
+
token: _(D)
|
|
4062
4024
|
};
|
|
4063
4025
|
}
|
|
4064
4026
|
return te;
|
|
4065
4027
|
});
|
|
4066
4028
|
}
|
|
4067
|
-
return s.pk || (s.pk = a.some((A) =>
|
|
4029
|
+
return s.pk || (s.pk = a.some((A) => W(A).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = a.some((A) => W(A).unwrap().toLowerCase() === "unique")), this.tablePartial.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
4068
4030
|
}
|
|
4069
4031
|
interpretIndexes(e) {
|
|
4070
4032
|
return this.tablePartial.indexes.push(...e.body.body.map((n) => {
|
|
4071
|
-
var r, c, p,
|
|
4033
|
+
var r, c, f, p, h, d, N;
|
|
4072
4034
|
const s = { columns: [] }, i = n;
|
|
4073
4035
|
s.token = _(i);
|
|
4074
4036
|
const a = [i.callee, ...i.args];
|
|
4075
4037
|
if (g.last(a) instanceof M) {
|
|
4076
|
-
const L =
|
|
4077
|
-
s.pk = !!((r = L[
|
|
4078
|
-
const v = (
|
|
4038
|
+
const L = F(a.pop()).getValue();
|
|
4039
|
+
s.pk = !!((r = L[E.PK]) != null && r.length), s.unique = !!((c = L[E.Unique]) != null && c.length), s.name = V((p = (f = L[E.Name]) == null ? void 0 : f.at(0)) == null ? void 0 : p.value).unwrap_or(void 0);
|
|
4040
|
+
const v = (h = L[E.Note]) == null ? void 0 : h.at(0);
|
|
4079
4041
|
s.note = v && {
|
|
4080
|
-
value:
|
|
4042
|
+
value: V(v.value).unwrap(),
|
|
4081
4043
|
token: _(v)
|
|
4082
|
-
}, s.type =
|
|
4044
|
+
}, s.type = W((N = (d = L[E.Type]) == null ? void 0 : d.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
4083
4045
|
}
|
|
4084
4046
|
return a.flatMap((L) => {
|
|
4085
|
-
if (!(L instanceof
|
|
4047
|
+
if (!(L instanceof ee))
|
|
4086
4048
|
return L;
|
|
4087
4049
|
const v = [];
|
|
4088
4050
|
let A = L;
|
|
4089
|
-
for (; A instanceof
|
|
4051
|
+
for (; A instanceof ee; )
|
|
4090
4052
|
v.push(A.argumentList), A = A.callee;
|
|
4091
4053
|
return v.push(A), v;
|
|
4092
4054
|
}).forEach((L) => {
|
|
4093
|
-
const { functional: v, nonFunctional: A } =
|
|
4055
|
+
const { functional: v, nonFunctional: A } = $e(L).unwrap();
|
|
4094
4056
|
s.columns.push(
|
|
4095
4057
|
...v.map((P) => ({
|
|
4096
4058
|
value: P.value.value,
|
|
@@ -4098,7 +4060,7 @@ class Jt {
|
|
|
4098
4060
|
token: _(P)
|
|
4099
4061
|
})),
|
|
4100
4062
|
...A.map((P) => ({
|
|
4101
|
-
value:
|
|
4063
|
+
value: X(P).unwrap(),
|
|
4102
4064
|
type: "column",
|
|
4103
4065
|
token: _(P)
|
|
4104
4066
|
}))
|
|
@@ -4107,7 +4069,7 @@ class Jt {
|
|
|
4107
4069
|
})), [];
|
|
4108
4070
|
}
|
|
4109
4071
|
}
|
|
4110
|
-
class
|
|
4072
|
+
class Ts {
|
|
4111
4073
|
constructor(e, n) {
|
|
4112
4074
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [], tablePartials: [] };
|
|
4113
4075
|
}
|
|
@@ -4117,7 +4079,7 @@ class ms {
|
|
|
4117
4079
|
interpretName(e) {
|
|
4118
4080
|
if (!e)
|
|
4119
4081
|
return this.project.name = null, [];
|
|
4120
|
-
const { name: n } =
|
|
4082
|
+
const { name: n } = ge(e);
|
|
4121
4083
|
return this.project.name = n, [];
|
|
4122
4084
|
}
|
|
4123
4085
|
interpretBody(e) {
|
|
@@ -4126,37 +4088,37 @@ class ms {
|
|
|
4126
4088
|
const s = n;
|
|
4127
4089
|
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
4128
4090
|
case "table": {
|
|
4129
|
-
const a = new
|
|
4091
|
+
const a = new Qt(s, this.env).interpret();
|
|
4130
4092
|
return this.project.tables.push(this.env.tables.get(s)), a;
|
|
4131
4093
|
}
|
|
4132
4094
|
case "ref": {
|
|
4133
|
-
const a = new
|
|
4095
|
+
const a = new Jt(s, this.env).interpret();
|
|
4134
4096
|
return this.project.refs.push(this.env.ref.get(s)), a;
|
|
4135
4097
|
}
|
|
4136
4098
|
case "tablegroup": {
|
|
4137
|
-
const a = new
|
|
4099
|
+
const a = new Kt(s, this.env).interpret();
|
|
4138
4100
|
return this.project.tableGroups.push(this.env.tableGroups.get(s)), a;
|
|
4139
4101
|
}
|
|
4140
4102
|
case "enum": {
|
|
4141
|
-
const a = new
|
|
4103
|
+
const a = new Zt(s, this.env).interpret();
|
|
4142
4104
|
return this.project.enums.push(this.env.enums.get(s)), a;
|
|
4143
4105
|
}
|
|
4144
4106
|
case "note":
|
|
4145
4107
|
return this.project.note = {
|
|
4146
|
-
value:
|
|
4108
|
+
value: V(s.body instanceof oe ? s.body.body[0].callee : s.body.callee).map(ae).unwrap(),
|
|
4147
4109
|
token: _(s)
|
|
4148
4110
|
}, [];
|
|
4149
4111
|
case "tablepartial": {
|
|
4150
|
-
const a = new
|
|
4112
|
+
const a = new en(s, this.env).interpret();
|
|
4151
4113
|
return this.project.tablePartials.push(this.env.tablePartials.get(s)), a;
|
|
4152
4114
|
}
|
|
4153
4115
|
default:
|
|
4154
|
-
return this.project[s.type.value.toLowerCase()] =
|
|
4116
|
+
return this.project[s.type.value.toLowerCase()] = V(s.body.callee).unwrap(), [];
|
|
4155
4117
|
}
|
|
4156
4118
|
});
|
|
4157
4119
|
}
|
|
4158
4120
|
}
|
|
4159
|
-
function
|
|
4121
|
+
function ms(t) {
|
|
4160
4122
|
return {
|
|
4161
4123
|
schemas: [],
|
|
4162
4124
|
tables: Array.from(t.tables.values()),
|
|
@@ -4169,7 +4131,7 @@ function bs(t) {
|
|
|
4169
4131
|
tablePartials: Array.from(t.tablePartials.values())
|
|
4170
4132
|
};
|
|
4171
4133
|
}
|
|
4172
|
-
class
|
|
4134
|
+
class bs {
|
|
4173
4135
|
constructor(e) {
|
|
4174
4136
|
this.ast = e, this.env = {
|
|
4175
4137
|
schema: [],
|
|
@@ -4187,30 +4149,30 @@ class Is {
|
|
|
4187
4149
|
}
|
|
4188
4150
|
interpret() {
|
|
4189
4151
|
const e = this.ast.body.flatMap((n) => {
|
|
4190
|
-
switch (
|
|
4152
|
+
switch (Le(n).unwrap_or(void 0)) {
|
|
4191
4153
|
case I.Table:
|
|
4192
|
-
return new
|
|
4154
|
+
return new Qt(n, this.env).interpret();
|
|
4193
4155
|
case I.Note:
|
|
4194
|
-
return new
|
|
4156
|
+
return new Ns(n, this.env).interpret();
|
|
4195
4157
|
case I.Ref:
|
|
4196
|
-
return new
|
|
4158
|
+
return new Jt(n, this.env).interpret();
|
|
4197
4159
|
case I.TableGroup:
|
|
4198
|
-
return new
|
|
4160
|
+
return new Kt(n, this.env).interpret();
|
|
4199
4161
|
case I.TablePartial:
|
|
4200
|
-
return new
|
|
4162
|
+
return new en(n, this.env).interpret();
|
|
4201
4163
|
case I.Enum:
|
|
4202
|
-
return new
|
|
4164
|
+
return new Zt(n, this.env).interpret();
|
|
4203
4165
|
case I.Project:
|
|
4204
|
-
return new
|
|
4166
|
+
return new Ts(n, this.env).interpret();
|
|
4205
4167
|
default:
|
|
4206
4168
|
return [];
|
|
4207
4169
|
}
|
|
4208
4170
|
});
|
|
4209
|
-
return new
|
|
4171
|
+
return new J(ms(this.env), e);
|
|
4210
4172
|
}
|
|
4211
4173
|
}
|
|
4212
4174
|
var k = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(k || {}), R = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(R || {});
|
|
4213
|
-
function
|
|
4175
|
+
function xe(t) {
|
|
4214
4176
|
switch (t) {
|
|
4215
4177
|
case m.Schema:
|
|
4216
4178
|
return k.Module;
|
|
@@ -4230,13 +4192,13 @@ function De(t) {
|
|
|
4230
4192
|
return k.Text;
|
|
4231
4193
|
}
|
|
4232
4194
|
}
|
|
4233
|
-
function
|
|
4195
|
+
function We(t, e) {
|
|
4234
4196
|
if (!t || et(t))
|
|
4235
4197
|
return !1;
|
|
4236
4198
|
for (const n of t.trailingTrivia) {
|
|
4237
4199
|
if (n.start > e)
|
|
4238
4200
|
break;
|
|
4239
|
-
if (n.kind ===
|
|
4201
|
+
if (n.kind === u.NEWLINE && n.end <= e)
|
|
4240
4202
|
return !1;
|
|
4241
4203
|
}
|
|
4242
4204
|
return !0;
|
|
@@ -4246,7 +4208,7 @@ function G() {
|
|
|
4246
4208
|
suggestions: []
|
|
4247
4209
|
};
|
|
4248
4210
|
}
|
|
4249
|
-
function
|
|
4211
|
+
function Ye(t) {
|
|
4250
4212
|
return {
|
|
4251
4213
|
...t,
|
|
4252
4214
|
suggestions: t.suggestions.map((e) => ({
|
|
@@ -4264,83 +4226,83 @@ function Ke(t) {
|
|
|
4264
4226
|
}))
|
|
4265
4227
|
};
|
|
4266
4228
|
}
|
|
4267
|
-
function
|
|
4229
|
+
function ft(t, e) {
|
|
4268
4230
|
return t.getOffsetAt(e);
|
|
4269
4231
|
}
|
|
4270
|
-
class
|
|
4232
|
+
class tn {
|
|
4271
4233
|
constructor(e, n = []) {
|
|
4272
4234
|
this.compiler = e, this.triggerCharacters = n;
|
|
4273
4235
|
}
|
|
4274
4236
|
provideCompletionItems(e, n) {
|
|
4275
|
-
var
|
|
4276
|
-
const s =
|
|
4237
|
+
var h, d;
|
|
4238
|
+
const s = ft(e, n), i = this.compiler.token.flatStream(), { token: a, index: r } = this.compiler.container.token(s), c = r === void 0 ? i[0] : i[r + 1];
|
|
4277
4239
|
if ([
|
|
4278
4240
|
...(a == null ? void 0 : a.trailingTrivia) || [],
|
|
4279
4241
|
...(a == null ? void 0 : a.leadingTrivia) || [],
|
|
4280
4242
|
...(c == null ? void 0 : c.leadingTrivia) || []
|
|
4281
|
-
].find((
|
|
4243
|
+
].find((N) => fn(N) && Se(s, N)))
|
|
4282
4244
|
return G();
|
|
4283
4245
|
if (r === void 0)
|
|
4284
|
-
return
|
|
4285
|
-
if ([
|
|
4246
|
+
return kt();
|
|
4247
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(a.kind) && Se(s, a))
|
|
4286
4248
|
return G();
|
|
4287
|
-
const
|
|
4288
|
-
if (this.compiler.container.scopeKind(s) === O.TOPLEVEL ||
|
|
4289
|
-
return
|
|
4290
|
-
const
|
|
4291
|
-
for (const
|
|
4292
|
-
if (
|
|
4293
|
-
switch ((
|
|
4249
|
+
const f = this.compiler.container.element(s);
|
|
4250
|
+
if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || f instanceof y && f.type && f.type.start <= s && f.type.end >= s)
|
|
4251
|
+
return kt();
|
|
4252
|
+
const p = [...this.compiler.container.stack(s)].reverse();
|
|
4253
|
+
for (const N of p)
|
|
4254
|
+
if (N instanceof Z)
|
|
4255
|
+
switch ((h = N.op) == null ? void 0 : h.value) {
|
|
4294
4256
|
case ">":
|
|
4295
4257
|
case "<":
|
|
4296
4258
|
case "<>":
|
|
4297
4259
|
case "-":
|
|
4298
|
-
return
|
|
4260
|
+
return gt(
|
|
4299
4261
|
this.compiler,
|
|
4300
4262
|
s,
|
|
4301
|
-
|
|
4263
|
+
N
|
|
4302
4264
|
);
|
|
4303
4265
|
}
|
|
4304
|
-
else if (
|
|
4305
|
-
switch ((
|
|
4266
|
+
else if (N instanceof le)
|
|
4267
|
+
switch ((d = N.op) == null ? void 0 : d.value) {
|
|
4306
4268
|
case ">":
|
|
4307
4269
|
case "<":
|
|
4308
4270
|
case "<>":
|
|
4309
4271
|
case "-":
|
|
4310
|
-
return
|
|
4272
|
+
return gt(
|
|
4311
4273
|
this.compiler,
|
|
4312
4274
|
s,
|
|
4313
|
-
|
|
4275
|
+
N
|
|
4314
4276
|
);
|
|
4315
4277
|
case ".":
|
|
4316
|
-
return
|
|
4278
|
+
return nn(
|
|
4317
4279
|
this.compiler,
|
|
4318
4280
|
s,
|
|
4319
|
-
|
|
4281
|
+
N
|
|
4320
4282
|
);
|
|
4321
4283
|
}
|
|
4322
4284
|
else {
|
|
4323
|
-
if (
|
|
4324
|
-
return
|
|
4325
|
-
if (
|
|
4326
|
-
return
|
|
4327
|
-
if (
|
|
4328
|
-
return As(this.compiler, s);
|
|
4329
|
-
if (E instanceof Ae)
|
|
4285
|
+
if (N instanceof se)
|
|
4286
|
+
return vt(this.compiler, s, N);
|
|
4287
|
+
if (N instanceof M)
|
|
4288
|
+
return vt(this.compiler, s, N);
|
|
4289
|
+
if (N instanceof ce)
|
|
4330
4290
|
return Ls(this.compiler, s);
|
|
4331
|
-
if (
|
|
4332
|
-
return
|
|
4333
|
-
if (
|
|
4334
|
-
return
|
|
4291
|
+
if (N instanceof be)
|
|
4292
|
+
return Is(this.compiler, s);
|
|
4293
|
+
if (N instanceof w)
|
|
4294
|
+
return yt(this.compiler, s, N);
|
|
4295
|
+
if (N instanceof y && (N.bodyColon && s >= N.bodyColon.end || N.body && Se(s, N.body)))
|
|
4296
|
+
return yt(this.compiler, s, void 0);
|
|
4335
4297
|
}
|
|
4336
4298
|
return G();
|
|
4337
4299
|
}
|
|
4338
4300
|
}
|
|
4339
|
-
function
|
|
4301
|
+
function Is(t, e) {
|
|
4340
4302
|
const n = t.container.element(e);
|
|
4341
4303
|
return Re(t, e, n, [m.TablePartial]);
|
|
4342
4304
|
}
|
|
4343
|
-
function
|
|
4305
|
+
function gt(t, e, n) {
|
|
4344
4306
|
const s = t.container.scopeKind(e);
|
|
4345
4307
|
if ([
|
|
4346
4308
|
O.REF,
|
|
@@ -4352,7 +4314,7 @@ function vt(t, e, n) {
|
|
|
4352
4314
|
m.Schema,
|
|
4353
4315
|
m.Column
|
|
4354
4316
|
]);
|
|
4355
|
-
return
|
|
4317
|
+
return We(n.op, e) ? Ye(i) : i;
|
|
4356
4318
|
}
|
|
4357
4319
|
return G();
|
|
4358
4320
|
}
|
|
@@ -4366,12 +4328,12 @@ function Re(t, e, n, s) {
|
|
|
4366
4328
|
if ((r = i == null ? void 0 : i.symbol) != null && r.symbolTable) {
|
|
4367
4329
|
const { symbol: c } = i;
|
|
4368
4330
|
a.suggestions.push(
|
|
4369
|
-
...t.symbol.members(c).filter(({ kind:
|
|
4370
|
-
label:
|
|
4371
|
-
insertText:
|
|
4331
|
+
...t.symbol.members(c).filter(({ kind: f }) => s.includes(f)).map(({ name: f, kind: p }) => ({
|
|
4332
|
+
label: f,
|
|
4333
|
+
insertText: f,
|
|
4372
4334
|
insertTextRules: R.KeepWhitespace,
|
|
4373
|
-
kind:
|
|
4374
|
-
sortText:
|
|
4335
|
+
kind: xe(p),
|
|
4336
|
+
sortText: xe(p).toString().padStart(2, "0"),
|
|
4375
4337
|
range: void 0
|
|
4376
4338
|
}))
|
|
4377
4339
|
);
|
|
@@ -4380,49 +4342,49 @@ function Re(t, e, n, s) {
|
|
|
4380
4342
|
}
|
|
4381
4343
|
return Ke(a);
|
|
4382
4344
|
}
|
|
4383
|
-
function
|
|
4345
|
+
function Ls(t, e) {
|
|
4384
4346
|
var s;
|
|
4385
4347
|
switch (t.container.scopeKind(e)) {
|
|
4386
4348
|
case O.INDEXES:
|
|
4387
|
-
return
|
|
4349
|
+
return an(t, e);
|
|
4388
4350
|
case O.REF:
|
|
4389
4351
|
{
|
|
4390
4352
|
const i = [...t.container.stack(e)];
|
|
4391
4353
|
for (; i.length > 0; ) {
|
|
4392
4354
|
const a = i.pop();
|
|
4393
|
-
if (a instanceof
|
|
4394
|
-
return
|
|
4355
|
+
if (a instanceof le && ((s = a.op) == null ? void 0 : s.value) === ".")
|
|
4356
|
+
return nn(
|
|
4395
4357
|
t,
|
|
4396
4358
|
e,
|
|
4397
4359
|
a
|
|
4398
4360
|
);
|
|
4399
4361
|
}
|
|
4400
4362
|
}
|
|
4401
|
-
return
|
|
4363
|
+
return sn(t, e);
|
|
4402
4364
|
}
|
|
4403
4365
|
return G();
|
|
4404
4366
|
}
|
|
4405
|
-
function
|
|
4367
|
+
function vt(t, e, n) {
|
|
4406
4368
|
const { token: s } = t.container.token(e);
|
|
4407
|
-
if ([
|
|
4408
|
-
const i =
|
|
4409
|
-
return (s == null ? void 0 : s.kind) ===
|
|
4369
|
+
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
4370
|
+
const i = wt(t, e);
|
|
4371
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && We(s, e) ? Ye(i) : i;
|
|
4410
4372
|
}
|
|
4411
4373
|
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
4412
|
-
return
|
|
4374
|
+
return wt(t, e);
|
|
4413
4375
|
if (n.name instanceof ne) {
|
|
4414
|
-
const i =
|
|
4376
|
+
const i = As(
|
|
4415
4377
|
t,
|
|
4416
4378
|
e,
|
|
4417
4379
|
we(n.name).unwrap_or("")
|
|
4418
4380
|
);
|
|
4419
|
-
return (s == null ? void 0 : s.kind) ===
|
|
4381
|
+
return (s == null ? void 0 : s.kind) === u.COLON && We(s, e) ? Ye(i) : i;
|
|
4420
4382
|
}
|
|
4421
4383
|
return G();
|
|
4422
4384
|
}
|
|
4423
|
-
function
|
|
4385
|
+
function wt(t, e) {
|
|
4424
4386
|
const n = t.container.element(e);
|
|
4425
|
-
if (n instanceof
|
|
4387
|
+
if (n instanceof K)
|
|
4426
4388
|
return G();
|
|
4427
4389
|
const s = t.container.scopeKind(e);
|
|
4428
4390
|
if (n.body && !Se(e, n.body)) {
|
|
@@ -4430,10 +4392,10 @@ function yt(t, e) {
|
|
|
4430
4392
|
switch (s) {
|
|
4431
4393
|
case O.TABLE:
|
|
4432
4394
|
case O.TABLEPARTIAL:
|
|
4433
|
-
i = [
|
|
4395
|
+
i = [E.HeaderColor, E.Note];
|
|
4434
4396
|
break;
|
|
4435
4397
|
case O.TABLEGROUP:
|
|
4436
|
-
i = [
|
|
4398
|
+
i = [E.Color, E.Note];
|
|
4437
4399
|
break;
|
|
4438
4400
|
default:
|
|
4439
4401
|
i = [];
|
|
@@ -4454,12 +4416,12 @@ function yt(t, e) {
|
|
|
4454
4416
|
return {
|
|
4455
4417
|
suggestions: [
|
|
4456
4418
|
...[
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4419
|
+
E.PK,
|
|
4420
|
+
E.PKey,
|
|
4421
|
+
E.Null,
|
|
4422
|
+
E.NotNull,
|
|
4423
|
+
E.Increment,
|
|
4424
|
+
E.Unique
|
|
4463
4425
|
].map((i) => ({
|
|
4464
4426
|
label: i,
|
|
4465
4427
|
insertText: i,
|
|
@@ -4467,7 +4429,7 @@ function yt(t, e) {
|
|
|
4467
4429
|
insertTextRules: R.KeepWhitespace,
|
|
4468
4430
|
range: void 0
|
|
4469
4431
|
})),
|
|
4470
|
-
...[
|
|
4432
|
+
...[E.Ref, E.Default, E.Note].map((i) => ({
|
|
4471
4433
|
label: i,
|
|
4472
4434
|
insertText: `${i}: `,
|
|
4473
4435
|
kind: k.Property,
|
|
@@ -4479,7 +4441,7 @@ function yt(t, e) {
|
|
|
4479
4441
|
case O.ENUM:
|
|
4480
4442
|
return {
|
|
4481
4443
|
suggestions: [
|
|
4482
|
-
...[
|
|
4444
|
+
...[E.Note].map((i) => ({
|
|
4483
4445
|
label: i,
|
|
4484
4446
|
insertText: `${i}: `,
|
|
4485
4447
|
kind: k.Property,
|
|
@@ -4491,14 +4453,14 @@ function yt(t, e) {
|
|
|
4491
4453
|
case O.INDEXES:
|
|
4492
4454
|
return {
|
|
4493
4455
|
suggestions: [
|
|
4494
|
-
...[
|
|
4456
|
+
...[E.Unique, E.PK].map((i) => ({
|
|
4495
4457
|
label: i,
|
|
4496
4458
|
insertText: i,
|
|
4497
4459
|
insertTextRules: R.KeepWhitespace,
|
|
4498
4460
|
kind: k.Property,
|
|
4499
4461
|
range: void 0
|
|
4500
4462
|
})),
|
|
4501
|
-
...[
|
|
4463
|
+
...[E.Note, E.Name, E.Type].map((i) => ({
|
|
4502
4464
|
label: i,
|
|
4503
4465
|
insertText: `${i}: `,
|
|
4504
4466
|
kind: k.Property,
|
|
@@ -4509,7 +4471,7 @@ function yt(t, e) {
|
|
|
4509
4471
|
};
|
|
4510
4472
|
case O.REF:
|
|
4511
4473
|
return {
|
|
4512
|
-
suggestions: [
|
|
4474
|
+
suggestions: [E.Update, E.Delete].map((i) => ({
|
|
4513
4475
|
label: i,
|
|
4514
4476
|
insertText: `${i}: `,
|
|
4515
4477
|
kind: k.Property,
|
|
@@ -4520,7 +4482,7 @@ function yt(t, e) {
|
|
|
4520
4482
|
}
|
|
4521
4483
|
return G();
|
|
4522
4484
|
}
|
|
4523
|
-
function
|
|
4485
|
+
function As(t, e, n) {
|
|
4524
4486
|
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
4525
4487
|
case "update":
|
|
4526
4488
|
case "delete":
|
|
@@ -4546,43 +4508,43 @@ function _s(t, e, n) {
|
|
|
4546
4508
|
}
|
|
4547
4509
|
return G();
|
|
4548
4510
|
}
|
|
4549
|
-
function
|
|
4550
|
-
const s =
|
|
4551
|
-
if (s.pop(), s.some((a) =>
|
|
4511
|
+
function nn(t, e, n) {
|
|
4512
|
+
const s = _e(n).unwrap_or([]);
|
|
4513
|
+
if (s.pop(), s.some((a) => !$(a)))
|
|
4552
4514
|
return G();
|
|
4553
|
-
const i = s.map((a) =>
|
|
4515
|
+
const i = s.map((a) => W(a).unwrap());
|
|
4554
4516
|
return Ke({
|
|
4555
4517
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: a }) => t.symbol.members(a)).map(({ kind: a, name: r }) => ({
|
|
4556
4518
|
label: r,
|
|
4557
4519
|
insertText: r,
|
|
4558
|
-
kind:
|
|
4520
|
+
kind: xe(a),
|
|
4559
4521
|
range: void 0
|
|
4560
4522
|
}))
|
|
4561
4523
|
});
|
|
4562
4524
|
}
|
|
4563
|
-
function
|
|
4525
|
+
function yt(t, e, n) {
|
|
4564
4526
|
var i;
|
|
4565
4527
|
switch (t.container.scopeKind(e)) {
|
|
4566
4528
|
case O.TABLE:
|
|
4567
4529
|
case O.TABLEPARTIAL:
|
|
4568
|
-
return
|
|
4530
|
+
return gs(t, e, n);
|
|
4569
4531
|
case O.PROJECT:
|
|
4570
|
-
return
|
|
4532
|
+
return vs(t, e, n);
|
|
4571
4533
|
case O.INDEXES:
|
|
4572
|
-
return
|
|
4534
|
+
return ys(t, e);
|
|
4573
4535
|
case O.ENUM:
|
|
4574
|
-
return
|
|
4536
|
+
return _s(t, e, n);
|
|
4575
4537
|
case O.REF: {
|
|
4576
|
-
const a =
|
|
4577
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) ===
|
|
4538
|
+
const a = sn(t, e);
|
|
4539
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && We(t.container.token(e).token, e) ? Ye(a) : a;
|
|
4578
4540
|
}
|
|
4579
4541
|
case O.TABLEGROUP:
|
|
4580
|
-
return
|
|
4542
|
+
return ws(t);
|
|
4581
4543
|
default:
|
|
4582
4544
|
return G();
|
|
4583
4545
|
}
|
|
4584
4546
|
}
|
|
4585
|
-
function
|
|
4547
|
+
function kt() {
|
|
4586
4548
|
return {
|
|
4587
4549
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref", "TablePartial"].map((t) => ({
|
|
4588
4550
|
label: t,
|
|
@@ -4593,14 +4555,14 @@ function Pt() {
|
|
|
4593
4555
|
}))
|
|
4594
4556
|
};
|
|
4595
4557
|
}
|
|
4596
|
-
function
|
|
4597
|
-
return n != null && n.callee &&
|
|
4558
|
+
function _s(t, e, n) {
|
|
4559
|
+
return n != null && n.callee && pt(e, n) === 1 ? Re(t, e, t.container.element(e), [
|
|
4598
4560
|
m.Schema,
|
|
4599
4561
|
m.Table,
|
|
4600
4562
|
m.Column
|
|
4601
4563
|
]) : G();
|
|
4602
4564
|
}
|
|
4603
|
-
function
|
|
4565
|
+
function gs(t, e, n) {
|
|
4604
4566
|
const s = ["Note", "indexes"];
|
|
4605
4567
|
if (!(n != null && n.callee))
|
|
4606
4568
|
return {
|
|
@@ -4612,7 +4574,7 @@ function vs(t, e, n) {
|
|
|
4612
4574
|
range: void 0
|
|
4613
4575
|
}))
|
|
4614
4576
|
};
|
|
4615
|
-
const i =
|
|
4577
|
+
const i = pt(e, n);
|
|
4616
4578
|
return i === 0 ? {
|
|
4617
4579
|
suggestions: s.map((a) => ({
|
|
4618
4580
|
label: a,
|
|
@@ -4621,11 +4583,11 @@ function vs(t, e, n) {
|
|
|
4621
4583
|
kind: k.Keyword,
|
|
4622
4584
|
range: void 0
|
|
4623
4585
|
}))
|
|
4624
|
-
} : i === 1 ?
|
|
4586
|
+
} : i === 1 ? ks(t, e) : G();
|
|
4625
4587
|
}
|
|
4626
|
-
function
|
|
4588
|
+
function vs(t, e, n) {
|
|
4627
4589
|
const s = ["Table", "TableGroup", "Enum", "Note", "Ref", "TablePartial"];
|
|
4628
|
-
return n != null && n.callee ?
|
|
4590
|
+
return n != null && n.callee ? pt(e, n) === 0 ? {
|
|
4629
4591
|
suggestions: s.map((a) => ({
|
|
4630
4592
|
label: a,
|
|
4631
4593
|
insertText: a,
|
|
@@ -4643,19 +4605,19 @@ function ws(t, e, n) {
|
|
|
4643
4605
|
}))
|
|
4644
4606
|
};
|
|
4645
4607
|
}
|
|
4646
|
-
function
|
|
4608
|
+
function sn(t, e) {
|
|
4647
4609
|
return Re(t, e, t.container.element(e), [
|
|
4648
4610
|
m.Schema,
|
|
4649
4611
|
m.Table,
|
|
4650
4612
|
m.Column
|
|
4651
4613
|
]);
|
|
4652
4614
|
}
|
|
4653
|
-
function
|
|
4615
|
+
function ws(t) {
|
|
4654
4616
|
return {
|
|
4655
4617
|
suggestions: [
|
|
4656
4618
|
...Ke({
|
|
4657
4619
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
4658
|
-
const n =
|
|
4620
|
+
const n = ie(e).unwrap_or(void 0);
|
|
4659
4621
|
if (n === void 0)
|
|
4660
4622
|
return [];
|
|
4661
4623
|
const { kind: s, name: i } = n;
|
|
@@ -4663,7 +4625,7 @@ function ys(t) {
|
|
|
4663
4625
|
label: i,
|
|
4664
4626
|
insertText: i,
|
|
4665
4627
|
insertTextRules: R.KeepWhitespace,
|
|
4666
|
-
kind:
|
|
4628
|
+
kind: xe(s),
|
|
4667
4629
|
range: void 0
|
|
4668
4630
|
};
|
|
4669
4631
|
})
|
|
@@ -4678,10 +4640,10 @@ function ys(t) {
|
|
|
4678
4640
|
]
|
|
4679
4641
|
};
|
|
4680
4642
|
}
|
|
4681
|
-
function
|
|
4682
|
-
return
|
|
4643
|
+
function ys(t, e) {
|
|
4644
|
+
return an(t, e);
|
|
4683
4645
|
}
|
|
4684
|
-
function
|
|
4646
|
+
function ks(t, e) {
|
|
4685
4647
|
return {
|
|
4686
4648
|
suggestions: [
|
|
4687
4649
|
...[
|
|
@@ -4756,14 +4718,14 @@ function Ps(t, e) {
|
|
|
4756
4718
|
]
|
|
4757
4719
|
};
|
|
4758
4720
|
}
|
|
4759
|
-
function
|
|
4721
|
+
function an(t, e) {
|
|
4760
4722
|
const n = t.container.element(e), s = n == null ? void 0 : n.parent;
|
|
4761
|
-
if (!((s == null ? void 0 : s.symbol) instanceof
|
|
4723
|
+
if (!((s == null ? void 0 : s.symbol) instanceof Mt))
|
|
4762
4724
|
return G();
|
|
4763
4725
|
const { symbolTable: i } = s.symbol;
|
|
4764
4726
|
return Ke({
|
|
4765
4727
|
suggestions: [...i.entries()].flatMap(([a]) => {
|
|
4766
|
-
const r =
|
|
4728
|
+
const r = ie(a).unwrap_or(void 0);
|
|
4767
4729
|
if (r === void 0)
|
|
4768
4730
|
return [];
|
|
4769
4731
|
const { name: c } = r;
|
|
@@ -4771,43 +4733,43 @@ function tn(t, e) {
|
|
|
4771
4733
|
label: c,
|
|
4772
4734
|
insertText: c,
|
|
4773
4735
|
insertTextRules: R.KeepWhitespace,
|
|
4774
|
-
kind:
|
|
4736
|
+
kind: xe(m.Column),
|
|
4775
4737
|
range: void 0
|
|
4776
4738
|
};
|
|
4777
4739
|
})
|
|
4778
4740
|
});
|
|
4779
4741
|
}
|
|
4780
|
-
function
|
|
4742
|
+
function pt(t, e) {
|
|
4781
4743
|
if (!e.callee)
|
|
4782
4744
|
return -1;
|
|
4783
4745
|
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
4784
4746
|
return s === -1 ? n.length : s;
|
|
4785
4747
|
}
|
|
4786
|
-
class
|
|
4748
|
+
class rn {
|
|
4787
4749
|
constructor(e) {
|
|
4788
4750
|
this.compiler = e;
|
|
4789
4751
|
}
|
|
4790
4752
|
provideDefinition(e, n) {
|
|
4791
4753
|
var r, c;
|
|
4792
|
-
const { uri: s } = e, i =
|
|
4754
|
+
const { uri: s } = e, i = ft(e, n), a = [...this.compiler.container.stack(i)];
|
|
4793
4755
|
for (; a.length !== 0; ) {
|
|
4794
|
-
const
|
|
4795
|
-
if (!(
|
|
4756
|
+
const f = a.pop();
|
|
4757
|
+
if (!(f != null && f.referee))
|
|
4796
4758
|
continue;
|
|
4797
|
-
let
|
|
4798
|
-
if ((r =
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
].includes(
|
|
4803
|
-
const { startPos:
|
|
4759
|
+
let p;
|
|
4760
|
+
if ((r = f.referee) != null && r.declaration && [
|
|
4761
|
+
me.PRIMARY_EXPRESSION,
|
|
4762
|
+
me.VARIABLE,
|
|
4763
|
+
me.PARTIAL_INJECTION
|
|
4764
|
+
].includes(f == null ? void 0 : f.kind) ? { declaration: p } = f.referee : (c = f.referee) != null && c.injectorDeclaration && (p = f.referee.injectorDeclaration), p) {
|
|
4765
|
+
const { startPos: h, endPos: d } = p;
|
|
4804
4766
|
return [
|
|
4805
4767
|
{
|
|
4806
4768
|
range: {
|
|
4807
|
-
startColumn:
|
|
4808
|
-
startLineNumber:
|
|
4809
|
-
endColumn:
|
|
4810
|
-
endLineNumber:
|
|
4769
|
+
startColumn: h.column + 1,
|
|
4770
|
+
startLineNumber: h.line + 1,
|
|
4771
|
+
endColumn: d.column + 1,
|
|
4772
|
+
endLineNumber: d.line + 1
|
|
4811
4773
|
},
|
|
4812
4774
|
uri: s
|
|
4813
4775
|
}
|
|
@@ -4817,27 +4779,27 @@ class nn {
|
|
|
4817
4779
|
return [];
|
|
4818
4780
|
}
|
|
4819
4781
|
}
|
|
4820
|
-
class
|
|
4782
|
+
class on {
|
|
4821
4783
|
constructor(e) {
|
|
4822
4784
|
this.compiler = e;
|
|
4823
4785
|
}
|
|
4824
4786
|
provideReferences(e, n) {
|
|
4825
|
-
const { uri: s } = e, i =
|
|
4787
|
+
const { uri: s } = e, i = ft(e, n), a = [...this.compiler.container.stack(i)];
|
|
4826
4788
|
for (; a.length !== 0; ) {
|
|
4827
4789
|
const r = a.pop();
|
|
4828
4790
|
if (r && [
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4791
|
+
me.ELEMENT_DECLARATION,
|
|
4792
|
+
me.FUNCTION_APPLICATION,
|
|
4793
|
+
me.PRIMARY_EXPRESSION
|
|
4832
4794
|
].includes(r == null ? void 0 : r.kind)) {
|
|
4833
4795
|
const { symbol: c } = r;
|
|
4834
4796
|
if (c != null && c.references.length)
|
|
4835
|
-
return c.references.map(({ startPos:
|
|
4797
|
+
return c.references.map(({ startPos: f, endPos: p }) => ({
|
|
4836
4798
|
range: {
|
|
4837
|
-
startColumn:
|
|
4838
|
-
startLineNumber:
|
|
4839
|
-
endColumn:
|
|
4840
|
-
endLineNumber:
|
|
4799
|
+
startColumn: f.column + 1,
|
|
4800
|
+
startLineNumber: f.line + 1,
|
|
4801
|
+
endColumn: p.column + 1,
|
|
4802
|
+
endLineNumber: p.line + 1
|
|
4841
4803
|
},
|
|
4842
4804
|
uri: s
|
|
4843
4805
|
}));
|
|
@@ -4850,17 +4812,17 @@ const Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4850
4812
|
__proto__: null,
|
|
4851
4813
|
CompletionItemInsertTextRule: R,
|
|
4852
4814
|
CompletionItemKind: k,
|
|
4853
|
-
DBMLCompletionItemProvider:
|
|
4854
|
-
DBMLDefinitionProvider:
|
|
4855
|
-
DBMLReferencesProvider:
|
|
4815
|
+
DBMLCompletionItemProvider: tn,
|
|
4816
|
+
DBMLDefinitionProvider: rn,
|
|
4817
|
+
DBMLReferencesProvider: on
|
|
4856
4818
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4857
4819
|
var O = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t[t.TABLEPARTIAL = 9] = "TABLEPARTIAL", t))(O || {});
|
|
4858
|
-
class
|
|
4820
|
+
class xs {
|
|
4859
4821
|
constructor() {
|
|
4860
4822
|
this.source = "", this.cache = new Array(
|
|
4861
4823
|
16
|
|
4862
4824
|
/* TOTAL_QUERY_COUNT */
|
|
4863
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4825
|
+
).fill(null), this.nodeIdGenerator = new pn(), this.symbolIdGenerator = new mn(), this.token = {
|
|
4864
4826
|
invalidStream: this.createQuery(
|
|
4865
4827
|
6,
|
|
4866
4828
|
() => this.parse.tokens().filter(Bt)
|
|
@@ -4875,8 +4837,8 @@ class Os {
|
|
|
4875
4837
|
_: this.createQuery(
|
|
4876
4838
|
0,
|
|
4877
4839
|
() => {
|
|
4878
|
-
const e = new
|
|
4879
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new
|
|
4840
|
+
const e = new On(this.source).lex().chain((n) => new Mn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Es(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4841
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new bs(n).interpret().map((a) => ({ ast: n, tokens: s, rawDb: a })));
|
|
4880
4842
|
}
|
|
4881
4843
|
),
|
|
4882
4844
|
ast: this.createQuery(
|
|
@@ -4900,38 +4862,38 @@ class Os {
|
|
|
4900
4862
|
stack: this.createQuery(
|
|
4901
4863
|
10,
|
|
4902
4864
|
(e) => {
|
|
4903
|
-
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), a = s === void 0 ? -1 :
|
|
4865
|
+
const n = this.token.flatStream(), { index: s, token: i } = this.container.token(e), a = s === void 0 ? -1 : cn(n, (p) => !p.isInvalid, s);
|
|
4904
4866
|
if (a === -1)
|
|
4905
4867
|
return [this.parse.ast()];
|
|
4906
4868
|
const r = n[a].start;
|
|
4907
4869
|
let c = this.parse.ast();
|
|
4908
|
-
const
|
|
4870
|
+
const f = [c];
|
|
4909
4871
|
for (; ; ) {
|
|
4910
|
-
const
|
|
4911
|
-
if (
|
|
4872
|
+
const h = xn(c).find((d) => Se(r, d));
|
|
4873
|
+
if (h === void 0 || h instanceof Q)
|
|
4912
4874
|
break;
|
|
4913
|
-
|
|
4875
|
+
f.push(h), c = h;
|
|
4914
4876
|
}
|
|
4915
|
-
if ((i == null ? void 0 : i.kind) ===
|
|
4916
|
-
return
|
|
4917
|
-
for (;
|
|
4918
|
-
let
|
|
4919
|
-
const
|
|
4920
|
-
if (
|
|
4921
|
-
const
|
|
4922
|
-
for (let
|
|
4923
|
-
|
|
4924
|
-
` && (
|
|
4877
|
+
if ((i == null ? void 0 : i.kind) === u.COLON)
|
|
4878
|
+
return f;
|
|
4879
|
+
for (; f.length > 0; ) {
|
|
4880
|
+
let p = !1;
|
|
4881
|
+
const h = Ve(f);
|
|
4882
|
+
if (h instanceof w) {
|
|
4883
|
+
const d = this.parse.source();
|
|
4884
|
+
for (let N = h.end; N < e; N += 1)
|
|
4885
|
+
d[N] === `
|
|
4886
|
+
` && (f.pop(), p = !0);
|
|
4925
4887
|
} else
|
|
4926
|
-
|
|
4927
|
-
if (
|
|
4928
|
-
const
|
|
4929
|
-
|
|
4888
|
+
h instanceof Z || h instanceof le ? this.container.token(e).token !== h.op && (f.pop(), p = !0) : h instanceof M ? h.listCloseBracket && h.end <= e && (f.pop(), p = !0) : h instanceof ce ? h.tupleCloseParen && h.end <= e && (f.pop(), p = !0) : h instanceof oe ? h.blockCloseBrace && h.end <= e && (f.pop(), p = !0) : h instanceof ne || h.end < e && (f.pop(), p = !0);
|
|
4889
|
+
if (p) {
|
|
4890
|
+
const d = Ve(f);
|
|
4891
|
+
d instanceof y && d.end <= e && f.pop();
|
|
4930
4892
|
}
|
|
4931
|
-
if (!
|
|
4893
|
+
if (!p)
|
|
4932
4894
|
break;
|
|
4933
4895
|
}
|
|
4934
|
-
return
|
|
4896
|
+
return f;
|
|
4935
4897
|
}
|
|
4936
4898
|
),
|
|
4937
4899
|
token: this.createQuery(
|
|
@@ -4963,7 +4925,7 @@ class Os {
|
|
|
4963
4925
|
),
|
|
4964
4926
|
scopeKind: this.createQuery(15, (e) => {
|
|
4965
4927
|
var s;
|
|
4966
|
-
if (this.container.element(e) instanceof
|
|
4928
|
+
if (this.container.element(e) instanceof K)
|
|
4967
4929
|
return 8;
|
|
4968
4930
|
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4969
4931
|
case "table":
|
|
@@ -5005,17 +4967,17 @@ class Os {
|
|
|
5005
4967
|
if (!((i = a.symbol) != null && i.symbolTable))
|
|
5006
4968
|
continue;
|
|
5007
4969
|
const { symbolTable: r } = a.symbol;
|
|
5008
|
-
let c = [r],
|
|
5009
|
-
for (const
|
|
5010
|
-
|
|
5011
|
-
(
|
|
5012
|
-
const
|
|
5013
|
-
return !
|
|
4970
|
+
let c = [r], f = [];
|
|
4971
|
+
for (const p of e)
|
|
4972
|
+
f = c.flatMap(
|
|
4973
|
+
(h) => wn(p).flatMap((d) => {
|
|
4974
|
+
const N = h.get(d), L = ie(d).unwrap_or(void 0);
|
|
4975
|
+
return !N || !L ? [] : { ...L, symbol: N };
|
|
5014
4976
|
})
|
|
5015
|
-
), c =
|
|
5016
|
-
(
|
|
4977
|
+
), c = f.flatMap(
|
|
4978
|
+
(h) => h.symbol.symbolTable ? h.symbol.symbolTable : []
|
|
5017
4979
|
);
|
|
5018
|
-
s.push(...
|
|
4980
|
+
s.push(...f);
|
|
5019
4981
|
}
|
|
5020
4982
|
return s;
|
|
5021
4983
|
},
|
|
@@ -5024,7 +4986,7 @@ class Os {
|
|
|
5024
4986
|
members: this.createQuery(
|
|
5025
4987
|
9,
|
|
5026
4988
|
(e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
|
|
5027
|
-
...
|
|
4989
|
+
...ie(n).unwrap(),
|
|
5028
4990
|
symbol: s
|
|
5029
4991
|
})) : []
|
|
5030
4992
|
)
|
|
@@ -5051,14 +5013,14 @@ class Os {
|
|
|
5051
5013
|
}
|
|
5052
5014
|
initMonacoServices() {
|
|
5053
5015
|
return {
|
|
5054
|
-
definitionProvider: new
|
|
5055
|
-
referenceProvider: new
|
|
5056
|
-
autocompletionProvider: new
|
|
5016
|
+
definitionProvider: new rn(this),
|
|
5017
|
+
referenceProvider: new on(this),
|
|
5018
|
+
autocompletionProvider: new tn(this)
|
|
5057
5019
|
};
|
|
5058
5020
|
}
|
|
5059
5021
|
}
|
|
5060
5022
|
export {
|
|
5061
|
-
|
|
5062
|
-
|
|
5023
|
+
xs as Compiler,
|
|
5024
|
+
Ss as serialize,
|
|
5063
5025
|
Ds as services
|
|
5064
5026
|
};
|