@danielx/civet 0.5.30 → 0.5.31

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/browser.js CHANGED
@@ -529,6 +529,8 @@ ${input.slice(result.pos)}
529
529
  FunctionDeclaration,
530
530
  FunctionSignature,
531
531
  FunctionExpression,
532
+ AmpersandBlockRHS,
533
+ AmpersandUnaryPrefix,
532
534
  ThinArrowFunction,
533
535
  Arrow,
534
536
  ExplicitBlock,
@@ -637,6 +639,7 @@ ${input.slice(result.pos)}
637
639
  NoExpressions,
638
640
  ImpliedColon,
639
641
  TryStatement,
642
+ TryExpression,
640
643
  CatchClause,
641
644
  CatchBind,
642
645
  Finally,
@@ -1296,6 +1299,7 @@ ${input.slice(result.pos)}
1296
1299
  var ExpressionizedStatement$3 = IterationExpression;
1297
1300
  var ExpressionizedStatement$4 = SwitchExpression;
1298
1301
  var ExpressionizedStatement$5 = ThrowExpression;
1302
+ var ExpressionizedStatement$6 = TryExpression;
1299
1303
  function ExpressionizedStatement(state) {
1300
1304
  let eventData;
1301
1305
  if (state.events) {
@@ -1307,12 +1311,12 @@ ${input.slice(result.pos)}
1307
1311
  }
1308
1312
  }
1309
1313
  if (state.tokenize) {
1310
- const result = $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state));
1314
+ const result = $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state) || ExpressionizedStatement$6(state));
1311
1315
  if (state.events)
1312
1316
  state.events.exit?.("ExpressionizedStatement", state, result, eventData);
1313
1317
  return result;
1314
1318
  } else {
1315
- const result = ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state);
1319
+ const result = ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state) || ExpressionizedStatement$6(state);
1316
1320
  if (state.events)
1317
1321
  state.events.exit?.("ExpressionizedStatement", state, result, eventData);
1318
1322
  return result;
@@ -4285,25 +4289,32 @@ ${input.slice(result.pos)}
4285
4289
  block
4286
4290
  };
4287
4291
  });
4288
- var FunctionExpression$1 = $TS($S(Ampersand, $N(_), $P(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
4289
- $1.token = "$ => $";
4290
- return {
4291
- type: "ArrowFunction",
4292
- children: [$1, $3]
4293
- };
4294
- });
4295
- var FunctionExpression$2 = $TS($S(Ampersand, $N($EXPECT($R1, fail, "FunctionExpression /[&]/")), $P(BinaryOpRHS)), function($skip, $loc, $0, $1, $2, $3) {
4296
- $1.token = "$ => $";
4297
- const exp = module.processBinaryOpExpression([$1, $3]);
4298
- return {
4299
- type: "ArrowFunction",
4300
- children: exp
4301
- };
4302
- });
4303
- var FunctionExpression$3 = $TS($S($EXPECT($R2, fail, "FunctionExpression /[!~+-]+/"), Ampersand), function($skip, $loc, $0, $1, $2) {
4292
+ var FunctionExpression$1 = $TS($S($E(AmpersandUnaryPrefix), Ampersand, $E(AmpersandBlockRHS)), function($skip, $loc, $0, $1, $2, $3) {
4293
+ var prefix = $1;
4294
+ var rhs = $3;
4295
+ if (!prefix && !rhs)
4296
+ return $skip;
4297
+ if (!rhs) {
4298
+ const ref2 = {
4299
+ type: "Ref",
4300
+ base: "$",
4301
+ id: "$"
4302
+ };
4303
+ return {
4304
+ type: "ArrowFunction",
4305
+ children: [ref2, " => ", prefix, ref2]
4306
+ };
4307
+ }
4308
+ const { ref } = rhs;
4309
+ if (!prefix) {
4310
+ return {
4311
+ type: "ArrowFunction",
4312
+ children: [ref, " => ", rhs]
4313
+ };
4314
+ }
4304
4315
  return {
4305
4316
  type: "ArrowFunction",
4306
- children: ["$ => ", $1, "$"]
4317
+ children: [ref, " => ", prefix, rhs]
4307
4318
  };
4308
4319
  });
4309
4320
  function FunctionExpression(state) {
@@ -4317,17 +4328,89 @@ ${input.slice(result.pos)}
4317
4328
  }
4318
4329
  }
4319
4330
  if (state.tokenize) {
4320
- const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state) || FunctionExpression$2(state) || FunctionExpression$3(state));
4331
+ const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
4321
4332
  if (state.events)
4322
4333
  state.events.exit?.("FunctionExpression", state, result, eventData);
4323
4334
  return result;
4324
4335
  } else {
4325
- const result = FunctionExpression$0(state) || FunctionExpression$1(state) || FunctionExpression$2(state) || FunctionExpression$3(state);
4336
+ const result = FunctionExpression$0(state) || FunctionExpression$1(state);
4326
4337
  if (state.events)
4327
4338
  state.events.exit?.("FunctionExpression", state, result, eventData);
4328
4339
  return result;
4329
4340
  }
