@dbml/parse 3.4.0 → 3.4.1-project-token.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 +12 -10
- package/dist/dbml-parse.mjs +358 -349
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import I from "lodash";
|
|
2
2
|
var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
|
|
3
|
-
function
|
|
3
|
+
function jt(t) {
|
|
4
4
|
switch (t.kind) {
|
|
5
5
|
case "<newline>":
|
|
6
6
|
case "<space>":
|
|
@@ -36,12 +36,12 @@ function rt(t) {
|
|
|
36
36
|
function at(t) {
|
|
37
37
|
return t !== void 0 && t.kind === "<op>";
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class F {
|
|
40
40
|
constructor(e, n, s, i, r) {
|
|
41
41
|
this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
|
|
42
42
|
}
|
|
43
43
|
static create(e, n, s, i, r) {
|
|
44
|
-
return new
|
|
44
|
+
return new F(e, n, s, i, r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function bt(t) {
|
|
@@ -59,7 +59,7 @@ 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
|
|
62
|
+
function Wt(t) {
|
|
63
63
|
return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
|
|
64
64
|
t.kind
|
|
65
65
|
);
|
|
@@ -75,19 +75,19 @@ class Yt {
|
|
|
75
75
|
return this.id++;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class x {
|
|
79
79
|
// The symbol that this syntax node refers to
|
|
80
80
|
// args must be passed in order of appearance in the node
|
|
81
81
|
constructor(e, n, s) {
|
|
82
82
|
this.id = e, this.kind = n;
|
|
83
83
|
const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
|
|
84
|
-
i ? (this.startPos = i.startPos, this.fullStart = i instanceof
|
|
84
|
+
i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ? Lt(i) : i.fullStart) : (this.startPos = {
|
|
85
85
|
offset: NaN,
|
|
86
86
|
column: NaN,
|
|
87
87
|
line: NaN
|
|
88
88
|
}, this.fullStart = NaN);
|
|
89
89
|
const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
|
|
90
|
-
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof
|
|
90
|
+
r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ? It(r) : r.fullEnd) : (this.endPos = {
|
|
91
91
|
offset: NaN,
|
|
92
92
|
column: NaN,
|
|
93
93
|
line: NaN
|
|
@@ -95,12 +95,12 @@ class k {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
var de = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(de || {});
|
|
98
|
-
class G extends
|
|
98
|
+
class G extends x {
|
|
99
99
|
constructor({ body: e = [], eof: n }, s) {
|
|
100
100
|
super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class A extends
|
|
103
|
+
class A extends x {
|
|
104
104
|
constructor({
|
|
105
105
|
type: e,
|
|
106
106
|
name: n,
|
|
@@ -108,7 +108,7 @@ class A extends k {
|
|
|
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,
|
|
@@ -117,18 +117,18 @@ class A extends k {
|
|
|
117
117
|
i,
|
|
118
118
|
r,
|
|
119
119
|
a,
|
|
120
|
-
|
|
121
|
-
]),
|
|
120
|
+
c
|
|
121
|
+
]), c && a && !(c instanceof w || c instanceof A))
|
|
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 = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body =
|
|
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 $ extends
|
|
126
|
+
class $ extends x {
|
|
127
127
|
constructor({ identifiers: e = [] }, n) {
|
|
128
128
|
super(n, "<identifer-stream>", e || []), this.identifiers = e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class se extends
|
|
131
|
+
class se extends x {
|
|
132
132
|
constructor({
|
|
133
133
|
name: e,
|
|
134
134
|
colon: n,
|
|
@@ -137,12 +137,12 @@ class se extends k {
|
|
|
137
137
|
super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class q extends
|
|
140
|
+
class q extends x {
|
|
141
141
|
constructor({ op: e, expression: n }, s) {
|
|
142
142
|
super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class H extends
|
|
145
|
+
class H extends x {
|
|
146
146
|
constructor({
|
|
147
147
|
op: e,
|
|
148
148
|
leftExpression: n,
|
|
@@ -151,22 +151,22 @@ class H extends k {
|
|
|
151
151
|
super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
class Pe extends
|
|
154
|
+
class Pe extends x {
|
|
155
155
|
constructor({ op: e, expression: n }, s) {
|
|
156
156
|
super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class te extends
|
|
159
|
+
class te extends x {
|
|
160
160
|
constructor({ value: e }, n) {
|
|
161
161
|
super(n, "<function-expression>", [e]), this.value = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
class w extends
|
|
164
|
+
class w extends x {
|
|
165
165
|
constructor({ callee: e, args: n = [] }, s) {
|
|
166
166
|
super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
class ne extends
|
|
169
|
+
class ne extends x {
|
|
170
170
|
constructor({
|
|
171
171
|
blockOpenBrace: e,
|
|
172
172
|
body: n = [],
|
|
@@ -175,7 +175,7 @@ class ne extends k {
|
|
|
175
175
|
super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
class P extends
|
|
178
|
+
class P extends x {
|
|
179
179
|
constructor({
|
|
180
180
|
listOpenBracket: e,
|
|
181
181
|
elementList: n = [],
|
|
@@ -189,7 +189,7 @@ class P extends k {
|
|
|
189
189
|
]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class Z extends
|
|
192
|
+
class Z extends x {
|
|
193
193
|
constructor({
|
|
194
194
|
tupleOpenParen: e,
|
|
195
195
|
elementList: n = [],
|
|
@@ -203,7 +203,7 @@ class Z extends k {
|
|
|
203
203
|
]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class
|
|
206
|
+
class je extends Z {
|
|
207
207
|
constructor({
|
|
208
208
|
groupOpenParen: e,
|
|
209
209
|
expression: n,
|
|
@@ -220,7 +220,7 @@ class We extends Z {
|
|
|
220
220
|
), this.kind = "<group-expression>";
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class J extends
|
|
223
|
+
class J extends x {
|
|
224
224
|
constructor({
|
|
225
225
|
callee: e,
|
|
226
226
|
argumentList: n
|
|
@@ -228,28 +228,28 @@ class J extends k {
|
|
|
228
228
|
super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class Te extends
|
|
231
|
+
class Te extends x {
|
|
232
232
|
constructor({ literal: e }, n) {
|
|
233
233
|
super(n, "<literal>", [e]), this.literal = e;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class W extends x {
|
|
237
237
|
constructor({ variable: e }, n) {
|
|
238
238
|
super(n, "<variable>", [e]), this.variable = e;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class D extends
|
|
241
|
+
class D extends x {
|
|
242
242
|
constructor({ expression: e }, n) {
|
|
243
243
|
super(n, "<primary-expression>", [e]), this.expression = e;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class ke extends
|
|
246
|
+
class ke extends x {
|
|
247
247
|
constructor({ pre: e }, n) {
|
|
248
|
-
const s =
|
|
248
|
+
const s = F.create(u.SPACE, e.endPos, e.endPos, " ", !1);
|
|
249
249
|
super(n, "<dummy>", [s]);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
252
|
+
class le extends x {
|
|
253
253
|
constructor({ expression: e, indexer: n }, s) {
|
|
254
254
|
super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
|
|
255
255
|
}
|
|
@@ -335,7 +335,7 @@ class v {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
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
|
-
function
|
|
338
|
+
function We(t) {
|
|
339
339
|
return `Schema:${t}`;
|
|
340
340
|
}
|
|
341
341
|
function Se(t) {
|
|
@@ -368,7 +368,7 @@ function Ve(t, e) {
|
|
|
368
368
|
case "Enum field":
|
|
369
369
|
return Qe(t);
|
|
370
370
|
case "Schema":
|
|
371
|
-
return
|
|
371
|
+
return We(t);
|
|
372
372
|
case "Table":
|
|
373
373
|
return Se(t);
|
|
374
374
|
case "TableGroup":
|
|
@@ -395,7 +395,7 @@ function Qt(t) {
|
|
|
395
395
|
}
|
|
396
396
|
function qt(t) {
|
|
397
397
|
return [
|
|
398
|
-
|
|
398
|
+
We,
|
|
399
399
|
Se,
|
|
400
400
|
ze,
|
|
401
401
|
qe,
|
|
@@ -418,7 +418,7 @@ function Ht(t) {
|
|
|
418
418
|
function pe(t) {
|
|
419
419
|
return Ue(t) || Oe(t);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function ct(t, e) {
|
|
422
422
|
const n = [], s = Math.min(t.length, e.length);
|
|
423
423
|
for (let i = 0; i < s; i += 1)
|
|
424
424
|
n.push(t[i], e[i]);
|
|
@@ -473,13 +473,13 @@ class nn {
|
|
|
473
473
|
this.references = [], this.id = n, this.declaration = e;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
|
|
477
|
-
class
|
|
476
|
+
var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
|
|
477
|
+
class l extends Error {
|
|
478
478
|
constructor(e, n, s) {
|
|
479
|
-
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this,
|
|
479
|
+
super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, l.prototype);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
class
|
|
482
|
+
class B {
|
|
483
483
|
constructor(e, n) {
|
|
484
484
|
this.value = e, this.errors = n === void 0 ? [] : n;
|
|
485
485
|
}
|
|
@@ -491,10 +491,10 @@ class F {
|
|
|
491
491
|
}
|
|
492
492
|
chain(e) {
|
|
493
493
|
const n = e(this.value), s = [...this.errors, ...n.errors];
|
|
494
|
-
return new
|
|
494
|
+
return new B(n.value, s);
|
|
495
495
|
}
|
|
496
496
|
map(e) {
|
|
497
|
-
return new
|
|
497
|
+
return new B(e(this.value), this.errors);
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
function sn(t, e, n) {
|
|
@@ -528,11 +528,11 @@ function sn(t, e, n) {
|
|
|
528
528
|
})
|
|
529
529
|
) : new v();
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function lt(t) {
|
|
532
532
|
return t.kind === u.IDENTIFIER && t.value === "as";
|
|
533
533
|
}
|
|
534
534
|
function E(t) {
|
|
535
|
-
t && (t instanceof
|
|
535
|
+
t && (t instanceof F ? rn(t) : an(t));
|
|
536
536
|
}
|
|
537
537
|
function rn(t) {
|
|
538
538
|
t.kind !== u.EOF && (t.isInvalid = !0);
|
|
@@ -564,12 +564,12 @@ function an(t) {
|
|
|
564
564
|
E(t.expression);
|
|
565
565
|
else if (t instanceof te)
|
|
566
566
|
E(t.value);
|
|
567
|
-
else if (t instanceof
|
|
567
|
+
else if (t instanceof W)
|
|
568
568
|
E(t.variable);
|
|
569
569
|
else if (t instanceof Te)
|
|
570
570
|
E(t.literal);
|
|
571
571
|
else
|
|
572
|
-
throw t instanceof
|
|
572
|
+
throw t instanceof je ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
|
|
573
573
|
}
|
|
574
574
|
function vt(t) {
|
|
575
575
|
return !!(t != null && t.isInvalid);
|
|
@@ -596,7 +596,7 @@ function on(t) {
|
|
|
596
596
|
return t.identifiers;
|
|
597
597
|
if (t instanceof Te)
|
|
598
598
|
return t.literal ? [t.literal] : [];
|
|
599
|
-
if (t instanceof
|
|
599
|
+
if (t instanceof W)
|
|
600
600
|
return U(t.variable);
|
|
601
601
|
if (t instanceof q)
|
|
602
602
|
return U(t.op, t.expression);
|
|
@@ -613,43 +613,43 @@ function on(t) {
|
|
|
613
613
|
if (t instanceof P)
|
|
614
614
|
return U(
|
|
615
615
|
t.listOpenBracket,
|
|
616
|
-
...
|
|
616
|
+
...ct(t.elementList, t.commaList),
|
|
617
617
|
t.listCloseBracket
|
|
618
618
|
);
|
|
619
619
|
if (t instanceof Z)
|
|
620
620
|
return U(
|
|
621
621
|
t.tupleOpenParen,
|
|
622
|
-
...
|
|
622
|
+
...ct(t.elementList, t.commaList),
|
|
623
623
|
t.tupleCloseParen
|
|
624
624
|
);
|
|
625
625
|
if (t instanceof J)
|
|
626
626
|
return U(t.callee, t.argumentList);
|
|
627
627
|
if (t instanceof D)
|
|
628
628
|
return U(t.expression);
|
|
629
|
-
if (t instanceof
|
|
629
|
+
if (t instanceof le)
|
|
630
630
|
return U(
|
|
631
631
|
t.array,
|
|
632
632
|
t.indexer
|
|
633
633
|
);
|
|
634
|
-
throw t instanceof
|
|
634
|
+
throw t instanceof je ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
|
|
635
635
|
}
|
|
636
636
|
function Ge(t) {
|
|
637
637
|
return M(t) ? new S(t.expression.variable) : new v();
|
|
638
638
|
}
|
|
639
639
|
function Y(t) {
|
|
640
640
|
var e;
|
|
641
|
-
return t instanceof D && (t.expression instanceof
|
|
641
|
+
return t instanceof D && (t.expression instanceof W && t.expression.variable instanceof F && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof Te && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
|
|
642
642
|
}
|
|
643
643
|
function M(t) {
|
|
644
|
-
return t instanceof D && t.expression instanceof
|
|
644
|
+
return t instanceof D && t.expression instanceof W && t.expression.variable instanceof F;
|
|
645
645
|
}
|
|
646
646
|
function Ne(t) {
|
|
647
647
|
var e;
|
|
648
|
-
return t instanceof D && t.expression instanceof
|
|
648
|
+
return t instanceof D && t.expression instanceof W && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
|
|
649
649
|
}
|
|
650
650
|
function Je(t) {
|
|
651
651
|
var e;
|
|
652
|
-
return t instanceof H && t.leftExpression instanceof
|
|
652
|
+
return t instanceof H && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
|
|
653
653
|
}
|
|
654
654
|
function me(t) {
|
|
655
655
|
if (t === void 0)
|
|
@@ -657,7 +657,7 @@ function me(t) {
|
|
|
657
657
|
const e = t.identifiers.map((n) => n.value).join(" ");
|
|
658
658
|
return e === "" ? new v() : new S(e);
|
|
659
659
|
}
|
|
660
|
-
class
|
|
660
|
+
class cn {
|
|
661
661
|
// list of errors during lexing
|
|
662
662
|
constructor(e) {
|
|
663
663
|
this.start = {
|
|
@@ -697,7 +697,7 @@ class ln {
|
|
|
697
697
|
this.tokens.push(this.createToken(e, n));
|
|
698
698
|
}
|
|
699
699
|
createToken(e, n = !1) {
|
|
700
|
-
return
|
|
700
|
+
return F.create(
|
|
701
701
|
e,
|
|
702
702
|
this.start,
|
|
703
703
|
this.current,
|
|
@@ -706,7 +706,7 @@ class ln {
|
|
|
706
706
|
);
|
|
707
707
|
}
|
|
708
708
|
lex() {
|
|
709
|
-
return this.scanTokens(), this.tokens.push(
|
|
709
|
+
return this.scanTokens(), this.tokens.push(F.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
|
|
710
710
|
}
|
|
711
711
|
scanTokens() {
|
|
712
712
|
for (; !this.isAtEnd(); ) {
|
|
@@ -780,7 +780,7 @@ class ln {
|
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
782
|
this.addToken(u.OP, !0), this.errors.push(
|
|
783
|
-
new
|
|
783
|
+
new l(
|
|
784
784
|
o.UNKNOWN_SYMBOL,
|
|
785
785
|
`Unexpected token '${e}'`,
|
|
786
786
|
this.createToken(u.OP, !0)
|
|
@@ -795,7 +795,7 @@ class ln {
|
|
|
795
795
|
let e = !0, n = [], s;
|
|
796
796
|
const i = [];
|
|
797
797
|
for (const r of this.tokens)
|
|
798
|
-
|
|
798
|
+
jt(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);
|
|
799
799
|
this.tokens = i;
|
|
800
800
|
}
|
|
801
801
|
gatherInvalid() {
|
|
@@ -820,14 +820,14 @@ class ln {
|
|
|
820
820
|
// Whether to interpret '\' as a backlash
|
|
821
821
|
consumeStopSequence: a = !0
|
|
822
822
|
}) {
|
|
823
|
-
let
|
|
823
|
+
let c = "";
|
|
824
824
|
for (; !this.isAtEnd() && (s || !this.check(`
|
|
825
825
|
`)) && !this.check(n); )
|
|
826
|
-
this.peek() === "\\" && !r ? (this.advance(),
|
|
826
|
+
this.peek() === "\\" && !r ? (this.advance(), c += this.escapedString()) : c += this.advance();
|
|
827
827
|
if (this.isAtEnd() && !i) {
|
|
828
828
|
const p = this.createToken(e, !0);
|
|
829
829
|
this.tokens.push(p), this.errors.push(
|
|
830
|
-
new
|
|
830
|
+
new l(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
|
|
831
831
|
);
|
|
832
832
|
return;
|
|
833
833
|
}
|
|
@@ -835,7 +835,7 @@ class ln {
|
|
|
835
835
|
`) && !s) {
|
|
836
836
|
const p = this.createToken(e, !0);
|
|
837
837
|
this.tokens.push(p), this.errors.push(
|
|
838
|
-
new
|
|
838
|
+
new l(
|
|
839
839
|
o.UNEXPECTED_NEWLINE,
|
|
840
840
|
"Invalid newline encountered while parsing",
|
|
841
841
|
p
|
|
@@ -843,7 +843,7 @@ class ln {
|
|
|
843
843
|
);
|
|
844
844
|
return;
|
|
845
845
|
}
|
|
846
|
-
a && this.match(n), this.tokens.push(
|
|
846
|
+
a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, c, !1));
|
|
847
847
|
}
|
|
848
848
|
singleLineStringLiteral() {
|
|
849
849
|
this.consumeUntil(u.STRING_LITERAL, "'", {
|
|
@@ -920,7 +920,7 @@ class ln {
|
|
|
920
920
|
for (; !this.isAtEnd() && (this.check(".") || pe(this.peek())); )
|
|
921
921
|
this.advance();
|
|
922
922
|
const n = this.createToken(u.NUMERIC_LITERAL, !0);
|
|
923
|
-
this.tokens.push(n), this.errors.push(new
|
|
923
|
+
this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
|
|
924
924
|
} else {
|
|
925
925
|
for (; !this.isAtEnd() && pe(this.peek()); )
|
|
926
926
|
this.advance();
|
|
@@ -934,9 +934,16 @@ class ln {
|
|
|
934
934
|
this.addToken(u.COLOR_LITERAL);
|
|
935
935
|
}
|
|
936
936
|
escapedString() {
|
|
937
|
+
const e = { column: this.current.column - 1, offset: this.current.offset - 1, line: this.current.line };
|
|
937
938
|
if (this.isAtEnd())
|
|
938
939
|
return "\\";
|
|
939
940
|
switch (this.advance()) {
|
|
941
|
+
case "\r":
|
|
942
|
+
return this.check(`
|
|
943
|
+
`) && this.advance(), "";
|
|
944
|
+
case `
|
|
945
|
+
`:
|
|
946
|
+
return "";
|
|
940
947
|
case "t":
|
|
941
948
|
return " ";
|
|
942
949
|
case "n":
|
|
@@ -947,7 +954,7 @@ class ln {
|
|
|
947
954
|
case "r":
|
|
948
955
|
return "\r";
|
|
949
956
|
case "'":
|
|
950
|
-
return "'";
|
|
957
|
+
return this.peek() === "'" && this.peek(1) === "'" ? (this.advance(), this.advance(), "'''") : "'";
|
|
951
958
|
case '"':
|
|
952
959
|
return '"';
|
|
953
960
|
case "0":
|
|
@@ -958,22 +965,24 @@ class ln {
|
|
|
958
965
|
return "\v";
|
|
959
966
|
case "f":
|
|
960
967
|
return "\f";
|
|
968
|
+
case " ":
|
|
969
|
+
return "\\ ";
|
|
961
970
|
case "u": {
|
|
962
|
-
let
|
|
963
|
-
for (let
|
|
971
|
+
let n = "";
|
|
972
|
+
for (let s = 0; s <= 3; s += 1) {
|
|
964
973
|
if (this.isAtEnd() || !pe(this.peek()))
|
|
965
|
-
return `\\u${
|
|
966
|
-
|
|
974
|
+
return this.errors.push(new l(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, F.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
|
|
975
|
+
n += this.advance();
|
|
967
976
|
}
|
|
968
|
-
return String.fromCharCode(parseInt(
|
|
977
|
+
return String.fromCharCode(parseInt(n, 16));
|
|
969
978
|
}
|
|
970
979
|
default:
|
|
971
|
-
return
|
|
980
|
+
return this.text[this.current.offset - 1];
|
|
972
981
|
}
|
|
973
982
|
}
|
|
974
983
|
}
|
|
975
984
|
var xe = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(xe || {});
|
|
976
|
-
class
|
|
985
|
+
class ln {
|
|
977
986
|
constructor() {
|
|
978
987
|
this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
|
|
979
988
|
}
|
|
@@ -1054,13 +1063,13 @@ class d {
|
|
|
1054
1063
|
}
|
|
1055
1064
|
class hn {
|
|
1056
1065
|
constructor(e, n) {
|
|
1057
|
-
this.current = 0, this.errors = [], this.contextStack = new
|
|
1066
|
+
this.current = 0, this.errors = [], this.contextStack = new ln(), this.synchronizeProgram = () => {
|
|
1058
1067
|
const s = this.peek();
|
|
1059
1068
|
s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
|
|
1060
1069
|
}, this.synchronizeElementDeclarationName = () => {
|
|
1061
1070
|
for (; !this.isAtEnd(); ) {
|
|
1062
1071
|
const s = this.peek();
|
|
1063
|
-
if (
|
|
1072
|
+
if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1064
1073
|
break;
|
|
1065
1074
|
E(s), this.advance();
|
|
1066
1075
|
}
|
|
@@ -1111,7 +1120,7 @@ class hn {
|
|
|
1111
1120
|
E(s), this.advance();
|
|
1112
1121
|
}
|
|
1113
1122
|
}, this.tupleExpression = this.contextStack.withContextDo(xe.GroupExpression, () => {
|
|
1114
|
-
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(
|
|
1123
|
+
const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(je, {
|
|
1115
1124
|
groupOpenParen: s.tupleOpenParen,
|
|
1116
1125
|
groupCloseParen: s.tupleCloseParen,
|
|
1117
1126
|
expression: s.elementList[0]
|
|
@@ -1141,7 +1150,7 @@ class hn {
|
|
|
1141
1150
|
} catch (a) {
|
|
1142
1151
|
if (!(a instanceof d))
|
|
1143
1152
|
throw a;
|
|
1144
|
-
if (a.partialNode instanceof
|
|
1153
|
+
if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
|
|
1145
1154
|
throw new d(a.token, r(), a.handlerContext);
|
|
1146
1155
|
this.synchronizeTuple();
|
|
1147
1156
|
}
|
|
@@ -1189,7 +1198,7 @@ class hn {
|
|
|
1189
1198
|
} catch (r) {
|
|
1190
1199
|
if (!(r instanceof d))
|
|
1191
1200
|
throw r;
|
|
1192
|
-
if (r.partialNode instanceof
|
|
1201
|
+
if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
|
|
1193
1202
|
throw new d(r.token, i(), r.handlerContext);
|
|
1194
1203
|
this.synchronizeList();
|
|
1195
1204
|
}
|
|
@@ -1281,7 +1290,7 @@ class hn {
|
|
|
1281
1290
|
}
|
|
1282
1291
|
parse() {
|
|
1283
1292
|
const e = this.program(), n = this.advance(), s = this.nodeFactory.create(G, { body: e, eof: n });
|
|
1284
|
-
return this.gatherInvalid(), new
|
|
1293
|
+
return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
|
|
1285
1294
|
}
|
|
1286
1295
|
/* Parsing and synchronizing ProgramNode */
|
|
1287
1296
|
program() {
|
|
@@ -1315,7 +1324,7 @@ class hn {
|
|
|
1315
1324
|
throw new d(s.token, n(), s.handlerContext);
|
|
1316
1325
|
this.synchronizeElementDeclarationName();
|
|
1317
1326
|
}
|
|
1318
|
-
if (
|
|
1327
|
+
if (lt(this.peek()))
|
|
1319
1328
|
if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
|
|
1320
1329
|
this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
|
|
1321
1330
|
else
|
|
@@ -1371,7 +1380,7 @@ class hn {
|
|
|
1371
1380
|
}
|
|
1372
1381
|
try {
|
|
1373
1382
|
const s = this.expression();
|
|
1374
|
-
s instanceof A ? this.errors.push(new
|
|
1383
|
+
s instanceof A ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
|
|
1375
1384
|
} catch (s) {
|
|
1376
1385
|
throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
|
|
1377
1386
|
}
|
|
@@ -1437,12 +1446,12 @@ class hn {
|
|
|
1437
1446
|
if (Ce(this.previous()))
|
|
1438
1447
|
break;
|
|
1439
1448
|
try {
|
|
1440
|
-
n = this.nodeFactory.create(
|
|
1449
|
+
n = this.nodeFactory.create(le, {
|
|
1441
1450
|
expression: n,
|
|
1442
1451
|
indexer: this.listExpression()
|
|
1443
1452
|
});
|
|
1444
1453
|
} catch (i) {
|
|
1445
|
-
throw i instanceof d ? (n = this.nodeFactory.create(
|
|
1454
|
+
throw i instanceof d ? (n = this.nodeFactory.create(le, {
|
|
1446
1455
|
expression: n,
|
|
1447
1456
|
indexer: i.partialNode
|
|
1448
1457
|
}), new d(i.token, n, i.handlerContext)) : i;
|
|
@@ -1467,12 +1476,12 @@ class hn {
|
|
|
1467
1476
|
op: i,
|
|
1468
1477
|
rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
|
|
1469
1478
|
});
|
|
1470
|
-
} catch (
|
|
1471
|
-
throw
|
|
1479
|
+
} catch (c) {
|
|
1480
|
+
throw c instanceof d ? (n = this.nodeFactory.create(H, {
|
|
1472
1481
|
leftExpression: n,
|
|
1473
1482
|
op: i,
|
|
1474
|
-
rightExpression:
|
|
1475
|
-
}), new d(
|
|
1483
|
+
rightExpression: c.partialNode
|
|
1484
|
+
}), new d(c.token, n, c.handlerContext)) : c;
|
|
1476
1485
|
}
|
|
1477
1486
|
}
|
|
1478
1487
|
} else
|
|
@@ -1565,12 +1574,12 @@ class hn {
|
|
|
1565
1574
|
});
|
|
1566
1575
|
if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
|
|
1567
1576
|
return this.nodeFactory.create(D, {
|
|
1568
|
-
expression: this.nodeFactory.create(
|
|
1577
|
+
expression: this.nodeFactory.create(W, { variable: this.previous() })
|
|
1569
1578
|
});
|
|
1570
1579
|
throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
|
|
1571
1580
|
this.peek(),
|
|
1572
1581
|
this.nodeFactory.create(D, {
|
|
1573
|
-
expression: this.nodeFactory.create(
|
|
1582
|
+
expression: this.nodeFactory.create(W, {})
|
|
1574
1583
|
}),
|
|
1575
1584
|
this.contextStack.findHandlerContext(this.tokens, this.current)
|
|
1576
1585
|
);
|
|
@@ -1628,7 +1637,7 @@ class hn {
|
|
|
1628
1637
|
return this.nodeFactory.create($, { identifiers: e });
|
|
1629
1638
|
}
|
|
1630
1639
|
logError(e, n, s) {
|
|
1631
|
-
this.errors.push(new
|
|
1640
|
+
this.errors.push(new l(n, s, e));
|
|
1632
1641
|
}
|
|
1633
1642
|
}
|
|
1634
1643
|
const fn = {
|
|
@@ -1753,7 +1762,7 @@ function V(t) {
|
|
|
1753
1762
|
return e === void 0 ? new v() : new S(e);
|
|
1754
1763
|
}
|
|
1755
1764
|
function Q(t) {
|
|
1756
|
-
return Y(t) ? t.expression instanceof
|
|
1765
|
+
return Y(t) ? t.expression instanceof W ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new v();
|
|
1757
1766
|
}
|
|
1758
1767
|
function mn(t) {
|
|
1759
1768
|
var e;
|
|
@@ -1767,16 +1776,16 @@ function Tn(t) {
|
|
|
1767
1776
|
return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
|
|
1768
1777
|
}
|
|
1769
1778
|
function ht(t) {
|
|
1770
|
-
return t instanceof D && t.expression instanceof
|
|
1779
|
+
return t instanceof D && t.expression instanceof W || t instanceof te;
|
|
1771
1780
|
}
|
|
1772
1781
|
function bn(t, e) {
|
|
1773
|
-
var i, r, a,
|
|
1782
|
+
var i, r, a, c;
|
|
1774
1783
|
let n = e;
|
|
1775
1784
|
const s = Qt(t);
|
|
1776
1785
|
for (; n; ) {
|
|
1777
1786
|
if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
|
|
1778
1787
|
return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
|
|
1779
|
-
if (((
|
|
1788
|
+
if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof G && s)
|
|
1780
1789
|
return n.symbol;
|
|
1781
1790
|
if (n instanceof G)
|
|
1782
1791
|
return;
|
|
@@ -1791,24 +1800,24 @@ class In {
|
|
|
1791
1800
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1792
1801
|
}
|
|
1793
1802
|
validateContext() {
|
|
1794
|
-
return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new
|
|
1803
|
+
return this.declarationNode.parent instanceof G || ve(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)] : [];
|
|
1795
1804
|
}
|
|
1796
1805
|
validateName(e) {
|
|
1797
|
-
return e ? [new
|
|
1806
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
|
|
1798
1807
|
}
|
|
1799
1808
|
validateAlias(e) {
|
|
1800
|
-
return e ? [new
|
|
1809
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
|
|
1801
1810
|
}
|
|
1802
1811
|
validateSettingList(e) {
|
|
1803
|
-
return e ? [new
|
|
1812
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
|
|
1804
1813
|
}
|
|
1805
1814
|
validateBody(e) {
|
|
1806
1815
|
if (!e)
|
|
1807
1816
|
return [];
|
|
1808
1817
|
if (e instanceof ne)
|
|
1809
|
-
return [new
|
|
1818
|
+
return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
|
|
1810
1819
|
const n = [];
|
|
1811
|
-
return Y(e.callee) || n.push(new
|
|
1820
|
+
return Y(e.callee) || n.push(new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
|
|
1812
1821
|
}
|
|
1813
1822
|
}
|
|
1814
1823
|
class we {
|
|
@@ -1836,26 +1845,26 @@ class Ln {
|
|
|
1836
1845
|
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)];
|
|
1837
1846
|
}
|
|
1838
1847
|
validateContext() {
|
|
1839
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
1848
|
+
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
|
|
1840
1849
|
}
|
|
1841
1850
|
validateName(e) {
|
|
1842
|
-
return e ? Ze(e) ? [] : [new
|
|
1851
|
+
return e ? Ze(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)];
|
|
1843
1852
|
}
|
|
1844
1853
|
validateAlias(e) {
|
|
1845
|
-
return e ? [new
|
|
1854
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
1846
1855
|
}
|
|
1847
1856
|
registerElement() {
|
|
1848
1857
|
const e = [];
|
|
1849
1858
|
this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new we() });
|
|
1850
1859
|
const { name: n } = this.declarationNode, s = C(n);
|
|
1851
1860
|
if (s.isOk()) {
|
|
1852
|
-
const i = s.unwrap(), r = i.pop(), a = Ke(i, this.publicSymbolTable, this.symbolFactory),
|
|
1853
|
-
a.has(
|
|
1861
|
+
const i = s.unwrap(), r = i.pop(), a = Ke(i, this.publicSymbolTable, this.symbolFactory), c = ze(r);
|
|
1862
|
+
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);
|
|
1854
1863
|
}
|
|
1855
1864
|
return e;
|
|
1856
1865
|
}
|
|
1857
1866
|
validateSettingList(e) {
|
|
1858
|
-
return e ? [new
|
|
1867
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
|
|
1859
1868
|
}
|
|
1860
1869
|
validateBody(e) {
|
|
1861
1870
|
if (!e)
|
|
@@ -1866,25 +1875,25 @@ class Ln {
|
|
|
1866
1875
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1867
1876
|
}
|
|
1868
1877
|
validateFields(e) {
|
|
1869
|
-
return e.length === 0 ? [new
|
|
1878
|
+
return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
|
|
1870
1879
|
const s = [];
|
|
1871
|
-
n.callee && !M(n.callee) && s.push(new
|
|
1880
|
+
n.callee && !M(n.callee) && s.push(new l(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
|
|
1872
1881
|
const i = [...n.args];
|
|
1873
|
-
return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new
|
|
1882
|
+
return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
|
|
1874
1883
|
});
|
|
1875
1884
|
}
|
|
1876
1885
|
validateFieldSettings(e) {
|
|
1877
|
-
const n =
|
|
1886
|
+
const n = j(e), s = n.getErrors(), i = n.getValue();
|
|
1878
1887
|
for (const r in i) {
|
|
1879
1888
|
const a = i[r];
|
|
1880
1889
|
switch (r) {
|
|
1881
1890
|
case "note":
|
|
1882
|
-
a.length > 1 && a.forEach((
|
|
1883
|
-
Y(
|
|
1891
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
1892
|
+
Y(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
|
|
1884
1893
|
});
|
|
1885
1894
|
break;
|
|
1886
1895
|
default:
|
|
1887
|
-
a.forEach((
|
|
1896
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, c)));
|
|
1888
1897
|
}
|
|
1889
1898
|
}
|
|
1890
1899
|
return s;
|
|
@@ -1905,8 +1914,8 @@ class Ln {
|
|
|
1905
1914
|
if (r.has(s)) {
|
|
1906
1915
|
const a = r.get(s);
|
|
1907
1916
|
return [
|
|
1908
|
-
new
|
|
1909
|
-
new
|
|
1917
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
|
|
1918
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
|
|
1910
1919
|
];
|
|
1911
1920
|
}
|
|
1912
1921
|
r.set(s, i);
|
|
@@ -1922,22 +1931,22 @@ class gn {
|
|
|
1922
1931
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1923
1932
|
}
|
|
1924
1933
|
validateContext() {
|
|
1925
|
-
return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new
|
|
1934
|
+
return this.declarationNode.parent instanceof G || ve(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)] : [];
|
|
1926
1935
|
}
|
|
1927
1936
|
validateName(e) {
|
|
1928
|
-
return e ? [new
|
|
1937
|
+
return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
|
|
1929
1938
|
}
|
|
1930
1939
|
validateAlias(e) {
|
|
1931
|
-
return e ? [new
|
|
1940
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
|
|
1932
1941
|
}
|
|
1933
1942
|
validateSettingList(e) {
|
|
1934
|
-
return e ? [new
|
|
1943
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
|
|
1935
1944
|
}
|
|
1936
1945
|
validateBody(e) {
|
|
1937
1946
|
if (!e)
|
|
1938
1947
|
return [];
|
|
1939
1948
|
if (e instanceof w)
|
|
1940
|
-
return [new
|
|
1949
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
|
|
1941
1950
|
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
1942
1951
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
1943
1952
|
}
|
|
@@ -1948,35 +1957,35 @@ class gn {
|
|
|
1948
1957
|
const s = [], i = [n.callee, ...n.args];
|
|
1949
1958
|
return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
|
|
1950
1959
|
for (; r instanceof J; )
|
|
1951
|
-
r.argumentList && !Xe(r.argumentList).isOk() && s.push(new
|
|
1952
|
-
Xe(r).isOk() || s.push(new
|
|
1960
|
+
r.argumentList && !Xe(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;
|
|
1961
|
+
Xe(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));
|
|
1953
1962
|
}), s;
|
|
1954
1963
|
});
|
|
1955
1964
|
}
|
|
1956
1965
|
validateFieldSetting(e) {
|
|
1957
|
-
const n =
|
|
1966
|
+
const n = j(e), s = n.getErrors(), i = n.getValue();
|
|
1958
1967
|
for (const r in i) {
|
|
1959
1968
|
const a = i[r];
|
|
1960
1969
|
switch (r) {
|
|
1961
1970
|
case "note":
|
|
1962
1971
|
case "name":
|
|
1963
|
-
a.length > 1 && a.forEach((
|
|
1964
|
-
Y(
|
|
1972
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1973
|
+
Y(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
|
|
1965
1974
|
});
|
|
1966
1975
|
break;
|
|
1967
1976
|
case "unique":
|
|
1968
1977
|
case "pk":
|
|
1969
|
-
a.length > 1 && a.forEach((
|
|
1970
|
-
|
|
1978
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
1979
|
+
ce(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
|
|
1971
1980
|
});
|
|
1972
1981
|
break;
|
|
1973
1982
|
case "type":
|
|
1974
|
-
a.length > 1 && a.forEach((
|
|
1975
|
-
M(
|
|
1983
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), a.forEach((c) => {
|
|
1984
|
+
M(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
|
|
1976
1985
|
});
|
|
1977
1986
|
break;
|
|
1978
1987
|
default:
|
|
1979
|
-
a.forEach((
|
|
1988
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, c)));
|
|
1980
1989
|
}
|
|
1981
1990
|
}
|
|
1982
1991
|
return s;
|
|
@@ -1998,24 +2007,24 @@ class _n {
|
|
|
1998
2007
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
1999
2008
|
}
|
|
2000
2009
|
validateContext() {
|
|
2001
|
-
return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new
|
|
2010
|
+
return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(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)] : [];
|
|
2002
2011
|
}
|
|
2003
2012
|
validateName(e) {
|
|
2004
2013
|
if (!(this.declarationNode.parent instanceof G))
|
|
2005
|
-
return e ? [new
|
|
2014
|
+
return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
|
|
2006
2015
|
if (!e)
|
|
2007
|
-
return [new
|
|
2016
|
+
return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
|
|
2008
2017
|
const n = C(e);
|
|
2009
2018
|
if (!n.isOk())
|
|
2010
|
-
return [new
|
|
2019
|
+
return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
|
|
2011
2020
|
const i = n.unwrap().join("."), r = zt(i);
|
|
2012
|
-
return this.publicSymbolTable.has(r) ? [new
|
|
2021
|
+
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), []);
|
|
2013
2022
|
}
|
|
2014
2023
|
validateAlias(e) {
|
|
2015
|
-
return e ? [new
|
|
2024
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2016
2025
|
}
|
|
2017
2026
|
validateSettingList(e) {
|
|
2018
|
-
return e ? [new
|
|
2027
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
|
|
2019
2028
|
}
|
|
2020
2029
|
validateBody(e) {
|
|
2021
2030
|
if (!e)
|
|
@@ -2027,7 +2036,7 @@ class _n {
|
|
|
2027
2036
|
}
|
|
2028
2037
|
validateFields(e) {
|
|
2029
2038
|
const n = [];
|
|
2030
|
-
return e.length === 0 ? [new
|
|
2039
|
+
return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), Y(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
|
|
2031
2040
|
}
|
|
2032
2041
|
validateSubElements(e) {
|
|
2033
2042
|
return e.flatMap((n) => {
|
|
@@ -2046,25 +2055,25 @@ class An {
|
|
|
2046
2055
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2047
2056
|
}
|
|
2048
2057
|
validateContext() {
|
|
2049
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2058
|
+
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
|
|
2050
2059
|
}
|
|
2051
2060
|
validateName(e) {
|
|
2052
|
-
return e ? Me(e) ? [] : [new
|
|
2061
|
+
return e ? Me(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2053
2062
|
}
|
|
2054
2063
|
validateAlias(e) {
|
|
2055
|
-
return e ? [new
|
|
2064
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
|
|
2056
2065
|
}
|
|
2057
2066
|
validateSettingList(e) {
|
|
2058
|
-
return e ? [new
|
|
2067
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
|
|
2059
2068
|
}
|
|
2060
2069
|
validateBody(e) {
|
|
2061
2070
|
if (!e)
|
|
2062
2071
|
return [];
|
|
2063
2072
|
if (e instanceof w)
|
|
2064
|
-
return [new
|
|
2073
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
|
|
2065
2074
|
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2066
2075
|
return [
|
|
2067
|
-
...n.map((i) => new
|
|
2076
|
+
...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
|
|
2068
2077
|
...this.validateSubElements(s)
|
|
2069
2078
|
];
|
|
2070
2079
|
}
|
|
@@ -2085,16 +2094,16 @@ class vn {
|
|
|
2085
2094
|
return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
|
|
2086
2095
|
}
|
|
2087
2096
|
validateContext() {
|
|
2088
|
-
return this.declarationNode.parent instanceof G ? [] : [new
|
|
2097
|
+
return this.declarationNode.parent instanceof G ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
|
|
2089
2098
|
}
|
|
2090
2099
|
validateName(e) {
|
|
2091
|
-
return e ? Me(e) ? [] : [new
|
|
2100
|
+
return e ? Me(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
|
|
2092
2101
|
}
|
|
2093
2102
|
validateAlias(e) {
|
|
2094
|
-
return e ? [new
|
|
2103
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
|
|
2095
2104
|
}
|
|
2096
2105
|
validateSettingList(e) {
|
|
2097
|
-
return e ? [new
|
|
2106
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
|
|
2098
2107
|
}
|
|
2099
2108
|
validateBody(e) {
|
|
2100
2109
|
if (!e)
|
|
@@ -2106,27 +2115,27 @@ class vn {
|
|
|
2106
2115
|
}
|
|
2107
2116
|
validateFields(e) {
|
|
2108
2117
|
if (e.length === 0)
|
|
2109
|
-
return [new
|
|
2118
|
+
return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
|
|
2110
2119
|
const n = [];
|
|
2111
|
-
return e.length > 1 && n.push(...e.slice(1).map((s) => new
|
|
2112
|
-
s.callee && !mn(s.callee) && n.push(new
|
|
2120
|
+
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) => {
|
|
2121
|
+
s.callee && !mn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Tn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
|
|
2113
2122
|
const i = [...s.args];
|
|
2114
|
-
I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new
|
|
2123
|
+
I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
|
|
2115
2124
|
}), n;
|
|
2116
2125
|
}
|
|
2117
2126
|
validateFieldSettings(e) {
|
|
2118
|
-
const n =
|
|
2127
|
+
const n = j(e), s = n.getErrors(), i = n.getValue();
|
|
2119
2128
|
for (const r in i) {
|
|
2120
2129
|
const a = i[r];
|
|
2121
2130
|
switch (r) {
|
|
2122
2131
|
case "delete":
|
|
2123
2132
|
case "update":
|
|
2124
|
-
a.length > 1 && a.forEach((
|
|
2125
|
-
wn(
|
|
2133
|
+
a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
|
|
2134
|
+
wn(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));
|
|
2126
2135
|
});
|
|
2127
2136
|
break;
|
|
2128
2137
|
default:
|
|
2129
|
-
a.forEach((
|
|
2138
|
+
a.forEach((c) => s.push(new l(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, c)));
|
|
2130
2139
|
}
|
|
2131
2140
|
}
|
|
2132
2141
|
return s;
|
|
@@ -2165,31 +2174,31 @@ class yn {
|
|
|
2165
2174
|
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)];
|
|
2166
2175
|
}
|
|
2167
2176
|
validateContext() {
|
|
2168
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2177
|
+
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
|
|
2169
2178
|
}
|
|
2170
2179
|
validateName(e) {
|
|
2171
|
-
return e ? e instanceof
|
|
2180
|
+
return e ? e instanceof le ? [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)] : Ze(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)];
|
|
2172
2181
|
}
|
|
2173
2182
|
validateAlias(e) {
|
|
2174
|
-
return e ? On(e) ? [] : [new
|
|
2183
|
+
return e ? On(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
|
|
2175
2184
|
}
|
|
2176
2185
|
validateSettingList(e) {
|
|
2177
|
-
const n =
|
|
2186
|
+
const n = j(e), s = n.getErrors(), i = n.getValue();
|
|
2178
2187
|
for (const r in i) {
|
|
2179
2188
|
const a = i[r];
|
|
2180
2189
|
switch (r) {
|
|
2181
2190
|
case "headercolor":
|
|
2182
|
-
a.length > 1 && s.push(...a.map((
|
|
2183
|
-
Rn(
|
|
2191
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
|
|
2192
|
+
Rn(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
|
|
2184
2193
|
});
|
|
2185
2194
|
break;
|
|
2186
2195
|
case "note":
|
|
2187
|
-
a.length > 1 && s.push(...a.map((
|
|
2188
|
-
Y(
|
|
2196
|
+
a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
|
|
2197
|
+
Y(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
|
|
2189
2198
|
});
|
|
2190
2199
|
break;
|
|
2191
2200
|
default:
|
|
2192
|
-
s.push(...a.map((
|
|
2201
|
+
s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
|
|
2193
2202
|
}
|
|
2194
2203
|
}
|
|
2195
2204
|
return s;
|
|
@@ -2199,12 +2208,12 @@ class yn {
|
|
|
2199
2208
|
this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
|
|
2200
2209
|
const { name: n, alias: s } = this.declarationNode, i = C(n);
|
|
2201
2210
|
if (i.isOk()) {
|
|
2202
|
-
const r = [...i.unwrap()], a = r.pop(),
|
|
2203
|
-
|
|
2211
|
+
const r = [...i.unwrap()], a = r.pop(), c = Ke(r, this.publicSymbolTable, this.symbolFactory), p = Se(a);
|
|
2212
|
+
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);
|
|
2204
2213
|
}
|
|
2205
2214
|
if (s && Me(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
|
|
2206
2215
|
const r = V(s).unwrap(), a = Se(r);
|
|
2207
|
-
this.publicSymbolTable.has(a) && e.push(new
|
|
2216
|
+
this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
|
|
2208
2217
|
}
|
|
2209
2218
|
return e;
|
|
2210
2219
|
}
|
|
@@ -2212,16 +2221,16 @@ class yn {
|
|
|
2212
2221
|
if (!e)
|
|
2213
2222
|
return [];
|
|
2214
2223
|
if (e instanceof w)
|
|
2215
|
-
return [new
|
|
2224
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
|
|
2216
2225
|
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2217
2226
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2218
2227
|
}
|
|
2219
2228
|
validateFields(e) {
|
|
2220
|
-
return e.length === 0 ? [new
|
|
2229
|
+
return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
|
|
2221
2230
|
if (!n.callee)
|
|
2222
2231
|
return [];
|
|
2223
2232
|
const s = [];
|
|
2224
|
-
n.args.length === 0 && s.push(new
|
|
2233
|
+
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] && !kn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
|
|
2225
2234
|
const i = n.args.slice(1);
|
|
2226
2235
|
return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
|
|
2227
2236
|
});
|
|
@@ -2234,8 +2243,8 @@ class yn {
|
|
|
2234
2243
|
if (r.has(s)) {
|
|
2235
2244
|
const a = r.get(s);
|
|
2236
2245
|
return [
|
|
2237
|
-
new
|
|
2238
|
-
new
|
|
2246
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
|
|
2247
|
+
new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
|
|
2239
2248
|
];
|
|
2240
2249
|
}
|
|
2241
2250
|
r.set(s, i);
|
|
@@ -2245,74 +2254,74 @@ class yn {
|
|
|
2245
2254
|
// This is needed to support legacy inline settings
|
|
2246
2255
|
validateFieldSetting(e) {
|
|
2247
2256
|
if (!e.slice(0, -1).every(Ne) || !e.slice(-1).every((p) => Ne(p) || p instanceof P))
|
|
2248
|
-
return [...e.map((p) => new
|
|
2257
|
+
return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
|
|
2249
2258
|
if (e.length === 0)
|
|
2250
2259
|
return [];
|
|
2251
2260
|
let n;
|
|
2252
2261
|
I.last(e) instanceof P && (n = e.pop());
|
|
2253
|
-
const s =
|
|
2262
|
+
const s = j(n), i = s.getErrors(), r = s.getValue();
|
|
2254
2263
|
for (const p of e) {
|
|
2255
2264
|
const h = V(p).unwrap_or("").toLowerCase();
|
|
2256
2265
|
if (h !== "pk" && h !== "unique") {
|
|
2257
|
-
i.push(new
|
|
2266
|
+
i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
|
|
2258
2267
|
continue;
|
|
2259
2268
|
}
|
|
2260
2269
|
r[h] === void 0 ? r[h] = [p] : r[h].push(p);
|
|
2261
2270
|
}
|
|
2262
|
-
const a = r.pk || [],
|
|
2263
|
-
a.length >= 1 &&
|
|
2271
|
+
const a = r.pk || [], c = r["primary key"] || [];
|
|
2272
|
+
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)));
|
|
2264
2273
|
for (const p in r) {
|
|
2265
2274
|
const h = r[p];
|
|
2266
2275
|
switch (p) {
|
|
2267
2276
|
case "note":
|
|
2268
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2269
|
-
Y(f.value) || i.push(new
|
|
2277
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
|
|
2278
|
+
Y(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
|
|
2270
2279
|
});
|
|
2271
2280
|
break;
|
|
2272
2281
|
case "ref":
|
|
2273
2282
|
h.forEach((f) => {
|
|
2274
|
-
Pn(f.value) || i.push(new
|
|
2283
|
+
Pn(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
|
|
2275
2284
|
});
|
|
2276
2285
|
break;
|
|
2277
2286
|
case "primary key":
|
|
2278
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2279
|
-
|
|
2287
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
|
|
2288
|
+
ce(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
|
|
2280
2289
|
});
|
|
2281
2290
|
break;
|
|
2282
2291
|
case "pk":
|
|
2283
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2284
|
-
f instanceof se && !
|
|
2292
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
|
|
2293
|
+
f instanceof se && !ce(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
|
|
2285
2294
|
});
|
|
2286
2295
|
break;
|
|
2287
2296
|
case "not null":
|
|
2288
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2297
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
|
|
2289
2298
|
const T = r.null || [];
|
|
2290
|
-
h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new
|
|
2291
|
-
|
|
2299
|
+
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) => {
|
|
2300
|
+
ce(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
|
|
2292
2301
|
});
|
|
2293
2302
|
break;
|
|
2294
2303
|
case "null":
|
|
2295
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2296
|
-
|
|
2304
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
|
|
2305
|
+
ce(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
|
|
2297
2306
|
});
|
|
2298
2307
|
break;
|
|
2299
2308
|
case "unique":
|
|
2300
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2301
|
-
f instanceof se && !
|
|
2309
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
|
|
2310
|
+
f instanceof se && !ce(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
|
|
2302
2311
|
});
|
|
2303
2312
|
break;
|
|
2304
2313
|
case "increment":
|
|
2305
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2306
|
-
f instanceof se && !
|
|
2314
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
|
|
2315
|
+
f instanceof se && !ce(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
|
|
2307
2316
|
});
|
|
2308
2317
|
break;
|
|
2309
2318
|
case "default":
|
|
2310
|
-
h.length > 1 && i.push(...h.map((f) => new
|
|
2311
|
-
Dn(f.value) || i.push(new
|
|
2319
|
+
h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
|
|
2320
|
+
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));
|
|
2312
2321
|
});
|
|
2313
2322
|
break;
|
|
2314
2323
|
default:
|
|
2315
|
-
h.forEach((f) => i.push(new
|
|
2324
|
+
h.forEach((f) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
|
|
2316
2325
|
}
|
|
2317
2326
|
}
|
|
2318
2327
|
return i;
|
|
@@ -2327,18 +2336,18 @@ class yn {
|
|
|
2327
2336
|
var r;
|
|
2328
2337
|
return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
|
|
2329
2338
|
});
|
|
2330
|
-
return s.length > 1 && (n.push(...s.map((i) => new
|
|
2339
|
+
return s.length > 1 && (n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
|
|
2331
2340
|
}
|
|
2332
2341
|
}
|
|
2333
2342
|
function kn(t) {
|
|
2334
|
-
if (!(t instanceof J || Je(t) || t instanceof D || t instanceof
|
|
2343
|
+
if (!(t instanceof J || Je(t) || t instanceof D || t instanceof le))
|
|
2335
2344
|
return !1;
|
|
2336
2345
|
if (t instanceof J) {
|
|
2337
2346
|
if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || Y(n) || Ne(n)))
|
|
2338
2347
|
return !1;
|
|
2339
2348
|
t = t.callee;
|
|
2340
2349
|
}
|
|
2341
|
-
for (; t instanceof
|
|
2350
|
+
for (; t instanceof le; ) {
|
|
2342
2351
|
if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ue(n.name)))
|
|
2343
2352
|
return !1;
|
|
2344
2353
|
t = t.array;
|
|
@@ -2357,13 +2366,13 @@ class Sn {
|
|
|
2357
2366
|
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)];
|
|
2358
2367
|
}
|
|
2359
2368
|
validateContext() {
|
|
2360
|
-
return this.declarationNode.parent instanceof A ? [new
|
|
2369
|
+
return this.declarationNode.parent instanceof A ? [new l(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
|
|
2361
2370
|
}
|
|
2362
2371
|
validateName(e) {
|
|
2363
|
-
return e ? Ze(e) ? [] : [new
|
|
2372
|
+
return e ? Ze(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)];
|
|
2364
2373
|
}
|
|
2365
2374
|
validateAlias(e) {
|
|
2366
|
-
return e ? [new
|
|
2375
|
+
return e ? [new l(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
|
|
2367
2376
|
}
|
|
2368
2377
|
registerElement() {
|
|
2369
2378
|
const { name: e } = this.declarationNode;
|
|
@@ -2372,26 +2381,26 @@ class Sn {
|
|
|
2372
2381
|
if (n.isOk()) {
|
|
2373
2382
|
const s = n.unwrap(), i = s.pop(), r = Ke(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
|
|
2374
2383
|
if (r.has(a))
|
|
2375
|
-
return [new
|
|
2384
|
+
return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
|
|
2376
2385
|
r.set(a, this.declarationNode.symbol);
|
|
2377
2386
|
}
|
|
2378
2387
|
return [];
|
|
2379
2388
|
}
|
|
2380
2389
|
validateSettingList(e) {
|
|
2381
|
-
return e ? [new
|
|
2390
|
+
return e ? [new l(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
|
|
2382
2391
|
}
|
|
2383
2392
|
validateBody(e) {
|
|
2384
2393
|
if (!e)
|
|
2385
2394
|
return [];
|
|
2386
2395
|
if (e instanceof w)
|
|
2387
|
-
return [new
|
|
2396
|
+
return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
|
|
2388
2397
|
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
2389
2398
|
return [...this.validateFields(n), ...this.validateSubElements(s)];
|
|
2390
2399
|
}
|
|
2391
2400
|
validateFields(e) {
|
|
2392
2401
|
return e.flatMap((n) => {
|
|
2393
2402
|
const s = [];
|
|
2394
|
-
return n.callee && !C(n.callee).isOk() && s.push(new
|
|
2403
|
+
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;
|
|
2395
2404
|
});
|
|
2396
2405
|
}
|
|
2397
2406
|
validateSubElements(e) {
|
|
@@ -2410,8 +2419,8 @@ class Sn {
|
|
|
2410
2419
|
if (r.has(s)) {
|
|
2411
2420
|
const a = r.get(s);
|
|
2412
2421
|
return [
|
|
2413
|
-
new
|
|
2414
|
-
new
|
|
2422
|
+
new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
|
|
2423
|
+
new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
|
|
2415
2424
|
];
|
|
2416
2425
|
}
|
|
2417
2426
|
r.set(s, i);
|
|
@@ -2447,7 +2456,7 @@ function On(t) {
|
|
|
2447
2456
|
return Me(t);
|
|
2448
2457
|
}
|
|
2449
2458
|
function Me(t) {
|
|
2450
|
-
return t instanceof D && t.expression instanceof
|
|
2459
|
+
return t instanceof D && t.expression instanceof W;
|
|
2451
2460
|
}
|
|
2452
2461
|
function Ke(t, e, n) {
|
|
2453
2462
|
var i;
|
|
@@ -2455,14 +2464,14 @@ function Ke(t, e, n) {
|
|
|
2455
2464
|
let s = e;
|
|
2456
2465
|
for (const r of t) {
|
|
2457
2466
|
let a;
|
|
2458
|
-
const
|
|
2459
|
-
if (s.has(
|
|
2460
|
-
if (a = (i = s.get(
|
|
2467
|
+
const c = We(r);
|
|
2468
|
+
if (s.has(c)) {
|
|
2469
|
+
if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
|
|
2461
2470
|
throw new Error("Expect a symbol table in a schema symbol");
|
|
2462
2471
|
} else {
|
|
2463
2472
|
a = new we();
|
|
2464
2473
|
const p = n.create(_t, { symbolTable: a });
|
|
2465
|
-
s.set(
|
|
2474
|
+
s.set(c, p);
|
|
2466
2475
|
}
|
|
2467
2476
|
s = a;
|
|
2468
2477
|
}
|
|
@@ -2483,7 +2492,7 @@ function Rn(t) {
|
|
|
2483
2492
|
return !1;
|
|
2484
2493
|
return !0;
|
|
2485
2494
|
}
|
|
2486
|
-
function
|
|
2495
|
+
function ce(t) {
|
|
2487
2496
|
return t === void 0;
|
|
2488
2497
|
}
|
|
2489
2498
|
function Dn(t) {
|
|
@@ -2504,22 +2513,22 @@ function Pn(t) {
|
|
|
2504
2513
|
function kt(t) {
|
|
2505
2514
|
return t instanceof Z && t.elementList.every(M);
|
|
2506
2515
|
}
|
|
2507
|
-
function
|
|
2516
|
+
function j(t) {
|
|
2508
2517
|
var s;
|
|
2509
2518
|
const e = {}, n = [];
|
|
2510
2519
|
if (!t)
|
|
2511
|
-
return new
|
|
2520
|
+
return new B({});
|
|
2512
2521
|
for (const i of t.elementList) {
|
|
2513
2522
|
if (!i.name)
|
|
2514
2523
|
continue;
|
|
2515
2524
|
if (i.name instanceof D) {
|
|
2516
|
-
n.push(new
|
|
2525
|
+
n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
|
|
2517
2526
|
continue;
|
|
2518
2527
|
}
|
|
2519
2528
|
const r = (s = me(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
|
|
2520
2529
|
r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
|
|
2521
2530
|
}
|
|
2522
|
-
return new
|
|
2531
|
+
return new B(e, n);
|
|
2523
2532
|
}
|
|
2524
2533
|
class ft {
|
|
2525
2534
|
constructor(e, n) {
|
|
@@ -2540,7 +2549,7 @@ class ft {
|
|
|
2540
2549
|
e.push(...r.validate());
|
|
2541
2550
|
});
|
|
2542
2551
|
const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
|
|
2543
|
-
return n.length > 1 && n.forEach((s) => e.push(new
|
|
2552
|
+
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);
|
|
2544
2553
|
}
|
|
2545
2554
|
}
|
|
2546
2555
|
class ae {
|
|
@@ -2591,7 +2600,7 @@ class ae {
|
|
|
2591
2600
|
var s, i;
|
|
2592
2601
|
if (e)
|
|
2593
2602
|
if (e instanceof D) {
|
|
2594
|
-
if (e.expression instanceof
|
|
2603
|
+
if (e.expression instanceof W && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
|
|
2595
2604
|
return;
|
|
2596
2605
|
this.bindFragments([e], n);
|
|
2597
2606
|
} else
|
|
@@ -2603,7 +2612,7 @@ class ae {
|
|
|
2603
2612
|
bindFragments(e, n) {
|
|
2604
2613
|
if (e.length === 0)
|
|
2605
2614
|
return;
|
|
2606
|
-
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)),
|
|
2615
|
+
const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), c = r !== -1 && kt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
|
|
2607
2616
|
0,
|
|
2608
2617
|
r === -1 ? void 0 : r
|
|
2609
2618
|
);
|
|
@@ -2624,7 +2633,7 @@ class ae {
|
|
|
2624
2633
|
referrer: f
|
|
2625
2634
|
});
|
|
2626
2635
|
}
|
|
2627
|
-
return
|
|
2636
|
+
return c ? c.elementList.forEach(
|
|
2628
2637
|
(f) => this.resolveIndexStack(
|
|
2629
2638
|
[
|
|
2630
2639
|
...T,
|
|
@@ -2652,24 +2661,24 @@ class ae {
|
|
|
2652
2661
|
return;
|
|
2653
2662
|
}
|
|
2654
2663
|
r.references.push(s.referrer), s.referrer.referee = r;
|
|
2655
|
-
let a = r.symbolTable, { kind:
|
|
2664
|
+
let a = r.symbolTable, { kind: c, name: p } = ie(s.index).unwrap();
|
|
2656
2665
|
for (const h of i) {
|
|
2657
2666
|
const { kind: T, name: f } = ie(h.index).unwrap(), N = a.get(h.index);
|
|
2658
2667
|
if (!N) {
|
|
2659
2668
|
this.logError(
|
|
2660
2669
|
h.referrer,
|
|
2661
|
-
`${
|
|
2670
|
+
`${c} '${p}' does not have ${T} '${f}'`,
|
|
2662
2671
|
n
|
|
2663
2672
|
);
|
|
2664
2673
|
return;
|
|
2665
2674
|
}
|
|
2666
|
-
if (
|
|
2675
|
+
if (c = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
|
|
2667
2676
|
break;
|
|
2668
2677
|
a = N.symbolTable;
|
|
2669
2678
|
}
|
|
2670
2679
|
}
|
|
2671
2680
|
logError(e, n, s) {
|
|
2672
|
-
s || this.errors.push(new
|
|
2681
|
+
s || this.errors.push(new l(o.BINDING_ERROR, n, e));
|
|
2673
2682
|
}
|
|
2674
2683
|
}
|
|
2675
2684
|
class Un extends ae {
|
|
@@ -2839,10 +2848,10 @@ class $n {
|
|
|
2839
2848
|
const n = xt(e);
|
|
2840
2849
|
new n(e, this.errors).bind();
|
|
2841
2850
|
}
|
|
2842
|
-
return new
|
|
2851
|
+
return new B(this.ast, this.errors);
|
|
2843
2852
|
}
|
|
2844
2853
|
}
|
|
2845
|
-
class
|
|
2854
|
+
class jn {
|
|
2846
2855
|
constructor(e) {
|
|
2847
2856
|
this.generator = e;
|
|
2848
2857
|
}
|
|
@@ -2850,9 +2859,9 @@ class Wn {
|
|
|
2850
2859
|
return new e(n, this.generator.nextId());
|
|
2851
2860
|
}
|
|
2852
2861
|
}
|
|
2853
|
-
class
|
|
2862
|
+
class Wn {
|
|
2854
2863
|
constructor(e, n) {
|
|
2855
|
-
this.ast = e, this.symbolFactory = new
|
|
2864
|
+
this.ast = e, this.symbolFactory = new jn(n);
|
|
2856
2865
|
}
|
|
2857
2866
|
// Analyzing: Invoking both the validator and binder
|
|
2858
2867
|
analyze() {
|
|
@@ -2860,7 +2869,7 @@ class jn {
|
|
|
2860
2869
|
}
|
|
2861
2870
|
// For invoking the validator only
|
|
2862
2871
|
validate() {
|
|
2863
|
-
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new
|
|
2872
|
+
return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
|
|
2864
2873
|
}
|
|
2865
2874
|
}
|
|
2866
2875
|
function pt(t, e) {
|
|
@@ -2896,7 +2905,7 @@ function St(t) {
|
|
|
2896
2905
|
}
|
|
2897
2906
|
throw new Error("Invalid relation op");
|
|
2898
2907
|
}
|
|
2899
|
-
function
|
|
2908
|
+
function y(t) {
|
|
2900
2909
|
return {
|
|
2901
2910
|
start: {
|
|
2902
2911
|
offset: t.startPos.offset,
|
|
@@ -2932,15 +2941,15 @@ function Rt(t, e) {
|
|
|
2932
2941
|
function Dt(t, e) {
|
|
2933
2942
|
if (Array.isArray(t)) {
|
|
2934
2943
|
const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
|
|
2935
|
-
return I.zip(i, r).every(([a,
|
|
2944
|
+
return I.zip(i, r).every(([a, c]) => a === c);
|
|
2936
2945
|
}
|
|
2937
2946
|
const n = t.id, s = e.id;
|
|
2938
2947
|
return n === s;
|
|
2939
2948
|
}
|
|
2940
2949
|
function Ee(t) {
|
|
2941
2950
|
const e = t.split(`
|
|
2942
|
-
`), n = e.
|
|
2943
|
-
return
|
|
2951
|
+
`), n = e.slice(e.findIndex((r) => r.trimStart() !== "")), s = n.filter((r) => r.trimStart()), i = Math.min(...s.map((r) => r.length - r.trimStart().length));
|
|
2952
|
+
return n.map((r) => r.slice(i)).join(`
|
|
2944
2953
|
`);
|
|
2945
2954
|
}
|
|
2946
2955
|
class Pt {
|
|
@@ -2948,7 +2957,7 @@ class Pt {
|
|
|
2948
2957
|
this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
|
|
2949
2958
|
}
|
|
2950
2959
|
interpret() {
|
|
2951
|
-
this.table.token =
|
|
2960
|
+
this.table.token = y(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
|
|
2952
2961
|
const e = [
|
|
2953
2962
|
...this.interpretName(this.declarationNode.name),
|
|
2954
2963
|
...this.interpretAlias(this.declarationNode.alias),
|
|
@@ -2968,7 +2977,7 @@ class Pt {
|
|
|
2968
2977
|
}
|
|
2969
2978
|
interpretName(e) {
|
|
2970
2979
|
const { name: n, schemaName: s } = be(e);
|
|
2971
|
-
return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new
|
|
2980
|
+
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, []);
|
|
2972
2981
|
}
|
|
2973
2982
|
interpretAlias(e) {
|
|
2974
2983
|
if (!e)
|
|
@@ -2985,12 +2994,12 @@ class Pt {
|
|
|
2985
2994
|
}
|
|
2986
2995
|
interpretSettingList(e) {
|
|
2987
2996
|
var i, r, a;
|
|
2988
|
-
const n =
|
|
2997
|
+
const n = j(e).getValue();
|
|
2989
2998
|
this.table.headerColor = (i = n.headercolor) != null && i.length ? Ot((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
|
|
2990
2999
|
const [s] = n.note || [];
|
|
2991
3000
|
return this.table.note = s && {
|
|
2992
3001
|
value: Q(s == null ? void 0 : s.value).map(Ee).unwrap(),
|
|
2993
|
-
token:
|
|
3002
|
+
token: y(s)
|
|
2994
3003
|
}, [];
|
|
2995
3004
|
}
|
|
2996
3005
|
interpretBody(e) {
|
|
@@ -3004,7 +3013,7 @@ class Pt {
|
|
|
3004
3013
|
case "note":
|
|
3005
3014
|
return this.table.note = {
|
|
3006
3015
|
value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(Ee).unwrap(),
|
|
3007
|
-
token:
|
|
3016
|
+
token: y(n)
|
|
3008
3017
|
}, [];
|
|
3009
3018
|
case "indexes":
|
|
3010
3019
|
return this.interpretIndexes(n);
|
|
@@ -3016,25 +3025,25 @@ class Pt {
|
|
|
3016
3025
|
return e.flatMap((n) => this.interpretColumn(n));
|
|
3017
3026
|
}
|
|
3018
3027
|
interpretColumn(e) {
|
|
3019
|
-
var a,
|
|
3028
|
+
var a, c, p, h, T, f, N, g;
|
|
3020
3029
|
const n = [], s = {};
|
|
3021
3030
|
s.name = V(e.callee).unwrap();
|
|
3022
3031
|
const i = Yn(e.args[0]);
|
|
3023
|
-
s.type = i.getValue(), n.push(...i.getErrors()), s.token =
|
|
3032
|
+
s.type = i.getValue(), n.push(...i.getErrors()), s.token = y(e), s.inline_refs = [];
|
|
3024
3033
|
const r = e.args.slice(1);
|
|
3025
3034
|
if (I.last(r) instanceof P) {
|
|
3026
|
-
const _ =
|
|
3027
|
-
s.pk = !!((a = _.pk) != null && a.length) || !!((
|
|
3035
|
+
const _ = j(r.pop()).getValue();
|
|
3036
|
+
s.pk = !!((a = _.pk) != null && a.length) || !!((c = _["primary key"]) != null && c.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault = zn((N = (f = _.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
|
|
3028
3037
|
const K = (g = _.note) == null ? void 0 : g.at(0);
|
|
3029
3038
|
s.note = K && {
|
|
3030
3039
|
value: Q(K.value).map(Ee).unwrap(),
|
|
3031
|
-
token:
|
|
3040
|
+
token: y(K)
|
|
3032
3041
|
};
|
|
3033
3042
|
const Ie = _.ref || [];
|
|
3034
3043
|
s.inline_refs = Ie.flatMap((z) => {
|
|
3035
3044
|
const [nt] = $e(z.value.expression);
|
|
3036
3045
|
if (Dt(nt, e.symbol))
|
|
3037
|
-
return n.push(new
|
|
3046
|
+
return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
|
|
3038
3047
|
const ye = z.value.op, ee = C(z.value.expression).unwrap();
|
|
3039
3048
|
let fe;
|
|
3040
3049
|
if (ee.length === 1) {
|
|
@@ -3044,7 +3053,7 @@ class Pt {
|
|
|
3044
3053
|
tableName: this.table.name,
|
|
3045
3054
|
fieldNames: [oe],
|
|
3046
3055
|
relation: ye.value,
|
|
3047
|
-
token:
|
|
3056
|
+
token: y(z)
|
|
3048
3057
|
};
|
|
3049
3058
|
} else if (ee.length === 2) {
|
|
3050
3059
|
const [oe, Le] = ee;
|
|
@@ -3053,7 +3062,7 @@ class Pt {
|
|
|
3053
3062
|
tableName: oe,
|
|
3054
3063
|
fieldNames: [Le],
|
|
3055
3064
|
relation: ye.value,
|
|
3056
|
-
token:
|
|
3065
|
+
token: y(z)
|
|
3057
3066
|
};
|
|
3058
3067
|
} else if (ee.length === 3) {
|
|
3059
3068
|
const [oe, Le, it] = ee;
|
|
@@ -3062,17 +3071,17 @@ class Pt {
|
|
|
3062
3071
|
tableName: Le,
|
|
3063
3072
|
fieldNames: [it],
|
|
3064
3073
|
relation: ye.value,
|
|
3065
|
-
token:
|
|
3074
|
+
token: y(z)
|
|
3066
3075
|
};
|
|
3067
3076
|
} else {
|
|
3068
|
-
n.push(new
|
|
3077
|
+
n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", z));
|
|
3069
3078
|
const oe = ee.pop(), Le = ee.pop();
|
|
3070
3079
|
fe = {
|
|
3071
3080
|
schemaName: ee.join("."),
|
|
3072
3081
|
tableName: Le,
|
|
3073
3082
|
fieldNames: [oe],
|
|
3074
3083
|
relation: ye.value,
|
|
3075
|
-
token:
|
|
3084
|
+
token: y(z)
|
|
3076
3085
|
};
|
|
3077
3086
|
}
|
|
3078
3087
|
const st = this.registerInlineRefToEnv(e, nt, fe, z);
|
|
@@ -3083,17 +3092,17 @@ class Pt {
|
|
|
3083
3092
|
}
|
|
3084
3093
|
interpretIndexes(e) {
|
|
3085
3094
|
return this.table.indexes.push(...e.body.body.map((n) => {
|
|
3086
|
-
var a,
|
|
3095
|
+
var a, c, p, h, T, f, N;
|
|
3087
3096
|
const s = { columns: [] }, i = n;
|
|
3088
|
-
s.token =
|
|
3097
|
+
s.token = y(e);
|
|
3089
3098
|
const r = [i.callee, ...i.args];
|
|
3090
3099
|
if (I.last(r) instanceof P) {
|
|
3091
|
-
const g =
|
|
3092
|
-
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((
|
|
3100
|
+
const g = j(r.pop()).getValue();
|
|
3101
|
+
s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = Q((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
|
|
3093
3102
|
const _ = (T = g.note) == null ? void 0 : T.at(0);
|
|
3094
3103
|
s.note = _ && {
|
|
3095
3104
|
value: Q(_.value).unwrap(),
|
|
3096
|
-
token:
|
|
3105
|
+
token: y(_)
|
|
3097
3106
|
}, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
|
|
3098
3107
|
}
|
|
3099
3108
|
return r.flatMap((g) => {
|
|
@@ -3122,8 +3131,8 @@ class Pt {
|
|
|
3122
3131
|
const r = Rt(e.symbol, n);
|
|
3123
3132
|
if (this.env.refIds[r])
|
|
3124
3133
|
return [
|
|
3125
|
-
new
|
|
3126
|
-
new
|
|
3134
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
|
|
3135
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
|
|
3127
3136
|
];
|
|
3128
3137
|
const a = St(s.relation);
|
|
3129
3138
|
return this.env.refIds[r] = i, this.env.ref.set(i, {
|
|
@@ -3139,7 +3148,7 @@ class Pt {
|
|
|
3139
3148
|
schemaName: this.table.schemaName,
|
|
3140
3149
|
tableName: this.table.name,
|
|
3141
3150
|
fieldNames: [X(e.callee).unwrap()],
|
|
3142
|
-
token:
|
|
3151
|
+
token: y(e),
|
|
3143
3152
|
relation: a[0]
|
|
3144
3153
|
}
|
|
3145
3154
|
]
|
|
@@ -3150,17 +3159,17 @@ function Yn(t) {
|
|
|
3150
3159
|
let e = null;
|
|
3151
3160
|
t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value : Y(r) ? Q(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
|
|
3152
3161
|
let n = "";
|
|
3153
|
-
for (; t instanceof
|
|
3162
|
+
for (; t instanceof le; )
|
|
3154
3163
|
n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
|
|
3155
3164
|
const { name: s, schemaName: i } = be(t);
|
|
3156
|
-
return i.length > 1 ? new
|
|
3165
|
+
return i.length > 1 ? new B(
|
|
3157
3166
|
{
|
|
3158
3167
|
schemaName: i.length === 0 ? null : i[0],
|
|
3159
3168
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3160
3169
|
args: e
|
|
3161
3170
|
},
|
|
3162
|
-
[new
|
|
3163
|
-
) : new
|
|
3171
|
+
[new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
|
|
3172
|
+
) : new B({
|
|
3164
3173
|
schemaName: i.length === 0 ? null : i[0],
|
|
3165
3174
|
type_name: `${s}${n}${e ? `(${e})` : ""}`,
|
|
3166
3175
|
args: e
|
|
@@ -3204,7 +3213,7 @@ class Qn {
|
|
|
3204
3213
|
this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
|
|
3205
3214
|
}
|
|
3206
3215
|
interpret() {
|
|
3207
|
-
return this.note.token =
|
|
3216
|
+
return this.note.token = y(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
|
|
3208
3217
|
...this.interpretName(this.declarationNode.name),
|
|
3209
3218
|
...this.interpretSettingList(this.declarationNode.attributeList),
|
|
3210
3219
|
...this.interpretBody(this.declarationNode.body)
|
|
@@ -3216,13 +3225,13 @@ class Qn {
|
|
|
3216
3225
|
}
|
|
3217
3226
|
interpretSettingList(e) {
|
|
3218
3227
|
var s, i, r;
|
|
3219
|
-
const n =
|
|
3228
|
+
const n = j(e).getValue();
|
|
3220
3229
|
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, [];
|
|
3221
3230
|
}
|
|
3222
3231
|
interpretBody(e) {
|
|
3223
3232
|
const [n, s] = I.partition(e.body, (i) => i instanceof w);
|
|
3224
3233
|
return n.length !== 1 || s.length > 0 ? [
|
|
3225
|
-
new
|
|
3234
|
+
new l(o.INVALID_NOTE, "Invalid note syntax", e)
|
|
3226
3235
|
] : [...this.interpretNote(n[0])];
|
|
3227
3236
|
}
|
|
3228
3237
|
interpretNote(e) {
|
|
@@ -3235,11 +3244,11 @@ class Ut {
|
|
|
3235
3244
|
this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
|
|
3236
3245
|
}
|
|
3237
3246
|
interpret() {
|
|
3238
|
-
return this.ref.token =
|
|
3247
|
+
return this.ref.token = y(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3239
3248
|
}
|
|
3240
3249
|
interpretName(e) {
|
|
3241
3250
|
const n = [], s = C(this.declarationNode.name).unwrap_or([]);
|
|
3242
|
-
return this.ref.name = s.pop() || null, s.length > 1 && n.push(new
|
|
3251
|
+
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;
|
|
3243
3252
|
}
|
|
3244
3253
|
interpretBody(e) {
|
|
3245
3254
|
return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
|
|
@@ -3248,15 +3257,15 @@ class Ut {
|
|
|
3248
3257
|
var h, T, f, N;
|
|
3249
3258
|
const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
|
|
3250
3259
|
if (Dt(r, a))
|
|
3251
|
-
return [new
|
|
3252
|
-
const
|
|
3253
|
-
if (this.env.refIds[
|
|
3260
|
+
return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
|
|
3261
|
+
const c = Rt(r, a);
|
|
3262
|
+
if (this.env.refIds[c])
|
|
3254
3263
|
return [
|
|
3255
|
-
new
|
|
3256
|
-
new
|
|
3264
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
|
|
3265
|
+
new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
|
|
3257
3266
|
];
|
|
3258
3267
|
if (e.args[0]) {
|
|
3259
|
-
const g =
|
|
3268
|
+
const g = j(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
|
|
3260
3269
|
this.ref.onDelete = _ instanceof $ ? me(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
|
|
3261
3270
|
const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
|
|
3262
3271
|
this.ref.onUpdate = K instanceof $ ? me(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
|
|
@@ -3266,14 +3275,14 @@ class Ut {
|
|
|
3266
3275
|
{
|
|
3267
3276
|
...pt(s, this.container),
|
|
3268
3277
|
relation: p[0],
|
|
3269
|
-
token:
|
|
3278
|
+
token: y(s)
|
|
3270
3279
|
},
|
|
3271
3280
|
{
|
|
3272
3281
|
...pt(i, this.container),
|
|
3273
3282
|
relation: p[1],
|
|
3274
|
-
token:
|
|
3283
|
+
token: y(i)
|
|
3275
3284
|
}
|
|
3276
|
-
], this.env.refIds[
|
|
3285
|
+
], this.env.refIds[c] = this.declarationNode, [];
|
|
3277
3286
|
}
|
|
3278
3287
|
}
|
|
3279
3288
|
class Mt {
|
|
@@ -3282,24 +3291,24 @@ class Mt {
|
|
|
3282
3291
|
}
|
|
3283
3292
|
interpret() {
|
|
3284
3293
|
const e = [];
|
|
3285
|
-
return this.tableGroup.token =
|
|
3294
|
+
return this.tableGroup.token = y(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
|
|
3286
3295
|
...this.interpretName(this.declarationNode.name),
|
|
3287
3296
|
...this.interpretBody(this.declarationNode.body)
|
|
3288
3297
|
), e;
|
|
3289
3298
|
}
|
|
3290
3299
|
interpretName(e) {
|
|
3291
3300
|
const n = [], { name: s, schemaName: i } = be(e);
|
|
3292
|
-
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new
|
|
3301
|
+
return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
|
|
3293
3302
|
}
|
|
3294
3303
|
interpretBody(e) {
|
|
3295
3304
|
const n = [];
|
|
3296
3305
|
return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
|
|
3297
3306
|
const i = C(s.callee).unwrap();
|
|
3298
|
-
i.length > 2 && n.push(new
|
|
3307
|
+
i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
|
|
3299
3308
|
const r = he(s.callee).unwrap().pop().referee.id;
|
|
3300
3309
|
if (this.env.groupOfTable[r]) {
|
|
3301
|
-
const a = this.env.groupOfTable[r], { schemaName:
|
|
3302
|
-
n.push(new
|
|
3310
|
+
const a = this.env.groupOfTable[r], { schemaName: c, name: p } = this.env.tableGroups.get(a), h = c ? `${c}.${p}` : p;
|
|
3311
|
+
n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
|
|
3303
3312
|
} else
|
|
3304
3313
|
this.env.groupOfTable[r] = this.declarationNode;
|
|
3305
3314
|
return {
|
|
@@ -3314,21 +3323,21 @@ class Ft {
|
|
|
3314
3323
|
this.declarationNode = e, this.env = n, this.enum = { values: [] };
|
|
3315
3324
|
}
|
|
3316
3325
|
interpret() {
|
|
3317
|
-
return this.enum.token =
|
|
3326
|
+
return this.enum.token = y(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3318
3327
|
}
|
|
3319
3328
|
interpretName(e) {
|
|
3320
3329
|
const { name: n, schemaName: s } = be(e);
|
|
3321
|
-
return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new
|
|
3330
|
+
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, []);
|
|
3322
3331
|
}
|
|
3323
3332
|
interpretBody(e) {
|
|
3324
3333
|
return e.body.flatMap((n) => {
|
|
3325
|
-
var
|
|
3334
|
+
var c;
|
|
3326
3335
|
const s = n, i = {};
|
|
3327
|
-
i.token =
|
|
3328
|
-
const a = (
|
|
3336
|
+
i.token = y(s), i.name = X(s.callee).unwrap();
|
|
3337
|
+
const a = (c = j(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
|
|
3329
3338
|
return i.note = a && {
|
|
3330
3339
|
value: Q(a.value).map(Ee).unwrap(),
|
|
3331
|
-
token:
|
|
3340
|
+
token: y(a)
|
|
3332
3341
|
}, this.enum.values.push(i), [];
|
|
3333
3342
|
});
|
|
3334
3343
|
}
|
|
@@ -3338,7 +3347,7 @@ class qn {
|
|
|
3338
3347
|
this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
|
|
3339
3348
|
}
|
|
3340
3349
|
interpret() {
|
|
3341
|
-
return this.env.project.set(this.declarationNode, this.project), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3350
|
+
return this.env.project.set(this.declarationNode, this.project), this.project.token = y(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
|
|
3342
3351
|
}
|
|
3343
3352
|
interpretName(e) {
|
|
3344
3353
|
if (!e)
|
|
@@ -3370,7 +3379,7 @@ class qn {
|
|
|
3370
3379
|
case "note":
|
|
3371
3380
|
return this.project.note = {
|
|
3372
3381
|
value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(Ee).unwrap(),
|
|
3373
|
-
token:
|
|
3382
|
+
token: y(s)
|
|
3374
3383
|
}, [];
|
|
3375
3384
|
default:
|
|
3376
3385
|
return this.project[s.type.value.toLowerCase()] = Q(s.body.callee).unwrap(), [];
|
|
@@ -3412,7 +3421,7 @@ class Hn {
|
|
|
3412
3421
|
return [];
|
|
3413
3422
|
}
|
|
3414
3423
|
});
|
|
3415
|
-
return new
|
|
3424
|
+
return new B(Jn(this.env), e);
|
|
3416
3425
|
}
|
|
3417
3426
|
}
|
|
3418
3427
|
function Jn(t) {
|
|
@@ -3427,7 +3436,7 @@ function Jn(t) {
|
|
|
3427
3436
|
project: Array.from(t.project.values())[0] || {}
|
|
3428
3437
|
};
|
|
3429
3438
|
}
|
|
3430
|
-
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 || {}),
|
|
3439
|
+
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 || {}), k = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(k || {});
|
|
3431
3440
|
function Ae(t) {
|
|
3432
3441
|
switch (t) {
|
|
3433
3442
|
case m.Schema:
|
|
@@ -3491,12 +3500,12 @@ class Bt {
|
|
|
3491
3500
|
}
|
|
3492
3501
|
provideCompletionItems(e, n) {
|
|
3493
3502
|
var T, f;
|
|
3494
|
-
const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s),
|
|
3503
|
+
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];
|
|
3495
3504
|
if ([
|
|
3496
3505
|
...(r == null ? void 0 : r.trailingTrivia) || [],
|
|
3497
3506
|
...(r == null ? void 0 : r.leadingTrivia) || [],
|
|
3498
|
-
...(
|
|
3499
|
-
].find((N) =>
|
|
3507
|
+
...(c == null ? void 0 : c.leadingTrivia) || []
|
|
3508
|
+
].find((N) => Wt(N) && ge(s, N)))
|
|
3500
3509
|
return O();
|
|
3501
3510
|
if (a === void 0)
|
|
3502
3511
|
return Tt();
|
|
@@ -3572,12 +3581,12 @@ function Be(t, e, n, s) {
|
|
|
3572
3581
|
const r = { suggestions: [] };
|
|
3573
3582
|
for (; i; ) {
|
|
3574
3583
|
if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
|
|
3575
|
-
const { symbol:
|
|
3584
|
+
const { symbol: c } = i;
|
|
3576
3585
|
r.suggestions.push(
|
|
3577
|
-
...t.symbol.members(
|
|
3586
|
+
...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
|
|
3578
3587
|
label: p,
|
|
3579
3588
|
insertText: p,
|
|
3580
|
-
insertTextRules:
|
|
3589
|
+
insertTextRules: k.KeepWhitespace,
|
|
3581
3590
|
kind: Ae(h),
|
|
3582
3591
|
sortText: Ae(h).toString().padStart(2, "0"),
|
|
3583
3592
|
range: void 0
|
|
@@ -3641,14 +3650,14 @@ function Nt(t, e) {
|
|
|
3641
3650
|
label: "headercolor",
|
|
3642
3651
|
insertText: "headercolor: ",
|
|
3643
3652
|
kind: L.Field,
|
|
3644
|
-
insertTextRules:
|
|
3653
|
+
insertTextRules: k.KeepWhitespace,
|
|
3645
3654
|
range: void 0
|
|
3646
3655
|
},
|
|
3647
3656
|
{
|
|
3648
3657
|
label: "note",
|
|
3649
3658
|
insertText: "note: ",
|
|
3650
3659
|
kind: L.Field,
|
|
3651
|
-
insertTextRules:
|
|
3660
|
+
insertTextRules: k.KeepWhitespace,
|
|
3652
3661
|
range: void 0
|
|
3653
3662
|
}
|
|
3654
3663
|
]
|
|
@@ -3664,21 +3673,21 @@ function Nt(t, e) {
|
|
|
3664
3673
|
label: i,
|
|
3665
3674
|
insertText: i,
|
|
3666
3675
|
kind: L.Property,
|
|
3667
|
-
insertTextRules:
|
|
3676
|
+
insertTextRules: k.KeepWhitespace,
|
|
3668
3677
|
range: void 0
|
|
3669
3678
|
})),
|
|
3670
3679
|
...["ref", "default"].map((i) => ({
|
|
3671
3680
|
label: i,
|
|
3672
3681
|
insertText: `${i}: `,
|
|
3673
3682
|
kind: L.Property,
|
|
3674
|
-
insertTextRules:
|
|
3683
|
+
insertTextRules: k.KeepWhitespace,
|
|
3675
3684
|
range: void 0
|
|
3676
3685
|
})),
|
|
3677
3686
|
{
|
|
3678
3687
|
label: "note",
|
|
3679
3688
|
insertText: "note: ",
|
|
3680
3689
|
kind: L.Property,
|
|
3681
|
-
insertTextRules:
|
|
3690
|
+
insertTextRules: k.KeepWhitespace,
|
|
3682
3691
|
range: void 0
|
|
3683
3692
|
}
|
|
3684
3693
|
]
|
|
@@ -3690,7 +3699,7 @@ function Nt(t, e) {
|
|
|
3690
3699
|
label: "note",
|
|
3691
3700
|
insertText: "note: ",
|
|
3692
3701
|
kind: L.Property,
|
|
3693
|
-
insertTextRules:
|
|
3702
|
+
insertTextRules: k.KeepWhitespace,
|
|
3694
3703
|
range: void 0
|
|
3695
3704
|
}
|
|
3696
3705
|
]
|
|
@@ -3701,7 +3710,7 @@ function Nt(t, e) {
|
|
|
3701
3710
|
...["unique", "pk"].map((i) => ({
|
|
3702
3711
|
label: i,
|
|
3703
3712
|
insertText: i,
|
|
3704
|
-
insertTextRules:
|
|
3713
|
+
insertTextRules: k.KeepWhitespace,
|
|
3705
3714
|
kind: L.Property,
|
|
3706
3715
|
range: void 0
|
|
3707
3716
|
})),
|
|
@@ -3709,7 +3718,7 @@ function Nt(t, e) {
|
|
|
3709
3718
|
label: i,
|
|
3710
3719
|
insertText: `${i}: `,
|
|
3711
3720
|
kind: L.Property,
|
|
3712
|
-
insertTextRules:
|
|
3721
|
+
insertTextRules: k.KeepWhitespace,
|
|
3713
3722
|
range: void 0
|
|
3714
3723
|
}))
|
|
3715
3724
|
]
|
|
@@ -3720,7 +3729,7 @@ function Nt(t, e) {
|
|
|
3720
3729
|
label: i,
|
|
3721
3730
|
insertText: `${i}: `,
|
|
3722
3731
|
kind: L.Property,
|
|
3723
|
-
insertTextRules:
|
|
3732
|
+
insertTextRules: k.KeepWhitespace,
|
|
3724
3733
|
range: void 0
|
|
3725
3734
|
}))
|
|
3726
3735
|
};
|
|
@@ -3736,7 +3745,7 @@ function Kn(t, e, n) {
|
|
|
3736
3745
|
label: s,
|
|
3737
3746
|
insertText: s,
|
|
3738
3747
|
kind: L.Value,
|
|
3739
|
-
insertTextRules:
|
|
3748
|
+
insertTextRules: k.KeepWhitespace,
|
|
3740
3749
|
range: void 0
|
|
3741
3750
|
}))
|
|
3742
3751
|
};
|
|
@@ -3746,7 +3755,7 @@ function Kn(t, e, n) {
|
|
|
3746
3755
|
label: s,
|
|
3747
3756
|
insertText: `${s}`,
|
|
3748
3757
|
kind: L.Value,
|
|
3749
|
-
insertTextRules:
|
|
3758
|
+
insertTextRules: k.KeepWhitespace,
|
|
3750
3759
|
range: void 0
|
|
3751
3760
|
}))
|
|
3752
3761
|
};
|
|
@@ -3793,7 +3802,7 @@ function Tt() {
|
|
|
3793
3802
|
suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
|
|
3794
3803
|
label: t,
|
|
3795
3804
|
insertText: t,
|
|
3796
|
-
insertTextRules:
|
|
3805
|
+
insertTextRules: k.KeepWhitespace,
|
|
3797
3806
|
kind: L.Keyword,
|
|
3798
3807
|
range: void 0
|
|
3799
3808
|
}))
|
|
@@ -3812,7 +3821,7 @@ function ts(t, e, n) {
|
|
|
3812
3821
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3813
3822
|
label: i,
|
|
3814
3823
|
insertText: i,
|
|
3815
|
-
insertTextRules:
|
|
3824
|
+
insertTextRules: k.KeepWhitespace,
|
|
3816
3825
|
kind: L.Keyword,
|
|
3817
3826
|
range: void 0
|
|
3818
3827
|
}))
|
|
@@ -3822,7 +3831,7 @@ function ts(t, e, n) {
|
|
|
3822
3831
|
suggestions: ["Note", "indexes"].map((i) => ({
|
|
3823
3832
|
label: i,
|
|
3824
3833
|
insertText: i,
|
|
3825
|
-
insertTextRules:
|
|
3834
|
+
insertTextRules: k.KeepWhitespace,
|
|
3826
3835
|
kind: L.Keyword,
|
|
3827
3836
|
range: void 0
|
|
3828
3837
|
}))
|
|
@@ -3833,7 +3842,7 @@ function ns(t, e, n) {
|
|
|
3833
3842
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3834
3843
|
label: i,
|
|
3835
3844
|
insertText: i,
|
|
3836
|
-
insertTextRules:
|
|
3845
|
+
insertTextRules: k.KeepWhitespace,
|
|
3837
3846
|
kind: L.Keyword,
|
|
3838
3847
|
range: void 0
|
|
3839
3848
|
}))
|
|
@@ -3841,7 +3850,7 @@ function ns(t, e, n) {
|
|
|
3841
3850
|
suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
|
|
3842
3851
|
label: i,
|
|
3843
3852
|
insertText: i,
|
|
3844
|
-
insertTextRules:
|
|
3853
|
+
insertTextRules: k.KeepWhitespace,
|
|
3845
3854
|
kind: L.Keyword,
|
|
3846
3855
|
range: void 0
|
|
3847
3856
|
}))
|
|
@@ -3864,7 +3873,7 @@ function ss(t) {
|
|
|
3864
3873
|
return s !== m.Table && s !== m.Schema ? [] : {
|
|
3865
3874
|
label: i,
|
|
3866
3875
|
insertText: i,
|
|
3867
|
-
insertTextRules:
|
|
3876
|
+
insertTextRules: k.KeepWhitespace,
|
|
3868
3877
|
kind: Ae(s),
|
|
3869
3878
|
range: void 0
|
|
3870
3879
|
};
|
|
@@ -3937,7 +3946,7 @@ function rs(t, e) {
|
|
|
3937
3946
|
].map((n) => ({
|
|
3938
3947
|
label: n,
|
|
3939
3948
|
insertText: n,
|
|
3940
|
-
insertTextRules:
|
|
3949
|
+
insertTextRules: k.KeepWhitespace,
|
|
3941
3950
|
kind: L.TypeParameter,
|
|
3942
3951
|
sortText: L.TypeParameter.toString().padStart(2, "0"),
|
|
3943
3952
|
range: void 0
|
|
@@ -3959,11 +3968,11 @@ function Ct(t, e) {
|
|
|
3959
3968
|
const a = ie(r).unwrap_or(void 0);
|
|
3960
3969
|
if (a === void 0)
|
|
3961
3970
|
return [];
|
|
3962
|
-
const { name:
|
|
3971
|
+
const { name: c } = a;
|
|
3963
3972
|
return {
|
|
3964
|
-
label:
|
|
3965
|
-
insertText:
|
|
3966
|
-
insertTextRules:
|
|
3973
|
+
label: c,
|
|
3974
|
+
insertText: c,
|
|
3975
|
+
insertTextRules: k.KeepWhitespace,
|
|
3967
3976
|
kind: Ae(m.Column),
|
|
3968
3977
|
range: void 0
|
|
3969
3978
|
};
|
|
@@ -3984,9 +3993,9 @@ class Xt {
|
|
|
3984
3993
|
var a;
|
|
3985
3994
|
const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
|
|
3986
3995
|
for (; r.length !== 0; ) {
|
|
3987
|
-
const
|
|
3988
|
-
if ((a =
|
|
3989
|
-
const { startPos: p, endPos: h } =
|
|
3996
|
+
const c = r.pop();
|
|
3997
|
+
if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [de.PRIMARY_EXPRESSION, de.VARIABLE].includes(c == null ? void 0 : c.kind)) {
|
|
3998
|
+
const { startPos: p, endPos: h } = c.referee.declaration;
|
|
3990
3999
|
return [
|
|
3991
4000
|
{
|
|
3992
4001
|
range: {
|
|
@@ -4016,9 +4025,9 @@ class $t {
|
|
|
4016
4025
|
de.FUNCTION_APPLICATION,
|
|
4017
4026
|
de.PRIMARY_EXPRESSION
|
|
4018
4027
|
].includes(a == null ? void 0 : a.kind)) {
|
|
4019
|
-
const { symbol:
|
|
4020
|
-
if (
|
|
4021
|
-
return
|
|
4028
|
+
const { symbol: c } = a;
|
|
4029
|
+
if (c != null && c.references.length)
|
|
4030
|
+
return c.references.map(({ startPos: p, endPos: h }) => ({
|
|
4022
4031
|
range: {
|
|
4023
4032
|
startColumn: p.column + 1,
|
|
4024
4033
|
startLineNumber: p.line + 1,
|
|
@@ -4032,16 +4041,16 @@ class $t {
|
|
|
4032
4041
|
return [];
|
|
4033
4042
|
}
|
|
4034
4043
|
}
|
|
4035
|
-
const
|
|
4044
|
+
const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4036
4045
|
__proto__: null,
|
|
4037
|
-
CompletionItemInsertTextRule:
|
|
4046
|
+
CompletionItemInsertTextRule: k,
|
|
4038
4047
|
CompletionItemKind: L,
|
|
4039
4048
|
DBMLCompletionItemProvider: Bt,
|
|
4040
4049
|
DBMLDefinitionProvider: Xt,
|
|
4041
4050
|
DBMLReferencesProvider: $t
|
|
4042
4051
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4043
4052
|
var R = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(R || {});
|
|
4044
|
-
class
|
|
4053
|
+
class ls {
|
|
4045
4054
|
constructor() {
|
|
4046
4055
|
this.source = "", this.cache = new Array(
|
|
4047
4056
|
16
|
|
@@ -4061,7 +4070,7 @@ class cs {
|
|
|
4061
4070
|
_: this.createQuery(
|
|
4062
4071
|
0,
|
|
4063
4072
|
() => {
|
|
4064
|
-
const e = new
|
|
4073
|
+
const e = new cn(this.source).lex().chain((n) => new hn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
|
|
4065
4074
|
return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Hn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
|
|
4066
4075
|
}
|
|
4067
4076
|
),
|
|
@@ -4097,33 +4106,33 @@ class cs {
|
|
|
4097
4106
|
return [this.parse.ast()];
|
|
4098
4107
|
const r = n[s].start;
|
|
4099
4108
|
let a = this.parse.ast();
|
|
4100
|
-
const
|
|
4109
|
+
const c = [a];
|
|
4101
4110
|
for (; ; ) {
|
|
4102
4111
|
const h = on(a).find((T) => ge(r, T));
|
|
4103
|
-
if (h === void 0 || h instanceof
|
|
4112
|
+
if (h === void 0 || h instanceof F)
|
|
4104
4113
|
break;
|
|
4105
|
-
|
|
4114
|
+
c.push(h), a = h;
|
|
4106
4115
|
}
|
|
4107
4116
|
if ((i == null ? void 0 : i.kind) === u.COLON)
|
|
4108
|
-
return
|
|
4109
|
-
for (;
|
|
4117
|
+
return c;
|
|
4118
|
+
for (; c.length > 0; ) {
|
|
4110
4119
|
let p = !1;
|
|
4111
|
-
const h = I.last(
|
|
4120
|
+
const h = I.last(c);
|
|
4112
4121
|
if (h instanceof w) {
|
|
4113
4122
|
const T = this.parse.source();
|
|
4114
4123
|
for (let f = h.end; f < e; f += 1)
|
|
4115
4124
|
T[f] === `
|
|
4116
|
-
` && (
|
|
4125
|
+
` && (c.pop(), p = !0);
|
|
4117
4126
|
} else
|
|
4118
|
-
h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (
|
|
4127
|
+
h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof $ || h.end < e && (c.pop(), p = !0);
|
|
4119
4128
|
if (p) {
|
|
4120
|
-
const T = I.last(
|
|
4121
|
-
T instanceof A && T.end <= e &&
|
|
4129
|
+
const T = I.last(c);
|
|
4130
|
+
T instanceof A && T.end <= e && c.pop();
|
|
4122
4131
|
}
|
|
4123
4132
|
if (!p)
|
|
4124
4133
|
break;
|
|
4125
4134
|
}
|
|
4126
|
-
return
|
|
4135
|
+
return c;
|
|
4127
4136
|
}
|
|
4128
4137
|
),
|
|
4129
4138
|
token: this.createQuery(
|
|
@@ -4195,14 +4204,14 @@ class cs {
|
|
|
4195
4204
|
if (!((i = r.symbol) != null && i.symbolTable))
|
|
4196
4205
|
continue;
|
|
4197
4206
|
const { symbolTable: a } = r.symbol;
|
|
4198
|
-
let
|
|
4207
|
+
let c = [a], p = [];
|
|
4199
4208
|
for (const h of e)
|
|
4200
|
-
p =
|
|
4209
|
+
p = c.flatMap(
|
|
4201
4210
|
(T) => qt(h).flatMap((f) => {
|
|
4202
4211
|
const N = T.get(f), g = ie(f).unwrap_or(void 0);
|
|
4203
4212
|
return !N || !g ? [] : { ...g, symbol: N };
|
|
4204
4213
|
})
|
|
4205
|
-
),
|
|
4214
|
+
), c = p.flatMap(
|
|
4206
4215
|
(T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
|
|
4207
4216
|
);
|
|
4208
4217
|
s.push(...p);
|
|
@@ -4229,8 +4238,8 @@ class cs {
|
|
|
4229
4238
|
if (r.has(a))
|
|
4230
4239
|
return r.get(a);
|
|
4231
4240
|
}
|
|
4232
|
-
const
|
|
4233
|
-
return i !== void 0 ? r instanceof Map ? r.set(a,
|
|
4241
|
+
const c = n(i);
|
|
4242
|
+
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;
|
|
4234
4243
|
};
|
|
4235
4244
|
}
|
|
4236
4245
|
setSource(e) {
|
|
@@ -4248,7 +4257,7 @@ class cs {
|
|
|
4248
4257
|
}
|
|
4249
4258
|
}
|
|
4250
4259
|
export {
|
|
4251
|
-
|
|
4260
|
+
ls as Compiler,
|
|
4252
4261
|
os as serialize,
|
|
4253
|
-
|
|
4262
|
+
cs as services
|
|
4254
4263
|
};
|