@dbml/parse 3.9.6 → 3.9.7-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +0 -0
  2. package/dist/compiler.d.ts +0 -0
  3. package/dist/constants.d.ts +0 -0
  4. package/dist/dbml-parse.js +7 -7
  5. package/dist/dbml-parse.mjs +234 -210
  6. package/dist/index.d.ts +0 -0
  7. package/dist/lib/analyzer/analyzer.d.ts +0 -0
  8. package/dist/lib/analyzer/binder/binder.d.ts +0 -0
  9. package/dist/lib/analyzer/binder/elementBinder/custom.d.ts +0 -0
  10. package/dist/lib/analyzer/binder/elementBinder/elementBinder.d.ts +0 -0
  11. package/dist/lib/analyzer/binder/elementBinder/enum.d.ts +0 -0
  12. package/dist/lib/analyzer/binder/elementBinder/indexes.d.ts +0 -0
  13. package/dist/lib/analyzer/binder/elementBinder/note.d.ts +0 -0
  14. package/dist/lib/analyzer/binder/elementBinder/project.d.ts +0 -0
  15. package/dist/lib/analyzer/binder/elementBinder/ref.d.ts +0 -0
  16. package/dist/lib/analyzer/binder/elementBinder/table.d.ts +0 -0
  17. package/dist/lib/analyzer/binder/elementBinder/tableGroup.d.ts +0 -0
  18. package/dist/lib/analyzer/binder/types.d.ts +0 -0
  19. package/dist/lib/analyzer/binder/utils.d.ts +0 -0
  20. package/dist/lib/analyzer/symbol/factory.d.ts +0 -0
  21. package/dist/lib/analyzer/symbol/symbolIndex.d.ts +0 -0
  22. package/dist/lib/analyzer/symbol/symbolTable.d.ts +0 -0
  23. package/dist/lib/analyzer/symbol/symbols.d.ts +0 -0
  24. package/dist/lib/analyzer/symbol/utils.d.ts +0 -0
  25. package/dist/lib/analyzer/types.d.ts +0 -0
  26. package/dist/lib/analyzer/utils.d.ts +0 -0
  27. package/dist/lib/analyzer/validator/elementValidators/custom.d.ts +0 -0
  28. package/dist/lib/analyzer/validator/elementValidators/enum.d.ts +0 -0
  29. package/dist/lib/analyzer/validator/elementValidators/indexes.d.ts +0 -0
  30. package/dist/lib/analyzer/validator/elementValidators/note.d.ts +0 -0
  31. package/dist/lib/analyzer/validator/elementValidators/project.d.ts +0 -0
  32. package/dist/lib/analyzer/validator/elementValidators/ref.d.ts +0 -0
  33. package/dist/lib/analyzer/validator/elementValidators/table.d.ts +0 -0
  34. package/dist/lib/analyzer/validator/elementValidators/tableGroup.d.ts +0 -0
  35. package/dist/lib/analyzer/validator/types.d.ts +0 -0
  36. package/dist/lib/analyzer/validator/utils.d.ts +0 -0
  37. package/dist/lib/analyzer/validator/validator.d.ts +0 -0
  38. package/dist/lib/errors.d.ts +0 -0
  39. package/dist/lib/interpreter/elementInterpreter/enum.d.ts +0 -0
  40. package/dist/lib/interpreter/elementInterpreter/project.d.ts +0 -0
  41. package/dist/lib/interpreter/elementInterpreter/ref.d.ts +1 -0
  42. package/dist/lib/interpreter/elementInterpreter/sticky_note.d.ts +0 -0
  43. package/dist/lib/interpreter/elementInterpreter/table.d.ts +0 -0
  44. package/dist/lib/interpreter/elementInterpreter/tableGroup.d.ts +0 -0
  45. package/dist/lib/interpreter/interpreter.d.ts +0 -0
  46. package/dist/lib/interpreter/types.d.ts +1 -0
  47. package/dist/lib/interpreter/utils.d.ts +0 -0
  48. package/dist/lib/lexer/lexer.d.ts +0 -0
  49. package/dist/lib/lexer/tokens.d.ts +0 -0
  50. package/dist/lib/lexer/utils.d.ts +0 -0
  51. package/dist/lib/option.d.ts +0 -0
  52. package/dist/lib/parser/contextStack.d.ts +0 -0
  53. package/dist/lib/parser/factory.d.ts +0 -0
  54. package/dist/lib/parser/nodes.d.ts +0 -0
  55. package/dist/lib/parser/parser.d.ts +0 -0
  56. package/dist/lib/parser/utils.d.ts +0 -0
  57. package/dist/lib/report.d.ts +0 -0
  58. package/dist/lib/serialization/serialize.d.ts +0 -0
  59. package/dist/lib/types.d.ts +0 -0
  60. package/dist/lib/utils.d.ts +0 -0
  61. package/dist/services/definition/provider.d.ts +0 -0
  62. package/dist/services/index.d.ts +0 -0
  63. package/dist/services/references/provider.d.ts +0 -0
  64. package/dist/services/suggestions/provider.d.ts +0 -0
  65. package/dist/services/suggestions/utils.d.ts +0 -0
  66. package/dist/services/types.d.ts +0 -0
  67. package/dist/services/utils.d.ts +0 -0
  68. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import I, { last as Ce, partition as zt, findLastIndex as Qt } from "lodash";
1
+ import I, { last as Xe, partition as zt, findLastIndex as Qt } from "lodash";
2
2
  var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
