@dbml/parse 3.1.2 → 3.1.3-alpha.0

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