@danielx/civet 0.7.7 → 0.7.8

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.js CHANGED
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // ../Hera/dist/machine.js
33
+ // node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js
34
34
  var require_machine = __commonJS({
35
- "../Hera/dist/machine.js"(exports2, module2) {
35
+ "node_modules/.pnpm/@danielx+hera@0.8.13/node_modules/@danielx/hera/dist/machine.js"(exports2, module2) {
36
36
  "use strict";
37
37
  var __defProp2 = Object.defineProperty;
38
38
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -550,6 +550,7 @@ __export(lib_exports, {
550
550
  processForInOf: () => processForInOf,
551
551
  processProgram: () => processProgram,
552
552
  processProgramAsync: () => processProgramAsync,
553
+ processTryBlock: () => processTryBlock,
553
554
  processUnaryExpression: () => processUnaryExpression,
554
555
  quoteString: () => quoteString,
555
556
  reorderBindingRestProperty: () => reorderBindingRestProperty,
@@ -1571,7 +1572,6 @@ function isExit(node) {
1571
1572
  if (!(node != null)) {
1572
1573
  return false;
1573
1574
  }
1574
- let ref2;
1575
1575
  switch (node.type) {
1576
1576
  case "ReturnStatement":
1577
1577
  case "ThrowStatement":
@@ -1583,13 +1583,10 @@ function isExit(node) {
1583
1583
  return isExit(node.then) && isExit(node.else?.block);
1584
1584
  }
1585
1585
  case "BlockStatement": {
1586
- return isExit((ref2 = node.expressions)[ref2.length - 1]?.[1]);
1586
+ return node.expressions.some((s) => isExit(s[1]));
1587
1587
  }
1588
1588
  case "IterationStatement": {
1589
- return node.condition?.type === "ParenthesizedExpression" && node.condition.expression?.type === "Literal" && node.condition.expression?.raw === "true" && gatherRecursiveWithinFunction(
1590
- node.block,
1591
- ({ type }) => type === "BreakStatement"
1592
- ).length === 0;
1589
+ return node.condition?.type === "ParenthesizedExpression" && node.condition.expression?.type === "Literal" && node.condition.expression?.raw === "true" && gatherRecursiveWithinFunction(node.block, ($) => $.type === "BreakStatement").length === 0;
1593
1590
  }
1594
1591
  default: {
1595
1592
  return false;
@@ -1890,8 +1887,8 @@ function updateParentPointers(node, parent, depth = 1) {
1890
1887
  node.parent = parent;
1891
1888
  }
1892
1889
  if (depth && isParent(node)) {
1893
- for (let ref3 = node.children, i3 = 0, len3 = ref3.length; i3 < len3; i3++) {
1894
- const child = ref3[i3];
1890
+ for (let ref2 = node.children, i3 = 0, len3 = ref2.length; i3 < len3; i3++) {
1891
+ const child = ref2[i3];
1895
1892
  updateParentPointers(child, node, depth - 1);
1896
1893
  }
1897
1894
  }
@@ -2963,6 +2960,10 @@ function aggregateDuplicateBindings(bindings) {
2963
2960
  const propsGroupedByName = /* @__PURE__ */ new Map();
2964
2961
  for (const p of props) {
2965
2962
  const { name, value } = p;
2963
+ let m;
2964
+ if (m = value?.type, m === "ArrayBindingPattern" || m === "ObjectBindingPattern") {
2965
+ continue;
2966
+ }
2966
2967
  const key = value?.name || name?.name || name;
2967
2968
  if (propsGroupedByName.has(key)) {
2968
2969
  propsGroupedByName.get(key).push(p);
@@ -3211,7 +3212,7 @@ function processDeclarationConditionStatement(s) {
3211
3212
  return;
3212
3213
  }
3213
3214
  let { expression } = condition;
3214
- if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && len2(expression.children, 2) && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
3215
+ if (expression && typeof expression === "object" && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && len2(expression.children, 2) && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
3215
3216
  const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
3216
3217
  const type = [type1, type2];
3217
3218
  expression = expression2;
@@ -3228,40 +3229,99 @@ function processDeclarationConditionStatement(s) {
3228
3229
  }
3229
3230
  });
3230
3231
  if (conditions.length) {
3231
- condition.children.unshift("(");
3232
- conditions.forEach((c) => {
3233
- return condition.children.push(" && ", c);
3234
- });
3235
- condition.children.push(")");
3232
+ if (s.negated) {
3233
+ let m;
3234
+ if (!(m = condition.expression, typeof m === "object" && m != null && "type" in m && m.type === "UnaryExpression" && "children" in m && Array.isArray(m.children) && len2(m.children, 2) && m.children[0] === "!" && typeof m.children[1] === "object" && m.children[1] != null && "type" in m.children[1] && m.children[1].type === "ParenthesizedExpression")) {
3235
+ console.log(condition.expression);
3236
+ throw new Error("Unsupported negated condition");
3237
+ }
3238
+ const { children } = condition.expression.children[1];
3239
+ const close = children.pop();
3240
+ conditions.forEach((c) => {
3241
+ return children.push(" && ", c);
3242
+ });
3243
+ children.push(close);
3244
+ } else {
3245
+ condition.children.unshift("(");
3246
+ conditions.forEach((c) => {
3247
+ return condition.children.push(" && ", c);
3248
+ });
3249
+ condition.children.push(")");
3250
+ }
3236
3251
  }
3237
3252
  }
3253
+ const { blockPrefix } = condition.expression;
3254
+ if (s.negated && blockPrefix && (s.type === "IfStatement" && isExit(s.then) || s.type === "IterationStatement")) {
3255
+ const { ancestor, child } = findAncestor(
3256
+ s,
3257
+ (a) => a.type === "BlockStatement"
3258
+ );
3259
+ if (!(ancestor != null)) {
3260
+ throw new Error("Couldn't find block for postfix declaration");
3261
+ }
3262
+ const index = findChildIndex(ancestor.expressions, child);
3263
+ if (index < 0) {
3264
+ throw new Error("Couldn't find where in block to put postfix declaration");
3265
+ }
3266
+ ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
3267
+ updateParentPointers(ancestor);
3268
+ braceBlock(ancestor);
3269
+ let ref1;
3270
+ switch (s.type) {
3271
+ case "IfStatement": {
3272
+ if (ref1 = s.else?.block) {
3273
+ const elseBlock = ref1;
3274
+ if (elseBlock.bare && !elseBlock.semicolon) {
3275
+ elseBlock.children.push(elseBlock.semicolon = ";");
3276
+ }
3277
+ ancestor.expressions.splice(index + 1 + blockPrefix.length, 0, ["", elseBlock]);
3278
+ s.children = s.children.filter((a1) => a1 !== s.else);
3279
+ s.else = void 0;
3280
+ }
3281
+ const block = s.then;
3282
+ if (block.bare && !block.semicolon) {
3283
+ block.children.push(block.semicolon = ";");
3284
+ }
3285
+ ;
3286
+ break;
3287
+ }
3288
+ }
3289
+ return;
3290
+ }
3238
3291
  switch (s.type) {
3239
3292
  case "IfStatement": {
3240
3293
  const { else: e } = s;
3241
- const block = blockWithPrefix(condition.expression.blockPrefix, s.then);
3242
- if (block.bare && e && !block.semicolon) {
3243
- block.children.push(block.semicolon = ";");
3244
- }
3245
- s.children = s.children.map((c) => {
3246
- if (c === s.then) {
3247
- return block;
3248
- } else {
3249
- return c;
3294
+ if (s.negated) {
3295
+ if (e != null) {
3296
+ const block = blockWithPrefix(blockPrefix, e.block);
3297
+ e.children = e.children.map(($1) => $1 === e.block ? block : $1);
3298
+ e.block = block;
3299
+ updateParentPointers(e);
3250
3300
  }
3251
- });
3252
- s.then = block;
3253
- updateParentPointers(block, s);
3301
+ } else {
3302
+ const block = blockWithPrefix(blockPrefix, s.then);
3303
+ if (block.bare && e && !block.semicolon) {
3304
+ block.children.push(block.semicolon = ";");
3305
+ }
3306
+ s.children = s.children.map(($2) => $2 === s.then ? block : $2);
3307
+ s.then = block;
3308
+ updateParentPointers(s);
3309
+ }
3310
+ ;
3254
3311
  break;
3255
3312
  }
3256
3313
  case "IterationStatement": {
3314
+ if (!blockPrefix) {
3315
+ return;
3316
+ }
3257
3317
  const { children, block } = s;
3258
- const newBlock = blockWithPrefix(condition.expression.blockPrefix, block);
3259
- s.children = children.map((c) => c?.type === "BlockStatement" ? newBlock : c);
3260
- updateParentPointers(newBlock, s);
3318
+ const newBlock = blockWithPrefix(blockPrefix, block);
3319
+ s.children = children.map(($3) => $3 === block ? newBlock : $3);
3320
+ updateParentPointers(s);
3261
3321
  break;
3262
3322
  }
3263
3323
  case "SwitchStatement": {
3264
- const { blockPrefix, ref: ref2, statementDeclaration } = condition.expression;
3324
+ const { ref: ref2, statementDeclaration } = condition.expression;
3265
3325
  if (!blockPrefix) {
3266
3326
  return;
3267
3327
  }
@@ -3284,7 +3344,7 @@ function processDeclarationConditionStatement(s) {
3284
3344
  const block = makeEmptyBlock();
3285
3345
  replaceBlockExpression(s.parent, s, block);
3286
3346
  block.expressions.push(["", s]);
3287
- s.children.splice(s.children.findIndex(($1) => $1.token === "switch"), 0, blockPrefix);
3347
+ s.children.splice(s.children.findIndex(($4) => $4.token === "switch"), 0, blockPrefix);
3288
3348
  s.parent = block;
3289
3349
  } else {
3290
3350
  const block = blockWithPrefix([["", [{
@@ -3314,20 +3374,20 @@ function dynamizeImportDeclaration(decl) {
3314
3374
  const { imports } = decl;
3315
3375
  let { star, binding, specifiers } = imports;
3316
3376
  const justDefault = binding && !specifiers && !star;
3317
- let ref1;
3377
+ let ref2;
3318
3378
  {
3319
3379
  if (binding) {
3320
3380
  if (specifiers) {
3321
- ref1 = makeRef();
3381
+ ref2 = makeRef();
3322
3382
  } else {
3323
- ref1 = binding;
3383
+ ref2 = binding;
3324
3384
  }
3325
3385
  } else {
3326
- ref1 = convertNamedImportsToObject(imports, true);
3386
+ ref2 = convertNamedImportsToObject(imports, true);
3327
3387
  }
3328
3388
  }
3329
3389
  ;
3330
- const pattern = ref1;
3390
+ const pattern = ref2;
3331
3391
  const c = "const";
3332
3392
  const expression = [
3333
3393
  justDefault ? "(" : void 0,
@@ -4763,6 +4823,67 @@ function handleThisPrivateShorthands(value) {
4763
4823
  }
4764
4824
  return [value, value.thisShorthand];
4765
4825
  }
4826
+ function processTryBlock($0) {
4827
+ let [t, , b, c, e, f] = $0;
4828
+ if (!c && (e || !f)) {
4829
+ const emptyCatchBlock = makeEmptyBlock();
4830
+ c = {
4831
+ type: "CatchClause",
4832
+ children: [" ", "catch(e) ", emptyCatchBlock],
4833
+ block: emptyCatchBlock
4834
+ };
4835
+ }
4836
+ let hoistDec;
4837
+ if (e) {
4838
+ c = c;
4839
+ const ok = makeRef("ok");
4840
+ hoistDec = {
4841
+ type: "Declaration",
4842
+ children: ["let ", ok, " = true"],
4843
+ names: []
4844
+ };
4845
+ replaceNode(
4846
+ c.block,
4847
+ blockWithPrefix([["", "ok = false"]], c.block),
4848
+ c
4849
+ );
4850
+ const condition = {
4851
+ type: "ParenthesizedExpression",
4852
+ children: ["(", ok, ")"],
4853
+ expression: ok
4854
+ };
4855
+ const i = makeNode({
4856
+ type: "IfStatement",
4857
+ children: ["if", condition, e.block],
4858
+ condition,
4859
+ then: e.block,
4860
+ else: void 0
4861
+ });
4862
+ if (!f) {
4863
+ const emptyFinallyBlock = makeEmptyBlock();
4864
+ f = {
4865
+ type: "FinallyClause",
4866
+ children: [" ", "finally ", emptyFinallyBlock],
4867
+ block: emptyFinallyBlock
4868
+ };
4869
+ }
4870
+ replaceNode(
4871
+ f.block,
4872
+ blockWithPrefix([["", i]], f.block),
4873
+ f
4874
+ );
4875
+ }
4876
+ const blocks = [b];
4877
+ if (c) {
4878
+ blocks.push(c.block);
4879
+ }
4880
+ return {
4881
+ type: "TryStatement",
4882
+ blocks,
4883
+ children: [t, b, c, f],
4884
+ hoistDec
4885
+ };
4886
+ }
4766
4887
  function processCallMemberExpression(node) {
4767
4888
  const { children } = node;
4768
4889
  if (Array.isArray(children) && children.length >= 2 && typeof children[0] === "object" && children[0] != null && "parenthesizedOp" in children[0] && typeof children[0].parenthesizedOp === "object" && children[0].parenthesizedOp != null && "token" in children[0].parenthesizedOp && typeof children[1] === "object" && children[1] != null && "type" in children[1] && children[1].type === "Call") {
@@ -5504,25 +5625,29 @@ function processStatementExpressions(statements) {
5504
5625
  }
5505
5626
  function processNegativeIndexAccess(statements) {
5506
5627
  gatherRecursiveAll(statements, (n) => n.type === "NegativeIndex").forEach((exp) => {
5507
- const { parent } = exp;
5508
- const index = parent.children.indexOf(exp);
5628
+ const { children } = exp.parent;
5629
+ let start = 0;
5630
+ while (start < children.length && isWhitespaceOrEmpty(children[start])) {
5631
+ start++;
5632
+ }
5633
+ const index = children.indexOf(exp);
5509
5634
  let ref, subexp;
5510
- if (index === 1) {
5511
- const child = parent.children[0];
5635
+ if (index === start + 1) {
5636
+ const child = children[start];
5512
5637
  ref = maybeRef(child);
5513
5638
  if (ref !== child) {
5514
- subexp = parent.children.splice(0, 1);
5639
+ subexp = children.splice(start, 1);
5515
5640
  }
5516
- } else if (index > 1) {
5641
+ } else if (index > start + 1) {
5517
5642
  ref = makeRef();
5518
- subexp = parent.children.splice(0, index);
5643
+ subexp = children.splice(start, index);
5519
5644
  } else {
5520
5645
  throw new Error("Invalid parse tree for negative index access");
5521
5646
  }
5522
5647
  if (subexp) {
5523
5648
  const { hoistDec, refAssignment } = makeRefAssignment(ref, subexp);
5524
5649
  exp.hoistDec = hoistDec;
5525
- parent.children.unshift(makeLeftHandSideExpression(refAssignment));
5650
+ children.splice(start, 0, makeLeftHandSideExpression(refAssignment));
5526
5651
  }
5527
5652
  return exp.len.children = [
5528
5653
  ref,
@@ -5595,6 +5720,7 @@ function populateRefs(statements) {
5595
5720
  }
5596
5721
  function processPlaceholders(statements) {
5597
5722
  const placeholderMap = /* @__PURE__ */ new Map();
5723
+ const liftedIfs = /* @__PURE__ */ new Set();
5598
5724
  gatherRecursiveAll(statements, ($3) => $3.type === "Placeholder").forEach((_exp) => {
5599
5725
  const exp = _exp;
5600
5726
  let ancestor;
@@ -5615,9 +5741,15 @@ function processPlaceholders(statements) {
5615
5741
  let child;
5616
5742
  ({ ancestor, child } = findAncestor(exp, (ancestor2, child2) => {
5617
5743
  const { type } = ancestor2;
5618
- return type === "Call" || type === "BlockStatement" || type === "PipelineExpression" || // Declaration
5744
+ if (type === "IfStatement") {
5745
+ liftedIfs.add(ancestor2);
5746
+ }
5747
+ let m;
5748
+ let m1;
5749
+ return type === "Call" || // Block, except for if/else blocks when condition already lifted
5750
+ type === "BlockStatement" && !((m = ancestor2.parent, typeof m === "object" && m != null && "type" in m && m.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m1 = ancestor2.parent, typeof m1 === "object" && m1 != null && "type" in m1 && m1.type === "ElseClause" && "parent" in m1 && typeof m1.parent === "object" && m1.parent != null && "type" in m1.parent && m1.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
5619
5751
  type === "Initializer" || // Right-hand side of assignment
5620
- type === "AssignmentExpression" && ancestor2.expression === child2 || type === "ReturnStatement" || type === "YieldExpression";
5752
+ type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
5621
5753
  }));
5622
5754
  switch (ancestor?.type) {
5623
5755
  case "Call": {
@@ -5985,7 +6117,7 @@ var grammar = {
5985
6117
  PrimaryExpression,
5986
6118
  ParenthesizedExpression,
5987
6119
  Placeholder,
5988
- AmpersandTypeSuffix,
6120
+ PlaceholderTypeSuffix,
5989
6121
  ClassDeclaration,
5990
6122
  ClassExpression,
5991
6123
  ClassBinding,
@@ -6191,7 +6323,6 @@ var grammar = {
6191
6323
  IfStatement,
6192
6324
  ElseClause,
6193
6325
  IfClause,
6194
- UnlessClause,
6195
6326
  IterationStatement,
6196
6327
  _IterationStatement,
6197
6328
  IterationExpression,
@@ -7856,15 +7987,17 @@ var ParenthesizedExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(OpenPar
7856
7987
  function ParenthesizedExpression(ctx, state2) {
7857
7988
  return (0, import_lib3.$EVENT)(ctx, state2, "ParenthesizedExpression", ParenthesizedExpression$0);
7858
7989
  }
7859
- var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.])/"))), function($skip, $loc, $0, $1, $2) {
7990
+ var Placeholder$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Dot, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R6, "Placeholder /(?:\\p{ID_Continue}|[\\u200C\\u200D$.])/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
7860
7991
  var dot = $1;
7992
+ var typeSuffix = $3;
7861
7993
  return {
7862
7994
  type: "Placeholder",
7863
7995
  subtype: ".",
7996
+ typeSuffix,
7864
7997
  children: [dot]
7865
7998
  };
7866
7999
  });
7867
- var Placeholder$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(Ampersand, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R7, "Placeholder /[&=]/")), (0, import_lib3.$E)(AmpersandTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
8000
+ var Placeholder$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(Ampersand, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($R7, "Placeholder /[&=]/")), (0, import_lib3.$E)(PlaceholderTypeSuffix)), function($skip, $loc, $0, $1, $2, $3) {
7868
8001
  var amp = $1;
7869
8002
  var typeSuffix = $3;
7870
8003
  return {
@@ -7885,11 +8018,11 @@ var Placeholder$$ = [Placeholder$0, Placeholder$1, Placeholder$2];
7885
8018
  function Placeholder(ctx, state2) {
7886
8019
  return (0, import_lib3.$EVENT_C)(ctx, state2, "Placeholder", Placeholder$$);
7887
8020
  }
7888
- var AmpersandTypeSuffix$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$Y)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$E)(QuestionMark), (0, import_lib3.$E)(_), Colon)), TypeSuffix), function(value) {
8021
+ var PlaceholderTypeSuffix$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$Y)((0, import_lib3.$S)((0, import_lib3.$E)(QuestionMark), Colon)), TypeSuffix), function(value) {
7889
8022
  return value[1];
7890
8023
  });
7891
- function AmpersandTypeSuffix(ctx, state2) {
7892
- return (0, import_lib3.$EVENT)(ctx, state2, "AmpersandTypeSuffix", AmpersandTypeSuffix$0);
8024
+ function PlaceholderTypeSuffix(ctx, state2) {
8025
+ return (0, import_lib3.$EVENT)(ctx, state2, "PlaceholderTypeSuffix", PlaceholderTypeSuffix$0);
7893
8026
  }
7894
8027
  var ClassDeclaration$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ClassExpression), function($skip, $loc, $0, $1) {
7895
8028
  if ($1.id)
@@ -8103,7 +8236,8 @@ var ClassElement$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(Static, BracedBloc
8103
8236
  children: $0
8104
8237
  };
8105
8238
  });
8106
- var ClassElement$$ = [ClassElement$0, ClassElement$1];
8239
+ var ClassElement$2 = EmptyStatement;
8240
+ var ClassElement$$ = [ClassElement$0, ClassElement$1, ClassElement$2];
8107
8241
  function ClassElement(ctx, state2) {
8108
8242
  return (0, import_lib3.$EVENT_C)(ctx, state2, "ClassElement", ClassElement$$);
8109
8243
  }
@@ -10687,18 +10821,7 @@ var ComputedPropertyName$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpen
10687
10821
  implicit: true
10688
10822
  };
10689
10823
  });
10690
- var ComputedPropertyName$3 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$Y)((0, import_lib3.$EXPECT)($L7, 'ComputedPropertyName "."')), InsertOpenBracket, Placeholder, InsertCloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
10691
- var open = $2;
10692
- var expression = $3;
10693
- var close = $4;
10694
- return {
10695
- type: "ComputedPropertyName",
10696
- expression,
10697
- children: [open, expression, close],
10698
- implicit: true
10699
- };
10700
- });
10701
- var ComputedPropertyName$$ = [ComputedPropertyName$0, ComputedPropertyName$1, ComputedPropertyName$2, ComputedPropertyName$3];
10824
+ var ComputedPropertyName$$ = [ComputedPropertyName$0, ComputedPropertyName$1, ComputedPropertyName$2];
10702
10825
  function ComputedPropertyName(ctx, state2) {
10703
10826
  return (0, import_lib3.$EVENT_C)(ctx, state2, "ComputedPropertyName", ComputedPropertyName$$);
10704
10827
  }
@@ -11490,9 +11613,8 @@ function PostfixStatement(ctx, state2) {
11490
11613
  var _PostfixStatement$0 = ForClause;
11491
11614
  var _PostfixStatement$1 = IfClause;
11492
11615
  var _PostfixStatement$2 = LoopClause;
11493
- var _PostfixStatement$3 = UnlessClause;
11494
- var _PostfixStatement$4 = WhileClause;
11495
- var _PostfixStatement$$ = [_PostfixStatement$0, _PostfixStatement$1, _PostfixStatement$2, _PostfixStatement$3, _PostfixStatement$4];
11616
+ var _PostfixStatement$3 = WhileClause;
11617
+ var _PostfixStatement$$ = [_PostfixStatement$0, _PostfixStatement$1, _PostfixStatement$2, _PostfixStatement$3];
11496
11618
  function _PostfixStatement(ctx, state2) {
11497
11619
  return (0, import_lib3.$EVENT_C)(ctx, state2, "_PostfixStatement", _PostfixStatement$$);
11498
11620
  }
@@ -11572,7 +11694,7 @@ var LabelledItem$$ = [LabelledItem$0, LabelledItem$1];
11572
11694
  function LabelledItem(ctx, state2) {
11573
11695
  return (0, import_lib3.$EVENT_C)(ctx, state2, "LabelledItem", LabelledItem$$);
11574
11696
  }
11575
- var IfStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(IfClause, UnlessClause), BlockOrEmpty, (0, import_lib3.$E)(ElseClause)), function($skip, $loc, $0, $1, $2, $3) {
11697
+ var IfStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(IfClause, BlockOrEmpty, (0, import_lib3.$E)(ElseClause)), function($skip, $loc, $0, $1, $2, $3) {
11576
11698
  var clause = $1;
11577
11699
  var block = $2;
11578
11700
  var e = $3;
@@ -11580,6 +11702,7 @@ var IfStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)
11580
11702
  type: "IfStatement",
11581
11703
  children: [...clause.children, block, e],
11582
11704
  condition: clause.condition,
11705
+ negated: clause.negated,
11583
11706
  then: block,
11584
11707
  else: e
11585
11708
  };
@@ -11594,33 +11717,24 @@ var ElseClause$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$C)(N
11594
11717
  function ElseClause(ctx, state2) {
11595
11718
  return (0, import_lib3.$EVENT)(ctx, state2, "ElseClause", ElseClause$0);
11596
11719
  }
11597
- var IfClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(If, Condition), function($skip, $loc, $0, $1, $2) {
11598
- var condition = $2;
11720
+ var IfClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(If, Unless), (0, import_lib3.$E)(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
11721
+ var kind = $1;
11722
+ var ws = $2;
11723
+ var condition = $3;
11724
+ if (kind.negated) {
11725
+ kind = { ...kind, token: "if" };
11726
+ condition = negateCondition(condition);
11727
+ }
11599
11728
  return {
11600
11729
  type: "IfStatement",
11601
- children: $0,
11602
- condition
11730
+ children: [kind, ws, condition],
11731
+ condition,
11732
+ negated: kind.negated
11603
11733
  };
11604
11734
  });
11605
11735
  function IfClause(ctx, state2) {
11606
11736
  return (0, import_lib3.$EVENT)(ctx, state2, "IfClause", IfClause$0);
11607
11737
  }
11608
- var UnlessClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Unless, Condition), function($skip, $loc, $0, $1, $2) {
11609
- var kind = $1;
11610
- var condition = $2;
11611
- kind = { ...kind, token: "if" };
11612
- kind.token += getTrimmingSpace(condition);
11613
- condition = insertTrimmingSpace(condition, "");
11614
- condition = negateCondition(condition);
11615
- return {
11616
- type: "IfStatement",
11617
- children: [kind, condition],
11618
- condition
11619
- };
11620
- });
11621
- function UnlessClause(ctx, state2) {
11622
- return (0, import_lib3.$EVENT)(ctx, state2, "UnlessClause", UnlessClause$0);
11623
- }
11624
11738
  var IterationStatement$0 = (0, import_lib3.$T)((0, import_lib3.$S)((0, import_lib3.$EXPECT)($R25, "IterationStatement /(?=loop|comptime|do|for|until|while)/"), _IterationStatement), function(value) {
11625
11739
  return value[1];
11626
11740
  });
@@ -11750,7 +11864,7 @@ var WhileClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)
11750
11864
  var kind = $1;
11751
11865
  var ws = $2;
11752
11866
  var condition = $3;
11753
- if (kind.token === "until") {
11867
+ if (kind.negated) {
11754
11868
  kind = { ...kind, token: "while" };
11755
11869
  condition = negateCondition(condition);
11756
11870
  }
@@ -11758,7 +11872,8 @@ var WhileClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)
11758
11872
  type: "IterationStatement",
11759
11873
  subtype: kind.token,
11760
11874
  children: [kind, ws, condition],
11761
- condition
11875
+ condition,
11876
+ negated: kind.negated
11762
11877
  };
11763
11878
  });
11764
11879
  function WhileClause(ctx, state2) {
@@ -12233,32 +12348,8 @@ var IgnoreColon$0 = (0, import_lib3.$TV)((0, import_lib3.$E)((0, import_lib3.$S)
12233
12348
  function IgnoreColon(ctx, state2) {
12234
12349
  return (0, import_lib3.$EVENT)(ctx, state2, "IgnoreColon", IgnoreColon$0);
12235
12350
  }
12236
- var TryStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Try, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($L15, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib3.$E)(CatchClause), (0, import_lib3.$E)(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
12237
- var t = $1;
12238
- var b = $3;
12239
- var c = $4;
12240
- var f = $5;
12241
- if (!c && !f) {
12242
- const emptyCatchBlock = makeEmptyBlock();
12243
- c = {
12244
- type: "CatchClause",
12245
- children: [" catch(e) ", emptyCatchBlock],
12246
- block: emptyCatchBlock
12247
- };
12248
- return {
12249
- type: "TryStatement",
12250
- blocks: [b, emptyCatchBlock],
12251
- children: [t, b, c]
12252
- };
12253
- }
12254
- const blocks = [b];
12255
- if (c)
12256
- blocks.push(c.block);
12257
- return {
12258
- type: "TryStatement",
12259
- blocks,
12260
- children: [t, b, c, f]
12261
- };
12351
+ var TryStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Try, (0, import_lib3.$N)((0, import_lib3.$EXPECT)($L15, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib3.$E)(CatchClause), (0, import_lib3.$E)(ElseClause), (0, import_lib3.$E)(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
12352
+ return processTryBlock($0);
12262
12353
  });
12263
12354
  function TryStatement(ctx, state2) {
12264
12355
  return (0, import_lib3.$EVENT)(ctx, state2, "TryStatement", TryStatement$0);
@@ -12280,7 +12371,14 @@ var CatchBind$$ = [CatchBind$0, CatchBind$1];
12280
12371
  function CatchBind(ctx, state2) {
12281
12372
  return (0, import_lib3.$EVENT_C)(ctx, state2, "CatchBind", CatchBind$$);
12282
12373
  }
12283
- var FinallyClause$0 = (0, import_lib3.$S)((0, import_lib3.$C)(Nested, _), Finally, (0, import_lib3.$C)(BracedThenClause, BracedOrEmptyBlock));
12374
+ var FinallyClause$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$C)(Nested, _), Finally, (0, import_lib3.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
12375
+ var block = $3;
12376
+ return {
12377
+ type: "FinallyClause",
12378
+ children: $0,
12379
+ block
12380
+ };
12381
+ });
12284
12382
  function FinallyClause(ctx, state2) {
12285
12383
  return (0, import_lib3.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
12286
12384
  }
@@ -12337,7 +12435,8 @@ var DeclarationCondition$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ForbidBrac
12337
12435
  return $skip;
12338
12436
  return {
12339
12437
  type: "DeclarationCondition",
12340
- declaration
12438
+ declaration,
12439
+ children: [declaration]
12341
12440
  };
12342
12441
  });
12343
12442
  function DeclarationCondition(ctx, state2) {
@@ -14137,7 +14236,7 @@ function Unless(ctx, state2) {
14137
14236
  return (0, import_lib3.$EVENT)(ctx, state2, "Unless", Unless$0);
14138
14237
  }
14139
14238
  var Until$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$EXPECT)($L205, 'Until "until"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
14140
- return { $loc, token: $1 };
14239
+ return { $loc, token: $1, negated: true };
14141
14240
  });
14142
14241
  function Until(ctx, state2) {
14143
14242
  return (0, import_lib3.$EVENT)(ctx, state2, "Until", Until$0);