3
3
  function qt(t) {
4
4
  switch (t.kind) {
@@ -12,7 +12,7 @@ function qt(t) {
12
12
  return !1;
13
13
  }
14
14
  }
15
- function at(t) {
15
+ function ot(t) {
16
16
  if (!t)
17
17
  return !1;
18
18
  switch (t) {
@@ -33,31 +33,31 @@ function at(t) {
33
33
  return !1;
34
34
  }
35
35
  }
36
- function ot(t) {
36
+ function lt(t) {
37
37
  return t !== void 0 && t.kind === "<op>";
38
38
  }
39
- class B {
39
+ class V {
40
40
  constructor(e, n, s, i, r) {
41
41
  this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
42
42
  }
43
43
  static create(e, n, s, i, r) {
44
- return new B(e, n, s, i, r);
44
+ return new V(e, n, s, i, r);
45
45
  }
46
46
  }
47
- function It(t) {
47
+ function Lt(t) {
48
48
  return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
49
49
  }
50
- function lt(t, e) {
51
- return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || It(t);
50
+ function ct(t, e) {
51
+ return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || Lt(t);
52
52
  }
53
- function Xe(t) {
53
+ function $e(t) {
54
54
  return t.trailingTrivia.find(({ kind: e }) => [u.SPACE, u.TAB].includes(e)) !== void 0;
55
55
  }
56
- function Lt(t) {
57
- return t.trailingTrivia.length === 0 ? t.end : Lt(Ce(t.trailingTrivia));
58
- }
59
56
  function gt(t) {
60
- return t.leadingTrivia.length === 0 ? t.start : gt(t.leadingTrivia[0]);
57
+ return t.trailingTrivia.length === 0 ? t.end : gt(Xe(t.trailingTrivia));
58
+ }
59
+ function _t(t) {
60
+ return t.leadingTrivia.length === 0 ? t.start : _t(t.leadingTrivia[0]);
61
61
  }
62
62
  function Ht(t) {
63
63
  return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
@@ -81,13 +81,13 @@ class k {
81
81
  constructor(e, n, s) {
82
82
  this.id = e, this.kind = n;
83
83
  const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
84
- i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? gt(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof V ? _t(i) : i.fullStart) : (this.startPos = {
85
85
  offset: NaN,
86
86
  column: NaN,
87
87
  line: NaN
88
88
  }, this.fullStart = NaN);
89
89
  const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
90
- r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? Lt(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof V ? gt(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
@@ -184,7 +184,7 @@ class P extends k {
184
184
  }, r) {
185
185
  super(r, "<list-expression>", [
186
186
  e,
187
- ..._t(n, s),
187
+ ...At(n, s),
188
188
  i
189
189
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
@@ -198,12 +198,12 @@ class K extends k {
198
198
  }, r) {
199
199
  super(r, "<tuple-expression>", [
200
200
  e,
201
- ..._t(n, s),
201
+ ...At(n, s),
202
202
  i
203
203
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
204
204
  }
205
205
  }
206
- class je extends K {
206
+ class Ye extends K {
207
207
  constructor({
208
208
  groupOpenParen: e,
209
209
  expression: n,
@@ -238,14 +238,14 @@ class ee extends k {
238
238
  super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
- class M extends k {
241
+ class F extends k {
242
242
  constructor({ expression: e }, n) {
243
243
  super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
246
  class xe extends k {
247
247
  constructor({ pre: e }, n) {
248
- const s = B.create(u.SPACE, e.endPos, e.endPos, " ", !1);
248
+ const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
249
249
  super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
@@ -254,7 +254,7 @@ class he extends k {
254
254
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
256
256
  }
257
- function _t(t, e) {
257
+ function At(t, e) {
258
258
  if (!t || t.length === 0)
259
259
  return e || [];
260
260
  if (!e || e.length === 0)
@@ -335,46 +335,46 @@ class y {
335
335
  }
336
336
  }
337
337
  var T = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t))(T || {});
338
- function Ye(t) {
338
+ function ze(t) {
339
339
  return `Schema:${t}`;
340
340
  }
341
341
  function Oe(t) {
342
342
  return `Table:${t}`;
343
343
  }
344
- function ze(t) {
344
+ function Qe(t) {
345
345
  return `Column:${t}`;
346
346
  }
347
- function Qe(t) {
347
+ function qe(t) {
348
348
  return `Enum:${t}`;
349
349
  }
350
- function qe(t) {
350
+ function He(t) {
351
351
  return `Enum field:${t}`;
352
352
  }
353
- function He(t) {
353
+ function Je(t) {
354
354
  return `TableGroup:${t}`;
355
355
  }
356
- function Je(t) {
356
+ function Ze(t) {
357
357
  return `TableGroup field:${t}`;
358
358
  }
359
359
  function Zt(t) {
360
360
  return `Note:${t}`;
361
361
  }
362
- function Ve(t, e) {
362
+ function Ge(t, e) {
363
363
  switch (e) {
364
364
  case "Column":
365
- return ze(t);
366
- case "Enum":
367
365
  return Qe(t);
368
- case "Enum field":
366
+ case "Enum":
369
367
  return qe(t);
368
+ case "Enum field":
369
+ return He(t);
370
370
  case "Schema":
371
- return Ye(t);
371
+ return ze(t);
372
372
  case "Table":
373
373
  return Oe(t);
374
374
  case "TableGroup":
375
- return He(t);
376
- case "TableGroup field":
377
375
  return Je(t);
376
+ case "TableGroup field":
377
+ return Ze(t);
378
378
  default:
379
379
  throw new Error("Unreachable");
380
380
  }
@@ -395,13 +395,13 @@ function Kt(t) {
395
395
  }
396
396
  function en(t) {
397
397
  return [
398
- Ye,
398
+ ze,
399
399
  Oe,
400
+ qe,
401
+ Je,
400
402
  Qe,
401
403
  He,
402
- ze,
403
- qe,
404
- Je
404
+ Ze
405
405
  ].map((e) => e(t));
406
406
  }
407
407
  function Me(t) {
@@ -418,7 +418,7 @@ function tn(t) {
418
418
  function Ee(t) {
419
419
  return Me(t) || De(t);
420
420
  }
421
- function ct(t, e) {
421
+ function ut(t, e) {
422
422
  const n = [], s = Math.min(t.length, e.length);
423
423
  for (let i = 0; i < s; i += 1)
424
424
  n.push(t[i], e[i]);
@@ -438,7 +438,7 @@ class nn {
438
438
  return this.id++;
439
439
  }
440
440
  }
441
- class At {
441
+ class vt {
442
442
  constructor({ symbolTable: e }, n) {
443
443
  this.references = [], this.id = n, this.symbolTable = e;
444
444
  }
@@ -453,7 +453,7 @@ class rn {
453
453
  this.references = [], this.id = n, this.declaration = e;
454
454
  }
455
455
  }
456
- class vt {
456
+ class wt {
457
457
  constructor({ symbolTable: e, declaration: n }, s) {
458
458
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
459
459
  }
@@ -500,15 +500,15 @@ class G {
500
500
  function cn(t, e, n) {
501
501
  if (!t || !me(t) || e.length === 0)
502
502
  return new y();
503
- const s = [...e], i = Ge(t).unwrap(), r = s.pop();
503
+ const s = [...e], i = Ce(t).unwrap(), r = s.pop();
504
504
  if (!(r instanceof Z))
505
505
  return new y();
506
506
  const a = I.last(s) instanceof P ? s.pop() : void 0;
507
- return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new x(
507
+ return s.length === 3 && Ce(s[1]).unwrap().value === "as" ? new x(
508
508
  n.create(A, {
509
509
  type: i,
510
510
  name: s[0],
511
- as: Ge(s[1]).unwrap(),
511
+ as: Ce(s[1]).unwrap(),
512
512
  alias: s[2],
513
513
  attributeList: a,
514
514
  body: r
@@ -528,11 +528,11 @@ function cn(t, e, n) {
528
528
  })
529
529
  ) : new y();
530
530
  }
531
- function ut(t) {
531
+ function ht(t) {
532
532
  return t.kind === u.IDENTIFIER && t.value === "as";
533
533
  }
534
534
  function N(t) {
535
- t && (t instanceof B ? un(t) : hn(t));
535
+ t && (t instanceof V ? un(t) : hn(t));
536
536
  }
537
537
  function un(t) {
538
538
  t.kind !== u.EOF && (t.isInvalid = !0);
@@ -560,7 +560,7 @@ function hn(t) {
560
560
  N(t.callee), N(t.argumentList);
561
561
  else if (t instanceof v)
562
562
  N(t.callee), t.args.forEach(N);
563
- else if (t instanceof M)
563
+ else if (t instanceof F)
564
564
  N(t.expression);
565
565
  else if (t instanceof se)
566
566
  N(t.value);
@@ -569,9 +569,9 @@ function hn(t) {
569
569
  else if (t instanceof be)
570
570
  N(t.literal);
571
571
  else
572
- throw t instanceof je ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
572
+ throw t instanceof Ye ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
573
573
  }
574
- function wt(t) {
574
+ function yt(t) {
575
575
  return !!(t != null && t.isInvalid);
576
576
  }
577
577
  function U(...t) {
@@ -613,41 +613,41 @@ function fn(t) {
613
613
  if (t instanceof P)
614
614
  return U(
615
615
  t.listOpenBracket,
616
- ...ct(t.elementList, t.commaList),
616
+ ...ut(t.elementList, t.commaList),
617
617
  t.listCloseBracket
618
618
  );
619
619
  if (t instanceof K)
620
620
  return U(
621
621
  t.tupleOpenParen,
622
- ...ct(t.elementList, t.commaList),
622
+ ...ut(t.elementList, t.commaList),
623
623
  t.tupleCloseParen
624
624
  );
625
625
  if (t instanceof J)
626
626
  return U(t.callee, t.argumentList);
627
- if (t instanceof M)
627
+ if (t instanceof F)
628
628
  return U(t.expression);
629
629
  if (t instanceof he)
630
630
  return U(
631
631
  t.array,
632
632
  t.indexer
633
633
  );
634
- throw t instanceof je ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
634
+ throw t instanceof Ye ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
635
635
  }
636
- function Ge(t) {
637
- return F(t) ? new x(t.expression.variable) : new y();
636
+ function Ce(t) {
637
+ return B(t) ? new x(t.expression.variable) : new y();
638
638
  }
639
639
  function W(t) {
640
640
  var e;
641
- return t instanceof M && (t.expression instanceof ee && t.expression.variable instanceof B && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
641
+ return t instanceof F && (t.expression instanceof ee && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
642
642
  }
643
- function F(t) {
644
- return t instanceof M && t.expression instanceof ee && t.expression.variable instanceof B;
643
+ function B(t) {
644
+ return t instanceof F && t.expression instanceof ee && t.expression.variable instanceof V;
645
645
  }
646
646
  function me(t) {
647
647
  var e;
648
- return t instanceof M && t.expression instanceof ee && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
648
+ return t instanceof F && t.expression instanceof ee && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
649
649
  }
650
- function Ze(t) {
650
+ function Ke(t) {
651
651
  var e;
652
652
  return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
653
653
  }
@@ -697,7 +697,7 @@ class pn {
697
697
  this.tokens.push(this.createToken(e, n));
698
698
  }
699
699
  createToken(e, n = !1) {
700
- return B.create(
700
+ return V.create(
701
701
  e,
702
702
  this.start,
703
703
  this.current,
@@ -706,7 +706,7 @@ class pn {
706
706
  );
707
707
  }
708
708
  lex() {
709
- return this.scanTokens(), this.tokens.push(B.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new G(this.tokens, this.errors);
709
+ return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new G(this.tokens, this.errors);
710
710
  }
711
711
  scanTokens() {
712
712
  for (; !this.isAtEnd(); ) {
@@ -767,7 +767,7 @@ class pn {
767
767
  this.match("/") ? this.singleLineComment() : this.match("*") ? this.multilineComment() : this.operator();
768
768
  break;
769
769
  default:
770
- if (at(e)) {
770
+ if (ot(e)) {
771
771
  this.operator();
772
772
  break;
773
773
  }
@@ -801,7 +801,7 @@ class pn {
801
801
  gatherInvalid() {
802
802
  let e;
803
803
  const n = [], s = [];
804
- for (e = 0; e < this.tokens.length && wt(this.tokens[e]); e += 1)
804
+ for (e = 0; e < this.tokens.length && yt(this.tokens[e]); e += 1)
805
805
  s.push(this.tokens[e]);
806
806
  let i = this.tokens[e];
807
807
  for (i.leadingInvalid = [...s, ...i.leadingInvalid]; e < this.tokens.length; e += 1) {
@@ -843,7 +843,7 @@ class pn {
843
843
  );
844
844
  return;
845
845
  }
846
- a && this.match(n), this.tokens.push(B.create(e, this.start, this.current, l, !1));
846
+ a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, l, !1));
847
847
  }
848
848
  singleLineStringLiteral() {
849
849
  this.consumeUntil(u.STRING_LITERAL, "'", {
@@ -895,7 +895,7 @@ class pn {
895
895
  this.addToken(u.IDENTIFIER);
896
896
  }
897
897
  operator() {
898
- for (; at(this.peek()); )
898
+ for (; ot(this.peek()); )
899
899
  this.advance();
900
900
  this.addToken(u.OP);
901
901
  }
@@ -971,7 +971,7 @@ class pn {
971
971
  let n = "";
972
972
  for (let s = 0; s <= 3; s += 1) {
973
973
  if (this.isAtEnd() || !Ee(this.peek()))
974
- return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, B.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
974
+ return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid unicode escape sequence '\\u${n}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`, V.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
975
975
  n += this.advance();
976
976
  }
977
977
  return String.fromCharCode(parseInt(n, 16));
@@ -1069,7 +1069,7 @@ class Nn {
1069
1069
  }, this.synchronizeElementDeclarationName = () => {
1070
1070
  for (; !this.isAtEnd(); ) {
1071
1071
  const s = this.peek();
1072
- if (ut(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1072
+ if (ht(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1073
1073
  break;
1074
1074
  N(s), this.advance();
1075
1075
  }
@@ -1115,12 +1115,12 @@ class Nn {
1115
1115
  if (!this.check(u.RBRACE))
1116
1116
  for (N(this.advance()); !this.isAtEnd(); ) {
1117
1117
  const s = this.peek();
1118
- if (this.check(u.RBRACE) || lt(this.previous(), s))
1118
+ if (this.check(u.RBRACE) || ct(this.previous(), s))
1119
1119
  break;
1120
1120
  N(s), this.advance();
1121
1121
  }
1122
1122
  }, this.tupleExpression = this.contextStack.withContextDo(Se.GroupExpression, () => {
1123
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(je, {
1123
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(Ye, {
1124
1124
  groupOpenParen: s.tupleOpenParen,
1125
1125
  groupCloseParen: s.tupleCloseParen,
1126
1126
  expression: s.elementList[0]
@@ -1324,7 +1324,7 @@ class Nn {
1324
1324
  throw new d(s.token, n(), s.handlerContext);
1325
1325
  this.synchronizeElementDeclarationName();
1326
1326
  }
1327
- if (ut(this.peek()))
1327
+ if (ht(this.peek()))
1328
1328
  if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
1329
1329
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1330
1330
  else
@@ -1400,7 +1400,7 @@ class Nn {
1400
1400
  return n();
1401
1401
  let s = e.callee;
1402
1402
  for (; !this.shouldStopExpression(); ) {
1403
- Xe(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1403
+ $e(this.previous()) || this.logError(s, o.MISSING_SPACES, "Expect a following space");
1404
1404
  try {
1405
1405
  s = this.normalExpression(), e.args.push(s);
1406
1406
  } catch (i) {
@@ -1410,7 +1410,7 @@ class Nn {
1410
1410
  return n();
1411
1411
  }
1412
1412
  shouldStopExpression() {
1413
- if (this.isAtEnd() || It(this.previous()))
1413
+ if (this.isAtEnd() || Lt(this.previous()))
1414
1414
  return !0;
1415
1415
  const e = this.peek().kind;
1416
1416
  return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
@@ -1424,12 +1424,12 @@ class Nn {
1424
1424
  for (; !this.isAtEnd(); ) {
1425
1425
  const s = this.peek();
1426
1426
  if (s.kind === u.LPAREN) {
1427
- const { left: i } = ht(s);
1427
+ const { left: i } = ft(s);
1428
1428
  if (i < e || // When '(' is encountered,
1429
1429
  // consider it part of another expression if
1430
1430
  // it's at the start of a new line
1431
1431
  // and we're currently not having unmatched '(' or '['
1432
- lt(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1432
+ ct(this.previous(), s) && !this.contextStack.isWithinGroupExpressionContext() && !this.contextStack.isWithinListExpressionContext())
1433
1433
  break;
1434
1434
  try {
1435
1435
  n = this.nodeFactory.create(J, {
@@ -1443,7 +1443,7 @@ class Nn {
1443
1443
  }), new d(r.token, n, r.handlerContext)) : r;
1444
1444
  }
1445
1445
  } else if (s.kind === u.LBRACKET) {
1446
- if (Xe(this.previous()))
1446
+ if ($e(this.previous()))
1447
1447
  break;
1448
1448
  try {
1449
1449
  n = this.nodeFactory.create(he, {
@@ -1456,8 +1456,8 @@ class Nn {
1456
1456
  indexer: i.partialNode
1457
1457
  }), new d(i.token, n, i.handlerContext)) : i;
1458
1458
  }
1459
- } else if (ot(s)) {
1460
- const i = s, r = ht(i);
1459
+ } else if (lt(s)) {
1460
+ const i = s, r = ft(i);
1461
1461
  if (r.left !== null) {
1462
1462
  if (r.left <= e)
1463
1463
  break;
@@ -1491,7 +1491,7 @@ class Nn {
1491
1491
  }
1492
1492
  leftExpression_bp() {
1493
1493
  let e;
1494
- if (ot(this.peek())) {
1494
+ if (lt(this.peek())) {
1495
1495
  const n = {};
1496
1496
  n.op = this.peek();
1497
1497
  const s = In(n.op);
@@ -1569,11 +1569,11 @@ class Nn {
1569
1569
  u.STRING_LITERAL,
1570
1570
  u.NUMERIC_LITERAL
1571
1571
  ))
1572
- return this.nodeFactory.create(M, {
1572
+ return this.nodeFactory.create(F, {
1573
1573
  expression: this.nodeFactory.create(be, { literal: this.previous() })
1574
1574
  });
1575
1575
  if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1576
- return this.nodeFactory.create(M, {
1576
+ return this.nodeFactory.create(F, {
1577
1577
  expression: this.nodeFactory.create(ee, { variable: this.previous() })
1578
1578
  });
1579
1579
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
@@ -1671,7 +1671,7 @@ function In(t) {
1671
1671
  const Ln = {
1672
1672
  "(": { left: 14, right: null }
1673
1673
  };
1674
- function ht(t) {
1674
+ function ft(t) {
1675
1675
  return Ln[t.value] || { left: null, right: null };
1676
1676
  }
1677
1677
  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 || {});
@@ -1692,7 +1692,7 @@ function ve(t) {
1692
1692
  }
1693
1693
  }
1694
1694
  function pe(t) {
1695
- if (!Ze(t))
1695
+ if (!Ke(t))
1696
1696
  return new x([t]);
1697
1697
  const e = pe(t.leftExpression).unwrap_or(void 0);
1698
1698
  return e ? (e.push(t.rightExpression), new x(e)) : new y();
@@ -1720,7 +1720,7 @@ function _e(t) {
1720
1720
  return new y();
1721
1721
  const n = [];
1722
1722
  let s;
1723
- if (!F(I.last(e))) {
1723
+ if (!B(I.last(e))) {
1724
1724
  const i = e.pop();
1725
1725
  if (Ot(i))
1726
1726
  s = i.elementList.map(
@@ -1741,15 +1741,15 @@ function _e(t) {
1741
1741
  });
1742
1742
  }
1743
1743
  function Y(t) {
1744
- return F(t) ? new x(t.expression.variable.value) : new y();
1744
+ return B(t) ? new x(t.expression.variable.value) : new y();
1745
1745
  }
1746
- function $e(t) {
1747
- if (ft(t))
1746
+ function We(t) {
1747
+ if (pt(t))
1748
1748
  return t instanceof se ? new x({ functional: [t], nonFunctional: [] }) : new x({ functional: [], nonFunctional: [t] });
1749
- if (t instanceof K && t.elementList.every(ft)) {
1749
+ if (t instanceof K && t.elementList.every(pt)) {
1750
1750
  const e = t.elementList.filter(
1751
1751
  (s) => s instanceof se
1752
- ), n = t.elementList.filter(F);
1752
+ ), n = t.elementList.filter(B);
1753
1753
  return new x({ functional: e, nonFunctional: n });
1754
1754
  }
1755
1755
  return new y();
@@ -1764,7 +1764,7 @@ function C(t) {
1764
1764
  }
1765
1765
  function gn(t) {
1766
1766
  var e;
1767
- return !(t instanceof H) || !xt((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
1767
+ return !(t instanceof H) || !St((e = t.op) == null ? void 0 : e.value) ? !1 : _e(t.leftExpression).and_then(() => _e(t.rightExpression)).unwrap_or(void 0) !== void 0;
1768
1768
  }
1769
1769
  function _n(t) {
1770
1770
  const e = _e(t.leftExpression), n = _e(t.rightExpression);
@@ -1773,8 +1773,8 @@ function _n(t) {
1773
1773
  const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1774
1774
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1775
1775
  }
1776
- function ft(t) {
1777
- return t instanceof M && t.expression instanceof ee || t instanceof se;
1776
+ function pt(t) {
1777
+ return t instanceof F && t.expression instanceof ee || t instanceof se;
1778
1778
  }
1779
1779
  function An(t, e) {
1780
1780
  var i, r, a, l;
@@ -1846,7 +1846,7 @@ class wn {
1846
1846
  return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1847
1847
  }
1848
1848
  validateName(e) {
1849
- return e ? kt(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1849
+ return e ? xt(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1850
1850
  }
1851
1851
  validateAlias(e) {
1852
1852
  return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
@@ -1856,7 +1856,7 @@ class wn {
1856
1856
  this.declarationNode.symbol = this.symbolFactory.create(sn, { declaration: this.declarationNode, symbolTable: new we() });
1857
1857
  const { name: n } = this.declarationNode, s = j(n);
1858
1858
  if (s.isOk()) {
1859
- const i = s.unwrap(), r = i.pop(), a = Ke(i, this.publicSymbolTable, this.symbolFactory), l = Qe(r);
1859
+ const i = s.unwrap(), r = i.pop(), a = et(i, this.publicSymbolTable, this.symbolFactory), l = qe(r);
1860
1860
  a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1861
1861
  }
1862
1862
  return e;
@@ -1875,13 +1875,13 @@ class wn {
1875
1875
  validateFields(e) {
1876
1876
  return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1877
1877
  const s = [];
1878
- n.callee && !F(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1878
+ n.callee && !B(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1879
1879
  const i = [...n.args];
1880
1880
  return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1881
1881
  });
1882
1882
  }
1883
1883
  validateFieldSettings(e) {
1884
- const n = V(e), s = n.getErrors(), i = n.getValue();
1884
+ const n = M(e), s = n.getErrors(), i = n.getValue();
1885
1885
  for (const r in i) {
1886
1886
  const a = i[r];
1887
1887
  switch (r) {
@@ -1905,8 +1905,8 @@ class wn {
1905
1905
  });
1906
1906
  }
1907
1907
  registerField(e) {
1908
- if (e.callee && F(e.callee)) {
1909
- const n = X(e.callee).unwrap(), s = qe(n), i = this.symbolFactory.create(rn, { declaration: e });
1908
+ if (e.callee && B(e.callee)) {
1909
+ const n = X(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(rn, { declaration: e });
1910
1910
  e.symbol = i;
1911
1911
  const r = this.declarationNode.symbol.symbolTable;
1912
1912
  if (r.has(s)) {
@@ -1955,13 +1955,13 @@ class yn {
1955
1955
  const s = [], i = [n.callee, ...n.args];
1956
1956
  return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1957
1957
  for (; r instanceof J; )
1958
- r.argumentList && !$e(r.argumentList).isOk() && s.push(new c(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;
1959
- $e(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1958
+ r.argumentList && !We(r.argumentList).isOk() && s.push(new c(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;
1959
+ We(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1960
1960
  }), s;
1961
1961
  });
1962
1962
  }
1963
1963
  validateFieldSetting(e) {
1964
- const n = V(e), s = n.getErrors(), i = n.getValue();
1964
+ const n = M(e), s = n.getErrors(), i = n.getValue();
1965
1965
  for (const r in i) {
1966
1966
  const a = i[r];
1967
1967
  switch (r) {
@@ -1979,7 +1979,7 @@ class yn {
1979
1979
  break;
1980
1980
  case "type":
1981
1981
  a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1982
- F(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1982
+ B(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1983
1983
  });
1984
1984
  break;
1985
1985
  default:
@@ -2115,7 +2115,22 @@ class Sn {
2115
2115
  return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2116
2116
  }
2117
2117
  validateSettingList(e) {
2118
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2118
+ if (!e)
2119
+ return [];
2120
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2121
+ for (const r in i) {
2122
+ const a = i[r];
2123
+ switch (r) {
2124
+ case "color":
2125
+ a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_REF_SETTING, "'color' can only appear once", l))), a.forEach((l) => {
2126
+ tt(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'color' must be a color literal", l.value || l.name));
2127
+ });
2128
+ break;
2129
+ default:
2130
+ s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2131
+ }
2132
+ }
2133
+ return s;
2119
2134
  }
2120
2135
  validateBody(e) {
2121
2136
  if (!e)
@@ -2136,7 +2151,7 @@ class Sn {
2136
2151
  }), n;
2137
2152
  }
2138
2153
  validateFieldSettings(e) {
2139
- const n = V(e), s = n.getErrors(), i = n.getValue();
2154
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2140
2155
  for (const r in i) {
2141
2156
  const a = i[r];
2142
2157
  switch (r) {
@@ -2162,7 +2177,7 @@ class Sn {
2162
2177
  }
2163
2178
  }
2164
2179
  function On(t) {
2165
- if (!(F(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof z))
2180
+ if (!(B(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof z))
2166
2181
  return !1;
2167
2182
  let e;
2168
2183
  if (t instanceof z ? e = Te(t).unwrap_or("") : e = t.expression.variable.value, e)
@@ -2189,19 +2204,19 @@ class Dn {
2189
2204
  return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2190
2205
  }
2191
2206
  validateName(e) {
2192
- return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : kt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2207
+ return e ? e instanceof he ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : xt(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2193
2208
  }
2194
2209
  validateAlias(e) {
2195
2210
  return e ? Mn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2196
2211
  }
2197
2212
  validateSettingList(e) {
2198
- const n = V(e), s = n.getErrors(), i = n.getValue();
2213
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2199
2214
  for (const r in i) {
2200
2215
  const a = i[r];
2201
2216
  switch (r) {
2202
2217
  case "headercolor":
2203
2218
  a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2204
- St(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2219
+ tt(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2205
2220
  });
2206
2221
  break;
2207
2222
  case "note":
@@ -2217,10 +2232,10 @@ class Dn {
2217
2232
  }
2218
2233
  registerElement() {
2219
2234
  const e = [];
2220
- this.declarationNode.symbol = this.symbolFactory.create(vt, { declaration: this.declarationNode, symbolTable: new we() });
2235
+ this.declarationNode.symbol = this.symbolFactory.create(wt, { declaration: this.declarationNode, symbolTable: new we() });
2221
2236
  const { name: n, alias: s } = this.declarationNode, i = j(n);
2222
2237
  if (i.isOk()) {
2223
- const r = [...i.unwrap()], a = r.pop(), l = Ke(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2238
+ const r = [...i.unwrap()], a = r.pop(), l = et(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2224
2239
  l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2225
2240
  }
2226
2241
  if (s && ye(s) && !Pn(s.expression.variable.value, i.unwrap_or([]))) {
@@ -2242,14 +2257,14 @@ class Dn {
2242
2257
  if (!n.callee)
2243
2258
  return [];
2244
2259
  const s = [];
2245
- n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), F(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Rn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2260
+ n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), B(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !Rn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2246
2261
  const i = n.args.slice(1);
2247
2262
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2248
2263
  });
2249
2264
  }
2250
2265
  registerField(e) {
2251
- if (e.callee && F(e.callee)) {
2252
- const n = X(e.callee).unwrap(), s = ze(n), i = this.symbolFactory.create(an, { declaration: e });
2266
+ if (e.callee && B(e.callee)) {
2267
+ const n = X(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(an, { declaration: e });
2253
2268
  e.symbol = i;
2254
2269
  const r = this.declarationNode.symbol.symbolTable;
2255
2270
  if (r.has(s)) {
@@ -2271,7 +2286,7 @@ class Dn {
2271
2286
  return [];
2272
2287
  let n;
2273
2288
  I.last(e) instanceof P && (n = e.pop());
2274
- const s = V(n), i = s.getErrors(), r = s.getValue();
2289
+ const s = M(n), i = s.getErrors(), r = s.getValue();
2275
2290
  for (const p of e) {
2276
2291
  const f = X(p).unwrap_or("").toLowerCase();
2277
2292
  if (f !== "pk" && f !== "unique") {
@@ -2352,7 +2367,7 @@ class Dn {
2352
2367
  }
2353
2368
  }
2354
2369
  function Rn(t) {
2355
- if (!(t instanceof J || Ze(t) || t instanceof M || t instanceof he))
2370
+ if (!(t instanceof J || Ke(t) || t instanceof F || t instanceof he))
2356
2371
  return !1;
2357
2372
  if (t instanceof J) {
2358
2373
  if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => fe(n) || W(n) || me(n)))
@@ -2414,7 +2429,7 @@ class Un {
2414
2429
  this.declarationNode.symbol = this.symbolFactory.create(on, { declaration: this.declarationNode, symbolTable: new we() });
2415
2430
  const n = j(e);
2416
2431
  if (n.isOk()) {
2417
- const s = n.unwrap(), i = s.pop(), r = Ke(s, this.publicSymbolTable, this.symbolFactory), a = He(i);
2432
+ const s = n.unwrap(), i = s.pop(), r = et(s, this.publicSymbolTable, this.symbolFactory), a = Je(i);
2418
2433
  if (r.has(a))
2419
2434
  return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
2420
2435
  r.set(a, this.declarationNode.symbol);
@@ -2422,7 +2437,7 @@ class Un {
2422
2437
  return [];
2423
2438
  }
2424
2439
  validateSettingList(e) {
2425
- const n = V(e), s = n.getErrors(), i = n.getValue();
2440
+ const n = M(e), s = n.getErrors(), i = n.getValue();
2426
2441
  return I.forIn(i, (r, a) => {
2427
2442
  switch (a) {
2428
2443
  case "color":
@@ -2431,7 +2446,7 @@ class Un {
2431
2446
  "'color' can only appear once",
2432
2447
  l
2433
2448
  ))), r.forEach((l) => {
2434
- St(l.value) || s.push(new c(
2449
+ tt(l.value) || s.push(new c(
2435
2450
  o.INVALID_TABLE_SETTING,
2436
2451
  "'color' must be a color literal",
2437
2452
  l.value || l.name
@@ -2495,8 +2510,8 @@ class Un {
2495
2510
  return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2496
2511
  }
2497
2512
  registerField(e) {
2498
- if (e.callee && F(e.callee)) {
2499
- const n = X(e.callee).unwrap(), s = Je(n), i = this.symbolFactory.create(ln, { declaration: e });
2513
+ if (e.callee && B(e.callee)) {
2514
+ const n = X(e.callee).unwrap(), s = Ze(n), i = this.symbolFactory.create(ln, { declaration: e });
2500
2515
  e.symbol = i;
2501
2516
  const r = this.declarationNode.symbol.symbolTable;
2502
2517
  if (r.has(s)) {
@@ -2511,7 +2526,7 @@ class Un {
2511
2526
  return [];
2512
2527
  }
2513
2528
  }
2514
- const yt = ["-", "+"];
2529
+ const kt = ["-", "+"];
2515
2530
  function oe(t) {
2516
2531
  switch (t.type.value.toLowerCase()) {
2517
2532
  case b.Enum:
@@ -2532,40 +2547,40 @@ function oe(t) {
2532
2547
  return vn;
2533
2548
  }
2534
2549
  }
2535
- function kt(t) {
2550
+ function xt(t) {
2536
2551
  return !!j(t).unwrap_or(!1);
2537
2552
  }
2538
2553
  function Mn(t) {
2539
2554
  return ye(t);
2540
2555
  }
2541
2556
  function ye(t) {
2542
- return t instanceof M && t.expression instanceof ee;
2557
+ return t instanceof F && t.expression instanceof ee;
2543
2558
  }
2544
- function Ke(t, e, n) {
2559
+ function et(t, e, n) {
2545
2560
  var i;
2546
2561
  t[0] === "public" && (t = t.slice(1));
2547
2562
  let s = e;
2548
2563
  for (const r of t) {
2549
2564
  let a;
2550
- const l = Ye(r);
2565
+ const l = ze(r);
2551
2566
  if (s.has(l)) {
2552
2567
  if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2553
2568
  throw new Error("Expect a symbol table in a schema symbol");
2554
2569
  } else {
2555
2570
  a = new we();
2556
- const p = n.create(At, { symbolTable: a });
2571
+ const p = n.create(vt, { symbolTable: a });
2557
2572
  s.set(l, p);
2558
2573
  }
2559
2574
  s = a;
2560
2575
  }
2561
2576
  return s;
2562
2577
  }
2563
- function xt(t) {
2578
+ function St(t) {
2564
2579
  return t === "-" || t === "<>" || t === ">" || t === "<";
2565
2580
  }
2566
- function St(t) {
2581
+ function tt(t) {
2567
2582
  var n;
2568
- if (!(t instanceof M) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2583
+ if (!(t instanceof F) || !(t.expression instanceof be) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2569
2584
  return !1;
2570
2585
  const e = t.expression.literal.value;
2571
2586
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
@@ -2580,23 +2595,23 @@ function ue(t) {
2580
2595
  }
2581
2596
  function Fn(t) {
2582
2597
  var e;
2583
- return !!(W(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof se);
2598
+ return !!(W(t) || fe(t) || me(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && kt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression) || t instanceof se);
2584
2599
  }
2585
2600
  function fe(t) {
2586
2601
  var e;
2587
- return t instanceof M && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2602
+ return t instanceof F && t.expression instanceof be && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2588
2603
  }
2589
2604
  function Bn(t) {
2590
2605
  var n;
2591
- if (!(t instanceof q) || !xt((n = t.op) == null ? void 0 : n.value))
2606
+ if (!(t instanceof q) || !St((n = t.op) == null ? void 0 : n.value))
2592
2607
  return !1;
2593
2608
  const e = j(t.expression).unwrap_or(void 0);
2594
2609
  return e !== void 0 && e.length > 0;
2595
2610
  }
2596
2611
  function Ot(t) {
2597
- return t instanceof K && t.elementList.every(F);
2612
+ return t instanceof K && t.elementList.every(B);
2598
2613
  }
2599
- function V(t) {
2614
+ function M(t) {
2600
2615
  var s;
2601
2616
  const e = {}, n = [];
2602
2617
  if (!t)
@@ -2604,7 +2619,7 @@ function V(t) {
2604
2619
  for (const i of t.elementList) {
2605
2620
  if (!i.name)
2606
2621
  continue;
2607
- if (i.name instanceof M) {
2622
+ if (i.name instanceof F) {
2608
2623
  n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2609
2624
  continue;
2610
2625
  }
@@ -2613,9 +2628,9 @@ function V(t) {
2613
2628
  }
2614
2629
  return new G(e, n);
2615
2630
  }
2616
- class pt {
2631
+ class dt {
2617
2632
  constructor(e, n) {
2618
- this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(At, {
2633
+ this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(vt, {
2619
2634
  symbolTable: new we()
2620
2635
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2621
2636
  }
@@ -2645,7 +2660,7 @@ class le {
2645
2660
  bindSettingList(e, n) {
2646
2661
  if (e)
2647
2662
  for (const s of e.elementList) {
2648
- if (s.name instanceof M)
2663
+ if (s.name instanceof F)
2649
2664
  continue;
2650
2665
  const i = Te(s.name).unwrap_or(void 0);
2651
2666
  if (!i)
@@ -2682,12 +2697,12 @@ class le {
2682
2697
  scanAndBind(e, n) {
2683
2698
  var s, i;
2684
2699
  if (e)
2685
- if (e instanceof M) {
2700
+ if (e instanceof F) {
2686
2701
  if (e.expression instanceof ee && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2687
2702
  return;
2688
2703
  this.bindFragments([e], n);
2689
2704
  } else
2690
- e instanceof H ? Ze(e) ? this.bindFragments(pe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof K && e.elementList.forEach((r) => this.scanAndBind(r, n));
2705
+ e instanceof H ? Ke(e) ? this.bindFragments(pe(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof q ? this.scanAndBind(e.expression, n) : e instanceof Ue ? this.scanAndBind(e.expression, n) : e instanceof K && e.elementList.forEach((r) => this.scanAndBind(r, n));
2691
2706
  }
2692
2707
  // Bind the fragments of a member access expression
2693
2708
  // which can be a simple expression like v1.User,
@@ -2695,7 +2710,7 @@ class le {
2695
2710
  bindFragments(e, n) {
2696
2711
  if (e.length === 0)
2697
2712
  return;
2698
- const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !F(h)), l = r !== -1 && Ot(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2713
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !B(h)), l = r !== -1 && Ot(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2699
2714
  0,
2700
2715
  r === -1 ? void 0 : r
2701
2716
  );
@@ -2705,14 +2720,14 @@ class le {
2705
2720
  for (; s.length && f.length; ) {
2706
2721
  const h = s.pop(), m = f.pop(), g = X(m).unwrap();
2707
2722
  E.unshift({
2708
- index: Ve(g, h),
2723
+ index: Ge(g, h),
2709
2724
  referrer: m
2710
2725
  });
2711
2726
  }
2712
2727
  for (; f.length; ) {
2713
2728
  const h = f.pop(), m = X(h).unwrap();
2714
2729
  E.unshift({
2715
- index: Ve(m, i),
2730
+ index: Ge(m, i),
2716
2731
  referrer: h
2717
2732
  });
2718
2733
  }
@@ -2721,7 +2736,7 @@ class le {
2721
2736
  [
2722
2737
  ...E,
2723
2738
  {
2724
- index: Ve(
2739
+ index: Ge(
2725
2740
  X(h).unwrap(),
2726
2741
  p
2727
2742
  ),
@@ -2948,14 +2963,14 @@ class qn {
2948
2963
  }
2949
2964
  // Analyzing: Invoking both the validator and binder
2950
2965
  analyze() {
2951
- return new pt(this.ast, this.symbolFactory).validate().chain((n) => new zn(n).resolve());
2966
+ return new dt(this.ast, this.symbolFactory).validate().chain((n) => new zn(n).resolve());
2952
2967
  }
2953
2968
  // For invoking the validator only
2954
2969
  validate() {
2955
- return new pt(this.ast, this.symbolFactory).validate().chain((n) => new G(n, []));
2970
+ return new dt(this.ast, this.symbolFactory).validate().chain((n) => new G(n, []));
2956
2971
  }
2957
2972
  }
2958
- function dt(t, e) {
2973
+ function Et(t, e) {
2959
2974
  const { variables: n, tupleElements: s } = _e(t).unwrap();
2960
2975
  return s ? n.length === 0 ? {
2961
2976
  schemaName: e.schemaName,
@@ -2998,7 +3013,7 @@ function _(t) {
2998
3013
  end: { offset: t.endPos.offset, line: t.endPos.line + 1, column: t.endPos.column + 1 }
2999
3014
  };
3000
3015
  }
3001
- function We(t) {
3016
+ function je(t) {
3002
3017
  var n;
3003
3018
  const e = (n = pe(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
3004
3019
  return e instanceof K ? e.elementList.map((s) => s.referee) : [e.referee];
@@ -3010,7 +3025,7 @@ function Ie(t) {
3010
3025
  schemaName: e
3011
3026
  };
3012
3027
  }
3013
- function et(t) {
3028
+ function Fe(t) {
3014
3029
  return t.expression.literal.value;
3015
3030
  }
3016
3031
  function Pt(t, e) {
@@ -3077,8 +3092,8 @@ class Mt {
3077
3092
  }
3078
3093
  interpretSettingList(e) {
3079
3094
  var i, r, a;
3080
- const n = V(e).getValue();
3081
- this.table.headerColor = (i = n.headercolor) != null && i.length ? et((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3095
+ const n = M(e).getValue();
3096
+ this.table.headerColor = (i = n.headercolor) != null && i.length ? Fe((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3082
3097
  const [s] = n.note || [];
3083
3098
  return this.table.note = s && {
3084
3099
  value: C(s == null ? void 0 : s.value).map(ae).unwrap(),
@@ -3115,7 +3130,7 @@ class Mt {
3115
3130
  s.type = i.getValue(), n.push(...i.getErrors()), s.token = _(e), s.inline_refs = [];
3116
3131
  const r = e.args.slice(1);
3117
3132
  if (I.last(r) instanceof P) {
3118
- const S = V(r.pop()).getValue();
3133
+ const S = M(r.pop()).getValue();
3119
3134
  s.pk = !!((a = S.pk) != null && a.length) || !!((l = S["primary key"]) != null && l.length), s.increment = !!((p = S.increment) != null && p.length), s.unique = !!((f = S.unique) != null && f.length), s.not_null = (E = S["not null"]) != null && E.length ? !0 : (h = S.null) != null && h.length ? !1 : void 0, s.dbdefault = Jn((g = (m = S.default) == null ? void 0 : m.at(0)) == null ? void 0 : g.value);
3120
3135
  const te = (R = S.note) == null ? void 0 : R.at(0);
3121
3136
  s.note = te && {
@@ -3124,8 +3139,8 @@ class Mt {
3124
3139
  };
3125
3140
  const Yt = S.ref || [];
3126
3141
  s.inline_refs = Yt.flatMap((Q) => {
3127
- const [st] = We(Q.value.expression);
3128
- if (Ut(st, e.symbol))
3142
+ const [it] = je(Q.value.expression);
3143
+ if (Ut(it, e.symbol))
3129
3144
  return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", Q)), [];
3130
3145
  const ke = Q.value.op, ne = j(Q.value.expression).unwrap();
3131
3146
  let de;
@@ -3148,11 +3163,11 @@ class Mt {
3148
3163
  token: _(Q)
3149
3164
  };
3150
3165
  } else if (ne.length === 3) {
3151
- const [ce, Le, rt] = ne;
3166
+ const [ce, Le, at] = ne;
3152
3167
  de = {
3153
3168
  schemaName: ce,
3154
3169
  tableName: Le,
3155
- fieldNames: [rt],
3170
+ fieldNames: [at],
3156
3171
  relation: ke.value,
3157
3172
  token: _(Q)
3158
3173
  };
@@ -3167,8 +3182,8 @@ class Mt {
3167
3182
  token: _(Q)
3168
3183
  };
3169
3184
  }
3170
- const it = this.registerInlineRefToEnv(e, st, de, Q);
3171
- return n.push(...it), it.length === 0 ? de : [];
3185
+ const rt = this.registerInlineRefToEnv(e, it, de, Q);
3186
+ return n.push(...rt), rt.length === 0 ? de : [];
3172
3187
  });
3173
3188
  }
3174
3189
  return s.pk || (s.pk = r.some((S) => Y(S).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((S) => Y(S).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
@@ -3180,7 +3195,7 @@ class Mt {
3180
3195
  s.token = _(i);
3181
3196
  const r = [i.callee, ...i.args];
3182
3197
  if (I.last(r) instanceof P) {
3183
- const g = V(r.pop()).getValue();
3198
+ const g = M(r.pop()).getValue();
3184
3199
  s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = C((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
3185
3200
  const R = (E = g.note) == null ? void 0 : E.at(0);
3186
3201
  s.note = R && {
@@ -3196,7 +3211,7 @@ class Mt {
3196
3211
  R.push(g.argumentList), g = g.callee;
3197
3212
  return R.push(g), R;
3198
3213
  }).forEach((g) => {
3199
- const { functional: R, nonFunctional: S } = $e(g).unwrap();
3214
+ const { functional: R, nonFunctional: S } = We(g).unwrap();
3200
3215
  s.columns.push(
3201
3216
  ...R.map((te) => ({
3202
3217
  value: te.value.value,
@@ -3278,7 +3293,7 @@ function Jn(t) {
3278
3293
  value: t.expression.variable.value.toLowerCase(),
3279
3294
  type: "boolean"
3280
3295
  };
3281
- if (t instanceof q && yt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
3296
+ if (t instanceof q && kt.includes((e = t.op) == null ? void 0 : e.value) && fe(t.expression)) {
3282
3297
  const i = Number.parseFloat(t.expression.expression.literal.value);
3283
3298
  return {
3284
3299
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
@@ -3310,8 +3325,8 @@ class Zn {
3310
3325
  }
3311
3326
  interpretSettingList(e) {
3312
3327
  var s, i, r;
3313
- const n = V(e).getValue();
3314
- return this.note.headerColor = (s = n.headercolor) != null && s.length ? et((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3328
+ const n = M(e).getValue();
3329
+ return this.note.headerColor = (s = n.headercolor) != null && s.length ? Fe((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3315
3330
  }
3316
3331
  interpretBody(e) {
3317
3332
  const [n, s] = I.partition(e.body, (i) => i instanceof v);
@@ -3329,18 +3344,27 @@ class Ft {
3329
3344
  this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3330
3345
  }
3331
3346
  interpret() {
3332
- return this.ref.token = _(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3347
+ return this.ref.token = _(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [
3348
+ ...this.interpretName(this.declarationNode.name),
3349
+ ...this.interpretSettingList(this.declarationNode.attributeList),
3350
+ ...this.interpretBody(this.declarationNode.body)
3351
+ ];
3333
3352
  }
3334
3353
  interpretName(e) {
3335
3354
  const n = [], s = j(this.declarationNode.name).unwrap_or([]);
3336
3355
  return this.ref.name = s.pop() || null, s.length > 1 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
3337
3356
  }
3357
+ interpretSettingList(e) {
3358
+ var s, i, r;
3359
+ const n = M(e).getValue();
3360
+ return this.ref.color = (s = n.color) != null && s.length ? Fe((r = (i = n.color) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3361
+ }
3338
3362
  interpretBody(e) {
3339
3363
  return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
3340
3364
  }
3341
3365
  interpretField(e) {
3342
3366
  var f, E, h, m;
3343
- const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = We(s), a = We(i);
3367
+ const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = je(s), a = je(i);
3344
3368
  if (Ut(r, a))
3345
3369
  return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3346
3370
  const l = Pt(r, a);
@@ -3350,7 +3374,7 @@ class Ft {
3350
3374
  new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3351
3375
  ];
3352
3376
  if (e.args[0]) {
3353
- const g = V(e.args[0]).getValue(), R = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
3377
+ const g = M(e.args[0]).getValue(), R = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
3354
3378
  this.ref.onDelete = R instanceof z ? Te(R).unwrap_or(void 0) : Y(R).unwrap_or(void 0);
3355
3379
  const S = (m = (h = g.update) == null ? void 0 : h.at(0)) == null ? void 0 : m.value;
3356
3380
  this.ref.onUpdate = S instanceof z ? Te(S).unwrap_or(void 0) : Y(S).unwrap_or(void 0);
@@ -3358,12 +3382,12 @@ class Ft {
3358
3382
  const p = Rt(n);
3359
3383
  return this.ref.endpoints = [
3360
3384
  {
3361
- ...dt(s, this.container),
3385
+ ...Et(s, this.container),
3362
3386
  relation: p[0],
3363
3387
  token: _(s)
3364
3388
  },
3365
3389
  {
3366
- ...dt(i, this.container),
3390
+ ...Et(i, this.container),
3367
3391
  relation: p[1],
3368
3392
  token: _(i)
3369
3393
  }
@@ -3428,8 +3452,8 @@ class Bt {
3428
3452
  }
3429
3453
  interpretSettingList(e) {
3430
3454
  var i, r, a;
3431
- const n = V(e).getValue();
3432
- this.tableGroup.color = (i = n.color) != null && i.length ? et((a = (r = n.color) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3455
+ const n = M(e).getValue();
3456
+ this.tableGroup.color = (i = n.color) != null && i.length ? Fe((a = (r = n.color) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
3433
3457
  const [s] = n.note || [];
3434
3458
  return this.tableGroup.note = s && {
3435
3459
  value: C(s == null ? void 0 : s.value).map(ae).unwrap(),
@@ -3453,7 +3477,7 @@ class Vt {
3453
3477
  var l;
3454
3478
  const s = n, i = {};
3455
3479
  i.token = _(s), i.name = Y(s.callee).unwrap();
3456
- const a = (l = V(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3480
+ const a = (l = M(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3457
3481
  return i.note = a && {
3458
3482
  value: C(a.value).map(ae).unwrap(),
3459
3483
  token: _(a)
@@ -3577,7 +3601,7 @@ function Ae(t) {
3577
3601
  }
3578
3602
  }
3579
3603
  function Re(t, e) {
3580
- if (!t || Xe(t))
3604
+ if (!t || $e(t))
3581
3605
  return !1;
3582
3606
  for (const n of t.trailingTrivia) {
3583
3607
  if (n.start > e)
@@ -3601,7 +3625,7 @@ function Pe(t) {
3601
3625
  }))
3602
3626
  };
3603
3627
  }
3604
- function Fe(t) {
3628
+ function Be(t) {
3605
3629
  return {
3606
3630
  ...t,
3607
3631
  suggestions: t.suggestions.map((e) => ({
@@ -3610,7 +3634,7 @@ function Fe(t) {
3610
3634
  }))
3611
3635
  };
3612
3636
  }
3613
- function tt(t, e) {
3637
+ function nt(t, e) {
3614
3638
  return t.getOffsetAt(e);
3615
3639
  }
3616
3640
  class Gt {
@@ -3619,7 +3643,7 @@ class Gt {
3619
3643
  }
3620
3644
  provideCompletionItems(e, n) {
3621
3645
  var E, h;
3622
- const s = tt(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];
3646
+ const s = nt(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];
3623
3647
  if ([
3624
3648
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3625
3649
  ...(r == null ? void 0 : r.leadingTrivia) || [],
@@ -3627,12 +3651,12 @@ class Gt {
3627
3651
  ].find((m) => Ht(m) && ge(s, m)))
3628
3652
  return D();
3629
3653
  if (a === void 0)
3630
- return bt();
3654
+ return It();
3631
3655
  if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
3632
3656
  return D();
3633
3657
  const p = this.compiler.container.element(s);
3634
3658
  if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
3635
- return bt();
3659
+ return It();
3636
3660
  const f = [...this.compiler.container.stack(s)].reverse();
3637
3661
  for (const m of f)
3638
3662
  if (m instanceof q)
@@ -3641,7 +3665,7 @@ class Gt {
3641
3665
  case "<":
3642
3666
  case "<>":
3643
3667
  case "-":
3644
- return Et(
3668
+ return Nt(
3645
3669
  this.compiler,
3646
3670
  s,
3647
3671
  m
@@ -3653,7 +3677,7 @@ class Gt {
3653
3677
  case "<":
3654
3678
  case "<>":
3655
3679
  case "-":
3656
- return Et(
3680
+ return Nt(
3657
3681
  this.compiler,
3658
3682
  s,
3659
3683
  m
@@ -3667,23 +3691,23 @@ class Gt {
3667
3691
  }
3668
3692
  else {
3669
3693
  if (m instanceof ie)
3670
- return Nt(this.compiler, s, m);
3694
+ return mt(this.compiler, s, m);
3671
3695
  if (m instanceof P)
3672
- return Nt(this.compiler, s, m);
3696
+ return mt(this.compiler, s, m);
3673
3697
  if (m instanceof K)
3674
3698
  return ns(this.compiler, s);
3675
3699
  if (m instanceof v)
3676
- return Tt(this.compiler, s, m);
3700
+ return bt(this.compiler, s, m);
3677
3701
  if (m instanceof A && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
3678
- return Tt(this.compiler, s, void 0);
3702
+ return bt(this.compiler, s, void 0);
3679
3703
  }
3680
3704
  return D();
3681
3705
  }
3682
3706
  }
3683
- function Et(t, e, n) {
3707
+ function Nt(t, e, n) {
3684
3708
  const s = t.container.scopeKind(e);
3685
3709
  if ([O.REF, O.TABLE].includes(s)) {
3686
- const i = Be(t, e, t.container.element(e), [
3710
+ const i = Ve(t, e, t.container.element(e), [
3687
3711
  T.Table,
3688
3712
  T.Schema,
3689
3713
  T.Column
@@ -3692,7 +3716,7 @@ function Et(t, e, n) {
3692
3716
  }
3693
3717
  return D();
3694
3718
  }
3695
- function Be(t, e, n, s) {
3719
+ function Ve(t, e, n, s) {
3696
3720
  var a;
3697
3721
  if (n === void 0)
3698
3722
  return D();
@@ -3714,7 +3738,7 @@ function Be(t, e, n, s) {
3714
3738
  }
3715
3739
  i = i instanceof A ? i.parent : void 0;
3716
3740
  }
3717
- return Fe(r);
3741
+ return Be(r);
3718
3742
  }
3719
3743
  function ns(t, e) {
3720
3744
  var s;
@@ -3738,14 +3762,14 @@ function ns(t, e) {
3738
3762
  }
3739
3763
  return D();
3740
3764
  }
3741
- function Nt(t, e, n) {
3765
+ function mt(t, e, n) {
3742
3766
  const { token: s } = t.container.token(e);
3743
3767
  if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3744
- const i = mt(t, e);
3768
+ const i = Tt(t, e);
3745
3769
  return (s == null ? void 0 : s.kind) === u.COMMA && Re(s, e) ? Pe(i) : i;
3746
3770
  }
3747
3771
  if (n.name && n.name.start <= e && n.name.end >= e)
3748
- return mt(t, e);
3772
+ return Tt(t, e);
3749
3773
  if (n.name instanceof z) {
3750
3774
  const i = ss(
3751
3775
  t,
@@ -3756,7 +3780,7 @@ function Nt(t, e, n) {
3756
3780
  }
3757
3781
  return D();
3758
3782
  }
3759
- function mt(t, e) {
3783
+ function Tt(t, e) {
3760
3784
  const n = t.container.element(e), s = t.container.scopeKind(e);
3761
3785
  if (n instanceof $)
3762
3786
  return D();
@@ -3884,10 +3908,10 @@ function ss(t, e, n) {
3884
3908
  }
3885
3909
  function Ct(t, e, n) {
3886
3910
  const s = pe(n).unwrap_or([]);
3887
- if (s.pop(), s.some((r) => !F(r)))
3911
+ if (s.pop(), s.some((r) => !B(r)))
3888
3912
  return D();
3889
3913
  const i = s.map((r) => Y(r).unwrap());
3890
- return Fe({
3914
+ return Be({
3891
3915
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3892
3916
  label: a,
3893
3917
  insertText: a,
@@ -3896,7 +3920,7 @@ function Ct(t, e, n) {
3896
3920
  }))
3897
3921
  });
3898
3922
  }
3899
- function Tt(t, e, n) {
3923
+ function bt(t, e, n) {
3900
3924
  var i;
3901
3925
  switch (t.container.scopeKind(e)) {
3902
3926
  case O.TABLE:
@@ -3917,7 +3941,7 @@ function Tt(t, e, n) {
3917
3941
  return D();
3918
3942
  }
3919
3943
  }
3920
- function bt() {
3944
+ function It() {
3921
3945
  return {
3922
3946
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3923
3947
  label: t,
@@ -3929,7 +3953,7 @@ function bt() {
3929
3953
  };
3930
3954
  }
3931
3955
  function is(t, e, n) {
3932
- return n != null && n.callee && nt(e, n) === 1 ? Be(t, e, t.container.element(e), [
3956
+ return n != null && n.callee && st(e, n) === 1 ? Ve(t, e, t.container.element(e), [
3933
3957
  T.Schema,
3934
3958
  T.Table,
3935
3959
  T.Column
@@ -3946,7 +3970,7 @@ function rs(t, e, n) {
3946
3970
  range: void 0
3947
3971
  }))
3948
3972
  };
3949
- const s = nt(e, n);
3973
+ const s = st(e, n);
3950
3974
  return s === 0 ? {
3951
3975
  suggestions: ["Note", "indexes"].map((i) => ({
3952
3976
  label: i,
@@ -3958,7 +3982,7 @@ function rs(t, e, n) {
3958
3982
  } : s === 1 ? cs(t, e) : D();
3959
3983
  }
3960
3984
  function as(t, e, n) {
3961
- return n != null && n.callee ? nt(e, n) === 0 ? {
3985
+ return n != null && n.callee ? st(e, n) === 0 ? {
3962
3986
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3963
3987
  label: i,
3964
3988
  insertText: i,
@@ -3977,7 +4001,7 @@ function as(t, e, n) {
3977
4001
  };
3978
4002
  }
3979
4003
  function Xt(t, e) {
3980
- return Be(t, e, t.container.element(e), [
4004
+ return Ve(t, e, t.container.element(e), [
3981
4005
  T.Schema,
3982
4006
  T.Table,
3983
4007
  T.Column
@@ -3986,7 +4010,7 @@ function Xt(t, e) {
3986
4010
  function os(t) {
3987
4011
  return {
3988
4012
  suggestions: [
3989
- ...Fe({
4013
+ ...Be({
3990
4014
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3991
4015
  const n = re(e).unwrap_or(void 0);
3992
4016
  if (n === void 0)
@@ -4082,7 +4106,7 @@ function cs(t, e) {
4082
4106
  sortText: L.TypeParameter.toString().padStart(2, "0"),
4083
4107
  range: void 0
4084
4108
  })),
4085
- ...Be(t, e, t.container.element(e), [
4109
+ ...Ve(t, e, t.container.element(e), [
4086
4110
  T.Enum,
4087
4111
  T.Schema
4088
4112
  ]).suggestions
@@ -4091,10 +4115,10 @@ function cs(t, e) {
4091
4115
  }
4092
4116
  function $t(t, e) {
4093
4117
  const n = t.container.element(e), s = n == null ? void 0 : n.parent;
4094
- if (!((s == null ? void 0 : s.symbol) instanceof vt))
4118
+ if (!((s == null ? void 0 : s.symbol) instanceof wt))
4095
4119
  return D();
4096
4120
  const { symbolTable: i } = s.symbol;
4097
- return Fe({
4121
+ return Be({
4098
4122
  suggestions: [...i.entries()].flatMap(([r]) => {
4099
4123
  const a = re(r).unwrap_or(void 0);
4100
4124
  if (a === void 0)
@@ -4110,7 +4134,7 @@ function $t(t, e) {
4110
4134
  })
4111
4135
  });
4112
4136
  }
4113
- function nt(t, e) {
4137
+ function st(t, e) {
4114
4138
  if (!e.callee)
4115
4139
  return -1;
4116
4140
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
@@ -4122,7 +4146,7 @@ class Wt {
4122
4146
  }
4123
4147
  provideDefinition(e, n) {
4124
4148
  var a;
4125
- const { uri: s } = e, i = tt(e, n), r = [...this.compiler.container.stack(i)];
4149
+ const { uri: s } = e, i = nt(e, n), r = [...this.compiler.container.stack(i)];
4126
4150
  for (; r.length !== 0; ) {
4127
4151
  const l = r.pop();
4128
4152
  if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(l == null ? void 0 : l.kind)) {
@@ -4148,7 +4172,7 @@ class jt {
4148
4172
  this.compiler = e;
4149
4173
  }
4150
4174
  provideReferences(e, n) {
4151
- const { uri: s } = e, i = tt(e, n), r = [...this.compiler.container.stack(i)];
4175
+ const { uri: s } = e, i = nt(e, n), r = [...this.compiler.container.stack(i)];
4152
4176
  for (; r.length !== 0; ) {
4153
4177
  const a = r.pop();
4154
4178
  if (a && [
@@ -4189,7 +4213,7 @@ class ps {
4189
4213
  ).fill(null), this.nodeIdGenerator = new Jt(), this.symbolIdGenerator = new nn(), this.token = {
4190
4214
  invalidStream: this.createQuery(
4191
4215
  6,
4192
- () => this.parse.tokens().filter(wt)
4216
+ () => this.parse.tokens().filter(yt)
4193
4217
  ),
4194
4218
  // Valid + Invalid tokens (which are guarenteed to be non-trivials) are included in the stream
4195
4219
  flatStream: this.createQuery(
@@ -4234,7 +4258,7 @@ class ps {
4234
4258
  const p = [l];
4235
4259
  for (; ; ) {
4236
4260
  const E = fn(l).find((h) => ge(a, h));
4237
- if (E === void 0 || E instanceof B)
4261
+ if (E === void 0 || E instanceof V)
4238
4262
  break;
4239
4263
  p.push(E), l = E;
4240
4264
  }
@@ -4242,7 +4266,7 @@ class ps {
4242
4266
  return p;
4243
4267
  for (; p.length > 0; ) {
4244
4268
  let f = !1;
4245
- const E = Ce(p);
4269
+ const E = Xe(p);
4246
4270
  if (E instanceof v) {
4247
4271
  const h = this.parse.source();
4248
4272
  for (let m = E.end; m < e; m += 1)
@@ -4251,7 +4275,7 @@ class ps {
4251
4275
  } else
4252
4276
  E instanceof q || E instanceof H ? this.container.token(e).token !== E.op && (p.pop(), f = !0) : E instanceof P ? E.listCloseBracket && E.end <= e && (p.pop(), f = !0) : E instanceof K ? E.tupleCloseParen && E.end <= e && (p.pop(), f = !0) : E instanceof Z ? E.blockCloseBrace && E.end <= e && (p.pop(), f = !0) : E instanceof z || E.end < e && (p.pop(), f = !0);
4253
4277
  if (f) {
4254
- const h = Ce(p);
4278
+ const h = Xe(p);
4255
4279
  h instanceof A && h.end <= e && p.pop();
4256
4280
  }
4257
4281
  if (!f)