4330
4341
  }
4342
+ var AmpersandBlockRHS$0 = $TS($S($E($S($N(_), $P(CallExpressionRest))), $E($S($N($EXPECT($R1, fail, "AmpersandBlockRHS /[&]/")), $P(BinaryOpRHS)))), function($skip, $loc, $0, $1, $2) {
4343
+ var callExpRest = $1;
4344
+ var binopRHS = $2;
4345
+ if (!callExpRest && !binopRHS)
4346
+ return $skip;
4347
+ const ref = {
4348
+ type: "Ref",
4349
+ base: "$",
4350
+ id: "$"
4351
+ };
4352
+ const exp = {
4353
+ type: "AmpersandRef",
4354
+ children: [ref],
4355
+ names: [],
4356
+ ref
4357
+ };
4358
+ if (callExpRest) {
4359
+ exp.children.push(...callExpRest[1]);
4360
+ }
4361
+ if (binopRHS) {
4362
+ return {
4363
+ children: module.processBinaryOpExpression([exp, binopRHS[1]]),
4364
+ ref
4365
+ };
4366
+ }
4367
+ return exp;
4368
+ });
4369
+ function AmpersandBlockRHS(state) {
4370
+ let eventData;
4371
+ if (state.events) {
4372
+ const result = state.events.enter?.("AmpersandBlockRHS", state);
4373
+ if (result) {
4374
+ if (result.cache)
4375
+ return result.cache;
4376
+ eventData = result.data;
4377
+ }
4378
+ }
4379
+ if (state.tokenize) {
4380
+ const result = $TOKEN("AmpersandBlockRHS", state, AmpersandBlockRHS$0(state));
4381
+ if (state.events)
4382
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
4383
+ return result;
4384
+ } else {
4385
+ const result = AmpersandBlockRHS$0(state);
4386
+ if (state.events)
4387
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
4388
+ return result;
4389
+ }
4390
+ }
4391
+ var AmpersandUnaryPrefix$0 = $R$0($EXPECT($R2, fail, "AmpersandUnaryPrefix /[!~+-]+/"));
4392
+ function AmpersandUnaryPrefix(state) {
4393
+ let eventData;
4394
+ if (state.events) {
4395
+ const result = state.events.enter?.("AmpersandUnaryPrefix", state);
4396
+ if (result) {
4397
+ if (result.cache)
4398
+ return result.cache;
4399
+ eventData = result.data;
4400
+ }
4401
+ }
4402
+ if (state.tokenize) {
4403
+ const result = $TOKEN("AmpersandUnaryPrefix", state, AmpersandUnaryPrefix$0(state));
4404
+ if (state.events)
4405
+ state.events.exit?.("AmpersandUnaryPrefix", state, result, eventData);
4406
+ return result;
4407
+ } else {
4408
+ const result = AmpersandUnaryPrefix$0(state);
4409
+ if (state.events)
4410
+ state.events.exit?.("AmpersandUnaryPrefix", state, result, eventData);
4411
+ return result;
4412
+ }
4413
+ }
4331
4414
  var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4332
