@dbml/parse 3.1.4 → 3.1.5

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.
@@ -37,18 +37,18 @@ function at(t) {
37
37
  return t !== void 0 && t.kind === "<op>";
38
38
  }
39
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;
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 B(e, n, s, i, r);
45
45
  }
46
46
  }
47
47
  function bt(t) {
48
48
  return t.trailingTrivia.find(({ kind: e }) => e === c.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 === c.NEWLINE) !== void 0 || bt(t);
52
52
  }
53
53
  function Ve(t) {
54
54
  return t.trailingTrivia.find(({ kind: e }) => e === c.SPACE) !== void 0;
@@ -78,15 +78,15 @@ class Wt {
78
78
  class y {
79
79
  // The symbol that this syntax node refers to
80
80
  // args must be passed in order of appearance in the node
81
- constructor(e, s, n) {
82
- this.id = e, this.kind = s;
83
- const i = n.find((a) => a !== void 0 && !Number.isNaN(a.start));
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
84
  i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? 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));
89
+ const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
90
90
  r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? It(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
@@ -94,17 +94,17 @@ class y {
94
94
  }, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
95
95
  }
96
96
  }
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 || {});
97
+ var he = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(he || {});
98
98
  class C extends y {
99
- constructor({ body: e = [], eof: s }, n) {
100
- super(n, "<program>", [...e, s]), this.body = e, this.eof = s;
99
+ constructor({ body: e = [], eof: n }, s) {
100
+ super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
101
101
  }
102
102
  }
103
103
  class _ extends y {
104
104
  constructor({
105
105
  type: e,
106
- name: s,
107
- as: n,
106
+ name: n,
107
+ as: s,
108
108
  alias: i,
109
109
  attributeList: r,
110
110
  bodyColon: a,
@@ -112,109 +112,109 @@ class _ extends y {
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
120
  l
121
- ]), l && a && !(l instanceof x || l instanceof _))
121
+ ]), l && a && !(l instanceof k || l 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 = l;
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 K extends y {
127
+ constructor({ identifiers: e = [] }, n) {
128
+ super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
130
130
  }
131
131
  class ne extends y {
132
132
  constructor({
133
133
  name: e,
134
- colon: s,
135
- value: n
134
+ colon: n,
135
+ value: s
136
136
  }, i) {
137
- super(i, "<attribute>", [e, s, n]), this.name = e, this.value = n, this.colon = s;
137
+ super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
138
138
  }
139
139
  }
140
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;
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
145
  class q extends y {
146
146
  constructor({
147
147
  op: e,
148
- leftExpression: s,
149
- rightExpression: n
148
+ leftExpression: n,
149
+ rightExpression: s
150
150
  }, i) {
151
- super(i, "<infix-expression>", [s, e, n]), this.op = e, this.leftExpression = s, this.rightExpression = n;
151
+ super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
152
152
  }
153
153
  }
154
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;
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 ee extends y {
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 k extends y {
165
+ constructor({ callee: e, args: n = [] }, s) {
166
+ super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
167
167
  }
168
168
  }
169
- class ee extends y {
169
+ class te extends y {
170
170
  constructor({
171
171
  blockOpenBrace: e,
172
- body: s = [],
173
- blockCloseBrace: n
172
+ body: n = [],
173
+ blockCloseBrace: s
174
174
  }, i) {
175
- super(i, "<block-expression>", [e, ...s, n]), this.blockOpenBrace = e, this.body = s, this.blockCloseBrace = n;
175
+ super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
176
176
  }
177
177
  }
178
178
  class U extends y {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
- elementList: s = [],
182
- commaList: n = [],
181
+ elementList: n = [],
182
+ commaList: s = [],
183
183
  listCloseBracket: i
184
184
  }, r) {
185
185
  super(r, "<list-expression>", [
186
186
  e,
187
- ...gt(s, n),
187
+ ...gt(n, s),
188
188
  i
189
- ]), this.listOpenBracket = e, this.elementList = s, this.commaList = n, this.listCloseBracket = i;
189
+ ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
191
191
  }
192
192
  class J extends y {
193
193
  constructor({
194
194
  tupleOpenParen: e,
195
- elementList: s = [],
196
- commaList: n = [],
195
+ elementList: n = [],
196
+ commaList: s = [],
197
197
  tupleCloseParen: i
198
198
  }, r) {
199
199
  super(r, "<tuple-expression>", [
200
200
  e,
201
- ...gt(s, n),
201
+ ...gt(n, s),
202
202
  i
203
- ]), this.tupleOpenParen = e, this.elementList = s, this.commaList = n, this.tupleCloseParen = i;
203
+ ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
204
204
  }
205
205
  }
206
206
  class Xe extends J {
207
207
  constructor({
208
208
  groupOpenParen: e,
209
- expression: s,
210
- groupCloseParen: n
209
+ expression: n,
210
+ groupCloseParen: s
211
211
  }, i) {
212
212
  super(
213
213
  {
214
214
  tupleOpenParen: e,
215
- elementList: s && [s],
215
+ elementList: n && [n],
216
216
  commaList: [],
217
- tupleCloseParen: n
217
+ tupleCloseParen: s
218
218
  },
219
219
  i
220
220
  ), this.kind = "<group-expression>";
@@ -223,35 +223,35 @@ class Xe extends J {
223
223
  class H extends y {
224
224
  constructor({
225
225
  callee: e,
226
- argumentList: s
227
- }, n) {
228
- super(n, "<call-expression>", [e, s]), this.callee = e, this.argumentList = s;
226
+ argumentList: n
227
+ }, s) {
228
+ super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
229
229
  }
230
230
  }
231
- class pe extends y {
232
- constructor({ literal: e }, s) {
233
- super(s, "<literal>", [e]), this.literal = e;
231
+ class de extends y {
232
+ constructor({ literal: e }, n) {
233
+ super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
236
  class X extends y {
237
- constructor({ variable: e }, s) {
238
- super(s, "<variable>", [e]), this.variable = e;
237
+ constructor({ variable: e }, n) {
238
+ super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
241
  class R extends y {
242
- constructor({ expression: e }, s) {
243
- super(s, "<primary-expression>", [e]), this.expression = e;
242
+ constructor({ expression: e }, n) {
243
+ super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
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]);
247
+ constructor({ pre: e }, n) {
248
+ const s = B.create(c.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 fe extends y {
253
+ constructor({ expression: e, indexer: n }, s) {
254
+ super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
256
256
  }
257
257
  function gt(t, e) {
@@ -259,30 +259,30 @@ function gt(t, e) {
259
259
  return e || [];
260
260
  if (!e || e.length === 0)
261
261
  return t || [];
262
- const [s] = t, [n] = e;
263
- return (s.start < n.start ? 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
267
  function is(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 C) && 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
  );
@@ -338,7 +338,7 @@ var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Colum
338
338
  function $e(t) {
339
339
  return `Schema:${t}`;
340
340
  }
341
- function xe(t) {
341
+ function ke(t) {
342
342
  return `Table:${t}`;
343
343
  }
344
344
  function We(t) {
@@ -367,7 +367,7 @@ function Fe(t, e) {
367
367
  case "Schema":
368
368
  return $e(t);
369
369
  case "Table":
370
- return xe(t);
370
+ return ke(t);
371
371
  case "TableGroup":
372
372
  return ze(t);
373
373
  case "TableGroup field":
@@ -377,9 +377,9 @@ function Fe(t, e) {
377
377
  }
378
378
  }
379
379
  function se(t) {
380
- const [e, s] = t.split(":");
380
+ const [e, n] = t.split(":");
381
381
  return Object.values(m).includes(e) ? new S({
382
- name: s,
382
+ name: n,
383
383
  kind: e
384
384
  }) : new A();
385
385
  }
@@ -387,13 +387,13 @@ function jt(t) {
387
387
  const e = se(t).unwrap_or(void 0);
388
388
  if (!e)
389
389
  return !1;
390
- const { kind: s, name: n } = e;
391
- return s === "Schema" && n === "public";
390
+ const { kind: n, name: s } = e;
391
+ return n === "Schema" && s === "public";
392
392
  }
393
393
  function Yt(t) {
394
394
  return [
395
395
  $e,
396
- xe,
396
+ ke,
397
397
  je,
398
398
  ze,
399
399
  We,
@@ -405,22 +405,22 @@ function qe(t) {
405
405
  const [e] = t;
406
406
  return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
407
407
  }
408
- function ke(t) {
408
+ function xe(t) {
409
409
  const [e] = t;
410
410
  return e >= "0" && e <= "9";
411
411
  }
412
412
  function zt(t) {
413
413
  const [e] = t;
414
- return ke(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
414
+ return xe(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
415
415
  }
416
- function be(t) {
417
- return qe(t) || ke(t);
416
+ function ue(t) {
417
+ return qe(t) || xe(t);
418
418
  }
419
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;
420
+ const n = [], s = Math.min(t.length, e.length);
421
+ for (let i = 0; i < s; i += 1)
422
+ n.push(t[i], e[i]);
423
+ return n.push(...t.slice(s), ...e.slice(s)), n;
424
424
  }
425
425
  function Ie(t, e) {
426
426
  return t >= e.start && t < e.end;
@@ -437,49 +437,49 @@ class Qt {
437
437
  }
438
438
  }
439
439
  class _t {
440
- constructor({ symbolTable: e }, s) {
441
- this.references = [], this.id = s, this.symbolTable = e;
440
+ constructor({ symbolTable: e }, n) {
441
+ this.references = [], this.id = n, this.symbolTable = e;
442
442
  }
443
443
  }
444
444
  class qt {
445
- constructor({ symbolTable: e, declaration: s }, n) {
446
- this.references = [], this.id = n, this.symbolTable = e, this.declaration = s;
445
+ constructor({ symbolTable: e, declaration: n }, s) {
446
+ this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
447
447
  }
448
448
  }
449
449
  class Ht {
450
- constructor({ declaration: e }, s) {
451
- this.references = [], this.id = s, this.declaration = e;
450
+ constructor({ declaration: e }, n) {
451
+ this.references = [], this.id = n, this.declaration = e;
452
452
  }
453
453
  }
454
454
  class At {
455
- constructor({ symbolTable: e, declaration: s }, n) {
456
- this.references = [], this.id = n, this.symbolTable = e, this.declaration = s;
455
+ constructor({ symbolTable: e, declaration: n }, s) {
456
+ this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
457
457
  }
458
458
  }
459
459
  class Jt {
460
- constructor({ declaration: e }, s) {
461
- this.references = [], this.id = s, this.declaration = e;
460
+ constructor({ declaration: e }, n) {
461
+ this.references = [], this.id = n, this.declaration = e;
462
462
  }
463
463
  }
464
464
  class Zt {
465
- constructor({ symbolTable: e, declaration: s }, n) {
466
- this.references = [], this.id = n, this.symbolTable = e, this.declaration = s;
465
+ constructor({ symbolTable: e, declaration: n }, s) {
466
+ this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
467
467
  }
468
468
  }
469
469
  class Kt {
470
- constructor({ declaration: e }, s) {
471
- this.references = [], this.id = s, this.declaration = e;
470
+ constructor({ declaration: e }, n) {
471
+ this.references = [], this.id = n, this.declaration = e;
472
472
  }
473
473
  }
474
474
  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
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);
476
+ constructor(e, n, s) {
477
+ 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, u.prototype);
478
478
  }
479
479
  }
480
480
  class F {
481
- constructor(e, s) {
482
- this.value = e, this.errors = s === void 0 ? [] : s;
481
+ constructor(e, n) {
482
+ this.value = e, this.errors = n === void 0 ? [] : n;
483
483
  }
484
484
  getValue() {
485
485
  return this.value;
@@ -488,38 +488,38 @@ class F {
488
488
  return this.errors;
489
489
  }
490
490
  chain(e) {
491
- const s = e(this.value), n = [...this.errors, ...s.errors];
492
- return new F(s.value, n);
491
+ const n = e(this.value), s = [...this.errors, ...n.errors];
492
+ return new F(n.value, s);
493
493
  }
494
494
  map(e) {
495
495
  return new F(e(this.value), this.errors);
496
496
  }
497
497
  }
498
- function en(t, e, s) {
499
- if (!t || !fe(t) || e.length === 0)
498
+ function en(t, e, n) {
499
+ if (!t || !pe(t) || e.length === 0)
500
500
  return new A();
501
- const n = [...e], i = Be(t).unwrap(), r = n.pop();
502
- if (!(r instanceof ee))
501
+ const s = [...e], i = Be(t).unwrap(), r = s.pop();
502
+ if (!(r instanceof te))
503
503
  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(_, {
504
+ const a = I.last(s) instanceof U ? s.pop() : void 0;
505
+ return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
506
+ n.create(_, {
507
507
  type: i,
508
- name: n[0],
509
- as: Be(n[1]).unwrap(),
510
- alias: n[2],
508
+ name: s[0],
509
+ as: Be(s[1]).unwrap(),
510
+ alias: s[2],
511
511
  attributeList: a,
512
512
  body: r
513
513
  })
514
- ) : n.length === 1 ? new S(
515
- s.create(_, {
514
+ ) : s.length === 1 ? new S(
515
+ n.create(_, {
516
516
  type: i,
517
- name: n[0],
517
+ name: s[0],
518
518
  attributeList: a,
519
519
  body: r
520
520
  })
521
- ) : n.length === 0 ? new S(
522
- s.create(_, {
521
+ ) : s.length === 0 ? new S(
522
+ n.create(_, {
523
523
  type: i,
524
524
  attributeList: a,
525
525
  body: r
@@ -538,7 +538,7 @@ function tn(t) {
538
538
  function nn(t) {
539
539
  if (t instanceof _)
540
540
  E(t.type), E(t.name), E(t.as), E(t.alias), E(t.bodyColon), E(t.attributeList), E(t.body);
541
- else if (t instanceof te)
541
+ else if (t instanceof K)
542
542
  t.identifiers.forEach(E);
543
543
  else if (t instanceof ne)
544
544
  E(t.name), E(t.colon), E(t.value);
@@ -548,7 +548,7 @@ function nn(t) {
548
548
  E(t.leftExpression), E(t.op), E(t.rightExpression);
549
549
  else if (t instanceof De)
550
550
  E(t.op), E(t.expression);
551
- else if (t instanceof ee)
551
+ else if (t instanceof te)
552
552
  E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
553
553
  else if (t instanceof U)
554
554
  E(t.listOpenBracket), t.commaList.forEach(E), t.elementList.forEach(E), E(t.listCloseBracket);
@@ -556,15 +556,15 @@ function nn(t) {
556
556
  E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
557
557
  else if (t instanceof H)
558
558
  E(t.callee), E(t.argumentList);
559
- else if (t instanceof x)
559
+ else if (t instanceof k)
560
560
  E(t.callee), t.args.forEach(E);
561
561
  else if (t instanceof R)
562
562
  E(t.expression);
563
- else if (t instanceof K)
563
+ else if (t instanceof ee)
564
564
  E(t.value);
565
565
  else if (t instanceof X)
566
566
  E(t.variable);
567
- else if (t instanceof pe)
567
+ else if (t instanceof de)
568
568
  E(t.literal);
569
569
  else
570
570
  throw t instanceof Xe ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
@@ -590,9 +590,9 @@ function sn(t) {
590
590
  );
591
591
  if (t instanceof ne)
592
592
  return P(t.name, t.colon, t.value);
593
- if (t instanceof te)
593
+ if (t instanceof K)
594
594
  return t.identifiers;
595
- if (t instanceof pe)
595
+ if (t instanceof de)
596
596
  return t.literal ? [t.literal] : [];
597
597
  if (t instanceof X)
598
598
  return P(t.variable);
@@ -602,11 +602,11 @@ function sn(t) {
602
602
  return P(t.leftExpression, t.op, t.rightExpression);
603
603
  if (t instanceof De)
604
604
  return P(t.expression, t.op);
605
- if (t instanceof K)
605
+ if (t instanceof ee)
606
606
  return P(t.value);
607
- if (t instanceof x)
607
+ if (t instanceof k)
608
608
  return P(t.callee, ...t.args);
609
- if (t instanceof ee)
609
+ if (t instanceof te)
610
610
  return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
611
611
  if (t instanceof U)
612
612
  return P(
@@ -631,12 +631,12 @@ function Be(t) {
631
631
  }
632
632
  function $(t) {
633
633
  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);
634
+ return t instanceof R && (t.expression instanceof X && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof de && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
635
635
  }
636
636
  function M(t) {
637
637
  return t instanceof R && t.expression instanceof X && t.expression.variable instanceof B;
638
638
  }
639
- function fe(t) {
639
+ function pe(t) {
640
640
  var e;
641
641
  return t instanceof R && t.expression instanceof X && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
642
642
  }
@@ -647,7 +647,7 @@ function He(t) {
647
647
  function Re(t) {
648
648
  if (t === void 0)
649
649
  return new A();
650
- const e = t.identifiers.map((s) => s.value).join(" ");
650
+ const e = t.identifiers.map((n) => n.value).join(" ");
651
651
  return e === "" ? new A() : new S(e);
652
652
  }
653
653
  class rn {
@@ -677,8 +677,8 @@ class rn {
677
677
  }
678
678
  // Check if the sequence ahead matches `sequence`
679
679
  check(e) {
680
- for (let s = 0; s < e.length; s += 1)
681
- if (e[s] !== this.peek(s))
680
+ for (let n = 0; n < e.length; n += 1)
681
+ if (e[n] !== this.peek(n))
682
682
  return !1;
683
683
  return !0;
684
684
  }
@@ -686,16 +686,16 @@ class rn {
686
686
  match(e) {
687
687
  return this.check(e) ? (e.split("").forEach(() => this.advance()), !0) : !1;
688
688
  }
689
- addToken(e, s = !1) {
690
- this.tokens.push(this.createToken(e, s));
689
+ addToken(e, n = !1) {
690
+ this.tokens.push(this.createToken(e, n));
691
691
  }
692
- createToken(e, s = !1) {
692
+ createToken(e, n = !1) {
693
693
  return B.create(
694
694
  e,
695
695
  this.start,
696
696
  this.current,
697
697
  this.text.substring(this.start.offset, this.current.offset),
698
- s
698
+ n
699
699
  );
700
700
  }
701
701
  lex() {
@@ -768,8 +768,8 @@ class rn {
768
768
  this.identifier();
769
769
  break;
770
770
  }
771
- if (ke(e)) {
772
- this.numericLiteral();
771
+ if (xe(e)) {
772
+ this.numericLiteralOrIdentifier();
773
773
  break;
774
774
  }
775
775
  this.addToken(c.OP, !0), this.errors.push(
@@ -785,27 +785,27 @@ class rn {
785
785
  }
786
786
  }
787
787
  gatherTrivia() {
788
- let e = !0, s = [], n;
788
+ let e = !0, n = [], s;
789
789
  const i = [];
790
790
  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);
791
+ Xt(r) ? (n.push(r), r.kind === c.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
792
  this.tokens = i;
793
793
  }
794
794
  gatherInvalid() {
795
795
  let e;
796
- const s = [], n = [];
796
+ const n = [], s = [];
797
797
  for (e = 0; e < this.tokens.length && vt(this.tokens[e]); e += 1)
798
- n.push(this.tokens[e]);
798
+ s.push(this.tokens[e]);
799
799
  let i = this.tokens[e];
800
- for (i.leadingInvalid = [...n, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
800
+ for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
801
801
  const r = this.tokens[e];
802
- r.isInvalid ? i.trailingInvalid.push(r) : (i = r, s.push(r));
802
+ r.isInvalid ? i.trailingInvalid.push(r) : (i = r, n.push(r));
803
803
  }
804
- this.tokens = s;
804
+ this.tokens = n;
805
805
  }
806
806
  // Consuming characters until the `stopSequence` is encountered
807
- consumeUntil(e, s, {
808
- allowNewline: n,
807
+ consumeUntil(e, n, {
808
+ allowNewline: s,
809
809
  // Whether newline is allowed
810
810
  allowEof: i,
811
811
  // Whether EOF is allowed
@@ -814,8 +814,8 @@ class rn {
814
814
  consumeStopSequence: a = !0
815
815
  }) {
816
816
  let l = "";
817
- for (; !this.isAtEnd() && (n || !this.check(`
818
- `)) && !this.check(s); )
817
+ for (; !this.isAtEnd() && (s || !this.check(`
818
+ `)) && !this.check(n); )
819
819
  this.peek() === "\\" && !r ? (this.advance(), l += this.escapedString()) : l += this.advance();
820
820
  if (this.isAtEnd() && !i) {
821
821
  const p = this.createToken(e, !0);
@@ -825,7 +825,7 @@ class rn {
825
825
  return;
826
826
  }
827
827
  if (this.check(`
828
- `) && !n) {
828
+ `) && !s) {
829
829
  const p = this.createToken(e, !0);
830
830
  this.tokens.push(p), this.errors.push(
831
831
  new u(
@@ -836,7 +836,7 @@ class rn {
836
836
  );
837
837
  return;
838
838
  }
839
- a && this.match(s), this.tokens.push(B.create(e, this.start, this.current, l, !1));
839
+ a && this.match(n), this.tokens.push(B.create(e, this.start, this.current, l, !1));
840
840
  }
841
841
  singleLineStringLiteral() {
842
842
  this.consumeUntil(c.STRING_LITERAL, "'", {
@@ -883,7 +883,7 @@ class rn {
883
883
  });
884
884
  }
885
885
  identifier() {
886
- for (; !this.isAtEnd() && be(this.peek()); )
886
+ for (; !this.isAtEnd() && ue(this.peek()); )
887
887
  this.advance();
888
888
  this.addToken(c.IDENTIFIER);
889
889
  }
@@ -892,7 +892,8 @@ class rn {
892
892
  this.advance();
893
893
  this.addToken(c.OP);
894
894
  }
895
- numericLiteral() {
895
+ // we accept identifiers starting with digits but must contain at least one char or underscore
896
+ numericLiteralOrIdentifier() {
896
897
  let e = 0;
897
898
  if (this.isAtEnd())
898
899
  return this.addToken(c.NUMERIC_LITERAL);
@@ -902,19 +903,26 @@ class rn {
902
903
  break;
903
904
  if (!n && this.current.offset === this.text.length - 1)
904
905
  return this.advance(), this.addToken(c.NUMERIC_LITERAL);
905
- if (!n && !be(this.peek()))
906
+ if (!n && !ue(this.peek()))
906
907
  return this.addToken(c.NUMERIC_LITERAL);
907
- if (!n && !ke(this.peek()))
908
+ if (!n && !xe(this.peek()))
908
909
  break;
909
910
  this.advance();
910
911
  }
911
- for (; !this.isAtEnd() && (this.check(".") || be(this.peek())); )
912
- 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));
912
+ if (e > 0) {
913
+ for (; !this.isAtEnd() && (this.check(".") || ue(this.peek())); )
914
+ this.advance();
915
+ const n = this.createToken(c.NUMERIC_LITERAL, !0);
916
+ this.tokens.push(n), this.errors.push(new u(o.UNKNOWN_TOKEN, "Invalid number", n));
917
+ } else {
918
+ for (; !this.isAtEnd() && ue(this.peek()); )
919
+ this.advance();
920
+ const n = this.createToken(c.IDENTIFIER, !1);
921
+ this.tokens.push(n);
922
+ }
915
923
  }
916
924
  colorLiteral() {
917
- for (; !this.isAtEnd() && be(this.peek()); )
925
+ for (; !this.isAtEnd() && ue(this.peek()); )
918
926
  this.advance();
919
927
  this.addToken(c.COLOR_LITERAL);
920
928
  }
@@ -945,8 +953,8 @@ class rn {
945
953
  return "\f";
946
954
  case "u": {
947
955
  let e = "";
948
- for (let s = 0; s <= 3; s += 1) {
949
- if (this.isAtEnd() || !be(this.peek()))
956
+ for (let n = 0; n <= 3; n += 1) {
957
+ if (this.isAtEnd() || !ue(this.peek()))
950
958
  return `\\u${e}`;
951
959
  e += this.advance();
952
960
  }
@@ -984,21 +992,21 @@ class an {
984
992
  // Call the passed in callback
985
993
  // with the guarantee that the passed in context will be pushed and popped properly
986
994
  // even in cases of exceptions
987
- withContextDo(e, s) {
995
+ withContextDo(e, n) {
988
996
  return () => {
989
997
  this.push(e);
990
998
  try {
991
- return s();
999
+ return n();
992
1000
  } finally {
993
1001
  this.pop();
994
1002
  }
995
1003
  };
996
1004
  }
997
1005
  // Return the type of the handler context currently in the context stack to handle `token`
998
- findHandlerContext(e, s) {
1006
+ findHandlerContext(e, n) {
999
1007
  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) {
1008
+ for (let s = n; s < e.length - 1; s += 1)
1009
+ switch (e[s].kind) {
1002
1010
  case c.COMMA:
1003
1011
  if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
1004
1012
  return [...this.stack].reverse().find(
@@ -1028,61 +1036,61 @@ class on {
1028
1036
  constructor(e) {
1029
1037
  this.generator = e;
1030
1038
  }
1031
- create(e, s) {
1032
- return new e(s, this.generator.nextId());
1039
+ create(e, n) {
1040
+ return new e(n, this.generator.nextId());
1033
1041
  }
1034
1042
  }
1035
1043
  class d {
1036
- constructor(e, s, n) {
1037
- this.token = e, this.partialNode = s, this.handlerContext = n;
1044
+ constructor(e, n, s) {
1045
+ this.token = e, this.partialNode = n, this.handlerContext = s;
1038
1046
  }
1039
1047
  }
1040
1048
  class ln {
1041
- constructor(e, s) {
1049
+ constructor(e, n) {
1042
1050
  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"));
1051
+ const s = this.peek();
1052
+ s.kind !== c.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1045
1053
  }, this.synchronizeElementDeclarationName = () => {
1046
1054
  for (; !this.isAtEnd(); ) {
1047
- const n = this.peek();
1048
- if (ct(n) || this.check(c.COLON, c.LBRACE, c.LBRACKET))
1055
+ const s = this.peek();
1056
+ if (ct(s) || this.check(c.COLON, c.LBRACE, c.LBRACKET))
1049
1057
  break;
1050
- E(n), this.advance();
1058
+ E(s), this.advance();
1051
1059
  }
1052
1060
  }, this.synchronizeElementDeclarationAlias = () => {
1053
1061
  for (; !this.isAtEnd(); ) {
1054
- const n = this.peek();
1062
+ const s = this.peek();
1055
1063
  if (this.check(c.COLON, c.LBRACE, c.LBRACKET))
1056
1064
  break;
1057
- E(n), this.advance();
1065
+ E(s), this.advance();
1058
1066
  }
1059
1067
  }, this.blockExpression = this.contextStack.withContextDo(ye.BlockExpression, () => {
1060
- const n = { body: [] }, i = () => this.nodeFactory.create(ee, n);
1068
+ const s = { body: [] }, i = () => this.nodeFactory.create(te, s);
1061
1069
  try {
1062
- this.consume("Expect an opening brace '{'", c.LBRACE), n.blockOpenBrace = this.previous();
1070
+ this.consume("Expect an opening brace '{'", c.LBRACE), s.blockOpenBrace = this.previous();
1063
1071
  } catch (r) {
1064
1072
  if (!(r instanceof d))
1065
1073
  throw r;
1066
- if (n.blockOpenBrace = r.partialNode, !this.canHandle(r))
1074
+ if (s.blockOpenBrace = r.partialNode, !this.canHandle(r))
1067
1075
  throw new d(r.token, i(), r.handlerContext);
1068
1076
  this.synchronizeBlock();
1069
1077
  }
1070
1078
  for (; !this.isAtEnd() && !this.check(c.RBRACE); )
1071
1079
  try {
1072
- n.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
1080
+ s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
1073
1081
  } catch (r) {
1074
1082
  if (!(r instanceof d))
1075
1083
  throw r;
1076
- if (n.body.push(r.partialNode), !this.canHandle(r))
1084
+ if (s.body.push(r.partialNode), !this.canHandle(r))
1077
1085
  throw new d(r.token, i(), r.handlerContext);
1078
1086
  this.synchronizeBlock();
1079
1087
  }
1080
1088
  try {
1081
- this.consume("Expect a closing brace '}'", c.RBRACE), n.blockCloseBrace = this.previous();
1089
+ this.consume("Expect a closing brace '}'", c.RBRACE), s.blockCloseBrace = this.previous();
1082
1090
  } catch (r) {
1083
1091
  if (!(r instanceof d))
1084
1092
  throw r;
1085
- if (n.blockCloseBrace = r.partialNode, !this.canHandle(r))
1093
+ if (s.blockCloseBrace = r.partialNode, !this.canHandle(r))
1086
1094
  throw new d(r.token, i(), r.handlerContext);
1087
1095
  this.synchronizeBlock();
1088
1096
  }
@@ -1090,126 +1098,126 @@ class ln {
1090
1098
  }), this.synchronizeBlock = () => {
1091
1099
  if (!this.check(c.RBRACE))
1092
1100
  for (E(this.advance()); !this.isAtEnd(); ) {
1093
- const n = this.peek();
1094
- if (this.check(c.RBRACE) || ot(this.previous(), n))
1101
+ const s = this.peek();
1102
+ if (this.check(c.RBRACE) || ot(this.previous(), s))
1095
1103
  break;
1096
- E(n), this.advance();
1104
+ E(s), this.advance();
1097
1105
  }
1098
1106
  }, 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);
1107
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Xe, {
1108
+ groupOpenParen: s.tupleOpenParen,
1109
+ groupCloseParen: s.tupleCloseParen,
1110
+ expression: s.elementList[0]
1111
+ }), r = () => this.nodeFactory.create(J, s);
1104
1112
  try {
1105
- this.consume("Expect an opening parenthesis '('", c.LPAREN), n.tupleOpenParen = this.previous();
1113
+ this.consume("Expect an opening parenthesis '('", c.LPAREN), s.tupleOpenParen = this.previous();
1106
1114
  } catch (a) {
1107
1115
  if (!(a instanceof d))
1108
1116
  throw a;
1109
- if (n.tupleOpenParen = a.partialNode, !this.canHandle(a))
1117
+ if (s.tupleOpenParen = a.partialNode, !this.canHandle(a))
1110
1118
  throw new d(a.token, r(), a.handlerContext);
1111
1119
  this.synchronizeTuple();
1112
1120
  }
1113
1121
  if (!this.isAtEnd() && !this.check(c.RPAREN))
1114
1122
  try {
1115
- n.elementList.push(this.normalExpression());
1123
+ s.elementList.push(this.normalExpression());
1116
1124
  } catch (a) {
1117
1125
  if (!(a instanceof d))
1118
1126
  throw a;
1119
- if (n.elementList.push(a.partialNode), !this.canHandle(a))
1127
+ if (s.elementList.push(a.partialNode), !this.canHandle(a))
1120
1128
  throw new d(a.token, i(), a.handlerContext);
1121
1129
  this.synchronizeTuple();
1122
1130
  }
1123
1131
  for (; !this.isAtEnd() && !this.check(c.RPAREN); )
1124
1132
  try {
1125
- this.consume("Expect a comma ','", c.COMMA), n.commaList.push(this.previous()), n.elementList.push(this.normalExpression());
1133
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1126
1134
  } catch (a) {
1127
1135
  if (!(a instanceof d))
1128
1136
  throw a;
1129
- if (a.partialNode instanceof y && n.elementList.push(a.partialNode), !this.canHandle(a))
1137
+ if (a.partialNode instanceof y && s.elementList.push(a.partialNode), !this.canHandle(a))
1130
1138
  throw new d(a.token, r(), a.handlerContext);
1131
1139
  this.synchronizeTuple();
1132
1140
  }
1133
1141
  try {
1134
- this.consume("Expect a closing parenthesis ')'", c.RPAREN), n.tupleCloseParen = this.previous();
1142
+ this.consume("Expect a closing parenthesis ')'", c.RPAREN), s.tupleCloseParen = this.previous();
1135
1143
  } catch (a) {
1136
1144
  if (!(a instanceof d))
1137
1145
  throw a;
1138
- if (n.tupleCloseParen = a.partialNode, !this.canHandle(a))
1146
+ if (s.tupleCloseParen = a.partialNode, !this.canHandle(a))
1139
1147
  throw new d(a.token, r(), a.handlerContext);
1140
1148
  this.synchronizeTuple();
1141
1149
  }
1142
- return n.elementList.length === 1 ? i() : r();
1150
+ return s.elementList.length === 1 ? i() : r();
1143
1151
  }), this.synchronizeTuple = () => {
1144
1152
  for (; !this.isAtEnd(); ) {
1145
- const n = this.peek();
1153
+ const s = this.peek();
1146
1154
  if (this.check(c.RPAREN, c.COMMA))
1147
1155
  break;
1148
- E(n), this.advance();
1156
+ E(s), this.advance();
1149
1157
  }
1150
1158
  }, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
1151
- const n = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, n);
1159
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, s);
1152
1160
  try {
1153
- this.consume("Expect an opening bracket '['", c.LBRACKET), n.listOpenBracket = this.previous();
1161
+ this.consume("Expect an opening bracket '['", c.LBRACKET), s.listOpenBracket = this.previous();
1154
1162
  } catch (r) {
1155
1163
  if (!(r instanceof d))
1156
1164
  throw r;
1157
- if (n.listOpenBracket = r.partialNode, !this.canHandle(r))
1165
+ if (s.listOpenBracket = r.partialNode, !this.canHandle(r))
1158
1166
  throw new d(r.token, i(), r.handlerContext);
1159
1167
  this.synchronizeList();
1160
1168
  }
1161
1169
  if (!this.isAtEnd() && !this.check(c.RBRACKET))
1162
1170
  try {
1163
- n.elementList.push(this.attribute());
1171
+ s.elementList.push(this.attribute());
1164
1172
  } catch (r) {
1165
1173
  if (!(r instanceof d))
1166
1174
  throw r;
1167
- if (n.elementList.push(r.partialNode), !this.canHandle(r))
1175
+ if (s.elementList.push(r.partialNode), !this.canHandle(r))
1168
1176
  throw new d(r.token, i(), r.handlerContext);
1169
1177
  this.synchronizeList();
1170
1178
  }
1171
1179
  for (; !this.isAtEnd() && !this.check(c.RBRACKET); )
1172
1180
  try {
1173
- this.consume("Expect a comma ','", c.COMMA), n.commaList.push(this.previous()), n.elementList.push(this.attribute());
1181
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1174
1182
  } catch (r) {
1175
1183
  if (!(r instanceof d))
1176
1184
  throw r;
1177
- if (r.partialNode instanceof y && n.elementList.push(r.partialNode), !this.canHandle(r))
1185
+ if (r.partialNode instanceof y && s.elementList.push(r.partialNode), !this.canHandle(r))
1178
1186
  throw new d(r.token, i(), r.handlerContext);
1179
1187
  this.synchronizeList();
1180
1188
  }
1181
1189
  try {
1182
- this.consume("Expect a closing bracket ']'", c.RBRACKET), n.listCloseBracket = this.previous();
1190
+ this.consume("Expect a closing bracket ']'", c.RBRACKET), s.listCloseBracket = this.previous();
1183
1191
  } catch (r) {
1184
1192
  if (!(r instanceof d))
1185
1193
  throw r;
1186
- if (n.listCloseBracket = r.partialNode, !this.canHandle(r))
1194
+ if (s.listCloseBracket = r.partialNode, !this.canHandle(r))
1187
1195
  throw new d(r.token, i(), r.handlerContext);
1188
1196
  this.synchronizeList();
1189
1197
  }
1190
1198
  return i();
1191
1199
  }), this.synchronizeList = () => {
1192
1200
  for (; !this.isAtEnd(); ) {
1193
- const n = this.peek();
1201
+ const s = this.peek();
1194
1202
  if (this.check(c.COMMA, c.RBRACKET))
1195
1203
  break;
1196
- E(n), this.advance();
1204
+ E(s), this.advance();
1197
1205
  }
1198
1206
  }, this.synchronizeAttributeName = () => {
1199
1207
  for (; !this.isAtEnd(); ) {
1200
- const n = this.peek();
1208
+ const s = this.peek();
1201
1209
  if (this.check(c.COMMA, c.RBRACKET, c.COLON))
1202
1210
  break;
1203
- E(n), this.advance();
1211
+ E(s), this.advance();
1204
1212
  }
1205
1213
  }, this.synchronizeAttributeValue = () => {
1206
1214
  for (; !this.isAtEnd(); ) {
1207
- const n = this.peek();
1215
+ const s = this.peek();
1208
1216
  if (this.check(c.COMMA, c.RBRACKET))
1209
1217
  break;
1210
- E(n), this.advance();
1218
+ E(s), this.advance();
1211
1219
  }
1212
- }, this.tokens = e, this.nodeFactory = new on(s);
1220
+ }, this.tokens = e, this.nodeFactory = new on(n);
1213
1221
  }
1214
1222
  isAtEnd() {
1215
1223
  return this.current >= this.tokens.length || this.tokens[this.current].kind === c.EOF;
@@ -1221,12 +1229,12 @@ class ln {
1221
1229
  return e + this.current >= this.tokens.length ? I.last(this.tokens) : this.tokens[this.current + e];
1222
1230
  }
1223
1231
  match(...e) {
1224
- const s = this.check(...e);
1225
- return s && this.advance(), s;
1232
+ const n = this.check(...e);
1233
+ return n && this.advance(), n;
1226
1234
  }
1227
1235
  check(...e) {
1228
- const s = this.peek();
1229
- return e.includes(s.kind);
1236
+ const n = this.peek();
1237
+ return e.includes(n.kind);
1230
1238
  }
1231
1239
  previous() {
1232
1240
  return this.tokens[this.current - 1];
@@ -1234,8 +1242,8 @@ class ln {
1234
1242
  canHandle(e) {
1235
1243
  return e.handlerContext === void 0 || e.handlerContext === this.contextStack.top();
1236
1244
  }
1237
- consume(e, ...s) {
1238
- if (!this.match(...s))
1245
+ consume(e, ...n) {
1246
+ if (!this.match(...n))
1239
1247
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, e), new d(
1240
1248
  this.peek(),
1241
1249
  void 0,
@@ -1245,59 +1253,59 @@ class ln {
1245
1253
  // Discard tokens until one of `kind` is found
1246
1254
  // If any tokens are discarded, the error message is logged
1247
1255
  // 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); )
1256
+ discardUntil(e, ...n) {
1257
+ if (this.isAtEnd() || !this.check(...n)) {
1258
+ for (E(this.peek()), this.logError(this.advance(), o.UNEXPECTED_TOKEN, e); !this.isAtEnd() && !this.check(...n); )
1251
1259
  E(this.advance());
1252
1260
  return !this.isAtEnd();
1253
1261
  }
1254
1262
  return !0;
1255
1263
  }
1256
1264
  gatherInvalid() {
1257
- const e = [], s = [];
1258
- let n, i = 0;
1265
+ const e = [], n = [];
1266
+ let s, i = 0;
1259
1267
  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) {
1268
+ n.push(this.tokens[i]);
1269
+ for (s = this.tokens[i], s.leadingInvalid = n, e.push(s), i += 1; i < this.tokens.length; i += 1) {
1262
1270
  const r = this.tokens[i];
1263
- r.isInvalid ? n.trailingInvalid.push(r) : (n = r, e.push(n));
1271
+ r.isInvalid ? s.trailingInvalid.push(r) : (s = r, e.push(s));
1264
1272
  }
1265
1273
  this.tokens = e;
1266
1274
  }
1267
1275
  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);
1276
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(C, { body: e, eof: n });
1277
+ return this.gatherInvalid(), new F({ ast: s, tokens: this.tokens }, this.errors);
1270
1278
  }
1271
1279
  /* Parsing and synchronizing ProgramNode */
1272
1280
  program() {
1273
1281
  const e = [];
1274
1282
  for (; !this.isAtEnd(); )
1275
1283
  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();
1284
+ const n = this.elementDeclaration();
1285
+ e.push(n);
1286
+ } catch (n) {
1287
+ if (!(n instanceof d))
1288
+ throw n;
1289
+ e.push(n.partialNode), this.synchronizeProgram();
1282
1290
  }
1283
1291
  return e;
1284
1292
  }
1285
1293
  /* Parsing and synchronizing top-level ElementDeclarationNode */
1286
1294
  elementDeclaration() {
1287
- const e = {}, s = () => this.nodeFactory.create(_, e);
1295
+ const e = {}, n = () => this.nodeFactory.create(_, e);
1288
1296
  try {
1289
1297
  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;
1298
+ } catch (s) {
1299
+ throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1292
1300
  }
1293
1301
  if (!this.check(c.COLON, c.LBRACE, c.LBRACKET))
1294
1302
  try {
1295
1303
  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);
1304
+ } catch (s) {
1305
+ if (!(s instanceof d))
1306
+ throw s;
1307
+ if (e.name = s.partialNode, !this.canHandle(s))
1308
+ throw new d(s.token, n(), s.handlerContext);
1301
1309
  this.synchronizeElementDeclarationName();
1302
1310
  }
1303
1311
  if (ct(this.peek()))
@@ -1306,33 +1314,33 @@ class ln {
1306
1314
  else
1307
1315
  try {
1308
1316
  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);
1317
+ } catch (s) {
1318
+ if (!(s instanceof d))
1319
+ throw s;
1320
+ if (e.alias = s.partialNode, !this.canHandle(s))
1321
+ throw new d(s.token, n(), s.handlerContext);
1314
1322
  this.synchronizeElementDeclarationAlias();
1315
1323
  }
1316
1324
  try {
1317
1325
  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;
1326
+ } catch (s) {
1327
+ throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1320
1328
  }
1321
1329
  if (!this.discardUntil(
1322
1330
  "Expect an opening brace '{' or a colon ':'",
1323
1331
  c.LBRACE,
1324
1332
  c.COLON
1325
1333
  ))
1326
- return s();
1334
+ return n();
1327
1335
  try {
1328
1336
  if (this.match(c.COLON)) {
1329
1337
  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;
1338
+ const s = this.expression();
1339
+ 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
1340
  } else
1333
1341
  e.body = this.blockExpression();
1334
- } catch (n) {
1335
- throw n instanceof d ? (e.body = n.partialNode, new d(n.token, s(), n.handlerContext)) : n;
1342
+ } catch (s) {
1343
+ throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1336
1344
  }
1337
1345
  return this.nodeFactory.create(_, e);
1338
1346
  }
@@ -1343,47 +1351,47 @@ class ln {
1343
1351
  // Note: 'This is a note' // fieldDeclaration() handles this
1344
1352
  // }
1345
1353
  fieldDeclaration() {
1346
- const e = {}, s = () => this.nodeFactory.create(_, e);
1354
+ const e = {}, n = () => this.nodeFactory.create(_, e);
1347
1355
  try {
1348
1356
  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;
1357
+ } catch (s) {
1358
+ throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1351
1359
  }
1352
1360
  try {
1353
1361
  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;
1362
+ } catch (s) {
1363
+ throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1356
1364
  }
1357
1365
  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;
1366
+ const s = this.expression();
1367
+ s instanceof _ ? this.errors.push(new u(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1368
+ } catch (s) {
1369
+ throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1362
1370
  }
1363
1371
  return this.nodeFactory.create(_, e);
1364
1372
  }
1365
1373
  /* Parsing any ExpressionNode, including non-NormalExpression */
1366
1374
  expression() {
1367
- const e = { args: [] }, s = () => en(e.callee, e.args, this.nodeFactory).unwrap_or(
1368
- this.nodeFactory.create(x, e)
1375
+ const e = { args: [] }, n = () => en(e.callee, e.args, this.nodeFactory).unwrap_or(
1376
+ this.nodeFactory.create(k, e)
1369
1377
  );
1370
1378
  try {
1371
1379
  e.callee = this.normalExpression();
1372
1380
  } catch (i) {
1373
- throw i instanceof d ? (e.callee = i.partialNode, new d(i.token, s(), i.handlerContext)) : i;
1381
+ throw i instanceof d ? (e.callee = i.partialNode, new d(i.token, n(), i.handlerContext)) : i;
1374
1382
  }
1375
1383
  if (this.shouldStopExpression())
1376
- return s();
1377
- let n = e.callee;
1384
+ return n();
1385
+ let s = e.callee;
1378
1386
  for (; !this.shouldStopExpression(); ) {
1379
- Ve(this.previous()) || this.logError(n, o.MISSING_SPACES, "Expect a following space");
1387
+ Ve(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1380
1388
  try {
1381
- n = this.normalExpression(), e.args.push(n);
1389
+ s = this.normalExpression(), e.args.push(s);
1382
1390
  } catch (i) {
1383
- throw i instanceof d ? (n = i.partialNode, e.args.push(n), new d(i.token, s(), i.handlerContext)) : i;
1391
+ throw i instanceof d ? (s = i.partialNode, e.args.push(s), new d(i.token, n(), i.handlerContext)) : i;
1384
1392
  }
1385
1393
  }
1386
- return s();
1394
+ return n();
1387
1395
  }
1388
1396
  shouldStopExpression() {
1389
1397
  if (this.isAtEnd() || bt(this.previous()))
@@ -1396,49 +1404,49 @@ class ln {
1396
1404
  }
1397
1405
  // Pratt's parsing algorithm
1398
1406
  expression_bp(e) {
1399
- let s = this.leftExpression_bp();
1407
+ let n = this.leftExpression_bp();
1400
1408
  for (; !this.isAtEnd(); ) {
1401
- const n = this.peek();
1402
- if (n.kind === c.LPAREN) {
1403
- const { left: i } = ut(n);
1409
+ const s = this.peek();
1410
+ if (s.kind === c.LPAREN) {
1411
+ const { left: i } = ut(s);
1404
1412
  if (i < e || // When '(' is encountered,
1405
1413
  // consider it part of another expression if
1406
1414
  // it's at the start of a new line
1407
1415
  // and we're currently not having unmatched '(' or '['
1408
- ot(this.previous(), n) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1416
+ ot(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1409
1417
  break;
1410
1418
  try {
1411
- s = this.nodeFactory.create(H, {
1412
- callee: s,
1419
+ n = this.nodeFactory.create(H, {
1420
+ callee: n,
1413
1421
  argumentList: this.tupleExpression()
1414
1422
  });
1415
1423
  } catch (r) {
1416
- throw r instanceof d ? (s = this.nodeFactory.create(H, {
1417
- callee: s,
1424
+ throw r instanceof d ? (n = this.nodeFactory.create(H, {
1425
+ callee: n,
1418
1426
  argumentList: r.partialNode
1419
- }), new d(r.token, s, r.handlerContext)) : r;
1427
+ }), new d(r.token, n, r.handlerContext)) : r;
1420
1428
  }
1421
- } else if (n.kind === c.LBRACKET) {
1429
+ } else if (s.kind === c.LBRACKET) {
1422
1430
  if (Ve(this.previous()))
1423
1431
  break;
1424
1432
  try {
1425
- s = this.nodeFactory.create(he, {
1426
- expression: s,
1433
+ n = this.nodeFactory.create(fe, {
1434
+ expression: n,
1427
1435
  indexer: this.listExpression()
1428
1436
  });
1429
1437
  } catch (i) {
1430
- throw i instanceof d ? (s = this.nodeFactory.create(he, {
1431
- expression: s,
1438
+ throw i instanceof d ? (n = this.nodeFactory.create(fe, {
1439
+ expression: n,
1432
1440
  indexer: i.partialNode
1433
- }), new d(i.token, s, i.handlerContext)) : i;
1441
+ }), new d(i.token, n, i.handlerContext)) : i;
1434
1442
  }
1435
- } else if (at(n)) {
1436
- const i = n, r = ut(i);
1443
+ } else if (at(s)) {
1444
+ const i = s, r = ut(i);
1437
1445
  if (r.left !== null) {
1438
1446
  if (r.left <= e)
1439
1447
  break;
1440
- this.advance(), s = this.nodeFactory.create(De, {
1441
- expression: s,
1448
+ this.advance(), n = this.nodeFactory.create(De, {
1449
+ expression: n,
1442
1450
  op: i
1443
1451
  });
1444
1452
  } else {
@@ -1447,51 +1455,51 @@ class ln {
1447
1455
  break;
1448
1456
  this.advance();
1449
1457
  try {
1450
- s = this.nodeFactory.create(q, {
1451
- leftExpression: s,
1458
+ n = this.nodeFactory.create(q, {
1459
+ leftExpression: n,
1452
1460
  op: i,
1453
1461
  rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
1454
1462
  });
1455
1463
  } catch (l) {
1456
- throw l instanceof d ? (s = this.nodeFactory.create(q, {
1457
- leftExpression: s,
1464
+ throw l instanceof d ? (n = this.nodeFactory.create(q, {
1465
+ leftExpression: n,
1458
1466
  op: i,
1459
1467
  rightExpression: l.partialNode
1460
- }), new d(l.token, s, l.handlerContext)) : l;
1468
+ }), new d(l.token, n, l.handlerContext)) : l;
1461
1469
  }
1462
1470
  }
1463
1471
  } else
1464
1472
  break;
1465
1473
  }
1466
- return s;
1474
+ return n;
1467
1475
  }
1468
1476
  leftExpression_bp() {
1469
1477
  let e;
1470
1478
  if (at(this.peek())) {
1471
- const s = {};
1472
- s.op = this.peek();
1473
- const n = fn(s.op);
1474
- if (n.right === null)
1479
+ const n = {};
1480
+ n.op = this.peek();
1481
+ const s = fn(n.op);
1482
+ if (s.right === null)
1475
1483
  throw this.logError(
1476
- s.op,
1484
+ n.op,
1477
1485
  o.UNKNOWN_PREFIX_OP,
1478
- `Unexpected '${s.op.value}' in an expression`
1486
+ `Unexpected '${n.op.value}' in an expression`
1479
1487
  ), new d(
1480
- s.op,
1481
- this.nodeFactory.create(we, { pre: s.op }),
1488
+ n.op,
1489
+ this.nodeFactory.create(we, { pre: n.op }),
1482
1490
  this.contextStack.findHandlerContext(this.tokens, this.current)
1483
1491
  );
1484
1492
  this.advance();
1485
1493
  try {
1486
- s.expression = this.expression_bp(n.right);
1494
+ n.expression = this.expression_bp(s.right);
1487
1495
  } catch (i) {
1488
- throw i instanceof d ? (s.expression = i.partialNode, new d(
1496
+ throw i instanceof d ? (n.expression = i.partialNode, new d(
1489
1497
  i.token,
1490
- this.nodeFactory.create(Q, s),
1498
+ this.nodeFactory.create(Q, n),
1491
1499
  i.handlerContext
1492
1500
  )) : i;
1493
1501
  }
1494
- e = this.nodeFactory.create(Q, s);
1502
+ e = this.nodeFactory.create(Q, n);
1495
1503
  } else if (e = this.extractOperand(), e instanceof we)
1496
1504
  throw new d(
1497
1505
  this.peek(),
@@ -1526,14 +1534,14 @@ class ln {
1526
1534
  const e = {};
1527
1535
  try {
1528
1536
  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,
1532
- this.nodeFactory.create(K, e),
1533
- s.handlerContext
1534
- )) : s;
1537
+ } catch (n) {
1538
+ throw n instanceof d ? (e.value = n.partialNode, new d(
1539
+ n.token,
1540
+ this.nodeFactory.create(ee, e),
1541
+ n.handlerContext
1542
+ )) : n;
1535
1543
  }
1536
- return this.nodeFactory.create(K, e);
1544
+ return this.nodeFactory.create(ee, e);
1537
1545
  }
1538
1546
  canBeField() {
1539
1547
  return this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.COLON;
@@ -1546,7 +1554,7 @@ class ln {
1546
1554
  c.NUMERIC_LITERAL
1547
1555
  ))
1548
1556
  return this.nodeFactory.create(R, {
1549
- expression: this.nodeFactory.create(pe, { literal: this.previous() })
1557
+ expression: this.nodeFactory.create(de, { literal: this.previous() })
1550
1558
  });
1551
1559
  if (this.match(c.QUOTED_STRING, c.IDENTIFIER))
1552
1560
  return this.nodeFactory.create(R, {
@@ -1563,23 +1571,23 @@ class ln {
1563
1571
  attribute() {
1564
1572
  const e = {};
1565
1573
  if (this.check(c.COLON, c.RBRACKET, c.COMMA)) {
1566
- const s = this.peek();
1574
+ const n = this.peek();
1567
1575
  this.logError(
1568
- s,
1576
+ n,
1569
1577
  o.EMPTY_ATTRIBUTE_NAME,
1570
1578
  "Expect a non-empty attribute name"
1571
- ), e.name = this.nodeFactory.create(te, { identifiers: [] });
1579
+ ), e.name = this.nodeFactory.create(K, { identifiers: [] });
1572
1580
  } else
1573
1581
  try {
1574
1582
  e.name = this.attributeName();
1575
- } catch (s) {
1576
- if (!(s instanceof d))
1577
- throw s;
1578
- if (e.name = s.partialNode, !this.canHandle(s))
1583
+ } catch (n) {
1584
+ if (!(n instanceof d))
1585
+ throw n;
1586
+ if (e.name = n.partialNode, !this.canHandle(n))
1579
1587
  throw new d(
1580
- s.token,
1588
+ n.token,
1581
1589
  this.nodeFactory.create(ne, e),
1582
- s.handlerContext
1590
+ n.handlerContext
1583
1591
  );
1584
1592
  this.synchronizeAttributeName();
1585
1593
  }
@@ -1589,10 +1597,10 @@ class ln {
1589
1597
  let e;
1590
1598
  try {
1591
1599
  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();
1600
+ } catch (n) {
1601
+ if (!(n instanceof d) || !this.canHandle(n))
1602
+ throw n;
1603
+ e = n.partialNode, this.synchronizeAttributeValue();
1596
1604
  }
1597
1605
  return e;
1598
1606
  }
@@ -1603,17 +1611,17 @@ class ln {
1603
1611
  for (; !this.isAtEnd() && !this.check(c.COLON, c.COMMA, c.RBRACKET); )
1604
1612
  try {
1605
1613
  this.consume("Expect an identifier", c.IDENTIFIER), e.push(this.previous());
1606
- } catch (s) {
1607
- throw s instanceof d ? new d(
1608
- s.token,
1609
- this.nodeFactory.create(te, { identifiers: e }),
1610
- s.handlerContext
1611
- ) : s;
1614
+ } catch (n) {
1615
+ throw n instanceof d ? new d(
1616
+ n.token,
1617
+ this.nodeFactory.create(K, { identifiers: e }),
1618
+ n.handlerContext
1619
+ ) : n;
1612
1620
  }
1613
- return this.nodeFactory.create(te, { identifiers: e });
1621
+ return this.nodeFactory.create(K, { identifiers: e });
1614
1622
  }
1615
- logError(e, s, n) {
1616
- this.errors.push(new u(s, n, e));
1623
+ logError(e, n, s) {
1624
+ this.errors.push(new u(n, s, e));
1617
1625
  }
1618
1626
  }
1619
1627
  const cn = {
@@ -1653,9 +1661,9 @@ function ut(t) {
1653
1661
  return pn[t.value] || { left: null, right: null };
1654
1662
  }
1655
1663
  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
- function de(t) {
1657
- var s;
1658
- const e = (s = t == null ? void 0 : t.type) == null ? void 0 : s.value.toLowerCase();
1664
+ function Ee(t) {
1665
+ var n;
1666
+ const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
1659
1667
  switch (e) {
1660
1668
  case b.Enum:
1661
1669
  case b.Table:
@@ -1669,39 +1677,39 @@ function de(t) {
1669
1677
  return new A();
1670
1678
  }
1671
1679
  }
1672
- function Ee(t) {
1680
+ function Ne(t) {
1673
1681
  if (!He(t))
1674
1682
  return new S([t]);
1675
- const e = Ee(t.leftExpression).unwrap_or(void 0);
1683
+ const e = Ne(t.leftExpression).unwrap_or(void 0);
1676
1684
  return e ? (e.push(t.rightExpression), new S(e)) : new A();
1677
1685
  }
1678
1686
  function W(t) {
1679
1687
  if (t === void 0)
1680
1688
  return new A();
1681
- const e = Ee(t).unwrap_or(void 0);
1689
+ const e = Ne(t).unwrap_or(void 0);
1682
1690
  if (!e)
1683
1691
  return new A();
1684
- const s = [];
1685
- for (const n of e) {
1686
- const i = G(n).unwrap_or(void 0);
1692
+ const n = [];
1693
+ for (const s of e) {
1694
+ const i = G(s).unwrap_or(void 0);
1687
1695
  if (!i)
1688
1696
  return new A();
1689
- s.push(i);
1697
+ n.push(i);
1690
1698
  }
1691
- return new S(s);
1699
+ return new S(n);
1692
1700
  }
1693
1701
  function Le(t) {
1694
1702
  if (t === void 0)
1695
1703
  return new A();
1696
- const e = Ee(t).unwrap_or(void 0);
1704
+ const e = Ne(t).unwrap_or(void 0);
1697
1705
  if (!e || e.length === 0)
1698
1706
  return new A();
1699
- const s = [];
1700
- let n;
1707
+ const n = [];
1708
+ let s;
1701
1709
  if (!M(I.last(e))) {
1702
1710
  const i = e.pop();
1703
- if (xt(i))
1704
- n = i.elementList.map(
1711
+ if (kt(i))
1712
+ s = i.elementList.map(
1705
1713
  (r) => V(r).unwrap()
1706
1714
  );
1707
1715
  else
@@ -1711,11 +1719,11 @@ function Le(t) {
1711
1719
  const r = G(i).unwrap_or(void 0);
1712
1720
  if (!r)
1713
1721
  return new A();
1714
- s.push(r);
1722
+ n.push(r);
1715
1723
  }
1716
1724
  return new S({
1717
- variables: s,
1718
- tupleElements: n
1725
+ variables: n,
1726
+ tupleElements: s
1719
1727
  });
1720
1728
  }
1721
1729
  function G(t) {
@@ -1723,18 +1731,18 @@ function G(t) {
1723
1731
  }
1724
1732
  function Ge(t) {
1725
1733
  if (ht(t))
1726
- return t instanceof K ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1734
+ return t instanceof ee ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1727
1735
  if (t instanceof J && t.elementList.every(ht)) {
1728
1736
  const e = t.elementList.filter(
1729
- (n) => n instanceof K
1730
- ), s = t.elementList.filter(M);
1731
- return new S({ functional: e, nonFunctional: s });
1737
+ (s) => s instanceof ee
1738
+ ), n = t.elementList.filter(M);
1739
+ return new S({ functional: e, nonFunctional: n });
1732
1740
  }
1733
1741
  return new A();
1734
1742
  }
1735
1743
  function V(t) {
1736
- var s;
1737
- const e = (s = t == null ? void 0 : t.expression.variable) == null ? void 0 : s.value;
1744
+ var n;
1745
+ const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1738
1746
  return e === void 0 ? new A() : new S(e);
1739
1747
  }
1740
1748
  function Y(t) {
@@ -1745,38 +1753,38 @@ function dn(t) {
1745
1753
  return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : Le(t.leftExpression).and_then(() => Le(t.rightExpression)).unwrap_or(void 0) !== void 0;
1746
1754
  }
1747
1755
  function En(t) {
1748
- const e = Le(t.leftExpression), s = Le(t.rightExpression);
1749
- if (!e.isOk() || !s.isOk())
1756
+ const e = Le(t.leftExpression), n = Le(t.rightExpression);
1757
+ if (!e.isOk() || !n.isOk())
1750
1758
  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);
1759
+ const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1760
+ return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1753
1761
  }
1754
1762
  function ht(t) {
1755
- return t instanceof R && t.expression instanceof X || t instanceof K;
1763
+ return t instanceof R && t.expression instanceof X || t instanceof ee;
1756
1764
  }
1757
1765
  function Nn(t, e) {
1758
1766
  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)
1767
+ let n = e;
1768
+ const s = jt(t);
1769
+ for (; n; ) {
1770
+ if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1771
+ return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1772
+ if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof C && s)
1773
+ return n.symbol;
1774
+ if (n instanceof C)
1767
1775
  return;
1768
- s = s.parent;
1776
+ n = n.parent;
1769
1777
  }
1770
1778
  }
1771
1779
  class mn {
1772
- constructor(e, s, n) {
1773
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
1780
+ constructor(e, n, s) {
1781
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1774
1782
  }
1775
1783
  validate() {
1776
1784
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1777
1785
  }
1778
1786
  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)] : [];
1787
+ return this.declarationNode.parent instanceof C || Ee(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)] : [];
1780
1788
  }
1781
1789
  validateName(e) {
1782
1790
  return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
@@ -1790,10 +1798,10 @@ class mn {
1790
1798
  validateBody(e) {
1791
1799
  if (!e)
1792
1800
  return [];
1793
- if (e instanceof ee)
1801
+ if (e instanceof te)
1794
1802
  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;
1803
+ const n = [];
1804
+ return $(e.callee) || n.push(new u(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 u(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1797
1805
  }
1798
1806
  }
1799
1807
  class _e {
@@ -1803,19 +1811,19 @@ class _e {
1803
1811
  has(e) {
1804
1812
  return this.table.has(e);
1805
1813
  }
1806
- set(e, s) {
1807
- this.table.set(e, s);
1814
+ set(e, n) {
1815
+ this.table.set(e, n);
1808
1816
  }
1809
- get(e, s) {
1810
- return this.table.get(e) || s !== void 0 && this.set(e, s) || s;
1817
+ get(e, n) {
1818
+ return this.table.get(e) || n !== void 0 && this.set(e, n) || n;
1811
1819
  }
1812
1820
  entries() {
1813
1821
  return this.table.entries();
1814
1822
  }
1815
1823
  }
1816
1824
  class Tn {
1817
- constructor(e, s, n) {
1818
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
1825
+ constructor(e, n, s) {
1826
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1819
1827
  }
1820
1828
  validate() {
1821
1829
  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)];
@@ -1832,10 +1840,10 @@ class Tn {
1832
1840
  registerElement() {
1833
1841
  const e = [];
1834
1842
  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);
1843
+ const { name: n } = this.declarationNode, s = W(n);
1844
+ if (s.isOk()) {
1845
+ const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = je(r);
1846
+ a.has(l) && e.push(new u(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1839
1847
  }
1840
1848
  return e;
1841
1849
  }
@@ -1845,67 +1853,67 @@ class Tn {
1845
1853
  validateBody(e) {
1846
1854
  if (!e)
1847
1855
  return [];
1848
- if (e instanceof x)
1856
+ if (e instanceof k)
1849
1857
  return this.validateFields([e]);
1850
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
1851
- return [...this.validateFields(s), ...this.validateSubElements(n)];
1858
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1859
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
1852
1860
  }
1853
1861
  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;
1862
+ return e.length === 0 ? [new u(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1863
+ const s = [];
1864
+ return n.callee && !M(n.callee) && s.push(new u(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 u(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), s.push(...this.registerField(n)), s;
1857
1865
  });
1858
1866
  }
1859
1867
  validateFieldSetting(e) {
1860
- const s = z(e), n = s.getErrors(), i = s.getValue();
1868
+ const n = z(e), s = n.getErrors(), i = n.getValue();
1861
1869
  for (const r in i) {
1862
1870
  const a = i[r];
1863
1871
  switch (r) {
1864
1872
  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));
1873
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1874
+ $(l.value) || s.push(new u(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1867
1875
  });
1868
1876
  break;
1869
1877
  default:
1870
- a.forEach((l) => n.push(new u(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1878
+ a.forEach((l) => s.push(new u(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1871
1879
  }
1872
1880
  }
1873
- return n;
1881
+ return s;
1874
1882
  }
1875
1883
  validateSubElements(e) {
1876
- return e.flatMap((s) => {
1877
- if (s.parent = this.declarationNode, !s.type)
1884
+ return e.flatMap((n) => {
1885
+ if (n.parent = this.declarationNode, !n.type)
1878
1886
  return [];
1879
- const n = ie(s);
1880
- return new n(s, this.publicSymbolTable, this.symbolFactory).validate();
1887
+ const s = ie(n);
1888
+ return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
1881
1889
  });
1882
1890
  }
1883
1891
  registerField(e) {
1884
1892
  if (e.callee && M(e.callee)) {
1885
- const s = V(e.callee).unwrap(), n = Ye(s), i = this.symbolFactory.create(Ht, { declaration: e });
1893
+ const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Ht, { declaration: e });
1886
1894
  e.symbol = i;
1887
1895
  const r = this.declarationNode.symbol.symbolTable;
1888
- if (r.has(n)) {
1889
- const a = r.get(n);
1896
+ if (r.has(s)) {
1897
+ const a = r.get(s);
1890
1898
  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)
1899
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1900
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1893
1901
  ];
1894
1902
  }
1895
- r.set(n, i);
1903
+ r.set(s, i);
1896
1904
  }
1897
1905
  return [];
1898
1906
  }
1899
1907
  }
1900
1908
  class bn {
1901
- constructor(e, s, n) {
1902
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
1909
+ constructor(e, n, s) {
1910
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1903
1911
  }
1904
1912
  validate() {
1905
1913
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1906
1914
  }
1907
1915
  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)] : [];
1916
+ return this.declarationNode.parent instanceof C || Ee(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)] : [];
1909
1917
  }
1910
1918
  validateName(e) {
1911
1919
  return e ? [new u(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
@@ -1919,69 +1927,69 @@ class bn {
1919
1927
  validateBody(e) {
1920
1928
  if (!e)
1921
1929
  return [];
1922
- if (e instanceof x)
1930
+ if (e instanceof k)
1923
1931
  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)];
1932
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1933
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
1926
1934
  }
1927
1935
  validateFields(e) {
1928
- return e.flatMap((s) => {
1929
- if (!s.callee)
1936
+ return e.flatMap((n) => {
1937
+ if (!n.callee)
1930
1938
  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) => {
1939
+ const s = [], i = [n.callee, ...n.args];
1940
+ return I.last(i) instanceof U && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1933
1941
  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;
1942
+ r.argumentList && !Ge(r.argumentList).isOk() && s.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;
1943
+ Ge(r).isOk() || s.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));
1944
+ }), s;
1937
1945
  });
1938
1946
  }
1939
1947
  validateFieldSetting(e) {
1940
- const s = z(e), n = s.getErrors(), i = s.getValue();
1948
+ const n = z(e), s = n.getErrors(), i = n.getValue();
1941
1949
  for (const r in i) {
1942
1950
  const a = i[r];
1943
1951
  switch (r) {
1944
1952
  case "note":
1945
1953
  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));
1954
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1955
+ $(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1948
1956
  });
1949
1957
  break;
1950
1958
  case "unique":
1951
1959
  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));
1960
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1961
+ oe(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1954
1962
  });
1955
1963
  break;
1956
1964
  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));
1965
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1966
+ M(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1959
1967
  });
1960
1968
  break;
1961
1969
  default:
1962
- a.forEach((l) => n.push(new u(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1970
+ a.forEach((l) => s.push(new u(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1963
1971
  }
1964
1972
  }
1965
- return n;
1973
+ return s;
1966
1974
  }
1967
1975
  validateSubElements(e) {
1968
- return e.flatMap((s) => {
1969
- if (s.parent = this.declarationNode, !s.type)
1976
+ return e.flatMap((n) => {
1977
+ if (n.parent = this.declarationNode, !n.type)
1970
1978
  return [];
1971
- const n = ie(s);
1972
- return new n(s, this.publicSymbolTable, this.symbolFactory).validate();
1979
+ const s = ie(n);
1980
+ return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
1973
1981
  });
1974
1982
  }
1975
1983
  }
1976
1984
  class In {
1977
- constructor(e, s, n) {
1978
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
1985
+ constructor(e, n, s) {
1986
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1979
1987
  }
1980
1988
  validate() {
1981
1989
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1982
1990
  }
1983
1991
  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)] : [];
1992
+ return this.declarationNode.parent instanceof C || ![b.Table, b.Project].includes(Ee(this.declarationNode.parent).unwrap_or(void 0)) ? [new u(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project", this.declarationNode)] : [];
1985
1993
  }
1986
1994
  validateName(e) {
1987
1995
  return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
@@ -1995,27 +2003,27 @@ class In {
1995
2003
  validateBody(e) {
1996
2004
  if (!e)
1997
2005
  return [];
1998
- if (e instanceof x)
2006
+ if (e instanceof k)
1999
2007
  return this.validateFields([e]);
2000
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
2001
- return [...this.validateFields(s), ...this.validateSubElements(n)];
2008
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2009
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2002
2010
  }
2003
2011
  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);
2012
+ const n = [];
2013
+ return e.length === 0 ? [new u(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new u(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new u(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 u(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2006
2014
  }
2007
2015
  validateSubElements(e) {
2008
- return e.flatMap((s) => {
2009
- if (s.parent = this.declarationNode, !s.type)
2016
+ return e.flatMap((n) => {
2017
+ if (n.parent = this.declarationNode, !n.type)
2010
2018
  return [];
2011
- const n = ie(s);
2012
- return new n(s, this.publicSymbolTable, this.symbolFactory).validate();
2019
+ const s = ie(n);
2020
+ return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2013
2021
  });
2014
2022
  }
2015
2023
  }
2016
2024
  class Ln {
2017
- constructor(e, s, n) {
2018
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
2025
+ constructor(e, n, s) {
2026
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2019
2027
  }
2020
2028
  validate() {
2021
2029
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
@@ -2035,32 +2043,32 @@ class Ln {
2035
2043
  validateBody(e) {
2036
2044
  if (!e)
2037
2045
  return [];
2038
- if (e instanceof x)
2046
+ if (e instanceof k)
2039
2047
  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);
2048
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2041
2049
  return [
2042
- ...s.map((i) => new u(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2043
- ...this.validateSubElements(n)
2050
+ ...n.map((i) => new u(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2051
+ ...this.validateSubElements(s)
2044
2052
  ];
2045
2053
  }
2046
2054
  validateSubElements(e) {
2047
- return e.flatMap((s) => {
2048
- if (s.parent = this.declarationNode, !s.type)
2055
+ return e.flatMap((n) => {
2056
+ if (n.parent = this.declarationNode, !n.type)
2049
2057
  return [];
2050
- const n = ie(s);
2051
- return new n(s, this.publicSymbolTable, this.symbolFactory).validate();
2058
+ const s = ie(n);
2059
+ return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2052
2060
  });
2053
2061
  }
2054
2062
  }
2055
2063
  class gn {
2056
- constructor(e, s, n) {
2057
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
2064
+ constructor(e, n, s) {
2065
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2058
2066
  }
2059
2067
  validate() {
2060
2068
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2061
2069
  }
2062
2070
  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)];
2071
+ return this.declarationNode.parent instanceof C || Ee(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)];
2064
2072
  }
2065
2073
  validateName(e) {
2066
2074
  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)] : [];
@@ -2074,50 +2082,50 @@ class gn {
2074
2082
  validateBody(e) {
2075
2083
  if (!e)
2076
2084
  return [];
2077
- if (e instanceof x)
2085
+ if (e instanceof k)
2078
2086
  return this.validateFields([e]);
2079
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
2080
- return [...this.validateFields(s), ...this.validateSubElements(n)];
2087
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2088
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2081
2089
  }
2082
2090
  validateFields(e) {
2083
2091
  if (e.length === 0)
2084
2092
  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;
2093
+ const n = [];
2094
+ return e.length > 1 && n.push(...e.slice(1).map((s) => new u(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2095
+ s.callee && !dn(s.callee) && n.push(new u(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !En(s.callee) && n.push(new u(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 u(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
2096
+ }), n;
2089
2097
  }
2090
2098
  validateFieldSettings(e) {
2091
- const s = z(e), n = s.getErrors(), i = s.getValue();
2099
+ const n = z(e), s = n.getErrors(), i = n.getValue();
2092
2100
  for (const r in i) {
2093
2101
  const a = i[r];
2094
2102
  switch (r) {
2095
2103
  case "delete":
2096
2104
  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));
2105
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2106
+ _n(l.value) || s.push(new u(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2099
2107
  });
2100
2108
  break;
2101
2109
  default:
2102
- a.forEach((l) => n.push(new u(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2110
+ a.forEach((l) => s.push(new u(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2103
2111
  }
2104
2112
  }
2105
- return n;
2113
+ return s;
2106
2114
  }
2107
2115
  validateSubElements(e) {
2108
- return e.flatMap((s) => {
2109
- if (s.parent = this.declarationNode, !s.type)
2116
+ return e.flatMap((n) => {
2117
+ if (n.parent = this.declarationNode, !n.type)
2110
2118
  return [];
2111
- const n = ie(s);
2112
- return new n(s, this.publicSymbolTable, this.symbolFactory).validate();
2119
+ const s = ie(n);
2120
+ return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2113
2121
  });
2114
2122
  }
2115
2123
  }
2116
2124
  function _n(t) {
2117
- if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof te))
2125
+ if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof K))
2118
2126
  return !1;
2119
2127
  let e;
2120
- if (t instanceof te ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
2128
+ if (t instanceof K ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
2121
2129
  switch (e.toLowerCase()) {
2122
2130
  case "cascade":
2123
2131
  case "no action":
@@ -2131,8 +2139,8 @@ function _n(t) {
2131
2139
  return !1;
2132
2140
  }
2133
2141
  class An {
2134
- constructor(e, s, n) {
2135
- this.declarationNode = e, this.symbolFactory = n, this.publicSymbolTable = s;
2142
+ constructor(e, n, s) {
2143
+ this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2136
2144
  }
2137
2145
  validate() {
2138
2146
  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)];
@@ -2141,89 +2149,89 @@ class An {
2141
2149
  return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2142
2150
  }
2143
2151
  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)];
2152
+ return e ? e instanceof fe ? [new u(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new u(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new u(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2145
2153
  }
2146
2154
  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)] : [];
2155
+ return e ? kn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2148
2156
  }
2149
2157
  validateSettingList(e) {
2150
- const s = z(e), n = s.getErrors(), i = s.getValue();
2158
+ const n = z(e), s = n.getErrors(), i = n.getValue();
2151
2159
  for (const r in i) {
2152
2160
  const a = i[r];
2153
2161
  switch (r) {
2154
2162
  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));
2163
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2164
+ xn(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2157
2165
  });
2158
2166
  break;
2159
2167
  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));
2168
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2169
+ $(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2162
2170
  });
2163
2171
  break;
2164
2172
  default:
2165
- n.push(...a.map((l) => new u(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2173
+ s.push(...a.map((l) => new u(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2166
2174
  }
2167
2175
  }
2168
- return n;
2176
+ return s;
2169
2177
  }
2170
2178
  registerElement() {
2171
2179
  const e = [];
2172
2180
  this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new _e() });
2173
- const { name: s, alias: n } = this.declarationNode, i = W(s);
2181
+ const { name: n, alias: s } = this.declarationNode, i = W(n);
2174
2182
  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);
2183
+ const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = ke(a);
2184
+ l.has(p) && e.push(new u(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2177
2185
  }
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);
2186
+ if (s && Pe(s) && !wn(s.expression.variable.value, i.unwrap_or([]))) {
2187
+ const r = V(s).unwrap(), a = ke(r);
2188
+ this.publicSymbolTable.has(a) && e.push(new u(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2181
2189
  }
2182
2190
  return e;
2183
2191
  }
2184
2192
  validateBody(e) {
2185
2193
  if (!e)
2186
2194
  return [];
2187
- if (e instanceof x)
2195
+ if (e instanceof k)
2188
2196
  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)];
2197
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2198
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2191
2199
  }
2192
2200
  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)
2201
+ return e.length === 0 ? [new u(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2202
+ if (!n.callee)
2195
2203
  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;
2204
+ const s = [];
2205
+ n.args.length === 0 && s.push(new u(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !vn(n.args[0]) && s.push(new u(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2206
+ const i = n.args.slice(1);
2207
+ return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2200
2208
  });
2201
2209
  }
2202
2210
  registerField(e) {
2203
2211
  if (e.callee && M(e.callee)) {
2204
- const s = V(e.callee).unwrap(), n = We(s), i = this.symbolFactory.create(Jt, { declaration: e });
2212
+ const n = V(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Jt, { declaration: e });
2205
2213
  e.symbol = i;
2206
2214
  const r = this.declarationNode.symbol.symbolTable;
2207
- if (r.has(n)) {
2208
- const a = r.get(n);
2215
+ if (r.has(s)) {
2216
+ const a = r.get(s);
2209
2217
  return [
2210
- new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${s}`, e),
2211
- new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${s}`, a.declaration)
2218
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2219
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2212
2220
  ];
2213
2221
  }
2214
- r.set(n, i);
2222
+ r.set(s, i);
2215
2223
  }
2216
2224
  return [];
2217
2225
  }
2218
2226
  // This is needed to support legacy inline settings
2219
2227
  validateFieldSetting(e) {
2220
- if (!e.slice(0, -1).every(fe) || !e.slice(-1).every((p) => fe(p) || p instanceof U))
2228
+ if (!e.slice(0, -1).every(pe) || !e.slice(-1).every((p) => pe(p) || p instanceof U))
2221
2229
  return [...e.map((p) => new u(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2222
2230
  if (e.length === 0)
2223
2231
  return [];
2224
- let s;
2225
- I.last(e) instanceof U && (s = e.pop());
2226
- const n = z(s), i = n.getErrors(), r = n.getValue();
2232
+ let n;
2233
+ I.last(e) instanceof U && (n = e.pop());
2234
+ const s = z(n), i = s.getErrors(), r = s.getValue();
2227
2235
  for (const p of e) {
2228
2236
  const h = V(p).unwrap_or("").toLowerCase();
2229
2237
  if (h !== "pk" && h !== "unique") {
@@ -2291,28 +2299,28 @@ class An {
2291
2299
  return i;
2292
2300
  }
2293
2301
  validateSubElements(e) {
2294
- const s = e.flatMap((i) => {
2302
+ const n = e.flatMap((i) => {
2295
2303
  if (i.parent = this.declarationNode, !i.type)
2296
2304
  return [];
2297
2305
  const r = ie(i);
2298
2306
  return new r(i, this.publicSymbolTable, this.symbolFactory).validate();
2299
- }), n = e.filter((i) => {
2307
+ }), s = e.filter((i) => {
2300
2308
  var r;
2301
2309
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2302
2310
  });
2303
- return n.length > 1 && (s.push(...n.map((i) => new u(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), s.push()), s;
2311
+ return s.length > 1 && (n.push(...s.map((i) => new u(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2304
2312
  }
2305
2313
  }
2306
2314
  function vn(t) {
2307
- if (!(t instanceof H || He(t) || t instanceof R || t instanceof he))
2315
+ if (!(t instanceof H || He(t) || t instanceof R || t instanceof fe))
2308
2316
  return !1;
2309
2317
  if (t instanceof H) {
2310
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((s) => le(s) || $(s) || fe(s)))
2318
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => le(n) || $(n) || pe(n)))
2311
2319
  return !1;
2312
2320
  t = t.callee;
2313
2321
  }
2314
- 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)))
2322
+ for (; t instanceof fe; ) {
2323
+ if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && le(n.name)))
2316
2324
  return !1;
2317
2325
  t = t.array;
2318
2326
  }
@@ -2323,8 +2331,8 @@ function wn(t, e) {
2323
2331
  return e.length === 1 && t === e[0];
2324
2332
  }
2325
2333
  class yn {
2326
- constructor(e, s, n) {
2327
- this.declarationNode = e, this.publicSymbolTable = s, this.symbolFactory = n;
2334
+ constructor(e, n, s) {
2335
+ this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2328
2336
  }
2329
2337
  validate() {
2330
2338
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.registerElement(), ...this.validateBody(this.declarationNode.body)];
@@ -2341,11 +2349,11 @@ class yn {
2341
2349
  registerElement() {
2342
2350
  const { name: e } = this.declarationNode;
2343
2351
  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);
2352
+ const n = W(e);
2353
+ if (n.isOk()) {
2354
+ const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
2347
2355
  if (r.has(a))
2348
- return [new u(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${n.join(".") || "public"}'`, e)];
2356
+ return [new u(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2349
2357
  r.set(a, this.declarationNode.symbol);
2350
2358
  }
2351
2359
  return [];
@@ -2356,38 +2364,38 @@ class yn {
2356
2364
  validateBody(e) {
2357
2365
  if (!e)
2358
2366
  return [];
2359
- if (e instanceof x)
2367
+ if (e instanceof k)
2360
2368
  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)];
2369
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2370
+ return [...this.validateFields(n), ...this.validateSubElements(s)];
2363
2371
  }
2364
2372
  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;
2373
+ return e.flatMap((n) => {
2374
+ const s = [];
2375
+ return n.callee && !W(n.callee).isOk() && s.push(new u(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 u(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2368
2376
  });
2369
2377
  }
2370
2378
  validateSubElements(e) {
2371
- return e.flatMap((s) => {
2372
- if (s.parent = this.declarationNode, !s.type)
2379
+ return e.flatMap((n) => {
2380
+ if (n.parent = this.declarationNode, !n.type)
2373
2381
  return [];
2374
- const n = ie(s);
2375
- return new n(s, this.publicSymbolTable, this.symbolFactory).validate();
2382
+ const s = ie(n);
2383
+ return new s(n, this.publicSymbolTable, this.symbolFactory).validate();
2376
2384
  });
2377
2385
  }
2378
2386
  registerField(e) {
2379
2387
  if (e.callee && M(e.callee)) {
2380
- const s = V(e.callee).unwrap(), n = Qe(s), i = this.symbolFactory.create(Kt, { declaration: e });
2388
+ const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(Kt, { declaration: e });
2381
2389
  e.symbol = i;
2382
2390
  const r = this.declarationNode.symbol.symbolTable;
2383
- if (r.has(n)) {
2384
- const a = r.get(n);
2391
+ if (r.has(s)) {
2392
+ const a = r.get(s);
2385
2393
  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)
2394
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2395
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2388
2396
  ];
2389
2397
  }
2390
- r.set(n, i);
2398
+ r.set(s, i);
2391
2399
  }
2392
2400
  return [];
2393
2401
  }
@@ -2416,43 +2424,43 @@ function ie(t) {
2416
2424
  function Je(t) {
2417
2425
  return !!W(t).unwrap_or(!1);
2418
2426
  }
2419
- function xn(t) {
2427
+ function kn(t) {
2420
2428
  return Pe(t);
2421
2429
  }
2422
2430
  function Pe(t) {
2423
2431
  return t instanceof R && t.expression instanceof X;
2424
2432
  }
2425
- function Ze(t, e, s) {
2433
+ function Ze(t, e, n) {
2426
2434
  var i;
2427
2435
  t[0] === "public" && (t = t.slice(1));
2428
- let n = e;
2436
+ let s = e;
2429
2437
  for (const r of t) {
2430
2438
  let a;
2431
2439
  const l = $e(r);
2432
- if (n.has(l)) {
2433
- if (a = (i = n.get(l)) == null ? void 0 : i.symbolTable, !a)
2440
+ if (s.has(l)) {
2441
+ if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2434
2442
  throw new Error("Expect a symbol table in a schema symbol");
2435
2443
  } else {
2436
2444
  a = new _e();
2437
- const p = s.create(_t, { symbolTable: a });
2438
- n.set(l, p);
2445
+ const p = n.create(_t, { symbolTable: a });
2446
+ s.set(l, p);
2439
2447
  }
2440
- n = a;
2448
+ s = a;
2441
2449
  }
2442
- return n;
2450
+ return s;
2443
2451
  }
2444
2452
  function yt(t) {
2445
2453
  return t === "-" || t === "<>" || t === ">" || t === "<";
2446
2454
  }
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)
2455
+ function xn(t) {
2456
+ var n;
2457
+ if (!(t instanceof R) || !(t.expression instanceof de) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== c.COLOR_LITERAL)
2450
2458
  return !1;
2451
2459
  const e = t.expression.literal.value;
2452
2460
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2453
2461
  return !1;
2454
- for (let n = 1; n < e.length; n += 1)
2455
- if (!zt(e[n]))
2462
+ for (let s = 1; s < e.length; s += 1)
2463
+ if (!zt(e[s]))
2456
2464
  return !1;
2457
2465
  return !0;
2458
2466
  }
@@ -2461,130 +2469,130 @@ function oe(t) {
2461
2469
  }
2462
2470
  function Sn(t) {
2463
2471
  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);
2472
+ return !!($(t) || le(t) || pe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression) || t instanceof ee);
2465
2473
  }
2466
2474
  function le(t) {
2467
2475
  var e;
2468
- return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
2476
+ return t instanceof R && t.expression instanceof de && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
2469
2477
  }
2470
2478
  function On(t) {
2471
- var s;
2472
- if (!(t instanceof Q) || !yt((s = t.op) == null ? void 0 : s.value))
2479
+ var n;
2480
+ if (!(t instanceof Q) || !yt((n = t.op) == null ? void 0 : n.value))
2473
2481
  return !1;
2474
2482
  const e = W(t.expression).unwrap_or(void 0);
2475
2483
  return e !== void 0 && e.length > 0;
2476
2484
  }
2477
- function xt(t) {
2485
+ function kt(t) {
2478
2486
  return t instanceof J && t.elementList.every(M);
2479
2487
  }
2480
2488
  function z(t) {
2481
- var n;
2482
- const e = {}, s = [];
2489
+ var s;
2490
+ const e = {}, n = [];
2483
2491
  if (!t)
2484
2492
  return new F({});
2485
2493
  for (const i of t.elementList) {
2486
2494
  if (!i.name)
2487
2495
  continue;
2488
2496
  if (i.name instanceof R) {
2489
- s.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2497
+ n.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2490
2498
  continue;
2491
2499
  }
2492
- const r = (n = Re(i.name).unwrap_or(void 0)) == null ? void 0 : n.toLowerCase();
2500
+ const r = (s = Re(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2493
2501
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2494
2502
  }
2495
- return new F(e, s);
2503
+ return new F(e, n);
2496
2504
  }
2497
2505
  class ft {
2498
- constructor(e, s) {
2499
- this.ast = e, this.symbolFactory = s, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
2506
+ constructor(e, n) {
2507
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
2500
2508
  symbolTable: new _e()
2501
2509
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2502
2510
  }
2503
2511
  validate() {
2504
2512
  const e = [];
2505
- this.ast.body.forEach((n) => {
2506
- if (n.parent = this.ast, n.type === void 0)
2513
+ this.ast.body.forEach((s) => {
2514
+ if (s.parent = this.ast, s.type === void 0)
2507
2515
  return;
2508
- const i = ie(n), r = new i(
2509
- n,
2516
+ const i = ie(s), r = new i(
2517
+ s,
2510
2518
  this.publicSchemaSymbol.symbolTable,
2511
2519
  this.symbolFactory
2512
2520
  );
2513
2521
  e.push(...r.validate());
2514
2522
  });
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);
2523
+ const n = this.ast.body.filter((s) => Ee(s).unwrap_or(void 0) === b.Project);
2524
+ return n.length > 1 && n.forEach((s) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
2517
2525
  }
2518
2526
  }
2519
2527
  class re {
2520
- constructor(e, s) {
2521
- this.declarationNode = e, this.errors = s;
2528
+ constructor(e, n) {
2529
+ this.declarationNode = e, this.errors = n;
2522
2530
  }
2523
2531
  bind() {
2524
2532
  this.bindSettingList(this.declarationNode.attributeList, this.settingList), this.bindBody();
2525
2533
  }
2526
- bindSettingList(e, s) {
2534
+ bindSettingList(e, n) {
2527
2535
  if (e)
2528
- for (const n of e.elementList) {
2529
- if (n.name instanceof R)
2536
+ for (const s of e.elementList) {
2537
+ if (s.name instanceof R)
2530
2538
  continue;
2531
- const i = Re(n.name).unwrap_or(void 0);
2539
+ const i = Re(s.name).unwrap_or(void 0);
2532
2540
  if (!i)
2533
2541
  continue;
2534
- const r = s[i.toLowerCase()];
2535
- r != null && r.shouldBind && this.scanAndBind(n.value, r);
2542
+ const r = n[i.toLowerCase()];
2543
+ r != null && r.shouldBind && this.scanAndBind(s.value, r);
2536
2544
  }
2537
2545
  }
2538
2546
  bindBody() {
2539
2547
  const e = this.declarationNode;
2540
2548
  if (!e.body)
2541
2549
  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)
2550
+ const { body: n } = e;
2551
+ if (n instanceof te)
2552
+ for (const s of n.body)
2553
+ if (s instanceof _) {
2554
+ if (!s.type)
2547
2555
  continue;
2548
- const i = kt(n);
2549
- new i(n, this.errors).bind();
2556
+ const i = xt(s);
2557
+ new i(s, this.errors).bind();
2550
2558
  } else
2551
- this.bindSubfield(n);
2559
+ this.bindSubfield(s);
2552
2560
  else
2553
- this.bindSubfield(s);
2561
+ this.bindSubfield(n);
2554
2562
  }
2555
2563
  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));
2564
+ const n = [e.callee, ...e.args], s = I.last(n);
2565
+ s instanceof U && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2558
2566
  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]);
2567
+ for (let r = 0; r < Math.min(n.length, i.length); r += 1)
2568
+ i[r].shouldBind && this.scanAndBind(n[r], i[r]);
2561
2569
  }
2562
2570
  // Scan for variable node and member access expression in the node to bind
2563
- scanAndBind(e, s) {
2564
- var n, i;
2571
+ scanAndBind(e, n) {
2572
+ var s, i;
2565
2573
  if (e)
2566
2574
  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())))
2575
+ if (e.expression instanceof X && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2568
2576
  return;
2569
- this.bindFragments([e], s);
2577
+ this.bindFragments([e], n);
2570
2578
  } 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));
2579
+ e instanceof q ? He(e) ? this.bindFragments(Ne(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
2572
2580
  }
2573
2581
  // Bind the fragments of a member access expression
2574
2582
  // which can be a simple expression like v1.User,
2575
2583
  // or a complex tuple like v1.User.(id, name)
2576
- bindFragments(e, s) {
2584
+ bindFragments(e, n) {
2577
2585
  if (e.length === 0)
2578
2586
  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(
2587
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 && kt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2580
2588
  0,
2581
2589
  r === -1 ? void 0 : r
2582
2590
  );
2583
2591
  if (h.length === 0)
2584
2592
  return;
2585
2593
  const T = [];
2586
- for (; n.length && h.length; ) {
2587
- const f = n.pop(), N = h.pop(), g = V(N).unwrap();
2594
+ for (; s.length && h.length; ) {
2595
+ const f = s.pop(), N = h.pop(), g = V(N).unwrap();
2588
2596
  T.unshift({
2589
2597
  index: Fe(g, f),
2590
2598
  referrer: N
@@ -2609,30 +2617,30 @@ class re {
2609
2617
  referrer: f
2610
2618
  }
2611
2619
  ],
2612
- s.ignoreNameNotFound
2620
+ n.ignoreNameNotFound
2613
2621
  )
2614
- ) : this.resolveIndexStack(T, s.ignoreNameNotFound);
2622
+ ) : this.resolveIndexStack(T, n.ignoreNameNotFound);
2615
2623
  }
2616
2624
  // Looking up the indexes in the subname stack from the current declaration node
2617
2625
  // Each time the index resolves to a symbol, the referrer's symbol is bound to it
2618
- resolveIndexStack(e, s) {
2626
+ resolveIndexStack(e, n) {
2619
2627
  if (e.length === 0)
2620
2628
  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);
2629
+ const [s, ...i] = e, r = Nn(s.index, this.declarationNode);
2622
2630
  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);
2631
+ const { kind: h, name: T } = se(s.index).unwrap();
2632
+ this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
2625
2633
  return;
2626
2634
  }
2627
- r.references.push(n.referrer), n.referrer.referee = r;
2628
- let a = r.symbolTable, { kind: l, name: p } = se(n.index).unwrap();
2635
+ r.references.push(s.referrer), s.referrer.referee = r;
2636
+ let a = r.symbolTable, { kind: l, name: p } = se(s.index).unwrap();
2629
2637
  for (const h of i) {
2630
2638
  const { kind: T, name: f } = se(h.index).unwrap(), N = a.get(h.index);
2631
2639
  if (!N) {
2632
2640
  this.logError(
2633
2641
  h.referrer,
2634
2642
  `${l} '${p}' does not have ${T} '${f}'`,
2635
- s
2643
+ n
2636
2644
  );
2637
2645
  return;
2638
2646
  }
@@ -2641,8 +2649,8 @@ class re {
2641
2649
  a = N.symbolTable;
2642
2650
  }
2643
2651
  }
2644
- logError(e, s, n) {
2645
- n || this.errors.push(new u(o.BINDING_ERROR, s, e));
2652
+ logError(e, n, s) {
2653
+ s || this.errors.push(new u(o.BINDING_ERROR, n, e));
2646
2654
  }
2647
2655
  }
2648
2656
  class Dn extends re {
@@ -2782,7 +2790,7 @@ class Vn extends re {
2782
2790
  }, this.settingList = {};
2783
2791
  }
2784
2792
  }
2785
- function kt(t) {
2793
+ function xt(t) {
2786
2794
  switch (t.type.value.toLowerCase()) {
2787
2795
  case b.Enum:
2788
2796
  return Rn;
@@ -2809,8 +2817,8 @@ class Gn {
2809
2817
  resolve() {
2810
2818
  for (const e of this.ast.body)
2811
2819
  if (e.type) {
2812
- const s = kt(e);
2813
- new s(e, this.errors).bind();
2820
+ const n = xt(e);
2821
+ new n(e, this.errors).bind();
2814
2822
  }
2815
2823
  return new F(this.ast, this.errors);
2816
2824
  }
@@ -2819,41 +2827,41 @@ class Cn {
2819
2827
  constructor(e) {
2820
2828
  this.generator = e;
2821
2829
  }
2822
- create(e, s) {
2823
- return new e(s, this.generator.nextId());
2830
+ create(e, n) {
2831
+ return new e(n, this.generator.nextId());
2824
2832
  }
2825
2833
  }
2826
2834
  class Xn {
2827
- constructor(e, s) {
2828
- this.ast = e, this.symbolFactory = new Cn(s);
2835
+ constructor(e, n) {
2836
+ this.ast = e, this.symbolFactory = new Cn(n);
2829
2837
  }
2830
2838
  // Analyzing: Invoking both the validator and binder
2831
2839
  analyze() {
2832
- return new ft(this.ast, this.symbolFactory).validate().chain((s) => new Gn(s).resolve());
2840
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Gn(n).resolve());
2833
2841
  }
2834
2842
  // For invoking the validator only
2835
2843
  validate() {
2836
- return new ft(this.ast, this.symbolFactory).validate().chain((s) => new F(s, []));
2844
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new F(n, []));
2837
2845
  }
2838
2846
  }
2839
2847
  function pt(t, e) {
2840
- const { variables: s, tupleElements: n } = Le(t).unwrap();
2841
- return n ? s.length === 0 ? {
2848
+ const { variables: n, tupleElements: s } = Le(t).unwrap();
2849
+ return s ? n.length === 0 ? {
2842
2850
  schemaName: e.schemaName,
2843
2851
  tableName: e.name,
2844
- fieldNames: n
2852
+ fieldNames: s
2845
2853
  } : {
2846
- tableName: s.pop(),
2847
- schemaName: s.pop() || null,
2848
- fieldNames: n
2849
- } : s.length === 1 ? {
2854
+ tableName: n.pop(),
2855
+ schemaName: n.pop() || null,
2856
+ fieldNames: s
2857
+ } : n.length === 1 ? {
2850
2858
  schemaName: e.schemaName,
2851
2859
  tableName: e.name,
2852
- fieldNames: [s[0]]
2860
+ fieldNames: [n[0]]
2853
2861
  } : {
2854
- fieldNames: [s.pop()],
2855
- tableName: s.pop(),
2856
- schemaName: s.pop() || null
2862
+ fieldNames: [n.pop()],
2863
+ tableName: n.pop(),
2864
+ schemaName: n.pop() || null
2857
2865
  };
2858
2866
  }
2859
2867
  function St(t) {
@@ -2869,7 +2877,7 @@ function St(t) {
2869
2877
  }
2870
2878
  throw new Error("Invalid relation op");
2871
2879
  }
2872
- function k(t) {
2880
+ function x(t) {
2873
2881
  return {
2874
2882
  start: {
2875
2883
  offset: t.startPos.offset,
@@ -2880,9 +2888,9 @@ function k(t) {
2880
2888
  };
2881
2889
  }
2882
2890
  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];
2891
+ var n;
2892
+ const e = (n = Ne(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2893
+ return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
2886
2894
  }
2887
2895
  function Ae(t) {
2888
2896
  const e = W(t).unwrap();
@@ -2899,34 +2907,34 @@ function Ot(t, e) {
2899
2907
  const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
2900
2908
  return i < r ? `${i}-${r}` : `${i}-${r}`;
2901
2909
  }
2902
- const s = t.id, n = e.id;
2903
- return s < n ? `${s}-${n}` : `${n}-${s}`;
2910
+ const n = t.id, s = e.id;
2911
+ return n < s ? `${n}-${s}` : `${s}-${n}`;
2904
2912
  }
2905
2913
  function Dt(t, e) {
2906
2914
  if (Array.isArray(t)) {
2907
2915
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
2908
2916
  return I.zip(i, r).every(([a, l]) => a === l);
2909
2917
  }
2910
- const s = t.id, n = e.id;
2911
- return s === n;
2918
+ const n = t.id, s = e.id;
2919
+ return n === s;
2912
2920
  }
2913
2921
  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 = {};
2922
+ constructor(e, n) {
2923
+ this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
2916
2924
  }
2917
2925
  interpret() {
2918
- 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)];
2926
+ return this.ref.token = x(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
2919
2927
  }
2920
2928
  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;
2929
+ const n = [], s = W(this.declarationNode.name).unwrap_or([]);
2930
+ return this.ref.name = s.pop() || null, s.length > 1 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
2923
2931
  }
2924
2932
  interpretBody(e) {
2925
- return e instanceof x ? this.interpretField(e) : this.interpretField(e.body[0]);
2933
+ return e instanceof k ? this.interpretField(e) : this.interpretField(e.body[0]);
2926
2934
  }
2927
2935
  interpretField(e) {
2928
2936
  var h, T, f, N;
2929
- const s = e.callee.op.value, { leftExpression: n, rightExpression: i } = e.callee, r = Ce(n), a = Ce(i);
2937
+ const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
2930
2938
  if (Dt(r, a))
2931
2939
  return [new u(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
2932
2940
  const l = Ot(r, a);
@@ -2939,27 +2947,27 @@ class Ke {
2939
2947
  const g = z(e.args[0]).getValue();
2940
2948
  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);
2941
2949
  }
2942
- const p = St(s);
2950
+ const p = St(n);
2943
2951
  return this.ref.endpoints = [
2944
2952
  {
2945
- ...pt(n, this.container),
2953
+ ...pt(s, this.container),
2946
2954
  relation: p[0],
2947
- token: k(n)
2955
+ token: x(s)
2948
2956
  },
2949
2957
  {
2950
2958
  ...pt(i, this.container),
2951
2959
  relation: p[1],
2952
- token: k(i)
2960
+ token: x(i)
2953
2961
  }
2954
2962
  ], this.env.refIds[l] = this.declarationNode, [];
2955
2963
  }
2956
2964
  }
2957
2965
  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 = [];
2966
+ constructor(e, n) {
2967
+ this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2960
2968
  }
2961
2969
  interpret() {
2962
- this.table.token = k(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2970
+ this.table.token = x(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2963
2971
  const e = [
2964
2972
  ...this.interpretName(this.declarationNode.name),
2965
2973
  ...this.interpretAlias(this.declarationNode.alias),
@@ -2967,7 +2975,7 @@ class Rt {
2967
2975
  ...this.interpretBody(this.declarationNode.body)
2968
2976
  ];
2969
2977
  return this.pkColumns.length >= 2 && (this.table.indexes.push({
2970
- columns: this.pkColumns.map(({ name: s }) => ({ value: s, type: "column" })),
2978
+ columns: this.pkColumns.map(({ name: n }) => ({ value: n, type: "column" })),
2971
2979
  token: {
2972
2980
  start: { offset: -1, line: -1, column: -1 },
2973
2981
  // do not make sense to have a meaningful start (?)
@@ -2975,79 +2983,79 @@ class Rt {
2975
2983
  // do not make sense to have a meaningful end (?)
2976
2984
  },
2977
2985
  pk: !0
2978
- }), this.pkColumns.forEach((s) => s.pk = !1)), e;
2986
+ }), this.pkColumns.forEach((n) => n.pk = !1)), e;
2979
2987
  }
2980
2988
  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, []);
2989
+ const { name: n, schemaName: s } = Ae(e);
2990
+ return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
2983
2991
  }
2984
2992
  interpretAlias(e) {
2985
2993
  if (!e)
2986
2994
  return [];
2987
- const s = V(e).unwrap_or(null);
2988
- return s && (this.env.aliases.push({
2989
- name: s,
2995
+ const n = V(e).unwrap_or(null);
2996
+ return n && (this.env.aliases.push({
2997
+ name: n,
2990
2998
  kind: "table",
2991
2999
  value: {
2992
3000
  tableName: this.table.name,
2993
3001
  schemaName: this.table.schemaName
2994
3002
  }
2995
- }), this.table.alias = s), [];
3003
+ }), this.table.alias = n), [];
2996
3004
  }
2997
3005
  interpretSettingList(e) {
2998
3006
  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 && {
3007
+ const n = z(e).getValue();
3008
+ this.table.headerColor = (r = n.headercolor) != null && r.length ? $n((l = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
3009
+ const [s] = n.note || [], i = Y(s == null ? void 0 : s.value).unwrap_or(void 0);
3010
+ return this.table.note = s && {
3003
3011
  value: i,
3004
- token: k(n)
3012
+ token: x(s)
3005
3013
  }, [];
3006
3014
  }
3007
3015
  interpretBody(e) {
3008
- const [s, n] = I.partition(e.body, (i) => i instanceof x);
3009
- return [...this.interpretFields(s), ...this.interpretSubElements(n)];
3016
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
3017
+ return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3010
3018
  }
3011
3019
  interpretSubElements(e) {
3012
- return e.flatMap((s) => {
3013
- var n;
3014
- switch ((n = s.type) == null ? void 0 : n.value.toLowerCase()) {
3020
+ return e.flatMap((n) => {
3021
+ var s;
3022
+ switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3015
3023
  case "note":
3016
3024
  return this.table.note = {
3017
- value: Y(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
3018
- token: k(s)
3025
+ value: Y(n.body instanceof te ? n.body.body[0].callee : n.body.callee).unwrap(),
3026
+ token: x(n)
3019
3027
  }, [];
3020
3028
  case "indexes":
3021
- return this.interpretIndexes(s);
3029
+ return this.interpretIndexes(n);
3022
3030
  case "ref":
3023
- return new Ke(s, this.env).interpret();
3031
+ return new Ke(n, this.env).interpret();
3024
3032
  }
3025
3033
  return [];
3026
3034
  });
3027
3035
  }
3028
3036
  interpretFields(e) {
3029
- return e.flatMap((s) => this.interpretColumn(s));
3037
+ return e.flatMap((n) => this.interpretColumn(n));
3030
3038
  }
3031
3039
  interpretColumn(e) {
3032
3040
  var a, l, p, h, T, f, N, g;
3033
- const s = [], n = {};
3034
- n.name = V(e.callee).unwrap();
3041
+ const n = [], s = {};
3042
+ s.name = V(e.callee).unwrap();
3035
3043
  const i = Wn(e.args[0]);
3036
- n.type = i.getValue(), s.push(...i.getErrors()), n.token = k(e), n.inline_refs = [];
3044
+ s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
3037
3045
  const r = e.args.slice(1);
3038
3046
  if (I.last(r) instanceof U) {
3039
3047
  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)
3048
+ s.pk = !!((a = v.pk) != null && a.length) || !!((l = v["primary key"]) != null && l.length), s.increment = !!((p = v.increment) != null && p.length), s.unique = !!((h = v.unique) != null && h.length), s.not_null = !!((T = v["not null"]) != null && T.length) && !0, s.dbdefault = jn((N = (f = v.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3049
+ const me = (g = v.note) == null ? void 0 : g.at(0);
3050
+ s.note = me && {
3051
+ value: Y(me.value).unwrap(),
3052
+ token: x(me)
3045
3053
  };
3046
- const me = v.ref || [];
3047
- n.inline_refs = me.flatMap((j) => {
3054
+ const Te = v.ref || [];
3055
+ s.inline_refs = Te.flatMap((j) => {
3048
3056
  const [nt] = Ce(j.value.expression);
3049
3057
  if (Dt(nt, e.symbol))
3050
- return s.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", j)), [];
3058
+ return n.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", j)), [];
3051
3059
  const ve = j.value.op, Z = W(j.value.expression).unwrap();
3052
3060
  let ce;
3053
3061
  if (Z.length === 1) {
@@ -3057,57 +3065,57 @@ class Rt {
3057
3065
  tableName: this.table.name,
3058
3066
  fieldNames: [ae],
3059
3067
  relation: ve.value,
3060
- token: k(j)
3068
+ token: x(j)
3061
3069
  };
3062
3070
  } else if (Z.length === 2) {
3063
- const [ae, Te] = Z;
3071
+ const [ae, be] = Z;
3064
3072
  ce = {
3065
3073
  schemaName: null,
3066
3074
  tableName: ae,
3067
- fieldNames: [Te],
3075
+ fieldNames: [be],
3068
3076
  relation: ve.value,
3069
- token: k(j)
3077
+ token: x(j)
3070
3078
  };
3071
3079
  } else if (Z.length === 3) {
3072
- const [ae, Te, it] = Z;
3080
+ const [ae, be, it] = Z;
3073
3081
  ce = {
3074
3082
  schemaName: ae,
3075
- tableName: Te,
3083
+ tableName: be,
3076
3084
  fieldNames: [it],
3077
3085
  relation: ve.value,
3078
- token: k(j)
3086
+ token: x(j)
3079
3087
  };
3080
3088
  } else {
3081
- s.push(new u(o.UNSUPPORTED, "Nested schema is not supported", j));
3082
- const ae = Z.pop(), Te = Z.pop();
3089
+ n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", j));
3090
+ const ae = Z.pop(), be = Z.pop();
3083
3091
  ce = {
3084
3092
  schemaName: Z.join("."),
3085
- tableName: Te,
3093
+ tableName: be,
3086
3094
  fieldNames: [ae],
3087
3095
  relation: ve.value,
3088
- token: k(j)
3096
+ token: x(j)
3089
3097
  };
3090
3098
  }
3091
3099
  const st = this.registerInlineRefToEnv(e, nt, ce, j);
3092
- return s.push(...st), st.length === 0 ? ce : [];
3100
+ return n.push(...st), st.length === 0 ? ce : [];
3093
3101
  });
3094
3102
  }
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;
3103
+ return s.pk || (s.pk = r.some((v) => G(v).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((v) => G(v).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3096
3104
  }
3097
3105
  interpretIndexes(e) {
3098
- return this.table.indexes.push(...e.body.body.map((s) => {
3106
+ return this.table.indexes.push(...e.body.body.map((n) => {
3099
3107
  var a, l, p, h, T, f, N;
3100
- const n = { columns: [] }, i = s;
3101
- n.token = k(e);
3108
+ const s = { columns: [] }, i = n;
3109
+ s.token = x(e);
3102
3110
  const r = [i.callee, ...i.args];
3103
3111
  if (I.last(r) instanceof U) {
3104
3112
  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);
3113
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = Y((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3106
3114
  const v = (T = g.note) == null ? void 0 : T.at(0);
3107
- n.note = v && {
3115
+ s.note = v && {
3108
3116
  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);
3117
+ token: x(v)
3118
+ }, s.type = G((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3111
3119
  }
3112
3120
  return r.flatMap((g) => {
3113
3121
  if (!(g instanceof H))
@@ -3117,42 +3125,42 @@ class Rt {
3117
3125
  v.push(g.argumentList), g = g.callee;
3118
3126
  return v.push(g), v;
3119
3127
  }).forEach((g) => {
3120
- const { functional: v, nonFunctional: Ne } = Ge(g).unwrap();
3121
- n.columns.push(
3122
- ...v.map((me) => ({
3123
- value: me.value.value,
3128
+ const { functional: v, nonFunctional: me } = Ge(g).unwrap();
3129
+ s.columns.push(
3130
+ ...v.map((Te) => ({
3131
+ value: Te.value.value,
3124
3132
  type: "expression"
3125
3133
  })),
3126
- ...Ne.map((me) => ({
3127
- value: V(me).unwrap(),
3134
+ ...me.map((Te) => ({
3135
+ value: V(Te).unwrap(),
3128
3136
  type: "column"
3129
3137
  }))
3130
3138
  );
3131
- }), n;
3139
+ }), s;
3132
3140
  })), [];
3133
3141
  }
3134
- registerInlineRefToEnv(e, s, n, i) {
3135
- const r = Ot(e.symbol, s);
3142
+ registerInlineRefToEnv(e, n, s, i) {
3143
+ const r = Ot(e.symbol, n);
3136
3144
  if (this.env.refIds[r])
3137
3145
  return [
3138
3146
  new u(o.CIRCULAR_REF, "References with same endpoints exist", i),
3139
3147
  new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3140
3148
  ];
3141
- const a = St(n.relation);
3149
+ const a = St(s.relation);
3142
3150
  return this.env.refIds[r] = i, this.env.ref.set(i, {
3143
3151
  name: null,
3144
3152
  schemaName: null,
3145
- token: n.token,
3153
+ token: s.token,
3146
3154
  endpoints: [
3147
3155
  {
3148
- ...n,
3156
+ ...s,
3149
3157
  relation: a[1]
3150
3158
  },
3151
3159
  {
3152
3160
  schemaName: this.table.schemaName,
3153
3161
  tableName: this.table.name,
3154
3162
  fieldNames: [G(e.callee).unwrap()],
3155
- token: k(e),
3163
+ token: x(e),
3156
3164
  relation: a[0]
3157
3165
  }
3158
3166
  ]
@@ -3162,25 +3170,25 @@ class Rt {
3162
3170
  function Wn(t) {
3163
3171
  let e = null;
3164
3172
  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 = "";
3166
- 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(
3173
+ let n = "";
3174
+ for (; t instanceof fe; )
3175
+ n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3176
+ const { name: s, schemaName: i } = Ae(t);
3177
+ return i.length > 1 ? new F(
3170
3178
  {
3171
3179
  schemaName: i.length === 0 ? null : i[0],
3172
- type_name: `${n}${s}${e ? `(${e})` : ""}`,
3180
+ type_name: `${s}${n}${e ? `(${e})` : ""}`,
3173
3181
  args: e
3174
3182
  },
3175
3183
  [new u(o.UNSUPPORTED, "Nested schema is not supported", t)]
3176
- ), new F({
3184
+ ) : new F({
3177
3185
  schemaName: i.length === 0 ? null : i[0],
3178
- type_name: `${n}${s}${e ? `(${e})` : ""}`,
3186
+ type_name: `${s}${n}${e ? `(${e})` : ""}`,
3179
3187
  args: e
3180
3188
  });
3181
3189
  }
3182
3190
  function jn(t) {
3183
- var e, s, n;
3191
+ var e, n, s;
3184
3192
  if (t) {
3185
3193
  if ($(t))
3186
3194
  return {
@@ -3192,7 +3200,7 @@ function jn(t) {
3192
3200
  type: "number",
3193
3201
  value: Number.parseFloat(t.expression.literal.value)
3194
3202
  };
3195
- if (fe(t))
3203
+ if (pe(t))
3196
3204
  return {
3197
3205
  value: t.expression.variable.value.toLowerCase(),
3198
3206
  type: "boolean"
@@ -3200,27 +3208,27 @@ function jn(t) {
3200
3208
  if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression)) {
3201
3209
  const i = Number.parseFloat(t.expression.expression.literal.value);
3202
3210
  return {
3203
- value: ((s = t.op) == null ? void 0 : s.value) === "-" ? 0 - i : i,
3211
+ value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
3204
3212
  type: "number"
3205
3213
  };
3206
3214
  }
3207
- if (t instanceof K)
3215
+ if (t instanceof ee)
3208
3216
  return {
3209
- value: (n = t.value) == null ? void 0 : n.value,
3217
+ value: (s = t.value) == null ? void 0 : s.value,
3210
3218
  type: "expression"
3211
3219
  };
3212
3220
  throw new Error("Unreachable");
3213
3221
  }
3214
3222
  }
3215
3223
  class Pt {
3216
- constructor(e, s) {
3217
- this.declarationNode = e, this.env = s, this.tableGroup = { tables: [] };
3224
+ constructor(e, n) {
3225
+ this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3218
3226
  }
3219
3227
  interpret() {
3220
3228
  const e = [];
3221
- 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) => {
3229
+ this.tableGroup.token = x(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
3230
+ const { name: n, schemaName: s } = Ae(this.declarationNode.name);
3231
+ return s.length >= 2 && (this.tableGroup.name = n, this.tableGroup.schemaName = s.join("."), e.push(new u(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) => {
3224
3232
  const r = W(i.callee).unwrap();
3225
3233
  return r.length > 2 && e.push(new u(o.UNSUPPORTED, "Nested schema is not supported", i)), {
3226
3234
  name: r.pop(),
@@ -3230,32 +3238,32 @@ class Pt {
3230
3238
  }
3231
3239
  }
3232
3240
  class Ut {
3233
- constructor(e, s) {
3234
- this.declarationNode = e, this.env = s, this.enum = { values: [] };
3241
+ constructor(e, n) {
3242
+ this.declarationNode = e, this.env = n, this.enum = { values: [] };
3235
3243
  }
3236
3244
  interpret() {
3237
- 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)];
3245
+ return this.enum.token = x(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3238
3246
  }
3239
3247
  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, []);
3248
+ const { name: n, schemaName: s } = Ae(e);
3249
+ return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3242
3250
  }
3243
3251
  interpretBody(e) {
3244
- return e.body.flatMap((s) => {
3252
+ return e.body.flatMap((n) => {
3245
3253
  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);
3254
+ const s = n, i = {};
3255
+ i.token = x(s), i.name = G(s.callee).unwrap();
3256
+ const a = (l = z(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3249
3257
  return i.note = a && {
3250
3258
  value: Y(a.value).unwrap(),
3251
- token: k(a)
3259
+ token: x(a)
3252
3260
  }, this.enum.values.push(i), [];
3253
3261
  });
3254
3262
  }
3255
3263
  }
3256
3264
  class Yn {
3257
- constructor(e, s) {
3258
- this.declarationNode = e, this.env = s, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3265
+ constructor(e, n) {
3266
+ this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3259
3267
  }
3260
3268
  interpret() {
3261
3269
  return this.env.project.set(this.declarationNode, this.project), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
@@ -3263,37 +3271,37 @@ class Yn {
3263
3271
  interpretName(e) {
3264
3272
  if (!e)
3265
3273
  return this.project.name = null, [];
3266
- const { name: s } = Ae(e);
3267
- return this.project.name = s, [];
3274
+ const { name: n } = Ae(e);
3275
+ return this.project.name = n, [];
3268
3276
  }
3269
3277
  interpretBody(e) {
3270
- return e.body.flatMap((s) => {
3278
+ return e.body.flatMap((n) => {
3271
3279
  var i;
3272
- const n = s;
3273
- switch ((i = n.type) == null ? void 0 : i.value.toLowerCase()) {
3280
+ const s = n;
3281
+ switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
3274
3282
  case "table": {
3275
- const r = new Rt(n, this.env).interpret();
3276
- return this.project.tables.push(this.env.tables.get(n)), r;
3283
+ const r = new Rt(s, this.env).interpret();
3284
+ return this.project.tables.push(this.env.tables.get(s)), r;
3277
3285
  }
3278
3286
  case "ref": {
3279
- const r = new Ke(n, this.env).interpret();
3280
- return this.project.refs.push(this.env.ref.get(n)), r;
3287
+ const r = new Ke(s, this.env).interpret();
3288
+ return this.project.refs.push(this.env.ref.get(s)), r;
3281
3289
  }
3282
3290
  case "tablegroup": {
3283
- const r = new Pt(n, this.env).interpret();
3284
- return this.project.tableGroups.push(this.env.tableGroups.get(n)), r;
3291
+ const r = new Pt(s, this.env).interpret();
3292
+ return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
3285
3293
  }
3286
3294
  case "enum": {
3287
- const r = new Ut(n, this.env).interpret();
3288
- return this.project.enums.push(this.env.enums.get(n)), r;
3295
+ const r = new Ut(s, this.env).interpret();
3296
+ return this.project.enums.push(this.env.enums.get(s)), r;
3289
3297
  }
3290
3298
  case "note":
3291
3299
  return this.project.note = {
3292
- value: Y(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
3293
- token: k(n)
3300
+ value: Y(s.body instanceof te ? s.body.body[0].callee : s.body.callee).unwrap(),
3301
+ token: x(s)
3294
3302
  }, [];
3295
3303
  default:
3296
- return this.project[n.type.value.toLowerCase()] = Y(n.body.callee).unwrap(), [];
3304
+ return this.project[s.type.value.toLowerCase()] = Y(s.body.callee).unwrap(), [];
3297
3305
  }
3298
3306
  });
3299
3307
  }
@@ -3312,18 +3320,18 @@ class zn {
3312
3320
  };
3313
3321
  }
3314
3322
  interpret() {
3315
- const e = this.ast.body.flatMap((s) => {
3316
- switch (de(s).unwrap_or(void 0)) {
3323
+ const e = this.ast.body.flatMap((n) => {
3324
+ switch (Ee(n).unwrap_or(void 0)) {
3317
3325
  case b.Table:
3318
- return new Rt(s, this.env).interpret();
3326
+ return new Rt(n, this.env).interpret();
3319
3327
  case b.Ref:
3320
- return new Ke(s, this.env).interpret();
3328
+ return new Ke(n, this.env).interpret();
3321
3329
  case b.TableGroup:
3322
- return new Pt(s, this.env).interpret();
3330
+ return new Pt(n, this.env).interpret();
3323
3331
  case b.Enum:
3324
- return new Ut(s, this.env).interpret();
3332
+ return new Ut(n, this.env).interpret();
3325
3333
  case b.Project:
3326
- return new Yn(s, this.env).interpret();
3334
+ return new Yn(n, this.env).interpret();
3327
3335
  default:
3328
3336
  return [];
3329
3337
  }
@@ -3366,10 +3374,10 @@ function ge(t) {
3366
3374
  function Se(t, e) {
3367
3375
  if (!t || Ve(t))
3368
3376
  return !1;
3369
- for (const s of t.trailingTrivia) {
3370
- if (s.start > e)
3377
+ for (const n of t.trailingTrivia) {
3378
+ if (n.start > e)
3371
3379
  break;
3372
- if (s.kind === c.NEWLINE && s.end <= e)
3380
+ if (n.kind === c.NEWLINE && n.end <= e)
3373
3381
  return !1;
3374
3382
  }
3375
3383
  return !0;
@@ -3401,26 +3409,26 @@ function et(t, e) {
3401
3409
  return t.getOffsetAt(e);
3402
3410
  }
3403
3411
  class Mt {
3404
- constructor(e, s = []) {
3405
- this.compiler = e, this.triggerCharacters = s;
3412
+ constructor(e, n = []) {
3413
+ this.compiler = e, this.triggerCharacters = n;
3406
3414
  }
3407
- provideCompletionItems(e, s) {
3415
+ provideCompletionItems(e, n) {
3408
3416
  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];
3417
+ const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
3410
3418
  if ([
3411
3419
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3412
3420
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3413
3421
  ...(l == null ? void 0 : l.leadingTrivia) || []
3414
- ].find((N) => $t(N) && Ie(n, N)))
3422
+ ].find((N) => $t(N) && Ie(s, N)))
3415
3423
  return O();
3416
3424
  if (a === void 0)
3417
3425
  return Tt();
3418
- if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && Ie(n, r))
3426
+ if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && Ie(s, r))
3419
3427
  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)
3428
+ const p = this.compiler.container.element(s);
3429
+ if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
3422
3430
  return Tt();
3423
- const h = [...this.compiler.container.stack(n)].reverse();
3431
+ const h = [...this.compiler.container.stack(s)].reverse();
3424
3432
  for (const N of h)
3425
3433
  if (N instanceof Q)
3426
3434
  switch ((T = N.op) == null ? void 0 : T.value) {
@@ -3430,7 +3438,7 @@ class Mt {
3430
3438
  case "-":
3431
3439
  return dt(
3432
3440
  this.compiler,
3433
- n,
3441
+ s,
3434
3442
  N
3435
3443
  );
3436
3444
  }
@@ -3442,54 +3450,54 @@ class Mt {
3442
3450
  case "-":
3443
3451
  return dt(
3444
3452
  this.compiler,
3445
- n,
3453
+ s,
3446
3454
  N
3447
3455
  );
3448
3456
  case ".":
3449
3457
  return Ft(
3450
3458
  this.compiler,
3451
- n,
3459
+ s,
3452
3460
  N
3453
3461
  );
3454
3462
  }
3455
3463
  else {
3456
3464
  if (N instanceof ne)
3457
- return Et(this.compiler, n, N);
3465
+ return Et(this.compiler, s, N);
3458
3466
  if (N instanceof U)
3459
- return Et(this.compiler, n, N);
3467
+ return Et(this.compiler, s, N);
3460
3468
  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);
3469
+ return qn(this.compiler, s);
3470
+ if (N instanceof k)
3471
+ return mt(this.compiler, s, N);
3472
+ if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && Ie(s, N.body)))
3473
+ return mt(this.compiler, s, void 0);
3466
3474
  }
3467
3475
  return O();
3468
3476
  }
3469
3477
  }
3470
- function dt(t, e, s) {
3471
- const n = t.container.scopeKind(e);
3472
- if ([D.REF, D.TABLE].includes(n)) {
3478
+ function dt(t, e, n) {
3479
+ const s = t.container.scopeKind(e);
3480
+ if ([D.REF, D.TABLE].includes(s)) {
3473
3481
  const i = Me(t, e, t.container.element(e), [
3474
3482
  m.Table,
3475
3483
  m.Schema,
3476
3484
  m.Column
3477
3485
  ]);
3478
- return Se(s.op, e) ? Oe(i) : i;
3486
+ return Se(n.op, e) ? Oe(i) : i;
3479
3487
  }
3480
3488
  return O();
3481
3489
  }
3482
- function Me(t, e, s, n) {
3490
+ function Me(t, e, n, s) {
3483
3491
  var a;
3484
- if (s === void 0)
3492
+ if (n === void 0)
3485
3493
  return O();
3486
- let i = s;
3494
+ let i = n;
3487
3495
  const r = { suggestions: [] };
3488
3496
  for (; i; ) {
3489
3497
  if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
3490
3498
  const { symbol: l } = i;
3491
3499
  r.suggestions.push(
3492
- ...t.symbol.members(l).filter(({ kind: p }) => n.includes(p)).map(({ name: p, kind: h }) => ({
3500
+ ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3493
3501
  label: p,
3494
3502
  insertText: p,
3495
3503
  insertTextRules: w.KeepWhitespace,
@@ -3504,7 +3512,7 @@ function Me(t, e, s, n) {
3504
3512
  return Ue(r);
3505
3513
  }
3506
3514
  function qn(t, e) {
3507
- var n;
3515
+ var s;
3508
3516
  switch (t.container.scopeKind(e)) {
3509
3517
  case D.INDEXES:
3510
3518
  return Vt(t, e);
@@ -3513,7 +3521,7 @@ function qn(t, e) {
3513
3521
  const i = [...t.container.stack(e)];
3514
3522
  for (; i.length > 0; ) {
3515
3523
  const r = i.pop();
3516
- if (r instanceof q && ((n = r.op) == null ? void 0 : n.value) === ".")
3524
+ if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
3517
3525
  return Ft(
3518
3526
  t,
3519
3527
  e,
@@ -3525,30 +3533,30 @@ function qn(t, e) {
3525
3533
  }
3526
3534
  return O();
3527
3535
  }
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)) {
3536
+ function Et(t, e, n) {
3537
+ const { token: s } = t.container.token(e);
3538
+ if ([c.COMMA, c.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3531
3539
  const i = Nt(t, e);
3532
- return (n == null ? void 0 : n.kind) === c.COMMA && Se(n, e) ? Oe(i) : i;
3540
+ return (s == null ? void 0 : s.kind) === c.COMMA && Se(s, e) ? Oe(i) : i;
3533
3541
  }
3534
- if (s.name && s.name.start <= e && s.name.end >= e)
3542
+ if (n.name && n.name.start <= e && n.name.end >= e)
3535
3543
  return Nt(t, e);
3536
- if (s.name) {
3544
+ if (n.name instanceof K) {
3537
3545
  const i = Hn(
3538
3546
  t,
3539
3547
  e,
3540
- Re(s.name).unwrap()
3548
+ Re(n.name).unwrap()
3541
3549
  );
3542
- return (n == null ? void 0 : n.kind) === c.COLON && Se(n, e) ? Oe(i) : i;
3550
+ return (s == null ? void 0 : s.kind) === c.COLON && Se(s, e) ? Oe(i) : i;
3543
3551
  }
3544
3552
  return O();
3545
3553
  }
3546
3554
  function Nt(t, e) {
3547
- const s = t.container.element(e), n = t.container.scopeKind(e);
3548
- if (s instanceof C)
3555
+ const n = t.container.element(e), s = t.container.scopeKind(e);
3556
+ if (n instanceof C)
3549
3557
  return O();
3550
- if (s.body && !Ie(e, s.body))
3551
- switch (n) {
3558
+ if (n.body && !Ie(e, n.body))
3559
+ switch (s) {
3552
3560
  case D.TABLE:
3553
3561
  return {
3554
3562
  suggestions: [
@@ -3571,7 +3579,7 @@ function Nt(t, e) {
3571
3579
  default:
3572
3580
  return O();
3573
3581
  }
3574
- switch (n) {
3582
+ switch (s) {
3575
3583
  case D.TABLE:
3576
3584
  return {
3577
3585
  suggestions: [
@@ -3642,14 +3650,14 @@ function Nt(t, e) {
3642
3650
  }
3643
3651
  return O();
3644
3652
  }
3645
- function Hn(t, e, s) {
3646
- switch (s == null ? void 0 : s.toLowerCase()) {
3653
+ function Hn(t, e, n) {
3654
+ switch (n == null ? void 0 : n.toLowerCase()) {
3647
3655
  case "update":
3648
3656
  case "delete":
3649
3657
  return {
3650
- suggestions: ["cascade", "set default", "set null", "restrict"].map((n) => ({
3651
- label: n,
3652
- insertText: n,
3658
+ suggestions: ["cascade", "set default", "set null", "restrict"].map((s) => ({
3659
+ label: s,
3660
+ insertText: s,
3653
3661
  kind: L.Value,
3654
3662
  insertTextRules: w.KeepWhitespace,
3655
3663
  range: void 0
@@ -3657,9 +3665,9 @@ function Hn(t, e, s) {
3657
3665
  };
3658
3666
  case "type":
3659
3667
  return {
3660
- suggestions: ["btree", "hash"].map((n) => ({
3661
- label: n,
3662
- insertText: `${n}`,
3668
+ suggestions: ["btree", "hash"].map((s) => ({
3669
+ label: s,
3670
+ insertText: `${s}`,
3663
3671
  kind: L.Value,
3664
3672
  insertTextRules: w.KeepWhitespace,
3665
3673
  range: void 0
@@ -3668,11 +3676,11 @@ function Hn(t, e, s) {
3668
3676
  }
3669
3677
  return O();
3670
3678
  }
3671
- function Ft(t, e, s) {
3672
- const n = Ee(s).unwrap_or([]);
3673
- if (n.pop(), n.some((r) => !M(r)))
3679
+ function Ft(t, e, n) {
3680
+ const s = Ne(n).unwrap_or([]);
3681
+ if (s.pop(), s.some((r) => !M(r)))
3674
3682
  return O();
3675
- const i = n.map((r) => G(r).unwrap());
3683
+ const i = s.map((r) => G(r).unwrap());
3676
3684
  return Ue({
3677
3685
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3678
3686
  label: a,
@@ -3682,17 +3690,17 @@ function Ft(t, e, s) {
3682
3690
  }))
3683
3691
  });
3684
3692
  }
3685
- function mt(t, e, s) {
3693
+ function mt(t, e, n) {
3686
3694
  var i;
3687
3695
  switch (t.container.scopeKind(e)) {
3688
3696
  case D.TABLE:
3689
- return Zn(t, e, s);
3697
+ return Zn(t, e, n);
3690
3698
  case D.PROJECT:
3691
- return Kn(t, e, s);
3699
+ return Kn(t, e, n);
3692
3700
  case D.INDEXES:
3693
3701
  return ts(t, e);
3694
3702
  case D.ENUM:
3695
- return Jn(t, e, s);
3703
+ return Jn(t, e, n);
3696
3704
  case D.REF: {
3697
3705
  const r = Bt(t, e);
3698
3706
  return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
@@ -3714,15 +3722,15 @@ function Tt() {
3714
3722
  }))
3715
3723
  };
3716
3724
  }
3717
- function Jn(t, e, s) {
3718
- return s != null && s.callee && tt(e, s) === 1 ? Me(t, e, t.container.element(e), [
3725
+ function Jn(t, e, n) {
3726
+ return n != null && n.callee && tt(e, n) === 1 ? Me(t, e, t.container.element(e), [
3719
3727
  m.Schema,
3720
3728
  m.Table,
3721
3729
  m.Column
3722
3730
  ]) : O();
3723
3731
  }
3724
- function Zn(t, e, s) {
3725
- if (!(s != null && s.callee))
3732
+ function Zn(t, e, n) {
3733
+ if (!(n != null && n.callee))
3726
3734
  return {
3727
3735
  suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3728
3736
  label: i,
@@ -3732,8 +3740,8 @@ function Zn(t, e, s) {
3732
3740
  range: void 0
3733
3741
  }))
3734
3742
  };
3735
- const n = tt(e, s);
3736
- return n === 0 ? {
3743
+ const s = tt(e, n);
3744
+ return s === 0 ? {
3737
3745
  suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3738
3746
  label: i,
3739
3747
  insertText: i,
@@ -3741,10 +3749,10 @@ function Zn(t, e, s) {
3741
3749
  kind: L.Keyword,
3742
3750
  range: void 0
3743
3751
  }))
3744
- } : n === 1 ? ns(t, e) : O();
3752
+ } : s === 1 ? ns(t, e) : O();
3745
3753
  }
3746
- function Kn(t, e, s) {
3747
- return s != null && s.callee ? tt(e, s) === 0 ? {
3754
+ function Kn(t, e, n) {
3755
+ return n != null && n.callee ? tt(e, n) === 0 ? {
3748
3756
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3749
3757
  label: i,
3750
3758
  insertText: i,
@@ -3772,15 +3780,15 @@ function Bt(t, e) {
3772
3780
  function es(t) {
3773
3781
  return Ue({
3774
3782
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3775
- const s = se(e).unwrap_or(void 0);
3776
- if (s === void 0)
3783
+ const n = se(e).unwrap_or(void 0);
3784
+ if (n === void 0)
3777
3785
  return [];
3778
- const { kind: n, name: i } = s;
3779
- return n !== m.Table && n !== m.Schema ? [] : {
3786
+ const { kind: s, name: i } = n;
3787
+ return s !== m.Table && s !== m.Schema ? [] : {
3780
3788
  label: i,
3781
3789
  insertText: i,
3782
3790
  insertTextRules: w.KeepWhitespace,
3783
- kind: ge(n),
3791
+ kind: ge(s),
3784
3792
  range: void 0
3785
3793
  };
3786
3794
  })
@@ -3849,9 +3857,9 @@ function ns(t, e) {
3849
3857
  "CLOB",
3850
3858
  "NCLOB",
3851
3859
  "RAW"
3852
- ].map((s) => ({
3853
- label: s,
3854
- insertText: s,
3860
+ ].map((n) => ({
3861
+ label: n,
3862
+ insertText: n,
3855
3863
  insertTextRules: w.KeepWhitespace,
3856
3864
  kind: L.TypeParameter,
3857
3865
  sortText: L.TypeParameter.toString().padStart(2, "0"),
@@ -3865,10 +3873,10 @@ function ns(t, e) {
3865
3873
  };
3866
3874
  }
3867
3875
  function Vt(t, e) {
3868
- const n = t.container.element(e).parent;
3869
- if (!((n == null ? void 0 : n.symbol) instanceof At))
3876
+ const n = t.container.element(e), s = n == null ? void 0 : n.parent;
3877
+ if (!((s == null ? void 0 : s.symbol) instanceof At))
3870
3878
  return O();
3871
- const { symbolTable: i } = n.symbol;
3879
+ const { symbolTable: i } = s.symbol;
3872
3880
  return Ue({
3873
3881
  suggestions: [...i.entries()].flatMap(([r]) => {
3874
3882
  const a = se(r).unwrap_or(void 0);
@@ -3888,19 +3896,19 @@ function Vt(t, e) {
3888
3896
  function tt(t, e) {
3889
3897
  if (!e.callee)
3890
3898
  return -1;
3891
- const s = [e.callee, ...e.args], n = s.findIndex((i) => t <= i.end);
3892
- return n === -1 ? s.length : n;
3899
+ const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
3900
+ return s === -1 ? n.length : s;
3893
3901
  }
3894
3902
  class Gt {
3895
3903
  constructor(e) {
3896
3904
  this.compiler = e;
3897
3905
  }
3898
- provideDefinition(e, s) {
3906
+ provideDefinition(e, n) {
3899
3907
  var a;
3900
- const { uri: n } = e, i = et(e, s), r = [...this.compiler.container.stack(i)];
3908
+ const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3901
3909
  for (; r.length !== 0; ) {
3902
3910
  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)) {
3911
+ if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [he.PRIMARY_EXPRESSION, he.VARIABLE].includes(l == null ? void 0 : l.kind)) {
3904
3912
  const { startPos: p, endPos: h } = l.referee.declaration;
3905
3913
  return [
3906
3914
  {
@@ -3910,7 +3918,7 @@ class Gt {
3910
3918
  endColumn: h.column + 1,
3911
3919
  endLineNumber: h.line + 1
3912
3920
  },
3913
- uri: n
3921
+ uri: s
3914
3922
  }
3915
3923
  ];
3916
3924
  }
@@ -3922,14 +3930,14 @@ class Ct {
3922
3930
  constructor(e) {
3923
3931
  this.compiler = e;
3924
3932
  }
3925
- provideReferences(e, s) {
3926
- const { uri: n } = e, i = et(e, s), r = [...this.compiler.container.stack(i)];
3933
+ provideReferences(e, n) {
3934
+ const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3927
3935
  for (; r.length !== 0; ) {
3928
3936
  const a = r.pop();
3929
3937
  if (a && [
3930
- ue.ELEMENT_DECLARATION,
3931
- ue.FUNCTION_APPLICATION,
3932
- ue.PRIMARY_EXPRESSION
3938
+ he.ELEMENT_DECLARATION,
3939
+ he.FUNCTION_APPLICATION,
3940
+ he.PRIMARY_EXPRESSION
3933
3941
  ].includes(a == null ? void 0 : a.kind)) {
3934
3942
  const { symbol: l } = a;
3935
3943
  if (l != null && l.references.length)
@@ -3940,7 +3948,7 @@ class Ct {
3940
3948
  endColumn: h.column + 1,
3941
3949
  endLineNumber: h.line + 1
3942
3950
  },
3943
- uri: n
3951
+ uri: s
3944
3952
  }));
3945
3953
  }
3946
3954
  }
@@ -3976,8 +3984,8 @@ class as {
3976
3984
  _: this.createQuery(
3977
3985
  0,
3978
3986
  () => {
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 })));
3987
+ const e = new rn(this.source).lex().chain((n) => new ln(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Xn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
3988
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new zn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
3981
3989
  }
3982
3990
  ),
3983
3991
  ast: this.createQuery(
@@ -4001,16 +4009,16 @@ class as {
4001
4009
  stack: this.createQuery(
4002
4010
  10,
4003
4011
  (e) => {
4004
- const s = this.parse.tokens();
4005
- let { index: n } = this.container.token(e);
4012
+ const n = this.parse.tokens();
4013
+ let { index: s } = this.container.token(e);
4006
4014
  const { token: i } = this.container.token(e);
4007
- if (n === void 0)
4015
+ if (s === void 0)
4008
4016
  return [this.parse.ast()];
4009
- for (; s[n].isInvalid && n >= 0; )
4010
- n -= 1;
4011
- if (n === -1)
4017
+ for (; n[s].isInvalid && s >= 0; )
4018
+ s -= 1;
4019
+ if (s === -1)
4012
4020
  return [this.parse.ast()];
4013
- const r = s[n].start;
4021
+ const r = n[s].start;
4014
4022
  let a = this.parse.ast();
4015
4023
  const l = [a];
4016
4024
  for (; ; ) {
@@ -4024,13 +4032,13 @@ class as {
4024
4032
  for (; l.length > 0; ) {
4025
4033
  let p = !1;
4026
4034
  const h = I.last(l);
4027
- if (h instanceof x) {
4035
+ if (h instanceof k) {
4028
4036
  const T = this.parse.source();
4029
4037
  for (let f = h.end; f < e; f += 1)
4030
4038
  T[f] === `
4031
4039
  ` && (l.pop(), p = !0);
4032
4040
  } 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);
4041
+ 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 te ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof K || h.end < e && (l.pop(), p = !0);
4034
4042
  if (p) {
4035
4043
  const T = I.last(l);
4036
4044
  T instanceof _ && T.end <= e && l.pop();
@@ -4044,35 +4052,35 @@ class as {
4044
4052
  token: this.createQuery(
4045
4053
  11,
4046
4054
  (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
4055
+ const n = this.token.flatStream().findIndex((s) => s.start >= e);
4056
+ return n === void 0 ? { token: void 0, index: void 0 } : n <= 0 ? { token: void 0, index: void 0 } : {
4057
+ token: this.token.flatStream()[n - 1],
4058
+ index: n - 1
4051
4059
  };
4052
4060
  }
4053
4061
  ),
4054
4062
  element: this.createQuery(
4055
4063
  12,
4056
4064
  (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];
4065
+ const n = this.container.stack(e);
4066
+ for (let s = n.length - 1; s >= 0; s -= 1)
4067
+ if (n[s] instanceof _)
4068
+ return n[s];
4061
4069
  return this.parse.ast();
4062
4070
  }
4063
4071
  ),
4064
4072
  scope: this.createQuery(
4065
4073
  14,
4066
4074
  (e) => {
4067
- var s, n;
4068
- return (n = (s = this.container.element(e)) == null ? void 0 : s.symbol) == null ? void 0 : n.symbolTable;
4075
+ var n, s;
4076
+ return (s = (n = this.container.element(e)) == null ? void 0 : n.symbol) == null ? void 0 : s.symbolTable;
4069
4077
  }
4070
4078
  ),
4071
4079
  scopeKind: this.createQuery(15, (e) => {
4072
- var n;
4080
+ var s;
4073
4081
  if (this.container.element(e) instanceof C)
4074
4082
  return 8;
4075
- switch ((n = this.container.element(e).type) == null ? void 0 : n.value.toLowerCase()) {
4083
+ switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4076
4084
  case "table":
4077
4085
  return 0;
4078
4086
  case "enum":
@@ -4100,13 +4108,13 @@ class as {
4100
4108
  8,
4101
4109
  ({
4102
4110
  nameStack: e,
4103
- owner: s = this.parse.ast()
4111
+ owner: n = this.parse.ast()
4104
4112
  }) => {
4105
4113
  var i;
4106
4114
  if (e.length === 0)
4107
4115
  return [];
4108
- const n = [];
4109
- for (let r = s; r; r = r instanceof _ ? r.parent : void 0) {
4116
+ const s = [];
4117
+ for (let r = n; r; r = r instanceof _ ? r.parent : void 0) {
4110
4118
  if (!((i = r.symbol) != null && i.symbolTable))
4111
4119
  continue;
4112
4120
  const { symbolTable: a } = r.symbol;
@@ -4120,31 +4128,31 @@ class as {
4120
4128
  ), l = p.flatMap(
4121
4129
  (T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
4122
4130
  );
4123
- n.push(...p);
4131
+ s.push(...p);
4124
4132
  }
4125
- return n;
4133
+ return s;
4126
4134
  },
4127
- ({ nameStack: e, owner: s }) => `${e.join(".")}@${s.id}`
4135
+ ({ nameStack: e, owner: n }) => `${e.join(".")}@${n.id}`
4128
4136
  ),
4129
4137
  members: this.createQuery(
4130
4138
  9,
4131
- (e) => e.symbolTable ? [...e.symbolTable.entries()].map(([s, n]) => ({
4132
- ...se(s).unwrap(),
4133
- symbol: n
4139
+ (e) => e.symbolTable ? [...e.symbolTable.entries()].map(([n, s]) => ({
4140
+ ...se(n).unwrap(),
4141
+ symbol: s
4134
4142
  })) : []
4135
4143
  )
4136
4144
  };
4137
4145
  }
4138
- createQuery(e, s, n) {
4146
+ createQuery(e, n, s) {
4139
4147
  return (i) => {
4140
- const r = this.cache[e], a = i && n ? n(i) : i;
4148
+ const r = this.cache[e], a = i && s ? s(i) : i;
4141
4149
  if (r !== null) {
4142
4150
  if (!(r instanceof Map))
4143
4151
  return r;
4144
4152
  if (r.has(a))
4145
4153
  return r.get(a);
4146
4154
  }
4147
- const l = s(i);
4155
+ const l = n(i);
4148
4156
  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;
4149
4157
  };
4150
4158
  }