@dbml/parse 3.1.4 → 3.1.5-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 I 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 B {
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 V {
40
+ constructor(e, n, s, i, r) {
41
+ this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
42
42
  }
43
- static create(e, s, n, i, r) {
44
- return new B(e, s, n, i, r);
43
+ static create(e, n, s, i, r) {
44
+ return new V(e, n, s, i, r);
45
45
  }
46
46
  }
47
47
  function bt(t) {
48
- return t.trailingTrivia.find(({ kind: e }) => e === 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(I.last(t.trailingTrivia));
@@ -59,12 +59,12 @@ function It(t) {
59
59
  function Lt(t) {
60
60
  return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
61
61
  }
62
- function $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 y {
78
+ class x {
79
79
  // The symbol that this syntax node refers to
80
80
  // args must be passed in order of appearance in the node
81
- constructor(e, 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 B ? 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 V ? Lt(i) : i.fullStart) : (this.startPos = {
85
85
  offset: NaN,
86
86
  column: NaN,
87
87
  line: NaN
88
88
  }, this.fullStart = NaN);
89
- const r = [...n].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
90
- r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? 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 V ? It(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
@@ -95,163 +95,163 @@ class y {
95
95
  }
96
96
  }
97
97
  var ue = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(ue || {});
98
- class C extends y {
99
- constructor({ body: e = [], eof: s }, n) {
100
- super(n, "<program>", [...e, s]), this.body = e, this.eof = s;
98
+ class F extends x {
99
+ constructor({ body: e = [], eof: n }, s) {
100
+ super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
101
101
  }
102
102
  }
103
- class _ extends y {
103
+ class _ extends x {
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 x || 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 y {
127
- constructor({ identifiers: e = [] }, s) {
128
- super(s, "<identifer-stream>", e || []), this.identifiers = e;
126
+ class te extends x {
127
+ constructor({ identifiers: e = [] }, n) {
128
+ super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
130
130
  }
131
- class ne extends y {
131
+ class ne extends x {
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 y {
141
- constructor({ op: e, expression: s }, n) {
142
- super(n, "<prefix-expression>", [e, s]), this.op = e, this.expression = s;
140
+ class Q extends x {
141
+ constructor({ op: e, expression: n }, s) {
142
+ super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
143
143
  }
144
144
  }
145
- class q extends y {
145
+ class q extends x {
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 De extends y {
155
- constructor({ op: e, expression: s }, n) {
156
- super(n, "<postfix-expression>", [s, e]), this.op = e, this.expression = s;
154
+ class De extends x {
155
+ constructor({ op: e, expression: n }, s) {
156
+ super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
157
157
  }
158
158
  }
159
- class K extends y {
160
- constructor({ value: e }, s) {
161
- super(s, "<function-expression>", [e]), this.value = e;
159
+ class K extends x {
160
+ constructor({ value: e }, n) {
161
+ super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class x extends y {
165
- constructor({ callee: e, args: s = [] }, n) {
166
- super(n, "<function-application>", [e, ...s]), this.callee = e, this.args = s;
164
+ class v extends x {
165
+ constructor({ callee: e, args: n = [] }, s) {
166
+ super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
167
167
  }
168
168
  }
169
- class ee extends y {
169
+ class ee extends x {
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 y {
178
+ class U extends x {
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 y {
192
+ class J extends x {
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 y {
223
+ class H extends x {
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 pe extends y {
232
- constructor({ literal: e }, s) {
233
- super(s, "<literal>", [e]), this.literal = e;
231
+ class pe extends x {
232
+ constructor({ literal: e }, n) {
233
+ super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
- class X extends y {
237
- constructor({ variable: e }, s) {
238
- super(s, "<variable>", [e]), this.variable = e;
236
+ class W extends x {
237
+ constructor({ variable: e }, n) {
238
+ super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
- class R extends y {
242
- constructor({ expression: e }, s) {
243
- super(s, "<primary-expression>", [e]), this.expression = e;
241
+ class R extends x {
242
+ constructor({ expression: e }, n) {
243
+ super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
- class we extends y {
247
- constructor({ pre: e }, s) {
248
- const n = B.create(c.SPACE, e.endPos, e.endPos, " ", !1);
249
- super(s, "<dummy>", [n]);
246
+ class we extends x {
247
+ constructor({ pre: e }, n) {
248
+ const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
249
+ super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
252
- class he extends y {
253
- constructor({ expression: e, indexer: s }, n) {
254
- super(n, "<array>", [e, s]), this.array = e, this.indexer = s;
252
+ class he extends x {
253
+ constructor({ expression: e, indexer: n }, s) {
254
+ super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
256
256
  }
257
257
  function gt(t, e) {
@@ -259,30 +259,30 @@ function gt(t, e) {
259
259
  return e || [];
260
260
  if (!e || e.length === 0)
261
261
  return t || [];
262
- const [s] = t, [n] = e;
263
- return (s.start < n.start ? I.flatten(I.zip(t, e)) : I.flatten(I.zip(e, t))).filter(
262
+ const [n] = t, [s] = e;
263
+ return (n.start < s.start ? I.flatten(I.zip(t, e)) : I.flatten(I.zip(e, t))).filter(
264
264
  (i) => i !== null
265
265
  );
266
266
  }
267
- function is(t, e = !1) {
267
+ function as(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 C) && s === "symbol" ? n == null ? void 0 : n.id : (
272
+ return !(this instanceof F) && 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 S({
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
  xe,
@@ -409,23 +412,23 @@ function ke(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 ke(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
415
418
  }
416
- function be(t) {
419
+ function Ie(t) {
417
420
  return qe(t) || ke(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 Ie(t, e) {
428
+ function Le(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 F {
481
- constructor(e, s) {
482
- this.value = e, this.errors = s === void 0 ? [] : s;
483
+ class B {
484
+ constructor(e, n) {
485
+ this.value = e, this.errors = n === void 0 ? [] : n;
483
486
  }
484
487
  getValue() {
485
488
  return this.value;
@@ -488,54 +491,54 @@ class F {
488
491
  return this.errors;
489
492
  }
490
493
  chain(e) {
491
- const s = e(this.value), n = [...this.errors, ...s.errors];
492
- return new F(s.value, n);
494
+ const n = e(this.value), s = [...this.errors, ...n.errors];
495
+ return new B(n.value, s);
493
496
  }
494
497
  map(e) {
495
- return new F(e(this.value), this.errors);
498
+ return new B(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 || !fe(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 = I.last(n) instanceof U ? n.pop() : void 0;
505
- return n.length === 3 && Be(n[1]).unwrap().value === "as" ? new S(
506
- s.create(_, {
507
+ const a = I.last(s) instanceof U ? s.pop() : void 0;
508
+ return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
509
+ n.create(_, {
507
510
  type: i,
508
- name: 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 S(
515
- s.create(_, {
517
+ ) : s.length === 1 ? new S(
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 S(
522
- s.create(_, {
524
+ ) : s.length === 0 ? new S(
525
+ n.create(_, {
523
526
  type: i,
524
527
  attributeList: a,
525
528
  body: r
526
529
  })
527
530
  ) : new A();
528
531
  }
529
- function 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 B ? tn(t) : nn(t));
536
+ t && (t instanceof V ? 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,13 +559,13 @@ function nn(t) {
556
559
  E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
557
560
  else if (t instanceof H)
558
561
  E(t.callee), E(t.argumentList);
559
- else if (t instanceof x)
562
+ else if (t instanceof v)
560
563
  E(t.callee), t.args.forEach(E);
561
564
  else if (t instanceof R)
562
565
  E(t.expression);
563
566
  else if (t instanceof K)
564
567
  E(t.value);
565
- else if (t instanceof X)
568
+ else if (t instanceof W)
566
569
  E(t.variable);
567
570
  else if (t instanceof pe)
568
571
  E(t.literal);
@@ -575,8 +578,8 @@ function vt(t) {
575
578
  function P(...t) {
576
579
  return t.filter((e) => e !== void 0);
577
580
  }
578
- function sn(t) {
579
- if (t instanceof C)
581
+ function an(t) {
582
+ if (t instanceof F)
580
583
  return P(...t.body, t.eof);
581
584
  if (t instanceof _)
582
585
  return P(
@@ -594,7 +597,7 @@ function sn(t) {
594
597
  return t.identifiers;
595
598
  if (t instanceof pe)
596
599
  return t.literal ? [t.literal] : [];
597
- if (t instanceof X)
600
+ if (t instanceof W)
598
601
  return P(t.variable);
599
602
  if (t instanceof Q)
600
603
  return P(t.op, t.expression);
@@ -604,20 +607,20 @@ function sn(t) {
604
607
  return P(t.expression, t.op);
605
608
  if (t instanceof K)
606
609
  return P(t.value);
607
- if (t instanceof x)
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 S(t.expression.variable) : new A();
631
634
  }
632
- function $(t) {
635
+ function j(t) {
633
636
  var e;
634
- return t instanceof R && (t.expression instanceof X && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
637
+ return t instanceof R && (t.expression instanceof W && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
635
638
  }
636
639
  function M(t) {
637
- return t instanceof R && t.expression instanceof X && t.expression.variable instanceof B;
640
+ return t instanceof R && t.expression instanceof W && t.expression.variable instanceof V;
638
641
  }
639
642
  function fe(t) {
640
643
  var e;
641
- return t instanceof R && t.expression instanceof X && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
644
+ return t instanceof R && t.expression instanceof W && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
642
645
  }
643
646
  function He(t) {
644
647
  var e;
645
- return t instanceof q && t.leftExpression instanceof y && t.rightExpression instanceof y && ((e = t.op) == null ? void 0 : e.value) === ".";
648
+ return t instanceof q && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
646
649
  }
647
650
  function Re(t) {
648
651
  if (t === void 0)
649
652
  return new A();
650
- const e = t.identifiers.map((s) => s.value).join(" ");
653
+ const e = t.identifiers.map((n) => n.value).join(" ");
651
654
  return e === "" ? new A() : new S(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 B.create(
695
+ createToken(e, n = !1) {
696
+ return V.create(
694
697
  e,
695
698
  this.start,
696
699
  this.current,
697
700
  this.text.substring(this.start.offset, this.current.offset),
698
- s
701
+ n
699
702
  );
700
703
  }
701
704
  lex() {
702
- return this.scanTokens(), this.tokens.push(B.create(c.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new F(this.tokens, this.errors);
705
+ return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
703
706
  }
704
707
  scanTokens() {
705
708
  for (; !this.isAtEnd(); ) {
706
709
  const e = this.advance();
707
710
  switch (e) {
708
711
  case " ":
709
- this.addToken(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 = [];
799
+ const n = [], s = [];
797
800
  for (e = 0; e < this.tokens.length && vt(this.tokens[e]); e += 1)
798
- n.push(this.tokens[e]);
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(B.create(e, this.start, this.current, l, !1));
842
+ a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, c, !1));
840
843
  }
841
844
  singleLineStringLiteral() {
842
- this.consumeUntil(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() && be(this.peek()); )
889
+ for (; !this.isAtEnd() && Ie(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 && !be(this.peek()))
906
- return this.addToken(c.NUMERIC_LITERAL);
907
- if (!n && !ke(this.peek()))
906
+ if (!s && this.current.offset === this.text.length - 1)
907
+ return this.advance(), this.addToken(u.NUMERIC_LITERAL);
908
+ if (!s && !Ie(this.peek()))
909
+ return this.addToken(u.NUMERIC_LITERAL);
910
+ if (!s && !ke(this.peek()))
908
911
  break;
909
912
  this.advance();
910
913
  }
911
- for (; !this.isAtEnd() && (this.check(".") || be(this.peek())); )
914
+ for (; !this.isAtEnd() && (this.check(".") || Ie(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() && be(this.peek()); )
920
+ for (; !this.isAtEnd() && Ie(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() || !be(this.peek()))
951
+ for (let n = 0; n <= 3; n += 1) {
952
+ if (this.isAtEnd() || !Ie(this.peek()))
950
953
  return `\\u${e}`;
951
954
  e += this.advance();
952
955
  }
@@ -958,7 +961,7 @@ class rn {
958
961
  }
959
962
  }
960
963
  var ye = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ye || {});
961
- class an {
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
1062
  }, this.blockExpression = this.contextStack.withContextDo(ye.BlockExpression, () => {
1060
- const n = { body: [] }, i = () => this.nodeFactory.create(ee, n);
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
1101
  }, this.tupleExpression = this.contextStack.withContextDo(ye.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);
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 y && n.elementList.push(a.partialNode), !this.canHandle(a))
1132
+ if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
1130
1133
  throw new d(a.token, r(), a.handlerContext);
1131
1134
  this.synchronizeTuple();
1132
1135
  }
1133
1136
  try {
1134
- this.consume("Expect a closing parenthesis ')'", 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
1153
  }, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
1151
- const n = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, n);
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 y && n.elementList.push(r.partialNode), !this.canHandle(r))
1180
+ if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
1178
1181
  throw new d(r.token, i(), r.handlerContext);
1179
1182
  this.synchronizeList();
1180
1183
  }
1181
1184
  try {
1182
- this.consume("Expect a closing bracket ']'", 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() ? I.last(this.tokens) : this.tokens[this.current++];
@@ -1221,12 +1224,12 @@ class ln {
1221
1224
  return e + this.current >= this.tokens.length ? I.last(this.tokens) : this.tokens[this.current + e];
1222
1225
  }
1223
1226
  match(...e) {
1224
- const 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(C, { body: e, eof: s });
1269
- return this.gatherInvalid(), new F({ ast: n, tokens: this.tokens }, this.errors);
1271
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(F, { body: e, eof: n });
1272
+ return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
1270
1273
  }
1271
1274
  /* Parsing and synchronizing ProgramNode */
1272
1275
  program() {
1273
1276
  const e = [];
1274
1277
  for (; !this.isAtEnd(); )
1275
1278
  try {
1276
- const 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,155 +1346,155 @@ 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(x, 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(he, {
1426
- expression: s,
1428
+ n = this.nodeFactory.create(he, {
1429
+ expression: n,
1427
1430
  indexer: this.listExpression()
1428
1431
  });
1429
1432
  } catch (i) {
1430
- throw i instanceof d ? (s = this.nodeFactory.create(he, {
1431
- expression: s,
1433
+ throw i instanceof d ? (n = this.nodeFactory.create(he, {
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(De, {
1441
- expression: s,
1443
+ this.advance(), n = this.nodeFactory.create(De, {
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(we, { 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);
1497
+ e = this.nodeFactory.create(Q, n);
1495
1498
  } else if (e = this.extractOperand(), e instanceof we)
1496
1499
  throw new d(
1497
1500
  this.peek(),
@@ -1506,12 +1509,12 @@ class ln {
1506
1509
  // e.g { ... }
1507
1510
  extractOperand() {
1508
1511
  return this.check(
1509
- 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"
@@ -1525,98 +1528,98 @@ class ln {
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(R, {
1549
1552
  expression: this.nodeFactory.create(pe, { 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(R, {
1553
- expression: this.nodeFactory.create(X, { variable: this.previous() })
1556
+ expression: this.nodeFactory.create(W, { variable: this.previous() })
1554
1557
  });
1555
1558
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
1556
1559
  this.peek(),
1557
1560
  this.nodeFactory.create(R, {
1558
- expression: this.nodeFactory.create(X, {})
1561
+ expression: this.nodeFactory.create(W, {})
1559
1562
  }),
1560
1563
  this.contextStack.findHandlerContext(this.tokens, this.current)
1561
1564
  );
1562
1565
  }
1563
1566
  attribute() {
1564
1567
  const e = {};
1565
- if (this.check(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 b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
1656
1659
  function de(t) {
1657
- var 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 b.Enum:
1661
1664
  case b.Table:
@@ -1675,50 +1678,50 @@ function Ee(t) {
1675
1678
  const e = Ee(t.leftExpression).unwrap_or(void 0);
1676
1679
  return e ? (e.push(t.rightExpression), new S(e)) : new A();
1677
1680
  }
1678
- function W(t) {
1681
+ function C(t) {
1679
1682
  if (t === void 0)
1680
1683
  return new A();
1681
1684
  const e = Ee(t).unwrap_or(void 0);
1682
1685
  if (!e)
1683
1686
  return new A();
1684
- const s = [];
1685
- for (const n of e) {
1686
- const i = G(n).unwrap_or(void 0);
1687
+ const n = [];
1688
+ for (const s of e) {
1689
+ const i = X(s).unwrap_or(void 0);
1687
1690
  if (!i)
1688
1691
  return new A();
1689
- s.push(i);
1692
+ n.push(i);
1690
1693
  }
1691
- return new S(s);
1694
+ return new S(n);
1692
1695
  }
1693
- function Le(t) {
1696
+ function ge(t) {
1694
1697
  if (t === void 0)
1695
1698
  return new A();
1696
1699
  const e = Ee(t).unwrap_or(void 0);
1697
1700
  if (!e || e.length === 0)
1698
1701
  return new A();
1699
- const s = [];
1700
- let n;
1702
+ const n = [];
1703
+ let s;
1701
1704
  if (!M(I.last(e))) {
1702
1705
  const i = e.pop();
1703
1706
  if (xt(i))
1704
- n = i.elementList.map(
1705
- (r) => V(r).unwrap()
1707
+ s = i.elementList.map(
1708
+ (r) => G(r).unwrap()
1706
1709
  );
1707
1710
  else
1708
1711
  return new A();
1709
1712
  }
1710
1713
  for (const i of e) {
1711
- const r = G(i).unwrap_or(void 0);
1714
+ const r = X(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 S({
1717
- variables: s,
1718
- tupleElements: n
1720
+ variables: n,
1721
+ tupleElements: s
1719
1722
  });
1720
1723
  }
1721
- function G(t) {
1724
+ function X(t) {
1722
1725
  return M(t) ? new S(t.expression.variable.value) : new A();
1723
1726
  }
1724
1727
  function Ge(t) {
@@ -1726,395 +1729,403 @@ function Ge(t) {
1726
1729
  return t instanceof K ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1727
1730
  if (t instanceof J && t.elementList.every(ht)) {
1728
1731
  const e = t.elementList.filter(
1729
- (n) => n instanceof K
1730
- ), s = t.elementList.filter(M);
1731
- return new S({ functional: e, nonFunctional: s });
1732
+ (s) => s instanceof K
1733
+ ), n = t.elementList.filter(M);
1734
+ return new S({ functional: e, nonFunctional: n });
1732
1735
  }
1733
1736
  return new A();
1734
1737
  }
1735
- function V(t) {
1736
- var s;
1737
- const e = (s = t == null ? void 0 : t.expression.variable) == null ? void 0 : s.value;
1738
+ function G(t) {
1739
+ var n;
1740
+ const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1738
1741
  return e === void 0 ? new A() : new S(e);
1739
1742
  }
1740
- function Y(t) {
1741
- return $(t) ? t.expression instanceof X ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
1743
+ function z(t) {
1744
+ return j(t) ? t.expression instanceof W ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
1742
1745
  }
1743
- function 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 : Le(t.leftExpression).and_then(() => Le(t.rightExpression)).unwrap_or(void 0) !== void 0;
1748
+ return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : ge(t.leftExpression).and_then(() => ge(t.rightExpression)).unwrap_or(void 0) !== void 0;
1746
1749
  }
1747
- function En(t) {
1748
- const e = Le(t.leftExpression), s = Le(t.rightExpression);
1749
- if (!e.isOk() || !s.isOk())
1750
+ function mn(t) {
1751
+ const e = ge(t.leftExpression), n = ge(t.rightExpression);
1752
+ if (!e.isOk() || !n.isOk())
1750
1753
  return !1;
1751
- const { tupleElements: 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 R && t.expression instanceof X || t instanceof K;
1758
+ return t instanceof R && t.expression instanceof W || 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 C && n)
1765
- return s.symbol;
1766
- if (s instanceof C)
1760
+ function Tn(t, e) {
1761
+ var i, r, a, c;
1762
+ let n = e;
1763
+ const s = zt(t);
1764
+ for (; n; ) {
1765
+ if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1766
+ return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1767
+ if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof F && s)
1768
+ return n.symbol;
1769
+ if (n instanceof F)
1767
1770
  return;
1768
- 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 C || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new u(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1782
+ return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1780
1783
  }
1781
1784
  validateName(e) {
1782
- return e ? [new 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 $(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 j(e.callee) || n.push(new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1797
1800
  }
1798
1801
  }
1799
- class _e {
1802
+ class Ae {
1800
1803
  constructor() {
1801
1804
  this.table = /* @__PURE__ */ new Map();
1802
1805
  }
1803
1806
  has(e) {
1804
1807
  return this.table.has(e);
1805
1808
  }
1806
- set(e, 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 _e() });
1835
- const { name: s } = this.declarationNode, n = W(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 Ae() });
1838
+ const { name: n } = this.declarationNode, s = C(n);
1839
+ if (s.isOk()) {
1840
+ const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = je(r);
1841
+ a.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(c, this.declarationNode.symbol);
1839
1842
  }
1840
1843
  return e;
1841
1844
  }
1842
1845
  validateSettingList(e) {
1843
- return e ? [new 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 x)
1851
+ if (e instanceof v)
1849
1852
  return this.validateFields([e]);
1850
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
1851
- return [...this.validateFields(s), ...this.validateSubElements(n)];
1853
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
1854
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
1852
1855
  }
1853
1856
  validateFields(e) {
1854
- return e.length === 0 ? [new 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)), I.last(s.args) instanceof U && n.push(...this.validateFieldSetting(I.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)), I.last(n.args) instanceof U && s.push(...this.validateFieldSetting(I.last(n.args))), n.args.length > 1 && s.push(...n.args.map((i) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), s.push(...this.registerField(n)), s;
1857
1860
  });
1858
1861
  }
1859
1862
  validateFieldSetting(e) {
1860
- const s = z(e), n = s.getErrors(), i = s.getValue();
1863
+ const n = $(e), s = n.getErrors(), i = n.getValue();
1861
1864
  for (const r in i) {
1862
1865
  const a = i[r];
1863
1866
  switch (r) {
1864
1867
  case "note":
1865
- a.length > 1 && a.forEach((l) => n.push(new u(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1866
- $(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
+ j(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
1867
1870
  });
1868
1871
  break;
1869
1872
  default:
1870
- a.forEach((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 = V(e.callee).unwrap(), n = Ye(s), i = this.symbolFactory.create(Ht, { declaration: e });
1888
+ const n = G(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Zt, { declaration: e });
1886
1889
  e.symbol = i;
1887
1890
  const r = this.declarationNode.symbol.symbolTable;
1888
- if (r.has(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 C || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new u(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1911
+ return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new l(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1909
1912
  }
1910
1913
  validateName(e) {
1911
- return e ? [new 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 x)
1923
- return [new u(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1924
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
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] = I.partition(e.body, (i) => i instanceof v);
1928
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
1926
1929
  }
1927
1930
  validateFields(e) {
1928
- return e.flatMap((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 I.last(i) instanceof U && n.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1934
+ const s = [], i = [n.callee, ...n.args];
1935
+ return I.last(i) instanceof U && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1933
1936
  for (; r instanceof H; )
1934
- r.argumentList && !Ge(r.argumentList).isOk() && 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 = $(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
- $(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
+ j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
1948
1951
  });
1949
1952
  break;
1950
1953
  case "unique":
1951
1954
  case "pk":
1952
- a.length > 1 && a.forEach((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 C || ![b.Table, b.Project].includes(de(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 F) && ![b.Table, b.Project].includes(de(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
1985
1988
  }
1986
1989
  validateName(e) {
1987
- return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
1990
+ if (!(this.declarationNode.parent instanceof F))
1991
+ return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
1992
+ if (!e)
1993
+ return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
1994
+ const n = C(e);
1995
+ if (!n.isOk())
1996
+ return [];
1997
+ const i = n.unwrap().join("."), r = Yt(i);
1998
+ return this.publicSymbolTable.has(r) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
1988
1999
  }
1989
2000
  validateAlias(e) {
1990
- return e ? [new 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 F) ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
1994
2005
  }
1995
2006
  validateBody(e) {
1996
2007
  if (!e)
1997
2008
  return [];
1998
- if (e instanceof x)
2009
+ if (e instanceof v)
1999
2010
  return this.validateFields([e]);
2000
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
2001
- return [...this.validateFields(s), ...this.validateSubElements(n)];
2011
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2012
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2002
2013
  }
2003
2014
  validateFields(e) {
2004
- const 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))), $(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))), j(e[0].callee) || n.push(new l(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2006
2017
  }
2007
2018
  validateSubElements(e) {
2008
- return e.flatMap((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 ? Pe(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 ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2028
2039
  }
2029
2040
  validateAlias(e) {
2030
- return e ? [new 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 x)
2039
- return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2040
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
2049
+ if (e instanceof v)
2050
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2051
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2041
2052
  return [
2042
- ...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 C || de(this.declarationNode.parent).unwrap_or(void 0) === b.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 F || de(this.declarationNode.parent).unwrap_or(void 0) === b.Table ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level or inside a table", this.declarationNode)];
2064
2075
  }
2065
2076
  validateName(e) {
2066
- return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2077
+ return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2067
2078
  }
2068
2079
  validateAlias(e) {
2069
- return e ? [new 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 x)
2088
+ if (e instanceof v)
2078
2089
  return this.validateFields([e]);
2079
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
2080
- return [...this.validateFields(s), ...this.validateSubElements(n)];
2090
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2091
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2081
2092
  }
2082
2093
  validateFields(e) {
2083
2094
  if (e.length === 0)
2084
- return [new 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)), I.last(n.args) instanceof U && this.validateFieldSettings(I.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)), I.last(s.args) instanceof U && this.validateFieldSettings(I.last(s.args)), s.args.length > 1 && n.push(...s.args.map((i) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
2099
+ }), n;
2089
2100
  }
2090
2101
  validateFieldSettings(e) {
2091
- const s = z(e), n = s.getErrors(), i = s.getValue();
2102
+ const n = $(e), s = n.getErrors(), i = n.getValue();
2092
2103
  for (const r in i) {
2093
2104
  const a = i[r];
2094
2105
  switch (r) {
2095
2106
  case "delete":
2096
2107
  case "update":
2097
- a.length > 1 && a.forEach((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 = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
@@ -2130,264 +2141,264 @@ function _n(t) {
2130
2141
  }
2131
2142
  return !1;
2132
2143
  }
2133
- class 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 he ? [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 he ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2145
2156
  }
2146
2157
  validateAlias(e) {
2147
- return e ? xn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2158
+ return e ? Sn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2148
2159
  }
2149
2160
  validateSettingList(e) {
2150
- const s = z(e), n = s.getErrors(), i = s.getValue();
2161
+ const n = $(e), s = n.getErrors(), i = n.getValue();
2151
2162
  for (const r in i) {
2152
2163
  const a = i[r];
2153
2164
  switch (r) {
2154
2165
  case "headercolor":
2155
- a.length > 1 && n.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2156
- kn(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
+ On(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2157
2168
  });
2158
2169
  break;
2159
2170
  case "note":
2160
- a.length > 1 && n.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2161
- $(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
+ j(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
2162
2173
  });
2163
2174
  break;
2164
2175
  default:
2165
- 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 _e() });
2173
- const { name: s, alias: n } = this.declarationNode, i = W(s);
2183
+ this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new Ae() });
2184
+ const { name: n, alias: s } = this.declarationNode, i = C(n);
2174
2185
  if (i.isOk()) {
2175
- const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(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 = xe(a);
2187
+ c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), c.set(p, this.declarationNode.symbol);
2177
2188
  }
2178
- if (n && Pe(n) && !wn(n.expression.variable.value, i.unwrap_or([]))) {
2179
- const r = V(n).unwrap(), a = xe(r);
2180
- this.publicSymbolTable.has(a) && e.push(new u(o.DUPLICATE_NAME, `Table name '${r}' already exists`, s)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2189
+ if (s && Pe(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
2190
+ const r = G(s).unwrap(), a = xe(r);
2191
+ this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2181
2192
  }
2182
2193
  return e;
2183
2194
  }
2184
2195
  validateBody(e) {
2185
2196
  if (!e)
2186
2197
  return [];
2187
- if (e instanceof x)
2188
- return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2189
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
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] = I.partition(e.body, (i) => i instanceof v);
2201
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2191
2202
  }
2192
2203
  validateFields(e) {
2193
- return e.length === 0 ? [new 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] && !vn(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 = V(e.callee).unwrap(), n = We(s), i = this.symbolFactory.create(Jt, { declaration: e });
2215
+ const n = G(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Kt, { declaration: e });
2205
2216
  e.symbol = i;
2206
2217
  const r = this.declarationNode.symbol.symbolTable;
2207
- if (r.has(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(fe) || !e.slice(-1).every((p) => fe(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
- I.last(e) instanceof U && (s = e.pop());
2226
- const n = z(s), i = n.getErrors(), r = n.getValue();
2235
+ let n;
2236
+ I.last(e) instanceof U && (n = e.pop());
2237
+ const s = $(n), i = s.getErrors(), r = s.getValue();
2227
2238
  for (const p of e) {
2228
- const h = V(p).unwrap_or("").toLowerCase();
2239
+ const h = G(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
- $(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
+ j(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2243
2254
  });
2244
2255
  break;
2245
2256
  case "ref":
2246
2257
  h.forEach((f) => {
2247
- On(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2258
+ Rn(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2248
2259
  });
2249
2260
  break;
2250
2261
  case "primary key":
2251
- h.length > 1 && i.push(...h.map((f) => new 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
- Sn(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
+ Dn(f.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
2285
2296
  });
2286
2297
  break;
2287
2298
  default:
2288
- h.forEach((f) => i.push(new 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 vn(t) {
2317
+ function yn(t) {
2307
2318
  if (!(t instanceof H || He(t) || t instanceof R || t instanceof he))
2308
2319
  return !1;
2309
2320
  if (t instanceof H) {
2310
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((s) => le(s) || $(s) || fe(s)))
2321
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) || j(n) || fe(n)))
2311
2322
  return !1;
2312
2323
  t = t.callee;
2313
2324
  }
2314
2325
  for (; t instanceof he; ) {
2315
- if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((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 = W(t).unwrap_or(void 0);
2330
+ const e = C(t).unwrap_or(void 0);
2320
2331
  return e !== void 0 && e.length > 0;
2321
2332
  }
2322
- function wn(t, e) {
2333
+ function xn(t, e) {
2323
2334
  return e.length === 1 && t === e[0];
2324
2335
  }
2325
- class yn {
2326
- constructor(e, s, n) {
2327
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
2336
+ class kn {
2337
+ constructor(e, n, s) {
2338
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2328
2339
  }
2329
2340
  validate() {
2330
2341
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
2331
2342
  }
2332
2343
  validateContext() {
2333
- return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2344
+ return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2334
2345
  }
2335
2346
  validateName(e) {
2336
- return e ? Je(e) ? [] : [new 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)];
2347
+ return e ? Je(e) ? [] : [new l(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new l(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2337
2348
  }
2338
2349
  validateAlias(e) {
2339
- return e ? [new u(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2350
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2340
2351
  }
2341
2352
  registerElement() {
2342
2353
  const { name: e } = this.declarationNode;
2343
- this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new _e() });
2344
- const s = W(e);
2345
- if (s.isOk()) {
2346
- const n = s.unwrap(), i = n.pop(), r = Ze(n, this.publicSymbolTable, this.symbolFactory), a = ze(i);
2354
+ this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new Ae() });
2355
+ const n = C(e);
2356
+ if (n.isOk()) {
2357
+ const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
2347
2358
  if (r.has(a))
2348
- return [new u(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${n.join(".") || "public"}'`, e)];
2359
+ return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2349
2360
  r.set(a, this.declarationNode.symbol);
2350
2361
  }
2351
2362
  return [];
2352
2363
  }
2353
2364
  validateSettingList(e) {
2354
- return e ? [new u(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2365
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2355
2366
  }
2356
2367
  validateBody(e) {
2357
2368
  if (!e)
2358
2369
  return [];
2359
- if (e instanceof x)
2360
- return [new u(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2361
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
2362
- return [...this.validateFields(s), ...this.validateSubElements(n)];
2370
+ if (e instanceof v)
2371
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2372
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
2373
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2363
2374
  }
2364
2375
  validateFields(e) {
2365
- return e.flatMap((s) => {
2366
- const n = [];
2367
- return s.callee && !W(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;
2376
+ return e.flatMap((n) => {
2377
+ const s = [];
2378
+ return n.callee && !C(n.callee).isOk() && s.push(new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2368
2379
  });
2369
2380
  }
2370
2381
  validateSubElements(e) {
2371
- return e.flatMap((s) => {
2372
- if (s.parent = this.declarationNode, !s.type)
2382
+ return e.flatMap((n) => {
2383
+ if (n.parent = this.declarationNode, !n.type)
2373
2384
  return [];
2374
- const n = ie(s);
2375
- return new n(s, this.publicSymbolTable, this.symbolFactory).validate();
2385
+ const s = ie(n);
2386
+ return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2376
2387
  });
2377
2388
  }
2378
2389
  registerField(e) {
2379
2390
  if (e.callee && M(e.callee)) {
2380
- const s = V(e.callee).unwrap(), n = Qe(s), i = this.symbolFactory.create(Kt, { declaration: e });
2391
+ const n = G(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
2381
2392
  e.symbol = i;
2382
2393
  const r = this.declarationNode.symbol.symbolTable;
2383
- if (r.has(n)) {
2384
- const a = r.get(n);
2394
+ if (r.has(s)) {
2395
+ const a = r.get(s);
2385
2396
  return [
2386
- new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${s} already exists in the group`, e),
2387
- new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${s} already exists in the group`, a.declaration)
2397
+ new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2398
+ new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2388
2399
  ];
2389
2400
  }
2390
- r.set(n, i);
2401
+ r.set(s, i);
2391
2402
  }
2392
2403
  return [];
2393
2404
  }
@@ -2396,256 +2407,256 @@ const wt = ["-", "+"];
2396
2407
  function ie(t) {
2397
2408
  switch (t.type.value.toLowerCase()) {
2398
2409
  case b.Enum:
2399
- return Tn;
2410
+ return In;
2400
2411
  case b.Table:
2401
- return An;
2412
+ return wn;
2402
2413
  case b.TableGroup:
2403
- return yn;
2414
+ return kn;
2404
2415
  case b.Project:
2405
- return Ln;
2416
+ return _n;
2406
2417
  case b.Ref:
2407
- return gn;
2418
+ return An;
2408
2419
  case b.Note:
2409
- return In;
2420
+ return gn;
2410
2421
  case b.Indexes:
2411
- return bn;
2422
+ return Ln;
2412
2423
  default:
2413
- return mn;
2424
+ return bn;
2414
2425
  }
2415
2426
  }
2416
2427
  function Je(t) {
2417
- return !!W(t).unwrap_or(!1);
2428
+ return !!C(t).unwrap_or(!1);
2418
2429
  }
2419
- function xn(t) {
2430
+ function Sn(t) {
2420
2431
  return Pe(t);
2421
2432
  }
2422
2433
  function Pe(t) {
2423
- return t instanceof R && t.expression instanceof X;
2434
+ return t instanceof R && t.expression instanceof W;
2424
2435
  }
2425
- function Ze(t, e, s) {
2436
+ function Ze(t, e, n) {
2426
2437
  var i;
2427
2438
  t[0] === "public" && (t = t.slice(1));
2428
- let n = e;
2439
+ let s = e;
2429
2440
  for (const r of t) {
2430
2441
  let a;
2431
- const l = $e(r);
2432
- if (n.has(l)) {
2433
- if (a = (i = n.get(l)) == null ? void 0 : i.symbolTable, !a)
2442
+ const c = $e(r);
2443
+ if (s.has(c)) {
2444
+ if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
2434
2445
  throw new Error("Expect a symbol table in a schema symbol");
2435
2446
  } else {
2436
- a = new _e();
2437
- const p = s.create(_t, { symbolTable: a });
2438
- n.set(l, p);
2447
+ a = new Ae();
2448
+ const p = n.create(_t, { symbolTable: a });
2449
+ s.set(c, p);
2439
2450
  }
2440
- n = a;
2451
+ s = a;
2441
2452
  }
2442
- return n;
2453
+ return s;
2443
2454
  }
2444
2455
  function yt(t) {
2445
2456
  return t === "-" || t === "<>" || t === ">" || t === "<";
2446
2457
  }
2447
- function kn(t) {
2448
- var s;
2449
- if (!(t instanceof R) || !(t.expression instanceof pe) || ((s = t.expression.literal) == null ? void 0 : s.kind) !== c.COLOR_LITERAL)
2458
+ function On(t) {
2459
+ var n;
2460
+ if (!(t instanceof R) || !(t.expression instanceof pe) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2450
2461
  return !1;
2451
2462
  const e = t.expression.literal.value;
2452
2463
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2453
2464
  return !1;
2454
- for (let n = 1; n < e.length; n += 1)
2455
- if (!zt(e[n]))
2465
+ for (let s = 1; s < e.length; s += 1)
2466
+ if (!qt(e[s]))
2456
2467
  return !1;
2457
2468
  return !0;
2458
2469
  }
2459
2470
  function oe(t) {
2460
2471
  return t === void 0;
2461
2472
  }
2462
- function Sn(t) {
2473
+ function Dn(t) {
2463
2474
  var e;
2464
- return !!($(t) || le(t) || fe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression) || t instanceof K);
2475
+ return !!(j(t) || ce(t) || fe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression) || t instanceof K);
2465
2476
  }
2466
- function le(t) {
2477
+ function ce(t) {
2467
2478
  var e;
2468
- return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
2479
+ return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2469
2480
  }
2470
- function On(t) {
2471
- var s;
2472
- if (!(t instanceof Q) || !yt((s = t.op) == null ? void 0 : s.value))
2481
+ function Rn(t) {
2482
+ var n;
2483
+ if (!(t instanceof Q) || !yt((n = t.op) == null ? void 0 : n.value))
2473
2484
  return !1;
2474
- const e = W(t.expression).unwrap_or(void 0);
2485
+ const e = C(t.expression).unwrap_or(void 0);
2475
2486
  return e !== void 0 && e.length > 0;
2476
2487
  }
2477
2488
  function xt(t) {
2478
2489
  return t instanceof J && t.elementList.every(M);
2479
2490
  }
2480
- function z(t) {
2481
- var n;
2482
- const e = {}, s = [];
2491
+ function $(t) {
2492
+ var s;
2493
+ const e = {}, n = [];
2483
2494
  if (!t)
2484
- return new F({});
2495
+ return new B({});
2485
2496
  for (const i of t.elementList) {
2486
2497
  if (!i.name)
2487
2498
  continue;
2488
2499
  if (i.name instanceof R) {
2489
- s.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2500
+ n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2490
2501
  continue;
2491
2502
  }
2492
- const r = (n = Re(i.name).unwrap_or(void 0)) == null ? void 0 : n.toLowerCase();
2503
+ const r = (s = Re(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2493
2504
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2494
2505
  }
2495
- return new F(e, s);
2506
+ return new B(e, n);
2496
2507
  }
2497
2508
  class ft {
2498
- constructor(e, s) {
2499
- this.ast = e, this.symbolFactory = s, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
2500
- symbolTable: new _e()
2509
+ constructor(e, n) {
2510
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
2511
+ symbolTable: new Ae()
2501
2512
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2502
2513
  }
2503
2514
  validate() {
2504
2515
  const e = [];
2505
- this.ast.body.forEach((n) => {
2506
- if (n.parent = this.ast, n.type === void 0)
2516
+ this.ast.body.forEach((s) => {
2517
+ if (s.parent = this.ast, s.type === void 0)
2507
2518
  return;
2508
- const i = ie(n), r = new i(
2509
- n,
2519
+ const i = ie(s), r = new i(
2520
+ s,
2510
2521
  this.publicSchemaSymbol.symbolTable,
2511
2522
  this.symbolFactory
2512
2523
  );
2513
2524
  e.push(...r.validate());
2514
2525
  });
2515
- const s = this.ast.body.filter((n) => de(n).unwrap_or(void 0) === b.Project);
2516
- return s.length > 1 && s.forEach((n) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", n))), new F(this.ast, e);
2526
+ const n = this.ast.body.filter((s) => de(s).unwrap_or(void 0) === b.Project);
2527
+ return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
2517
2528
  }
2518
2529
  }
2519
2530
  class re {
2520
- constructor(e, s) {
2521
- this.declarationNode = e, this.errors = s;
2531
+ constructor(e, n) {
2532
+ this.declarationNode = e, this.errors = n;
2522
2533
  }
2523
2534
  bind() {
2524
2535
  this.bindSettingList(this.declarationNode.attributeList, this.settingList), this.bindBody();
2525
2536
  }
2526
- bindSettingList(e, s) {
2537
+ bindSettingList(e, n) {
2527
2538
  if (e)
2528
- for (const n of e.elementList) {
2529
- if (n.name instanceof R)
2539
+ for (const s of e.elementList) {
2540
+ if (s.name instanceof R)
2530
2541
  continue;
2531
- const i = Re(n.name).unwrap_or(void 0);
2542
+ const i = Re(s.name).unwrap_or(void 0);
2532
2543
  if (!i)
2533
2544
  continue;
2534
- const r = s[i.toLowerCase()];
2535
- r != null && r.shouldBind && this.scanAndBind(n.value, r);
2545
+ const r = n[i.toLowerCase()];
2546
+ r != null && r.shouldBind && this.scanAndBind(s.value, r);
2536
2547
  }
2537
2548
  }
2538
2549
  bindBody() {
2539
2550
  const e = this.declarationNode;
2540
2551
  if (!e.body)
2541
2552
  return;
2542
- const { body: s } = e;
2543
- if (s instanceof ee)
2544
- for (const n of s.body)
2545
- if (n instanceof _) {
2546
- if (!n.type)
2553
+ const { body: n } = e;
2554
+ if (n instanceof ee)
2555
+ for (const s of n.body)
2556
+ if (s instanceof _) {
2557
+ if (!s.type)
2547
2558
  continue;
2548
- const i = kt(n);
2549
- new i(n, this.errors).bind();
2559
+ const i = kt(s);
2560
+ new i(s, this.errors).bind();
2550
2561
  } else
2551
- this.bindSubfield(n);
2562
+ this.bindSubfield(s);
2552
2563
  else
2553
- this.bindSubfield(s);
2564
+ this.bindSubfield(n);
2554
2565
  }
2555
2566
  bindSubfield(e) {
2556
- const s = [e.callee, ...e.args], n = I.last(s);
2557
- n instanceof U && (s.pop(), this.bindSettingList(n, this.subfield.settingList));
2567
+ const n = [e.callee, ...e.args], s = I.last(n);
2568
+ s instanceof U && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2558
2569
  const { argBinderRules: i } = this.subfield.arg;
2559
- for (let r = 0; r < Math.min(s.length, i.length); r += 1)
2560
- i[r].shouldBind && this.scanAndBind(s[r], i[r]);
2570
+ for (let r = 0; r < Math.min(n.length, i.length); r += 1)
2571
+ i[r].shouldBind && this.scanAndBind(n[r], i[r]);
2561
2572
  }
2562
2573
  // Scan for variable node and member access expression in the node to bind
2563
- scanAndBind(e, s) {
2564
- var n, i;
2574
+ scanAndBind(e, n) {
2575
+ var s, i;
2565
2576
  if (e)
2566
2577
  if (e instanceof R) {
2567
- if (e.expression instanceof X && ((i = s.keywords) != null && i.includes((n = e.expression.variable) == null ? void 0 : n.value.toLowerCase())))
2578
+ if (e.expression instanceof W && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2568
2579
  return;
2569
- this.bindFragments([e], s);
2580
+ this.bindFragments([e], n);
2570
2581
  } else
2571
- e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]), s) : (this.scanAndBind(e.leftExpression, s), this.scanAndBind(e.rightExpression, s)) : e instanceof Q ? this.scanAndBind(e.expression, s) : e instanceof De ? this.scanAndBind(e.expression, s) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, s));
2582
+ e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
2572
2583
  }
2573
2584
  // Bind the fragments of a member access expression
2574
2585
  // which can be a simple expression like v1.User,
2575
2586
  // or a complex tuple like v1.User.(id, name)
2576
- bindFragments(e, s) {
2587
+ bindFragments(e, n) {
2577
2588
  if (e.length === 0)
2578
2589
  return;
2579
- 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(
2590
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), c = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2580
2591
  0,
2581
2592
  r === -1 ? void 0 : r
2582
2593
  );
2583
2594
  if (h.length === 0)
2584
2595
  return;
2585
2596
  const T = [];
2586
- for (; n.length && h.length; ) {
2587
- const f = n.pop(), N = h.pop(), g = V(N).unwrap();
2597
+ for (; s.length && h.length; ) {
2598
+ const f = s.pop(), N = h.pop(), g = G(N).unwrap();
2588
2599
  T.unshift({
2589
2600
  index: Fe(g, f),
2590
2601
  referrer: N
2591
2602
  });
2592
2603
  }
2593
2604
  for (; h.length; ) {
2594
- const f = h.pop(), N = V(f).unwrap();
2605
+ const f = h.pop(), N = G(f).unwrap();
2595
2606
  T.unshift({
2596
2607
  index: Fe(N, i),
2597
2608
  referrer: f
2598
2609
  });
2599
2610
  }
2600
- return l ? l.elementList.forEach(
2611
+ return c ? c.elementList.forEach(
2601
2612
  (f) => this.resolveIndexStack(
2602
2613
  [
2603
2614
  ...T,
2604
2615
  {
2605
2616
  index: Fe(
2606
- V(f).unwrap(),
2617
+ G(f).unwrap(),
2607
2618
  p
2608
2619
  ),
2609
2620
  referrer: f
2610
2621
  }
2611
2622
  ],
2612
- s.ignoreNameNotFound
2623
+ n.ignoreNameNotFound
2613
2624
  )
2614
- ) : this.resolveIndexStack(T, s.ignoreNameNotFound);
2625
+ ) : this.resolveIndexStack(T, n.ignoreNameNotFound);
2615
2626
  }
2616
2627
  // Looking up the indexes in the subname stack from the current declaration node
2617
2628
  // Each time the index resolves to a symbol, the referrer's symbol is bound to it
2618
- resolveIndexStack(e, s) {
2629
+ resolveIndexStack(e, n) {
2619
2630
  if (e.length === 0)
2620
2631
  throw new Error("Unreachable - An unresolved name must have at least one name component");
2621
- const [n, ...i] = e, r = Nn(n.index, this.declarationNode);
2632
+ const [s, ...i] = e, r = Tn(s.index, this.declarationNode);
2622
2633
  if (r === void 0) {
2623
- const { kind: h, name: T } = se(n.index).unwrap();
2624
- this.logError(n.referrer, `Can not find ${h} '${T}'`, s);
2634
+ const { kind: h, name: T } = se(s.index).unwrap();
2635
+ this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
2625
2636
  return;
2626
2637
  }
2627
- r.references.push(n.referrer), n.referrer.referee = r;
2628
- let a = r.symbolTable, { kind: l, name: p } = se(n.index).unwrap();
2638
+ r.references.push(s.referrer), s.referrer.referee = r;
2639
+ let a = r.symbolTable, { kind: c, name: p } = se(s.index).unwrap();
2629
2640
  for (const h of i) {
2630
2641
  const { kind: T, name: f } = se(h.index).unwrap(), N = a.get(h.index);
2631
2642
  if (!N) {
2632
2643
  this.logError(
2633
2644
  h.referrer,
2634
- `${l} '${p}' does not have ${T} '${f}'`,
2635
- s
2645
+ `${c} '${p}' does not have ${T} '${f}'`,
2646
+ n
2636
2647
  );
2637
2648
  return;
2638
2649
  }
2639
- if (l = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2650
+ if (c = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2640
2651
  break;
2641
2652
  a = N.symbolTable;
2642
2653
  }
2643
2654
  }
2644
- logError(e, s, n) {
2645
- n || this.errors.push(new u(o.BINDING_ERROR, s, e));
2655
+ logError(e, n, s) {
2656
+ s || this.errors.push(new l(o.BINDING_ERROR, n, e));
2646
2657
  }
2647
2658
  }
2648
- class Dn extends re {
2659
+ class Pn extends re {
2649
2660
  constructor() {
2650
2661
  super(...arguments), this.subfield = {
2651
2662
  arg: {
@@ -2655,7 +2666,7 @@ class Dn extends re {
2655
2666
  }, this.settingList = {};
2656
2667
  }
2657
2668
  }
2658
- class Rn extends re {
2669
+ class Un extends re {
2659
2670
  constructor() {
2660
2671
  super(...arguments), this.subfield = {
2661
2672
  arg: {
@@ -2665,7 +2676,7 @@ class Rn extends re {
2665
2676
  }, this.settingList = {};
2666
2677
  }
2667
2678
  }
2668
- class Pn extends re {
2679
+ class Mn extends re {
2669
2680
  constructor() {
2670
2681
  super(...arguments), this.subfield = {
2671
2682
  arg: {
@@ -2700,7 +2711,7 @@ class Pn extends re {
2700
2711
  }, this.settingList = {};
2701
2712
  }
2702
2713
  }
2703
- class Un extends re {
2714
+ class Fn extends re {
2704
2715
  constructor() {
2705
2716
  super(...arguments), this.subfield = {
2706
2717
  arg: {
@@ -2710,7 +2721,7 @@ class Un extends re {
2710
2721
  }, this.settingList = {};
2711
2722
  }
2712
2723
  }
2713
- class Mn extends re {
2724
+ class Bn extends re {
2714
2725
  constructor() {
2715
2726
  super(...arguments), this.subfield = {
2716
2727
  arg: {
@@ -2720,7 +2731,7 @@ class Mn extends re {
2720
2731
  }, this.settingList = {};
2721
2732
  }
2722
2733
  }
2723
- class Fn extends re {
2734
+ class Vn extends re {
2724
2735
  constructor() {
2725
2736
  super(...arguments), this.subfield = {
2726
2737
  arg: {
@@ -2737,7 +2748,7 @@ class Fn extends re {
2737
2748
  }, this.settingList = {};
2738
2749
  }
2739
2750
  }
2740
- class Bn extends re {
2751
+ class Gn extends re {
2741
2752
  constructor() {
2742
2753
  super(...arguments), this.subfield = {
2743
2754
  arg: {
@@ -2765,7 +2776,7 @@ class Bn extends re {
2765
2776
  }, this.settingList = {};
2766
2777
  }
2767
2778
  }
2768
- class Vn extends re {
2779
+ class Cn extends re {
2769
2780
  constructor() {
2770
2781
  super(...arguments), this.subfield = {
2771
2782
  arg: {
@@ -2785,75 +2796,75 @@ class Vn extends re {
2785
2796
  function kt(t) {
2786
2797
  switch (t.type.value.toLowerCase()) {
2787
2798
  case b.Enum:
2788
- return Rn;
2799
+ return Un;
2789
2800
  case b.Table:
2790
- return Bn;
2801
+ return Gn;
2791
2802
  case b.TableGroup:
2792
- return Vn;
2803
+ return Cn;
2793
2804
  case b.Project:
2794
- return Mn;
2805
+ return Bn;
2795
2806
  case b.Ref:
2796
- return Fn;
2807
+ return Vn;
2797
2808
  case b.Note:
2798
- return Un;
2809
+ return Fn;
2799
2810
  case b.Indexes:
2800
- return Pn;
2811
+ return Mn;
2801
2812
  default:
2802
- return Dn;
2813
+ return Pn;
2803
2814
  }
2804
2815
  }
2805
- class Gn {
2816
+ class Xn {
2806
2817
  constructor(e) {
2807
2818
  this.ast = e, this.errors = [];
2808
2819
  }
2809
2820
  resolve() {
2810
2821
  for (const e of this.ast.body)
2811
2822
  if (e.type) {
2812
- const s = kt(e);
2813
- new s(e, this.errors).bind();
2823
+ const n = kt(e);
2824
+ new n(e, this.errors).bind();
2814
2825
  }
2815
- return new F(this.ast, this.errors);
2826
+ return new B(this.ast, this.errors);
2816
2827
  }
2817
2828
  }
2818
- class Cn {
2829
+ class $n {
2819
2830
  constructor(e) {
2820
2831
  this.generator = e;
2821
2832
  }
2822
- create(e, s) {
2823
- return new e(s, this.generator.nextId());
2833
+ create(e, n) {
2834
+ return new e(n, this.generator.nextId());
2824
2835
  }
2825
2836
  }
2826
- class Xn {
2827
- constructor(e, s) {
2828
- this.ast = e, this.symbolFactory = new Cn(s);
2837
+ class Wn {
2838
+ constructor(e, n) {
2839
+ this.ast = e, this.symbolFactory = new $n(n);
2829
2840
  }
2830
2841
  // Analyzing: Invoking both the validator and binder
2831
2842
  analyze() {
2832
- return new ft(this.ast, this.symbolFactory).validate().chain((s) => new Gn(s).resolve());
2843
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Xn(n).resolve());
2833
2844
  }
2834
2845
  // For invoking the validator only
2835
2846
  validate() {
2836
- return new ft(this.ast, this.symbolFactory).validate().chain((s) => new F(s, []));
2847
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
2837
2848
  }
2838
2849
  }
2839
2850
  function pt(t, e) {
2840
- const { variables: s, tupleElements: n } = Le(t).unwrap();
2841
- return n ? s.length === 0 ? {
2851
+ const { variables: n, tupleElements: s } = ge(t).unwrap();
2852
+ return s ? n.length === 0 ? {
2842
2853
  schemaName: e.schemaName,
2843
2854
  tableName: e.name,
2844
- fieldNames: n
2855
+ fieldNames: s
2845
2856
  } : {
2846
- tableName: s.pop(),
2847
- schemaName: s.pop() || null,
2848
- fieldNames: n
2849
- } : s.length === 1 ? {
2857
+ tableName: n.pop(),
2858
+ schemaName: n.pop() || null,
2859
+ fieldNames: s
2860
+ } : n.length === 1 ? {
2850
2861
  schemaName: e.schemaName,
2851
2862
  tableName: e.name,
2852
- fieldNames: [s[0]]
2863
+ fieldNames: [n[0]]
2853
2864
  } : {
2854
- fieldNames: [s.pop()],
2855
- tableName: s.pop(),
2856
- schemaName: s.pop() || null
2865
+ fieldNames: [n.pop()],
2866
+ tableName: n.pop(),
2867
+ schemaName: n.pop() || null
2857
2868
  };
2858
2869
  }
2859
2870
  function St(t) {
@@ -2880,83 +2891,83 @@ function k(t) {
2880
2891
  };
2881
2892
  }
2882
2893
  function Ce(t) {
2883
- var s;
2884
- const e = (s = Ee(t).unwrap_or(void 0)) == null ? void 0 : s.pop();
2885
- return e instanceof J ? e.elementList.map((n) => n.referee) : [e.referee];
2894
+ var n;
2895
+ const e = (n = Ee(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2896
+ return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
2886
2897
  }
2887
- function Ae(t) {
2888
- const e = W(t).unwrap();
2898
+ function Ne(t) {
2899
+ const e = C(t).unwrap();
2889
2900
  return {
2890
2901
  name: e.pop(),
2891
2902
  schemaName: e
2892
2903
  };
2893
2904
  }
2894
- function $n(t) {
2905
+ function Ot(t) {
2895
2906
  return t.expression.literal.value;
2896
2907
  }
2897
- function Ot(t, e) {
2908
+ function Dt(t, e) {
2898
2909
  if (Array.isArray(t)) {
2899
2910
  const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
2900
2911
  return i < r ? `${i}-${r}` : `${i}-${r}`;
2901
2912
  }
2902
- const s = t.id, n = e.id;
2903
- return s < n ? `${s}-${n}` : `${n}-${s}`;
2913
+ const n = t.id, s = e.id;
2914
+ return n < s ? `${n}-${s}` : `${s}-${n}`;
2904
2915
  }
2905
- function Dt(t, e) {
2916
+ function Rt(t, e) {
2906
2917
  if (Array.isArray(t)) {
2907
2918
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
2908
- return I.zip(i, r).every(([a, l]) => a === l);
2919
+ return I.zip(i, r).every(([a, c]) => a === c);
2909
2920
  }
2910
- const s = t.id, n = e.id;
2911
- return s === n;
2921
+ const n = t.id, s = e.id;
2922
+ return n === s;
2912
2923
  }
2913
2924
  class Ke {
2914
- constructor(e, s) {
2915
- this.declarationNode = e, this.env = s, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
2925
+ constructor(e, n) {
2926
+ this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
2916
2927
  }
2917
2928
  interpret() {
2918
2929
  return this.ref.token = k(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
2919
2930
  }
2920
2931
  interpretName(e) {
2921
- const s = [], n = W(this.declarationNode.name).unwrap_or([]);
2922
- 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;
2932
+ const n = [], s = C(this.declarationNode.name).unwrap_or([]);
2933
+ return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
2923
2934
  }
2924
2935
  interpretBody(e) {
2925
- return e instanceof x ? this.interpretField(e) : this.interpretField(e.body[0]);
2936
+ return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
2926
2937
  }
2927
2938
  interpretField(e) {
2928
2939
  var h, T, f, N;
2929
- const s = e.callee.op.value, { leftExpression: n, rightExpression: i } = e.callee, r = Ce(n), a = Ce(i);
2930
- if (Dt(r, a))
2931
- return [new u(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
2932
- const l = Ot(r, a);
2933
- if (this.env.refIds[l])
2940
+ const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
2941
+ if (Rt(r, a))
2942
+ return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
2943
+ const c = Dt(r, a);
2944
+ if (this.env.refIds[c])
2934
2945
  return [
2935
- new u(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
2936
- new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
2946
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
2947
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
2937
2948
  ];
2938
2949
  if (e.args[0]) {
2939
- const g = z(e.args[0]).getValue();
2940
- this.ref.onDelete = G((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = G((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
2950
+ const g = $(e.args[0]).getValue();
2951
+ this.ref.onDelete = X((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = X((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
2941
2952
  }
2942
- const p = St(s);
2953
+ const p = St(n);
2943
2954
  return this.ref.endpoints = [
2944
2955
  {
2945
- ...pt(n, this.container),
2956
+ ...pt(s, this.container),
2946
2957
  relation: p[0],
2947
- token: k(n)
2958
+ token: k(s)
2948
2959
  },
2949
2960
  {
2950
2961
  ...pt(i, this.container),
2951
2962
  relation: p[1],
2952
2963
  token: k(i)
2953
2964
  }
2954
- ], this.env.refIds[l] = this.declarationNode, [];
2965
+ ], this.env.refIds[c] = this.declarationNode, [];
2955
2966
  }
2956
2967
  }
2957
- class Rt {
2958
- constructor(e, s) {
2959
- this.declarationNode = e, this.env = s, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2968
+ class Pt {
2969
+ constructor(e, n) {
2970
+ this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2960
2971
  }
2961
2972
  interpret() {
2962
2973
  this.table.token = k(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
@@ -2967,7 +2978,7 @@ class Rt {
2967
2978
  ...this.interpretBody(this.declarationNode.body)
2968
2979
  ];
2969
2980
  return this.pkColumns.length >= 2 && (this.table.indexes.push({
2970
- columns: this.pkColumns.map(({ name: s }) => ({ value: s, type: "column" })),
2981
+ columns: this.pkColumns.map(({ name: n }) => ({ value: n, type: "column" })),
2971
2982
  token: {
2972
2983
  start: { offset: -1, line: -1, column: -1 },
2973
2984
  // do not make sense to have a meaningful start (?)
@@ -2975,183 +2986,183 @@ class Rt {
2975
2986
  // do not make sense to have a meaningful end (?)
2976
2987
  },
2977
2988
  pk: !0
2978
- }), this.pkColumns.forEach((s) => s.pk = !1)), e;
2989
+ }), this.pkColumns.forEach((n) => n.pk = !1)), e;
2979
2990
  }
2980
2991
  interpretName(e) {
2981
- const { name: s, schemaName: n } = Ae(e);
2982
- 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, []);
2992
+ const { name: n, schemaName: s } = Ne(e);
2993
+ return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
2983
2994
  }
2984
2995
  interpretAlias(e) {
2985
2996
  if (!e)
2986
2997
  return [];
2987
- const s = V(e).unwrap_or(null);
2988
- return s && (this.env.aliases.push({
2989
- name: s,
2998
+ const n = G(e).unwrap_or(null);
2999
+ return n && (this.env.aliases.push({
3000
+ name: n,
2990
3001
  kind: "table",
2991
3002
  value: {
2992
3003
  tableName: this.table.name,
2993
3004
  schemaName: this.table.schemaName
2994
3005
  }
2995
- }), this.table.alias = s), [];
3006
+ }), this.table.alias = n), [];
2996
3007
  }
2997
3008
  interpretSettingList(e) {
2998
- var r, a, l;
2999
- const s = z(e).getValue();
3000
- this.table.headerColor = (r = s.headercolor) != null && r.length ? $n((l = (a = s.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
3001
- const [n] = s.note || [], i = Y(n == null ? void 0 : n.value).unwrap_or(void 0);
3002
- return this.table.note = n && {
3009
+ var r, a, c;
3010
+ const n = $(e).getValue();
3011
+ this.table.headerColor = (r = n.headercolor) != null && r.length ? Ot((c = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : c.value) : void 0;
3012
+ const [s] = n.note || [], i = z(s == null ? void 0 : s.value).unwrap_or(void 0);
3013
+ return this.table.note = s && {
3003
3014
  value: i,
3004
- token: k(n)
3015
+ token: k(s)
3005
3016
  }, [];
3006
3017
  }
3007
3018
  interpretBody(e) {
3008
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
3009
- return [...this.interpretFields(s), ...this.interpretSubElements(n)];
3019
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
3020
+ return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3010
3021
  }
3011
3022
  interpretSubElements(e) {
3012
- return e.flatMap((s) => {
3013
- var n;
3014
- switch ((n = s.type) == null ? void 0 : n.value.toLowerCase()) {
3023
+ return e.flatMap((n) => {
3024
+ var s;
3025
+ switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3015
3026
  case "note":
3016
3027
  return this.table.note = {
3017
- value: Y(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
3018
- token: k(s)
3028
+ value: z(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
3029
+ token: k(n)
3019
3030
  }, [];
3020
3031
  case "indexes":
3021
- return this.interpretIndexes(s);
3032
+ return this.interpretIndexes(n);
3022
3033
  case "ref":
3023
- return new Ke(s, this.env).interpret();
3034
+ return new Ke(n, this.env).interpret();
3024
3035
  }
3025
3036
  return [];
3026
3037
  });
3027
3038
  }
3028
3039
  interpretFields(e) {
3029
- return e.flatMap((s) => this.interpretColumn(s));
3040
+ return e.flatMap((n) => this.interpretColumn(n));
3030
3041
  }
3031
3042
  interpretColumn(e) {
3032
- var a, l, p, h, T, f, N, g;
3033
- const s = [], n = {};
3034
- n.name = V(e.callee).unwrap();
3035
- const i = Wn(e.args[0]);
3036
- n.type = i.getValue(), s.push(...i.getErrors()), n.token = k(e), n.inline_refs = [];
3043
+ var a, c, p, h, T, f, N, g;
3044
+ const n = [], s = {};
3045
+ s.name = G(e.callee).unwrap();
3046
+ const i = jn(e.args[0]);
3047
+ s.type = i.getValue(), n.push(...i.getErrors()), s.token = k(e), s.inline_refs = [];
3037
3048
  const r = e.args.slice(1);
3038
3049
  if (I.last(r) instanceof U) {
3039
- const v = z(r.pop()).getValue();
3040
- n.pk = !!((a = v.pk) != null && a.length) || !!((l = v["primary key"]) != null && l.length), n.increment = !!((p = v.increment) != null && p.length), n.unique = !!((h = v.unique) != null && h.length), n.not_null = !!((T = v["not null"]) != null && T.length) && !0, n.dbdefault = jn((N = (f = v.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3041
- const Ne = (g = v.note) == null ? void 0 : g.at(0);
3042
- n.note = Ne && {
3043
- value: Y(Ne.value).unwrap(),
3044
- token: k(Ne)
3050
+ const w = $(r.pop()).getValue();
3051
+ s.pk = !!((a = w.pk) != null && a.length) || !!((c = w["primary key"]) != null && c.length), s.increment = !!((p = w.increment) != null && p.length), s.unique = !!((h = w.unique) != null && h.length), s.not_null = !!((T = w["not null"]) != null && T.length) && !0, s.dbdefault = Yn((N = (f = w.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3052
+ const me = (g = w.note) == null ? void 0 : g.at(0);
3053
+ s.note = me && {
3054
+ value: z(me.value).unwrap(),
3055
+ token: k(me)
3045
3056
  };
3046
- const me = v.ref || [];
3047
- n.inline_refs = me.flatMap((j) => {
3048
- const [nt] = Ce(j.value.expression);
3049
- if (Dt(nt, e.symbol))
3050
- return s.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", j)), [];
3051
- const ve = j.value.op, Z = W(j.value.expression).unwrap();
3052
- let ce;
3057
+ const Te = w.ref || [];
3058
+ s.inline_refs = Te.flatMap((Y) => {
3059
+ const [nt] = Ce(Y.value.expression);
3060
+ if (Rt(nt, e.symbol))
3061
+ return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
3062
+ const ve = Y.value.op, Z = C(Y.value.expression).unwrap();
3063
+ let le;
3053
3064
  if (Z.length === 1) {
3054
3065
  const [ae] = Z;
3055
- ce = {
3066
+ le = {
3056
3067
  schemaName: this.table.schemaName,
3057
3068
  tableName: this.table.name,
3058
3069
  fieldNames: [ae],
3059
3070
  relation: ve.value,
3060
- token: k(j)
3071
+ token: k(Y)
3061
3072
  };
3062
3073
  } else if (Z.length === 2) {
3063
- const [ae, Te] = Z;
3064
- ce = {
3074
+ const [ae, be] = Z;
3075
+ le = {
3065
3076
  schemaName: null,
3066
3077
  tableName: ae,
3067
- fieldNames: [Te],
3078
+ fieldNames: [be],
3068
3079
  relation: ve.value,
3069
- token: k(j)
3080
+ token: k(Y)
3070
3081
  };
3071
3082
  } else if (Z.length === 3) {
3072
- const [ae, Te, it] = Z;
3073
- ce = {
3083
+ const [ae, be, it] = Z;
3084
+ le = {
3074
3085
  schemaName: ae,
3075
- tableName: Te,
3086
+ tableName: be,
3076
3087
  fieldNames: [it],
3077
3088
  relation: ve.value,
3078
- token: k(j)
3089
+ token: k(Y)
3079
3090
  };
3080
3091
  } else {
3081
- s.push(new u(o.UNSUPPORTED, "Nested schema is not supported", j));
3082
- const ae = Z.pop(), Te = Z.pop();
3083
- ce = {
3092
+ n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", Y));
3093
+ const ae = Z.pop(), be = Z.pop();
3094
+ le = {
3084
3095
  schemaName: Z.join("."),
3085
- tableName: Te,
3096
+ tableName: be,
3086
3097
  fieldNames: [ae],
3087
3098
  relation: ve.value,
3088
- token: k(j)
3099
+ token: k(Y)
3089
3100
  };
3090
3101
  }
3091
- const st = this.registerInlineRefToEnv(e, nt, ce, j);
3092
- return s.push(...st), st.length === 0 ? ce : [];
3102
+ const st = this.registerInlineRefToEnv(e, nt, le, Y);
3103
+ return n.push(...st), st.length === 0 ? le : [];
3093
3104
  });
3094
3105
  }
3095
- return n.pk || (n.pk = r.some((v) => G(v).unwrap().toLowerCase() === "pk")), n.unique || (n.unique = r.some((v) => G(v).unwrap().toLowerCase() === "unique")), this.table.fields.push(n), n.pk && this.pkColumns.push(n), s;
3106
+ return s.pk || (s.pk = r.some((w) => X(w).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((w) => X(w).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3096
3107
  }
3097
3108
  interpretIndexes(e) {
3098
- return this.table.indexes.push(...e.body.body.map((s) => {
3099
- var a, l, p, h, T, f, N;
3100
- const n = { columns: [] }, i = s;
3101
- n.token = k(e);
3109
+ return this.table.indexes.push(...e.body.body.map((n) => {
3110
+ var a, c, p, h, T, f, N;
3111
+ const s = { columns: [] }, i = n;
3112
+ s.token = k(e);
3102
3113
  const r = [i.callee, ...i.args];
3103
3114
  if (I.last(r) instanceof U) {
3104
- const g = z(r.pop()).getValue();
3105
- n.pk = !!((a = g.pk) != null && a.length), n.unique = !!((l = g.unique) != null && l.length), n.name = Y((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3106
- const v = (T = g.note) == null ? void 0 : T.at(0);
3107
- n.note = v && {
3108
- value: Y(v.value).unwrap(),
3109
- token: k(v)
3110
- }, n.type = G((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3115
+ const g = $(r.pop()).getValue();
3116
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3117
+ const w = (T = g.note) == null ? void 0 : T.at(0);
3118
+ s.note = w && {
3119
+ value: z(w.value).unwrap(),
3120
+ token: k(w)
3121
+ }, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3111
3122
  }
3112
3123
  return r.flatMap((g) => {
3113
3124
  if (!(g instanceof H))
3114
3125
  return g;
3115
- const v = [];
3126
+ const w = [];
3116
3127
  for (; g instanceof H; )
3117
- v.push(g.argumentList), g = g.callee;
3118
- return v.push(g), v;
3128
+ w.push(g.argumentList), g = g.callee;
3129
+ return w.push(g), w;
3119
3130
  }).forEach((g) => {
3120
- const { functional: v, nonFunctional: Ne } = Ge(g).unwrap();
3121
- n.columns.push(
3122
- ...v.map((me) => ({
3123
- value: me.value.value,
3131
+ const { functional: w, nonFunctional: me } = Ge(g).unwrap();
3132
+ s.columns.push(
3133
+ ...w.map((Te) => ({
3134
+ value: Te.value.value,
3124
3135
  type: "expression"
3125
3136
  })),
3126
- ...Ne.map((me) => ({
3127
- value: V(me).unwrap(),
3137
+ ...me.map((Te) => ({
3138
+ value: G(Te).unwrap(),
3128
3139
  type: "column"
3129
3140
  }))
3130
3141
  );
3131
- }), n;
3142
+ }), s;
3132
3143
  })), [];
3133
3144
  }
3134
- registerInlineRefToEnv(e, s, n, i) {
3135
- const r = Ot(e.symbol, s);
3145
+ registerInlineRefToEnv(e, n, s, i) {
3146
+ const r = Dt(e.symbol, n);
3136
3147
  if (this.env.refIds[r])
3137
3148
  return [
3138
- new u(o.CIRCULAR_REF, "References with same endpoints exist", i),
3139
- new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3149
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
3150
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3140
3151
  ];
3141
- const a = St(n.relation);
3152
+ const a = St(s.relation);
3142
3153
  return this.env.refIds[r] = i, this.env.ref.set(i, {
3143
3154
  name: null,
3144
3155
  schemaName: null,
3145
- token: n.token,
3156
+ token: s.token,
3146
3157
  endpoints: [
3147
3158
  {
3148
- ...n,
3159
+ ...s,
3149
3160
  relation: a[1]
3150
3161
  },
3151
3162
  {
3152
3163
  schemaName: this.table.schemaName,
3153
3164
  tableName: this.table.name,
3154
- fieldNames: [G(e.callee).unwrap()],
3165
+ fieldNames: [X(e.callee).unwrap()],
3155
3166
  token: k(e),
3156
3167
  relation: a[0]
3157
3168
  }
@@ -3159,35 +3170,35 @@ class Rt {
3159
3170
  }), [];
3160
3171
  }
3161
3172
  }
3162
- function Wn(t) {
3173
+ function jn(t) {
3163
3174
  let e = null;
3164
- t instanceof H && (e = t.argumentList.elementList.map((r) => le(r) ? r.expression.literal.value : $(r) ? Y(r).unwrap() : G(r).unwrap()).join(","), t = t.callee);
3165
- let s = "";
3175
+ t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
3176
+ let n = "";
3166
3177
  for (; t instanceof he; )
3167
- s = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${s}`, t = t.array;
3168
- const { name: n, schemaName: i } = Ae(t);
3169
- return i.length > 1 && new F(
3178
+ n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3179
+ const { name: s, schemaName: i } = Ne(t);
3180
+ return i.length > 1 && new B(
3170
3181
  {
3171
3182
  schemaName: i.length === 0 ? null : i[0],
3172
- type_name: `${n}${s}${e ? `(${e})` : ""}`,
3183
+ type_name: `${s}${n}${e ? `(${e})` : ""}`,
3173
3184
  args: e
3174
3185
  },
3175
- [new u(o.UNSUPPORTED, "Nested schema is not supported", t)]
3176
- ), new F({
3186
+ [new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
3187
+ ), new B({
3177
3188
  schemaName: i.length === 0 ? null : i[0],
3178
- type_name: `${n}${s}${e ? `(${e})` : ""}`,
3189
+ type_name: `${s}${n}${e ? `(${e})` : ""}`,
3179
3190
  args: e
3180
3191
  });
3181
3192
  }
3182
- function jn(t) {
3183
- var e, s, n;
3193
+ function Yn(t) {
3194
+ var e, n, s;
3184
3195
  if (t) {
3185
- if ($(t))
3196
+ if (j(t))
3186
3197
  return {
3187
- value: Y(t).unwrap(),
3198
+ value: z(t).unwrap(),
3188
3199
  type: "string"
3189
3200
  };
3190
- if (le(t))
3201
+ if (ce(t))
3191
3202
  return {
3192
3203
  type: "number",
3193
3204
  value: Number.parseFloat(t.expression.literal.value)
@@ -3197,65 +3208,96 @@ function jn(t) {
3197
3208
  value: t.expression.variable.value.toLowerCase(),
3198
3209
  type: "boolean"
3199
3210
  };
3200
- if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression)) {
3211
+ if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression)) {
3201
3212
  const i = Number.parseFloat(t.expression.expression.literal.value);
3202
3213
  return {
3203
- value: ((s = t.op) == null ? void 0 : s.value) === "-" ? 0 - i : i,
3214
+ value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
3204
3215
  type: "number"
3205
3216
  };
3206
3217
  }
3207
3218
  if (t instanceof K)
3208
3219
  return {
3209
- value: (n = t.value) == null ? void 0 : n.value,
3220
+ value: (s = t.value) == null ? void 0 : s.value,
3210
3221
  type: "expression"
3211
3222
  };
3212
3223
  throw new Error("Unreachable");
3213
3224
  }
3214
3225
  }
3215
- class Pt {
3216
- constructor(e, s) {
3217
- this.declarationNode = e, this.env = s, this.tableGroup = { tables: [] };
3226
+ class zn {
3227
+ constructor(e, n) {
3228
+ this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3229
+ }
3230
+ interpret() {
3231
+ return this.note.token = k(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3232
+ ...this.interpretName(this.declarationNode.name),
3233
+ ...this.interpretSettingList(this.declarationNode.attributeList),
3234
+ ...this.interpretBody(this.declarationNode.body)
3235
+ ];
3236
+ }
3237
+ interpretName(e) {
3238
+ const { name: n } = Ne(e);
3239
+ return this.note.name = n, [];
3240
+ }
3241
+ interpretSettingList(e) {
3242
+ var s, i, r;
3243
+ const n = $(e).getValue();
3244
+ return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ot((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3245
+ }
3246
+ interpretBody(e) {
3247
+ const [n, s] = I.partition(e.body, (i) => i instanceof v);
3248
+ return n.length !== 1 || s.length > 0 ? [
3249
+ new l(o.INVALID_NOTE, "Invalid note syntax", e)
3250
+ ] : [...this.interpretNote(n[0])];
3251
+ }
3252
+ interpretNote(e) {
3253
+ const n = I.get(e, "callee.expression.literal.value", "");
3254
+ return this.note.content = n, [];
3255
+ }
3256
+ }
3257
+ class Ut {
3258
+ constructor(e, n) {
3259
+ this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3218
3260
  }
3219
3261
  interpret() {
3220
3262
  const e = [];
3221
3263
  this.tableGroup.token = k(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
3222
- const { name: s, schemaName: n } = Ae(this.declarationNode.name);
3223
- 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) => {
3224
- const r = W(i.callee).unwrap();
3225
- return r.length > 2 && e.push(new u(o.UNSUPPORTED, "Nested schema is not supported", i)), {
3264
+ const { name: n, schemaName: s } = Ne(this.declarationNode.name);
3265
+ return s.length >= 2 && (this.tableGroup.name = n, this.tableGroup.schemaName = s.join("."), e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = n, this.tableGroup.schemaName = s[0] || null, this.tableGroup.tables = this.declarationNode.body.body.map((i) => {
3266
+ const r = C(i.callee).unwrap();
3267
+ return r.length > 2 && e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", i)), {
3226
3268
  name: r.pop(),
3227
3269
  schemaName: r.join(".")
3228
3270
  };
3229
3271
  }), e;
3230
3272
  }
3231
3273
  }
3232
- class Ut {
3233
- constructor(e, s) {
3234
- this.declarationNode = e, this.env = s, this.enum = { values: [] };
3274
+ class Mt {
3275
+ constructor(e, n) {
3276
+ this.declarationNode = e, this.env = n, this.enum = { values: [] };
3235
3277
  }
3236
3278
  interpret() {
3237
3279
  return this.enum.token = k(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3238
3280
  }
3239
3281
  interpretName(e) {
3240
- const { name: s, schemaName: n } = Ae(e);
3241
- 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, []);
3282
+ const { name: n, schemaName: s } = Ne(e);
3283
+ return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3242
3284
  }
3243
3285
  interpretBody(e) {
3244
- return e.body.flatMap((s) => {
3245
- var l;
3246
- const n = s, i = {};
3247
- i.token = k(n), i.name = G(n.callee).unwrap();
3248
- const a = (l = z(n.args[0]).getValue().note) == null ? void 0 : l.at(0);
3286
+ return e.body.flatMap((n) => {
3287
+ var c;
3288
+ const s = n, i = {};
3289
+ i.token = k(s), i.name = X(s.callee).unwrap();
3290
+ const a = (c = $(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
3249
3291
  return i.note = a && {
3250
- value: Y(a.value).unwrap(),
3292
+ value: z(a.value).unwrap(),
3251
3293
  token: k(a)
3252
3294
  }, this.enum.values.push(i), [];
3253
3295
  });
3254
3296
  }
3255
3297
  }
3256
- class Yn {
3257
- constructor(e, s) {
3258
- this.declarationNode = e, this.env = s, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3298
+ class Qn {
3299
+ constructor(e, n) {
3300
+ this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3259
3301
  }
3260
3302
  interpret() {
3261
3303
  return this.env.project.set(this.declarationNode, this.project), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
@@ -3263,46 +3305,47 @@ class Yn {
3263
3305
  interpretName(e) {
3264
3306
  if (!e)
3265
3307
  return this.project.name = null, [];
3266
- const { name: s } = Ae(e);
3267
- return this.project.name = s, [];
3308
+ const { name: n } = Ne(e);
3309
+ return this.project.name = n, [];
3268
3310
  }
3269
3311
  interpretBody(e) {
3270
- return e.body.flatMap((s) => {
3312
+ return e.body.flatMap((n) => {
3271
3313
  var i;
3272
- const n = s;
3273
- switch ((i = n.type) == null ? void 0 : i.value.toLowerCase()) {
3314
+ const s = n;
3315
+ switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
3274
3316
  case "table": {
3275
- const r = new Rt(n, this.env).interpret();
3276
- return this.project.tables.push(this.env.tables.get(n)), r;
3317
+ const r = new Pt(s, this.env).interpret();
3318
+ return this.project.tables.push(this.env.tables.get(s)), r;
3277
3319
  }
3278
3320
  case "ref": {
3279
- const r = new Ke(n, this.env).interpret();
3280
- return this.project.refs.push(this.env.ref.get(n)), r;
3321
+ const r = new Ke(s, this.env).interpret();
3322
+ return this.project.refs.push(this.env.ref.get(s)), r;
3281
3323
  }
3282
3324
  case "tablegroup": {
3283
- const r = new Pt(n, this.env).interpret();
3284
- return this.project.tableGroups.push(this.env.tableGroups.get(n)), r;
3325
+ const r = new Ut(s, this.env).interpret();
3326
+ return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
3285
3327
  }
3286
3328
  case "enum": {
3287
- const r = new Ut(n, this.env).interpret();
3288
- return this.project.enums.push(this.env.enums.get(n)), r;
3329
+ const r = new Mt(s, this.env).interpret();
3330
+ return this.project.enums.push(this.env.enums.get(s)), r;
3289
3331
  }
3290
3332
  case "note":
3291
3333
  return this.project.note = {
3292
- value: Y(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
3293
- token: k(n)
3334
+ value: z(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
3335
+ token: k(s)
3294
3336
  }, [];
3295
3337
  default:
3296
- return this.project[n.type.value.toLowerCase()] = Y(n.body.callee).unwrap(), [];
3338
+ return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
3297
3339
  }
3298
3340
  });
3299
3341
  }
3300
3342
  }
3301
- class zn {
3343
+ class qn {
3302
3344
  constructor(e) {
3303
3345
  this.ast = e, this.env = {
3304
3346
  schema: [],
3305
3347
  tables: /* @__PURE__ */ new Map(),
3348
+ notes: /* @__PURE__ */ new Map(),
3306
3349
  refIds: {},
3307
3350
  ref: /* @__PURE__ */ new Map(),
3308
3351
  enums: /* @__PURE__ */ new Map(),
@@ -3312,29 +3355,32 @@ class zn {
3312
3355
  };
3313
3356
  }
3314
3357
  interpret() {
3315
- const e = this.ast.body.flatMap((s) => {
3316
- switch (de(s).unwrap_or(void 0)) {
3358
+ const e = this.ast.body.flatMap((n) => {
3359
+ switch (de(n).unwrap_or(void 0)) {
3317
3360
  case b.Table:
3318
- return new Rt(s, this.env).interpret();
3361
+ return new Pt(n, this.env).interpret();
3362
+ case b.Note:
3363
+ return new zn(n, this.env).interpret();
3319
3364
  case b.Ref:
3320
- return new Ke(s, this.env).interpret();
3365
+ return new Ke(n, this.env).interpret();
3321
3366
  case b.TableGroup:
3322
- return new Pt(s, this.env).interpret();
3367
+ return new Ut(n, this.env).interpret();
3323
3368
  case b.Enum:
3324
- return new Ut(s, this.env).interpret();
3369
+ return new Mt(n, this.env).interpret();
3325
3370
  case b.Project:
3326
- return new Yn(s, this.env).interpret();
3371
+ return new Qn(n, this.env).interpret();
3327
3372
  default:
3328
3373
  return [];
3329
3374
  }
3330
3375
  });
3331
- return new F(Qn(this.env), e);
3376
+ return new B(Hn(this.env), e);
3332
3377
  }
3333
3378
  }
3334
- function Qn(t) {
3379
+ function Hn(t) {
3335
3380
  return {
3336
3381
  schemas: [],
3337
3382
  tables: Array.from(t.tables.values()),
3383
+ notes: Array.from(t.notes.values()),
3338
3384
  refs: Array.from(t.ref.values()),
3339
3385
  enums: Array.from(t.enums.values()),
3340
3386
  tableGroups: Array.from(t.tableGroups.values()),
@@ -3342,8 +3388,8 @@ function Qn(t) {
3342
3388
  project: Array.from(t.project.values())[0] || {}
3343
3389
  };
3344
3390
  }
3345
- var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
3346
- function ge(t) {
3391
+ var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
3392
+ function _e(t) {
3347
3393
  switch (t) {
3348
3394
  case m.Schema:
3349
3395
  return L.Module;
@@ -3366,10 +3412,10 @@ function ge(t) {
3366
3412
  function Se(t, e) {
3367
3413
  if (!t || Ve(t))
3368
3414
  return !1;
3369
- for (const s of t.trailingTrivia) {
3370
- if (s.start > e)
3415
+ for (const n of t.trailingTrivia) {
3416
+ if (n.start > e)
3371
3417
  break;
3372
- if (s.kind === c.NEWLINE && s.end <= e)
3418
+ if (n.kind === u.NEWLINE && n.end <= e)
3373
3419
  return !1;
3374
3420
  }
3375
3421
  return !0;
@@ -3400,27 +3446,27 @@ function Ue(t) {
3400
3446
  function et(t, e) {
3401
3447
  return t.getOffsetAt(e);
3402
3448
  }
3403
- class Mt {
3404
- constructor(e, s = []) {
3405
- this.compiler = e, this.triggerCharacters = s;
3449
+ class Ft {
3450
+ constructor(e, n = []) {
3451
+ this.compiler = e, this.triggerCharacters = n;
3406
3452
  }
3407
- provideCompletionItems(e, s) {
3453
+ provideCompletionItems(e, n) {
3408
3454
  var T, f;
3409
- 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];
3455
+ const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), c = a === void 0 ? i[0] : i[a + 1];
3410
3456
  if ([
3411
3457
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3412
3458
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3413
- ...(l == null ? void 0 : l.leadingTrivia) || []
3414
- ].find((N) => $t(N) && Ie(n, N)))
3459
+ ...(c == null ? void 0 : c.leadingTrivia) || []
3460
+ ].find((N) => Wt(N) && Le(s, N)))
3415
3461
  return O();
3416
3462
  if (a === void 0)
3417
3463
  return Tt();
3418
- if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && Ie(n, r))
3464
+ if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
3419
3465
  return O();
3420
- const p = this.compiler.container.element(n);
3421
- if (this.compiler.container.scopeKind(n) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= n && p.type.end >= n)
3466
+ const p = this.compiler.container.element(s);
3467
+ if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
3422
3468
  return Tt();
3423
- const h = [...this.compiler.container.stack(n)].reverse();
3469
+ const h = [...this.compiler.container.stack(s)].reverse();
3424
3470
  for (const N of h)
3425
3471
  if (N instanceof Q)
3426
3472
  switch ((T = N.op) == null ? void 0 : T.value) {
@@ -3430,7 +3476,7 @@ class Mt {
3430
3476
  case "-":
3431
3477
  return dt(
3432
3478
  this.compiler,
3433
- n,
3479
+ s,
3434
3480
  N
3435
3481
  );
3436
3482
  }
@@ -3442,59 +3488,59 @@ class Mt {
3442
3488
  case "-":
3443
3489
  return dt(
3444
3490
  this.compiler,
3445
- n,
3491
+ s,
3446
3492
  N
3447
3493
  );
3448
3494
  case ".":
3449
- return Ft(
3495
+ return Bt(
3450
3496
  this.compiler,
3451
- n,
3497
+ s,
3452
3498
  N
3453
3499
  );
3454
3500
  }
3455
3501
  else {
3456
3502
  if (N instanceof ne)
3457
- return Et(this.compiler, n, N);
3503
+ return Et(this.compiler, s, N);
3458
3504
  if (N instanceof U)
3459
- return Et(this.compiler, n, N);
3505
+ return Et(this.compiler, s, N);
3460
3506
  if (N instanceof J)
3461
- return qn(this.compiler, n);
3462
- if (N instanceof x)
3463
- return mt(this.compiler, n, N);
3464
- if (N instanceof _ && (N.bodyColon && n >= N.bodyColon.end || N.body && Ie(n, N.body)))
3465
- return mt(this.compiler, n, void 0);
3507
+ return Jn(this.compiler, s);
3508
+ if (N instanceof v)
3509
+ return mt(this.compiler, s, N);
3510
+ if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
3511
+ return mt(this.compiler, s, void 0);
3466
3512
  }
3467
3513
  return O();
3468
3514
  }
3469
3515
  }
3470
- function dt(t, e, s) {
3471
- const n = t.container.scopeKind(e);
3472
- if ([D.REF, D.TABLE].includes(n)) {
3516
+ function dt(t, e, n) {
3517
+ const s = t.container.scopeKind(e);
3518
+ if ([D.REF, D.TABLE].includes(s)) {
3473
3519
  const i = Me(t, e, t.container.element(e), [
3474
3520
  m.Table,
3475
3521
  m.Schema,
3476
3522
  m.Column
3477
3523
  ]);
3478
- return Se(s.op, e) ? Oe(i) : i;
3524
+ return Se(n.op, e) ? Oe(i) : i;
3479
3525
  }
3480
3526
  return O();
3481
3527
  }
3482
- function Me(t, e, s, n) {
3528
+ function Me(t, e, n, s) {
3483
3529
  var a;
3484
- if (s === void 0)
3530
+ if (n === void 0)
3485
3531
  return O();
3486
- let i = s;
3532
+ let i = n;
3487
3533
  const r = { suggestions: [] };
3488
3534
  for (; i; ) {
3489
3535
  if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
3490
- const { symbol: l } = i;
3536
+ const { symbol: c } = i;
3491
3537
  r.suggestions.push(
3492
- ...t.symbol.members(l).filter(({ kind: p }) => n.includes(p)).map(({ name: p, kind: h }) => ({
3538
+ ...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3493
3539
  label: p,
3494
3540
  insertText: p,
3495
- insertTextRules: w.KeepWhitespace,
3496
- kind: ge(h),
3497
- sortText: ge(h).toString().padStart(2, "0"),
3541
+ insertTextRules: y.KeepWhitespace,
3542
+ kind: _e(h),
3543
+ sortText: _e(h).toString().padStart(2, "0"),
3498
3544
  range: void 0
3499
3545
  }))
3500
3546
  );
@@ -3503,52 +3549,52 @@ function Me(t, e, s, n) {
3503
3549
  }
3504
3550
  return Ue(r);
3505
3551
  }
3506
- function qn(t, e) {
3507
- var n;
3552
+ function Jn(t, e) {
3553
+ var s;
3508
3554
  switch (t.container.scopeKind(e)) {
3509
3555
  case D.INDEXES:
3510
- return Vt(t, e);
3556
+ return Gt(t, e);
3511
3557
  case D.REF:
3512
3558
  {
3513
3559
  const i = [...t.container.stack(e)];
3514
3560
  for (; i.length > 0; ) {
3515
3561
  const r = i.pop();
3516
- if (r instanceof q && ((n = r.op) == null ? void 0 : n.value) === ".")
3517
- return Ft(
3562
+ if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
3563
+ return Bt(
3518
3564
  t,
3519
3565
  e,
3520
3566
  r
3521
3567
  );
3522
3568
  }
3523
3569
  }
3524
- return Bt(t, e);
3570
+ return Vt(t, e);
3525
3571
  }
3526
3572
  return O();
3527
3573
  }
3528
- function Et(t, e, s) {
3529
- const { token: n } = t.container.token(e);
3530
- if ([c.COMMA, c.LBRACKET].includes(n == null ? void 0 : n.kind)) {
3574
+ function Et(t, e, n) {
3575
+ const { token: s } = t.container.token(e);
3576
+ if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3531
3577
  const i = Nt(t, e);
3532
- return (n == null ? void 0 : n.kind) === c.COMMA && Se(n, e) ? Oe(i) : i;
3578
+ return (s == null ? void 0 : s.kind) === u.COMMA && Se(s, e) ? Oe(i) : i;
3533
3579
  }
3534
- if (s.name && s.name.start <= e && s.name.end >= e)
3580
+ if (n.name && n.name.start <= e && n.name.end >= e)
3535
3581
  return Nt(t, e);
3536
- if (s.name) {
3537
- const i = Hn(
3582
+ if (n.name) {
3583
+ const i = Zn(
3538
3584
  t,
3539
3585
  e,
3540
- Re(s.name).unwrap()
3586
+ Re(n.name).unwrap()
3541
3587
  );
3542
- return (n == null ? void 0 : n.kind) === c.COLON && Se(n, e) ? Oe(i) : i;
3588
+ return (s == null ? void 0 : s.kind) === u.COLON && Se(s, e) ? Oe(i) : i;
3543
3589
  }
3544
3590
  return O();
3545
3591
  }
3546
3592
  function Nt(t, e) {
3547
- const s = t.container.element(e), n = t.container.scopeKind(e);
3548
- if (s instanceof C)
3593
+ const n = t.container.element(e), s = t.container.scopeKind(e);
3594
+ if (n instanceof F)
3549
3595
  return O();
3550
- if (s.body && !Ie(e, s.body))
3551
- switch (n) {
3596
+ if (n.body && !Le(e, n.body))
3597
+ switch (s) {
3552
3598
  case D.TABLE:
3553
3599
  return {
3554
3600
  suggestions: [
@@ -3556,14 +3602,14 @@ function Nt(t, e) {
3556
3602
  label: "headercolor",
3557
3603
  insertText: "headercolor: ",
3558
3604
  kind: L.Field,
3559
- insertTextRules: w.KeepWhitespace,
3605
+ insertTextRules: y.KeepWhitespace,
3560
3606
  range: void 0
3561
3607
  },
3562
3608
  {
3563
3609
  label: "note",
3564
3610
  insertText: "note: ",
3565
3611
  kind: L.Field,
3566
- insertTextRules: w.KeepWhitespace,
3612
+ insertTextRules: y.KeepWhitespace,
3567
3613
  range: void 0
3568
3614
  }
3569
3615
  ]
@@ -3571,7 +3617,7 @@ function Nt(t, e) {
3571
3617
  default:
3572
3618
  return O();
3573
3619
  }
3574
- switch (n) {
3620
+ switch (s) {
3575
3621
  case D.TABLE:
3576
3622
  return {
3577
3623
  suggestions: [
@@ -3579,21 +3625,21 @@ function Nt(t, e) {
3579
3625
  label: i,
3580
3626
  insertText: i,
3581
3627
  kind: L.Property,
3582
- insertTextRules: w.KeepWhitespace,
3628
+ insertTextRules: y.KeepWhitespace,
3583
3629
  range: void 0
3584
3630
  })),
3585
3631
  ...["ref", "default"].map((i) => ({
3586
3632
  label: i,
3587
3633
  insertText: `${i}: `,
3588
3634
  kind: L.Property,
3589
- insertTextRules: w.KeepWhitespace,
3635
+ insertTextRules: y.KeepWhitespace,
3590
3636
  range: void 0
3591
3637
  })),
3592
3638
  {
3593
3639
  label: "note",
3594
3640
  insertText: "note: ",
3595
3641
  kind: L.Property,
3596
- insertTextRules: w.KeepWhitespace,
3642
+ insertTextRules: y.KeepWhitespace,
3597
3643
  range: void 0
3598
3644
  }
3599
3645
  ]
@@ -3605,7 +3651,7 @@ function Nt(t, e) {
3605
3651
  label: "note",
3606
3652
  insertText: "note: ",
3607
3653
  kind: L.Property,
3608
- insertTextRules: w.KeepWhitespace,
3654
+ insertTextRules: y.KeepWhitespace,
3609
3655
  range: void 0
3610
3656
  }
3611
3657
  ]
@@ -3616,7 +3662,7 @@ function Nt(t, e) {
3616
3662
  ...["unique", "pk"].map((i) => ({
3617
3663
  label: i,
3618
3664
  insertText: i,
3619
- insertTextRules: w.KeepWhitespace,
3665
+ insertTextRules: y.KeepWhitespace,
3620
3666
  kind: L.Property,
3621
3667
  range: void 0
3622
3668
  })),
@@ -3624,7 +3670,7 @@ function Nt(t, e) {
3624
3670
  label: i,
3625
3671
  insertText: `${i}: `,
3626
3672
  kind: L.Property,
3627
- insertTextRules: w.KeepWhitespace,
3673
+ insertTextRules: y.KeepWhitespace,
3628
3674
  range: void 0
3629
3675
  }))
3630
3676
  ]
@@ -3635,70 +3681,70 @@ function Nt(t, e) {
3635
3681
  label: i,
3636
3682
  insertText: `${i}: `,
3637
3683
  kind: L.Property,
3638
- insertTextRules: w.KeepWhitespace,
3684
+ insertTextRules: y.KeepWhitespace,
3639
3685
  range: void 0
3640
3686
  }))
3641
3687
  };
3642
3688
  }
3643
3689
  return O();
3644
3690
  }
3645
- function Hn(t, e, s) {
3646
- switch (s == null ? void 0 : s.toLowerCase()) {
3691
+ function Zn(t, e, n) {
3692
+ switch (n == null ? void 0 : n.toLowerCase()) {
3647
3693
  case "update":
3648
3694
  case "delete":
3649
3695
  return {
3650
- suggestions: ["cascade", "set default", "set null", "restrict"].map((n) => ({
3651
- label: n,
3652
- insertText: n,
3696
+ suggestions: ["cascade", "set default", "set null", "restrict"].map((s) => ({
3697
+ label: s,
3698
+ insertText: s,
3653
3699
  kind: L.Value,
3654
- insertTextRules: w.KeepWhitespace,
3700
+ insertTextRules: y.KeepWhitespace,
3655
3701
  range: void 0
3656
3702
  }))
3657
3703
  };
3658
3704
  case "type":
3659
3705
  return {
3660
- suggestions: ["btree", "hash"].map((n) => ({
3661
- label: n,
3662
- insertText: `${n}`,
3706
+ suggestions: ["btree", "hash"].map((s) => ({
3707
+ label: s,
3708
+ insertText: `${s}`,
3663
3709
  kind: L.Value,
3664
- insertTextRules: w.KeepWhitespace,
3710
+ insertTextRules: y.KeepWhitespace,
3665
3711
  range: void 0
3666
3712
  }))
3667
3713
  };
3668
3714
  }
3669
3715
  return O();
3670
3716
  }
3671
- function Ft(t, e, s) {
3672
- const n = Ee(s).unwrap_or([]);
3673
- if (n.pop(), n.some((r) => !M(r)))
3717
+ function Bt(t, e, n) {
3718
+ const s = Ee(n).unwrap_or([]);
3719
+ if (s.pop(), s.some((r) => !M(r)))
3674
3720
  return O();
3675
- const i = n.map((r) => G(r).unwrap());
3721
+ const i = s.map((r) => X(r).unwrap());
3676
3722
  return Ue({
3677
3723
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3678
3724
  label: a,
3679
3725
  insertText: a,
3680
- kind: ge(r),
3726
+ kind: _e(r),
3681
3727
  range: void 0
3682
3728
  }))
3683
3729
  });
3684
3730
  }
3685
- function mt(t, e, s) {
3731
+ function mt(t, e, n) {
3686
3732
  var i;
3687
3733
  switch (t.container.scopeKind(e)) {
3688
3734
  case D.TABLE:
3689
- return Zn(t, e, s);
3735
+ return es(t, e, n);
3690
3736
  case D.PROJECT:
3691
- return Kn(t, e, s);
3737
+ return ts(t, e, n);
3692
3738
  case D.INDEXES:
3693
- return ts(t, e);
3739
+ return ss(t, e);
3694
3740
  case D.ENUM:
3695
- return Jn(t, e, s);
3741
+ return Kn(t, e, n);
3696
3742
  case D.REF: {
3697
- const r = Bt(t, e);
3698
- return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
3743
+ const r = Vt(t, e);
3744
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
3699
3745
  }
3700
3746
  case D.TABLEGROUP:
3701
- return es(t);
3747
+ return ns(t);
3702
3748
  default:
3703
3749
  return O();
3704
3750
  }
@@ -3708,47 +3754,47 @@ function Tt() {
3708
3754
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3709
3755
  label: t,
3710
3756
  insertText: t,
3711
- insertTextRules: w.KeepWhitespace,
3757
+ insertTextRules: y.KeepWhitespace,
3712
3758
  kind: L.Keyword,
3713
3759
  range: void 0
3714
3760
  }))
3715
3761
  };
3716
3762
  }
3717
- function Jn(t, e, s) {
3718
- return s != null && s.callee && tt(e, s) === 1 ? Me(t, e, t.container.element(e), [
3763
+ function Kn(t, e, n) {
3764
+ return n != null && n.callee && tt(e, n) === 1 ? Me(t, e, t.container.element(e), [
3719
3765
  m.Schema,
3720
3766
  m.Table,
3721
3767
  m.Column
3722
3768
  ]) : O();
3723
3769
  }
3724
- function Zn(t, e, s) {
3725
- if (!(s != null && s.callee))
3770
+ function es(t, e, n) {
3771
+ if (!(n != null && n.callee))
3726
3772
  return {
3727
3773
  suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3728
3774
  label: i,
3729
3775
  insertText: i,
3730
- insertTextRules: w.KeepWhitespace,
3776
+ insertTextRules: y.KeepWhitespace,
3731
3777
  kind: L.Keyword,
3732
3778
  range: void 0
3733
3779
  }))
3734
3780
  };
3735
- const n = tt(e, s);
3736
- return n === 0 ? {
3781
+ const s = tt(e, n);
3782
+ return s === 0 ? {
3737
3783
  suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3738
3784
  label: i,
3739
3785
  insertText: i,
3740
- insertTextRules: w.KeepWhitespace,
3786
+ insertTextRules: y.KeepWhitespace,
3741
3787
  kind: L.Keyword,
3742
3788
  range: void 0
3743
3789
  }))
3744
- } : n === 1 ? ns(t, e) : O();
3790
+ } : s === 1 ? is(t, e) : O();
3745
3791
  }
3746
- function Kn(t, e, s) {
3747
- return s != null && s.callee ? tt(e, s) === 0 ? {
3792
+ function ts(t, e, n) {
3793
+ return n != null && n.callee ? tt(e, n) === 0 ? {
3748
3794
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3749
3795
  label: i,
3750
3796
  insertText: i,
3751
- insertTextRules: w.KeepWhitespace,
3797
+ insertTextRules: y.KeepWhitespace,
3752
3798
  kind: L.Keyword,
3753
3799
  range: void 0
3754
3800
  }))
@@ -3756,40 +3802,40 @@ function Kn(t, e, s) {
3756
3802
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3757
3803
  label: i,
3758
3804
  insertText: i,
3759
- insertTextRules: w.KeepWhitespace,
3805
+ insertTextRules: y.KeepWhitespace,
3760
3806
  kind: L.Keyword,
3761
3807
  range: void 0
3762
3808
  }))
3763
3809
  };
3764
3810
  }
3765
- function Bt(t, e) {
3811
+ function Vt(t, e) {
3766
3812
  return Me(t, e, t.container.element(e), [
3767
3813
  m.Schema,
3768
3814
  m.Table,
3769
3815
  m.Column
3770
3816
  ]);
3771
3817
  }
3772
- function es(t) {
3818
+ function ns(t) {
3773
3819
  return Ue({
3774
3820
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3775
- const s = se(e).unwrap_or(void 0);
3776
- if (s === void 0)
3821
+ const n = se(e).unwrap_or(void 0);
3822
+ if (n === void 0)
3777
3823
  return [];
3778
- const { kind: n, name: i } = s;
3779
- return n !== m.Table && n !== m.Schema ? [] : {
3824
+ const { kind: s, name: i } = n;
3825
+ return s !== m.Table && s !== m.Schema ? [] : {
3780
3826
  label: i,
3781
3827
  insertText: i,
3782
- insertTextRules: w.KeepWhitespace,
3783
- kind: ge(n),
3828
+ insertTextRules: y.KeepWhitespace,
3829
+ kind: _e(s),
3784
3830
  range: void 0
3785
3831
  };
3786
3832
  })
3787
3833
  });
3788
3834
  }
3789
- function ts(t, e) {
3790
- return Vt(t, e);
3835
+ function ss(t, e) {
3836
+ return Gt(t, e);
3791
3837
  }
3792
- function ns(t, e) {
3838
+ function is(t, e) {
3793
3839
  return {
3794
3840
  suggestions: [
3795
3841
  ...[
@@ -3849,10 +3895,10 @@ function ns(t, e) {
3849
3895
  "CLOB",
3850
3896
  "NCLOB",
3851
3897
  "RAW"
3852
- ].map((s) => ({
3853
- label: s,
3854
- insertText: s,
3855
- insertTextRules: w.KeepWhitespace,
3898
+ ].map((n) => ({
3899
+ label: n,
3900
+ insertText: n,
3901
+ insertTextRules: y.KeepWhitespace,
3856
3902
  kind: L.TypeParameter,
3857
3903
  sortText: L.TypeParameter.toString().padStart(2, "0"),
3858
3904
  range: void 0
@@ -3864,22 +3910,22 @@ function ns(t, e) {
3864
3910
  ]
3865
3911
  };
3866
3912
  }
3867
- function Vt(t, e) {
3868
- const n = t.container.element(e).parent;
3869
- if (!((n == null ? void 0 : n.symbol) instanceof At))
3913
+ function Gt(t, e) {
3914
+ const s = t.container.element(e).parent;
3915
+ if (!((s == null ? void 0 : s.symbol) instanceof At))
3870
3916
  return O();
3871
- const { symbolTable: i } = n.symbol;
3917
+ const { symbolTable: i } = s.symbol;
3872
3918
  return Ue({
3873
3919
  suggestions: [...i.entries()].flatMap(([r]) => {
3874
3920
  const a = se(r).unwrap_or(void 0);
3875
3921
  if (a === void 0)
3876
3922
  return [];
3877
- const { name: l } = a;
3923
+ const { name: c } = a;
3878
3924
  return {
3879
- label: l,
3880
- insertText: l,
3881
- insertTextRules: w.KeepWhitespace,
3882
- kind: ge(m.Column),
3925
+ label: c,
3926
+ insertText: c,
3927
+ insertTextRules: y.KeepWhitespace,
3928
+ kind: _e(m.Column),
3883
3929
  range: void 0
3884
3930
  };
3885
3931
  })
@@ -3888,20 +3934,20 @@ function Vt(t, e) {
3888
3934
  function tt(t, e) {
3889
3935
  if (!e.callee)
3890
3936
  return -1;
3891
- const s = [e.callee, ...e.args], n = s.findIndex((i) => t <= i.end);
3892
- return n === -1 ? s.length : n;
3937
+ const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
3938
+ return s === -1 ? n.length : s;
3893
3939
  }
3894
- class Gt {
3940
+ class Ct {
3895
3941
  constructor(e) {
3896
3942
  this.compiler = e;
3897
3943
  }
3898
- provideDefinition(e, s) {
3944
+ provideDefinition(e, n) {
3899
3945
  var a;
3900
- const { uri: n } = e, i = et(e, s), r = [...this.compiler.container.stack(i)];
3946
+ const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3901
3947
  for (; r.length !== 0; ) {
3902
- const l = r.pop();
3903
- if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [ue.PRIMARY_EXPRESSION, ue.VARIABLE].includes(l == null ? void 0 : l.kind)) {
3904
- const { startPos: p, endPos: h } = l.referee.declaration;
3948
+ const c = r.pop();
3949
+ if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [ue.PRIMARY_EXPRESSION, ue.VARIABLE].includes(c == null ? void 0 : c.kind)) {
3950
+ const { startPos: p, endPos: h } = c.referee.declaration;
3905
3951
  return [
3906
3952
  {
3907
3953
  range: {
@@ -3910,7 +3956,7 @@ class Gt {
3910
3956
  endColumn: h.column + 1,
3911
3957
  endLineNumber: h.line + 1
3912
3958
  },
3913
- uri: n
3959
+ uri: s
3914
3960
  }
3915
3961
  ];
3916
3962
  }
@@ -3918,12 +3964,12 @@ class Gt {
3918
3964
  return [];
3919
3965
  }
3920
3966
  }
3921
- class Ct {
3967
+ class Xt {
3922
3968
  constructor(e) {
3923
3969
  this.compiler = e;
3924
3970
  }
3925
- provideReferences(e, s) {
3926
- const { uri: n } = e, i = et(e, s), r = [...this.compiler.container.stack(i)];
3971
+ provideReferences(e, n) {
3972
+ const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3927
3973
  for (; r.length !== 0; ) {
3928
3974
  const a = r.pop();
3929
3975
  if (a && [
@@ -3931,37 +3977,37 @@ class Ct {
3931
3977
  ue.FUNCTION_APPLICATION,
3932
3978
  ue.PRIMARY_EXPRESSION
3933
3979
  ].includes(a == null ? void 0 : a.kind)) {
3934
- const { symbol: l } = a;
3935
- if (l != null && l.references.length)
3936
- return l.references.map(({ startPos: p, endPos: h }) => ({
3980
+ const { symbol: c } = a;
3981
+ if (c != null && c.references.length)
3982
+ return c.references.map(({ startPos: p, endPos: h }) => ({
3937
3983
  range: {
3938
3984
  startColumn: p.column + 1,
3939
3985
  startLineNumber: p.line + 1,
3940
3986
  endColumn: h.column + 1,
3941
3987
  endLineNumber: h.line + 1
3942
3988
  },
3943
- uri: n
3989
+ uri: s
3944
3990
  }));
3945
3991
  }
3946
3992
  }
3947
3993
  return [];
3948
3994
  }
3949
3995
  }
3950
- const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3996
+ const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3951
3997
  __proto__: null,
3952
- CompletionItemInsertTextRule: w,
3998
+ CompletionItemInsertTextRule: y,
3953
3999
  CompletionItemKind: L,
3954
- DBMLCompletionItemProvider: Mt,
3955
- DBMLDefinitionProvider: Gt,
3956
- DBMLReferencesProvider: Ct
4000
+ DBMLCompletionItemProvider: Ft,
4001
+ DBMLDefinitionProvider: Ct,
4002
+ DBMLReferencesProvider: Xt
3957
4003
  }, Symbol.toStringTag, { value: "Module" }));
3958
4004
  var D = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(D || {});
3959
- class as {
4005
+ class cs {
3960
4006
  constructor() {
3961
4007
  this.source = "", this.cache = new Array(
3962
4008
  16
3963
4009
  /* TOTAL_QUERY_COUNT */
3964
- ).fill(null), this.nodeIdGenerator = new Wt(), this.symbolIdGenerator = new Qt(), this.token = {
4010
+ ).fill(null), this.nodeIdGenerator = new jt(), this.symbolIdGenerator = new Ht(), this.token = {
3965
4011
  invalidStream: this.createQuery(
3966
4012
  6,
3967
4013
  () => this.parse.tokens().filter(vt)
@@ -3976,8 +4022,8 @@ class as {
3976
4022
  _: this.createQuery(
3977
4023
  0,
3978
4024
  () => {
3979
- const e = new rn(this.source).lex().chain((s) => new ln(s, this.nodeIdGenerator).parse()).chain(({ ast: s, tokens: n }) => new Xn(s, this.symbolIdGenerator).analyze().map(() => ({ ast: s, tokens: n })));
3980
- return e.getErrors().length > 0 ? e : e.chain(({ ast: s, tokens: n }) => new zn(s).interpret().map((r) => ({ ast: s, tokens: n, rawDb: r })));
4025
+ const e = new on(this.source).lex().chain((n) => new un(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4026
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new qn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
3981
4027
  }
3982
4028
  ),
3983
4029
  ast: this.createQuery(
@@ -4001,78 +4047,78 @@ class as {
4001
4047
  stack: this.createQuery(
4002
4048
  10,
4003
4049
  (e) => {
4004
- const s = this.parse.tokens();
4005
- let { index: n } = this.container.token(e);
4050
+ const n = this.parse.tokens();
4051
+ let { index: s } = this.container.token(e);
4006
4052
  const { token: i } = this.container.token(e);
4007
- if (n === void 0)
4053
+ if (s === void 0)
4008
4054
  return [this.parse.ast()];
4009
- for (; s[n].isInvalid && n >= 0; )
4010
- n -= 1;
4011
- if (n === -1)
4055
+ for (; n[s].isInvalid && s >= 0; )
4056
+ s -= 1;
4057
+ if (s === -1)
4012
4058
  return [this.parse.ast()];
4013
- const r = s[n].start;
4059
+ const r = n[s].start;
4014
4060
  let a = this.parse.ast();
4015
- const l = [a];
4061
+ const c = [a];
4016
4062
  for (; ; ) {
4017
- const h = sn(a).find((T) => Ie(r, T));
4018
- if (h === void 0 || h instanceof B)
4063
+ const h = an(a).find((T) => Le(r, T));
4064
+ if (h === void 0 || h instanceof V)
4019
4065
  break;
4020
- l.push(h), a = h;
4066
+ c.push(h), a = h;
4021
4067
  }
4022
- if ((i == null ? void 0 : i.kind) === c.COLON)
4023
- return l;
4024
- for (; l.length > 0; ) {
4068
+ if ((i == null ? void 0 : i.kind) === u.COLON)
4069
+ return c;
4070
+ for (; c.length > 0; ) {
4025
4071
  let p = !1;
4026
- const h = I.last(l);
4027
- if (h instanceof x) {
4072
+ const h = I.last(c);
4073
+ if (h instanceof v) {
4028
4074
  const T = this.parse.source();
4029
4075
  for (let f = h.end; f < e; f += 1)
4030
4076
  T[f] === `
4031
- ` && (l.pop(), p = !0);
4077
+ ` && (c.pop(), p = !0);
4032
4078
  } else
4033
- 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);
4079
+ h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof U ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ee ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof te || h.end < e && (c.pop(), p = !0);
4034
4080
  if (p) {
4035
- const T = I.last(l);
4036
- T instanceof _ && T.end <= e && l.pop();
4081
+ const T = I.last(c);
4082
+ T instanceof _ && T.end <= e && c.pop();
4037
4083
  }
4038
4084
  if (!p)
4039
4085
  break;
4040
4086
  }
4041
- return l;
4087
+ return c;
4042
4088
  }
4043
4089
  ),
4044
4090
  token: this.createQuery(
4045
4091
  11,
4046
4092
  (e) => {
4047
- const s = this.token.flatStream().findIndex((n) => n.start >= e);
4048
- return s === void 0 ? { token: void 0, index: void 0 } : s <= 0 ? { token: void 0, index: void 0 } : {
4049
- token: this.token.flatStream()[s - 1],
4050
- index: s - 1
4093
+ const n = this.token.flatStream().findIndex((s) => s.start >= e);
4094
+ return n === void 0 ? { token: void 0, index: void 0 } : n <= 0 ? { token: void 0, index: void 0 } : {
4095
+ token: this.token.flatStream()[n - 1],
4096
+ index: n - 1
4051
4097
  };
4052
4098
  }
4053
4099
  ),
4054
4100
  element: this.createQuery(
4055
4101
  12,
4056
4102
  (e) => {
4057
- const s = this.container.stack(e);
4058
- for (let n = s.length - 1; n >= 0; n -= 1)
4059
- if (s[n] instanceof _)
4060
- return s[n];
4103
+ const n = this.container.stack(e);
4104
+ for (let s = n.length - 1; s >= 0; s -= 1)
4105
+ if (n[s] instanceof _)
4106
+ return n[s];
4061
4107
  return this.parse.ast();
4062
4108
  }
4063
4109
  ),
4064
4110
  scope: this.createQuery(
4065
4111
  14,
4066
4112
  (e) => {
4067
- var s, n;
4068
- return (n = (s = this.container.element(e)) == null ? void 0 : s.symbol) == null ? void 0 : n.symbolTable;
4113
+ var n, s;
4114
+ return (s = (n = this.container.element(e)) == null ? void 0 : n.symbol) == null ? void 0 : s.symbolTable;
4069
4115
  }
4070
4116
  ),
4071
4117
  scopeKind: this.createQuery(15, (e) => {
4072
- var n;
4073
- if (this.container.element(e) instanceof C)
4118
+ var s;
4119
+ if (this.container.element(e) instanceof F)
4074
4120
  return 8;
4075
- switch ((n = this.container.element(e).type) == null ? void 0 : n.value.toLowerCase()) {
4121
+ switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4076
4122
  case "table":
4077
4123
  return 0;
4078
4124
  case "enum":
@@ -4100,52 +4146,52 @@ class as {
4100
4146
  8,
4101
4147
  ({
4102
4148
  nameStack: e,
4103
- owner: s = this.parse.ast()
4149
+ owner: n = this.parse.ast()
4104
4150
  }) => {
4105
4151
  var i;
4106
4152
  if (e.length === 0)
4107
4153
  return [];
4108
- const n = [];
4109
- for (let r = s; r; r = r instanceof _ ? r.parent : void 0) {
4154
+ const s = [];
4155
+ for (let r = n; r; r = r instanceof _ ? r.parent : void 0) {
4110
4156
  if (!((i = r.symbol) != null && i.symbolTable))
4111
4157
  continue;
4112
4158
  const { symbolTable: a } = r.symbol;
4113
- let l = [a], p = [];
4159
+ let c = [a], p = [];
4114
4160
  for (const h of e)
4115
- p = l.flatMap(
4116
- (T) => Yt(h).flatMap((f) => {
4161
+ p = c.flatMap(
4162
+ (T) => Qt(h).flatMap((f) => {
4117
4163
  const N = T.get(f), g = se(f).unwrap_or(void 0);
4118
4164
  return !N || !g ? [] : { ...g, symbol: N };
4119
4165
  })
4120
- ), l = p.flatMap(
4166
+ ), c = p.flatMap(
4121
4167
  (T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
4122
4168
  );
4123
- n.push(...p);
4169
+ s.push(...p);
4124
4170
  }
4125
- return n;
4171
+ return s;
4126
4172
  },
4127
- ({ nameStack: e, owner: s }) => `${e.join(".")}@${s.id}`
4173
+ ({ nameStack: e, owner: n }) => `${e.join(".")}@${n.id}`
4128
4174
  ),
4129
4175
  members: this.createQuery(
4130
4176
  9,
4131
- (e) => e.symbolTable ? [...e.symbolTable.entries()].map(([s, n]) => ({
4132
- ...se(s).unwrap(),
4133
- symbol: n
4177
+ (e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
4178
+ ...se(n).unwrap(),
4179
+ symbol: s
4134
4180
  })) : []
4135
4181
  )
4136
4182
  };
4137
4183
  }
4138
- createQuery(e, s, n) {
4184
+ createQuery(e, n, s) {
4139
4185
  return (i) => {
4140
- const r = this.cache[e], a = i && n ? n(i) : i;
4186
+ const r = this.cache[e], a = i && s ? s(i) : i;
4141
4187
  if (r !== null) {
4142
4188
  if (!(r instanceof Map))
4143
4189
  return r;
4144
4190
  if (r.has(a))
4145
4191
  return r.get(a);
4146
4192
  }
4147
- const l = s(i);
4148
- 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;
4193
+ const c = n(i);
4194
+ return i !== void 0 ? r instanceof Map ? r.set(a, c) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, c)) : this.cache[e] = c, c;
4149
4195
  };
4150
4196
  }
4151
4197
  setSource(e) {
@@ -4156,14 +4202,14 @@ class as {
4156
4202
  }
4157
4203
  initMonacoServices() {
4158
4204
  return {
4159
- definitionProvider: new Gt(this),
4160
- referenceProvider: new Ct(this),
4161
- autocompletionProvider: new Mt(this)
4205
+ definitionProvider: new Ct(this),
4206
+ referenceProvider: new Xt(this),
4207
+ autocompletionProvider: new Ft(this)
4162
4208
  };
4163
4209
  }
4164
4210
  }
4165
4211
  export {
4166
- as as Compiler,
4167
- is as serialize,
4168
- rs as services
4212
+ cs as Compiler,
4213
+ as as serialize,
4214
+ os as services
4169
4215
  };