4415
  var parameters = $1;
4333
4416
  var suffix = $2;
@@ -8115,6 +8198,36 @@ ${input.slice(result.pos)}
8115
8198
  return result;
8116
8199
  }
8117
8200
  }
8201
+ var TryExpression$0 = $TV(TryStatement, function($skip, $loc, $0, $1) {
8202
+ var t = $0;
8203
+ return {
8204
+ type: "TryExpression",
8205
+ blocks: [t.children[1], t.children[2]?.[3]],
8206
+ children: ["(()=>{", t, "})()"]
8207
+ };
8208
+ });
8209
+ function TryExpression(state) {
8210
+ let eventData;
8211
+ if (state.events) {
8212
+ const result = state.events.enter?.("TryExpression", state);
8213
+ if (result) {
8214
+ if (result.cache)
8215
+ return result.cache;
8216
+ eventData = result.data;
8217
+ }
8218
+ }
8219
+ if (state.tokenize) {
8220
+ const result = $TOKEN("TryExpression", state, TryExpression$0(state));
8221
+ if (state.events)
8222
+ state.events.exit?.("TryExpression", state, result, eventData);
8223
+ return result;
8224
+ } else {
8225
+ const result = TryExpression$0(state);
8226
+ if (state.events)
8227
+ state.events.exit?.("TryExpression", state, result, eventData);
8228
+ return result;
8229
+ }
8230
+ }
8118
8231
  var CatchClause$0 = $S(__, Catch, $E(CatchBind), BracedBlock);
8119
8232
  function CatchClause(state) {
8120
8233
  let eventData;
@@ -16704,6 +16817,13 @@ ${input.slice(result.pos)}
16704
16817
  });
16705
16818
  }
16706
16819
  }
16820
+ function processTryExpressions(statements) {
16821
+ if (module.config.implicitReturns) {
16822
+ gatherRecursiveAll(statements, (n) => n.type === "TryExpression").forEach(({ blocks }) => {
16823
+ blocks.forEach(insertReturn);
16824
+ });
16825
+ }
16826
+ }
16707
16827
  function processBindingPatternLHS(lhs, tail) {
16708
16828
  adjustAtBindings(lhs, true);
16709
16829
  const [splices, thisAssignments] = module.gatherBindingCode(lhs);
@@ -16823,6 +16943,7 @@ ${input.slice(result.pos)}
16823
16943
  processAssignments(statements);
16824
16944
  processFunctions(statements);
16825
16945
  processSwitchExpressions(statements);
16946
+ processTryExpressions(statements);
16826
16947
  gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
16827
16948
  checkSpliceRef(statements);
16828
16949
  statements.unshift(...module.prelude);
package/dist/main.js CHANGED
@@ -528,6 +528,8 @@ ${input.slice(result.pos)}
528
528
  FunctionDeclaration,
529
529
  FunctionSignature,
530
530
  FunctionExpression,
531
+ AmpersandBlockRHS,
532
+ AmpersandUnaryPrefix,
531
533
  ThinArrowFunction,
532
534
  Arrow,
533
535
  ExplicitBlock,
@@ -636,6 +638,7 @@ ${input.slice(result.pos)}
636
638
  NoExpressions,
637
639
  ImpliedColon,
638
640
  TryStatement,
641
+ TryExpression,
639
642
  CatchClause,
640
643
  CatchBind,
641
644
  Finally,
@@ -1295,6 +1298,7 @@ ${input.slice(result.pos)}
1295
1298
  var ExpressionizedStatement$3 = IterationExpression;
1296
1299
  var ExpressionizedStatement$4 = SwitchExpression;
1297
1300
  var ExpressionizedStatement$5 = ThrowExpression;
1301
+ var ExpressionizedStatement$6 = TryExpression;
1298
1302
  function ExpressionizedStatement(state) {
1299
1303
  let eventData;
1300
1304
  if (state.events) {
@@ -1306,12 +1310,12 @@ ${input.slice(result.pos)}
1306
1310
  }
1307
1311
  }
1308
1312
  if (state.tokenize) {
1309
- const result = $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state));
1313
+ const result = $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state) || ExpressionizedStatement$6(state));
1310
1314
  if (state.events)
