@dbml/parse 3.1.3 → 3.1.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/dist/dbml-parse.js +8 -8
- package/dist/dbml-parse.mjs +1353 -1307
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import I from "lodash";
|
|
2
|
-
var
|
|
3
|
-
function
|
|
2
|
+
var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
|
+
function $t(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -36,22 +36,22 @@ function rt(t) {
|
|
|
36
36
|
function at(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
|
-
class
|
|
40
|
-
constructor(e,
|
|
41
|
-
this.kind = e, this.startPos =
|
|
39
|
+
class V {
|
|
40
|
+
constructor(e, n, s, i, r) {
|
|
41
|
+
this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
|
|
42
42
|
}
|
|
43
|
-
static create(e,
|
|
44
|
-
return new
|
|
43
|
+
static create(e, n, s, i, r) {
|
|
44
|
+
return new V(e, n, s, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function bt(t) {
|
|
48
|
-
return t.trailingTrivia.find(({ kind: e }) => e ===
|
|
48
|
+
return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
|
|
49
49
|
}
|
|
50
50
|
function ot(t, e) {
|
|
51
|
-
return e.leadingTrivia.find(({ kind:
|
|
51
|
+
return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || bt(t);
|
|
52
52
|
}
|
|
53
53
|
function Ve(t) {
|
|
54
|
-
return t.trailingTrivia.find(({ kind: e }) => e ===
|
|
54
|
+
return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
|
|
55
55
|
}
|
|
56
56
|
function It(t) {
|
|
57
57
|
return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
|
|
@@ -59,12 +59,12 @@ function It(t) {
|
|
|
59
59
|
function Lt(t) {
|
|
60
60
|
return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return [
|
|
62
|
+
function Wt(t) {
|
|
63
|
+
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class jt {
|
|
68
68
|
constructor() {
|
|
69
69
|
this.id = 0;
|
|
70
70
|
}
|
|
@@ -75,19 +75,19 @@ class Wt {
|
|
|
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
|
-
constructor(e,
|
|
82
|
-
this.id = e, this.kind =
|
|
83
|
-
const i =
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
81
|
+
constructor(e, n, s) {
|
|
82
|
+
this.id = e, this.kind = n;
|
|
83
|
+
const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof V ? Lt(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
|
-
const r = [...
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof
|
|
89
|
+
const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof V ? It(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
@@ -95,163 +95,163 @@ class y {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
var ue = /* @__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))(ue || {});
|
|
98
|
-
class
|
|
99
|
-
constructor({ body: e = [], eof:
|
|
100
|
-
super(
|
|
98
|
+
class F extends x {
|
|
99
|
+
constructor({ body: e = [], eof: n }, s) {
|
|
100
|
+
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class _ extends
|
|
103
|
+
class _ extends x {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
|
-
name:
|
|
107
|
-
as:
|
|
106
|
+
name: n,
|
|
107
|
+
as: s,
|
|
108
108
|
alias: i,
|
|
109
109
|
attributeList: r,
|
|
110
110
|
bodyColon: a,
|
|
111
|
-
body:
|
|
111
|
+
body: c
|
|
112
112
|
}, p) {
|
|
113
113
|
if (super(p, "<element-declaration>", [
|
|
114
114
|
e,
|
|
115
|
-
s,
|
|
116
115
|
n,
|
|
116
|
+
s,
|
|
117
117
|
i,
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
|
-
|
|
121
|
-
]),
|
|
120
|
+
c
|
|
121
|
+
]), c && a && !(c instanceof v || c instanceof _))
|
|
122
122
|
throw new Error("If an element has a simple body, it must be a function application node");
|
|
123
|
-
this.type = e, this.name =
|
|
123
|
+
this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = c;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
class te extends
|
|
127
|
-
constructor({ identifiers: e = [] },
|
|
128
|
-
super(
|
|
126
|
+
class te extends x {
|
|
127
|
+
constructor({ identifiers: e = [] }, n) {
|
|
128
|
+
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class ne extends
|
|
131
|
+
class ne extends x {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
|
-
colon:
|
|
135
|
-
value:
|
|
134
|
+
colon: n,
|
|
135
|
+
value: s
|
|
136
136
|
}, i) {
|
|
137
|
-
super(i, "<attribute>", [e,
|
|
137
|
+
super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class Q extends
|
|
141
|
-
constructor({ op: e, expression:
|
|
142
|
-
super(
|
|
140
|
+
class Q extends x {
|
|
141
|
+
constructor({ op: e, expression: n }, s) {
|
|
142
|
+
super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class q extends
|
|
145
|
+
class q extends x {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
|
-
leftExpression:
|
|
149
|
-
rightExpression:
|
|
148
|
+
leftExpression: n,
|
|
149
|
+
rightExpression: s
|
|
150
150
|
}, i) {
|
|
151
|
-
super(i, "<infix-expression>", [
|
|
151
|
+
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class De extends
|
|
155
|
-
constructor({ op: e, expression:
|
|
156
|
-
super(
|
|
154
|
+
class De extends x {
|
|
155
|
+
constructor({ op: e, expression: n }, s) {
|
|
156
|
+
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class K extends
|
|
160
|
-
constructor({ value: e },
|
|
161
|
-
super(
|
|
159
|
+
class K extends x {
|
|
160
|
+
constructor({ value: e }, n) {
|
|
161
|
+
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class
|
|
165
|
-
constructor({ callee: e, args:
|
|
166
|
-
super(
|
|
164
|
+
class v extends x {
|
|
165
|
+
constructor({ callee: e, args: n = [] }, s) {
|
|
166
|
+
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class ee extends
|
|
169
|
+
class ee extends x {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
|
-
body:
|
|
173
|
-
blockCloseBrace:
|
|
172
|
+
body: n = [],
|
|
173
|
+
blockCloseBrace: s
|
|
174
174
|
}, i) {
|
|
175
|
-
super(i, "<block-expression>", [e, ...
|
|
175
|
+
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class U extends
|
|
178
|
+
class U extends x {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
|
-
elementList:
|
|
182
|
-
commaList:
|
|
181
|
+
elementList: n = [],
|
|
182
|
+
commaList: s = [],
|
|
183
183
|
listCloseBracket: i
|
|
184
184
|
}, r) {
|
|
185
185
|
super(r, "<list-expression>", [
|
|
186
186
|
e,
|
|
187
|
-
...gt(
|
|
187
|
+
...gt(n, s),
|
|
188
188
|
i
|
|
189
|
-
]), this.listOpenBracket = e, this.elementList =
|
|
189
|
+
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class J extends
|
|
192
|
+
class J extends x {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
|
-
elementList:
|
|
196
|
-
commaList:
|
|
195
|
+
elementList: n = [],
|
|
196
|
+
commaList: s = [],
|
|
197
197
|
tupleCloseParen: i
|
|
198
198
|
}, r) {
|
|
199
199
|
super(r, "<tuple-expression>", [
|
|
200
200
|
e,
|
|
201
|
-
...gt(
|
|
201
|
+
...gt(n, s),
|
|
202
202
|
i
|
|
203
|
-
]), this.tupleOpenParen = e, this.elementList =
|
|
203
|
+
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
class Xe extends J {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
|
-
expression:
|
|
210
|
-
groupCloseParen:
|
|
209
|
+
expression: n,
|
|
210
|
+
groupCloseParen: s
|
|
211
211
|
}, i) {
|
|
212
212
|
super(
|
|
213
213
|
{
|
|
214
214
|
tupleOpenParen: e,
|
|
215
|
-
elementList:
|
|
215
|
+
elementList: n && [n],
|
|
216
216
|
commaList: [],
|
|
217
|
-
tupleCloseParen:
|
|
217
|
+
tupleCloseParen: s
|
|
218
218
|
},
|
|
219
219
|
i
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class H extends
|
|
223
|
+
class H extends x {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
|
-
argumentList:
|
|
227
|
-
},
|
|
228
|
-
super(
|
|
226
|
+
argumentList: n
|
|
227
|
+
}, s) {
|
|
228
|
+
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class pe extends
|
|
232
|
-
constructor({ literal: e },
|
|
233
|
-
super(
|
|
231
|
+
class pe extends x {
|
|
232
|
+
constructor({ literal: e }, n) {
|
|
233
|
+
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
237
|
-
constructor({ variable: e },
|
|
238
|
-
super(
|
|
236
|
+
class W extends x {
|
|
237
|
+
constructor({ variable: e }, n) {
|
|
238
|
+
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class R extends
|
|
242
|
-
constructor({ expression: e },
|
|
243
|
-
super(
|
|
241
|
+
class R extends x {
|
|
242
|
+
constructor({ expression: e }, n) {
|
|
243
|
+
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class we extends
|
|
247
|
-
constructor({ pre: e },
|
|
248
|
-
const
|
|
249
|
-
super(
|
|
246
|
+
class we extends x {
|
|
247
|
+
constructor({ pre: e }, n) {
|
|
248
|
+
const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
|
+
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class he extends
|
|
253
|
-
constructor({ expression: e, indexer:
|
|
254
|
-
super(
|
|
252
|
+
class he extends x {
|
|
253
|
+
constructor({ expression: e, indexer: n }, s) {
|
|
254
|
+
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
function gt(t, e) {
|
|
@@ -259,30 +259,30 @@ function gt(t, e) {
|
|
|
259
259
|
return e || [];
|
|
260
260
|
if (!e || e.length === 0)
|
|
261
261
|
return t || [];
|
|
262
|
-
const [
|
|
263
|
-
return (
|
|
262
|
+
const [n] = t, [s] = e;
|
|
263
|
+
return (n.start < s.start ? I.flatten(I.zip(t, e)) : I.flatten(I.zip(e, t))).filter(
|
|
264
264
|
(i) => i !== null
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function as(t, e = !1) {
|
|
268
268
|
return JSON.stringify(
|
|
269
269
|
t,
|
|
270
|
-
function(
|
|
270
|
+
function(n, s) {
|
|
271
271
|
var i;
|
|
272
|
-
return !(this instanceof
|
|
272
|
+
return !(this instanceof F) && n === "symbol" ? s == null ? void 0 : s.id : (
|
|
273
273
|
/* this instanceof SyntaxNode && */
|
|
274
|
-
|
|
275
|
-
symbolTable:
|
|
276
|
-
id:
|
|
277
|
-
references:
|
|
278
|
-
declaration: (i =
|
|
274
|
+
n === "symbol" ? {
|
|
275
|
+
symbolTable: s == null ? void 0 : s.symbolTable,
|
|
276
|
+
id: s == null ? void 0 : s.id,
|
|
277
|
+
references: s == null ? void 0 : s.references.map((r) => r.id),
|
|
278
|
+
declaration: (i = s == null ? void 0 : s.declaration) == null ? void 0 : i.id
|
|
279
279
|
} : (
|
|
280
280
|
/* this instanceof SyntaxNode && */
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
n === "referee" || /* this instanceof SyntaxNode && */
|
|
282
|
+
n === "parent" || /* this instanceof NodeSymbol && */
|
|
283
|
+
n === "declaration" ? s == null ? void 0 : s.id : (
|
|
284
284
|
/* this instanceof NodeSymbol && */
|
|
285
|
-
|
|
285
|
+
n === "symbolTable" ? Object.fromEntries(s.table) : s
|
|
286
286
|
)
|
|
287
287
|
)
|
|
288
288
|
);
|
|
@@ -334,7 +334,7 @@ class A {
|
|
|
334
334
|
return !1;
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t))(m || {});
|
|
337
|
+
var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t))(m || {});
|
|
338
338
|
function $e(t) {
|
|
339
339
|
return `Schema:${t}`;
|
|
340
340
|
}
|
|
@@ -356,6 +356,9 @@ function ze(t) {
|
|
|
356
356
|
function Qe(t) {
|
|
357
357
|
return `TableGroup field:${t}`;
|
|
358
358
|
}
|
|
359
|
+
function Yt(t) {
|
|
360
|
+
return `Note:${t}`;
|
|
361
|
+
}
|
|
359
362
|
function Fe(t, e) {
|
|
360
363
|
switch (e) {
|
|
361
364
|
case "Column":
|
|
@@ -377,20 +380,20 @@ function Fe(t, e) {
|
|
|
377
380
|
}
|
|
378
381
|
}
|
|
379
382
|
function se(t) {
|
|
380
|
-
const [e,
|
|
383
|
+
const [e, n] = t.split(":");
|
|
381
384
|
return Object.values(m).includes(e) ? new S({
|
|
382
|
-
name:
|
|
385
|
+
name: n,
|
|
383
386
|
kind: e
|
|
384
387
|
}) : new A();
|
|
385
388
|
}
|
|
386
|
-
function
|
|
389
|
+
function zt(t) {
|
|
387
390
|
const e = se(t).unwrap_or(void 0);
|
|
388
391
|
if (!e)
|
|
389
392
|
return !1;
|
|
390
|
-
const { kind:
|
|
391
|
-
return
|
|
393
|
+
const { kind: n, name: s } = e;
|
|
394
|
+
return n === "Schema" && s === "public";
|
|
392
395
|
}
|
|
393
|
-
function
|
|
396
|
+
function Qt(t) {
|
|
394
397
|
return [
|
|
395
398
|
$e,
|
|
396
399
|
xe,
|
|
@@ -409,23 +412,23 @@ function ke(t) {
|
|
|
409
412
|
const [e] = t;
|
|
410
413
|
return e >= "0" && e <= "9";
|
|
411
414
|
}
|
|
412
|
-
function
|
|
415
|
+
function qt(t) {
|
|
413
416
|
const [e] = t;
|
|
414
417
|
return ke(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
|
|
415
418
|
}
|
|
416
|
-
function
|
|
419
|
+
function Ie(t) {
|
|
417
420
|
return qe(t) || ke(t);
|
|
418
421
|
}
|
|
419
|
-
function
|
|
420
|
-
const
|
|
421
|
-
for (let i = 0; i <
|
|
422
|
-
|
|
423
|
-
return
|
|
422
|
+
function ct(t, e) {
|
|
423
|
+
const n = [], s = Math.min(t.length, e.length);
|
|
424
|
+
for (let i = 0; i < s; i += 1)
|
|
425
|
+
n.push(t[i], e[i]);
|
|
426
|
+
return n.push(...t.slice(s), ...e.slice(s)), n;
|
|
424
427
|
}
|
|
425
|
-
function
|
|
428
|
+
function Le(t, e) {
|
|
426
429
|
return t >= e.start && t < e.end;
|
|
427
430
|
}
|
|
428
|
-
class
|
|
431
|
+
class Ht {
|
|
429
432
|
constructor() {
|
|
430
433
|
this.id = 0;
|
|
431
434
|
}
|
|
@@ -437,49 +440,49 @@ class Qt {
|
|
|
437
440
|
}
|
|
438
441
|
}
|
|
439
442
|
class _t {
|
|
440
|
-
constructor({ symbolTable: e },
|
|
441
|
-
this.references = [], this.id =
|
|
443
|
+
constructor({ symbolTable: e }, n) {
|
|
444
|
+
this.references = [], this.id = n, this.symbolTable = e;
|
|
442
445
|
}
|
|
443
446
|
}
|
|
444
|
-
class
|
|
445
|
-
constructor({ symbolTable: e, declaration:
|
|
446
|
-
this.references = [], this.id =
|
|
447
|
+
class Jt {
|
|
448
|
+
constructor({ symbolTable: e, declaration: n }, s) {
|
|
449
|
+
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
|
-
class
|
|
450
|
-
constructor({ declaration: e },
|
|
451
|
-
this.references = [], this.id =
|
|
452
|
+
class Zt {
|
|
453
|
+
constructor({ declaration: e }, n) {
|
|
454
|
+
this.references = [], this.id = n, this.declaration = e;
|
|
452
455
|
}
|
|
453
456
|
}
|
|
454
457
|
class At {
|
|
455
|
-
constructor({ symbolTable: e, declaration:
|
|
456
|
-
this.references = [], this.id =
|
|
458
|
+
constructor({ symbolTable: e, declaration: n }, s) {
|
|
459
|
+
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
457
460
|
}
|
|
458
461
|
}
|
|
459
|
-
class
|
|
460
|
-
constructor({ declaration: e },
|
|
461
|
-
this.references = [], this.id =
|
|
462
|
+
class Kt {
|
|
463
|
+
constructor({ declaration: e }, n) {
|
|
464
|
+
this.references = [], this.id = n, this.declaration = e;
|
|
462
465
|
}
|
|
463
466
|
}
|
|
464
|
-
class
|
|
465
|
-
constructor({ symbolTable: e, declaration:
|
|
466
|
-
this.references = [], this.id =
|
|
467
|
+
class en {
|
|
468
|
+
constructor({ symbolTable: e, declaration: n }, s) {
|
|
469
|
+
this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
|
|
467
470
|
}
|
|
468
471
|
}
|
|
469
|
-
class
|
|
470
|
-
constructor({ declaration: e },
|
|
471
|
-
this.references = [], this.id =
|
|
472
|
+
class tn {
|
|
473
|
+
constructor({ declaration: e }, n) {
|
|
474
|
+
this.references = [], this.id = n, this.declaration = e;
|
|
472
475
|
}
|
|
473
476
|
}
|
|
474
477
|
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t))(o || {});
|
|
475
|
-
class
|
|
476
|
-
constructor(e,
|
|
477
|
-
super(
|
|
478
|
+
class l extends Error {
|
|
479
|
+
constructor(e, n, s) {
|
|
480
|
+
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, l.prototype);
|
|
478
481
|
}
|
|
479
482
|
}
|
|
480
|
-
class
|
|
481
|
-
constructor(e,
|
|
482
|
-
this.value = e, this.errors =
|
|
483
|
+
class B {
|
|
484
|
+
constructor(e, n) {
|
|
485
|
+
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
483
486
|
}
|
|
484
487
|
getValue() {
|
|
485
488
|
return this.value;
|
|
@@ -488,54 +491,54 @@ class F {
|
|
|
488
491
|
return this.errors;
|
|
489
492
|
}
|
|
490
493
|
chain(e) {
|
|
491
|
-
const
|
|
492
|
-
return new
|
|
494
|
+
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
495
|
+
return new B(n.value, s);
|
|
493
496
|
}
|
|
494
497
|
map(e) {
|
|
495
|
-
return new
|
|
498
|
+
return new B(e(this.value), this.errors);
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
|
-
function
|
|
501
|
+
function nn(t, e, n) {
|
|
499
502
|
if (!t || !fe(t) || e.length === 0)
|
|
500
503
|
return new A();
|
|
501
|
-
const
|
|
504
|
+
const s = [...e], i = Be(t).unwrap(), r = s.pop();
|
|
502
505
|
if (!(r instanceof ee))
|
|
503
506
|
return new A();
|
|
504
|
-
const a = I.last(
|
|
505
|
-
return
|
|
506
|
-
|
|
507
|
+
const a = I.last(s) instanceof U ? s.pop() : void 0;
|
|
508
|
+
return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
|
|
509
|
+
n.create(_, {
|
|
507
510
|
type: i,
|
|
508
|
-
name:
|
|
509
|
-
as: Be(
|
|
510
|
-
alias:
|
|
511
|
+
name: s[0],
|
|
512
|
+
as: Be(s[1]).unwrap(),
|
|
513
|
+
alias: s[2],
|
|
511
514
|
attributeList: a,
|
|
512
515
|
body: r
|
|
513
516
|
})
|
|
514
|
-
) :
|
|
515
|
-
|
|
517
|
+
) : s.length === 1 ? new S(
|
|
518
|
+
n.create(_, {
|
|
516
519
|
type: i,
|
|
517
|
-
name:
|
|
520
|
+
name: s[0],
|
|
518
521
|
attributeList: a,
|
|
519
522
|
body: r
|
|
520
523
|
})
|
|
521
|
-
) :
|
|
522
|
-
|
|
524
|
+
) : s.length === 0 ? new S(
|
|
525
|
+
n.create(_, {
|
|
523
526
|
type: i,
|
|
524
527
|
attributeList: a,
|
|
525
528
|
body: r
|
|
526
529
|
})
|
|
527
530
|
) : new A();
|
|
528
531
|
}
|
|
529
|
-
function
|
|
530
|
-
return t.kind ===
|
|
532
|
+
function lt(t) {
|
|
533
|
+
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
531
534
|
}
|
|
532
535
|
function E(t) {
|
|
533
|
-
t && (t instanceof
|
|
536
|
+
t && (t instanceof V ? sn(t) : rn(t));
|
|
534
537
|
}
|
|
535
|
-
function
|
|
536
|
-
t.kind !==
|
|
538
|
+
function sn(t) {
|
|
539
|
+
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
537
540
|
}
|
|
538
|
-
function
|
|
541
|
+
function rn(t) {
|
|
539
542
|
if (t instanceof _)
|
|
540
543
|
E(t.type), E(t.name), E(t.as), E(t.alias), E(t.bodyColon), E(t.attributeList), E(t.body);
|
|
541
544
|
else if (t instanceof te)
|
|
@@ -556,13 +559,13 @@ function nn(t) {
|
|
|
556
559
|
E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
|
|
557
560
|
else if (t instanceof H)
|
|
558
561
|
E(t.callee), E(t.argumentList);
|
|
559
|
-
else if (t instanceof
|
|
562
|
+
else if (t instanceof v)
|
|
560
563
|
E(t.callee), t.args.forEach(E);
|
|
561
564
|
else if (t instanceof R)
|
|
562
565
|
E(t.expression);
|
|
563
566
|
else if (t instanceof K)
|
|
564
567
|
E(t.value);
|
|
565
|
-
else if (t instanceof
|
|
568
|
+
else if (t instanceof W)
|
|
566
569
|
E(t.variable);
|
|
567
570
|
else if (t instanceof pe)
|
|
568
571
|
E(t.literal);
|
|
@@ -575,8 +578,8 @@ function vt(t) {
|
|
|
575
578
|
function P(...t) {
|
|
576
579
|
return t.filter((e) => e !== void 0);
|
|
577
580
|
}
|
|
578
|
-
function
|
|
579
|
-
if (t instanceof
|
|
581
|
+
function an(t) {
|
|
582
|
+
if (t instanceof F)
|
|
580
583
|
return P(...t.body, t.eof);
|
|
581
584
|
if (t instanceof _)
|
|
582
585
|
return P(
|
|
@@ -594,7 +597,7 @@ function sn(t) {
|
|
|
594
597
|
return t.identifiers;
|
|
595
598
|
if (t instanceof pe)
|
|
596
599
|
return t.literal ? [t.literal] : [];
|
|
597
|
-
if (t instanceof
|
|
600
|
+
if (t instanceof W)
|
|
598
601
|
return P(t.variable);
|
|
599
602
|
if (t instanceof Q)
|
|
600
603
|
return P(t.op, t.expression);
|
|
@@ -604,20 +607,20 @@ function sn(t) {
|
|
|
604
607
|
return P(t.expression, t.op);
|
|
605
608
|
if (t instanceof K)
|
|
606
609
|
return P(t.value);
|
|
607
|
-
if (t instanceof
|
|
610
|
+
if (t instanceof v)
|
|
608
611
|
return P(t.callee, ...t.args);
|
|
609
612
|
if (t instanceof ee)
|
|
610
613
|
return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
|
|
611
614
|
if (t instanceof U)
|
|
612
615
|
return P(
|
|
613
616
|
t.listOpenBracket,
|
|
614
|
-
...
|
|
617
|
+
...ct(t.elementList, t.commaList),
|
|
615
618
|
t.listCloseBracket
|
|
616
619
|
);
|
|
617
620
|
if (t instanceof J)
|
|
618
621
|
return P(
|
|
619
622
|
t.tupleOpenParen,
|
|
620
|
-
...
|
|
623
|
+
...ct(t.elementList, t.commaList),
|
|
621
624
|
t.tupleCloseParen
|
|
622
625
|
);
|
|
623
626
|
if (t instanceof H)
|
|
@@ -629,28 +632,28 @@ function sn(t) {
|
|
|
629
632
|
function Be(t) {
|
|
630
633
|
return M(t) ? new S(t.expression.variable) : new A();
|
|
631
634
|
}
|
|
632
|
-
function
|
|
635
|
+
function j(t) {
|
|
633
636
|
var e;
|
|
634
|
-
return t instanceof R && (t.expression instanceof
|
|
637
|
+
return t instanceof R && (t.expression instanceof W && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
635
638
|
}
|
|
636
639
|
function M(t) {
|
|
637
|
-
return t instanceof R && t.expression instanceof
|
|
640
|
+
return t instanceof R && t.expression instanceof W && t.expression.variable instanceof V;
|
|
638
641
|
}
|
|
639
642
|
function fe(t) {
|
|
640
643
|
var e;
|
|
641
|
-
return t instanceof R && t.expression instanceof
|
|
644
|
+
return t instanceof R && t.expression instanceof W && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
642
645
|
}
|
|
643
646
|
function He(t) {
|
|
644
647
|
var e;
|
|
645
|
-
return t instanceof q && t.leftExpression instanceof
|
|
648
|
+
return t instanceof q && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
646
649
|
}
|
|
647
650
|
function Re(t) {
|
|
648
651
|
if (t === void 0)
|
|
649
652
|
return new A();
|
|
650
|
-
const e = t.identifiers.map((
|
|
653
|
+
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
651
654
|
return e === "" ? new A() : new S(e);
|
|
652
655
|
}
|
|
653
|
-
class
|
|
656
|
+
class on {
|
|
654
657
|
// list of errors during lexing
|
|
655
658
|
constructor(e) {
|
|
656
659
|
this.start = {
|
|
@@ -677,8 +680,8 @@ class rn {
|
|
|
677
680
|
}
|
|
678
681
|
// Check if the sequence ahead matches `sequence`
|
|
679
682
|
check(e) {
|
|
680
|
-
for (let
|
|
681
|
-
if (e[
|
|
683
|
+
for (let n = 0; n < e.length; n += 1)
|
|
684
|
+
if (e[n] !== this.peek(n))
|
|
682
685
|
return !1;
|
|
683
686
|
return !0;
|
|
684
687
|
}
|
|
@@ -686,63 +689,63 @@ class rn {
|
|
|
686
689
|
match(e) {
|
|
687
690
|
return this.check(e) ? (e.split("").forEach(() => this.advance()), !0) : !1;
|
|
688
691
|
}
|
|
689
|
-
addToken(e,
|
|
690
|
-
this.tokens.push(this.createToken(e,
|
|
692
|
+
addToken(e, n = !1) {
|
|
693
|
+
this.tokens.push(this.createToken(e, n));
|
|
691
694
|
}
|
|
692
|
-
createToken(e,
|
|
693
|
-
return
|
|
695
|
+
createToken(e, n = !1) {
|
|
696
|
+
return V.create(
|
|
694
697
|
e,
|
|
695
698
|
this.start,
|
|
696
699
|
this.current,
|
|
697
700
|
this.text.substring(this.start.offset, this.current.offset),
|
|
698
|
-
|
|
701
|
+
n
|
|
699
702
|
);
|
|
700
703
|
}
|
|
701
704
|
lex() {
|
|
702
|
-
return this.scanTokens(), this.tokens.push(
|
|
705
|
+
return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
|
|
703
706
|
}
|
|
704
707
|
scanTokens() {
|
|
705
708
|
for (; !this.isAtEnd(); ) {
|
|
706
709
|
const e = this.advance();
|
|
707
710
|
switch (e) {
|
|
708
711
|
case " ":
|
|
709
|
-
this.addToken(
|
|
712
|
+
this.addToken(u.SPACE);
|
|
710
713
|
break;
|
|
711
714
|
case "\r":
|
|
712
715
|
break;
|
|
713
716
|
case `
|
|
714
717
|
`:
|
|
715
|
-
this.addToken(
|
|
718
|
+
this.addToken(u.NEWLINE);
|
|
716
719
|
break;
|
|
717
720
|
case " ":
|
|
718
|
-
this.addToken(
|
|
721
|
+
this.addToken(u.TAB);
|
|
719
722
|
break;
|
|
720
723
|
case ",":
|
|
721
|
-
this.addToken(
|
|
724
|
+
this.addToken(u.COMMA);
|
|
722
725
|
break;
|
|
723
726
|
case "(":
|
|
724
|
-
this.addToken(
|
|
727
|
+
this.addToken(u.LPAREN);
|
|
725
728
|
break;
|
|
726
729
|
case ")":
|
|
727
|
-
this.addToken(
|
|
730
|
+
this.addToken(u.RPAREN);
|
|
728
731
|
break;
|
|
729
732
|
case "[":
|
|
730
|
-
this.addToken(
|
|
733
|
+
this.addToken(u.LBRACKET);
|
|
731
734
|
break;
|
|
732
735
|
case "]":
|
|
733
|
-
this.addToken(
|
|
736
|
+
this.addToken(u.RBRACKET);
|
|
734
737
|
break;
|
|
735
738
|
case "{":
|
|
736
|
-
this.addToken(
|
|
739
|
+
this.addToken(u.LBRACE);
|
|
737
740
|
break;
|
|
738
741
|
case "}":
|
|
739
|
-
this.addToken(
|
|
742
|
+
this.addToken(u.RBRACE);
|
|
740
743
|
break;
|
|
741
744
|
case ";":
|
|
742
|
-
this.addToken(
|
|
745
|
+
this.addToken(u.SEMICOLON);
|
|
743
746
|
break;
|
|
744
747
|
case ":":
|
|
745
|
-
this.addToken(
|
|
748
|
+
this.addToken(u.COLON);
|
|
746
749
|
break;
|
|
747
750
|
case "'":
|
|
748
751
|
this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
|
|
@@ -772,11 +775,11 @@ class rn {
|
|
|
772
775
|
this.numericLiteral();
|
|
773
776
|
break;
|
|
774
777
|
}
|
|
775
|
-
this.addToken(
|
|
776
|
-
new
|
|
778
|
+
this.addToken(u.OP, !0), this.errors.push(
|
|
779
|
+
new l(
|
|
777
780
|
o.UNKNOWN_SYMBOL,
|
|
778
781
|
`Unexpected token '${e}'`,
|
|
779
|
-
this.createToken(
|
|
782
|
+
this.createToken(u.OP, !0)
|
|
780
783
|
)
|
|
781
784
|
);
|
|
782
785
|
break;
|
|
@@ -785,27 +788,27 @@ class rn {
|
|
|
785
788
|
}
|
|
786
789
|
}
|
|
787
790
|
gatherTrivia() {
|
|
788
|
-
let e = !0,
|
|
791
|
+
let e = !0, n = [], s;
|
|
789
792
|
const i = [];
|
|
790
793
|
for (const r of this.tokens)
|
|
791
|
-
|
|
794
|
+
$t(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
|
|
792
795
|
this.tokens = i;
|
|
793
796
|
}
|
|
794
797
|
gatherInvalid() {
|
|
795
798
|
let e;
|
|
796
|
-
const
|
|
799
|
+
const n = [], s = [];
|
|
797
800
|
for (e = 0; e < this.tokens.length && vt(this.tokens[e]); e += 1)
|
|
798
|
-
|
|
801
|
+
s.push(this.tokens[e]);
|
|
799
802
|
let i = this.tokens[e];
|
|
800
|
-
for (i.leadingInvalid = [...
|
|
803
|
+
for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
|
|
801
804
|
const r = this.tokens[e];
|
|
802
|
-
r.isInvalid ? i.trailingInvalid.push(r) : (i = r,
|
|
805
|
+
r.isInvalid ? i.trailingInvalid.push(r) : (i = r, n.push(r));
|
|
803
806
|
}
|
|
804
|
-
this.tokens =
|
|
807
|
+
this.tokens = n;
|
|
805
808
|
}
|
|
806
809
|
// Consuming characters until the `stopSequence` is encountered
|
|
807
|
-
consumeUntil(e,
|
|
808
|
-
allowNewline:
|
|
810
|
+
consumeUntil(e, n, {
|
|
811
|
+
allowNewline: s,
|
|
809
812
|
// Whether newline is allowed
|
|
810
813
|
allowEof: i,
|
|
811
814
|
// Whether EOF is allowed
|
|
@@ -813,22 +816,22 @@ class rn {
|
|
|
813
816
|
// Whether to interpret '\' as a backlash
|
|
814
817
|
consumeStopSequence: a = !0
|
|
815
818
|
}) {
|
|
816
|
-
let
|
|
817
|
-
for (; !this.isAtEnd() && (
|
|
818
|
-
`)) && !this.check(
|
|
819
|
-
this.peek() === "\\" && !r ? (this.advance(),
|
|
819
|
+
let c = "";
|
|
820
|
+
for (; !this.isAtEnd() && (s || !this.check(`
|
|
821
|
+
`)) && !this.check(n); )
|
|
822
|
+
this.peek() === "\\" && !r ? (this.advance(), c += this.escapedString()) : c += this.advance();
|
|
820
823
|
if (this.isAtEnd() && !i) {
|
|
821
824
|
const p = this.createToken(e, !0);
|
|
822
825
|
this.tokens.push(p), this.errors.push(
|
|
823
|
-
new
|
|
826
|
+
new l(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
|
|
824
827
|
);
|
|
825
828
|
return;
|
|
826
829
|
}
|
|
827
830
|
if (this.check(`
|
|
828
|
-
`) && !
|
|
831
|
+
`) && !s) {
|
|
829
832
|
const p = this.createToken(e, !0);
|
|
830
833
|
this.tokens.push(p), this.errors.push(
|
|
831
|
-
new
|
|
834
|
+
new l(
|
|
832
835
|
o.UNEXPECTED_NEWLINE,
|
|
833
836
|
"Invalid newline encountered while parsing",
|
|
834
837
|
p
|
|
@@ -836,38 +839,38 @@ class rn {
|
|
|
836
839
|
);
|
|
837
840
|
return;
|
|
838
841
|
}
|
|
839
|
-
a && this.match(
|
|
842
|
+
a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, c, !1));
|
|
840
843
|
}
|
|
841
844
|
singleLineStringLiteral() {
|
|
842
|
-
this.consumeUntil(
|
|
845
|
+
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
843
846
|
allowNewline: !1,
|
|
844
847
|
allowEof: !1,
|
|
845
848
|
raw: !1
|
|
846
849
|
});
|
|
847
850
|
}
|
|
848
851
|
multilineStringLiteral() {
|
|
849
|
-
this.consumeUntil(
|
|
852
|
+
this.consumeUntil(u.STRING_LITERAL, "'''", {
|
|
850
853
|
allowNewline: !0,
|
|
851
854
|
allowEof: !1,
|
|
852
855
|
raw: !1
|
|
853
856
|
});
|
|
854
857
|
}
|
|
855
858
|
functionExpression() {
|
|
856
|
-
this.consumeUntil(
|
|
859
|
+
this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
|
|
857
860
|
allowNewline: !1,
|
|
858
861
|
allowEof: !1,
|
|
859
862
|
raw: !0
|
|
860
863
|
});
|
|
861
864
|
}
|
|
862
865
|
quotedVariable() {
|
|
863
|
-
this.consumeUntil(
|
|
866
|
+
this.consumeUntil(u.QUOTED_STRING, '"', {
|
|
864
867
|
allowNewline: !1,
|
|
865
868
|
allowEof: !1,
|
|
866
869
|
raw: !1
|
|
867
870
|
});
|
|
868
871
|
}
|
|
869
872
|
singleLineComment() {
|
|
870
|
-
this.consumeUntil(
|
|
873
|
+
this.consumeUntil(u.SINGLE_LINE_COMMENT, `
|
|
871
874
|
`, {
|
|
872
875
|
allowNewline: !0,
|
|
873
876
|
allowEof: !0,
|
|
@@ -876,47 +879,47 @@ class rn {
|
|
|
876
879
|
});
|
|
877
880
|
}
|
|
878
881
|
multilineComment() {
|
|
879
|
-
this.consumeUntil(
|
|
882
|
+
this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
|
|
880
883
|
allowNewline: !0,
|
|
881
884
|
allowEof: !1,
|
|
882
885
|
raw: !0
|
|
883
886
|
});
|
|
884
887
|
}
|
|
885
888
|
identifier() {
|
|
886
|
-
for (; !this.isAtEnd() &&
|
|
889
|
+
for (; !this.isAtEnd() && Ie(this.peek()); )
|
|
887
890
|
this.advance();
|
|
888
|
-
this.addToken(
|
|
891
|
+
this.addToken(u.IDENTIFIER);
|
|
889
892
|
}
|
|
890
893
|
operator() {
|
|
891
894
|
for (; rt(this.peek()); )
|
|
892
895
|
this.advance();
|
|
893
|
-
this.addToken(
|
|
896
|
+
this.addToken(u.OP);
|
|
894
897
|
}
|
|
895
898
|
numericLiteral() {
|
|
896
899
|
let e = 0;
|
|
897
900
|
if (this.isAtEnd())
|
|
898
|
-
return this.addToken(
|
|
901
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
899
902
|
for (; !this.isAtEnd(); ) {
|
|
900
|
-
const
|
|
901
|
-
if (e +=
|
|
903
|
+
const s = this.check(".");
|
|
904
|
+
if (e += s ? 1 : 0, e > 1)
|
|
902
905
|
break;
|
|
903
|
-
if (!
|
|
904
|
-
return this.advance(), this.addToken(
|
|
905
|
-
if (!
|
|
906
|
-
return this.addToken(
|
|
907
|
-
if (!
|
|
906
|
+
if (!s && this.current.offset === this.text.length - 1)
|
|
907
|
+
return this.advance(), this.addToken(u.NUMERIC_LITERAL);
|
|
908
|
+
if (!s && !Ie(this.peek()))
|
|
909
|
+
return this.addToken(u.NUMERIC_LITERAL);
|
|
910
|
+
if (!s && !ke(this.peek()))
|
|
908
911
|
break;
|
|
909
912
|
this.advance();
|
|
910
913
|
}
|
|
911
|
-
for (; !this.isAtEnd() && (this.check(".") ||
|
|
914
|
+
for (; !this.isAtEnd() && (this.check(".") || Ie(this.peek())); )
|
|
912
915
|
this.advance();
|
|
913
|
-
const
|
|
914
|
-
this.tokens.push(
|
|
916
|
+
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
917
|
+
this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
915
918
|
}
|
|
916
919
|
colorLiteral() {
|
|
917
|
-
for (; !this.isAtEnd() &&
|
|
920
|
+
for (; !this.isAtEnd() && Ie(this.peek()); )
|
|
918
921
|
this.advance();
|
|
919
|
-
this.addToken(
|
|
922
|
+
this.addToken(u.COLOR_LITERAL);
|
|
920
923
|
}
|
|
921
924
|
escapedString() {
|
|
922
925
|
if (this.isAtEnd())
|
|
@@ -945,8 +948,8 @@ class rn {
|
|
|
945
948
|
return "\f";
|
|
946
949
|
case "u": {
|
|
947
950
|
let e = "";
|
|
948
|
-
for (let
|
|
949
|
-
if (this.isAtEnd() || !
|
|
951
|
+
for (let n = 0; n <= 3; n += 1) {
|
|
952
|
+
if (this.isAtEnd() || !Ie(this.peek()))
|
|
950
953
|
return `\\u${e}`;
|
|
951
954
|
e += this.advance();
|
|
952
955
|
}
|
|
@@ -958,7 +961,7 @@ class rn {
|
|
|
958
961
|
}
|
|
959
962
|
}
|
|
960
963
|
var ye = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ye || {});
|
|
961
|
-
class
|
|
964
|
+
class cn {
|
|
962
965
|
constructor() {
|
|
963
966
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
964
967
|
}
|
|
@@ -984,22 +987,22 @@ class an {
|
|
|
984
987
|
// Call the passed in callback
|
|
985
988
|
// with the guarantee that the passed in context will be pushed and popped properly
|
|
986
989
|
// even in cases of exceptions
|
|
987
|
-
withContextDo(e,
|
|
990
|
+
withContextDo(e, n) {
|
|
988
991
|
return () => {
|
|
989
992
|
this.push(e);
|
|
990
993
|
try {
|
|
991
|
-
return
|
|
994
|
+
return n();
|
|
992
995
|
} finally {
|
|
993
996
|
this.pop();
|
|
994
997
|
}
|
|
995
998
|
};
|
|
996
999
|
}
|
|
997
1000
|
// Return the type of the handler context currently in the context stack to handle `token`
|
|
998
|
-
findHandlerContext(e,
|
|
1001
|
+
findHandlerContext(e, n) {
|
|
999
1002
|
if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
|
|
1000
|
-
for (let
|
|
1001
|
-
switch (e[
|
|
1002
|
-
case
|
|
1003
|
+
for (let s = n; s < e.length - 1; s += 1)
|
|
1004
|
+
switch (e[s].kind) {
|
|
1005
|
+
case u.COMMA:
|
|
1003
1006
|
if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
|
|
1004
1007
|
return [...this.stack].reverse().find(
|
|
1005
1008
|
(r) => [
|
|
@@ -1009,210 +1012,210 @@ class an {
|
|
|
1009
1012
|
].includes(r)
|
|
1010
1013
|
);
|
|
1011
1014
|
break;
|
|
1012
|
-
case
|
|
1015
|
+
case u.RPAREN:
|
|
1013
1016
|
if (this.isWithinGroupExpressionContext())
|
|
1014
1017
|
return 1;
|
|
1015
1018
|
break;
|
|
1016
|
-
case
|
|
1019
|
+
case u.RBRACE:
|
|
1017
1020
|
if (this.isWithinBlockExpressionContext())
|
|
1018
1021
|
return 2;
|
|
1019
1022
|
break;
|
|
1020
|
-
case
|
|
1023
|
+
case u.RBRACKET:
|
|
1021
1024
|
if (this.isWithinListExpressionContext())
|
|
1022
1025
|
return 0;
|
|
1023
1026
|
break;
|
|
1024
1027
|
}
|
|
1025
1028
|
}
|
|
1026
1029
|
}
|
|
1027
|
-
class
|
|
1030
|
+
class ln {
|
|
1028
1031
|
constructor(e) {
|
|
1029
1032
|
this.generator = e;
|
|
1030
1033
|
}
|
|
1031
|
-
create(e,
|
|
1032
|
-
return new e(
|
|
1034
|
+
create(e, n) {
|
|
1035
|
+
return new e(n, this.generator.nextId());
|
|
1033
1036
|
}
|
|
1034
1037
|
}
|
|
1035
1038
|
class d {
|
|
1036
|
-
constructor(e,
|
|
1037
|
-
this.token = e, this.partialNode =
|
|
1039
|
+
constructor(e, n, s) {
|
|
1040
|
+
this.token = e, this.partialNode = n, this.handlerContext = s;
|
|
1038
1041
|
}
|
|
1039
1042
|
}
|
|
1040
|
-
class
|
|
1041
|
-
constructor(e,
|
|
1042
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1043
|
+
class un {
|
|
1044
|
+
constructor(e, n) {
|
|
1045
|
+
this.current = 0, this.errors = [], this.contextStack = new cn(), this.synchronizeProgram = () => {
|
|
1046
|
+
const s = this.peek();
|
|
1047
|
+
s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1045
1048
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1046
1049
|
for (; !this.isAtEnd(); ) {
|
|
1047
|
-
const
|
|
1048
|
-
if (
|
|
1050
|
+
const s = this.peek();
|
|
1051
|
+
if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1049
1052
|
break;
|
|
1050
|
-
E(
|
|
1053
|
+
E(s), this.advance();
|
|
1051
1054
|
}
|
|
1052
1055
|
}, this.synchronizeElementDeclarationAlias = () => {
|
|
1053
1056
|
for (; !this.isAtEnd(); ) {
|
|
1054
|
-
const
|
|
1055
|
-
if (this.check(
|
|
1057
|
+
const s = this.peek();
|
|
1058
|
+
if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1056
1059
|
break;
|
|
1057
|
-
E(
|
|
1060
|
+
E(s), this.advance();
|
|
1058
1061
|
}
|
|
1059
1062
|
}, this.blockExpression = this.contextStack.withContextDo(ye.BlockExpression, () => {
|
|
1060
|
-
const
|
|
1063
|
+
const s = { body: [] }, i = () => this.nodeFactory.create(ee, s);
|
|
1061
1064
|
try {
|
|
1062
|
-
this.consume("Expect an opening brace '{'",
|
|
1065
|
+
this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
|
|
1063
1066
|
} catch (r) {
|
|
1064
1067
|
if (!(r instanceof d))
|
|
1065
1068
|
throw r;
|
|
1066
|
-
if (
|
|
1069
|
+
if (s.blockOpenBrace = r.partialNode, !this.canHandle(r))
|
|
1067
1070
|
throw new d(r.token, i(), r.handlerContext);
|
|
1068
1071
|
this.synchronizeBlock();
|
|
1069
1072
|
}
|
|
1070
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1073
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACE); )
|
|
1071
1074
|
try {
|
|
1072
|
-
|
|
1075
|
+
s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
|
|
1073
1076
|
} catch (r) {
|
|
1074
1077
|
if (!(r instanceof d))
|
|
1075
1078
|
throw r;
|
|
1076
|
-
if (
|
|
1079
|
+
if (s.body.push(r.partialNode), !this.canHandle(r))
|
|
1077
1080
|
throw new d(r.token, i(), r.handlerContext);
|
|
1078
1081
|
this.synchronizeBlock();
|
|
1079
1082
|
}
|
|
1080
1083
|
try {
|
|
1081
|
-
this.consume("Expect a closing brace '}'",
|
|
1084
|
+
this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
|
|
1082
1085
|
} catch (r) {
|
|
1083
1086
|
if (!(r instanceof d))
|
|
1084
1087
|
throw r;
|
|
1085
|
-
if (
|
|
1088
|
+
if (s.blockCloseBrace = r.partialNode, !this.canHandle(r))
|
|
1086
1089
|
throw new d(r.token, i(), r.handlerContext);
|
|
1087
1090
|
this.synchronizeBlock();
|
|
1088
1091
|
}
|
|
1089
1092
|
return i();
|
|
1090
1093
|
}), this.synchronizeBlock = () => {
|
|
1091
|
-
if (!this.check(
|
|
1094
|
+
if (!this.check(u.RBRACE))
|
|
1092
1095
|
for (E(this.advance()); !this.isAtEnd(); ) {
|
|
1093
|
-
const
|
|
1094
|
-
if (this.check(
|
|
1096
|
+
const s = this.peek();
|
|
1097
|
+
if (this.check(u.RBRACE) || ot(this.previous(), s))
|
|
1095
1098
|
break;
|
|
1096
|
-
E(
|
|
1099
|
+
E(s), this.advance();
|
|
1097
1100
|
}
|
|
1098
1101
|
}, this.tupleExpression = this.contextStack.withContextDo(ye.GroupExpression, () => {
|
|
1099
|
-
const
|
|
1100
|
-
groupOpenParen:
|
|
1101
|
-
groupCloseParen:
|
|
1102
|
-
expression:
|
|
1103
|
-
}), r = () => this.nodeFactory.create(J,
|
|
1102
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Xe, {
|
|
1103
|
+
groupOpenParen: s.tupleOpenParen,
|
|
1104
|
+
groupCloseParen: s.tupleCloseParen,
|
|
1105
|
+
expression: s.elementList[0]
|
|
1106
|
+
}), r = () => this.nodeFactory.create(J, s);
|
|
1104
1107
|
try {
|
|
1105
|
-
this.consume("Expect an opening parenthesis '('",
|
|
1108
|
+
this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
|
|
1106
1109
|
} catch (a) {
|
|
1107
1110
|
if (!(a instanceof d))
|
|
1108
1111
|
throw a;
|
|
1109
|
-
if (
|
|
1112
|
+
if (s.tupleOpenParen = a.partialNode, !this.canHandle(a))
|
|
1110
1113
|
throw new d(a.token, r(), a.handlerContext);
|
|
1111
1114
|
this.synchronizeTuple();
|
|
1112
1115
|
}
|
|
1113
|
-
if (!this.isAtEnd() && !this.check(
|
|
1116
|
+
if (!this.isAtEnd() && !this.check(u.RPAREN))
|
|
1114
1117
|
try {
|
|
1115
|
-
|
|
1118
|
+
s.elementList.push(this.normalExpression());
|
|
1116
1119
|
} catch (a) {
|
|
1117
1120
|
if (!(a instanceof d))
|
|
1118
1121
|
throw a;
|
|
1119
|
-
if (
|
|
1122
|
+
if (s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1120
1123
|
throw new d(a.token, i(), a.handlerContext);
|
|
1121
1124
|
this.synchronizeTuple();
|
|
1122
1125
|
}
|
|
1123
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1126
|
+
for (; !this.isAtEnd() && !this.check(u.RPAREN); )
|
|
1124
1127
|
try {
|
|
1125
|
-
this.consume("Expect a comma ','",
|
|
1128
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
|
|
1126
1129
|
} catch (a) {
|
|
1127
1130
|
if (!(a instanceof d))
|
|
1128
1131
|
throw a;
|
|
1129
|
-
if (a.partialNode instanceof
|
|
1132
|
+
if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1130
1133
|
throw new d(a.token, r(), a.handlerContext);
|
|
1131
1134
|
this.synchronizeTuple();
|
|
1132
1135
|
}
|
|
1133
1136
|
try {
|
|
1134
|
-
this.consume("Expect a closing parenthesis ')'",
|
|
1137
|
+
this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
|
|
1135
1138
|
} catch (a) {
|
|
1136
1139
|
if (!(a instanceof d))
|
|
1137
1140
|
throw a;
|
|
1138
|
-
if (
|
|
1141
|
+
if (s.tupleCloseParen = a.partialNode, !this.canHandle(a))
|
|
1139
1142
|
throw new d(a.token, r(), a.handlerContext);
|
|
1140
1143
|
this.synchronizeTuple();
|
|
1141
1144
|
}
|
|
1142
|
-
return
|
|
1145
|
+
return s.elementList.length === 1 ? i() : r();
|
|
1143
1146
|
}), this.synchronizeTuple = () => {
|
|
1144
1147
|
for (; !this.isAtEnd(); ) {
|
|
1145
|
-
const
|
|
1146
|
-
if (this.check(
|
|
1148
|
+
const s = this.peek();
|
|
1149
|
+
if (this.check(u.RPAREN, u.COMMA))
|
|
1147
1150
|
break;
|
|
1148
|
-
E(
|
|
1151
|
+
E(s), this.advance();
|
|
1149
1152
|
}
|
|
1150
1153
|
}, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
|
|
1151
|
-
const
|
|
1154
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, s);
|
|
1152
1155
|
try {
|
|
1153
|
-
this.consume("Expect an opening bracket '['",
|
|
1156
|
+
this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
|
|
1154
1157
|
} catch (r) {
|
|
1155
1158
|
if (!(r instanceof d))
|
|
1156
1159
|
throw r;
|
|
1157
|
-
if (
|
|
1160
|
+
if (s.listOpenBracket = r.partialNode, !this.canHandle(r))
|
|
1158
1161
|
throw new d(r.token, i(), r.handlerContext);
|
|
1159
1162
|
this.synchronizeList();
|
|
1160
1163
|
}
|
|
1161
|
-
if (!this.isAtEnd() && !this.check(
|
|
1164
|
+
if (!this.isAtEnd() && !this.check(u.RBRACKET))
|
|
1162
1165
|
try {
|
|
1163
|
-
|
|
1166
|
+
s.elementList.push(this.attribute());
|
|
1164
1167
|
} catch (r) {
|
|
1165
1168
|
if (!(r instanceof d))
|
|
1166
1169
|
throw r;
|
|
1167
|
-
if (
|
|
1170
|
+
if (s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1168
1171
|
throw new d(r.token, i(), r.handlerContext);
|
|
1169
1172
|
this.synchronizeList();
|
|
1170
1173
|
}
|
|
1171
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1174
|
+
for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
|
|
1172
1175
|
try {
|
|
1173
|
-
this.consume("Expect a comma ','",
|
|
1176
|
+
this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
|
|
1174
1177
|
} catch (r) {
|
|
1175
1178
|
if (!(r instanceof d))
|
|
1176
1179
|
throw r;
|
|
1177
|
-
if (r.partialNode instanceof
|
|
1180
|
+
if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1178
1181
|
throw new d(r.token, i(), r.handlerContext);
|
|
1179
1182
|
this.synchronizeList();
|
|
1180
1183
|
}
|
|
1181
1184
|
try {
|
|
1182
|
-
this.consume("Expect a closing bracket ']'",
|
|
1185
|
+
this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
|
|
1183
1186
|
} catch (r) {
|
|
1184
1187
|
if (!(r instanceof d))
|
|
1185
1188
|
throw r;
|
|
1186
|
-
if (
|
|
1189
|
+
if (s.listCloseBracket = r.partialNode, !this.canHandle(r))
|
|
1187
1190
|
throw new d(r.token, i(), r.handlerContext);
|
|
1188
1191
|
this.synchronizeList();
|
|
1189
1192
|
}
|
|
1190
1193
|
return i();
|
|
1191
1194
|
}), this.synchronizeList = () => {
|
|
1192
1195
|
for (; !this.isAtEnd(); ) {
|
|
1193
|
-
const
|
|
1194
|
-
if (this.check(
|
|
1196
|
+
const s = this.peek();
|
|
1197
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1195
1198
|
break;
|
|
1196
|
-
E(
|
|
1199
|
+
E(s), this.advance();
|
|
1197
1200
|
}
|
|
1198
1201
|
}, this.synchronizeAttributeName = () => {
|
|
1199
1202
|
for (; !this.isAtEnd(); ) {
|
|
1200
|
-
const
|
|
1201
|
-
if (this.check(
|
|
1203
|
+
const s = this.peek();
|
|
1204
|
+
if (this.check(u.COMMA, u.RBRACKET, u.COLON))
|
|
1202
1205
|
break;
|
|
1203
|
-
E(
|
|
1206
|
+
E(s), this.advance();
|
|
1204
1207
|
}
|
|
1205
1208
|
}, this.synchronizeAttributeValue = () => {
|
|
1206
1209
|
for (; !this.isAtEnd(); ) {
|
|
1207
|
-
const
|
|
1208
|
-
if (this.check(
|
|
1210
|
+
const s = this.peek();
|
|
1211
|
+
if (this.check(u.COMMA, u.RBRACKET))
|
|
1209
1212
|
break;
|
|
1210
|
-
E(
|
|
1213
|
+
E(s), this.advance();
|
|
1211
1214
|
}
|
|
1212
|
-
}, this.tokens = e, this.nodeFactory = new
|
|
1215
|
+
}, this.tokens = e, this.nodeFactory = new ln(n);
|
|
1213
1216
|
}
|
|
1214
1217
|
isAtEnd() {
|
|
1215
|
-
return this.current >= this.tokens.length || this.tokens[this.current].kind ===
|
|
1218
|
+
return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
|
|
1216
1219
|
}
|
|
1217
1220
|
advance() {
|
|
1218
1221
|
return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
|
|
@@ -1221,12 +1224,12 @@ class ln {
|
|
|
1221
1224
|
return e + this.current >= this.tokens.length ? I.last(this.tokens) : this.tokens[this.current + e];
|
|
1222
1225
|
}
|
|
1223
1226
|
match(...e) {
|
|
1224
|
-
const
|
|
1225
|
-
return
|
|
1227
|
+
const n = this.check(...e);
|
|
1228
|
+
return n && this.advance(), n;
|
|
1226
1229
|
}
|
|
1227
1230
|
check(...e) {
|
|
1228
|
-
const
|
|
1229
|
-
return e.includes(
|
|
1231
|
+
const n = this.peek();
|
|
1232
|
+
return e.includes(n.kind);
|
|
1230
1233
|
}
|
|
1231
1234
|
previous() {
|
|
1232
1235
|
return this.tokens[this.current - 1];
|
|
@@ -1234,8 +1237,8 @@ class ln {
|
|
|
1234
1237
|
canHandle(e) {
|
|
1235
1238
|
return e.handlerContext === void 0 || e.handlerContext === this.contextStack.top();
|
|
1236
1239
|
}
|
|
1237
|
-
consume(e, ...
|
|
1238
|
-
if (!this.match(...
|
|
1240
|
+
consume(e, ...n) {
|
|
1241
|
+
if (!this.match(...n))
|
|
1239
1242
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, e), new d(
|
|
1240
1243
|
this.peek(),
|
|
1241
1244
|
void 0,
|
|
@@ -1245,94 +1248,94 @@ class ln {
|
|
|
1245
1248
|
// Discard tokens until one of `kind` is found
|
|
1246
1249
|
// If any tokens are discarded, the error message is logged
|
|
1247
1250
|
// Return whether the token of one of the listed kinds are eventually reached
|
|
1248
|
-
discardUntil(e, ...
|
|
1249
|
-
if (this.isAtEnd() || !this.check(...
|
|
1250
|
-
for (E(this.peek()), this.logError(this.advance(), o.UNEXPECTED_TOKEN, e); !this.isAtEnd() && !this.check(...
|
|
1251
|
+
discardUntil(e, ...n) {
|
|
1252
|
+
if (this.isAtEnd() || !this.check(...n)) {
|
|
1253
|
+
for (E(this.peek()), this.logError(this.advance(), o.UNEXPECTED_TOKEN, e); !this.isAtEnd() && !this.check(...n); )
|
|
1251
1254
|
E(this.advance());
|
|
1252
1255
|
return !this.isAtEnd();
|
|
1253
1256
|
}
|
|
1254
1257
|
return !0;
|
|
1255
1258
|
}
|
|
1256
1259
|
gatherInvalid() {
|
|
1257
|
-
const e = [],
|
|
1258
|
-
let
|
|
1260
|
+
const e = [], n = [];
|
|
1261
|
+
let s, i = 0;
|
|
1259
1262
|
for (; i < this.tokens.length && this.tokens[i].isInvalid; i += 1)
|
|
1260
|
-
|
|
1261
|
-
for (
|
|
1263
|
+
n.push(this.tokens[i]);
|
|
1264
|
+
for (s = this.tokens[i], s.leadingInvalid = n, e.push(s), i += 1; i < this.tokens.length; i += 1) {
|
|
1262
1265
|
const r = this.tokens[i];
|
|
1263
|
-
r.isInvalid ?
|
|
1266
|
+
r.isInvalid ? s.trailingInvalid.push(r) : (s = r, e.push(s));
|
|
1264
1267
|
}
|
|
1265
1268
|
this.tokens = e;
|
|
1266
1269
|
}
|
|
1267
1270
|
parse() {
|
|
1268
|
-
const e = this.program(),
|
|
1269
|
-
return this.gatherInvalid(), new
|
|
1271
|
+
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(F, { body: e, eof: n });
|
|
1272
|
+
return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
|
|
1270
1273
|
}
|
|
1271
1274
|
/* Parsing and synchronizing ProgramNode */
|
|
1272
1275
|
program() {
|
|
1273
1276
|
const e = [];
|
|
1274
1277
|
for (; !this.isAtEnd(); )
|
|
1275
1278
|
try {
|
|
1276
|
-
const
|
|
1277
|
-
e.push(
|
|
1278
|
-
} catch (
|
|
1279
|
-
if (!(
|
|
1280
|
-
throw
|
|
1281
|
-
e.push(
|
|
1279
|
+
const n = this.elementDeclaration();
|
|
1280
|
+
e.push(n);
|
|
1281
|
+
} catch (n) {
|
|
1282
|
+
if (!(n instanceof d))
|
|
1283
|
+
throw n;
|
|
1284
|
+
e.push(n.partialNode), this.synchronizeProgram();
|
|
1282
1285
|
}
|
|
1283
1286
|
return e;
|
|
1284
1287
|
}
|
|
1285
1288
|
/* Parsing and synchronizing top-level ElementDeclarationNode */
|
|
1286
1289
|
elementDeclaration() {
|
|
1287
|
-
const e = {},
|
|
1290
|
+
const e = {}, n = () => this.nodeFactory.create(_, e);
|
|
1288
1291
|
try {
|
|
1289
|
-
this.consume("Expect an identifier",
|
|
1290
|
-
} catch (
|
|
1291
|
-
throw
|
|
1292
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1293
|
+
} catch (s) {
|
|
1294
|
+
throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1292
1295
|
}
|
|
1293
|
-
if (!this.check(
|
|
1296
|
+
if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1294
1297
|
try {
|
|
1295
1298
|
e.name = this.normalExpression();
|
|
1296
|
-
} catch (
|
|
1297
|
-
if (!(
|
|
1298
|
-
throw
|
|
1299
|
-
if (e.name =
|
|
1300
|
-
throw new d(
|
|
1299
|
+
} catch (s) {
|
|
1300
|
+
if (!(s instanceof d))
|
|
1301
|
+
throw s;
|
|
1302
|
+
if (e.name = s.partialNode, !this.canHandle(s))
|
|
1303
|
+
throw new d(s.token, n(), s.handlerContext);
|
|
1301
1304
|
this.synchronizeElementDeclarationName();
|
|
1302
1305
|
}
|
|
1303
|
-
if (
|
|
1304
|
-
if (e.as = this.advance(), this.check(
|
|
1306
|
+
if (lt(this.peek()))
|
|
1307
|
+
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1305
1308
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1306
1309
|
else
|
|
1307
1310
|
try {
|
|
1308
1311
|
e.alias = this.normalExpression();
|
|
1309
|
-
} catch (
|
|
1310
|
-
if (!(
|
|
1311
|
-
throw
|
|
1312
|
-
if (e.alias =
|
|
1313
|
-
throw new d(
|
|
1312
|
+
} catch (s) {
|
|
1313
|
+
if (!(s instanceof d))
|
|
1314
|
+
throw s;
|
|
1315
|
+
if (e.alias = s.partialNode, !this.canHandle(s))
|
|
1316
|
+
throw new d(s.token, n(), s.handlerContext);
|
|
1314
1317
|
this.synchronizeElementDeclarationAlias();
|
|
1315
1318
|
}
|
|
1316
1319
|
try {
|
|
1317
|
-
e.attributeList = this.check(
|
|
1318
|
-
} catch (
|
|
1319
|
-
throw
|
|
1320
|
+
e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
|
|
1321
|
+
} catch (s) {
|
|
1322
|
+
throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1320
1323
|
}
|
|
1321
1324
|
if (!this.discardUntil(
|
|
1322
1325
|
"Expect an opening brace '{' or a colon ':'",
|
|
1323
|
-
|
|
1324
|
-
|
|
1326
|
+
u.LBRACE,
|
|
1327
|
+
u.COLON
|
|
1325
1328
|
))
|
|
1326
|
-
return
|
|
1329
|
+
return n();
|
|
1327
1330
|
try {
|
|
1328
|
-
if (this.match(
|
|
1331
|
+
if (this.match(u.COLON)) {
|
|
1329
1332
|
e.bodyColon = this.previous();
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1333
|
+
const s = this.expression();
|
|
1334
|
+
s instanceof _ ? (E(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
|
|
1332
1335
|
} else
|
|
1333
1336
|
e.body = this.blockExpression();
|
|
1334
|
-
} catch (
|
|
1335
|
-
throw
|
|
1337
|
+
} catch (s) {
|
|
1338
|
+
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1336
1339
|
}
|
|
1337
1340
|
return this.nodeFactory.create(_, e);
|
|
1338
1341
|
}
|
|
@@ -1343,155 +1346,155 @@ class ln {
|
|
|
1343
1346
|
// Note: 'This is a note' // fieldDeclaration() handles this
|
|
1344
1347
|
// }
|
|
1345
1348
|
fieldDeclaration() {
|
|
1346
|
-
const e = {},
|
|
1349
|
+
const e = {}, n = () => this.nodeFactory.create(_, e);
|
|
1347
1350
|
try {
|
|
1348
|
-
this.consume("Expect an identifier",
|
|
1349
|
-
} catch (
|
|
1350
|
-
throw
|
|
1351
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
|
|
1352
|
+
} catch (s) {
|
|
1353
|
+
throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1351
1354
|
}
|
|
1352
1355
|
try {
|
|
1353
|
-
this.consume("Expect a colon ':'",
|
|
1354
|
-
} catch (
|
|
1355
|
-
throw
|
|
1356
|
+
this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
|
|
1357
|
+
} catch (s) {
|
|
1358
|
+
throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1356
1359
|
}
|
|
1357
1360
|
try {
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1360
|
-
} catch (
|
|
1361
|
-
throw
|
|
1361
|
+
const s = this.expression();
|
|
1362
|
+
s instanceof _ ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1363
|
+
} catch (s) {
|
|
1364
|
+
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1362
1365
|
}
|
|
1363
1366
|
return this.nodeFactory.create(_, e);
|
|
1364
1367
|
}
|
|
1365
1368
|
/* Parsing any ExpressionNode, including non-NormalExpression */
|
|
1366
1369
|
expression() {
|
|
1367
|
-
const e = { args: [] },
|
|
1368
|
-
this.nodeFactory.create(
|
|
1370
|
+
const e = { args: [] }, n = () => nn(e.callee, e.args, this.nodeFactory).unwrap_or(
|
|
1371
|
+
this.nodeFactory.create(v, e)
|
|
1369
1372
|
);
|
|
1370
1373
|
try {
|
|
1371
1374
|
e.callee = this.normalExpression();
|
|
1372
1375
|
} catch (i) {
|
|
1373
|
-
throw i instanceof d ? (e.callee = i.partialNode, new d(i.token,
|
|
1376
|
+
throw i instanceof d ? (e.callee = i.partialNode, new d(i.token, n(), i.handlerContext)) : i;
|
|
1374
1377
|
}
|
|
1375
1378
|
if (this.shouldStopExpression())
|
|
1376
|
-
return
|
|
1377
|
-
let
|
|
1379
|
+
return n();
|
|
1380
|
+
let s = e.callee;
|
|
1378
1381
|
for (; !this.shouldStopExpression(); ) {
|
|
1379
|
-
Ve(this.previous()) || this.logError(
|
|
1382
|
+
Ve(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
|
|
1380
1383
|
try {
|
|
1381
|
-
|
|
1384
|
+
s = this.normalExpression(), e.args.push(s);
|
|
1382
1385
|
} catch (i) {
|
|
1383
|
-
throw i instanceof d ? (
|
|
1386
|
+
throw i instanceof d ? (s = i.partialNode, e.args.push(s), new d(i.token, n(), i.handlerContext)) : i;
|
|
1384
1387
|
}
|
|
1385
1388
|
}
|
|
1386
|
-
return
|
|
1389
|
+
return n();
|
|
1387
1390
|
}
|
|
1388
1391
|
shouldStopExpression() {
|
|
1389
1392
|
if (this.isAtEnd() || bt(this.previous()))
|
|
1390
1393
|
return !0;
|
|
1391
1394
|
const e = this.peek().kind;
|
|
1392
|
-
return e ===
|
|
1395
|
+
return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
|
|
1393
1396
|
}
|
|
1394
1397
|
normalExpression() {
|
|
1395
1398
|
return this.expression_bp(0);
|
|
1396
1399
|
}
|
|
1397
1400
|
// Pratt's parsing algorithm
|
|
1398
1401
|
expression_bp(e) {
|
|
1399
|
-
let
|
|
1402
|
+
let n = this.leftExpression_bp();
|
|
1400
1403
|
for (; !this.isAtEnd(); ) {
|
|
1401
|
-
const
|
|
1402
|
-
if (
|
|
1403
|
-
const { left: i } = ut(
|
|
1404
|
+
const s = this.peek();
|
|
1405
|
+
if (s.kind === u.LPAREN) {
|
|
1406
|
+
const { left: i } = ut(s);
|
|
1404
1407
|
if (i < e || // When '(' is encountered,
|
|
1405
1408
|
// consider it part of another expression if
|
|
1406
1409
|
// it's at the start of a new line
|
|
1407
1410
|
// and we're currently not having unmatched '(' or '['
|
|
1408
|
-
ot(this.previous(),
|
|
1411
|
+
ot(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
|
|
1409
1412
|
break;
|
|
1410
1413
|
try {
|
|
1411
|
-
|
|
1412
|
-
callee:
|
|
1414
|
+
n = this.nodeFactory.create(H, {
|
|
1415
|
+
callee: n,
|
|
1413
1416
|
argumentList: this.tupleExpression()
|
|
1414
1417
|
});
|
|
1415
1418
|
} catch (r) {
|
|
1416
|
-
throw r instanceof d ? (
|
|
1417
|
-
callee:
|
|
1419
|
+
throw r instanceof d ? (n = this.nodeFactory.create(H, {
|
|
1420
|
+
callee: n,
|
|
1418
1421
|
argumentList: r.partialNode
|
|
1419
|
-
}), new d(r.token,
|
|
1422
|
+
}), new d(r.token, n, r.handlerContext)) : r;
|
|
1420
1423
|
}
|
|
1421
|
-
} else if (
|
|
1424
|
+
} else if (s.kind === u.LBRACKET) {
|
|
1422
1425
|
if (Ve(this.previous()))
|
|
1423
1426
|
break;
|
|
1424
1427
|
try {
|
|
1425
|
-
|
|
1426
|
-
expression:
|
|
1428
|
+
n = this.nodeFactory.create(he, {
|
|
1429
|
+
expression: n,
|
|
1427
1430
|
indexer: this.listExpression()
|
|
1428
1431
|
});
|
|
1429
1432
|
} catch (i) {
|
|
1430
|
-
throw i instanceof d ? (
|
|
1431
|
-
expression:
|
|
1433
|
+
throw i instanceof d ? (n = this.nodeFactory.create(he, {
|
|
1434
|
+
expression: n,
|
|
1432
1435
|
indexer: i.partialNode
|
|
1433
|
-
}), new d(i.token,
|
|
1436
|
+
}), new d(i.token, n, i.handlerContext)) : i;
|
|
1434
1437
|
}
|
|
1435
|
-
} else if (at(
|
|
1436
|
-
const i =
|
|
1438
|
+
} else if (at(s)) {
|
|
1439
|
+
const i = s, r = ut(i);
|
|
1437
1440
|
if (r.left !== null) {
|
|
1438
1441
|
if (r.left <= e)
|
|
1439
1442
|
break;
|
|
1440
|
-
this.advance(),
|
|
1441
|
-
expression:
|
|
1443
|
+
this.advance(), n = this.nodeFactory.create(De, {
|
|
1444
|
+
expression: n,
|
|
1442
1445
|
op: i
|
|
1443
1446
|
});
|
|
1444
1447
|
} else {
|
|
1445
|
-
const a =
|
|
1448
|
+
const a = fn(i);
|
|
1446
1449
|
if (a.left === null || a.left <= e)
|
|
1447
1450
|
break;
|
|
1448
1451
|
this.advance();
|
|
1449
1452
|
try {
|
|
1450
|
-
|
|
1451
|
-
leftExpression:
|
|
1453
|
+
n = this.nodeFactory.create(q, {
|
|
1454
|
+
leftExpression: n,
|
|
1452
1455
|
op: i,
|
|
1453
1456
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1454
1457
|
});
|
|
1455
|
-
} catch (
|
|
1456
|
-
throw
|
|
1457
|
-
leftExpression:
|
|
1458
|
+
} catch (c) {
|
|
1459
|
+
throw c instanceof d ? (n = this.nodeFactory.create(q, {
|
|
1460
|
+
leftExpression: n,
|
|
1458
1461
|
op: i,
|
|
1459
|
-
rightExpression:
|
|
1460
|
-
}), new d(
|
|
1462
|
+
rightExpression: c.partialNode
|
|
1463
|
+
}), new d(c.token, n, c.handlerContext)) : c;
|
|
1461
1464
|
}
|
|
1462
1465
|
}
|
|
1463
1466
|
} else
|
|
1464
1467
|
break;
|
|
1465
1468
|
}
|
|
1466
|
-
return
|
|
1469
|
+
return n;
|
|
1467
1470
|
}
|
|
1468
1471
|
leftExpression_bp() {
|
|
1469
1472
|
let e;
|
|
1470
1473
|
if (at(this.peek())) {
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1474
|
-
if (
|
|
1474
|
+
const n = {};
|
|
1475
|
+
n.op = this.peek();
|
|
1476
|
+
const s = dn(n.op);
|
|
1477
|
+
if (s.right === null)
|
|
1475
1478
|
throw this.logError(
|
|
1476
|
-
|
|
1479
|
+
n.op,
|
|
1477
1480
|
o.UNKNOWN_PREFIX_OP,
|
|
1478
|
-
`Unexpected '${
|
|
1481
|
+
`Unexpected '${n.op.value}' in an expression`
|
|
1479
1482
|
), new d(
|
|
1480
|
-
|
|
1481
|
-
this.nodeFactory.create(we, { pre:
|
|
1483
|
+
n.op,
|
|
1484
|
+
this.nodeFactory.create(we, { pre: n.op }),
|
|
1482
1485
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1483
1486
|
);
|
|
1484
1487
|
this.advance();
|
|
1485
1488
|
try {
|
|
1486
|
-
|
|
1489
|
+
n.expression = this.expression_bp(s.right);
|
|
1487
1490
|
} catch (i) {
|
|
1488
|
-
throw i instanceof d ? (
|
|
1491
|
+
throw i instanceof d ? (n.expression = i.partialNode, new d(
|
|
1489
1492
|
i.token,
|
|
1490
|
-
this.nodeFactory.create(Q,
|
|
1493
|
+
this.nodeFactory.create(Q, n),
|
|
1491
1494
|
i.handlerContext
|
|
1492
1495
|
)) : i;
|
|
1493
1496
|
}
|
|
1494
|
-
e = this.nodeFactory.create(Q,
|
|
1497
|
+
e = this.nodeFactory.create(Q, n);
|
|
1495
1498
|
} else if (e = this.extractOperand(), e instanceof we)
|
|
1496
1499
|
throw new d(
|
|
1497
1500
|
this.peek(),
|
|
@@ -1506,12 +1509,12 @@ class ln {
|
|
|
1506
1509
|
// e.g { ... }
|
|
1507
1510
|
extractOperand() {
|
|
1508
1511
|
return this.check(
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
) ? this.primaryExpression() : this.check(
|
|
1512
|
+
u.NUMERIC_LITERAL,
|
|
1513
|
+
u.STRING_LITERAL,
|
|
1514
|
+
u.COLOR_LITERAL,
|
|
1515
|
+
u.QUOTED_STRING,
|
|
1516
|
+
u.IDENTIFIER
|
|
1517
|
+
) ? 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(
|
|
1515
1518
|
this.peek(),
|
|
1516
1519
|
o.UNEXPECTED_EOF,
|
|
1517
1520
|
"Unexpected EOF"
|
|
@@ -1525,98 +1528,98 @@ class ln {
|
|
|
1525
1528
|
functionExpression() {
|
|
1526
1529
|
const e = {};
|
|
1527
1530
|
try {
|
|
1528
|
-
this.consume("Expect a function expression",
|
|
1529
|
-
} catch (
|
|
1530
|
-
throw
|
|
1531
|
-
|
|
1531
|
+
this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
|
|
1532
|
+
} catch (n) {
|
|
1533
|
+
throw n instanceof d ? (e.value = n.partialNode, new d(
|
|
1534
|
+
n.token,
|
|
1532
1535
|
this.nodeFactory.create(K, e),
|
|
1533
|
-
|
|
1534
|
-
)) :
|
|
1536
|
+
n.handlerContext
|
|
1537
|
+
)) : n;
|
|
1535
1538
|
}
|
|
1536
1539
|
return this.nodeFactory.create(K, e);
|
|
1537
1540
|
}
|
|
1538
1541
|
canBeField() {
|
|
1539
|
-
return this.peek().kind ===
|
|
1542
|
+
return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
|
|
1540
1543
|
}
|
|
1541
1544
|
/* Parsing PrimaryExpression */
|
|
1542
1545
|
primaryExpression() {
|
|
1543
1546
|
if (this.match(
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
+
u.COLOR_LITERAL,
|
|
1548
|
+
u.STRING_LITERAL,
|
|
1549
|
+
u.NUMERIC_LITERAL
|
|
1547
1550
|
))
|
|
1548
1551
|
return this.nodeFactory.create(R, {
|
|
1549
1552
|
expression: this.nodeFactory.create(pe, { literal: this.previous() })
|
|
1550
1553
|
});
|
|
1551
|
-
if (this.match(
|
|
1554
|
+
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1552
1555
|
return this.nodeFactory.create(R, {
|
|
1553
|
-
expression: this.nodeFactory.create(
|
|
1556
|
+
expression: this.nodeFactory.create(W, { variable: this.previous() })
|
|
1554
1557
|
});
|
|
1555
1558
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1556
1559
|
this.peek(),
|
|
1557
1560
|
this.nodeFactory.create(R, {
|
|
1558
|
-
expression: this.nodeFactory.create(
|
|
1561
|
+
expression: this.nodeFactory.create(W, {})
|
|
1559
1562
|
}),
|
|
1560
1563
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1561
1564
|
);
|
|
1562
1565
|
}
|
|
1563
1566
|
attribute() {
|
|
1564
1567
|
const e = {};
|
|
1565
|
-
if (this.check(
|
|
1566
|
-
const
|
|
1568
|
+
if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
|
|
1569
|
+
const n = this.peek();
|
|
1567
1570
|
this.logError(
|
|
1568
|
-
|
|
1571
|
+
n,
|
|
1569
1572
|
o.EMPTY_ATTRIBUTE_NAME,
|
|
1570
1573
|
"Expect a non-empty attribute name"
|
|
1571
1574
|
), e.name = this.nodeFactory.create(te, { identifiers: [] });
|
|
1572
1575
|
} else
|
|
1573
1576
|
try {
|
|
1574
1577
|
e.name = this.attributeName();
|
|
1575
|
-
} catch (
|
|
1576
|
-
if (!(
|
|
1577
|
-
throw
|
|
1578
|
-
if (e.name =
|
|
1578
|
+
} catch (n) {
|
|
1579
|
+
if (!(n instanceof d))
|
|
1580
|
+
throw n;
|
|
1581
|
+
if (e.name = n.partialNode, !this.canHandle(n))
|
|
1579
1582
|
throw new d(
|
|
1580
|
-
|
|
1583
|
+
n.token,
|
|
1581
1584
|
this.nodeFactory.create(ne, e),
|
|
1582
|
-
|
|
1585
|
+
n.handlerContext
|
|
1583
1586
|
);
|
|
1584
1587
|
this.synchronizeAttributeName();
|
|
1585
1588
|
}
|
|
1586
|
-
return this.match(
|
|
1589
|
+
return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ne, e);
|
|
1587
1590
|
}
|
|
1588
1591
|
attributeValue() {
|
|
1589
1592
|
let e;
|
|
1590
1593
|
try {
|
|
1591
|
-
e = this.peek().kind ===
|
|
1592
|
-
} catch (
|
|
1593
|
-
if (!(
|
|
1594
|
-
throw
|
|
1595
|
-
e =
|
|
1594
|
+
e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
|
|
1595
|
+
} catch (n) {
|
|
1596
|
+
if (!(n instanceof d) || !this.canHandle(n))
|
|
1597
|
+
throw n;
|
|
1598
|
+
e = n.partialNode, this.synchronizeAttributeValue();
|
|
1596
1599
|
}
|
|
1597
1600
|
return e;
|
|
1598
1601
|
}
|
|
1599
1602
|
attributeName() {
|
|
1600
1603
|
const e = [];
|
|
1601
|
-
if (this.peek().kind !==
|
|
1604
|
+
if (this.peek().kind !== u.IDENTIFIER)
|
|
1602
1605
|
return this.primaryExpression();
|
|
1603
|
-
for (; !this.isAtEnd() && !this.check(
|
|
1606
|
+
for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
|
|
1604
1607
|
try {
|
|
1605
|
-
this.consume("Expect an identifier",
|
|
1606
|
-
} catch (
|
|
1607
|
-
throw
|
|
1608
|
-
|
|
1608
|
+
this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
|
|
1609
|
+
} catch (n) {
|
|
1610
|
+
throw n instanceof d ? new d(
|
|
1611
|
+
n.token,
|
|
1609
1612
|
this.nodeFactory.create(te, { identifiers: e }),
|
|
1610
|
-
|
|
1611
|
-
) :
|
|
1613
|
+
n.handlerContext
|
|
1614
|
+
) : n;
|
|
1612
1615
|
}
|
|
1613
1616
|
return this.nodeFactory.create(te, { identifiers: e });
|
|
1614
1617
|
}
|
|
1615
|
-
logError(e,
|
|
1616
|
-
this.errors.push(new
|
|
1618
|
+
logError(e, n, s) {
|
|
1619
|
+
this.errors.push(new l(n, s, e));
|
|
1617
1620
|
}
|
|
1618
1621
|
}
|
|
1619
|
-
const
|
|
1622
|
+
const hn = {
|
|
1620
1623
|
"+": { left: 9, right: 10 },
|
|
1621
1624
|
"*": { left: 11, right: 12 },
|
|
1622
1625
|
"-": { left: 9, right: 10 },
|
|
@@ -1632,10 +1635,10 @@ const cn = {
|
|
|
1632
1635
|
"!=": { left: 4, right: 5 },
|
|
1633
1636
|
".": { left: 16, right: 17 }
|
|
1634
1637
|
};
|
|
1635
|
-
function
|
|
1636
|
-
return
|
|
1638
|
+
function fn(t) {
|
|
1639
|
+
return hn[t.value] || { left: null, right: null };
|
|
1637
1640
|
}
|
|
1638
|
-
const
|
|
1641
|
+
const pn = {
|
|
1639
1642
|
"+": { left: null, right: 15 },
|
|
1640
1643
|
"-": { left: null, right: 15 },
|
|
1641
1644
|
"<": { left: null, right: 15 },
|
|
@@ -1643,19 +1646,19 @@ const hn = {
|
|
|
1643
1646
|
"<>": { left: null, right: 15 },
|
|
1644
1647
|
"!": { left: null, right: 15 }
|
|
1645
1648
|
};
|
|
1646
|
-
function
|
|
1647
|
-
return
|
|
1649
|
+
function dn(t) {
|
|
1650
|
+
return pn[t.value] || { left: null, right: null };
|
|
1648
1651
|
}
|
|
1649
|
-
const
|
|
1652
|
+
const En = {
|
|
1650
1653
|
"(": { left: 14, right: null }
|
|
1651
1654
|
};
|
|
1652
1655
|
function ut(t) {
|
|
1653
|
-
return
|
|
1656
|
+
return En[t.value] || { left: null, right: null };
|
|
1654
1657
|
}
|
|
1655
1658
|
var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
|
|
1656
1659
|
function de(t) {
|
|
1657
|
-
var
|
|
1658
|
-
const e = (
|
|
1660
|
+
var n;
|
|
1661
|
+
const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
|
|
1659
1662
|
switch (e) {
|
|
1660
1663
|
case b.Enum:
|
|
1661
1664
|
case b.Table:
|
|
@@ -1675,50 +1678,50 @@ function Ee(t) {
|
|
|
1675
1678
|
const e = Ee(t.leftExpression).unwrap_or(void 0);
|
|
1676
1679
|
return e ? (e.push(t.rightExpression), new S(e)) : new A();
|
|
1677
1680
|
}
|
|
1678
|
-
function
|
|
1681
|
+
function C(t) {
|
|
1679
1682
|
if (t === void 0)
|
|
1680
1683
|
return new A();
|
|
1681
1684
|
const e = Ee(t).unwrap_or(void 0);
|
|
1682
1685
|
if (!e)
|
|
1683
1686
|
return new A();
|
|
1684
|
-
const
|
|
1685
|
-
for (const
|
|
1686
|
-
const i =
|
|
1687
|
+
const n = [];
|
|
1688
|
+
for (const s of e) {
|
|
1689
|
+
const i = X(s).unwrap_or(void 0);
|
|
1687
1690
|
if (!i)
|
|
1688
1691
|
return new A();
|
|
1689
|
-
|
|
1692
|
+
n.push(i);
|
|
1690
1693
|
}
|
|
1691
|
-
return new S(
|
|
1694
|
+
return new S(n);
|
|
1692
1695
|
}
|
|
1693
|
-
function
|
|
1696
|
+
function ge(t) {
|
|
1694
1697
|
if (t === void 0)
|
|
1695
1698
|
return new A();
|
|
1696
1699
|
const e = Ee(t).unwrap_or(void 0);
|
|
1697
1700
|
if (!e || e.length === 0)
|
|
1698
1701
|
return new A();
|
|
1699
|
-
const
|
|
1700
|
-
let
|
|
1702
|
+
const n = [];
|
|
1703
|
+
let s;
|
|
1701
1704
|
if (!M(I.last(e))) {
|
|
1702
1705
|
const i = e.pop();
|
|
1703
1706
|
if (xt(i))
|
|
1704
|
-
|
|
1705
|
-
(r) =>
|
|
1707
|
+
s = i.elementList.map(
|
|
1708
|
+
(r) => G(r).unwrap()
|
|
1706
1709
|
);
|
|
1707
1710
|
else
|
|
1708
1711
|
return new A();
|
|
1709
1712
|
}
|
|
1710
1713
|
for (const i of e) {
|
|
1711
|
-
const r =
|
|
1714
|
+
const r = X(i).unwrap_or(void 0);
|
|
1712
1715
|
if (!r)
|
|
1713
1716
|
return new A();
|
|
1714
|
-
|
|
1717
|
+
n.push(r);
|
|
1715
1718
|
}
|
|
1716
1719
|
return new S({
|
|
1717
|
-
variables:
|
|
1718
|
-
tupleElements:
|
|
1720
|
+
variables: n,
|
|
1721
|
+
tupleElements: s
|
|
1719
1722
|
});
|
|
1720
1723
|
}
|
|
1721
|
-
function
|
|
1724
|
+
function X(t) {
|
|
1722
1725
|
return M(t) ? new S(t.expression.variable.value) : new A();
|
|
1723
1726
|
}
|
|
1724
1727
|
function Ge(t) {
|
|
@@ -1726,395 +1729,403 @@ function Ge(t) {
|
|
|
1726
1729
|
return t instanceof K ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
|
|
1727
1730
|
if (t instanceof J && t.elementList.every(ht)) {
|
|
1728
1731
|
const e = t.elementList.filter(
|
|
1729
|
-
(
|
|
1730
|
-
),
|
|
1731
|
-
return new S({ functional: e, nonFunctional:
|
|
1732
|
+
(s) => s instanceof K
|
|
1733
|
+
), n = t.elementList.filter(M);
|
|
1734
|
+
return new S({ functional: e, nonFunctional: n });
|
|
1732
1735
|
}
|
|
1733
1736
|
return new A();
|
|
1734
1737
|
}
|
|
1735
|
-
function
|
|
1736
|
-
var
|
|
1737
|
-
const e = (
|
|
1738
|
+
function G(t) {
|
|
1739
|
+
var n;
|
|
1740
|
+
const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
|
|
1738
1741
|
return e === void 0 ? new A() : new S(e);
|
|
1739
1742
|
}
|
|
1740
|
-
function
|
|
1741
|
-
return
|
|
1743
|
+
function z(t) {
|
|
1744
|
+
return j(t) ? t.expression instanceof W ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
|
|
1742
1745
|
}
|
|
1743
|
-
function
|
|
1746
|
+
function Nn(t) {
|
|
1744
1747
|
var e;
|
|
1745
|
-
return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 :
|
|
1748
|
+
return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : ge(t.leftExpression).and_then(() => ge(t.rightExpression)).unwrap_or(void 0) !== void 0;
|
|
1746
1749
|
}
|
|
1747
|
-
function
|
|
1748
|
-
const e =
|
|
1749
|
-
if (!e.isOk() || !
|
|
1750
|
+
function mn(t) {
|
|
1751
|
+
const e = ge(t.leftExpression), n = ge(t.rightExpression);
|
|
1752
|
+
if (!e.isOk() || !n.isOk())
|
|
1750
1753
|
return !1;
|
|
1751
|
-
const { tupleElements:
|
|
1752
|
-
return (
|
|
1754
|
+
const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
|
|
1755
|
+
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1753
1756
|
}
|
|
1754
1757
|
function ht(t) {
|
|
1755
|
-
return t instanceof R && t.expression instanceof
|
|
1758
|
+
return t instanceof R && t.expression instanceof W || t instanceof K;
|
|
1756
1759
|
}
|
|
1757
|
-
function
|
|
1758
|
-
var i, r, a,
|
|
1759
|
-
let
|
|
1760
|
-
const
|
|
1761
|
-
for (;
|
|
1762
|
-
if ((r = (i =
|
|
1763
|
-
return (a =
|
|
1764
|
-
if (((
|
|
1765
|
-
return
|
|
1766
|
-
if (
|
|
1760
|
+
function Tn(t, e) {
|
|
1761
|
+
var i, r, a, c;
|
|
1762
|
+
let n = e;
|
|
1763
|
+
const s = zt(t);
|
|
1764
|
+
for (; n; ) {
|
|
1765
|
+
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1766
|
+
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1767
|
+
if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof F && s)
|
|
1768
|
+
return n.symbol;
|
|
1769
|
+
if (n instanceof F)
|
|
1767
1770
|
return;
|
|
1768
|
-
|
|
1771
|
+
n = n.parent;
|
|
1769
1772
|
}
|
|
1770
1773
|
}
|
|
1771
|
-
class
|
|
1772
|
-
constructor(e,
|
|
1773
|
-
this.declarationNode = e, this.publicSymbolTable =
|
|
1774
|
+
class bn {
|
|
1775
|
+
constructor(e, n, s) {
|
|
1776
|
+
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1774
1777
|
}
|
|
1775
1778
|
validate() {
|
|
1776
1779
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1777
1780
|
}
|
|
1778
1781
|
validateContext() {
|
|
1779
|
-
return this.declarationNode.parent instanceof
|
|
1782
|
+
return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
|
|
1780
1783
|
}
|
|
1781
1784
|
validateName(e) {
|
|
1782
|
-
return e ? [new
|
|
1785
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
1783
1786
|
}
|
|
1784
1787
|
validateAlias(e) {
|
|
1785
|
-
return e ? [new
|
|
1788
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
|
|
1786
1789
|
}
|
|
1787
1790
|
validateSettingList(e) {
|
|
1788
|
-
return e ? [new
|
|
1791
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
|
|
1789
1792
|
}
|
|
1790
1793
|
validateBody(e) {
|
|
1791
1794
|
if (!e)
|
|
1792
1795
|
return [];
|
|
1793
1796
|
if (e instanceof ee)
|
|
1794
|
-
return [new
|
|
1795
|
-
const
|
|
1796
|
-
return
|
|
1797
|
+
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1798
|
+
const n = [];
|
|
1799
|
+
return j(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;
|
|
1797
1800
|
}
|
|
1798
1801
|
}
|
|
1799
|
-
class
|
|
1802
|
+
class Ae {
|
|
1800
1803
|
constructor() {
|
|
1801
1804
|
this.table = /* @__PURE__ */ new Map();
|
|
1802
1805
|
}
|
|
1803
1806
|
has(e) {
|
|
1804
1807
|
return this.table.has(e);
|
|
1805
1808
|
}
|
|
1806
|
-
set(e,
|
|
1807
|
-
this.table.set(e,
|
|
1809
|
+
set(e, n) {
|
|
1810
|
+
this.table.set(e, n);
|
|
1808
1811
|
}
|
|
1809
|
-
get(e,
|
|
1810
|
-
return this.table.get(e) ||
|
|
1812
|
+
get(e, n) {
|
|
1813
|
+
return this.table.get(e) || n !== void 0 && this.set(e, n) || n;
|
|
1811
1814
|
}
|
|
1812
1815
|
entries() {
|
|
1813
1816
|
return this.table.entries();
|
|
1814
1817
|
}
|
|
1815
1818
|
}
|
|
1816
|
-
class
|
|
1817
|
-
constructor(e,
|
|
1818
|
-
this.declarationNode = e, this.publicSymbolTable =
|
|
1819
|
+
class In {
|
|
1820
|
+
constructor(e, n, s) {
|
|
1821
|
+
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1819
1822
|
}
|
|
1820
1823
|
validate() {
|
|
1821
1824
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
1822
1825
|
}
|
|
1823
1826
|
validateContext() {
|
|
1824
|
-
return this.declarationNode.parent instanceof _ ? [new
|
|
1827
|
+
return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1825
1828
|
}
|
|
1826
1829
|
validateName(e) {
|
|
1827
|
-
return e ? Je(e) ? [] : [new
|
|
1830
|
+
return e ? Je(e) ? [] : [new l(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new l(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
|
|
1828
1831
|
}
|
|
1829
1832
|
validateAlias(e) {
|
|
1830
|
-
return e ? [new
|
|
1833
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1831
1834
|
}
|
|
1832
1835
|
registerElement() {
|
|
1833
1836
|
const e = [];
|
|
1834
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
1835
|
-
const { name:
|
|
1836
|
-
if (
|
|
1837
|
-
const i =
|
|
1838
|
-
a.has(
|
|
1837
|
+
this.declarationNode.symbol = this.symbolFactory.create(Jt, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
1838
|
+
const { name: n } = this.declarationNode, s = C(n);
|
|
1839
|
+
if (s.isOk()) {
|
|
1840
|
+
const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = je(r);
|
|
1841
|
+
a.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(c, this.declarationNode.symbol);
|
|
1839
1842
|
}
|
|
1840
1843
|
return e;
|
|
1841
1844
|
}
|
|
1842
1845
|
validateSettingList(e) {
|
|
1843
|
-
return e ? [new
|
|
1846
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
|
|
1844
1847
|
}
|
|
1845
1848
|
validateBody(e) {
|
|
1846
1849
|
if (!e)
|
|
1847
1850
|
return [];
|
|
1848
|
-
if (e instanceof
|
|
1851
|
+
if (e instanceof v)
|
|
1849
1852
|
return this.validateFields([e]);
|
|
1850
|
-
const [
|
|
1851
|
-
return [...this.validateFields(
|
|
1853
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
1854
|
+
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1852
1855
|
}
|
|
1853
1856
|
validateFields(e) {
|
|
1854
|
-
return e.length === 0 ? [new
|
|
1855
|
-
const
|
|
1856
|
-
return
|
|
1857
|
+
return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1858
|
+
const s = [];
|
|
1859
|
+
return n.callee && !M(n.callee) && s.push(new l(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), I.last(n.args) instanceof U && s.push(...this.validateFieldSetting(I.last(n.args))), n.args.length > 1 && s.push(...n.args.map((i) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), s.push(...this.registerField(n)), s;
|
|
1857
1860
|
});
|
|
1858
1861
|
}
|
|
1859
1862
|
validateFieldSetting(e) {
|
|
1860
|
-
const
|
|
1863
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
1861
1864
|
for (const r in i) {
|
|
1862
1865
|
const a = i[r];
|
|
1863
1866
|
switch (r) {
|
|
1864
1867
|
case "note":
|
|
1865
|
-
a.length > 1 && a.forEach((
|
|
1866
|
-
|
|
1868
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
1869
|
+
j(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1867
1870
|
});
|
|
1868
1871
|
break;
|
|
1869
1872
|
default:
|
|
1870
|
-
a.forEach((
|
|
1873
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, c)));
|
|
1871
1874
|
}
|
|
1872
1875
|
}
|
|
1873
|
-
return
|
|
1876
|
+
return s;
|
|
1874
1877
|
}
|
|
1875
1878
|
validateSubElements(e) {
|
|
1876
|
-
return e.flatMap((
|
|
1877
|
-
if (
|
|
1879
|
+
return e.flatMap((n) => {
|
|
1880
|
+
if (n.parent = this.declarationNode, !n.type)
|
|
1878
1881
|
return [];
|
|
1879
|
-
const
|
|
1880
|
-
return new n
|
|
1882
|
+
const s = ie(n);
|
|
1883
|
+
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1881
1884
|
});
|
|
1882
1885
|
}
|
|
1883
1886
|
registerField(e) {
|
|
1884
1887
|
if (e.callee && M(e.callee)) {
|
|
1885
|
-
const
|
|
1888
|
+
const n = G(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Zt, { declaration: e });
|
|
1886
1889
|
e.symbol = i;
|
|
1887
1890
|
const r = this.declarationNode.symbol.symbolTable;
|
|
1888
|
-
if (r.has(
|
|
1889
|
-
const a = r.get(
|
|
1891
|
+
if (r.has(s)) {
|
|
1892
|
+
const a = r.get(s);
|
|
1890
1893
|
return [
|
|
1891
|
-
new
|
|
1892
|
-
new
|
|
1894
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
|
|
1895
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
|
|
1893
1896
|
];
|
|
1894
1897
|
}
|
|
1895
|
-
r.set(
|
|
1898
|
+
r.set(s, i);
|
|
1896
1899
|
}
|
|
1897
1900
|
return [];
|
|
1898
1901
|
}
|
|
1899
1902
|
}
|
|
1900
|
-
class
|
|
1901
|
-
constructor(e,
|
|
1902
|
-
this.declarationNode = e, this.publicSymbolTable =
|
|
1903
|
+
class Ln {
|
|
1904
|
+
constructor(e, n, s) {
|
|
1905
|
+
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1903
1906
|
}
|
|
1904
1907
|
validate() {
|
|
1905
1908
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1906
1909
|
}
|
|
1907
1910
|
validateContext() {
|
|
1908
|
-
return this.declarationNode.parent instanceof
|
|
1911
|
+
return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new l(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
|
|
1909
1912
|
}
|
|
1910
1913
|
validateName(e) {
|
|
1911
|
-
return e ? [new
|
|
1914
|
+
return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
1912
1915
|
}
|
|
1913
1916
|
validateAlias(e) {
|
|
1914
|
-
return e ? [new
|
|
1917
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
|
|
1915
1918
|
}
|
|
1916
1919
|
validateSettingList(e) {
|
|
1917
|
-
return e ? [new
|
|
1920
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
|
|
1918
1921
|
}
|
|
1919
1922
|
validateBody(e) {
|
|
1920
1923
|
if (!e)
|
|
1921
1924
|
return [];
|
|
1922
|
-
if (e instanceof
|
|
1923
|
-
return [new
|
|
1924
|
-
const [
|
|
1925
|
-
return [...this.validateFields(
|
|
1925
|
+
if (e instanceof v)
|
|
1926
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1927
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
1928
|
+
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1926
1929
|
}
|
|
1927
1930
|
validateFields(e) {
|
|
1928
|
-
return e.flatMap((
|
|
1929
|
-
if (!
|
|
1931
|
+
return e.flatMap((n) => {
|
|
1932
|
+
if (!n.callee)
|
|
1930
1933
|
return [];
|
|
1931
|
-
const
|
|
1932
|
-
return I.last(i) instanceof U &&
|
|
1934
|
+
const s = [], i = [n.callee, ...n.args];
|
|
1935
|
+
return I.last(i) instanceof U && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1933
1936
|
for (; r instanceof H; )
|
|
1934
|
-
r.argumentList && !Ge(r.argumentList).isOk() &&
|
|
1935
|
-
Ge(r).isOk() ||
|
|
1936
|
-
}),
|
|
1937
|
+
r.argumentList && !Ge(r.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", r.argumentList)), r = r.callee;
|
|
1938
|
+
Ge(r).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", r));
|
|
1939
|
+
}), s;
|
|
1937
1940
|
});
|
|
1938
1941
|
}
|
|
1939
1942
|
validateFieldSetting(e) {
|
|
1940
|
-
const
|
|
1943
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
1941
1944
|
for (const r in i) {
|
|
1942
1945
|
const a = i[r];
|
|
1943
1946
|
switch (r) {
|
|
1944
1947
|
case "note":
|
|
1945
1948
|
case "name":
|
|
1946
|
-
a.length > 1 && a.forEach((
|
|
1947
|
-
|
|
1949
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1950
|
+
j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
|
|
1948
1951
|
});
|
|
1949
1952
|
break;
|
|
1950
1953
|
case "unique":
|
|
1951
1954
|
case "pk":
|
|
1952
|
-
a.length > 1 && a.forEach((
|
|
1953
|
-
oe(
|
|
1955
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1956
|
+
oe(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
|
|
1954
1957
|
});
|
|
1955
1958
|
break;
|
|
1956
1959
|
case "type":
|
|
1957
|
-
a.length > 1 && a.forEach((
|
|
1958
|
-
M(
|
|
1960
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), a.forEach((c) => {
|
|
1961
|
+
M(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
|
|
1959
1962
|
});
|
|
1960
1963
|
break;
|
|
1961
1964
|
default:
|
|
1962
|
-
a.forEach((
|
|
1965
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, c)));
|
|
1963
1966
|
}
|
|
1964
1967
|
}
|
|
1965
|
-
return
|
|
1968
|
+
return s;
|
|
1966
1969
|
}
|
|
1967
1970
|
validateSubElements(e) {
|
|
1968
|
-
return e.flatMap((
|
|
1969
|
-
if (
|
|
1971
|
+
return e.flatMap((n) => {
|
|
1972
|
+
if (n.parent = this.declarationNode, !n.type)
|
|
1970
1973
|
return [];
|
|
1971
|
-
const
|
|
1972
|
-
return new n
|
|
1974
|
+
const s = ie(n);
|
|
1975
|
+
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
1973
1976
|
});
|
|
1974
1977
|
}
|
|
1975
1978
|
}
|
|
1976
|
-
class
|
|
1977
|
-
constructor(e,
|
|
1978
|
-
this.declarationNode = e, this.publicSymbolTable =
|
|
1979
|
+
class gn {
|
|
1980
|
+
constructor(e, n, s) {
|
|
1981
|
+
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
1979
1982
|
}
|
|
1980
1983
|
validate() {
|
|
1981
1984
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1982
1985
|
}
|
|
1983
1986
|
validateContext() {
|
|
1984
|
-
return this.declarationNode.parent instanceof
|
|
1987
|
+
return !(this.declarationNode.parent instanceof F) && ![b.Table, b.Project].includes(de(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
|
|
1985
1988
|
}
|
|
1986
1989
|
validateName(e) {
|
|
1987
|
-
|
|
1990
|
+
if (!(this.declarationNode.parent instanceof F))
|
|
1991
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
1992
|
+
if (!e)
|
|
1993
|
+
return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
1994
|
+
const n = C(e);
|
|
1995
|
+
if (!n.isOk())
|
|
1996
|
+
return [];
|
|
1997
|
+
const i = n.unwrap().join("."), r = Yt(i);
|
|
1998
|
+
return this.publicSymbolTable.has(r) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
|
|
1988
1999
|
}
|
|
1989
2000
|
validateAlias(e) {
|
|
1990
|
-
return e ? [new
|
|
2001
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1991
2002
|
}
|
|
1992
2003
|
validateSettingList(e) {
|
|
1993
|
-
return e ? [new
|
|
2004
|
+
return e && !(this.declarationNode.parent instanceof F) ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
|
|
1994
2005
|
}
|
|
1995
2006
|
validateBody(e) {
|
|
1996
2007
|
if (!e)
|
|
1997
2008
|
return [];
|
|
1998
|
-
if (e instanceof
|
|
2009
|
+
if (e instanceof v)
|
|
1999
2010
|
return this.validateFields([e]);
|
|
2000
|
-
const [
|
|
2001
|
-
return [...this.validateFields(
|
|
2011
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2012
|
+
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2002
2013
|
}
|
|
2003
2014
|
validateFields(e) {
|
|
2004
|
-
const
|
|
2005
|
-
return e.length === 0 ? [new
|
|
2015
|
+
const n = [];
|
|
2016
|
+
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))), j(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);
|
|
2006
2017
|
}
|
|
2007
2018
|
validateSubElements(e) {
|
|
2008
|
-
return e.flatMap((
|
|
2009
|
-
if (
|
|
2019
|
+
return e.flatMap((n) => {
|
|
2020
|
+
if (n.parent = this.declarationNode, !n.type)
|
|
2010
2021
|
return [];
|
|
2011
|
-
const
|
|
2012
|
-
return new n
|
|
2022
|
+
const s = ie(n);
|
|
2023
|
+
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2013
2024
|
});
|
|
2014
2025
|
}
|
|
2015
2026
|
}
|
|
2016
|
-
class
|
|
2017
|
-
constructor(e,
|
|
2018
|
-
this.declarationNode = e, this.publicSymbolTable =
|
|
2027
|
+
class _n {
|
|
2028
|
+
constructor(e, n, s) {
|
|
2029
|
+
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2019
2030
|
}
|
|
2020
2031
|
validate() {
|
|
2021
2032
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2022
2033
|
}
|
|
2023
2034
|
validateContext() {
|
|
2024
|
-
return this.declarationNode.parent instanceof _ ? [new
|
|
2035
|
+
return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2025
2036
|
}
|
|
2026
2037
|
validateName(e) {
|
|
2027
|
-
return e ? Pe(e) ? [] : [new
|
|
2038
|
+
return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2028
2039
|
}
|
|
2029
2040
|
validateAlias(e) {
|
|
2030
|
-
return e ? [new
|
|
2041
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
2031
2042
|
}
|
|
2032
2043
|
validateSettingList(e) {
|
|
2033
|
-
return e ? [new
|
|
2044
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
|
|
2034
2045
|
}
|
|
2035
2046
|
validateBody(e) {
|
|
2036
2047
|
if (!e)
|
|
2037
2048
|
return [];
|
|
2038
|
-
if (e instanceof
|
|
2039
|
-
return [new
|
|
2040
|
-
const [
|
|
2049
|
+
if (e instanceof v)
|
|
2050
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2051
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2041
2052
|
return [
|
|
2042
|
-
...
|
|
2043
|
-
...this.validateSubElements(
|
|
2053
|
+
...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2054
|
+
...this.validateSubElements(s)
|
|
2044
2055
|
];
|
|
2045
2056
|
}
|
|
2046
2057
|
validateSubElements(e) {
|
|
2047
|
-
return e.flatMap((
|
|
2048
|
-
if (
|
|
2058
|
+
return e.flatMap((n) => {
|
|
2059
|
+
if (n.parent = this.declarationNode, !n.type)
|
|
2049
2060
|
return [];
|
|
2050
|
-
const
|
|
2051
|
-
return new n
|
|
2061
|
+
const s = ie(n);
|
|
2062
|
+
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2052
2063
|
});
|
|
2053
2064
|
}
|
|
2054
2065
|
}
|
|
2055
|
-
class
|
|
2056
|
-
constructor(e,
|
|
2057
|
-
this.declarationNode = e, this.publicSymbolTable =
|
|
2066
|
+
class An {
|
|
2067
|
+
constructor(e, n, s) {
|
|
2068
|
+
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2058
2069
|
}
|
|
2059
2070
|
validate() {
|
|
2060
2071
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2061
2072
|
}
|
|
2062
2073
|
validateContext() {
|
|
2063
|
-
return this.declarationNode.parent instanceof
|
|
2074
|
+
return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) === b.Table ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level or inside a table", this.declarationNode)];
|
|
2064
2075
|
}
|
|
2065
2076
|
validateName(e) {
|
|
2066
|
-
return e ? Pe(e) ? [] : [new
|
|
2077
|
+
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)] : [];
|
|
2067
2078
|
}
|
|
2068
2079
|
validateAlias(e) {
|
|
2069
|
-
return e ? [new
|
|
2080
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2070
2081
|
}
|
|
2071
2082
|
validateSettingList(e) {
|
|
2072
|
-
return e ? [new
|
|
2083
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
|
|
2073
2084
|
}
|
|
2074
2085
|
validateBody(e) {
|
|
2075
2086
|
if (!e)
|
|
2076
2087
|
return [];
|
|
2077
|
-
if (e instanceof
|
|
2088
|
+
if (e instanceof v)
|
|
2078
2089
|
return this.validateFields([e]);
|
|
2079
|
-
const [
|
|
2080
|
-
return [...this.validateFields(
|
|
2090
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2091
|
+
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2081
2092
|
}
|
|
2082
2093
|
validateFields(e) {
|
|
2083
2094
|
if (e.length === 0)
|
|
2084
|
-
return [new
|
|
2085
|
-
const
|
|
2086
|
-
return e.length > 1 &&
|
|
2087
|
-
|
|
2088
|
-
}),
|
|
2095
|
+
return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2096
|
+
const n = [];
|
|
2097
|
+
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) => {
|
|
2098
|
+
s.callee && !Nn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !mn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee)), I.last(s.args) instanceof U && this.validateFieldSettings(I.last(s.args)), s.args.length > 1 && n.push(...s.args.map((i) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
|
|
2099
|
+
}), n;
|
|
2089
2100
|
}
|
|
2090
2101
|
validateFieldSettings(e) {
|
|
2091
|
-
const
|
|
2102
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
2092
2103
|
for (const r in i) {
|
|
2093
2104
|
const a = i[r];
|
|
2094
2105
|
switch (r) {
|
|
2095
2106
|
case "delete":
|
|
2096
2107
|
case "update":
|
|
2097
|
-
a.length > 1 && a.forEach((
|
|
2098
|
-
|
|
2108
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
2109
|
+
vn(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
|
|
2099
2110
|
});
|
|
2100
2111
|
break;
|
|
2101
2112
|
default:
|
|
2102
|
-
a.forEach((
|
|
2113
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, c)));
|
|
2103
2114
|
}
|
|
2104
2115
|
}
|
|
2105
|
-
return
|
|
2116
|
+
return s;
|
|
2106
2117
|
}
|
|
2107
2118
|
validateSubElements(e) {
|
|
2108
|
-
return e.flatMap((
|
|
2109
|
-
if (
|
|
2119
|
+
return e.flatMap((n) => {
|
|
2120
|
+
if (n.parent = this.declarationNode, !n.type)
|
|
2110
2121
|
return [];
|
|
2111
|
-
const
|
|
2112
|
-
return new n
|
|
2122
|
+
const s = ie(n);
|
|
2123
|
+
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2113
2124
|
});
|
|
2114
2125
|
}
|
|
2115
2126
|
}
|
|
2116
|
-
function
|
|
2117
|
-
if (!(M(t) && t.expression.variable.kind !==
|
|
2127
|
+
function vn(t) {
|
|
2128
|
+
if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof te))
|
|
2118
2129
|
return !1;
|
|
2119
2130
|
let e;
|
|
2120
2131
|
if (t instanceof te ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
|
|
@@ -2130,264 +2141,264 @@ function _n(t) {
|
|
|
2130
2141
|
}
|
|
2131
2142
|
return !1;
|
|
2132
2143
|
}
|
|
2133
|
-
class
|
|
2134
|
-
constructor(e,
|
|
2135
|
-
this.declarationNode = e, this.symbolFactory =
|
|
2144
|
+
class wn {
|
|
2145
|
+
constructor(e, n, s) {
|
|
2146
|
+
this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
|
|
2136
2147
|
}
|
|
2137
2148
|
validate() {
|
|
2138
2149
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
2139
2150
|
}
|
|
2140
2151
|
validateContext() {
|
|
2141
|
-
return this.declarationNode.parent instanceof _ ? [new
|
|
2152
|
+
return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2142
2153
|
}
|
|
2143
2154
|
validateName(e) {
|
|
2144
|
-
return e ? e instanceof he ? [new
|
|
2155
|
+
return e ? e instanceof he ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(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)];
|
|
2145
2156
|
}
|
|
2146
2157
|
validateAlias(e) {
|
|
2147
|
-
return e ?
|
|
2158
|
+
return e ? Sn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2148
2159
|
}
|
|
2149
2160
|
validateSettingList(e) {
|
|
2150
|
-
const
|
|
2161
|
+
const n = $(e), s = n.getErrors(), i = n.getValue();
|
|
2151
2162
|
for (const r in i) {
|
|
2152
2163
|
const a = i[r];
|
|
2153
2164
|
switch (r) {
|
|
2154
2165
|
case "headercolor":
|
|
2155
|
-
a.length > 1 &&
|
|
2156
|
-
|
|
2166
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
|
|
2167
|
+
On(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
|
|
2157
2168
|
});
|
|
2158
2169
|
break;
|
|
2159
2170
|
case "note":
|
|
2160
|
-
a.length > 1 &&
|
|
2161
|
-
|
|
2171
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
2172
|
+
j(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2162
2173
|
});
|
|
2163
2174
|
break;
|
|
2164
2175
|
default:
|
|
2165
|
-
|
|
2176
|
+
s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
|
|
2166
2177
|
}
|
|
2167
2178
|
}
|
|
2168
|
-
return
|
|
2179
|
+
return s;
|
|
2169
2180
|
}
|
|
2170
2181
|
registerElement() {
|
|
2171
2182
|
const e = [];
|
|
2172
|
-
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new
|
|
2173
|
-
const { name:
|
|
2183
|
+
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
2184
|
+
const { name: n, alias: s } = this.declarationNode, i = C(n);
|
|
2174
2185
|
if (i.isOk()) {
|
|
2175
|
-
const r = [...i.unwrap()], a = r.pop(),
|
|
2176
|
-
|
|
2186
|
+
const r = [...i.unwrap()], a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
|
|
2187
|
+
c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), c.set(p, this.declarationNode.symbol);
|
|
2177
2188
|
}
|
|
2178
|
-
if (
|
|
2179
|
-
const r =
|
|
2180
|
-
this.publicSymbolTable.has(a) && e.push(new
|
|
2189
|
+
if (s && Pe(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2190
|
+
const r = G(s).unwrap(), a = xe(r);
|
|
2191
|
+
this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2181
2192
|
}
|
|
2182
2193
|
return e;
|
|
2183
2194
|
}
|
|
2184
2195
|
validateBody(e) {
|
|
2185
2196
|
if (!e)
|
|
2186
2197
|
return [];
|
|
2187
|
-
if (e instanceof
|
|
2188
|
-
return [new
|
|
2189
|
-
const [
|
|
2190
|
-
return [...this.validateFields(
|
|
2198
|
+
if (e instanceof v)
|
|
2199
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2200
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2201
|
+
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2191
2202
|
}
|
|
2192
2203
|
validateFields(e) {
|
|
2193
|
-
return e.length === 0 ? [new
|
|
2194
|
-
if (!
|
|
2204
|
+
return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
|
|
2205
|
+
if (!n.callee)
|
|
2195
2206
|
return [];
|
|
2196
|
-
const
|
|
2197
|
-
|
|
2198
|
-
const i =
|
|
2199
|
-
return
|
|
2207
|
+
const s = [];
|
|
2208
|
+
n.args.length === 0 && s.push(new l(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(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] && !yn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2209
|
+
const i = n.args.slice(1);
|
|
2210
|
+
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2200
2211
|
});
|
|
2201
2212
|
}
|
|
2202
2213
|
registerField(e) {
|
|
2203
2214
|
if (e.callee && M(e.callee)) {
|
|
2204
|
-
const
|
|
2215
|
+
const n = G(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Kt, { declaration: e });
|
|
2205
2216
|
e.symbol = i;
|
|
2206
2217
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2207
|
-
if (r.has(
|
|
2208
|
-
const a = r.get(
|
|
2218
|
+
if (r.has(s)) {
|
|
2219
|
+
const a = r.get(s);
|
|
2209
2220
|
return [
|
|
2210
|
-
new
|
|
2211
|
-
new
|
|
2221
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
|
|
2222
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
|
|
2212
2223
|
];
|
|
2213
2224
|
}
|
|
2214
|
-
r.set(
|
|
2225
|
+
r.set(s, i);
|
|
2215
2226
|
}
|
|
2216
2227
|
return [];
|
|
2217
2228
|
}
|
|
2218
2229
|
// This is needed to support legacy inline settings
|
|
2219
2230
|
validateFieldSetting(e) {
|
|
2220
2231
|
if (!e.slice(0, -1).every(fe) || !e.slice(-1).every((p) => fe(p) || p instanceof U))
|
|
2221
|
-
return [...e.map((p) => new
|
|
2232
|
+
return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2222
2233
|
if (e.length === 0)
|
|
2223
2234
|
return [];
|
|
2224
|
-
let
|
|
2225
|
-
I.last(e) instanceof U && (
|
|
2226
|
-
const
|
|
2235
|
+
let n;
|
|
2236
|
+
I.last(e) instanceof U && (n = e.pop());
|
|
2237
|
+
const s = $(n), i = s.getErrors(), r = s.getValue();
|
|
2227
2238
|
for (const p of e) {
|
|
2228
|
-
const h =
|
|
2239
|
+
const h = G(p).unwrap_or("").toLowerCase();
|
|
2229
2240
|
if (h !== "pk" && h !== "unique") {
|
|
2230
|
-
i.push(new
|
|
2241
|
+
i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2231
2242
|
continue;
|
|
2232
2243
|
}
|
|
2233
2244
|
r[h] === void 0 ? r[h] = [p] : r[h].push(p);
|
|
2234
2245
|
}
|
|
2235
|
-
const a = r.pk || [],
|
|
2236
|
-
a.length >= 1 &&
|
|
2246
|
+
const a = r.pk || [], c = r["primary key"] || [];
|
|
2247
|
+
a.length >= 1 && c.length >= 1 && i.push(...[...a, ...c].map((p) => new l(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
|
|
2237
2248
|
for (const p in r) {
|
|
2238
2249
|
const h = r[p];
|
|
2239
2250
|
switch (p) {
|
|
2240
2251
|
case "note":
|
|
2241
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2242
|
-
|
|
2252
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2253
|
+
j(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2243
2254
|
});
|
|
2244
2255
|
break;
|
|
2245
2256
|
case "ref":
|
|
2246
2257
|
h.forEach((f) => {
|
|
2247
|
-
|
|
2258
|
+
Rn(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
|
|
2248
2259
|
});
|
|
2249
2260
|
break;
|
|
2250
2261
|
case "primary key":
|
|
2251
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2252
|
-
oe(f.value) || i.push(new
|
|
2262
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
|
|
2263
|
+
oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
|
|
2253
2264
|
});
|
|
2254
2265
|
break;
|
|
2255
2266
|
case "pk":
|
|
2256
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2257
|
-
f instanceof ne && !oe(f.value) && i.push(new
|
|
2267
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
|
|
2268
|
+
f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
|
|
2258
2269
|
});
|
|
2259
2270
|
break;
|
|
2260
2271
|
case "not null":
|
|
2261
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2272
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
|
|
2262
2273
|
const T = r.null || [];
|
|
2263
|
-
h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new
|
|
2264
|
-
oe(f.value) || i.push(new
|
|
2274
|
+
h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
|
|
2275
|
+
oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
|
|
2265
2276
|
});
|
|
2266
2277
|
break;
|
|
2267
2278
|
case "null":
|
|
2268
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2269
|
-
oe(f.value) || i.push(new
|
|
2279
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
|
|
2280
|
+
oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
|
|
2270
2281
|
});
|
|
2271
2282
|
break;
|
|
2272
2283
|
case "unique":
|
|
2273
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2274
|
-
f instanceof ne && !oe(f.value) && i.push(new
|
|
2284
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
|
|
2285
|
+
f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
|
|
2275
2286
|
});
|
|
2276
2287
|
break;
|
|
2277
2288
|
case "increment":
|
|
2278
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2279
|
-
f instanceof ne && !oe(f.value) && i.push(new
|
|
2289
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
|
|
2290
|
+
f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
|
|
2280
2291
|
});
|
|
2281
2292
|
break;
|
|
2282
2293
|
case "default":
|
|
2283
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2284
|
-
|
|
2294
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
|
|
2295
|
+
Dn(f.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
|
|
2285
2296
|
});
|
|
2286
2297
|
break;
|
|
2287
2298
|
default:
|
|
2288
|
-
h.forEach((f) => i.push(new
|
|
2299
|
+
h.forEach((f) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
|
|
2289
2300
|
}
|
|
2290
2301
|
}
|
|
2291
2302
|
return i;
|
|
2292
2303
|
}
|
|
2293
2304
|
validateSubElements(e) {
|
|
2294
|
-
const
|
|
2305
|
+
const n = e.flatMap((i) => {
|
|
2295
2306
|
if (i.parent = this.declarationNode, !i.type)
|
|
2296
2307
|
return [];
|
|
2297
2308
|
const r = ie(i);
|
|
2298
2309
|
return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2299
|
-
}),
|
|
2310
|
+
}), s = e.filter((i) => {
|
|
2300
2311
|
var r;
|
|
2301
2312
|
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2302
2313
|
});
|
|
2303
|
-
return
|
|
2314
|
+
return s.length > 1 && (n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
|
|
2304
2315
|
}
|
|
2305
2316
|
}
|
|
2306
|
-
function
|
|
2317
|
+
function yn(t) {
|
|
2307
2318
|
if (!(t instanceof H || He(t) || t instanceof R || t instanceof he))
|
|
2308
2319
|
return !1;
|
|
2309
2320
|
if (t instanceof H) {
|
|
2310
|
-
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((
|
|
2321
|
+
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) || j(n) || fe(n)))
|
|
2311
2322
|
return !1;
|
|
2312
2323
|
t = t.callee;
|
|
2313
2324
|
}
|
|
2314
2325
|
for (; t instanceof he; ) {
|
|
2315
|
-
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((
|
|
2326
|
+
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ce(n.name)))
|
|
2316
2327
|
return !1;
|
|
2317
2328
|
t = t.array;
|
|
2318
2329
|
}
|
|
2319
|
-
const e =
|
|
2330
|
+
const e = C(t).unwrap_or(void 0);
|
|
2320
2331
|
return e !== void 0 && e.length > 0;
|
|
2321
2332
|
}
|
|
2322
|
-
function
|
|
2333
|
+
function xn(t, e) {
|
|
2323
2334
|
return e.length === 1 && t === e[0];
|
|
2324
2335
|
}
|
|
2325
|
-
class
|
|
2326
|
-
constructor(e,
|
|
2327
|
-
this.declarationNode = e, this.publicSymbolTable =
|
|
2336
|
+
class kn {
|
|
2337
|
+
constructor(e, n, s) {
|
|
2338
|
+
this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
|
|
2328
2339
|
}
|
|
2329
2340
|
validate() {
|
|
2330
2341
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
|
|
2331
2342
|
}
|
|
2332
2343
|
validateContext() {
|
|
2333
|
-
return this.declarationNode.parent instanceof _ ? [new
|
|
2344
|
+
return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
2334
2345
|
}
|
|
2335
2346
|
validateName(e) {
|
|
2336
|
-
return e ? Je(e) ? [] : [new
|
|
2347
|
+
return e ? Je(e) ? [] : [new l(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new l(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
|
|
2337
2348
|
}
|
|
2338
2349
|
validateAlias(e) {
|
|
2339
|
-
return e ? [new
|
|
2350
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
|
|
2340
2351
|
}
|
|
2341
2352
|
registerElement() {
|
|
2342
2353
|
const { name: e } = this.declarationNode;
|
|
2343
|
-
this.declarationNode.symbol = this.symbolFactory.create(
|
|
2344
|
-
const
|
|
2345
|
-
if (
|
|
2346
|
-
const
|
|
2354
|
+
this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new Ae() });
|
|
2355
|
+
const n = C(e);
|
|
2356
|
+
if (n.isOk()) {
|
|
2357
|
+
const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
|
|
2347
2358
|
if (r.has(a))
|
|
2348
|
-
return [new
|
|
2359
|
+
return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
|
|
2349
2360
|
r.set(a, this.declarationNode.symbol);
|
|
2350
2361
|
}
|
|
2351
2362
|
return [];
|
|
2352
2363
|
}
|
|
2353
2364
|
validateSettingList(e) {
|
|
2354
|
-
return e ? [new
|
|
2365
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
|
|
2355
2366
|
}
|
|
2356
2367
|
validateBody(e) {
|
|
2357
2368
|
if (!e)
|
|
2358
2369
|
return [];
|
|
2359
|
-
if (e instanceof
|
|
2360
|
-
return [new
|
|
2361
|
-
const [
|
|
2362
|
-
return [...this.validateFields(
|
|
2370
|
+
if (e instanceof v)
|
|
2371
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2372
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
2373
|
+
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2363
2374
|
}
|
|
2364
2375
|
validateFields(e) {
|
|
2365
|
-
return e.flatMap((
|
|
2366
|
-
const
|
|
2367
|
-
return
|
|
2376
|
+
return e.flatMap((n) => {
|
|
2377
|
+
const s = [];
|
|
2378
|
+
return n.callee && !C(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;
|
|
2368
2379
|
});
|
|
2369
2380
|
}
|
|
2370
2381
|
validateSubElements(e) {
|
|
2371
|
-
return e.flatMap((
|
|
2372
|
-
if (
|
|
2382
|
+
return e.flatMap((n) => {
|
|
2383
|
+
if (n.parent = this.declarationNode, !n.type)
|
|
2373
2384
|
return [];
|
|
2374
|
-
const
|
|
2375
|
-
return new n
|
|
2385
|
+
const s = ie(n);
|
|
2386
|
+
return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
|
|
2376
2387
|
});
|
|
2377
2388
|
}
|
|
2378
2389
|
registerField(e) {
|
|
2379
2390
|
if (e.callee && M(e.callee)) {
|
|
2380
|
-
const
|
|
2391
|
+
const n = G(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
|
|
2381
2392
|
e.symbol = i;
|
|
2382
2393
|
const r = this.declarationNode.symbol.symbolTable;
|
|
2383
|
-
if (r.has(
|
|
2384
|
-
const a = r.get(
|
|
2394
|
+
if (r.has(s)) {
|
|
2395
|
+
const a = r.get(s);
|
|
2385
2396
|
return [
|
|
2386
|
-
new
|
|
2387
|
-
new
|
|
2397
|
+
new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
|
|
2398
|
+
new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
|
|
2388
2399
|
];
|
|
2389
2400
|
}
|
|
2390
|
-
r.set(
|
|
2401
|
+
r.set(s, i);
|
|
2391
2402
|
}
|
|
2392
2403
|
return [];
|
|
2393
2404
|
}
|
|
@@ -2396,256 +2407,256 @@ const wt = ["-", "+"];
|
|
|
2396
2407
|
function ie(t) {
|
|
2397
2408
|
switch (t.type.value.toLowerCase()) {
|
|
2398
2409
|
case b.Enum:
|
|
2399
|
-
return
|
|
2410
|
+
return In;
|
|
2400
2411
|
case b.Table:
|
|
2401
|
-
return
|
|
2412
|
+
return wn;
|
|
2402
2413
|
case b.TableGroup:
|
|
2403
|
-
return
|
|
2414
|
+
return kn;
|
|
2404
2415
|
case b.Project:
|
|
2405
|
-
return
|
|
2416
|
+
return _n;
|
|
2406
2417
|
case b.Ref:
|
|
2407
|
-
return
|
|
2418
|
+
return An;
|
|
2408
2419
|
case b.Note:
|
|
2409
|
-
return
|
|
2420
|
+
return gn;
|
|
2410
2421
|
case b.Indexes:
|
|
2411
|
-
return
|
|
2422
|
+
return Ln;
|
|
2412
2423
|
default:
|
|
2413
|
-
return
|
|
2424
|
+
return bn;
|
|
2414
2425
|
}
|
|
2415
2426
|
}
|
|
2416
2427
|
function Je(t) {
|
|
2417
|
-
return !!
|
|
2428
|
+
return !!C(t).unwrap_or(!1);
|
|
2418
2429
|
}
|
|
2419
|
-
function
|
|
2430
|
+
function Sn(t) {
|
|
2420
2431
|
return Pe(t);
|
|
2421
2432
|
}
|
|
2422
2433
|
function Pe(t) {
|
|
2423
|
-
return t instanceof R && t.expression instanceof
|
|
2434
|
+
return t instanceof R && t.expression instanceof W;
|
|
2424
2435
|
}
|
|
2425
|
-
function Ze(t, e,
|
|
2436
|
+
function Ze(t, e, n) {
|
|
2426
2437
|
var i;
|
|
2427
2438
|
t[0] === "public" && (t = t.slice(1));
|
|
2428
|
-
let
|
|
2439
|
+
let s = e;
|
|
2429
2440
|
for (const r of t) {
|
|
2430
2441
|
let a;
|
|
2431
|
-
const
|
|
2432
|
-
if (
|
|
2433
|
-
if (a = (i =
|
|
2442
|
+
const c = $e(r);
|
|
2443
|
+
if (s.has(c)) {
|
|
2444
|
+
if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
|
|
2434
2445
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2435
2446
|
} else {
|
|
2436
|
-
a = new
|
|
2437
|
-
const p =
|
|
2438
|
-
|
|
2447
|
+
a = new Ae();
|
|
2448
|
+
const p = n.create(_t, { symbolTable: a });
|
|
2449
|
+
s.set(c, p);
|
|
2439
2450
|
}
|
|
2440
|
-
|
|
2451
|
+
s = a;
|
|
2441
2452
|
}
|
|
2442
|
-
return
|
|
2453
|
+
return s;
|
|
2443
2454
|
}
|
|
2444
2455
|
function yt(t) {
|
|
2445
2456
|
return t === "-" || t === "<>" || t === ">" || t === "<";
|
|
2446
2457
|
}
|
|
2447
|
-
function
|
|
2448
|
-
var
|
|
2449
|
-
if (!(t instanceof R) || !(t.expression instanceof pe) || ((
|
|
2458
|
+
function On(t) {
|
|
2459
|
+
var n;
|
|
2460
|
+
if (!(t instanceof R) || !(t.expression instanceof pe) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
|
|
2450
2461
|
return !1;
|
|
2451
2462
|
const e = t.expression.literal.value;
|
|
2452
2463
|
if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
|
|
2453
2464
|
return !1;
|
|
2454
|
-
for (let
|
|
2455
|
-
if (!
|
|
2465
|
+
for (let s = 1; s < e.length; s += 1)
|
|
2466
|
+
if (!qt(e[s]))
|
|
2456
2467
|
return !1;
|
|
2457
2468
|
return !0;
|
|
2458
2469
|
}
|
|
2459
2470
|
function oe(t) {
|
|
2460
2471
|
return t === void 0;
|
|
2461
2472
|
}
|
|
2462
|
-
function
|
|
2473
|
+
function Dn(t) {
|
|
2463
2474
|
var e;
|
|
2464
|
-
return !!(
|
|
2475
|
+
return !!(j(t) || ce(t) || fe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression) || t instanceof K);
|
|
2465
2476
|
}
|
|
2466
|
-
function
|
|
2477
|
+
function ce(t) {
|
|
2467
2478
|
var e;
|
|
2468
|
-
return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) ===
|
|
2479
|
+
return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
|
|
2469
2480
|
}
|
|
2470
|
-
function
|
|
2471
|
-
var
|
|
2472
|
-
if (!(t instanceof Q) || !yt((
|
|
2481
|
+
function Rn(t) {
|
|
2482
|
+
var n;
|
|
2483
|
+
if (!(t instanceof Q) || !yt((n = t.op) == null ? void 0 : n.value))
|
|
2473
2484
|
return !1;
|
|
2474
|
-
const e =
|
|
2485
|
+
const e = C(t.expression).unwrap_or(void 0);
|
|
2475
2486
|
return e !== void 0 && e.length > 0;
|
|
2476
2487
|
}
|
|
2477
2488
|
function xt(t) {
|
|
2478
2489
|
return t instanceof J && t.elementList.every(M);
|
|
2479
2490
|
}
|
|
2480
|
-
function
|
|
2481
|
-
var
|
|
2482
|
-
const e = {},
|
|
2491
|
+
function $(t) {
|
|
2492
|
+
var s;
|
|
2493
|
+
const e = {}, n = [];
|
|
2483
2494
|
if (!t)
|
|
2484
|
-
return new
|
|
2495
|
+
return new B({});
|
|
2485
2496
|
for (const i of t.elementList) {
|
|
2486
2497
|
if (!i.name)
|
|
2487
2498
|
continue;
|
|
2488
2499
|
if (i.name instanceof R) {
|
|
2489
|
-
|
|
2500
|
+
n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2490
2501
|
continue;
|
|
2491
2502
|
}
|
|
2492
|
-
const r = (
|
|
2503
|
+
const r = (s = Re(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2493
2504
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2494
2505
|
}
|
|
2495
|
-
return new
|
|
2506
|
+
return new B(e, n);
|
|
2496
2507
|
}
|
|
2497
2508
|
class ft {
|
|
2498
|
-
constructor(e,
|
|
2499
|
-
this.ast = e, this.symbolFactory =
|
|
2500
|
-
symbolTable: new
|
|
2509
|
+
constructor(e, n) {
|
|
2510
|
+
this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
|
|
2511
|
+
symbolTable: new Ae()
|
|
2501
2512
|
}), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
|
|
2502
2513
|
}
|
|
2503
2514
|
validate() {
|
|
2504
2515
|
const e = [];
|
|
2505
|
-
this.ast.body.forEach((
|
|
2506
|
-
if (
|
|
2516
|
+
this.ast.body.forEach((s) => {
|
|
2517
|
+
if (s.parent = this.ast, s.type === void 0)
|
|
2507
2518
|
return;
|
|
2508
|
-
const i = ie(
|
|
2509
|
-
|
|
2519
|
+
const i = ie(s), r = new i(
|
|
2520
|
+
s,
|
|
2510
2521
|
this.publicSchemaSymbol.symbolTable,
|
|
2511
2522
|
this.symbolFactory
|
|
2512
2523
|
);
|
|
2513
2524
|
e.push(...r.validate());
|
|
2514
2525
|
});
|
|
2515
|
-
const
|
|
2516
|
-
return
|
|
2526
|
+
const n = this.ast.body.filter((s) => de(s).unwrap_or(void 0) === b.Project);
|
|
2527
|
+
return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
|
|
2517
2528
|
}
|
|
2518
2529
|
}
|
|
2519
2530
|
class re {
|
|
2520
|
-
constructor(e,
|
|
2521
|
-
this.declarationNode = e, this.errors =
|
|
2531
|
+
constructor(e, n) {
|
|
2532
|
+
this.declarationNode = e, this.errors = n;
|
|
2522
2533
|
}
|
|
2523
2534
|
bind() {
|
|
2524
2535
|
this.bindSettingList(this.declarationNode.attributeList, this.settingList), this.bindBody();
|
|
2525
2536
|
}
|
|
2526
|
-
bindSettingList(e,
|
|
2537
|
+
bindSettingList(e, n) {
|
|
2527
2538
|
if (e)
|
|
2528
|
-
for (const
|
|
2529
|
-
if (
|
|
2539
|
+
for (const s of e.elementList) {
|
|
2540
|
+
if (s.name instanceof R)
|
|
2530
2541
|
continue;
|
|
2531
|
-
const i = Re(
|
|
2542
|
+
const i = Re(s.name).unwrap_or(void 0);
|
|
2532
2543
|
if (!i)
|
|
2533
2544
|
continue;
|
|
2534
|
-
const r =
|
|
2535
|
-
r != null && r.shouldBind && this.scanAndBind(
|
|
2545
|
+
const r = n[i.toLowerCase()];
|
|
2546
|
+
r != null && r.shouldBind && this.scanAndBind(s.value, r);
|
|
2536
2547
|
}
|
|
2537
2548
|
}
|
|
2538
2549
|
bindBody() {
|
|
2539
2550
|
const e = this.declarationNode;
|
|
2540
2551
|
if (!e.body)
|
|
2541
2552
|
return;
|
|
2542
|
-
const { body:
|
|
2543
|
-
if (
|
|
2544
|
-
for (const
|
|
2545
|
-
if (
|
|
2546
|
-
if (!
|
|
2553
|
+
const { body: n } = e;
|
|
2554
|
+
if (n instanceof ee)
|
|
2555
|
+
for (const s of n.body)
|
|
2556
|
+
if (s instanceof _) {
|
|
2557
|
+
if (!s.type)
|
|
2547
2558
|
continue;
|
|
2548
|
-
const i = kt(
|
|
2549
|
-
new i(
|
|
2559
|
+
const i = kt(s);
|
|
2560
|
+
new i(s, this.errors).bind();
|
|
2550
2561
|
} else
|
|
2551
|
-
this.bindSubfield(
|
|
2562
|
+
this.bindSubfield(s);
|
|
2552
2563
|
else
|
|
2553
|
-
this.bindSubfield(
|
|
2564
|
+
this.bindSubfield(n);
|
|
2554
2565
|
}
|
|
2555
2566
|
bindSubfield(e) {
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2567
|
+
const n = [e.callee, ...e.args], s = I.last(n);
|
|
2568
|
+
s instanceof U && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
|
|
2558
2569
|
const { argBinderRules: i } = this.subfield.arg;
|
|
2559
|
-
for (let r = 0; r < Math.min(
|
|
2560
|
-
i[r].shouldBind && this.scanAndBind(
|
|
2570
|
+
for (let r = 0; r < Math.min(n.length, i.length); r += 1)
|
|
2571
|
+
i[r].shouldBind && this.scanAndBind(n[r], i[r]);
|
|
2561
2572
|
}
|
|
2562
2573
|
// Scan for variable node and member access expression in the node to bind
|
|
2563
|
-
scanAndBind(e,
|
|
2564
|
-
var
|
|
2574
|
+
scanAndBind(e, n) {
|
|
2575
|
+
var s, i;
|
|
2565
2576
|
if (e)
|
|
2566
2577
|
if (e instanceof R) {
|
|
2567
|
-
if (e.expression instanceof
|
|
2578
|
+
if (e.expression instanceof W && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2568
2579
|
return;
|
|
2569
|
-
this.bindFragments([e],
|
|
2580
|
+
this.bindFragments([e], n);
|
|
2570
2581
|
} else
|
|
2571
|
-
e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]),
|
|
2582
|
+
e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
|
|
2572
2583
|
}
|
|
2573
2584
|
// Bind the fragments of a member access expression
|
|
2574
2585
|
// which can be a simple expression like v1.User,
|
|
2575
2586
|
// or a complex tuple like v1.User.(id, name)
|
|
2576
|
-
bindFragments(e,
|
|
2587
|
+
bindFragments(e, n) {
|
|
2577
2588
|
if (e.length === 0)
|
|
2578
2589
|
return;
|
|
2579
|
-
const
|
|
2590
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), c = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
|
|
2580
2591
|
0,
|
|
2581
2592
|
r === -1 ? void 0 : r
|
|
2582
2593
|
);
|
|
2583
2594
|
if (h.length === 0)
|
|
2584
2595
|
return;
|
|
2585
2596
|
const T = [];
|
|
2586
|
-
for (;
|
|
2587
|
-
const f =
|
|
2597
|
+
for (; s.length && h.length; ) {
|
|
2598
|
+
const f = s.pop(), N = h.pop(), g = G(N).unwrap();
|
|
2588
2599
|
T.unshift({
|
|
2589
2600
|
index: Fe(g, f),
|
|
2590
2601
|
referrer: N
|
|
2591
2602
|
});
|
|
2592
2603
|
}
|
|
2593
2604
|
for (; h.length; ) {
|
|
2594
|
-
const f = h.pop(), N =
|
|
2605
|
+
const f = h.pop(), N = G(f).unwrap();
|
|
2595
2606
|
T.unshift({
|
|
2596
2607
|
index: Fe(N, i),
|
|
2597
2608
|
referrer: f
|
|
2598
2609
|
});
|
|
2599
2610
|
}
|
|
2600
|
-
return
|
|
2611
|
+
return c ? c.elementList.forEach(
|
|
2601
2612
|
(f) => this.resolveIndexStack(
|
|
2602
2613
|
[
|
|
2603
2614
|
...T,
|
|
2604
2615
|
{
|
|
2605
2616
|
index: Fe(
|
|
2606
|
-
|
|
2617
|
+
G(f).unwrap(),
|
|
2607
2618
|
p
|
|
2608
2619
|
),
|
|
2609
2620
|
referrer: f
|
|
2610
2621
|
}
|
|
2611
2622
|
],
|
|
2612
|
-
|
|
2623
|
+
n.ignoreNameNotFound
|
|
2613
2624
|
)
|
|
2614
|
-
) : this.resolveIndexStack(T,
|
|
2625
|
+
) : this.resolveIndexStack(T, n.ignoreNameNotFound);
|
|
2615
2626
|
}
|
|
2616
2627
|
// Looking up the indexes in the subname stack from the current declaration node
|
|
2617
2628
|
// Each time the index resolves to a symbol, the referrer's symbol is bound to it
|
|
2618
|
-
resolveIndexStack(e,
|
|
2629
|
+
resolveIndexStack(e, n) {
|
|
2619
2630
|
if (e.length === 0)
|
|
2620
2631
|
throw new Error("Unreachable - An unresolved name must have at least one name component");
|
|
2621
|
-
const [
|
|
2632
|
+
const [s, ...i] = e, r = Tn(s.index, this.declarationNode);
|
|
2622
2633
|
if (r === void 0) {
|
|
2623
|
-
const { kind: h, name: T } = se(
|
|
2624
|
-
this.logError(
|
|
2634
|
+
const { kind: h, name: T } = se(s.index).unwrap();
|
|
2635
|
+
this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
|
|
2625
2636
|
return;
|
|
2626
2637
|
}
|
|
2627
|
-
r.references.push(
|
|
2628
|
-
let a = r.symbolTable, { kind:
|
|
2638
|
+
r.references.push(s.referrer), s.referrer.referee = r;
|
|
2639
|
+
let a = r.symbolTable, { kind: c, name: p } = se(s.index).unwrap();
|
|
2629
2640
|
for (const h of i) {
|
|
2630
2641
|
const { kind: T, name: f } = se(h.index).unwrap(), N = a.get(h.index);
|
|
2631
2642
|
if (!N) {
|
|
2632
2643
|
this.logError(
|
|
2633
2644
|
h.referrer,
|
|
2634
|
-
`${
|
|
2635
|
-
|
|
2645
|
+
`${c} '${p}' does not have ${T} '${f}'`,
|
|
2646
|
+
n
|
|
2636
2647
|
);
|
|
2637
2648
|
return;
|
|
2638
2649
|
}
|
|
2639
|
-
if (
|
|
2650
|
+
if (c = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
|
|
2640
2651
|
break;
|
|
2641
2652
|
a = N.symbolTable;
|
|
2642
2653
|
}
|
|
2643
2654
|
}
|
|
2644
|
-
logError(e,
|
|
2645
|
-
|
|
2655
|
+
logError(e, n, s) {
|
|
2656
|
+
s || this.errors.push(new l(o.BINDING_ERROR, n, e));
|
|
2646
2657
|
}
|
|
2647
2658
|
}
|
|
2648
|
-
class
|
|
2659
|
+
class Pn extends re {
|
|
2649
2660
|
constructor() {
|
|
2650
2661
|
super(...arguments), this.subfield = {
|
|
2651
2662
|
arg: {
|
|
@@ -2655,7 +2666,7 @@ class Dn extends re {
|
|
|
2655
2666
|
}, this.settingList = {};
|
|
2656
2667
|
}
|
|
2657
2668
|
}
|
|
2658
|
-
class
|
|
2669
|
+
class Un extends re {
|
|
2659
2670
|
constructor() {
|
|
2660
2671
|
super(...arguments), this.subfield = {
|
|
2661
2672
|
arg: {
|
|
@@ -2665,7 +2676,7 @@ class Rn extends re {
|
|
|
2665
2676
|
}, this.settingList = {};
|
|
2666
2677
|
}
|
|
2667
2678
|
}
|
|
2668
|
-
class
|
|
2679
|
+
class Mn extends re {
|
|
2669
2680
|
constructor() {
|
|
2670
2681
|
super(...arguments), this.subfield = {
|
|
2671
2682
|
arg: {
|
|
@@ -2700,7 +2711,7 @@ class Pn extends re {
|
|
|
2700
2711
|
}, this.settingList = {};
|
|
2701
2712
|
}
|
|
2702
2713
|
}
|
|
2703
|
-
class
|
|
2714
|
+
class Fn extends re {
|
|
2704
2715
|
constructor() {
|
|
2705
2716
|
super(...arguments), this.subfield = {
|
|
2706
2717
|
arg: {
|
|
@@ -2710,7 +2721,7 @@ class Un extends re {
|
|
|
2710
2721
|
}, this.settingList = {};
|
|
2711
2722
|
}
|
|
2712
2723
|
}
|
|
2713
|
-
class
|
|
2724
|
+
class Bn extends re {
|
|
2714
2725
|
constructor() {
|
|
2715
2726
|
super(...arguments), this.subfield = {
|
|
2716
2727
|
arg: {
|
|
@@ -2720,7 +2731,7 @@ class Mn extends re {
|
|
|
2720
2731
|
}, this.settingList = {};
|
|
2721
2732
|
}
|
|
2722
2733
|
}
|
|
2723
|
-
class
|
|
2734
|
+
class Vn extends re {
|
|
2724
2735
|
constructor() {
|
|
2725
2736
|
super(...arguments), this.subfield = {
|
|
2726
2737
|
arg: {
|
|
@@ -2737,7 +2748,7 @@ class Fn extends re {
|
|
|
2737
2748
|
}, this.settingList = {};
|
|
2738
2749
|
}
|
|
2739
2750
|
}
|
|
2740
|
-
class
|
|
2751
|
+
class Gn extends re {
|
|
2741
2752
|
constructor() {
|
|
2742
2753
|
super(...arguments), this.subfield = {
|
|
2743
2754
|
arg: {
|
|
@@ -2765,7 +2776,7 @@ class Bn extends re {
|
|
|
2765
2776
|
}, this.settingList = {};
|
|
2766
2777
|
}
|
|
2767
2778
|
}
|
|
2768
|
-
class
|
|
2779
|
+
class Cn extends re {
|
|
2769
2780
|
constructor() {
|
|
2770
2781
|
super(...arguments), this.subfield = {
|
|
2771
2782
|
arg: {
|
|
@@ -2785,75 +2796,75 @@ class Vn extends re {
|
|
|
2785
2796
|
function kt(t) {
|
|
2786
2797
|
switch (t.type.value.toLowerCase()) {
|
|
2787
2798
|
case b.Enum:
|
|
2788
|
-
return
|
|
2799
|
+
return Un;
|
|
2789
2800
|
case b.Table:
|
|
2790
|
-
return
|
|
2801
|
+
return Gn;
|
|
2791
2802
|
case b.TableGroup:
|
|
2792
|
-
return
|
|
2803
|
+
return Cn;
|
|
2793
2804
|
case b.Project:
|
|
2794
|
-
return
|
|
2805
|
+
return Bn;
|
|
2795
2806
|
case b.Ref:
|
|
2796
|
-
return
|
|
2807
|
+
return Vn;
|
|
2797
2808
|
case b.Note:
|
|
2798
|
-
return
|
|
2809
|
+
return Fn;
|
|
2799
2810
|
case b.Indexes:
|
|
2800
|
-
return
|
|
2811
|
+
return Mn;
|
|
2801
2812
|
default:
|
|
2802
|
-
return
|
|
2813
|
+
return Pn;
|
|
2803
2814
|
}
|
|
2804
2815
|
}
|
|
2805
|
-
class
|
|
2816
|
+
class Xn {
|
|
2806
2817
|
constructor(e) {
|
|
2807
2818
|
this.ast = e, this.errors = [];
|
|
2808
2819
|
}
|
|
2809
2820
|
resolve() {
|
|
2810
2821
|
for (const e of this.ast.body)
|
|
2811
2822
|
if (e.type) {
|
|
2812
|
-
const
|
|
2813
|
-
new
|
|
2823
|
+
const n = kt(e);
|
|
2824
|
+
new n(e, this.errors).bind();
|
|
2814
2825
|
}
|
|
2815
|
-
return new
|
|
2826
|
+
return new B(this.ast, this.errors);
|
|
2816
2827
|
}
|
|
2817
2828
|
}
|
|
2818
|
-
class
|
|
2829
|
+
class $n {
|
|
2819
2830
|
constructor(e) {
|
|
2820
2831
|
this.generator = e;
|
|
2821
2832
|
}
|
|
2822
|
-
create(e,
|
|
2823
|
-
return new e(
|
|
2833
|
+
create(e, n) {
|
|
2834
|
+
return new e(n, this.generator.nextId());
|
|
2824
2835
|
}
|
|
2825
2836
|
}
|
|
2826
|
-
class
|
|
2827
|
-
constructor(e,
|
|
2828
|
-
this.ast = e, this.symbolFactory = new
|
|
2837
|
+
class Wn {
|
|
2838
|
+
constructor(e, n) {
|
|
2839
|
+
this.ast = e, this.symbolFactory = new $n(n);
|
|
2829
2840
|
}
|
|
2830
2841
|
// Analyzing: Invoking both the validator and binder
|
|
2831
2842
|
analyze() {
|
|
2832
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((
|
|
2843
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Xn(n).resolve());
|
|
2833
2844
|
}
|
|
2834
2845
|
// For invoking the validator only
|
|
2835
2846
|
validate() {
|
|
2836
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((
|
|
2847
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
|
|
2837
2848
|
}
|
|
2838
2849
|
}
|
|
2839
2850
|
function pt(t, e) {
|
|
2840
|
-
const { variables:
|
|
2841
|
-
return
|
|
2851
|
+
const { variables: n, tupleElements: s } = ge(t).unwrap();
|
|
2852
|
+
return s ? n.length === 0 ? {
|
|
2842
2853
|
schemaName: e.schemaName,
|
|
2843
2854
|
tableName: e.name,
|
|
2844
|
-
fieldNames:
|
|
2855
|
+
fieldNames: s
|
|
2845
2856
|
} : {
|
|
2846
|
-
tableName:
|
|
2847
|
-
schemaName:
|
|
2848
|
-
fieldNames:
|
|
2849
|
-
} :
|
|
2857
|
+
tableName: n.pop(),
|
|
2858
|
+
schemaName: n.pop() || null,
|
|
2859
|
+
fieldNames: s
|
|
2860
|
+
} : n.length === 1 ? {
|
|
2850
2861
|
schemaName: e.schemaName,
|
|
2851
2862
|
tableName: e.name,
|
|
2852
|
-
fieldNames: [
|
|
2863
|
+
fieldNames: [n[0]]
|
|
2853
2864
|
} : {
|
|
2854
|
-
fieldNames: [
|
|
2855
|
-
tableName:
|
|
2856
|
-
schemaName:
|
|
2865
|
+
fieldNames: [n.pop()],
|
|
2866
|
+
tableName: n.pop(),
|
|
2867
|
+
schemaName: n.pop() || null
|
|
2857
2868
|
};
|
|
2858
2869
|
}
|
|
2859
2870
|
function St(t) {
|
|
@@ -2880,83 +2891,83 @@ function k(t) {
|
|
|
2880
2891
|
};
|
|
2881
2892
|
}
|
|
2882
2893
|
function Ce(t) {
|
|
2883
|
-
var
|
|
2884
|
-
const e = (
|
|
2885
|
-
return e instanceof J ? e.elementList.map((
|
|
2894
|
+
var n;
|
|
2895
|
+
const e = (n = Ee(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
|
|
2896
|
+
return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
|
|
2886
2897
|
}
|
|
2887
|
-
function
|
|
2888
|
-
const e =
|
|
2898
|
+
function Ne(t) {
|
|
2899
|
+
const e = C(t).unwrap();
|
|
2889
2900
|
return {
|
|
2890
2901
|
name: e.pop(),
|
|
2891
2902
|
schemaName: e
|
|
2892
2903
|
};
|
|
2893
2904
|
}
|
|
2894
|
-
function
|
|
2905
|
+
function Ot(t) {
|
|
2895
2906
|
return t.expression.literal.value;
|
|
2896
2907
|
}
|
|
2897
|
-
function
|
|
2908
|
+
function Dt(t, e) {
|
|
2898
2909
|
if (Array.isArray(t)) {
|
|
2899
2910
|
const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
|
|
2900
2911
|
return i < r ? `${i}-${r}` : `${i}-${r}`;
|
|
2901
2912
|
}
|
|
2902
|
-
const
|
|
2903
|
-
return
|
|
2913
|
+
const n = t.id, s = e.id;
|
|
2914
|
+
return n < s ? `${n}-${s}` : `${s}-${n}`;
|
|
2904
2915
|
}
|
|
2905
|
-
function
|
|
2916
|
+
function Rt(t, e) {
|
|
2906
2917
|
if (Array.isArray(t)) {
|
|
2907
2918
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2908
|
-
return I.zip(i, r).every(([a,
|
|
2919
|
+
return I.zip(i, r).every(([a, c]) => a === c);
|
|
2909
2920
|
}
|
|
2910
|
-
const
|
|
2911
|
-
return
|
|
2921
|
+
const n = t.id, s = e.id;
|
|
2922
|
+
return n === s;
|
|
2912
2923
|
}
|
|
2913
2924
|
class Ke {
|
|
2914
|
-
constructor(e,
|
|
2915
|
-
this.declarationNode = e, this.env =
|
|
2925
|
+
constructor(e, n) {
|
|
2926
|
+
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
2916
2927
|
}
|
|
2917
2928
|
interpret() {
|
|
2918
2929
|
return this.ref.token = k(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
2919
2930
|
}
|
|
2920
2931
|
interpretName(e) {
|
|
2921
|
-
const
|
|
2922
|
-
return this.ref.name =
|
|
2932
|
+
const n = [], s = C(this.declarationNode.name).unwrap_or([]);
|
|
2933
|
+
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;
|
|
2923
2934
|
}
|
|
2924
2935
|
interpretBody(e) {
|
|
2925
|
-
return e instanceof
|
|
2936
|
+
return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
2926
2937
|
}
|
|
2927
2938
|
interpretField(e) {
|
|
2928
2939
|
var h, T, f, N;
|
|
2929
|
-
const
|
|
2930
|
-
if (
|
|
2931
|
-
return [new
|
|
2932
|
-
const
|
|
2933
|
-
if (this.env.refIds[
|
|
2940
|
+
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
|
|
2941
|
+
if (Rt(r, a))
|
|
2942
|
+
return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
2943
|
+
const c = Dt(r, a);
|
|
2944
|
+
if (this.env.refIds[c])
|
|
2934
2945
|
return [
|
|
2935
|
-
new
|
|
2936
|
-
new
|
|
2946
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
2947
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
|
|
2937
2948
|
];
|
|
2938
2949
|
if (e.args[0]) {
|
|
2939
|
-
const g =
|
|
2940
|
-
this.ref.onDelete =
|
|
2950
|
+
const g = $(e.args[0]).getValue();
|
|
2951
|
+
this.ref.onDelete = X((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = X((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
2941
2952
|
}
|
|
2942
|
-
const p = St(
|
|
2953
|
+
const p = St(n);
|
|
2943
2954
|
return this.ref.endpoints = [
|
|
2944
2955
|
{
|
|
2945
|
-
...pt(
|
|
2956
|
+
...pt(s, this.container),
|
|
2946
2957
|
relation: p[0],
|
|
2947
|
-
token: k(
|
|
2958
|
+
token: k(s)
|
|
2948
2959
|
},
|
|
2949
2960
|
{
|
|
2950
2961
|
...pt(i, this.container),
|
|
2951
2962
|
relation: p[1],
|
|
2952
2963
|
token: k(i)
|
|
2953
2964
|
}
|
|
2954
|
-
], this.env.refIds[
|
|
2965
|
+
], this.env.refIds[c] = this.declarationNode, [];
|
|
2955
2966
|
}
|
|
2956
2967
|
}
|
|
2957
|
-
class
|
|
2958
|
-
constructor(e,
|
|
2959
|
-
this.declarationNode = e, this.env =
|
|
2968
|
+
class Pt {
|
|
2969
|
+
constructor(e, n) {
|
|
2970
|
+
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2960
2971
|
}
|
|
2961
2972
|
interpret() {
|
|
2962
2973
|
this.table.token = k(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
|
|
@@ -2967,7 +2978,7 @@ class Rt {
|
|
|
2967
2978
|
...this.interpretBody(this.declarationNode.body)
|
|
2968
2979
|
];
|
|
2969
2980
|
return this.pkColumns.length >= 2 && (this.table.indexes.push({
|
|
2970
|
-
columns: this.pkColumns.map(({ name:
|
|
2981
|
+
columns: this.pkColumns.map(({ name: n }) => ({ value: n, type: "column" })),
|
|
2971
2982
|
token: {
|
|
2972
2983
|
start: { offset: -1, line: -1, column: -1 },
|
|
2973
2984
|
// do not make sense to have a meaningful start (?)
|
|
@@ -2975,219 +2986,219 @@ class Rt {
|
|
|
2975
2986
|
// do not make sense to have a meaningful end (?)
|
|
2976
2987
|
},
|
|
2977
2988
|
pk: !0
|
|
2978
|
-
}), this.pkColumns.forEach((
|
|
2989
|
+
}), this.pkColumns.forEach((n) => n.pk = !1)), e;
|
|
2979
2990
|
}
|
|
2980
2991
|
interpretName(e) {
|
|
2981
|
-
const { name:
|
|
2982
|
-
return
|
|
2992
|
+
const { name: n, schemaName: s } = Ne(e);
|
|
2993
|
+
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, []);
|
|
2983
2994
|
}
|
|
2984
2995
|
interpretAlias(e) {
|
|
2985
2996
|
if (!e)
|
|
2986
2997
|
return [];
|
|
2987
|
-
const
|
|
2988
|
-
return
|
|
2989
|
-
name:
|
|
2998
|
+
const n = G(e).unwrap_or(null);
|
|
2999
|
+
return n && (this.env.aliases.push({
|
|
3000
|
+
name: n,
|
|
2990
3001
|
kind: "table",
|
|
2991
3002
|
value: {
|
|
2992
3003
|
tableName: this.table.name,
|
|
2993
3004
|
schemaName: this.table.schemaName
|
|
2994
3005
|
}
|
|
2995
|
-
}), this.table.alias =
|
|
3006
|
+
}), this.table.alias = n), [];
|
|
2996
3007
|
}
|
|
2997
3008
|
interpretSettingList(e) {
|
|
2998
|
-
var r, a,
|
|
2999
|
-
const
|
|
3000
|
-
this.table.headerColor = (r =
|
|
3001
|
-
const [
|
|
3002
|
-
return this.table.note =
|
|
3009
|
+
var r, a, c;
|
|
3010
|
+
const n = $(e).getValue();
|
|
3011
|
+
this.table.headerColor = (r = n.headercolor) != null && r.length ? Ot((c = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : c.value) : void 0;
|
|
3012
|
+
const [s] = n.note || [], i = z(s == null ? void 0 : s.value).unwrap_or(void 0);
|
|
3013
|
+
return this.table.note = s && {
|
|
3003
3014
|
value: i,
|
|
3004
|
-
token: k(
|
|
3015
|
+
token: k(s)
|
|
3005
3016
|
}, [];
|
|
3006
3017
|
}
|
|
3007
3018
|
interpretBody(e) {
|
|
3008
|
-
const [
|
|
3009
|
-
return [...this.interpretFields(
|
|
3019
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
3020
|
+
return [...this.interpretFields(n), ...this.interpretSubElements(s)];
|
|
3010
3021
|
}
|
|
3011
3022
|
interpretSubElements(e) {
|
|
3012
|
-
return e.flatMap((
|
|
3013
|
-
var
|
|
3014
|
-
switch ((
|
|
3023
|
+
return e.flatMap((n) => {
|
|
3024
|
+
var s;
|
|
3025
|
+
switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
|
|
3015
3026
|
case "note":
|
|
3016
3027
|
return this.table.note = {
|
|
3017
|
-
value:
|
|
3018
|
-
token: k(
|
|
3028
|
+
value: z(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
|
|
3029
|
+
token: k(n)
|
|
3019
3030
|
}, [];
|
|
3020
3031
|
case "indexes":
|
|
3021
|
-
return this.interpretIndexes(
|
|
3032
|
+
return this.interpretIndexes(n);
|
|
3022
3033
|
case "ref":
|
|
3023
|
-
return new Ke(
|
|
3034
|
+
return new Ke(n, this.env).interpret();
|
|
3024
3035
|
}
|
|
3025
3036
|
return [];
|
|
3026
3037
|
});
|
|
3027
3038
|
}
|
|
3028
3039
|
interpretFields(e) {
|
|
3029
|
-
return e.flatMap((
|
|
3040
|
+
return e.flatMap((n) => this.interpretColumn(n));
|
|
3030
3041
|
}
|
|
3031
3042
|
interpretColumn(e) {
|
|
3032
|
-
var a,
|
|
3033
|
-
const
|
|
3034
|
-
|
|
3035
|
-
const i =
|
|
3036
|
-
|
|
3043
|
+
var a, c, p, h, T, f, N, g;
|
|
3044
|
+
const n = [], s = {};
|
|
3045
|
+
s.name = G(e.callee).unwrap();
|
|
3046
|
+
const i = jn(e.args[0]);
|
|
3047
|
+
s.type = i.getValue(), n.push(...i.getErrors()), s.token = k(e), s.inline_refs = [];
|
|
3037
3048
|
const r = e.args.slice(1);
|
|
3038
3049
|
if (I.last(r) instanceof U) {
|
|
3039
|
-
const
|
|
3040
|
-
|
|
3041
|
-
const
|
|
3042
|
-
|
|
3043
|
-
value:
|
|
3044
|
-
token: k(
|
|
3050
|
+
const w = $(r.pop()).getValue();
|
|
3051
|
+
s.pk = !!((a = w.pk) != null && a.length) || !!((c = w["primary key"]) != null && c.length), s.increment = !!((p = w.increment) != null && p.length), s.unique = !!((h = w.unique) != null && h.length), s.not_null = !!((T = w["not null"]) != null && T.length) && !0, s.dbdefault = Yn((N = (f = w.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3052
|
+
const me = (g = w.note) == null ? void 0 : g.at(0);
|
|
3053
|
+
s.note = me && {
|
|
3054
|
+
value: z(me.value).unwrap(),
|
|
3055
|
+
token: k(me)
|
|
3045
3056
|
};
|
|
3046
|
-
const
|
|
3047
|
-
|
|
3048
|
-
const [nt] = Ce(
|
|
3049
|
-
if (
|
|
3050
|
-
return
|
|
3051
|
-
const ve =
|
|
3052
|
-
let
|
|
3057
|
+
const Te = w.ref || [];
|
|
3058
|
+
s.inline_refs = Te.flatMap((Y) => {
|
|
3059
|
+
const [nt] = Ce(Y.value.expression);
|
|
3060
|
+
if (Rt(nt, e.symbol))
|
|
3061
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
|
|
3062
|
+
const ve = Y.value.op, Z = C(Y.value.expression).unwrap();
|
|
3063
|
+
let le;
|
|
3053
3064
|
if (Z.length === 1) {
|
|
3054
3065
|
const [ae] = Z;
|
|
3055
|
-
|
|
3066
|
+
le = {
|
|
3056
3067
|
schemaName: this.table.schemaName,
|
|
3057
3068
|
tableName: this.table.name,
|
|
3058
3069
|
fieldNames: [ae],
|
|
3059
3070
|
relation: ve.value,
|
|
3060
|
-
token: k(
|
|
3071
|
+
token: k(Y)
|
|
3061
3072
|
};
|
|
3062
3073
|
} else if (Z.length === 2) {
|
|
3063
|
-
const [ae,
|
|
3064
|
-
|
|
3074
|
+
const [ae, be] = Z;
|
|
3075
|
+
le = {
|
|
3065
3076
|
schemaName: null,
|
|
3066
3077
|
tableName: ae,
|
|
3067
|
-
fieldNames: [
|
|
3078
|
+
fieldNames: [be],
|
|
3068
3079
|
relation: ve.value,
|
|
3069
|
-
token: k(
|
|
3080
|
+
token: k(Y)
|
|
3070
3081
|
};
|
|
3071
3082
|
} else if (Z.length === 3) {
|
|
3072
|
-
const [ae,
|
|
3073
|
-
|
|
3083
|
+
const [ae, be, it] = Z;
|
|
3084
|
+
le = {
|
|
3074
3085
|
schemaName: ae,
|
|
3075
|
-
tableName:
|
|
3086
|
+
tableName: be,
|
|
3076
3087
|
fieldNames: [it],
|
|
3077
3088
|
relation: ve.value,
|
|
3078
|
-
token: k(
|
|
3089
|
+
token: k(Y)
|
|
3079
3090
|
};
|
|
3080
3091
|
} else {
|
|
3081
|
-
|
|
3082
|
-
const ae = Z.pop(),
|
|
3083
|
-
|
|
3092
|
+
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", Y));
|
|
3093
|
+
const ae = Z.pop(), be = Z.pop();
|
|
3094
|
+
le = {
|
|
3084
3095
|
schemaName: Z.join("."),
|
|
3085
|
-
tableName:
|
|
3096
|
+
tableName: be,
|
|
3086
3097
|
fieldNames: [ae],
|
|
3087
3098
|
relation: ve.value,
|
|
3088
|
-
token: k(
|
|
3099
|
+
token: k(Y)
|
|
3089
3100
|
};
|
|
3090
3101
|
}
|
|
3091
|
-
const st = this.registerInlineRefToEnv(e, nt,
|
|
3092
|
-
return
|
|
3102
|
+
const st = this.registerInlineRefToEnv(e, nt, le, Y);
|
|
3103
|
+
return n.push(...st), st.length === 0 ? le : [];
|
|
3093
3104
|
});
|
|
3094
3105
|
}
|
|
3095
|
-
return
|
|
3106
|
+
return s.pk || (s.pk = r.some((w) => X(w).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((w) => X(w).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
|
|
3096
3107
|
}
|
|
3097
3108
|
interpretIndexes(e) {
|
|
3098
|
-
return this.table.indexes.push(...e.body.body.map((
|
|
3099
|
-
var a,
|
|
3100
|
-
const
|
|
3101
|
-
|
|
3109
|
+
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3110
|
+
var a, c, p, h, T, f, N;
|
|
3111
|
+
const s = { columns: [] }, i = n;
|
|
3112
|
+
s.token = k(e);
|
|
3102
3113
|
const r = [i.callee, ...i.args];
|
|
3103
3114
|
if (I.last(r) instanceof U) {
|
|
3104
|
-
const g =
|
|
3105
|
-
|
|
3106
|
-
const
|
|
3107
|
-
|
|
3108
|
-
value:
|
|
3109
|
-
token: k(
|
|
3110
|
-
},
|
|
3115
|
+
const g = $(r.pop()).getValue();
|
|
3116
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3117
|
+
const w = (T = g.note) == null ? void 0 : T.at(0);
|
|
3118
|
+
s.note = w && {
|
|
3119
|
+
value: z(w.value).unwrap(),
|
|
3120
|
+
token: k(w)
|
|
3121
|
+
}, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3111
3122
|
}
|
|
3112
3123
|
return r.flatMap((g) => {
|
|
3113
3124
|
if (!(g instanceof H))
|
|
3114
3125
|
return g;
|
|
3115
|
-
const
|
|
3126
|
+
const w = [];
|
|
3116
3127
|
for (; g instanceof H; )
|
|
3117
|
-
|
|
3118
|
-
return
|
|
3128
|
+
w.push(g.argumentList), g = g.callee;
|
|
3129
|
+
return w.push(g), w;
|
|
3119
3130
|
}).forEach((g) => {
|
|
3120
|
-
const { functional:
|
|
3121
|
-
|
|
3122
|
-
...
|
|
3123
|
-
value:
|
|
3131
|
+
const { functional: w, nonFunctional: me } = Ge(g).unwrap();
|
|
3132
|
+
s.columns.push(
|
|
3133
|
+
...w.map((Te) => ({
|
|
3134
|
+
value: Te.value.value,
|
|
3124
3135
|
type: "expression"
|
|
3125
3136
|
})),
|
|
3126
|
-
...
|
|
3127
|
-
value:
|
|
3137
|
+
...me.map((Te) => ({
|
|
3138
|
+
value: G(Te).unwrap(),
|
|
3128
3139
|
type: "column"
|
|
3129
3140
|
}))
|
|
3130
3141
|
);
|
|
3131
|
-
}),
|
|
3142
|
+
}), s;
|
|
3132
3143
|
})), [];
|
|
3133
3144
|
}
|
|
3134
|
-
registerInlineRefToEnv(e,
|
|
3135
|
-
const r =
|
|
3145
|
+
registerInlineRefToEnv(e, n, s, i) {
|
|
3146
|
+
const r = Dt(e.symbol, n);
|
|
3136
3147
|
if (this.env.refIds[r])
|
|
3137
3148
|
return [
|
|
3138
|
-
new
|
|
3139
|
-
new
|
|
3149
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3150
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3140
3151
|
];
|
|
3141
|
-
const a = St(
|
|
3152
|
+
const a = St(s.relation);
|
|
3142
3153
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
3143
3154
|
name: null,
|
|
3144
3155
|
schemaName: null,
|
|
3145
|
-
token:
|
|
3156
|
+
token: s.token,
|
|
3146
3157
|
endpoints: [
|
|
3147
3158
|
{
|
|
3148
3159
|
schemaName: this.table.schemaName,
|
|
3149
3160
|
tableName: this.table.name,
|
|
3150
|
-
fieldNames: [
|
|
3161
|
+
fieldNames: [X(e.callee).unwrap()],
|
|
3151
3162
|
token: k(e),
|
|
3152
3163
|
relation: a[0]
|
|
3153
3164
|
},
|
|
3154
3165
|
{
|
|
3155
|
-
...
|
|
3166
|
+
...s,
|
|
3156
3167
|
relation: a[1]
|
|
3157
3168
|
}
|
|
3158
3169
|
]
|
|
3159
3170
|
}), [];
|
|
3160
3171
|
}
|
|
3161
3172
|
}
|
|
3162
|
-
function
|
|
3173
|
+
function jn(t) {
|
|
3163
3174
|
let e = null;
|
|
3164
|
-
t instanceof H && (e = t.argumentList.elementList.map((r) =>
|
|
3165
|
-
let
|
|
3175
|
+
t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3176
|
+
let n = "";
|
|
3166
3177
|
for (; t instanceof he; )
|
|
3167
|
-
|
|
3168
|
-
const { name:
|
|
3169
|
-
return i.length > 1 && new
|
|
3178
|
+
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3179
|
+
const { name: s, schemaName: i } = Ne(t);
|
|
3180
|
+
return i.length > 1 && new B(
|
|
3170
3181
|
{
|
|
3171
3182
|
schemaName: i.length === 0 ? null : i[0],
|
|
3172
|
-
type_name: `${
|
|
3183
|
+
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3173
3184
|
args: e
|
|
3174
3185
|
},
|
|
3175
|
-
[new
|
|
3176
|
-
), new
|
|
3186
|
+
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3187
|
+
), new B({
|
|
3177
3188
|
schemaName: i.length === 0 ? null : i[0],
|
|
3178
|
-
type_name: `${
|
|
3189
|
+
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3179
3190
|
args: e
|
|
3180
3191
|
});
|
|
3181
3192
|
}
|
|
3182
|
-
function
|
|
3183
|
-
var e,
|
|
3193
|
+
function Yn(t) {
|
|
3194
|
+
var e, n, s;
|
|
3184
3195
|
if (t) {
|
|
3185
|
-
if (
|
|
3196
|
+
if (j(t))
|
|
3186
3197
|
return {
|
|
3187
|
-
value:
|
|
3198
|
+
value: z(t).unwrap(),
|
|
3188
3199
|
type: "string"
|
|
3189
3200
|
};
|
|
3190
|
-
if (
|
|
3201
|
+
if (ce(t))
|
|
3191
3202
|
return {
|
|
3192
3203
|
type: "number",
|
|
3193
3204
|
value: Number.parseFloat(t.expression.literal.value)
|
|
@@ -3197,65 +3208,96 @@ function jn(t) {
|
|
|
3197
3208
|
value: t.expression.variable.value.toLowerCase(),
|
|
3198
3209
|
type: "boolean"
|
|
3199
3210
|
};
|
|
3200
|
-
if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) &&
|
|
3211
|
+
if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression)) {
|
|
3201
3212
|
const i = Number.parseFloat(t.expression.expression.literal.value);
|
|
3202
3213
|
return {
|
|
3203
|
-
value: ((
|
|
3214
|
+
value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
|
|
3204
3215
|
type: "number"
|
|
3205
3216
|
};
|
|
3206
3217
|
}
|
|
3207
3218
|
if (t instanceof K)
|
|
3208
3219
|
return {
|
|
3209
|
-
value: (
|
|
3220
|
+
value: (s = t.value) == null ? void 0 : s.value,
|
|
3210
3221
|
type: "expression"
|
|
3211
3222
|
};
|
|
3212
3223
|
throw new Error("Unreachable");
|
|
3213
3224
|
}
|
|
3214
3225
|
}
|
|
3215
|
-
class
|
|
3216
|
-
constructor(e,
|
|
3217
|
-
this.declarationNode = e, this.env =
|
|
3226
|
+
class zn {
|
|
3227
|
+
constructor(e, n) {
|
|
3228
|
+
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3229
|
+
}
|
|
3230
|
+
interpret() {
|
|
3231
|
+
return this.note.token = k(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
|
|
3232
|
+
...this.interpretName(this.declarationNode.name),
|
|
3233
|
+
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3234
|
+
...this.interpretBody(this.declarationNode.body)
|
|
3235
|
+
];
|
|
3236
|
+
}
|
|
3237
|
+
interpretName(e) {
|
|
3238
|
+
const { name: n } = Ne(e);
|
|
3239
|
+
return this.note.name = n, [];
|
|
3240
|
+
}
|
|
3241
|
+
interpretSettingList(e) {
|
|
3242
|
+
var s, i, r;
|
|
3243
|
+
const n = $(e).getValue();
|
|
3244
|
+
return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ot((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
|
|
3245
|
+
}
|
|
3246
|
+
interpretBody(e) {
|
|
3247
|
+
const [n, s] = I.partition(e.body, (i) => i instanceof v);
|
|
3248
|
+
return n.length !== 1 || s.length > 0 ? [
|
|
3249
|
+
new l(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3250
|
+
] : [...this.interpretNote(n[0])];
|
|
3251
|
+
}
|
|
3252
|
+
interpretNote(e) {
|
|
3253
|
+
const n = I.get(e, "callee.expression.literal.value", "");
|
|
3254
|
+
return this.note.content = n, [];
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
class Ut {
|
|
3258
|
+
constructor(e, n) {
|
|
3259
|
+
this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
|
|
3218
3260
|
}
|
|
3219
3261
|
interpret() {
|
|
3220
3262
|
const e = [];
|
|
3221
3263
|
this.tableGroup.token = k(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
|
|
3222
|
-
const { name:
|
|
3223
|
-
return
|
|
3224
|
-
const r =
|
|
3225
|
-
return r.length > 2 && e.push(new
|
|
3264
|
+
const { name: n, schemaName: s } = Ne(this.declarationNode.name);
|
|
3265
|
+
return s.length >= 2 && (this.tableGroup.name = n, this.tableGroup.schemaName = s.join("."), e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = n, this.tableGroup.schemaName = s[0] || null, this.tableGroup.tables = this.declarationNode.body.body.map((i) => {
|
|
3266
|
+
const r = C(i.callee).unwrap();
|
|
3267
|
+
return r.length > 2 && e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", i)), {
|
|
3226
3268
|
name: r.pop(),
|
|
3227
3269
|
schemaName: r.join(".")
|
|
3228
3270
|
};
|
|
3229
3271
|
}), e;
|
|
3230
3272
|
}
|
|
3231
3273
|
}
|
|
3232
|
-
class
|
|
3233
|
-
constructor(e,
|
|
3234
|
-
this.declarationNode = e, this.env =
|
|
3274
|
+
class Mt {
|
|
3275
|
+
constructor(e, n) {
|
|
3276
|
+
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3235
3277
|
}
|
|
3236
3278
|
interpret() {
|
|
3237
3279
|
return this.enum.token = k(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3238
3280
|
}
|
|
3239
3281
|
interpretName(e) {
|
|
3240
|
-
const { name:
|
|
3241
|
-
return
|
|
3282
|
+
const { name: n, schemaName: s } = Ne(e);
|
|
3283
|
+
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, []);
|
|
3242
3284
|
}
|
|
3243
3285
|
interpretBody(e) {
|
|
3244
|
-
return e.body.flatMap((
|
|
3245
|
-
var
|
|
3246
|
-
const
|
|
3247
|
-
i.token = k(
|
|
3248
|
-
const a = (
|
|
3286
|
+
return e.body.flatMap((n) => {
|
|
3287
|
+
var c;
|
|
3288
|
+
const s = n, i = {};
|
|
3289
|
+
i.token = k(s), i.name = X(s.callee).unwrap();
|
|
3290
|
+
const a = (c = $(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3249
3291
|
return i.note = a && {
|
|
3250
|
-
value:
|
|
3292
|
+
value: z(a.value).unwrap(),
|
|
3251
3293
|
token: k(a)
|
|
3252
3294
|
}, this.enum.values.push(i), [];
|
|
3253
3295
|
});
|
|
3254
3296
|
}
|
|
3255
3297
|
}
|
|
3256
|
-
class
|
|
3257
|
-
constructor(e,
|
|
3258
|
-
this.declarationNode = e, this.env =
|
|
3298
|
+
class Qn {
|
|
3299
|
+
constructor(e, n) {
|
|
3300
|
+
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3259
3301
|
}
|
|
3260
3302
|
interpret() {
|
|
3261
3303
|
return this.env.project.set(this.declarationNode, this.project), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
@@ -3263,46 +3305,47 @@ class Yn {
|
|
|
3263
3305
|
interpretName(e) {
|
|
3264
3306
|
if (!e)
|
|
3265
3307
|
return this.project.name = null, [];
|
|
3266
|
-
const { name:
|
|
3267
|
-
return this.project.name =
|
|
3308
|
+
const { name: n } = Ne(e);
|
|
3309
|
+
return this.project.name = n, [];
|
|
3268
3310
|
}
|
|
3269
3311
|
interpretBody(e) {
|
|
3270
|
-
return e.body.flatMap((
|
|
3312
|
+
return e.body.flatMap((n) => {
|
|
3271
3313
|
var i;
|
|
3272
|
-
const
|
|
3273
|
-
switch ((i =
|
|
3314
|
+
const s = n;
|
|
3315
|
+
switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
|
|
3274
3316
|
case "table": {
|
|
3275
|
-
const r = new
|
|
3276
|
-
return this.project.tables.push(this.env.tables.get(
|
|
3317
|
+
const r = new Pt(s, this.env).interpret();
|
|
3318
|
+
return this.project.tables.push(this.env.tables.get(s)), r;
|
|
3277
3319
|
}
|
|
3278
3320
|
case "ref": {
|
|
3279
|
-
const r = new Ke(
|
|
3280
|
-
return this.project.refs.push(this.env.ref.get(
|
|
3321
|
+
const r = new Ke(s, this.env).interpret();
|
|
3322
|
+
return this.project.refs.push(this.env.ref.get(s)), r;
|
|
3281
3323
|
}
|
|
3282
3324
|
case "tablegroup": {
|
|
3283
|
-
const r = new
|
|
3284
|
-
return this.project.tableGroups.push(this.env.tableGroups.get(
|
|
3325
|
+
const r = new Ut(s, this.env).interpret();
|
|
3326
|
+
return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
|
|
3285
3327
|
}
|
|
3286
3328
|
case "enum": {
|
|
3287
|
-
const r = new
|
|
3288
|
-
return this.project.enums.push(this.env.enums.get(
|
|
3329
|
+
const r = new Mt(s, this.env).interpret();
|
|
3330
|
+
return this.project.enums.push(this.env.enums.get(s)), r;
|
|
3289
3331
|
}
|
|
3290
3332
|
case "note":
|
|
3291
3333
|
return this.project.note = {
|
|
3292
|
-
value:
|
|
3293
|
-
token: k(
|
|
3334
|
+
value: z(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
|
|
3335
|
+
token: k(s)
|
|
3294
3336
|
}, [];
|
|
3295
3337
|
default:
|
|
3296
|
-
return this.project[
|
|
3338
|
+
return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
|
|
3297
3339
|
}
|
|
3298
3340
|
});
|
|
3299
3341
|
}
|
|
3300
3342
|
}
|
|
3301
|
-
class
|
|
3343
|
+
class qn {
|
|
3302
3344
|
constructor(e) {
|
|
3303
3345
|
this.ast = e, this.env = {
|
|
3304
3346
|
schema: [],
|
|
3305
3347
|
tables: /* @__PURE__ */ new Map(),
|
|
3348
|
+
notes: /* @__PURE__ */ new Map(),
|
|
3306
3349
|
refIds: {},
|
|
3307
3350
|
ref: /* @__PURE__ */ new Map(),
|
|
3308
3351
|
enums: /* @__PURE__ */ new Map(),
|
|
@@ -3312,29 +3355,32 @@ class zn {
|
|
|
3312
3355
|
};
|
|
3313
3356
|
}
|
|
3314
3357
|
interpret() {
|
|
3315
|
-
const e = this.ast.body.flatMap((
|
|
3316
|
-
switch (de(
|
|
3358
|
+
const e = this.ast.body.flatMap((n) => {
|
|
3359
|
+
switch (de(n).unwrap_or(void 0)) {
|
|
3317
3360
|
case b.Table:
|
|
3318
|
-
return new
|
|
3361
|
+
return new Pt(n, this.env).interpret();
|
|
3362
|
+
case b.Note:
|
|
3363
|
+
return new zn(n, this.env).interpret();
|
|
3319
3364
|
case b.Ref:
|
|
3320
|
-
return new Ke(
|
|
3365
|
+
return new Ke(n, this.env).interpret();
|
|
3321
3366
|
case b.TableGroup:
|
|
3322
|
-
return new
|
|
3367
|
+
return new Ut(n, this.env).interpret();
|
|
3323
3368
|
case b.Enum:
|
|
3324
|
-
return new
|
|
3369
|
+
return new Mt(n, this.env).interpret();
|
|
3325
3370
|
case b.Project:
|
|
3326
|
-
return new
|
|
3371
|
+
return new Qn(n, this.env).interpret();
|
|
3327
3372
|
default:
|
|
3328
3373
|
return [];
|
|
3329
3374
|
}
|
|
3330
3375
|
});
|
|
3331
|
-
return new
|
|
3376
|
+
return new B(Hn(this.env), e);
|
|
3332
3377
|
}
|
|
3333
3378
|
}
|
|
3334
|
-
function
|
|
3379
|
+
function Hn(t) {
|
|
3335
3380
|
return {
|
|
3336
3381
|
schemas: [],
|
|
3337
3382
|
tables: Array.from(t.tables.values()),
|
|
3383
|
+
notes: Array.from(t.notes.values()),
|
|
3338
3384
|
refs: Array.from(t.ref.values()),
|
|
3339
3385
|
enums: Array.from(t.enums.values()),
|
|
3340
3386
|
tableGroups: Array.from(t.tableGroups.values()),
|
|
@@ -3342,8 +3388,8 @@ function Qn(t) {
|
|
|
3342
3388
|
project: Array.from(t.project.values())[0] || {}
|
|
3343
3389
|
};
|
|
3344
3390
|
}
|
|
3345
|
-
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}),
|
|
3346
|
-
function
|
|
3391
|
+
var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
|
|
3392
|
+
function _e(t) {
|
|
3347
3393
|
switch (t) {
|
|
3348
3394
|
case m.Schema:
|
|
3349
3395
|
return L.Module;
|
|
@@ -3366,10 +3412,10 @@ function ge(t) {
|
|
|
3366
3412
|
function Se(t, e) {
|
|
3367
3413
|
if (!t || Ve(t))
|
|
3368
3414
|
return !1;
|
|
3369
|
-
for (const
|
|
3370
|
-
if (
|
|
3415
|
+
for (const n of t.trailingTrivia) {
|
|
3416
|
+
if (n.start > e)
|
|
3371
3417
|
break;
|
|
3372
|
-
if (
|
|
3418
|
+
if (n.kind === u.NEWLINE && n.end <= e)
|
|
3373
3419
|
return !1;
|
|
3374
3420
|
}
|
|
3375
3421
|
return !0;
|
|
@@ -3400,27 +3446,27 @@ function Ue(t) {
|
|
|
3400
3446
|
function et(t, e) {
|
|
3401
3447
|
return t.getOffsetAt(e);
|
|
3402
3448
|
}
|
|
3403
|
-
class
|
|
3404
|
-
constructor(e,
|
|
3405
|
-
this.compiler = e, this.triggerCharacters =
|
|
3449
|
+
class Ft {
|
|
3450
|
+
constructor(e, n = []) {
|
|
3451
|
+
this.compiler = e, this.triggerCharacters = n;
|
|
3406
3452
|
}
|
|
3407
|
-
provideCompletionItems(e,
|
|
3453
|
+
provideCompletionItems(e, n) {
|
|
3408
3454
|
var T, f;
|
|
3409
|
-
const
|
|
3455
|
+
const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), c = a === void 0 ? i[0] : i[a + 1];
|
|
3410
3456
|
if ([
|
|
3411
3457
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3412
3458
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3413
|
-
...(
|
|
3414
|
-
].find((N) =>
|
|
3459
|
+
...(c == null ? void 0 : c.leadingTrivia) || []
|
|
3460
|
+
].find((N) => Wt(N) && Le(s, N)))
|
|
3415
3461
|
return O();
|
|
3416
3462
|
if (a === void 0)
|
|
3417
3463
|
return Tt();
|
|
3418
|
-
if ([
|
|
3464
|
+
if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
|
|
3419
3465
|
return O();
|
|
3420
|
-
const p = this.compiler.container.element(
|
|
3421
|
-
if (this.compiler.container.scopeKind(
|
|
3466
|
+
const p = this.compiler.container.element(s);
|
|
3467
|
+
if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
|
|
3422
3468
|
return Tt();
|
|
3423
|
-
const h = [...this.compiler.container.stack(
|
|
3469
|
+
const h = [...this.compiler.container.stack(s)].reverse();
|
|
3424
3470
|
for (const N of h)
|
|
3425
3471
|
if (N instanceof Q)
|
|
3426
3472
|
switch ((T = N.op) == null ? void 0 : T.value) {
|
|
@@ -3430,7 +3476,7 @@ class Mt {
|
|
|
3430
3476
|
case "-":
|
|
3431
3477
|
return dt(
|
|
3432
3478
|
this.compiler,
|
|
3433
|
-
|
|
3479
|
+
s,
|
|
3434
3480
|
N
|
|
3435
3481
|
);
|
|
3436
3482
|
}
|
|
@@ -3442,59 +3488,59 @@ class Mt {
|
|
|
3442
3488
|
case "-":
|
|
3443
3489
|
return dt(
|
|
3444
3490
|
this.compiler,
|
|
3445
|
-
|
|
3491
|
+
s,
|
|
3446
3492
|
N
|
|
3447
3493
|
);
|
|
3448
3494
|
case ".":
|
|
3449
|
-
return
|
|
3495
|
+
return Bt(
|
|
3450
3496
|
this.compiler,
|
|
3451
|
-
|
|
3497
|
+
s,
|
|
3452
3498
|
N
|
|
3453
3499
|
);
|
|
3454
3500
|
}
|
|
3455
3501
|
else {
|
|
3456
3502
|
if (N instanceof ne)
|
|
3457
|
-
return Et(this.compiler,
|
|
3503
|
+
return Et(this.compiler, s, N);
|
|
3458
3504
|
if (N instanceof U)
|
|
3459
|
-
return Et(this.compiler,
|
|
3505
|
+
return Et(this.compiler, s, N);
|
|
3460
3506
|
if (N instanceof J)
|
|
3461
|
-
return
|
|
3462
|
-
if (N instanceof
|
|
3463
|
-
return mt(this.compiler,
|
|
3464
|
-
if (N instanceof _ && (N.bodyColon &&
|
|
3465
|
-
return mt(this.compiler,
|
|
3507
|
+
return Jn(this.compiler, s);
|
|
3508
|
+
if (N instanceof v)
|
|
3509
|
+
return mt(this.compiler, s, N);
|
|
3510
|
+
if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
|
|
3511
|
+
return mt(this.compiler, s, void 0);
|
|
3466
3512
|
}
|
|
3467
3513
|
return O();
|
|
3468
3514
|
}
|
|
3469
3515
|
}
|
|
3470
|
-
function dt(t, e,
|
|
3471
|
-
const
|
|
3472
|
-
if ([D.REF, D.TABLE].includes(
|
|
3516
|
+
function dt(t, e, n) {
|
|
3517
|
+
const s = t.container.scopeKind(e);
|
|
3518
|
+
if ([D.REF, D.TABLE].includes(s)) {
|
|
3473
3519
|
const i = Me(t, e, t.container.element(e), [
|
|
3474
3520
|
m.Table,
|
|
3475
3521
|
m.Schema,
|
|
3476
3522
|
m.Column
|
|
3477
3523
|
]);
|
|
3478
|
-
return Se(
|
|
3524
|
+
return Se(n.op, e) ? Oe(i) : i;
|
|
3479
3525
|
}
|
|
3480
3526
|
return O();
|
|
3481
3527
|
}
|
|
3482
|
-
function Me(t, e,
|
|
3528
|
+
function Me(t, e, n, s) {
|
|
3483
3529
|
var a;
|
|
3484
|
-
if (
|
|
3530
|
+
if (n === void 0)
|
|
3485
3531
|
return O();
|
|
3486
|
-
let i =
|
|
3532
|
+
let i = n;
|
|
3487
3533
|
const r = { suggestions: [] };
|
|
3488
3534
|
for (; i; ) {
|
|
3489
3535
|
if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
|
|
3490
|
-
const { symbol:
|
|
3536
|
+
const { symbol: c } = i;
|
|
3491
3537
|
r.suggestions.push(
|
|
3492
|
-
...t.symbol.members(
|
|
3538
|
+
...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
|
|
3493
3539
|
label: p,
|
|
3494
3540
|
insertText: p,
|
|
3495
|
-
insertTextRules:
|
|
3496
|
-
kind:
|
|
3497
|
-
sortText:
|
|
3541
|
+
insertTextRules: y.KeepWhitespace,
|
|
3542
|
+
kind: _e(h),
|
|
3543
|
+
sortText: _e(h).toString().padStart(2, "0"),
|
|
3498
3544
|
range: void 0
|
|
3499
3545
|
}))
|
|
3500
3546
|
);
|
|
@@ -3503,52 +3549,52 @@ function Me(t, e, s, n) {
|
|
|
3503
3549
|
}
|
|
3504
3550
|
return Ue(r);
|
|
3505
3551
|
}
|
|
3506
|
-
function
|
|
3507
|
-
var
|
|
3552
|
+
function Jn(t, e) {
|
|
3553
|
+
var s;
|
|
3508
3554
|
switch (t.container.scopeKind(e)) {
|
|
3509
3555
|
case D.INDEXES:
|
|
3510
|
-
return
|
|
3556
|
+
return Gt(t, e);
|
|
3511
3557
|
case D.REF:
|
|
3512
3558
|
{
|
|
3513
3559
|
const i = [...t.container.stack(e)];
|
|
3514
3560
|
for (; i.length > 0; ) {
|
|
3515
3561
|
const r = i.pop();
|
|
3516
|
-
if (r instanceof q && ((
|
|
3517
|
-
return
|
|
3562
|
+
if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
|
|
3563
|
+
return Bt(
|
|
3518
3564
|
t,
|
|
3519
3565
|
e,
|
|
3520
3566
|
r
|
|
3521
3567
|
);
|
|
3522
3568
|
}
|
|
3523
3569
|
}
|
|
3524
|
-
return
|
|
3570
|
+
return Vt(t, e);
|
|
3525
3571
|
}
|
|
3526
3572
|
return O();
|
|
3527
3573
|
}
|
|
3528
|
-
function Et(t, e,
|
|
3529
|
-
const { token:
|
|
3530
|
-
if ([
|
|
3574
|
+
function Et(t, e, n) {
|
|
3575
|
+
const { token: s } = t.container.token(e);
|
|
3576
|
+
if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
|
|
3531
3577
|
const i = Nt(t, e);
|
|
3532
|
-
return (
|
|
3578
|
+
return (s == null ? void 0 : s.kind) === u.COMMA && Se(s, e) ? Oe(i) : i;
|
|
3533
3579
|
}
|
|
3534
|
-
if (
|
|
3580
|
+
if (n.name && n.name.start <= e && n.name.end >= e)
|
|
3535
3581
|
return Nt(t, e);
|
|
3536
|
-
if (
|
|
3537
|
-
const i =
|
|
3582
|
+
if (n.name) {
|
|
3583
|
+
const i = Zn(
|
|
3538
3584
|
t,
|
|
3539
3585
|
e,
|
|
3540
|
-
Re(
|
|
3586
|
+
Re(n.name).unwrap()
|
|
3541
3587
|
);
|
|
3542
|
-
return (
|
|
3588
|
+
return (s == null ? void 0 : s.kind) === u.COLON && Se(s, e) ? Oe(i) : i;
|
|
3543
3589
|
}
|
|
3544
3590
|
return O();
|
|
3545
3591
|
}
|
|
3546
3592
|
function Nt(t, e) {
|
|
3547
|
-
const
|
|
3548
|
-
if (
|
|
3593
|
+
const n = t.container.element(e), s = t.container.scopeKind(e);
|
|
3594
|
+
if (n instanceof F)
|
|
3549
3595
|
return O();
|
|
3550
|
-
if (
|
|
3551
|
-
switch (
|
|
3596
|
+
if (n.body && !Le(e, n.body))
|
|
3597
|
+
switch (s) {
|
|
3552
3598
|
case D.TABLE:
|
|
3553
3599
|
return {
|
|
3554
3600
|
suggestions: [
|
|
@@ -3556,14 +3602,14 @@ function Nt(t, e) {
|
|
|
3556
3602
|
label: "headercolor",
|
|
3557
3603
|
insertText: "headercolor: ",
|
|
3558
3604
|
kind: L.Field,
|
|
3559
|
-
insertTextRules:
|
|
3605
|
+
insertTextRules: y.KeepWhitespace,
|
|
3560
3606
|
range: void 0
|
|
3561
3607
|
},
|
|
3562
3608
|
{
|
|
3563
3609
|
label: "note",
|
|
3564
3610
|
insertText: "note: ",
|
|
3565
3611
|
kind: L.Field,
|
|
3566
|
-
insertTextRules:
|
|
3612
|
+
insertTextRules: y.KeepWhitespace,
|
|
3567
3613
|
range: void 0
|
|
3568
3614
|
}
|
|
3569
3615
|
]
|
|
@@ -3571,7 +3617,7 @@ function Nt(t, e) {
|
|
|
3571
3617
|
default:
|
|
3572
3618
|
return O();
|
|
3573
3619
|
}
|
|
3574
|
-
switch (
|
|
3620
|
+
switch (s) {
|
|
3575
3621
|
case D.TABLE:
|
|
3576
3622
|
return {
|
|
3577
3623
|
suggestions: [
|
|
@@ -3579,21 +3625,21 @@ function Nt(t, e) {
|
|
|
3579
3625
|
label: i,
|
|
3580
3626
|
insertText: i,
|
|
3581
3627
|
kind: L.Property,
|
|
3582
|
-
insertTextRules:
|
|
3628
|
+
insertTextRules: y.KeepWhitespace,
|
|
3583
3629
|
range: void 0
|
|
3584
3630
|
})),
|
|
3585
3631
|
...["ref", "default"].map((i) => ({
|
|
3586
3632
|
label: i,
|
|
3587
3633
|
insertText: `${i}: `,
|
|
3588
3634
|
kind: L.Property,
|
|
3589
|
-
insertTextRules:
|
|
3635
|
+
insertTextRules: y.KeepWhitespace,
|
|
3590
3636
|
range: void 0
|
|
3591
3637
|
})),
|
|
3592
3638
|
{
|
|
3593
3639
|
label: "note",
|
|
3594
3640
|
insertText: "note: ",
|
|
3595
3641
|
kind: L.Property,
|
|
3596
|
-
insertTextRules:
|
|
3642
|
+
insertTextRules: y.KeepWhitespace,
|
|
3597
3643
|
range: void 0
|
|
3598
3644
|
}
|
|
3599
3645
|
]
|
|
@@ -3605,7 +3651,7 @@ function Nt(t, e) {
|
|
|
3605
3651
|
label: "note",
|
|
3606
3652
|
insertText: "note: ",
|
|
3607
3653
|
kind: L.Property,
|
|
3608
|
-
insertTextRules:
|
|
3654
|
+
insertTextRules: y.KeepWhitespace,
|
|
3609
3655
|
range: void 0
|
|
3610
3656
|
}
|
|
3611
3657
|
]
|
|
@@ -3616,7 +3662,7 @@ function Nt(t, e) {
|
|
|
3616
3662
|
...["unique", "pk"].map((i) => ({
|
|
3617
3663
|
label: i,
|
|
3618
3664
|
insertText: i,
|
|
3619
|
-
insertTextRules:
|
|
3665
|
+
insertTextRules: y.KeepWhitespace,
|
|
3620
3666
|
kind: L.Property,
|
|
3621
3667
|
range: void 0
|
|
3622
3668
|
})),
|
|
@@ -3624,7 +3670,7 @@ function Nt(t, e) {
|
|
|
3624
3670
|
label: i,
|
|
3625
3671
|
insertText: `${i}: `,
|
|
3626
3672
|
kind: L.Property,
|
|
3627
|
-
insertTextRules:
|
|
3673
|
+
insertTextRules: y.KeepWhitespace,
|
|
3628
3674
|
range: void 0
|
|
3629
3675
|
}))
|
|
3630
3676
|
]
|
|
@@ -3635,70 +3681,70 @@ function Nt(t, e) {
|
|
|
3635
3681
|
label: i,
|
|
3636
3682
|
insertText: `${i}: `,
|
|
3637
3683
|
kind: L.Property,
|
|
3638
|
-
insertTextRules:
|
|
3684
|
+
insertTextRules: y.KeepWhitespace,
|
|
3639
3685
|
range: void 0
|
|
3640
3686
|
}))
|
|
3641
3687
|
};
|
|
3642
3688
|
}
|
|
3643
3689
|
return O();
|
|
3644
3690
|
}
|
|
3645
|
-
function
|
|
3646
|
-
switch (
|
|
3691
|
+
function Zn(t, e, n) {
|
|
3692
|
+
switch (n == null ? void 0 : n.toLowerCase()) {
|
|
3647
3693
|
case "update":
|
|
3648
3694
|
case "delete":
|
|
3649
3695
|
return {
|
|
3650
|
-
suggestions: ["cascade", "set default", "set null", "restrict"].map((
|
|
3651
|
-
label:
|
|
3652
|
-
insertText:
|
|
3696
|
+
suggestions: ["cascade", "set default", "set null", "restrict"].map((s) => ({
|
|
3697
|
+
label: s,
|
|
3698
|
+
insertText: s,
|
|
3653
3699
|
kind: L.Value,
|
|
3654
|
-
insertTextRules:
|
|
3700
|
+
insertTextRules: y.KeepWhitespace,
|
|
3655
3701
|
range: void 0
|
|
3656
3702
|
}))
|
|
3657
3703
|
};
|
|
3658
3704
|
case "type":
|
|
3659
3705
|
return {
|
|
3660
|
-
suggestions: ["btree", "hash"].map((
|
|
3661
|
-
label:
|
|
3662
|
-
insertText: `${
|
|
3706
|
+
suggestions: ["btree", "hash"].map((s) => ({
|
|
3707
|
+
label: s,
|
|
3708
|
+
insertText: `${s}`,
|
|
3663
3709
|
kind: L.Value,
|
|
3664
|
-
insertTextRules:
|
|
3710
|
+
insertTextRules: y.KeepWhitespace,
|
|
3665
3711
|
range: void 0
|
|
3666
3712
|
}))
|
|
3667
3713
|
};
|
|
3668
3714
|
}
|
|
3669
3715
|
return O();
|
|
3670
3716
|
}
|
|
3671
|
-
function
|
|
3672
|
-
const
|
|
3673
|
-
if (
|
|
3717
|
+
function Bt(t, e, n) {
|
|
3718
|
+
const s = Ee(n).unwrap_or([]);
|
|
3719
|
+
if (s.pop(), s.some((r) => !M(r)))
|
|
3674
3720
|
return O();
|
|
3675
|
-
const i =
|
|
3721
|
+
const i = s.map((r) => X(r).unwrap());
|
|
3676
3722
|
return Ue({
|
|
3677
3723
|
suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
|
|
3678
3724
|
label: a,
|
|
3679
3725
|
insertText: a,
|
|
3680
|
-
kind:
|
|
3726
|
+
kind: _e(r),
|
|
3681
3727
|
range: void 0
|
|
3682
3728
|
}))
|
|
3683
3729
|
});
|
|
3684
3730
|
}
|
|
3685
|
-
function mt(t, e,
|
|
3731
|
+
function mt(t, e, n) {
|
|
3686
3732
|
var i;
|
|
3687
3733
|
switch (t.container.scopeKind(e)) {
|
|
3688
3734
|
case D.TABLE:
|
|
3689
|
-
return
|
|
3735
|
+
return es(t, e, n);
|
|
3690
3736
|
case D.PROJECT:
|
|
3691
|
-
return
|
|
3737
|
+
return ts(t, e, n);
|
|
3692
3738
|
case D.INDEXES:
|
|
3693
|
-
return
|
|
3739
|
+
return ss(t, e);
|
|
3694
3740
|
case D.ENUM:
|
|
3695
|
-
return
|
|
3741
|
+
return Kn(t, e, n);
|
|
3696
3742
|
case D.REF: {
|
|
3697
|
-
const r =
|
|
3698
|
-
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) ===
|
|
3743
|
+
const r = Vt(t, e);
|
|
3744
|
+
return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
|
|
3699
3745
|
}
|
|
3700
3746
|
case D.TABLEGROUP:
|
|
3701
|
-
return
|
|
3747
|
+
return ns(t);
|
|
3702
3748
|
default:
|
|
3703
3749
|
return O();
|
|
3704
3750
|
}
|
|
@@ -3708,47 +3754,47 @@ function Tt() {
|
|
|
3708
3754
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3709
3755
|
label: t,
|
|
3710
3756
|
insertText: t,
|
|
3711
|
-
insertTextRules:
|
|
3757
|
+
insertTextRules: y.KeepWhitespace,
|
|
3712
3758
|
kind: L.Keyword,
|
|
3713
3759
|
range: void 0
|
|
3714
3760
|
}))
|
|
3715
3761
|
};
|
|
3716
3762
|
}
|
|
3717
|
-
function
|
|
3718
|
-
return
|
|
3763
|
+
function Kn(t, e, n) {
|
|
3764
|
+
return n != null && n.callee && tt(e, n) === 1 ? Me(t, e, t.container.element(e), [
|
|
3719
3765
|
m.Schema,
|
|
3720
3766
|
m.Table,
|
|
3721
3767
|
m.Column
|
|
3722
3768
|
]) : O();
|
|
3723
3769
|
}
|
|
3724
|
-
function
|
|
3725
|
-
if (!(
|
|
3770
|
+
function es(t, e, n) {
|
|
3771
|
+
if (!(n != null && n.callee))
|
|
3726
3772
|
return {
|
|
3727
3773
|
suggestions: ["Ref", "Note", "indexes"].map((i) => ({
|
|
3728
3774
|
label: i,
|
|
3729
3775
|
insertText: i,
|
|
3730
|
-
insertTextRules:
|
|
3776
|
+
insertTextRules: y.KeepWhitespace,
|
|
3731
3777
|
kind: L.Keyword,
|
|
3732
3778
|
range: void 0
|
|
3733
3779
|
}))
|
|
3734
3780
|
};
|
|
3735
|
-
const
|
|
3736
|
-
return
|
|
3781
|
+
const s = tt(e, n);
|
|
3782
|
+
return s === 0 ? {
|
|
3737
3783
|
suggestions: ["Ref", "Note", "indexes"].map((i) => ({
|
|
3738
3784
|
label: i,
|
|
3739
3785
|
insertText: i,
|
|
3740
|
-
insertTextRules:
|
|
3786
|
+
insertTextRules: y.KeepWhitespace,
|
|
3741
3787
|
kind: L.Keyword,
|
|
3742
3788
|
range: void 0
|
|
3743
3789
|
}))
|
|
3744
|
-
} :
|
|
3790
|
+
} : s === 1 ? is(t, e) : O();
|
|
3745
3791
|
}
|
|
3746
|
-
function
|
|
3747
|
-
return
|
|
3792
|
+
function ts(t, e, n) {
|
|
3793
|
+
return n != null && n.callee ? tt(e, n) === 0 ? {
|
|
3748
3794
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3749
3795
|
label: i,
|
|
3750
3796
|
insertText: i,
|
|
3751
|
-
insertTextRules:
|
|
3797
|
+
insertTextRules: y.KeepWhitespace,
|
|
3752
3798
|
kind: L.Keyword,
|
|
3753
3799
|
range: void 0
|
|
3754
3800
|
}))
|
|
@@ -3756,40 +3802,40 @@ function Kn(t, e, s) {
|
|
|
3756
3802
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3757
3803
|
label: i,
|
|
3758
3804
|
insertText: i,
|
|
3759
|
-
insertTextRules:
|
|
3805
|
+
insertTextRules: y.KeepWhitespace,
|
|
3760
3806
|
kind: L.Keyword,
|
|
3761
3807
|
range: void 0
|
|
3762
3808
|
}))
|
|
3763
3809
|
};
|
|
3764
3810
|
}
|
|
3765
|
-
function
|
|
3811
|
+
function Vt(t, e) {
|
|
3766
3812
|
return Me(t, e, t.container.element(e), [
|
|
3767
3813
|
m.Schema,
|
|
3768
3814
|
m.Table,
|
|
3769
3815
|
m.Column
|
|
3770
3816
|
]);
|
|
3771
3817
|
}
|
|
3772
|
-
function
|
|
3818
|
+
function ns(t) {
|
|
3773
3819
|
return Ue({
|
|
3774
3820
|
suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
|
|
3775
|
-
const
|
|
3776
|
-
if (
|
|
3821
|
+
const n = se(e).unwrap_or(void 0);
|
|
3822
|
+
if (n === void 0)
|
|
3777
3823
|
return [];
|
|
3778
|
-
const { kind:
|
|
3779
|
-
return
|
|
3824
|
+
const { kind: s, name: i } = n;
|
|
3825
|
+
return s !== m.Table && s !== m.Schema ? [] : {
|
|
3780
3826
|
label: i,
|
|
3781
3827
|
insertText: i,
|
|
3782
|
-
insertTextRules:
|
|
3783
|
-
kind:
|
|
3828
|
+
insertTextRules: y.KeepWhitespace,
|
|
3829
|
+
kind: _e(s),
|
|
3784
3830
|
range: void 0
|
|
3785
3831
|
};
|
|
3786
3832
|
})
|
|
3787
3833
|
});
|
|
3788
3834
|
}
|
|
3789
|
-
function
|
|
3790
|
-
return
|
|
3835
|
+
function ss(t, e) {
|
|
3836
|
+
return Gt(t, e);
|
|
3791
3837
|
}
|
|
3792
|
-
function
|
|
3838
|
+
function is(t, e) {
|
|
3793
3839
|
return {
|
|
3794
3840
|
suggestions: [
|
|
3795
3841
|
...[
|
|
@@ -3849,10 +3895,10 @@ function ns(t, e) {
|
|
|
3849
3895
|
"CLOB",
|
|
3850
3896
|
"NCLOB",
|
|
3851
3897
|
"RAW"
|
|
3852
|
-
].map((
|
|
3853
|
-
label:
|
|
3854
|
-
insertText:
|
|
3855
|
-
insertTextRules:
|
|
3898
|
+
].map((n) => ({
|
|
3899
|
+
label: n,
|
|
3900
|
+
insertText: n,
|
|
3901
|
+
insertTextRules: y.KeepWhitespace,
|
|
3856
3902
|
kind: L.TypeParameter,
|
|
3857
3903
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3858
3904
|
range: void 0
|
|
@@ -3864,22 +3910,22 @@ function ns(t, e) {
|
|
|
3864
3910
|
]
|
|
3865
3911
|
};
|
|
3866
3912
|
}
|
|
3867
|
-
function
|
|
3868
|
-
const
|
|
3869
|
-
if (!((
|
|
3913
|
+
function Gt(t, e) {
|
|
3914
|
+
const s = t.container.element(e).parent;
|
|
3915
|
+
if (!((s == null ? void 0 : s.symbol) instanceof At))
|
|
3870
3916
|
return O();
|
|
3871
|
-
const { symbolTable: i } =
|
|
3917
|
+
const { symbolTable: i } = s.symbol;
|
|
3872
3918
|
return Ue({
|
|
3873
3919
|
suggestions: [...i.entries()].flatMap(([r]) => {
|
|
3874
3920
|
const a = se(r).unwrap_or(void 0);
|
|
3875
3921
|
if (a === void 0)
|
|
3876
3922
|
return [];
|
|
3877
|
-
const { name:
|
|
3923
|
+
const { name: c } = a;
|
|
3878
3924
|
return {
|
|
3879
|
-
label:
|
|
3880
|
-
insertText:
|
|
3881
|
-
insertTextRules:
|
|
3882
|
-
kind:
|
|
3925
|
+
label: c,
|
|
3926
|
+
insertText: c,
|
|
3927
|
+
insertTextRules: y.KeepWhitespace,
|
|
3928
|
+
kind: _e(m.Column),
|
|
3883
3929
|
range: void 0
|
|
3884
3930
|
};
|
|
3885
3931
|
})
|
|
@@ -3888,20 +3934,20 @@ function Vt(t, e) {
|
|
|
3888
3934
|
function tt(t, e) {
|
|
3889
3935
|
if (!e.callee)
|
|
3890
3936
|
return -1;
|
|
3891
|
-
const
|
|
3892
|
-
return
|
|
3937
|
+
const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
|
|
3938
|
+
return s === -1 ? n.length : s;
|
|
3893
3939
|
}
|
|
3894
|
-
class
|
|
3940
|
+
class Ct {
|
|
3895
3941
|
constructor(e) {
|
|
3896
3942
|
this.compiler = e;
|
|
3897
3943
|
}
|
|
3898
|
-
provideDefinition(e,
|
|
3944
|
+
provideDefinition(e, n) {
|
|
3899
3945
|
var a;
|
|
3900
|
-
const { uri:
|
|
3946
|
+
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
3901
3947
|
for (; r.length !== 0; ) {
|
|
3902
|
-
const
|
|
3903
|
-
if ((a =
|
|
3904
|
-
const { startPos: p, endPos: h } =
|
|
3948
|
+
const c = r.pop();
|
|
3949
|
+
if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [ue.PRIMARY_EXPRESSION, ue.VARIABLE].includes(c == null ? void 0 : c.kind)) {
|
|
3950
|
+
const { startPos: p, endPos: h } = c.referee.declaration;
|
|
3905
3951
|
return [
|
|
3906
3952
|
{
|
|
3907
3953
|
range: {
|
|
@@ -3910,7 +3956,7 @@ class Gt {
|
|
|
3910
3956
|
endColumn: h.column + 1,
|
|
3911
3957
|
endLineNumber: h.line + 1
|
|
3912
3958
|
},
|
|
3913
|
-
uri:
|
|
3959
|
+
uri: s
|
|
3914
3960
|
}
|
|
3915
3961
|
];
|
|
3916
3962
|
}
|
|
@@ -3918,12 +3964,12 @@ class Gt {
|
|
|
3918
3964
|
return [];
|
|
3919
3965
|
}
|
|
3920
3966
|
}
|
|
3921
|
-
class
|
|
3967
|
+
class Xt {
|
|
3922
3968
|
constructor(e) {
|
|
3923
3969
|
this.compiler = e;
|
|
3924
3970
|
}
|
|
3925
|
-
provideReferences(e,
|
|
3926
|
-
const { uri:
|
|
3971
|
+
provideReferences(e, n) {
|
|
3972
|
+
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
3927
3973
|
for (; r.length !== 0; ) {
|
|
3928
3974
|
const a = r.pop();
|
|
3929
3975
|
if (a && [
|
|
@@ -3931,37 +3977,37 @@ class Ct {
|
|
|
3931
3977
|
ue.FUNCTION_APPLICATION,
|
|
3932
3978
|
ue.PRIMARY_EXPRESSION
|
|
3933
3979
|
].includes(a == null ? void 0 : a.kind)) {
|
|
3934
|
-
const { symbol:
|
|
3935
|
-
if (
|
|
3936
|
-
return
|
|
3980
|
+
const { symbol: c } = a;
|
|
3981
|
+
if (c != null && c.references.length)
|
|
3982
|
+
return c.references.map(({ startPos: p, endPos: h }) => ({
|
|
3937
3983
|
range: {
|
|
3938
3984
|
startColumn: p.column + 1,
|
|
3939
3985
|
startLineNumber: p.line + 1,
|
|
3940
3986
|
endColumn: h.column + 1,
|
|
3941
3987
|
endLineNumber: h.line + 1
|
|
3942
3988
|
},
|
|
3943
|
-
uri:
|
|
3989
|
+
uri: s
|
|
3944
3990
|
}));
|
|
3945
3991
|
}
|
|
3946
3992
|
}
|
|
3947
3993
|
return [];
|
|
3948
3994
|
}
|
|
3949
3995
|
}
|
|
3950
|
-
const
|
|
3996
|
+
const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3951
3997
|
__proto__: null,
|
|
3952
|
-
CompletionItemInsertTextRule:
|
|
3998
|
+
CompletionItemInsertTextRule: y,
|
|
3953
3999
|
CompletionItemKind: L,
|
|
3954
|
-
DBMLCompletionItemProvider:
|
|
3955
|
-
DBMLDefinitionProvider:
|
|
3956
|
-
DBMLReferencesProvider:
|
|
4000
|
+
DBMLCompletionItemProvider: Ft,
|
|
4001
|
+
DBMLDefinitionProvider: Ct,
|
|
4002
|
+
DBMLReferencesProvider: Xt
|
|
3957
4003
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3958
4004
|
var D = /* @__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))(D || {});
|
|
3959
|
-
class
|
|
4005
|
+
class cs {
|
|
3960
4006
|
constructor() {
|
|
3961
4007
|
this.source = "", this.cache = new Array(
|
|
3962
4008
|
16
|
|
3963
4009
|
/* TOTAL_QUERY_COUNT */
|
|
3964
|
-
).fill(null), this.nodeIdGenerator = new
|
|
4010
|
+
).fill(null), this.nodeIdGenerator = new jt(), this.symbolIdGenerator = new Ht(), this.token = {
|
|
3965
4011
|
invalidStream: this.createQuery(
|
|
3966
4012
|
6,
|
|
3967
4013
|
() => this.parse.tokens().filter(vt)
|
|
@@ -3976,8 +4022,8 @@ class as {
|
|
|
3976
4022
|
_: this.createQuery(
|
|
3977
4023
|
0,
|
|
3978
4024
|
() => {
|
|
3979
|
-
const e = new
|
|
3980
|
-
return e.getErrors().length > 0 ? e : e.chain(({ ast:
|
|
4025
|
+
const e = new on(this.source).lex().chain((n) => new un(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4026
|
+
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new qn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
3981
4027
|
}
|
|
3982
4028
|
),
|
|
3983
4029
|
ast: this.createQuery(
|
|
@@ -4001,78 +4047,78 @@ class as {
|
|
|
4001
4047
|
stack: this.createQuery(
|
|
4002
4048
|
10,
|
|
4003
4049
|
(e) => {
|
|
4004
|
-
const
|
|
4005
|
-
let { index:
|
|
4050
|
+
const n = this.parse.tokens();
|
|
4051
|
+
let { index: s } = this.container.token(e);
|
|
4006
4052
|
const { token: i } = this.container.token(e);
|
|
4007
|
-
if (
|
|
4053
|
+
if (s === void 0)
|
|
4008
4054
|
return [this.parse.ast()];
|
|
4009
|
-
for (; s
|
|
4010
|
-
|
|
4011
|
-
if (
|
|
4055
|
+
for (; n[s].isInvalid && s >= 0; )
|
|
4056
|
+
s -= 1;
|
|
4057
|
+
if (s === -1)
|
|
4012
4058
|
return [this.parse.ast()];
|
|
4013
|
-
const r = s
|
|
4059
|
+
const r = n[s].start;
|
|
4014
4060
|
let a = this.parse.ast();
|
|
4015
|
-
const
|
|
4061
|
+
const c = [a];
|
|
4016
4062
|
for (; ; ) {
|
|
4017
|
-
const h =
|
|
4018
|
-
if (h === void 0 || h instanceof
|
|
4063
|
+
const h = an(a).find((T) => Le(r, T));
|
|
4064
|
+
if (h === void 0 || h instanceof V)
|
|
4019
4065
|
break;
|
|
4020
|
-
|
|
4066
|
+
c.push(h), a = h;
|
|
4021
4067
|
}
|
|
4022
|
-
if ((i == null ? void 0 : i.kind) ===
|
|
4023
|
-
return
|
|
4024
|
-
for (;
|
|
4068
|
+
if ((i == null ? void 0 : i.kind) === u.COLON)
|
|
4069
|
+
return c;
|
|
4070
|
+
for (; c.length > 0; ) {
|
|
4025
4071
|
let p = !1;
|
|
4026
|
-
const h = I.last(
|
|
4027
|
-
if (h instanceof
|
|
4072
|
+
const h = I.last(c);
|
|
4073
|
+
if (h instanceof v) {
|
|
4028
4074
|
const T = this.parse.source();
|
|
4029
4075
|
for (let f = h.end; f < e; f += 1)
|
|
4030
4076
|
T[f] === `
|
|
4031
|
-
` && (
|
|
4077
|
+
` && (c.pop(), p = !0);
|
|
4032
4078
|
} else
|
|
4033
|
-
h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (
|
|
4079
|
+
h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof U ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ee ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof te || h.end < e && (c.pop(), p = !0);
|
|
4034
4080
|
if (p) {
|
|
4035
|
-
const T = I.last(
|
|
4036
|
-
T instanceof _ && T.end <= e &&
|
|
4081
|
+
const T = I.last(c);
|
|
4082
|
+
T instanceof _ && T.end <= e && c.pop();
|
|
4037
4083
|
}
|
|
4038
4084
|
if (!p)
|
|
4039
4085
|
break;
|
|
4040
4086
|
}
|
|
4041
|
-
return
|
|
4087
|
+
return c;
|
|
4042
4088
|
}
|
|
4043
4089
|
),
|
|
4044
4090
|
token: this.createQuery(
|
|
4045
4091
|
11,
|
|
4046
4092
|
(e) => {
|
|
4047
|
-
const
|
|
4048
|
-
return
|
|
4049
|
-
token: this.token.flatStream()[
|
|
4050
|
-
index:
|
|
4093
|
+
const n = this.token.flatStream().findIndex((s) => s.start >= e);
|
|
4094
|
+
return n === void 0 ? { token: void 0, index: void 0 } : n <= 0 ? { token: void 0, index: void 0 } : {
|
|
4095
|
+
token: this.token.flatStream()[n - 1],
|
|
4096
|
+
index: n - 1
|
|
4051
4097
|
};
|
|
4052
4098
|
}
|
|
4053
4099
|
),
|
|
4054
4100
|
element: this.createQuery(
|
|
4055
4101
|
12,
|
|
4056
4102
|
(e) => {
|
|
4057
|
-
const
|
|
4058
|
-
for (let
|
|
4059
|
-
if (s
|
|
4060
|
-
return s
|
|
4103
|
+
const n = this.container.stack(e);
|
|
4104
|
+
for (let s = n.length - 1; s >= 0; s -= 1)
|
|
4105
|
+
if (n[s] instanceof _)
|
|
4106
|
+
return n[s];
|
|
4061
4107
|
return this.parse.ast();
|
|
4062
4108
|
}
|
|
4063
4109
|
),
|
|
4064
4110
|
scope: this.createQuery(
|
|
4065
4111
|
14,
|
|
4066
4112
|
(e) => {
|
|
4067
|
-
var
|
|
4068
|
-
return (
|
|
4113
|
+
var n, s;
|
|
4114
|
+
return (s = (n = this.container.element(e)) == null ? void 0 : n.symbol) == null ? void 0 : s.symbolTable;
|
|
4069
4115
|
}
|
|
4070
4116
|
),
|
|
4071
4117
|
scopeKind: this.createQuery(15, (e) => {
|
|
4072
|
-
var
|
|
4073
|
-
if (this.container.element(e) instanceof
|
|
4118
|
+
var s;
|
|
4119
|
+
if (this.container.element(e) instanceof F)
|
|
4074
4120
|
return 8;
|
|
4075
|
-
switch ((
|
|
4121
|
+
switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
|
|
4076
4122
|
case "table":
|
|
4077
4123
|
return 0;
|
|
4078
4124
|
case "enum":
|
|
@@ -4100,52 +4146,52 @@ class as {
|
|
|
4100
4146
|
8,
|
|
4101
4147
|
({
|
|
4102
4148
|
nameStack: e,
|
|
4103
|
-
owner:
|
|
4149
|
+
owner: n = this.parse.ast()
|
|
4104
4150
|
}) => {
|
|
4105
4151
|
var i;
|
|
4106
4152
|
if (e.length === 0)
|
|
4107
4153
|
return [];
|
|
4108
|
-
const
|
|
4109
|
-
for (let r =
|
|
4154
|
+
const s = [];
|
|
4155
|
+
for (let r = n; r; r = r instanceof _ ? r.parent : void 0) {
|
|
4110
4156
|
if (!((i = r.symbol) != null && i.symbolTable))
|
|
4111
4157
|
continue;
|
|
4112
4158
|
const { symbolTable: a } = r.symbol;
|
|
4113
|
-
let
|
|
4159
|
+
let c = [a], p = [];
|
|
4114
4160
|
for (const h of e)
|
|
4115
|
-
p =
|
|
4116
|
-
(T) =>
|
|
4161
|
+
p = c.flatMap(
|
|
4162
|
+
(T) => Qt(h).flatMap((f) => {
|
|
4117
4163
|
const N = T.get(f), g = se(f).unwrap_or(void 0);
|
|
4118
4164
|
return !N || !g ? [] : { ...g, symbol: N };
|
|
4119
4165
|
})
|
|
4120
|
-
),
|
|
4166
|
+
), c = p.flatMap(
|
|
4121
4167
|
(T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
|
|
4122
4168
|
);
|
|
4123
|
-
|
|
4169
|
+
s.push(...p);
|
|
4124
4170
|
}
|
|
4125
|
-
return
|
|
4171
|
+
return s;
|
|
4126
4172
|
},
|
|
4127
|
-
({ nameStack: e, owner:
|
|
4173
|
+
({ nameStack: e, owner: n }) => `${e.join(".")}@${n.id}`
|
|
4128
4174
|
),
|
|
4129
4175
|
members: this.createQuery(
|
|
4130
4176
|
9,
|
|
4131
|
-
(e) => e.symbolTable ? [...e.symbolTable.entries()].map(([
|
|
4132
|
-
...se(
|
|
4133
|
-
symbol:
|
|
4177
|
+
(e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
|
|
4178
|
+
...se(n).unwrap(),
|
|
4179
|
+
symbol: s
|
|
4134
4180
|
})) : []
|
|
4135
4181
|
)
|
|
4136
4182
|
};
|
|
4137
4183
|
}
|
|
4138
|
-
createQuery(e,
|
|
4184
|
+
createQuery(e, n, s) {
|
|
4139
4185
|
return (i) => {
|
|
4140
|
-
const r = this.cache[e], a = i &&
|
|
4186
|
+
const r = this.cache[e], a = i && s ? s(i) : i;
|
|
4141
4187
|
if (r !== null) {
|
|
4142
4188
|
if (!(r instanceof Map))
|
|
4143
4189
|
return r;
|
|
4144
4190
|
if (r.has(a))
|
|
4145
4191
|
return r.get(a);
|
|
4146
4192
|
}
|
|
4147
|
-
const
|
|
4148
|
-
return i !== void 0 ? r instanceof Map ? r.set(a,
|
|
4193
|
+
const c = n(i);
|
|
4194
|
+
return i !== void 0 ? r instanceof Map ? r.set(a, c) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, c)) : this.cache[e] = c, c;
|
|
4149
4195
|
};
|
|
4150
4196
|
}
|
|
4151
4197
|
setSource(e) {
|
|
@@ -4156,14 +4202,14 @@ class as {
|
|
|
4156
4202
|
}
|
|
4157
4203
|
initMonacoServices() {
|
|
4158
4204
|
return {
|
|
4159
|
-
definitionProvider: new
|
|
4160
|
-
referenceProvider: new
|
|
4161
|
-
autocompletionProvider: new
|
|
4205
|
+
definitionProvider: new Ct(this),
|
|
4206
|
+
referenceProvider: new Xt(this),
|
|
4207
|
+
autocompletionProvider: new Ft(this)
|
|
4162
4208
|
};
|
|
4163
4209
|
}
|
|
4164
4210
|
}
|
|
4165
4211
|
export {
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4212
|
+
cs as Compiler,
|
|
4213
|
+
as as serialize,
|
|
4214
|
+
os as services
|
|
4169
4215
|
};
|