@danielx/civet 0.8.4 → 0.8.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.
package/dist/main.mjs CHANGED
@@ -1038,6 +1038,9 @@ function makeLeftHandSideExpression(expression) {
1038
1038
  expression = item;
1039
1039
  }
1040
1040
  if (isASTNodeObject(expression)) {
1041
+ if (expression.token) {
1042
+ return expression;
1043
+ }
1041
1044
  if (expression.parenthesized) {
1042
1045
  return expression;
1043
1046
  }
@@ -1560,86 +1563,90 @@ function gatherBindingPatternTypeSuffix(pattern) {
1560
1563
  let count = 0;
1561
1564
  switch (pattern.type) {
1562
1565
  case "ArrayBindingPattern": {
1563
- const results = [];
1564
- for (let ref2 = pattern.elements, i2 = 0, len1 = ref2.length; i2 < len1; i2++) {
1565
- const elem = ref2[i2];
1566
- let { typeSuffix } = elem;
1567
- typeSuffix ??= elem.binding?.typeSuffix;
1568
- if (typeSuffix) {
1569
- count++;
1570
- }
1571
- let typeElement = [typeSuffix?.t, elem.delim];
1572
- if (typeSuffix?.optional) {
1573
- typeElement[0] = parenthesizeType(typeElement[0]);
1574
- typeElement.unshift("undefined |");
1566
+ {
1567
+ const results = [];
1568
+ for (let ref2 = pattern.elements, i2 = 0, len1 = ref2.length; i2 < len1; i2++) {
1569
+ const elem = ref2[i2];
1570
+ let { typeSuffix } = elem;
1571
+ typeSuffix ??= elem.binding?.typeSuffix;
1572
+ if (typeSuffix) {
1573
+ count++;
1574
+ }
1575
+ let typeElement = [typeSuffix?.t, elem.delim];
1576
+ if (typeSuffix?.optional) {
1577
+ typeElement[0] = parenthesizeType(typeElement[0]);
1578
+ typeElement.unshift("undefined |");
1579
+ }
1580
+ if (elem.type === "BindingRestElement") {
1581
+ typeElement[0] ??= "unknown[]";
1582
+ typeElement.unshift(elem.dots);
1583
+ } else {
1584
+ typeElement[0] ??= "unknown";
1585
+ }
1586
+ results.push(typeElement);
1575
1587
  }
1576
- if (elem.type === "BindingRestElement") {
1577
- typeElement[0] ??= "unknown[]";
1578
- typeElement.unshift(elem.dots);
1579
- } else {
1580
- typeElement[0] ??= "unknown";
1588
+ ;
1589
+ const types = results;
1590
+ if (count) {
1591
+ const t = [": [", types, "]"];
1592
+ pattern.typeSuffix = {
1593
+ type: "TypeSuffix",
1594
+ ts: true,
1595
+ t,
1596
+ children: [t]
1597
+ };
1581
1598
  }
1582
- results.push(typeElement);
1583
- }
1584
- ;
1585
- const types = results;
1586
- if (count) {
1587
- const t = [": [", types, "]"];
1588
- pattern.typeSuffix = {
1589
- type: "TypeSuffix",
1590
- ts: true,
1591
- t,
1592
- children: [t]
1593
- };
1594
1599
  }
1595
1600
  ;
1596
1601
  break;
1597
1602
  }
1598
1603
  case "ObjectBindingPattern": {
1599
- let restType;
1600
- const results1 = [];
1601
- for (let ref3 = pattern.properties, i3 = 0, len22 = ref3.length; i3 < len22; i3++) {
1602
- const prop = ref3[i3];
1603
- let { typeSuffix } = prop;
1604
- typeSuffix ??= prop.value?.typeSuffix;
1605
- if (typeSuffix) {
1606
- count++;
1607
- }
1608
- typeSuffix ??= {
1609
- type: "TypeSuffix",
1610
- ts: true,
1611
- children: [": unknown"]
1612
- };
1613
- switch (prop.type) {
1614
- case "BindingProperty": {
1615
- const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
1616
- results1.push([...ws, prop.name, typeSuffix, prop.delim]);
1617
- break;
1618
- }
1619
- case "AtBindingProperty": {
1620
- const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
1621
- results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
1622
- break;
1604
+ {
1605
+ let restType;
1606
+ const results1 = [];
1607
+ for (let ref3 = pattern.properties, i3 = 0, len22 = ref3.length; i3 < len22; i3++) {
1608
+ const prop = ref3[i3];
1609
+ let { typeSuffix } = prop;
1610
+ typeSuffix ??= prop.value?.typeSuffix;
1611
+ if (typeSuffix) {
1612
+ count++;
1623
1613
  }
1624
- case "BindingRestProperty": {
1625
- restType = prop.typeSuffix?.t;
1626
- continue;
1614
+ typeSuffix ??= {
1615
+ type: "TypeSuffix",
1616
+ ts: true,
1617
+ children: [": unknown"]
1618
+ };
1619
+ switch (prop.type) {
1620
+ case "BindingProperty": {
1621
+ const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
1622
+ results1.push([...ws, prop.name, typeSuffix, prop.delim]);
1623
+ break;
1624
+ }
1625
+ case "AtBindingProperty": {
1626
+ const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
1627
+ results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
1628
+ break;
1629
+ }
1630
+ case "BindingRestProperty": {
1631
+ restType = prop.typeSuffix?.t;
1632
+ continue;
1633
+ }
1627
1634
  }
1628
1635
  }
1629
- }
1630
- ;
1631
- const types = results1;
1632
- if (count) {
1633
- const t = ["{", types, "}"];
1634
- if (restType != null) {
1635
- t.push(" & ", parenthesizeType(trimFirstSpace(restType)));
1636
+ ;
1637
+ const types = results1;
1638
+ if (count) {
1639
+ const t = ["{", types, "}"];
1640
+ if (restType != null) {
1641
+ t.push(" & ", parenthesizeType(trimFirstSpace(restType)));
1642
+ }
1643
+ pattern.typeSuffix = {
1644
+ type: "TypeSuffix",
1645
+ ts: true,
1646
+ t,
1647
+ children: [": ", t]
1648
+ };
1636
1649
  }
1637
- pattern.typeSuffix = {
1638
- type: "TypeSuffix",
1639
- ts: true,
1640
- t,
1641
- children: [": ", t]
1642
- };
1643
1650
  }
1644
1651
  ;
1645
1652
  break;
@@ -1709,6 +1716,34 @@ var declareHelper = {
1709
1716
  "\n"
1710
1717
  ]]);
1711
1718
  },
1719
+ rslice(rsliceRef) {
1720
+ const RSliceable = makeRef("RSliceable");
1721
+ state.prelude.push(["", [
1722
+ ts(["type ", RSliceable, "<R> = string | {length: number; slice(start: number, end: number): {reverse(): R}}\n"]),
1723
+ preludeVar,
1724
+ rsliceRef,
1725
+ ts([": <R, T extends string | ", RSliceable, "<R>>(a: T, start?: number, end?: number) => T extends string ? string : T extends ", RSliceable, "<infer R> ? R : never"]),
1726
+ " = ((a, start, end) => {\n",
1727
+ " const l = a.length\n",
1728
+ " start = ",
1729
+ getHelperRef("modulo"),
1730
+ "(start ?? -1, l)\n",
1731
+ " end = ",
1732
+ getHelperRef("modulo"),
1733
+ "((end ?? -1) + 1, l)\n",
1734
+ " if (typeof a === 'string') {\n",
1735
+ ` let r = ""
1736
+ `,
1737
+ " for (let i = start; i >= end; --i) r += a[i]\n",
1738
+ " return r",
1739
+ asAny,
1740
+ "\n",
1741
+ " } else {\n",
1742
+ " return a.slice(end, start + 1).reverse()\n",
1743
+ " }\n",
1744
+ "});\n"
1745
+ ]]);
1746
+ },
1712
1747
  div(divRef) {
1713
1748
  state.prelude.push(["", [
1714
1749
  // [indent, statement]
@@ -1835,6 +1870,9 @@ function getHelperRef(base) {
1835
1870
  declareHelper[base](ref);
1836
1871
  return state.helperRefs[base] = ref;
1837
1872
  }
1873
+ function peekHelperRef(base) {
1874
+ return state.helperRefs[base];
1875
+ }
1838
1876
  function extractPreludeFor(node) {
1839
1877
  let helpers = new Set(Object.values(state.helperRefs));
1840
1878
  helpers = new Set(gatherRecursive(node, helpers.has.bind(helpers)));
@@ -5781,7 +5819,131 @@ function handleThisPrivateShorthands(value) {
5781
5819
  return [value, value.thisShorthand];
5782
5820
  }
5783
5821
  function processTryBlock($0) {
5784
- let [t, , b, c, e, f] = $0;
5822
+ let [t, , b, cs, e, f] = $0;
5823
+ let c;
5824
+ let m;
5825
+ if (cs.some(($) => (m = $.binding?.parameter, typeof m === "object" && m != null && "type" in m && m.type === "CatchPattern"))) {
5826
+ const ref = makeRef("e");
5827
+ const binding = {
5828
+ type: "CatchBinding",
5829
+ children: ["(", ref, ")"],
5830
+ parameter: ref
5831
+ };
5832
+ const condition = {
5833
+ type: "ParenthesizedExpression",
5834
+ children: ["(", ref, ")"],
5835
+ expression: ref
5836
+ };
5837
+ let defaultClause = false;
5838
+ const clauses = cs.map((clause) => {
5839
+ let ref1;
5840
+ if ((ref1 = clause.binding?.parameter) && typeof ref1 === "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
5841
+ const { type, patterns } = ref1;
5842
+ return {
5843
+ type: "PatternClause",
5844
+ patterns,
5845
+ block: clause.block,
5846
+ children: [patterns, clause.block]
5847
+ };
5848
+ } else {
5849
+ defaultClause = true;
5850
+ const parameter = clause.binding?.parameter;
5851
+ if (parameter != null) {
5852
+ assert.equal(
5853
+ parameter.type,
5854
+ "CatchParameter",
5855
+ `Invalid catch parameter ${parameter.type}`
5856
+ );
5857
+ const { binding: pattern, typeSuffix } = parameter;
5858
+ const initializer = {
5859
+ type: "Initializer",
5860
+ expression: ref,
5861
+ children: ["", " = ", ref]
5862
+ };
5863
+ const bindings = [{
5864
+ type: "Binding",
5865
+ names: pattern.names,
5866
+ pattern,
5867
+ typeSuffix,
5868
+ initializer,
5869
+ children: [pattern, typeSuffix, initializer],
5870
+ splices: [],
5871
+ thisAssignments: []
5872
+ }];
5873
+ clause.block.expressions.unshift(["", {
5874
+ type: "Declaration",
5875
+ children: ["let", " ", bindings],
5876
+ bindings,
5877
+ names: bindings[0].names,
5878
+ decl: "let"
5879
+ }, ";"]);
5880
+ }
5881
+ return {
5882
+ type: "DefaultClause",
5883
+ block: clause.block,
5884
+ children: ["default: ", clause.block]
5885
+ };
5886
+ }
5887
+ });
5888
+ if (!defaultClause) {
5889
+ const expressions = [[
5890
+ "",
5891
+ {
5892
+ type: "ThrowStatement",
5893
+ children: ["throw", " ", ref]
5894
+ }
5895
+ ]];
5896
+ const block2 = {
5897
+ type: "BlockStatement",
5898
+ expressions,
5899
+ children: [" {", expressions, "}"],
5900
+ bare: false
5901
+ };
5902
+ clauses.push({
5903
+ type: "DefaultClause",
5904
+ block: block2,
5905
+ children: ["default: ", block2]
5906
+ });
5907
+ }
5908
+ const caseBlock = {
5909
+ type: "CaseBlock",
5910
+ clauses,
5911
+ children: [" {", clauses, "}"]
5912
+ };
5913
+ const patternSwitch = {
5914
+ type: "SwitchStatement",
5915
+ condition,
5916
+ caseBlock,
5917
+ children: ["switch", condition, caseBlock]
5918
+ };
5919
+ const block = {
5920
+ type: "BlockStatement",
5921
+ bare: false,
5922
+ expressions: [["", patternSwitch]],
5923
+ children: [" {", patternSwitch, "}"]
5924
+ };
5925
+ c = makeNode({
5926
+ type: "CatchClause",
5927
+ children: [
5928
+ cs[0].children[0],
5929
+ // whitespace
5930
+ cs[0].children[1],
5931
+ // catch token
5932
+ binding,
5933
+ block
5934
+ ],
5935
+ binding,
5936
+ block
5937
+ });
5938
+ } else {
5939
+ c = cs[0];
5940
+ if (cs.length > 1) {
5941
+ c = append(c, {
5942
+ type: "Error",
5943
+ message: "Only one catch clause allowed unless using pattern matching"
5944
+ });
5945
+ }
5946
+ }
5785
5947
  if (!c && (e || !f)) {
5786
5948
  const emptyCatchBlock = makeEmptyBlock();
5787
5949
  c = {
@@ -5880,8 +6042,9 @@ function processCallMemberExpression(node) {
5880
6042
  }
5881
6043
  }
5882
6044
  }
5883
- for (let i = 0; i < children.length; i++) {
5884
- const glob = children[i];
6045
+ for (let i3 = 0, len22 = children.length; i3 < len22; i3++) {
6046
+ const i = i3;
6047
+ const glob = children[i3];
5885
6048
  if (glob?.type === "PropertyGlob") {
5886
6049
  let prefix = children.slice(0, i);
5887
6050
  const parts = [];
@@ -5952,14 +6115,14 @@ function processCallMemberExpression(node) {
5952
6115
  });
5953
6116
  }
5954
6117
  }
5955
- let ref1;
6118
+ let ref2;
5956
6119
  let object = {
5957
6120
  type: "ObjectExpression",
5958
6121
  children: [
5959
6122
  glob.object.children[0],
5960
6123
  // {
5961
6124
  ...parts,
5962
- (ref1 = glob.object.children)[ref1.length - 1]
6125
+ (ref2 = glob.object.children)[ref2.length - 1]
5963
6126
  // whitespace and }
5964
6127
  ],
5965
6128
  properties: parts,
@@ -6001,6 +6164,33 @@ function processCallMemberExpression(node) {
6001
6164
  ...children.slice(i + 1)
6002
6165
  ]
6003
6166
  });
6167
+ } else if (typeof glob === "object" && glob != null && "type" in glob && glob.type === "SliceExpression" && "reversed" in glob && glob.reversed === true) {
6168
+ const args = [
6169
+ { ...node, children: node.children.slice(0, i) },
6170
+ { ...glob.children[0], token: ", " },
6171
+ ...glob.children.slice(1, -1)
6172
+ ];
6173
+ let ref3;
6174
+ return makeNode({
6175
+ ...node,
6176
+ children: [
6177
+ {
6178
+ type: "CallExpression",
6179
+ children: [
6180
+ getHelperRef("rslice"),
6181
+ makeNode({
6182
+ type: "Call",
6183
+ args,
6184
+ children: [
6185
+ "(",
6186
+ args,
6187
+ (ref3 = glob.children)[ref3.length - 1]
6188
+ ]
6189
+ })
6190
+ ]
6191
+ }
6192
+ ]
6193
+ });
6004
6194
  }
6005
6195
  }
6006
6196
  return node;
@@ -6011,9 +6201,9 @@ function replaceNode(node, newNode, parent) {
6011
6201
  throw new Error("replaceNode failed: node has no parent");
6012
6202
  }
6013
6203
  function recurse(children) {
6014
- for (let i3 = 0, len22 = children.length; i3 < len22; i3++) {
6015
- const i = i3;
6016
- const child = children[i3];
6204
+ for (let i4 = 0, len3 = children.length; i4 < len3; i4++) {
6205
+ const i = i4;
6206
+ const child = children[i4];
6017
6207
  if (child === node) {
6018
6208
  children[i] = newNode;
6019
6209
  return true;
@@ -6105,8 +6295,8 @@ function convertNamedImportsToObject(node, pattern) {
6105
6295
  return { type: "Error", message: "cannot use `type` in dynamic import" };
6106
6296
  } else {
6107
6297
  const { source, binding } = specifier;
6108
- let ref2;
6109
- const delim = (ref2 = specifier.children)[ref2.length - 1];
6298
+ let ref4;
6299
+ const delim = (ref4 = specifier.children)[ref4.length - 1];
6110
6300
  return {
6111
6301
  type: pattern ? "BindingProperty" : "Property",
6112
6302
  name: source,
@@ -6116,7 +6306,7 @@ function convertNamedImportsToObject(node, pattern) {
6116
6306
  };
6117
6307
  }
6118
6308
  });
6119
- let ref3;
6309
+ let ref5;
6120
6310
  return {
6121
6311
  type: pattern ? "ObjectBindingPattern" : "ObjectExpression",
6122
6312
  names: node.names,
@@ -6125,7 +6315,7 @@ function convertNamedImportsToObject(node, pattern) {
6125
6315
  node.children[0],
6126
6316
  // {
6127
6317
  properties,
6128
- (ref3 = node.children)[ref3.length - 1]
6318
+ (ref5 = node.children)[ref5.length - 1]
6129
6319
  // }
6130
6320
  ]
6131
6321
  };
@@ -6231,8 +6421,8 @@ function processAssignments(statements) {
6231
6421
  while (expr.type === "ParenthesizedExpression") {
6232
6422
  expr = expr.expression;
6233
6423
  }
6234
- let m;
6235
- if (m = expr.type, m === "AssignmentExpression" || m === "UpdateExpression") {
6424
+ let m1;
6425
+ if (m1 = expr.type, m1 === "AssignmentExpression" || m1 === "UpdateExpression") {
6236
6426
  if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
6237
6427
  pre.push("(");
6238
6428
  post.push([", ", lhs, ")"]);
@@ -6246,15 +6436,15 @@ function processAssignments(statements) {
6246
6436
  return;
6247
6437
  }
6248
6438
  const pre = [], post = [];
6249
- let ref4;
6439
+ let ref6;
6250
6440
  switch (exp.type) {
6251
6441
  case "AssignmentExpression": {
6252
6442
  if (!exp.lhs)
6253
6443
  return;
6254
6444
  exp.lhs.forEach((lhsPart, i) => {
6255
- let ref5;
6256
- if (ref5 = extractAssignment(lhsPart[1])) {
6257
- const newLhs = ref5;
6445
+ let ref7;
6446
+ if (ref7 = extractAssignment(lhsPart[1])) {
6447
+ const newLhs = ref7;
6258
6448
  return lhsPart[1] = newLhs;
6259
6449
  }
6260
6450
  ;
@@ -6263,8 +6453,8 @@ function processAssignments(statements) {
6263
6453
  break;
6264
6454
  }
6265
6455
  case "UpdateExpression": {
6266
- if (ref4 = extractAssignment(exp.assigned)) {
6267
- const newLhs = ref4;
6456
+ if (ref6 = extractAssignment(exp.assigned)) {
6457
+ const newLhs = ref6;
6268
6458
  const i = exp.children.indexOf(exp.assigned);
6269
6459
  exp.assigned = exp.children[i] = newLhs;
6270
6460
  }
@@ -6280,7 +6470,7 @@ function processAssignments(statements) {
6280
6470
  const { assigned } = exp;
6281
6471
  const ref = makeRef();
6282
6472
  const newMemberExp = unchainOptionalMemberExpression(assigned, ref, (children) => {
6283
- return exp.children.map(($) => $ === assigned ? children : $);
6473
+ return exp.children.map(($3) => $3 === assigned ? children : $3);
6284
6474
  });
6285
6475
  if (newMemberExp !== assigned) {
6286
6476
  if (newMemberExp.usesRef) {
@@ -6304,23 +6494,23 @@ function processAssignments(statements) {
6304
6494
  (exp) => {
6305
6495
  let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
6306
6496
  let block;
6307
- let ref6;
6308
- if (exp.parent?.type === "BlockStatement" && !(ref6 = $1[$1.length - 1])?.[ref6.length - 1]?.special) {
6497
+ let ref8;
6498
+ if (exp.parent?.type === "BlockStatement" && !(ref8 = $1[$1.length - 1])?.[ref8.length - 1]?.special) {
6309
6499
  block = makeBlockFragment();
6310
- let ref7;
6311
- if (ref7 = prependStatementExpressionBlock(
6500
+ let ref9;
6501
+ if (ref9 = prependStatementExpressionBlock(
6312
6502
  { type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
6313
6503
  block
6314
6504
  )) {
6315
- const ref = ref7;
6316
- exp.children = exp.children.map(($3) => $3 === $2 ? ref : $3);
6505
+ const ref = ref9;
6506
+ exp.children = exp.children.map(($4) => $4 === $2 ? ref : $4);
6317
6507
  $2 = ref;
6318
6508
  } else {
6319
6509
  block = void 0;
6320
6510
  }
6321
6511
  }
6322
- let ref8;
6323
- if ($1.some(($4) => (ref8 = $4)[ref8.length - 1].special)) {
6512
+ let ref10;
6513
+ if ($1.some(($5) => (ref10 = $5)[ref10.length - 1].special)) {
6324
6514
  if ($1.length !== 1)
6325
6515
  throw new Error("Only one assignment with id= is allowed");
6326
6516
  const [, lhs, , op] = $1[0];
@@ -6345,8 +6535,8 @@ function processAssignments(statements) {
6345
6535
  if (!(op.token === "=")) {
6346
6536
  continue;
6347
6537
  }
6348
- let m1;
6349
- if (m1 = lhs.type, m1 === "ObjectExpression" || m1 === "ObjectBindingPattern") {
6538
+ let m2;
6539
+ if (m2 = lhs.type, m2 === "ObjectExpression" || m2 === "ObjectBindingPattern") {
6350
6540
  if (!wrapped) {
6351
6541
  wrapped = true;
6352
6542
  lhs.children.splice(0, 0, "(");
@@ -6360,10 +6550,17 @@ function processAssignments(statements) {
6360
6550
  const lastAssignment = $1[i];
6361
6551
  if (lastAssignment[3].token === "=") {
6362
6552
  const lhs = lastAssignment[1];
6363
- let m2;
6553
+ let m3;
6364
6554
  if (lhs.type === "MemberExpression") {
6365
6555
  const members = lhs.children;
6366
6556
  const lastMember = members[members.length - 1];
6557
+ if (typeof lastMember === "object" && lastMember != null && "type" in lastMember && lastMember.type === "CallExpression" && "children" in lastMember && Array.isArray(lastMember.children) && lastMember.children.length >= 1 && lastMember.children[0] === peekHelperRef("rslice")) {
6558
+ lastMember.children.push({
6559
+ type: "Error",
6560
+ message: "Slice range cannot be decreasing in assignment"
6561
+ });
6562
+ break;
6563
+ }
6367
6564
  if (lastMember.type === "SliceExpression") {
6368
6565
  const { start, end, children: c } = lastMember;
6369
6566
  c[0].token = ".splice(";
@@ -6386,9 +6583,9 @@ function processAssignments(statements) {
6386
6583
  exp.names = [];
6387
6584
  break;
6388
6585
  }
6389
- } else if (m2 = lhs.type, m2 === "ObjectBindingPattern" || m2 === "ArrayBindingPattern") {
6586
+ } else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") {
6390
6587
  processBindingPatternLHS(lhs, tail);
6391
- gatherRecursiveAll(lhs, ($5) => $5.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
6588
+ gatherRecursiveAll(lhs, ($6) => $6.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
6392
6589
  }
6393
6590
  }
6394
6591
  i--;
@@ -6421,7 +6618,7 @@ function processAssignments(statements) {
6421
6618
  }
6422
6619
  if (refsToDeclare.size) {
6423
6620
  if (exp.hoistDec) {
6424
- exp.hoistDec.children.push([...refsToDeclare].map(($6) => [",", $6]));
6621
+ exp.hoistDec.children.push([...refsToDeclare].map(($7) => [",", $7]));
6425
6622
  } else {
6426
6623
  exp.hoistDec = {
6427
6624
  type: "Declaration",
@@ -6495,9 +6692,9 @@ function unchainOptionalMemberExpression(exp, ref, innerExp) {
6495
6692
  }
6496
6693
  j++;
6497
6694
  }
6498
- let ref9;
6499
- if (ref9 = conditions.length) {
6500
- const l = ref9;
6695
+ let ref11;
6696
+ if (ref11 = conditions.length) {
6697
+ const l = ref11;
6501
6698
  const cs = flatJoin(conditions, " && ");
6502
6699
  return {
6503
6700
  ...exp,
@@ -6536,27 +6733,27 @@ function processTypes(node) {
6536
6733
  if (!unary.suffix.length) {
6537
6734
  return;
6538
6735
  }
6539
- let ref10;
6540
- let m3;
6541
- if (m3 = (ref10 = unary.suffix)[ref10.length - 1], typeof m3 === "object" && m3 != null && "token" in m3 && m3.token === "?") {
6542
- const { token } = m3;
6736
+ let ref12;
6737
+ let m4;
6738
+ if (m4 = (ref12 = unary.suffix)[ref12.length - 1], typeof m4 === "object" && m4 != null && "token" in m4 && m4.token === "?") {
6739
+ const { token } = m4;
6543
6740
  let last;
6544
6741
  let count = 0;
6545
- let ref11;
6546
- while (unary.suffix.length && (ref11 = unary.suffix)[ref11.length - 1]?.token === "?") {
6742
+ let ref13;
6743
+ while (unary.suffix.length && (ref13 = unary.suffix)[ref13.length - 1]?.token === "?") {
6547
6744
  last = unary.suffix.pop();
6548
6745
  count++;
6549
6746
  }
6550
- let ref12;
6551
- while (unary.suffix.length && (ref12 = unary.suffix)[ref12.length - 1]?.type === "NonNullAssertion") {
6747
+ let ref14;
6748
+ while (unary.suffix.length && (ref14 = unary.suffix)[ref14.length - 1]?.type === "NonNullAssertion") {
6552
6749
  unary.suffix.pop();
6553
6750
  }
6554
- let ref13;
6751
+ let ref15;
6555
6752
  if (unary.suffix.length || unary.prefix.length)
6556
- ref13 = unary;
6753
+ ref15 = unary;
6557
6754
  else
6558
- ref13 = unary.t;
6559
- const t = ref13;
6755
+ ref15 = unary.t;
6756
+ const t = ref15;
6560
6757
  if (unary.parent?.type === "TypeTuple") {
6561
6758
  if (count === 1) {
6562
6759
  unary.suffix.push(last);
@@ -6582,14 +6779,14 @@ function processTypes(node) {
6582
6779
  ]
6583
6780
  });
6584
6781
  }
6585
- } else if (typeof m3 === "object" && m3 != null && "type" in m3 && m3.type === "NonNullAssertion") {
6586
- const { type } = m3;
6587
- let ref14;
6588
- while (unary.suffix.length && (ref14 = unary.suffix)[ref14.length - 1]?.type === "NonNullAssertion") {
6782
+ } else if (typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "NonNullAssertion") {
6783
+ const { type } = m4;
6784
+ let ref16;
6785
+ while (unary.suffix.length && (ref16 = unary.suffix)[ref16.length - 1]?.type === "NonNullAssertion") {
6589
6786
  unary.suffix.pop();
6590
6787
  }
6591
- let ref15;
6592
- while (unary.suffix.length && (ref15 = unary.suffix)[ref15.length - 1]?.token === "?") {
6788
+ let ref17;
6789
+ while (unary.suffix.length && (ref17 = unary.suffix)[ref17.length - 1]?.token === "?") {
6593
6790
  unary.suffix.pop();
6594
6791
  }
6595
6792
  const t = trimFirstSpace(
@@ -6615,14 +6812,14 @@ function processTypes(node) {
6615
6812
  });
6616
6813
  }
6617
6814
  function processStatementExpressions(statements) {
6618
- gatherRecursiveAll(statements, ($7) => $7.type === "StatementExpression").forEach((_exp) => {
6815
+ gatherRecursiveAll(statements, ($8) => $8.type === "StatementExpression").forEach((_exp) => {
6619
6816
  const exp = _exp;
6620
6817
  const { statement } = exp;
6621
- let ref16;
6818
+ let ref18;
6622
6819
  switch (statement.type) {
6623
6820
  case "IfStatement": {
6624
- if (ref16 = expressionizeIfStatement(statement)) {
6625
- const expression = ref16;
6821
+ if (ref18 = expressionizeIfStatement(statement)) {
6822
+ const expression = ref18;
6626
6823
  return replaceNode(statement, expression, exp);
6627
6824
  } else {
6628
6825
  return replaceNode(statement, wrapIIFE([["", statement]]), exp);
@@ -6691,7 +6888,7 @@ function processProgram(root) {
6691
6888
  if (config2.iife || config2.repl) {
6692
6889
  rootIIFE = wrapIIFE(root.expressions, root.topLevelAwait);
6693
6890
  const newExpressions = [["", rootIIFE]];
6694
- root.children = root.children.map(($8) => $8 === root.expressions ? newExpressions : $8);
6891
+ root.children = root.children.map(($9) => $9 === root.expressions ? newExpressions : $9);
6695
6892
  root.expressions = newExpressions;
6696
6893
  }
6697
6894
  addParentPointers(root);
@@ -6731,17 +6928,17 @@ async function processProgramAsync(root) {
6731
6928
  await processComptime(statements);
6732
6929
  }
6733
6930
  function processRepl(root, rootIIFE) {
6734
- const topBlock = gatherRecursive(rootIIFE, ($9) => $9.type === "BlockStatement")[0];
6931
+ const topBlock = gatherRecursive(rootIIFE, ($10) => $10.type === "BlockStatement")[0];
6735
6932
  let i = 0;
6736
- for (let ref17 = gatherRecursiveWithinFunction(topBlock, ($10) => $10.type === "Declaration"), i4 = 0, len3 = ref17.length; i4 < len3; i4++) {
6737
- const decl = ref17[i4];
6933
+ for (let ref19 = gatherRecursiveWithinFunction(topBlock, ($11) => $11.type === "Declaration"), i5 = 0, len4 = ref19.length; i5 < len4; i5++) {
6934
+ const decl = ref19[i5];
6738
6935
  if (decl.parent === topBlock || decl.decl === "var") {
6739
6936
  decl.children.shift();
6740
6937
  root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")};`]);
6741
6938
  }
6742
6939
  }
6743
- for (let ref18 = gatherRecursive(topBlock, ($11) => $11.type === "FunctionExpression"), i5 = 0, len4 = ref18.length; i5 < len4; i5++) {
6744
- const func = ref18[i5];
6940
+ for (let ref20 = gatherRecursive(topBlock, ($12) => $12.type === "FunctionExpression"), i6 = 0, len5 = ref20.length; i6 < len5; i6++) {
6941
+ const func = ref20[i6];
6745
6942
  if (func.name && func.parent?.type === "BlockStatement") {
6746
6943
  if (func.parent === topBlock) {
6747
6944
  replaceNode(func, void 0);
@@ -6753,17 +6950,17 @@ function processRepl(root, rootIIFE) {
6753
6950
  }
6754
6951
  }
6755
6952
  }
6756
- for (let ref19 = gatherRecursiveWithinFunction(topBlock, ($12) => $12.type === "ClassExpression"), i6 = 0, len5 = ref19.length; i6 < len5; i6++) {
6757
- const classExp = ref19[i6];
6758
- let m4;
6759
- if (classExp.name && classExp.parent === topBlock || (m4 = classExp.parent, typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "ReturnStatement" && "parent" in m4 && m4.parent === topBlock)) {
6953
+ for (let ref21 = gatherRecursiveWithinFunction(topBlock, ($13) => $13.type === "ClassExpression"), i7 = 0, len6 = ref21.length; i7 < len6; i7++) {
6954
+ const classExp = ref21[i7];
6955
+ let m5;
6956
+ if (classExp.name && classExp.parent === topBlock || (m5 = classExp.parent, typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "ReturnStatement" && "parent" in m5 && m5.parent === topBlock)) {
6760
6957
  classExp.children.unshift(classExp.name, "=");
6761
6958
  root.expressions.splice(i++, 0, ["", `var ${classExp.name};`]);
6762
6959
  }
6763
6960
  }
6764
6961
  }
6765
6962
  function populateRefs(statements) {
6766
- const refNodes = gatherRecursive(statements, ($13) => $13.type === "Ref");
6963
+ const refNodes = gatherRecursive(statements, ($14) => $14.type === "Ref");
6767
6964
  if (refNodes.length) {
6768
6965
  const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
6769
6966
  const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
@@ -6786,11 +6983,11 @@ function populateRefs(statements) {
6786
6983
  function processPlaceholders(statements) {
6787
6984
  const placeholderMap = /* @__PURE__ */ new Map();
6788
6985
  const liftedIfs = /* @__PURE__ */ new Set();
6789
- gatherRecursiveAll(statements, ($14) => $14.type === "Placeholder").forEach((_exp) => {
6986
+ gatherRecursiveAll(statements, ($15) => $15.type === "Placeholder").forEach((_exp) => {
6790
6987
  const exp = _exp;
6791
6988
  let ancestor;
6792
6989
  if (exp.subtype === ".") {
6793
- ({ ancestor } = findAncestor(exp, ($15) => $15.type === "Call"));
6990
+ ({ ancestor } = findAncestor(exp, ($16) => $16.type === "Call"));
6794
6991
  ancestor = ancestor?.parent;
6795
6992
  while (ancestor?.parent?.type === "UnaryExpression" || ancestor?.parent?.type === "NewExpression") {
6796
6993
  ancestor = ancestor.parent;
@@ -6809,10 +7006,10 @@ function processPlaceholders(statements) {
6809
7006
  if (type === "IfStatement") {
6810
7007
  liftedIfs.add(ancestor2);
6811
7008
  }
6812
- let m5;
6813
7009
  let m6;
7010
+ let m7;
6814
7011
  return type === "Call" || // Block, except for if/else blocks when condition already lifted
6815
- type === "BlockStatement" && !((m5 = ancestor2.parent, typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m6 = ancestor2.parent, typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "ElseClause" && "parent" in m6 && typeof m6.parent === "object" && m6.parent != null && "type" in m6.parent && m6.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
7012
+ type === "BlockStatement" && !((m6 = ancestor2.parent, typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m7 = ancestor2.parent, typeof m7 === "object" && m7 != null && "type" in m7 && m7.type === "ElseClause" && "parent" in m7 && typeof m7.parent === "object" && m7.parent != null && "type" in m7.parent && m7.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
6816
7013
  type === "Initializer" || // Right-hand side of assignment
6817
7014
  type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
6818
7015
  }));
@@ -6888,11 +7085,11 @@ function processPlaceholders(statements) {
6888
7085
  for (const [ancestor, placeholders] of placeholderMap) {
6889
7086
  let ref = makeRef("$");
6890
7087
  let typeSuffix;
6891
- for (let i7 = 0, len6 = placeholders.length; i7 < len6; i7++) {
6892
- const placeholder = placeholders[i7];
7088
+ for (let i8 = 0, len7 = placeholders.length; i8 < len7; i8++) {
7089
+ const placeholder = placeholders[i8];
6893
7090
  typeSuffix ??= placeholder.typeSuffix;
6894
- let ref20;
6895
- replaceNode((ref20 = placeholder.children)[ref20.length - 1], ref);
7091
+ let ref22;
7092
+ replaceNode((ref22 = placeholder.children)[ref22.length - 1], ref);
6896
7093
  }
6897
7094
  const { parent } = ancestor;
6898
7095
  const body = maybeUnwrap(ancestor);
@@ -6913,16 +7110,16 @@ function processPlaceholders(statements) {
6913
7110
  }
6914
7111
  case "PipelineExpression": {
6915
7112
  const i = findChildIndex(parent, ancestor);
6916
- let ref21;
7113
+ let ref23;
6917
7114
  if (i === 1) {
6918
- ref21 = ancestor === parent.children[i];
7115
+ ref23 = ancestor === parent.children[i];
6919
7116
  } else if (i === 2) {
6920
- ref21 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
7117
+ ref23 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6921
7118
  } else {
6922
- ref21 = void 0;
7119
+ ref23 = void 0;
6923
7120
  }
6924
7121
  ;
6925
- outer = ref21;
7122
+ outer = ref23;
6926
7123
  break;
6927
7124
  }
6928
7125
  case "AssignmentExpression":
@@ -6937,9 +7134,9 @@ function processPlaceholders(statements) {
6937
7134
  fnExp = makeLeftHandSideExpression(fnExp);
6938
7135
  }
6939
7136
  replaceNode(ancestor, fnExp, parent);
6940
- let ref22;
6941
- if (ref22 = getTrimmingSpace(body)) {
6942
- const ws = ref22;
7137
+ let ref24;
7138
+ if (ref24 = getTrimmingSpace(body)) {
7139
+ const ws = ref24;
6943
7140
  inplaceInsertTrimmingSpace(body, "");
6944
7141
  inplacePrepend(ws, fnExp);
6945
7142
  }
@@ -6984,8 +7181,8 @@ function reorderBindingRestProperty(props) {
6984
7181
  }
6985
7182
  ];
6986
7183
  }
6987
- let ref23;
6988
- if (Array.isArray(rest.delim) && (ref23 = rest.delim)[ref23.length - 1]?.token === ",") {
7184
+ let ref25;
7185
+ if (Array.isArray(rest.delim) && (ref25 = rest.delim)[ref25.length - 1]?.token === ",") {
6989
7186
  rest.delim = rest.delim.slice(0, -1);
6990
7187
  rest.children = [...rest.children.slice(0, -1), rest.delim];
6991
7188
  }
@@ -7010,9 +7207,9 @@ function replaceNodes(root, predicate, replacer) {
7010
7207
  return root;
7011
7208
  }
7012
7209
  }
7013
- for (let i8 = 0, len7 = array.length; i8 < len7; i8++) {
7014
- const i = i8;
7015
- const node = array[i8];
7210
+ for (let i9 = 0, len8 = array.length; i9 < len8; i9++) {
7211
+ const i = i9;
7212
+ const node = array[i9];
7016
7213
  if (!(node != null)) {
7017
7214
  return;
7018
7215
  }
@@ -7036,9 +7233,9 @@ function replaceNodesRecursive(root, predicate, replacer) {
7036
7233
  return root;
7037
7234
  }
7038
7235
  }
7039
- for (let i9 = 0, len8 = array.length; i9 < len8; i9++) {
7040
- const i = i9;
7041
- const node = array[i9];
7236
+ for (let i10 = 0, len9 = array.length; i10 < len9; i10++) {
7237
+ const i = i10;
7238
+ const node = array[i10];
7042
7239
  if (!(node != null)) {
7043
7240
  continue;
7044
7241
  }
@@ -7456,7 +7653,7 @@ var grammar = {
7456
7653
  IgnoreColon,
7457
7654
  TryStatement,
7458
7655
  CatchClause,
7459
- CatchBind,
7656
+ CatchBinding,
7460
7657
  FinallyClause,
7461
7658
  CatchParameter,
7462
7659
  Condition,
@@ -7800,6 +7997,7 @@ var grammar = {
7800
7997
  TypeSuffix,
7801
7998
  MaybeNestedType,
7802
7999
  MaybeNestedTypePrimary,
8000
+ MaybeNestedTypeUnary,
7803
8001
  ReturnTypeSuffix,
7804
8002
  ReturnType,
7805
8003
  TypePredicate,
@@ -9858,11 +10056,12 @@ var MemberBracketContent$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(OpenBracke
9858
10056
  var ws = $3;
9859
10057
  var close = $4;
9860
10058
  if (expression.type === "SliceParameters") {
9861
- const { start, end, children } = expression;
10059
+ const { start, end, reversed, children } = expression;
9862
10060
  return {
9863
10061
  type: "SliceExpression",
9864
10062
  start,
9865
10063
  end,
10064
+ reversed,
9866
10065
  children: [
9867
10066
  { ...open, token: ".slice(" },
9868
10067
  ...children,
@@ -9879,78 +10078,57 @@ var MemberBracketContent$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(OpenBracke
9879
10078
  function MemberBracketContent(ctx, state2) {
9880
10079
  return (0, import_lib4.$EVENT)(ctx, state2, "MemberBracketContent", MemberBracketContent$0);
9881
10080
  }
9882
- var SliceParameters$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Expression, __, RangeDots, (0, import_lib4.$E)(Expression)), function($skip, $loc, $0, $1, $2, $3, $4) {
9883
- var start = $1;
9884
- var ws = $2;
9885
- var dots = $3;
9886
- var end = $4;
10081
+ var SliceParameters$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, (0, import_lib4.$E)(Expression), __, RangeDots, Loc, (0, import_lib4.$E)(Expression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10082
+ var ls = $1;
10083
+ var start = $2;
10084
+ var ws = $3;
10085
+ var dots = $4;
10086
+ var le = $5;
10087
+ var end = $6;
10088
+ const reversed = dots.increasing === false;
10089
+ const sign = reversed ? "-" : "+";
9887
10090
  let children;
10091
+ start ??= {
10092
+ $loc: ls.$loc,
10093
+ token: reversed ? "-1" : "0"
10094
+ };
10095
+ if (!end) {
10096
+ if (reversed) {
10097
+ end = {
10098
+ $loc: le.$loc,
10099
+ token: "0"
10100
+ };
10101
+ } else if (!dots.right.inclusive && !dots.triple) {
10102
+ end = {
10103
+ $loc: le.$loc,
10104
+ token: "-1"
10105
+ };
10106
+ }
10107
+ }
9888
10108
  if (!dots.left.inclusive) {
9889
- start = ["1 + ", makeLeftHandSideExpression(start)];
10109
+ start = [makeLeftHandSideExpression(start), ` ${sign} 1`];
9890
10110
  }
9891
10111
  if (end) {
9892
10112
  const inc = [];
9893
10113
  if (dots.right.inclusive) {
9894
- end = ["1 + ", makeLeftHandSideExpression(end)];
9895
- inc.push(" || 1/0");
10114
+ end = [makeLeftHandSideExpression(end), ` ${sign} 1`];
10115
+ if (!reversed)
10116
+ inc.push(" || 1/0");
9896
10117
  }
9897
10118
  children = [start, [...ws, dots.children[0], { token: ", ", $loc: dots.$loc }], [dots.children[1], end, ...inc]];
9898
10119
  } else {
9899
10120
  children = [start, ws];
9900
10121
  }
9901
- if (dots.increasing === false) {
9902
- children.push({
9903
- type: "Error",
9904
- message: "Slice range cannot be decreasing",
9905
- $loc: dots.$loc
9906
- });
9907
- }
9908
10122
  return {
9909
10123
  type: "SliceParameters",
9910
10124
  start,
9911
10125
  end,
10126
+ reversed,
9912
10127
  children
9913
10128
  };
9914
10129
  });
9915
- var SliceParameters$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, __, (0, import_lib4.$C)(DotDotDot, DotDot), Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
9916
- var l = $1;
9917
- var ws = $2;
9918
- var sep = $3;
9919
- var end = $4;
9920
- const inclusive = sep.token === "..";
9921
- const inc = [];
9922
- if (inclusive) {
9923
- end = ["1 + ", end];
9924
- inc.push(" || 1/0");
9925
- }
9926
- const start = {
9927
- $loc: l.$loc,
9928
- token: "0"
9929
- };
9930
- return {
9931
- type: "SliceParameters",
9932
- start,
9933
- end,
9934
- children: [start, [...ws, { ...sep, token: ", " }], [end, ...inc]]
9935
- };
9936
- });
9937
- var SliceParameters$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, __, (0, import_lib4.$C)(DotDot, DotDotDot), (0, import_lib4.$Y)((0, import_lib4.$S)(__, CloseBracket))), function($skip, $loc, $0, $1, $2, $3, $4) {
9938
- var l = $1;
9939
- var ws = $2;
9940
- const start = {
9941
- $loc: l.$loc,
9942
- token: "0"
9943
- };
9944
- return {
9945
- type: "SliceParameters",
9946
- start,
9947
- end: void 0,
9948
- children: [start, ws]
9949
- };
9950
- });
9951
- var SliceParameters$$ = [SliceParameters$0, SliceParameters$1, SliceParameters$2];
9952
10130
  function SliceParameters(ctx, state2) {
9953
- return (0, import_lib4.$EVENT_C)(ctx, state2, "SliceParameters", SliceParameters$$);
10131
+ return (0, import_lib4.$EVENT)(ctx, state2, "SliceParameters", SliceParameters$0);
9954
10132
  }
9955
10133
  var AccessStart$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(PropertyAccessModifier), Dot, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($R11, "AccessStart /[.\\s]/"))), function($skip, $loc, $0, $1, $2, $3) {
9956
10134
  var modifier = $1;
@@ -11619,6 +11797,7 @@ var RangeDots$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(DotDotDot), function(
11619
11797
  left: { inclusive: true, raw: "" },
11620
11798
  right: { inclusive: false, raw: "." },
11621
11799
  increasing: void 0,
11800
+ triple: true,
11622
11801
  children: []
11623
11802
  };
11624
11803
  });
@@ -13896,12 +14075,14 @@ var CaseClause$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(Default, ImpliedColo
13896
14075
  };
13897
14076
  });
13898
14077
  var CaseClause$4 = (0, import_lib4.$TS)((0, import_lib4.$S)(Else, ImpliedColon, (0, import_lib4.$C)(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
14078
+ var e = $1;
14079
+ var colon = $2;
13899
14080
  var block = $3;
13900
- $1.token = "default";
14081
+ e = { ...e, token: "default" };
13901
14082
  return {
13902
14083
  type: "DefaultClause",
13903
14084
  block,
13904
- children: $0
14085
+ children: [e, colon, block]
13905
14086
  };
13906
14087
  });
13907
14088
  var CaseClause$$ = [CaseClause$0, CaseClause$1, CaseClause$2, CaseClause$3, CaseClause$4];
@@ -13972,36 +14153,56 @@ var IgnoreColon$0 = (0, import_lib4.$TV)((0, import_lib4.$E)((0, import_lib4.$S)
13972
14153
  function IgnoreColon(ctx, state2) {
13973
14154
  return (0, import_lib4.$EVENT)(ctx, state2, "IgnoreColon", IgnoreColon$0);
13974
14155
  }
13975
- var TryStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Try, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($L16, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib4.$E)(CatchClause), (0, import_lib4.$E)(ElseClause), (0, import_lib4.$E)(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
14156
+ var TryStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Try, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($L16, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib4.$Q)(CatchClause), (0, import_lib4.$E)(ElseClause), (0, import_lib4.$E)(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
13976
14157
  return processTryBlock($0);
13977
14158
  });
13978
14159
  function TryStatement(ctx, state2) {
13979
14160
  return (0, import_lib4.$EVENT)(ctx, state2, "TryStatement", TryStatement$0);
13980
14161
  }
13981
- var CatchClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Catch, (0, import_lib4.$E)(CatchBind), (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
14162
+ var CatchClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Catch, (0, import_lib4.$E)(CatchBinding), (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
14163
+ var binding = $3;
13982
14164
  var block = $4;
13983
14165
  return {
13984
14166
  type: "CatchClause",
13985
14167
  children: $0,
13986
- block
14168
+ block,
14169
+ binding
13987
14170
  };
13988
14171
  });
13989
14172
  function CatchClause(ctx, state2) {
13990
14173
  return (0, import_lib4.$EVENT)(ctx, state2, "CatchClause", CatchClause$0);
13991
14174
  }
13992
- var CatchBind$0 = (0, import_lib4.$S)((0, import_lib4.$E)(_), OpenParen, __, CatchParameter, __, CloseParen);
13993
- var CatchBind$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(_, InsertOpenParen, (0, import_lib4.$N)(EOS), ForbidIndentedApplication, (0, import_lib4.$E)(CatchParameter), RestoreIndentedApplication, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
14175
+ var CatchBinding$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), OpenParen, __, AllowAll, (0, import_lib4.$E)(CatchParameter), RestoreAll, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
14176
+ var ws1 = $1;
14177
+ var open = $2;
14178
+ var ws2 = $3;
14179
+ var parameter = $5;
14180
+ var ws3 = $7;
14181
+ var close = $8;
14182
+ if (!parameter)
14183
+ return $skip;
14184
+ return {
14185
+ type: "CatchBinding",
14186
+ parameter,
14187
+ children: [ws1, open, ws2, parameter, ws3, close]
14188
+ };
14189
+ });
14190
+ var CatchBinding$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(_, InsertOpenParen, (0, import_lib4.$N)(EOS), ForbidIndentedApplication, (0, import_lib4.$E)(CatchParameter), RestoreIndentedApplication, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
13994
14191
  var ws = $1;
13995
14192
  var open = $2;
13996
- var param = $5;
14193
+ var parameter = $5;
13997
14194
  var close = $7;
13998
- if (!param)
14195
+ if (!parameter)
13999
14196
  return $skip;
14000
- return [ws, open, param, close];
14197
+ return {
14198
+ type: "CatchBinding",
14199
+ parameter,
14200
+ children: [ws, open, parameter, close]
14201
+ };
14001
14202
  });
14002
- var CatchBind$$ = [CatchBind$0, CatchBind$1];
14003
- function CatchBind(ctx, state2) {
14004
- return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchBind", CatchBind$$);
14203
+ var CatchBinding$$ = [CatchBinding$0, CatchBinding$1];
14204
+ function CatchBinding(ctx, state2) {
14205
+ return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchBinding", CatchBinding$$);
14005
14206
  }
14006
14207
  var FinallyClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Finally, (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
14007
14208
  var block = $3;
@@ -14014,9 +14215,34 @@ var FinallyClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$
14014
14215
  function FinallyClause(ctx, state2) {
14015
14216
  return (0, import_lib4.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
14016
14217
  }
14017
- var CatchParameter$0 = (0, import_lib4.$S)(BindingIdentifier, (0, import_lib4.$E)(TypeSuffix));
14018
- var CatchParameter$1 = (0, import_lib4.$S)(BindingPattern, (0, import_lib4.$E)(TypeSuffix));
14019
- var CatchParameter$$ = [CatchParameter$0, CatchParameter$1];
14218
+ var CatchParameter$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(BindingIdentifier, (0, import_lib4.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
14219
+ var binding = $1;
14220
+ var typeSuffix = $2;
14221
+ return {
14222
+ type: "CatchParameter",
14223
+ binding,
14224
+ typeSuffix,
14225
+ children: $0
14226
+ };
14227
+ });
14228
+ var CatchParameter$1 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
14229
+ var binding = $1;
14230
+ var typeSuffix = $2;
14231
+ return {
14232
+ type: "CatchParameter",
14233
+ binding,
14234
+ typeSuffix,
14235
+ children: [binding, typeSuffix]
14236
+ };
14237
+ });
14238
+ var CatchParameter$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
14239
+ return {
14240
+ type: "CatchPattern",
14241
+ children: $0,
14242
+ patterns: $1
14243
+ };
14244
+ });
14245
+ var CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
14020
14246
  function CatchParameter(ctx, state2) {
14021
14247
  return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchParameter", CatchParameter$$);
14022
14248
  }
@@ -17422,6 +17648,19 @@ var MaybeNestedTypePrimary$$ = [MaybeNestedTypePrimary$0, MaybeNestedTypePrimary
17422
17648
  function MaybeNestedTypePrimary(ctx, state2) {
17423
17649
  return (0, import_lib4.$EVENT_C)(ctx, state2, "MaybeNestedTypePrimary", MaybeNestedTypePrimary$$);
17424
17650
  }
17651
+ var MaybeNestedTypeUnary$0 = NestedTypeBulletedTuple;
17652
+ var MaybeNestedTypeUnary$1 = NestedInterfaceBlock;
17653
+ var MaybeNestedTypeUnary$2 = NestedTypeBinaryChain;
17654
+ var MaybeNestedTypeUnary$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(PushIndent, (0, import_lib4.$E)((0, import_lib4.$S)(Nested, Type)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
17655
+ if (!$2)
17656
+ return $skip;
17657
+ return $2;
17658
+ });
17659
+ var MaybeNestedTypeUnary$4 = (0, import_lib4.$S)(NotDedented, TypeUnary);
17660
+ var MaybeNestedTypeUnary$$ = [MaybeNestedTypeUnary$0, MaybeNestedTypeUnary$1, MaybeNestedTypeUnary$2, MaybeNestedTypeUnary$3, MaybeNestedTypeUnary$4];
17661
+ function MaybeNestedTypeUnary(ctx, state2) {
17662
+ return (0, import_lib4.$EVENT_C)(ctx, state2, "MaybeNestedTypeUnary", MaybeNestedTypeUnary$$);
17663
+ }
17425
17664
  var ReturnTypeSuffix$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), (0, import_lib4.$E)(QuestionMark), (0, import_lib4.$E)(_), Colon, ReturnType), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17426
17665
  var optional = $2;
17427
17666
  var t = $5;
@@ -17476,7 +17715,7 @@ var Type$0 = TypeWithPostfix;
17476
17715
  function Type(ctx, state2) {
17477
17716
  return (0, import_lib4.$EVENT)(ctx, state2, "Type", Type$0);
17478
17717
  }
17479
- var TypeBinary$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __)), TypeUnary, (0, import_lib4.$Q)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __, TypeUnary))), function($skip, $loc, $0, $1, $2, $3) {
17718
+ var TypeBinary$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __)), TypeUnary, (0, import_lib4.$Q)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, MaybeNestedTypeUnary))), function($skip, $loc, $0, $1, $2, $3) {
17480
17719
  var optionalPrefix = $1;
17481
17720
  var t = $2;
17482
17721
  var ops = $3;