1311
1315
  state.events.exit?.("ExpressionizedStatement", state, result, eventData);
1312
1316
  return result;
1313
1317
  } else {
1314
- const result = ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state);
1318
+ const result = ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state) || ExpressionizedStatement$6(state);
1315
1319
  if (state.events)
1316
1320
  state.events.exit?.("ExpressionizedStatement", state, result, eventData);
1317
1321
  return result;
@@ -4284,25 +4288,32 @@ ${input.slice(result.pos)}
4284
4288
  block
4285
4289
  };
4286
4290
  });
4287
- var FunctionExpression$1 = $TS($S(Ampersand, $N(_), $P(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
4288
- $1.token = "$ => $";
4289
- return {
4290
- type: "ArrowFunction",
4291
- children: [$1, $3]
4292
- };
4293
- });
4294
- var FunctionExpression$2 = $TS($S(Ampersand, $N($EXPECT($R1, fail, "FunctionExpression /[&]/")), $P(BinaryOpRHS)), function($skip, $loc, $0, $1, $2, $3) {
4295
- $1.token = "$ => $";
4296
- const exp = module2.processBinaryOpExpression([$1, $3]);
4297
- return {
4298
- type: "ArrowFunction",
4299
- children: exp
4300
- };
4301
- });
4302
- var FunctionExpression$3 = $TS($S($EXPECT($R2, fail, "FunctionExpression /[!~+-]+/"), Ampersand), function($skip, $loc, $0, $1, $2) {
4291
+ var FunctionExpression$1 = $TS($S($E(AmpersandUnaryPrefix), Ampersand, $E(AmpersandBlockRHS)), function($skip, $loc, $0, $1, $2, $3) {
4292
+ var prefix = $1;
4293
+ var rhs = $3;
4294
+ if (!prefix && !rhs)
4295
+ return $skip;
4296
+ if (!rhs) {
4297
+ const ref2 = {
4298
+ type: "Ref",
4299
+ base: "$",
4300
+ id: "$"
4301
+ };
4302
+ return {
4303
+ type: "ArrowFunction",
4304
+ children: [ref2, " => ", prefix, ref2]
4305
+ };
4306
+ }
4307
+ const { ref } = rhs;
4308
+ if (!prefix) {
4309
+ return {
4310
+ type: "ArrowFunction",
4311
+ children: [ref, " => ", rhs]
4312
+ };
4313
+ }
4303
4314
  return {
4304
4315
  type: "ArrowFunction",
4305
- children: ["$ => ", $1, "$"]
4316
+ children: [ref, " => ", prefix, rhs]
4306
4317
  };
4307
4318
  });
4308
4319
  function FunctionExpression(state) {
@@ -4316,17 +4327,89 @@ ${input.slice(result.pos)}
4316
4327
  }
4317
4328
  }
4318
4329
  if (state.tokenize) {
4319
- const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state) || FunctionExpression$2(state) || FunctionExpression$3(state));
4330
+ const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
4320
4331
  if (state.events)
4321
4332
  state.events.exit?.("FunctionExpression", state, result, eventData);
4322
4333
  return result;
4323
4334
  } else {
4324
- const result = FunctionExpression$0(state) || FunctionExpression$1(state) || FunctionExpression$2(state) || FunctionExpression$3(state);
4335
+ const result = FunctionExpression$0(state) || FunctionExpression$1(state);
4325
4336
  if (state.events)
4326
4337
  state.events.exit?.("FunctionExpression", state, result, eventData);
4327
4338
  return result;
4328
4339
  }
4329
4340
  }
4341
+ var AmpersandBlockRHS$0 = $TS($S($E($S($N(_), $P(CallExpressionRest))), $E($S($N($EXPECT($R1, fail, "AmpersandBlockRHS /[&]/")), $P(BinaryOpRHS)))), function($skip, $loc, $0, $1, $2) {
4342
+ var callExpRest = $1;
4343
+ var binopRHS = $2;
4344
+ if (!callExpRest && !binopRHS)
4345
+ return $skip;
4346
+ const ref = {
4347
+ type: "Ref",
4348
+ base: "$",
4349
+ id: "$"
4350
+ };
4351
+ const exp = {
4352
+ type: "AmpersandRef",
4353
+ children: [ref],
4354
+ names: [],
4355
+ ref
4356
+ };
4357
+ if (callExpRest) {
4358
+ exp.children.push(...callExpRest[1]);
4359
+ }
4360
+ if (binopRHS) {
4361
+ return {
4362
+ children: module2.processBinaryOpExpression([exp, binopRHS[1]]),
4363
+ ref
4364
+ };
4365
+ }
4366
+ return exp;
4367
+ });
4368
+ function AmpersandBlockRHS(state) {
4369
+ let eventData;
4370
+ if (state.events) {
4371
+ const result = state.events.enter?.("AmpersandBlockRHS", state);
4372
+ if (result) {
4373
+ if (result.cache)
4374
+ return result.cache;
4375
+ eventData = result.data;
4376
+ }
4377
+ }
4378
+ if (state.tokenize) {
4379
+ const result = $TOKEN("AmpersandBlockRHS", state, AmpersandBlockRHS$0(state));
4380
+ if (state.events)
4381
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
4382
+ return result;
4383
+ } else {
4384
+ const result = AmpersandBlockRHS$0(state);
4385
+ if (state.events)
4386
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
4387
+ return result;
4388
+ }
4389
+ }
4390
+ var AmpersandUnaryPrefix$0 = $R$0($EXPECT($R2, fail, "AmpersandUnaryPrefix /[!~+-]+/"));
4391
+ function AmpersandUnaryPrefix(state) {
4392
+ let eventData;
4393
+ if (state.events) {
4394
+ const result = state.events.enter?.("AmpersandUnaryPrefix", state);
4395
+ if (result) {
4396
+ if (result.cache)
4397
+ return result.cache;
4398
+ eventData = result.data;
4399
+ }
4400
+ }
4401
+ if (state.tokenize) {
4402
+ const result = $TOKEN("AmpersandUnaryPrefix", state, AmpersandUnaryPrefix$0(state));
4403
+ if (state.events)
4404
+ state.events.exit?.("AmpersandUnaryPrefix", state, result, eventData);
4405
+ return result;
4406
+ } else {
4407
+ const result = AmpersandUnaryPrefix$0(state);
4408
+ if (state.events)
4409
+ state.events.exit?.("AmpersandUnaryPrefix", state, result, eventData);
4410
+ return result;
4411
+ }
4412
+ }
4330
4413
  var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4331
4414
  var parameters = $1;
4332
4415
  var suffix = $2;
@@ -8114,6 +8197,36 @@ ${input.slice(result.pos)}
8114
8197
  return result;
8115
8198
  }
8116
8199
  }
8200
+ var TryExpression$0 = $TV(TryStatement, function($skip, $loc, $0, $1) {
8201
+ var t = $0;
8202
+ return {
8203
+ type: "TryExpression",
8204
+ blocks: [t.children[1], t.children[2]?.[3]],
8205
+ children: ["(()=>{", t, "})()"]
8206
+ };
8207
+ });
8208
+ function TryExpression(state) {
8209
+ let eventData;
8210
+ if (state.events) {
8211
+ const result = state.events.enter?.("TryExpression", state);
8212
+ if (result) {
8213
+ if (result.cache)
8214
+ return result.cache;
8215
+ eventData = result.data;
8216
+ }
8217
+ }
8218
+ if (state.tokenize) {
8219
+ const result = $TOKEN("TryExpression", state, TryExpression$0(state));
8220
+ if (state.events)
8221
+ state.events.exit?.("TryExpression", state, result, eventData);
8222
+ return result;
8223
+ } else {
8224
+ const result = TryExpression$0(state);
8225
+ if (state.events)
8226
+ state.events.exit?.("TryExpression", state, result, eventData);
8227
+ return result;
8228
+ }
8229
+ }
8117
8230
  var CatchClause$0 = $S(__, Catch, $E(CatchBind), BracedBlock);
8118
8231
  function CatchClause(state) {
8119
8232
  let eventData;
@@ -16703,6 +16816,13 @@ ${input.slice(result.pos)}
16703
16816
  });
16704
16817
  }
16705
16818
  }
16819
+ function processTryExpressions(statements) {
16820
+ if (module2.config.implicitReturns) {
16821
+ gatherRecursiveAll(statements, (n) => n.type === "TryExpression").forEach(({ blocks }) => {
16822
+ blocks.forEach(insertReturn);
16823
+ });
16824
+ }
16825
+ }
16706
16826
  function processBindingPatternLHS(lhs, tail) {
16707
16827
  adjustAtBindings(lhs, true);
16708
16828
  const [splices, thisAssignments] = module2.gatherBindingCode(lhs);
@@ -16822,6 +16942,7 @@ ${input.slice(result.pos)}
16822
16942
  processAssignments(statements);
16823
16943
  processFunctions(statements);
16824
16944
  processSwitchExpressions(statements);
16945
+ processTryExpressions(statements);
16825
16946
  gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
16826
16947
  checkSpliceRef(statements);
16827
16948
  statements.unshift(...module2.prelude);
package/dist/main.mjs CHANGED
@@ -526,6 +526,8 @@ ${input.slice(result.pos)}
526
526
  FunctionDeclaration,
527
527
  FunctionSignature,
528
528
  FunctionExpression,
529
+ AmpersandBlockRHS,
530
+ AmpersandUnaryPrefix,
529
531
  ThinArrowFunction,
530
532
  Arrow,
531
533
  ExplicitBlock,
@@ -634,6 +636,7 @@ ${input.slice(result.pos)}
634
636
  NoExpressions,
635
637
  ImpliedColon,
636
638
  TryStatement,
639
+ TryExpression,
637
640
  CatchClause,
638
641
  CatchBind,
639
642
  Finally,
@@ -1293,6 +1296,7 @@ ${input.slice(result.pos)}
1293
1296
  var ExpressionizedStatement$3 = IterationExpression;
1294
1297
  var ExpressionizedStatement$4 = SwitchExpression;
1295
1298
  var ExpressionizedStatement$5 = ThrowExpression;
1299
+ var ExpressionizedStatement$6 = TryExpression;
1296
1300
  function ExpressionizedStatement(state) {
1297
1301
  let eventData;
1298
1302
  if (state.events) {
@@ -1304,12 +1308,12 @@ ${input.slice(result.pos)}
1304
1308
  }
1305
1309
  }
1306
1310
  if (state.tokenize) {
1307
- const result = $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state));
1311
+ const result = $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state) || ExpressionizedStatement$6(state));
1308
1312
  if (state.events)
1309
1313
  state.events.exit?.("ExpressionizedStatement", state, result, eventData);
1310
1314
  return result;
1311
1315
  } else {
1312
- const result = ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state);
1316
+ const result = ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state) || ExpressionizedStatement$6(state);
1313
1317
  if (state.events)
1314
1318
  state.events.exit?.("ExpressionizedStatement", state, result, eventData);
1315
1319
  return result;
@@ -4282,25 +4286,32 @@ ${input.slice(result.pos)}
4282
4286
  block
4283
4287
  };
4284
4288
  });
4285
- var FunctionExpression$1 = $TS($S(Ampersand, $N(_), $P(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
4286
- $1.token = "$ => $";
4287
- return {
4288
- type: "ArrowFunction",
4289
- children: [$1, $3]
4290
- };
4291
- });
4292
- var FunctionExpression$2 = $TS($S(Ampersand, $N($EXPECT($R1, fail, "FunctionExpression /[&]/")), $P(BinaryOpRHS)), function($skip, $loc, $0, $1, $2, $3) {
4293
- $1.token = "$ => $";
4294
- const exp = module.processBinaryOpExpression([$1, $3]);
4295
- return {
4296
- type: "ArrowFunction",
4297
- children: exp
4298
- };
4299
- });
4300
- var FunctionExpression$3 = $TS($S($EXPECT($R2, fail, "FunctionExpression /[!~+-]+/"), Ampersand), function($skip, $loc, $0, $1, $2) {
4289
+ var FunctionExpression$1 = $TS($S($E(AmpersandUnaryPrefix), Ampersand, $E(AmpersandBlockRHS)), function($skip, $loc, $0, $1, $2, $3) {
4290
+ var prefix = $1;
4291
+ var rhs = $3;
4292
+ if (!prefix && !rhs)
4293
+ return $skip;
4294
+ if (!rhs) {
4295
+ const ref2 = {
4296
+ type: "Ref",
4297
+ base: "$",
4298
+ id: "$"
4299
+ };
4300
+ return {
4301
+ type: "ArrowFunction",
4302
+ children: [ref2, " => ", prefix, ref2]
4303
+ };
4304
+ }
4305
+ const { ref } = rhs;
4306
+ if (!prefix) {
4307
+ return {
4308
+ type: "ArrowFunction",
4309
+ children: [ref, " => ", rhs]
4310
+ };
4311
+ }
4301
4312
  return {
4302
4313
  type: "ArrowFunction",
4303
- children: ["$ => ", $1, "$"]
4314
+ children: [ref, " => ", prefix, rhs]
4304
4315
  };
4305
4316
  });
4306
4317
  function FunctionExpression(state) {
@@ -4314,17 +4325,89 @@ ${input.slice(result.pos)}
4314
4325
  }
4315
4326
  }
4316
4327
  if (state.tokenize) {
4317
- const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state) || FunctionExpression$2(state) || FunctionExpression$3(state));
4328
+ const result = $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
4318
4329
  if (state.events)
4319
4330
  state.events.exit?.("FunctionExpression", state, result, eventData);
4320
4331
  return result;
4321
4332
  } else {
4322
- const result = FunctionExpression$0(state) || FunctionExpression$1(state) || FunctionExpression$2(state) || FunctionExpression$3(state);
4333
+ const result = FunctionExpression$0(state) || FunctionExpression$1(state);
4323
4334
  if (state.events)
4324
4335
  state.events.exit?.("FunctionExpression", state, result, eventData);
4325
4336
  return result;
4326
4337
  }
4327
4338
  }
4339
+ var AmpersandBlockRHS$0 = $TS($S($E($S($N(_), $P(CallExpressionRest))), $E($S($N($EXPECT($R1, fail, "AmpersandBlockRHS /[&]/")), $P(BinaryOpRHS)))), function($skip, $loc, $0, $1, $2) {
4340
+ var callExpRest = $1;
4341
+ var binopRHS = $2;
4342
+ if (!callExpRest && !binopRHS)
4343
+ return $skip;
4344
+ const ref = {
4345
+ type: "Ref",
4346
+ base: "$",
4347
+ id: "$"
4348
+ };
4349
+ const exp = {
4350
+ type: "AmpersandRef",
4351
+ children: [ref],
4352
+ names: [],
4353
+ ref
4354
+ };
4355
+ if (callExpRest) {
4356
+ exp.children.push(...callExpRest[1]);
4357
+ }
4358
+ if (binopRHS) {
4359
+ return {
4360
+ children: module.processBinaryOpExpression([exp, binopRHS[1]]),
4361
+ ref
4362
+ };
4363
+ }
4364
+ return exp;
4365
+ });
4366
+ function AmpersandBlockRHS(state) {
4367
+ let eventData;
4368
+ if (state.events) {
4369
+ const result = state.events.enter?.("AmpersandBlockRHS", state);
4370
+ if (result) {
4371
+ if (result.cache)
4372
+ return result.cache;
4373
+ eventData = result.data;
4374
+ }
4375
+ }
4376
+ if (state.tokenize) {
4377
+ const result = $TOKEN("AmpersandBlockRHS", state, AmpersandBlockRHS$0(state));
4378
+ if (state.events)
4379
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
4380
+ return result;
4381
+ } else {
4382
+ const result = AmpersandBlockRHS$0(state);
4383
+ if (state.events)
4384
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
4385
+ return result;
4386
+ }
4387
+ }
4388
+ var AmpersandUnaryPrefix$0 = $R$0($EXPECT($R2, fail, "AmpersandUnaryPrefix /[!~+-]+/"));
4389
+ function AmpersandUnaryPrefix(state) {
4390
+ let eventData;
4391
+ if (state.events) {
4392
+ const result = state.events.enter?.("AmpersandUnaryPrefix", state);
4393
+ if (result) {
4394
+ if (result.cache)
4395
+ return result.cache;
4396
+ eventData = result.data;
4397
+ }
4398
+ }
4399
+ if (state.tokenize) {
4400
+ const result = $TOKEN("AmpersandUnaryPrefix", state, AmpersandUnaryPrefix$0(state));
4401
+ if (state.events)
4402
+ state.events.exit?.("AmpersandUnaryPrefix", state, result, eventData);
4403
+ return result;
4404
+ } else {
4405
+ const result = AmpersandUnaryPrefix$0(state);
4406
+ if (state.events)
4407
+ state.events.exit?.("AmpersandUnaryPrefix", state, result, eventData);
4408
+ return result;
4409
+ }
4410
+ }
4328
4411
  var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4329
4412
  var parameters = $1;
4330
4413
  var suffix = $2;
@@ -8112,6 +8195,36 @@ ${input.slice(result.pos)}
8112
8195
  return result;
8113
8196
  }
8114
8197
  }
8198
+ var TryExpression$0 = $TV(TryStatement, function($skip, $loc, $0, $1) {
8199
+ var t = $0;
8200
+ return {
8201
+ type: "TryExpression",
8202
+ blocks: [t.children[1], t.children[2]?.[3]],
8203
+ children: ["(()=>{", t, "})()"]
8204
+ };
8205
+ });
8206
+ function TryExpression(state) {
8207
+ let eventData;
8208
+ if (state.events) {
8209
+ const result = state.events.enter?.("TryExpression", state);
8210
+ if (result) {
8211
+ if (result.cache)
8212
+ return result.cache;
8213
+ eventData = result.data;
8214
+ }
8215
+ }
8216
+ if (state.tokenize) {
8217
+ const result = $TOKEN("TryExpression", state, TryExpression$0(state));
8218
+ if (state.events)
8219
+ state.events.exit?.("TryExpression", state, result, eventData);
8220
+ return result;
8221
+ } else {
8222
+ const result = TryExpression$0(state);
8223
+ if (state.events)
8224
+ state.events.exit?.("TryExpression", state, result, eventData);
8225
+ return result;
8226
+ }
8227
+ }
8115
8228
  var CatchClause$0 = $S(__, Catch, $E(CatchBind), BracedBlock);
8116
8229
  function CatchClause(state) {
8117
8230
  let eventData;
@@ -16701,6 +16814,13 @@ ${input.slice(result.pos)}
16701
16814
  });
16702
16815
  }
16703
16816
  }
16817
+ function processTryExpressions(statements) {
16818
+ if (module.config.implicitReturns) {
16819
+ gatherRecursiveAll(statements, (n) => n.type === "TryExpression").forEach(({ blocks }) => {
16820
+ blocks.forEach(insertReturn);
16821
+ });
16822
+ }
16823
+ }
16704
16824
  function processBindingPatternLHS(lhs, tail) {
16705
16825
  adjustAtBindings(lhs, true);
16706
16826
  const [splices, thisAssignments] = module.gatherBindingCode(lhs);
@@ -16820,6 +16940,7 @@ ${input.slice(result.pos)}
16820
16940
  processAssignments(statements);
16821
16941
  processFunctions(statements);
16822
16942
  processSwitchExpressions(statements);
16943
+ processTryExpressions(statements);
16823
16944
  gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
16824
16945
  checkSpliceRef(statements);
16825
16946
  statements.unshift(...module.prelude);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.5.30",
3
+ "version": "0.5.31",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",