@danielx/civet 0.4.7 → 0.4.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/browser.js CHANGED
@@ -456,6 +456,7 @@ var Civet = (() => {
456
456
  SuperProperty,
457
457
  MetaProperty,
458
458
  Parameters,
459
+ NonEmptyParameters,
459
460
  ParameterElement,
460
461
  ParameterElementDelimiter,
461
462
  BindingIdentifier,
@@ -476,6 +477,7 @@ var Civet = (() => {
476
477
  Arrow,
477
478
  Block,
478
479
  BracedOrEmptyBlock,
480
+ EmptyBlock,
479
481
  BracedBlock,
480
482
  SingleNestedExpression,
481
483
  NestedBlockExpressions,
@@ -1179,7 +1181,19 @@ var Civet = (() => {
1179
1181
  }
1180
1182
  }
1181
1183
  var ArrowFunction$0 = ThinArrowFunction;
1182
- var ArrowFunction$1 = $S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody);
1184
+ var ArrowFunction$1 = $TS($S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4) {
1185
+ var suffix = $2;
1186
+ var expOrBlock = $4;
1187
+ const isVoid = suffix?.children?.[1]?.[0]?.[1]?.token === "void";
1188
+ const isBlock = expOrBlock.type === "BlockStatement";
1189
+ if (module.implicitReturns && !isVoid && isBlock) {
1190
+ module.addImplicitReturns(expOrBlock);
1191
+ }
1192
+ return {
1193
+ type: "FunctionExpression",
1194
+ children: $0
1195
+ };
1196
+ });
1183
1197
  function ArrowFunction(state) {
1184
1198
  if (state.tokenize) {
1185
1199
  return $TOKEN("ArrowFunction", state, ArrowFunction$0(state) || ArrowFunction$1(state));
@@ -1202,11 +1216,17 @@ var Civet = (() => {
1202
1216
  return FatArrow$0(state);
1203
1217
  }
1204
1218
  }
1205
- var FatArrowBody$0 = $S(__, OpenBrace, EOS, NestedBlockExpressions, __, CloseBrace);
1206
- var FatArrowBody$1 = $S(InsertOpenBrace, EOS, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseBrace);
1219
+ var FatArrowBody$0 = $T($S(__, OpenBrace, EOS, NestedBlockExpressions, __, CloseBrace), function(value) {
1220
+ var exps = value[3];
1221
+ return { "type": "BlockStatement", "expressions": exps, "children": value };
1222
+ });
1223
+ var FatArrowBody$1 = $T($S(InsertOpenBrace, EOS, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseBrace), function(value) {
1224
+ var exps = value[2];
1225
+ return { "type": "BlockStatement", "expressions": exps, "children": value };
1226
+ });
1207
1227
  var FatArrowBody$2 = AssignmentExpression;
1208
1228
  var FatArrowBody$3 = $S(__, AssignmentExpression);
1209
- var FatArrowBody$4 = $S(InsertOpenBrace, InsertCloseBrace);
1229
+ var FatArrowBody$4 = EmptyBlock;
1210
1230
  function FatArrowBody(state) {
1211
1231
  if (state.tokenize) {
1212
1232
  return $TOKEN("FatArrowBody", state, FatArrowBody$0(state) || FatArrowBody$1(state) || FatArrowBody$2(state) || FatArrowBody$3(state) || FatArrowBody$4(state));
@@ -1522,7 +1542,7 @@ var Civet = (() => {
1522
1542
  return MetaProperty$0(state) || MetaProperty$1(state);
1523
1543
  }
1524
1544
  }
1525
- var Parameters$0 = $S($E(TypeParameters), OpenParen, $Q(ParameterElement), __, CloseParen);
1545
+ var Parameters$0 = NonEmptyParameters;
1526
1546
  var Parameters$1 = $TV($EXPECT($L1, fail, 'Parameters ""'), function($skip, $loc, $0, $1) {
1527
1547
  return { $loc, token: "()" };
1528
1548
  });
@@ -1533,6 +1553,16 @@ var Civet = (() => {
1533
1553
  return Parameters$0(state) || Parameters$1(state);
1534
1554
  }
1535
1555
  }
1556
+ var NonEmptyParameters$0 = $S($E(TypeParameters), OpenParen, $Q(ParameterElement), __, CloseParen);
1557
+ function NonEmptyParameters(state) {
1558
+ if (state.verbose)
1559
+ console.log("ENTER:", "NonEmptyParameters");
1560
+ if (state.tokenize) {
1561
+ return $TOKEN("NonEmptyParameters", state, NonEmptyParameters$0(state));
1562
+ } else {
1563
+ return NonEmptyParameters$0(state);
1564
+ }
1565
+ }
1536
1566
  var ParameterElement$0 = $S(__, $C(BindingIdentifier, BindingPattern), $E(TypeSuffix), $E(Initializer), ParameterElementDelimiter);
1537
1567
  function ParameterElement(state) {
1538
1568
  if (state.verbose)
@@ -1701,8 +1731,17 @@ var Civet = (() => {
1701
1731
  }
1702
1732
  }
1703
1733
  var FunctionExpression$0 = ThinArrowFunction;
1704
- var FunctionExpression$1 = $T($S($E($S(Async, __)), Function, $E($S(Star, __)), $E(BindingIdentifier), __, Parameters, $E(ReturnTypeSuffix), BracedBlock), function(value) {
1705
- return { "type": "FunctionExpression", "children": value };
1734
+ var FunctionExpression$1 = $TS($S($E($S(Async, __)), Function, $E($S(Star, __)), $E(BindingIdentifier), __, Parameters, $E(ReturnTypeSuffix), BracedBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
1735
+ var suffix = $7;
1736
+ var block = $8;
1737
+ const isVoid = suffix?.children?.[1]?.[0]?.[1]?.token === "void";
1738
+ if (module.implicitReturns && !isVoid) {
1739
+ module.addImplicitReturns(block);
1740
+ }
1741
+ return {
1742
+ type: "FunctionExpression",
1743
+ children: $0
1744
+ };
1706
1745
  });
1707
1746
  function FunctionExpression(state) {
1708
1747
  if (state.tokenize) {
@@ -1716,7 +1755,8 @@ var Civet = (() => {
1716
1755
  var suffix = $2;
1717
1756
  var arrow = $4;
1718
1757
  var block = $5;
1719
- if (module.implicitReturns && suffix?.children[3] !== "void") {
1758
+ const isVoid = suffix?.children?.[1]?.[0]?.[1]?.token === "void";
1759
+ if (module.implicitReturns && !isVoid) {
1720
1760
  block = module.addImplicitReturns(block);
1721
1761
  }
1722
1762
  return {
@@ -1768,9 +1808,7 @@ var Civet = (() => {
1768
1808
  }
1769
1809
  }
1770
1810
  var BracedOrEmptyBlock$0 = BracedBlock;
1771
- var BracedOrEmptyBlock$1 = $T($S(InsertOpenBrace, InsertCloseBrace), function(value) {
1772
- return { "type": "BlockStatement", "expressions": [], "children": value };
1773
- });
1811
+ var BracedOrEmptyBlock$1 = EmptyBlock;
1774
1812
  function BracedOrEmptyBlock(state) {
1775
1813
  if (state.tokenize) {
1776
1814
  return $TOKEN("BracedOrEmptyBlock", state, BracedOrEmptyBlock$0(state) || BracedOrEmptyBlock$1(state));
@@ -1778,6 +1816,18 @@ var Civet = (() => {
1778
1816
  return BracedOrEmptyBlock$0(state) || BracedOrEmptyBlock$1(state);
1779
1817
  }
1780
1818
  }
1819
+ var EmptyBlock$0 = $T($S(InsertOpenBrace, InsertCloseBrace), function(value) {
1820
+ return { "type": "BlockStatement", "expressions": [], "children": value };
1821
+ });
1822
+ function EmptyBlock(state) {
1823
+ if (state.verbose)
1824
+ console.log("ENTER:", "EmptyBlock");
1825
+ if (state.tokenize) {
1826
+ return $TOKEN("EmptyBlock", state, EmptyBlock$0(state));
1827
+ } else {
1828
+ return EmptyBlock$0(state);
1829
+ }
1830
+ }
1781
1831
  var BracedBlock$0 = $T($S(__, OpenBrace, EOS, NestedBlockExpressions, __, CloseBrace), function(value) {
1782
1832
  var exps = value[3];
1783
1833
  return { "type": "BlockStatement", "expressions": exps, "children": value };
@@ -2101,7 +2151,17 @@ var Civet = (() => {
2101
2151
  return PropertyName$0(state) || PropertyName$1(state) || PropertyName$2(state) || PropertyName$3(state);
2102
2152
  }
2103
2153
  }
2104
- var MethodDefinition$0 = $S(MethodSignature, BracedBlock);
2154
+ var MethodDefinition$0 = $TS($S(MethodSignature, BracedBlock), function($skip, $loc, $0, $1, $2) {
2155
+ var sig = $1;
2156
+ var block = $2;
2157
+ const isConstructor = sig.name === "constructor";
2158
+ const isVoid = sig.returnType === "void";
2159
+ const isSet = sig.modifier === "set";
2160
+ if (module.implicitReturns && !isConstructor && !isSet && !isVoid) {
2161
+ block = module.addImplicitReturns(block);
2162
+ }
2163
+ return $0;
2164
+ });
2105
2165
  function MethodDefinition(state) {
2106
2166
  if (state.verbose)
2107
2167
  console.log("ENTER:", "MethodDefinition");
@@ -2122,8 +2182,26 @@ var Civet = (() => {
2122
2182
  return MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state) || MethodModifier$3(state);
2123
2183
  }
2124
2184
  }
2125
- var MethodSignature$0 = $S(ConstructorShorthand, Parameters);
2126
- var MethodSignature$1 = $S($E(MethodModifier), ClassElementName, $Q(_), Parameters);
2185
+ var MethodSignature$0 = $TS($S(ConstructorShorthand, Parameters), function($skip, $loc, $0, $1, $2) {
2186
+ return {
2187
+ type: "MethodSignature",
2188
+ children: $0,
2189
+ name: $1.token,
2190
+ returnType: void 0
2191
+ };
2192
+ });
2193
+ var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $Q(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
2194
+ var name = $2;
2195
+ var suffix = $5;
2196
+ name = name.token.match(/^(?:"|')/) ? name.token.slice(1, -1) : name.token;
2197
+ return {
2198
+ type: "MethodSignature",
2199
+ children: $0,
2200
+ name,
2201
+ modifier: $1?.[0]?.token,
2202
+ returnType: void 0
2203
+ };
2204
+ });
2127
2205
  function MethodSignature(state) {
2128
2206
  if (state.tokenize) {
2129
2207
  return $TOKEN("MethodSignature", state, MethodSignature$0(state) || MethodSignature$1(state));
@@ -2140,7 +2218,12 @@ var Civet = (() => {
2140
2218
  return ClassElementName$0(state) || ClassElementName$1(state);
2141
2219
  }
2142
2220
  }
2143
- var PrivateIdentifier$0 = $S($EXPECT($L8, fail, 'PrivateIdentifier "#"'), IdentifierName);
2221
+ var PrivateIdentifier$0 = $TV($TEXT($S($EXPECT($L8, fail, 'PrivateIdentifier "#"'), IdentifierName)), function($skip, $loc, $0, $1) {
2222
+ return {
2223
+ $loc,
2224
+ token: $1
2225
+ };
2226
+ });
2144
2227
  function PrivateIdentifier(state) {
2145
2228
  if (state.verbose)
2146
2229
  console.log("ENTER:", "PrivateIdentifier");
@@ -4413,7 +4496,7 @@ var Civet = (() => {
4413
4496
  }
4414
4497
  }
4415
4498
  var InterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
4416
- var InterfaceProperty$1 = $S(MethodSignature, $E(TypeSuffix));
4499
+ var InterfaceProperty$1 = MethodSignature;
4417
4500
  function InterfaceProperty(state) {
4418
4501
  if (state.tokenize) {
4419
4502
  return $TOKEN("InterfaceProperty", state, InterfaceProperty$0(state) || InterfaceProperty$1(state));
@@ -4491,7 +4574,7 @@ var Civet = (() => {
4491
4574
  }
4492
4575
  }
4493
4576
  var TypeSuffix$0 = $T($S($E(QuestionMark), __, Colon, Type), function(value) {
4494
- return { "ts": true, "children": value };
4577
+ return { "type": "TypeSuffix", "ts": true, "children": value };
4495
4578
  });
4496
4579
  function TypeSuffix(state) {
4497
4580
  if (state.verbose)
@@ -4502,8 +4585,16 @@ var Civet = (() => {
4502
4585
  return TypeSuffix$0(state);
4503
4586
  }
4504
4587
  }
4505
- var ReturnTypeSuffix$0 = $T($S(__, Colon, $E($S(__, $EXPECT($L137, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function(value) {
4506
- return { "ts": true, "children": value };
4588
+ var ReturnTypeSuffix$0 = $TS($S(__, Colon, $E($S(__, $EXPECT($L137, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
4589
+ if (!$3)
4590
+ $0.splice(2, 1);
4591
+ if ($1.length === 0)
4592
+ $0.shift();
4593
+ return {
4594
+ type: "ReturnTypeAnnotation",
4595
+ children: $0,
4596
+ ts: true
4597
+ };
4507
4598
  });
4508
4599
  function ReturnTypeSuffix(state) {
4509
4600
  if (state.verbose)
@@ -4514,7 +4605,11 @@ var Civet = (() => {
4514
4605
  return ReturnTypeSuffix$0(state);
4515
4606
  }
4516
4607
  }
4517
- var TypePredicate$0 = $S(Type, $E($S(__, $EXPECT($L56, fail, 'TypePredicate "is"'), NonIdContinue, Type)));
4608
+ var TypePredicate$0 = $TS($S(Type, $E($S(__, $EXPECT($L56, fail, 'TypePredicate "is"'), NonIdContinue, Type))), function($skip, $loc, $0, $1, $2) {
4609
+ if (!$2)
4610
+ return $1;
4611
+ return $0;
4612
+ });
4518
4613
  function TypePredicate(state) {
4519
4614
  if (state.verbose)
4520
4615
  console.log("ENTER:", "TypePredicate");
@@ -4534,7 +4629,11 @@ var Civet = (() => {
4534
4629
  return Type$0(state);
4535
4630
  }
4536
4631
  }
4537
- var TypeBinary$0 = $S(TypeUnary, $Q($S(__, TypeBinaryOp, __, TypeUnary)));
4632
+ var TypeBinary$0 = $TS($S(TypeUnary, $Q($S(__, TypeBinaryOp, __, TypeUnary))), function($skip, $loc, $0, $1, $2) {
4633
+ if ($2.length)
4634
+ return $0;
4635
+ return $1;
4636
+ });
4538
4637
  function TypeBinary(state) {
4539
4638
  if (state.verbose)
4540
4639
  console.log("ENTER:", "TypeBinary");
@@ -4544,7 +4643,13 @@ var Civet = (() => {
4544
4643
  return TypeBinary$0(state);
4545
4644
  }
4546
4645
  }
4547
- var TypeUnary$0 = $S($Q($S(__, TypeUnaryOp, NonIdContinue)), TypePrimary, $Q(TypeUnarySuffix));
4646
+ var TypeUnary$0 = $TS($S($Q($S(__, TypeUnaryOp, NonIdContinue)), TypePrimary, $Q(TypeUnarySuffix)), function($skip, $loc, $0, $1, $2, $3) {
4647
+ if (!$3.length)
4648
+ $0.pop();
4649
+ if (!$1.length)
4650
+ $0.shift();
4651
+ return $0;
4652
+ });
4548
4653
  function TypeUnary(state) {
4549
4654
  if (state.verbose)
4550
4655
  console.log("ENTER:", "TypeUnary");
@@ -4587,8 +4692,8 @@ var Civet = (() => {
4587
4692
  var TypePrimary$0 = InterfaceBlock;
4588
4693
  var TypePrimary$1 = $S(__, OpenParen, Type, __, CloseParen);
4589
4694
  var TypePrimary$2 = $S($Q(_), FunctionType);
4590
- var TypePrimary$3 = $S($Q(_), IdentifierName, $Q($S(Dot, IdentifierName)), $E(TypeArguments));
4591
- var TypePrimary$4 = $S($Q(_), TypeLiteral);
4695
+ var TypePrimary$3 = $S($Q(_), TypeLiteral);
4696
+ var TypePrimary$4 = $S($Q(_), IdentifierName, $Q($S(Dot, IdentifierName)), $E(TypeArguments));
4592
4697
  function TypePrimary(state) {
4593
4698
  if (state.tokenize) {
4594
4699
  return $TOKEN("TypePrimary", state, TypePrimary$0(state) || TypePrimary$1(state) || TypePrimary$2(state) || TypePrimary$3(state) || TypePrimary$4(state));
@@ -4596,7 +4701,11 @@ var Civet = (() => {
4596
4701
  return TypePrimary$0(state) || TypePrimary$1(state) || TypePrimary$2(state) || TypePrimary$3(state) || TypePrimary$4(state);
4597
4702
  }
4598
4703
  }
4599
- var TypeConditional$0 = $S(TypeBinary, $E($S(__, $EXPECT($L6, fail, 'TypeConditional "extends"'), Type, $E($S(__, QuestionMark, Type, __, Colon, Type)))));
4704
+ var TypeConditional$0 = $TS($S(TypeBinary, $E($S(__, $EXPECT($L6, fail, 'TypeConditional "extends"'), Type, $E($S(__, QuestionMark, Type, __, Colon, Type))))), function($skip, $loc, $0, $1, $2) {
4705
+ if ($2)
4706
+ return $0;
4707
+ return $1;
4708
+ });
4600
4709
  function TypeConditional(state) {
4601
4710
  if (state.verbose)
4602
4711
  console.log("ENTER:", "TypeConditional");
@@ -4607,8 +4716,12 @@ var Civet = (() => {
4607
4716
  }
4608
4717
  }
4609
4718
  var TypeLiteral$0 = Literal;
4610
- var TypeLiteral$1 = $EXPECT($L70, fail, 'TypeLiteral "void"');
4611
- var TypeLiteral$2 = $EXPECT($L140, fail, 'TypeLiteral "[]"');
4719
+ var TypeLiteral$1 = $TV($EXPECT($L70, fail, 'TypeLiteral "void"'), function($skip, $loc, $0, $1) {
4720
+ return { $loc, token: "void" };
4721
+ });
4722
+ var TypeLiteral$2 = $TV($EXPECT($L140, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
4723
+ return { $loc, token: "[]" };
4724
+ });
4612
4725
  function TypeLiteral(state) {
4613
4726
  if (state.tokenize) {
4614
4727
  return $TOKEN("TypeLiteral", state, TypeLiteral$0(state) || TypeLiteral$1(state) || TypeLiteral$2(state));
@@ -4616,8 +4729,12 @@ var Civet = (() => {
4616
4729
  return TypeLiteral$0(state) || TypeLiteral$1(state) || TypeLiteral$2(state);
4617
4730
  }
4618
4731
  }
4619
- var TypeBinaryOp$0 = $EXPECT($L68, fail, 'TypeBinaryOp "|"');
4620
- var TypeBinaryOp$1 = $EXPECT($L66, fail, 'TypeBinaryOp "&"');
4732
+ var TypeBinaryOp$0 = $TV($EXPECT($L68, fail, 'TypeBinaryOp "|"'), function($skip, $loc, $0, $1) {
4733
+ return { $loc, token: "|" };
4734
+ });
4735
+ var TypeBinaryOp$1 = $TV($EXPECT($L66, fail, 'TypeBinaryOp "&"'), function($skip, $loc, $0, $1) {
4736
+ return { $loc, token: "&" };
4737
+ });
4621
4738
  function TypeBinaryOp(state) {
4622
4739
  if (state.tokenize) {
4623
4740
  return $TOKEN("TypeBinaryOp", state, TypeBinaryOp$0(state) || TypeBinaryOp$1(state));
@@ -4949,7 +5066,6 @@ var Civet = (() => {
4949
5066
  if (!Array.isArray(node))
4950
5067
  return;
4951
5068
  const [, exp] = node;
4952
- debugger;
4953
5069
  if (!exp)
4954
5070
  return;
4955
5071
  switch (exp.type) {
@@ -4962,7 +5078,6 @@ var Civet = (() => {
4962
5078
  case "VariableDeclaration":
4963
5079
  return;
4964
5080
  case "IfStatement":
4965
- debugger;
4966
5081
  insertReturn(exp.children[2]);
4967
5082
  if (exp.children[3])
4968
5083
  insertReturn(exp.children[3][2]);
@@ -7,7 +7,7 @@ const { compile } = require("../dist/main.js");
7
7
  module.exports = {
8
8
  name: 'civet',
9
9
  setup(build) {
10
- build.onLoad({
10
+ return build.onLoad({
11
11
  filter: /\.civet$/
12
12
  }, async function(args) {
13
13
  try {
package/dist/main.js CHANGED
@@ -455,6 +455,7 @@ var require_parser = __commonJS({
455
455
  SuperProperty,
456
456
  MetaProperty,
457
457
  Parameters,
458
+ NonEmptyParameters,
458
459
  ParameterElement,
459
460
  ParameterElementDelimiter,
460
461
  BindingIdentifier,
@@ -475,6 +476,7 @@ var require_parser = __commonJS({
475
476
  Arrow,
476
477
  Block,
477
478
  BracedOrEmptyBlock,
479
+ EmptyBlock,
478
480
  BracedBlock,
479
481
  SingleNestedExpression,
480
482
  NestedBlockExpressions,
@@ -1178,7 +1180,19 @@ var require_parser = __commonJS({
1178
1180
  }
1179
1181
  }
1180
1182
  var ArrowFunction$0 = ThinArrowFunction;
1181
- var ArrowFunction$1 = $S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody);
1183
+ var ArrowFunction$1 = $TS($S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4) {
1184
+ var suffix = $2;
1185
+ var expOrBlock = $4;
1186
+ const isVoid = suffix?.children?.[1]?.[0]?.[1]?.token === "void";
1187
+ const isBlock = expOrBlock.type === "BlockStatement";
1188
+ if (module2.implicitReturns && !isVoid && isBlock) {
1189
+ module2.addImplicitReturns(expOrBlock);
1190
+ }
1191
+ return {
1192
+ type: "FunctionExpression",
1193
+ children: $0
1194
+ };
1195
+ });
1182
1196
  function ArrowFunction(state) {
1183
1197
  if (state.tokenize) {
1184
1198
  return $TOKEN("ArrowFunction", state, ArrowFunction$0(state) || ArrowFunction$1(state));
@@ -1201,11 +1215,17 @@ var require_parser = __commonJS({
1201
1215
  return FatArrow$0(state);
1202
1216
  }
1203
1217
  }
1204
- var FatArrowBody$0 = $S(__, OpenBrace, EOS, NestedBlockExpressions, __, CloseBrace);
1205
- var FatArrowBody$1 = $S(InsertOpenBrace, EOS, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseBrace);
1218
+ var FatArrowBody$0 = $T($S(__, OpenBrace, EOS, NestedBlockExpressions, __, CloseBrace), function(value) {
1219
+ var exps = value[3];
1220
+ return { "type": "BlockStatement", "expressions": exps, "children": value };
1221
+ });
1222
+ var FatArrowBody$1 = $T($S(InsertOpenBrace, EOS, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseBrace), function(value) {
1223
+ var exps = value[2];
1224
+ return { "type": "BlockStatement", "expressions": exps, "children": value };
1225
+ });
1206
1226
  var FatArrowBody$2 = AssignmentExpression;
1207
1227
  var FatArrowBody$3 = $S(__, AssignmentExpression);
1208
- var FatArrowBody$4 = $S(InsertOpenBrace, InsertCloseBrace);
1228
+ var FatArrowBody$4 = EmptyBlock;
1209
1229
  function FatArrowBody(state) {
1210
1230
  if (state.tokenize) {
1211
1231
  return $TOKEN("FatArrowBody", state, FatArrowBody$0(state) || FatArrowBody$1(state) || FatArrowBody$2(state) || FatArrowBody$3(state) || FatArrowBody$4(state));
@@ -1521,7 +1541,7 @@ var require_parser = __commonJS({
1521
1541
  return MetaProperty$0(state) || MetaProperty$1(state);
1522
1542
  }
1523
1543
  }
1524
- var Parameters$0 = $S($E(TypeParameters), OpenParen, $Q(ParameterElement), __, CloseParen);
1544
+ var Parameters$0 = NonEmptyParameters;
1525
1545
  var Parameters$1 = $TV($EXPECT($L1, fail, 'Parameters ""'), function($skip, $loc, $0, $1) {
1526
1546
  return { $loc, token: "()" };
1527
1547
  });
@@ -1532,6 +1552,16 @@ var require_parser = __commonJS({
1532
1552
  return Parameters$0(state) || Parameters$1(state);
1533
1553
  }
1534
1554
  }
1555
+ var NonEmptyParameters$0 = $S($E(TypeParameters), OpenParen, $Q(ParameterElement), __, CloseParen);
1556
+ function NonEmptyParameters(state) {
1557
+ if (state.verbose)
1558
+ console.log("ENTER:", "NonEmptyParameters");
1559
+ if (state.tokenize) {
1560
+ return $TOKEN("NonEmptyParameters", state, NonEmptyParameters$0(state));
1561
+ } else {
1562
+ return NonEmptyParameters$0(state);
1563
+ }
1564
+ }
1535
1565
  var ParameterElement$0 = $S(__, $C(BindingIdentifier, BindingPattern), $E(TypeSuffix), $E(Initializer), ParameterElementDelimiter);
1536
1566
  function ParameterElement(state) {
1537
1567
  if (state.verbose)
@@ -1700,8 +1730,17 @@ var require_parser = __commonJS({
1700
1730
  }
1701
1731
  }
1702
1732
  var FunctionExpression$0 = ThinArrowFunction;
1703
- var FunctionExpression$1 = $T($S($E($S(Async, __)), Function, $E($S(Star, __)), $E(BindingIdentifier), __, Parameters, $E(ReturnTypeSuffix), BracedBlock), function(value) {
1704
- return { "type": "FunctionExpression", "children": value };
1733
+ var FunctionExpression$1 = $TS($S($E($S(Async, __)), Function, $E($S(Star, __)), $E(BindingIdentifier), __, Parameters, $E(ReturnTypeSuffix), BracedBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
1734
+ var suffix = $7;
1735
+ var block = $8;
1736
+ const isVoid = suffix?.children?.[1]?.[0]?.[1]?.token === "void";
1737
+ if (module2.implicitReturns && !isVoid) {
1738
+ module2.addImplicitReturns(block);
1739
+ }
1740
+ return {
1741
+ type: "FunctionExpression",
1742
+ children: $0
1743
+ };
1705
1744
  });
1706
1745
  function FunctionExpression(state) {
1707
1746
  if (state.tokenize) {
@@ -1715,7 +1754,8 @@ var require_parser = __commonJS({
1715
1754
  var suffix = $2;
1716
1755
  var arrow = $4;
1717
1756
  var block = $5;
1718
- if (module2.implicitReturns && suffix?.children[3] !== "void") {
1757
+ const isVoid = suffix?.children?.[1]?.[0]?.[1]?.token === "void";
1758
+ if (module2.implicitReturns && !isVoid) {
1719
1759
  block = module2.addImplicitReturns(block);
1720
1760
  }
1721
1761
  return {
@@ -1767,9 +1807,7 @@ var require_parser = __commonJS({
1767
1807
  }
1768
1808
  }
1769
1809
  var BracedOrEmptyBlock$0 = BracedBlock;
1770
- var BracedOrEmptyBlock$1 = $T($S(InsertOpenBrace, InsertCloseBrace), function(value) {
1771
- return { "type": "BlockStatement", "expressions": [], "children": value };
1772
- });
1810
+ var BracedOrEmptyBlock$1 = EmptyBlock;
1773
1811
  function BracedOrEmptyBlock(state) {
1774
1812
  if (state.tokenize) {
1775
1813
  return $TOKEN("BracedOrEmptyBlock", state, BracedOrEmptyBlock$0(state) || BracedOrEmptyBlock$1(state));
@@ -1777,6 +1815,18 @@ var require_parser = __commonJS({
1777
1815
  return BracedOrEmptyBlock$0(state) || BracedOrEmptyBlock$1(state);
1778
1816
  }
1779
1817
  }
1818
+ var EmptyBlock$0 = $T($S(InsertOpenBrace, InsertCloseBrace), function(value) {
1819
+ return { "type": "BlockStatement", "expressions": [], "children": value };
1820
+ });
1821
+ function EmptyBlock(state) {
1822
+ if (state.verbose)
1823
+ console.log("ENTER:", "EmptyBlock");
1824
+ if (state.tokenize) {
1825
+ return $TOKEN("EmptyBlock", state, EmptyBlock$0(state));
1826
+ } else {
1827
+ return EmptyBlock$0(state);
1828
+ }
1829
+ }
1780
1830
  var BracedBlock$0 = $T($S(__, OpenBrace, EOS, NestedBlockExpressions, __, CloseBrace), function(value) {
1781
1831
  var exps = value[3];
1782
1832
  return { "type": "BlockStatement", "expressions": exps, "children": value };
@@ -2100,7 +2150,17 @@ var require_parser = __commonJS({
2100
2150
  return PropertyName$0(state) || PropertyName$1(state) || PropertyName$2(state) || PropertyName$3(state);
2101
2151
  }
2102
2152
  }
2103
- var MethodDefinition$0 = $S(MethodSignature, BracedBlock);
2153
+ var MethodDefinition$0 = $TS($S(MethodSignature, BracedBlock), function($skip, $loc, $0, $1, $2) {
2154
+ var sig = $1;
2155
+ var block = $2;
2156
+ const isConstructor = sig.name === "constructor";
2157
+ const isVoid = sig.returnType === "void";
2158
+ const isSet = sig.modifier === "set";
2159
+ if (module2.implicitReturns && !isConstructor && !isSet && !isVoid) {
2160
+ block = module2.addImplicitReturns(block);
2161
+ }
2162
+ return $0;
2163
+ });
2104
2164
  function MethodDefinition(state) {
2105
2165
  if (state.verbose)
2106
2166
  console.log("ENTER:", "MethodDefinition");
@@ -2121,8 +2181,26 @@ var require_parser = __commonJS({
2121
2181
  return MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state) || MethodModifier$3(state);
2122
2182
  }
2123
2183
  }
2124
- var MethodSignature$0 = $S(ConstructorShorthand, Parameters);
2125
- var MethodSignature$1 = $S($E(MethodModifier), ClassElementName, $Q(_), Parameters);
2184
+ var MethodSignature$0 = $TS($S(ConstructorShorthand, Parameters), function($skip, $loc, $0, $1, $2) {
2185
+ return {
2186
+ type: "MethodSignature",
2187
+ children: $0,
2188
+ name: $1.token,
2189
+ returnType: void 0
2190
+ };
2191
+ });
2192
+ var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $Q(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
2193
+ var name = $2;
2194
+ var suffix = $5;
2195
+ name = name.token.match(/^(?:"|')/) ? name.token.slice(1, -1) : name.token;
2196
+ return {
2197
+ type: "MethodSignature",
2198
+ children: $0,
2199
+ name,
2200
+ modifier: $1?.[0]?.token,
2201
+ returnType: void 0
2202
+ };
2203
+ });
2126
2204
  function MethodSignature(state) {
2127
2205
  if (state.tokenize) {
2128
2206
  return $TOKEN("MethodSignature", state, MethodSignature$0(state) || MethodSignature$1(state));
@@ -2139,7 +2217,12 @@ var require_parser = __commonJS({
2139
2217
  return ClassElementName$0(state) || ClassElementName$1(state);
2140
2218
  }
2141
2219
  }
2142
- var PrivateIdentifier$0 = $S($EXPECT($L8, fail, 'PrivateIdentifier "#"'), IdentifierName);
2220
+ var PrivateIdentifier$0 = $TV($TEXT($S($EXPECT($L8, fail, 'PrivateIdentifier "#"'), IdentifierName)), function($skip, $loc, $0, $1) {
2221
+ return {
2222
+ $loc,
2223
+ token: $1
2224
+ };
2225
+ });
2143
2226
  function PrivateIdentifier(state) {
2144
2227
  if (state.verbose)
2145
2228
  console.log("ENTER:", "PrivateIdentifier");
@@ -4412,7 +4495,7 @@ var require_parser = __commonJS({
4412
4495
  }
4413
4496
  }
4414
4497
  var InterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
4415
- var InterfaceProperty$1 = $S(MethodSignature, $E(TypeSuffix));
4498
+ var InterfaceProperty$1 = MethodSignature;
4416
4499
  function InterfaceProperty(state) {
4417
4500
  if (state.tokenize) {
4418
4501
  return $TOKEN("InterfaceProperty", state, InterfaceProperty$0(state) || InterfaceProperty$1(state));
@@ -4490,7 +4573,7 @@ var require_parser = __commonJS({
4490
4573
  }
4491
4574
  }
4492
4575
  var TypeSuffix$0 = $T($S($E(QuestionMark), __, Colon, Type), function(value) {
4493
- return { "ts": true, "children": value };
4576
+ return { "type": "TypeSuffix", "ts": true, "children": value };
4494
4577
  });
4495
4578
  function TypeSuffix(state) {
4496
4579
  if (state.verbose)
@@ -4501,8 +4584,16 @@ var require_parser = __commonJS({
4501
4584
  return TypeSuffix$0(state);
4502
4585
  }
4503
4586
  }
4504
- var ReturnTypeSuffix$0 = $T($S(__, Colon, $E($S(__, $EXPECT($L137, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function(value) {
4505
- return { "ts": true, "children": value };
4587
+ var ReturnTypeSuffix$0 = $TS($S(__, Colon, $E($S(__, $EXPECT($L137, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
4588
+ if (!$3)
4589
+ $0.splice(2, 1);
4590
+ if ($1.length === 0)
4591
+ $0.shift();
4592
+ return {
4593
+ type: "ReturnTypeAnnotation",
4594
+ children: $0,
4595
+ ts: true
4596
+ };
4506
4597
  });
4507
4598
  function ReturnTypeSuffix(state) {
4508
4599
  if (state.verbose)
@@ -4513,7 +4604,11 @@ var require_parser = __commonJS({
4513
4604
  return ReturnTypeSuffix$0(state);
4514
4605
  }
4515
4606
  }
4516
- var TypePredicate$0 = $S(Type, $E($S(__, $EXPECT($L56, fail, 'TypePredicate "is"'), NonIdContinue, Type)));
4607
+ var TypePredicate$0 = $TS($S(Type, $E($S(__, $EXPECT($L56, fail, 'TypePredicate "is"'), NonIdContinue, Type))), function($skip, $loc, $0, $1, $2) {
4608
+ if (!$2)
4609
+ return $1;
4610
+ return $0;
4611
+ });
4517
4612
  function TypePredicate(state) {
4518
4613
  if (state.verbose)
4519
4614
  console.log("ENTER:", "TypePredicate");
@@ -4533,7 +4628,11 @@ var require_parser = __commonJS({
4533
4628
  return Type$0(state);
4534
4629
  }
4535
4630
  }
4536
- var TypeBinary$0 = $S(TypeUnary, $Q($S(__, TypeBinaryOp, __, TypeUnary)));
4631
+ var TypeBinary$0 = $TS($S(TypeUnary, $Q($S(__, TypeBinaryOp, __, TypeUnary))), function($skip, $loc, $0, $1, $2) {
4632
+ if ($2.length)
4633
+ return $0;
4634
+ return $1;
4635
+ });
4537
4636
  function TypeBinary(state) {
4538
4637
  if (state.verbose)
4539
4638
  console.log("ENTER:", "TypeBinary");
@@ -4543,7 +4642,13 @@ var require_parser = __commonJS({
4543
4642
  return TypeBinary$0(state);
4544
4643
  }
4545
4644
  }
4546
- var TypeUnary$0 = $S($Q($S(__, TypeUnaryOp, NonIdContinue)), TypePrimary, $Q(TypeUnarySuffix));
4645
+ var TypeUnary$0 = $TS($S($Q($S(__, TypeUnaryOp, NonIdContinue)), TypePrimary, $Q(TypeUnarySuffix)), function($skip, $loc, $0, $1, $2, $3) {
4646
+ if (!$3.length)
4647
+ $0.pop();
4648
+ if (!$1.length)
4649
+ $0.shift();
4650
+ return $0;
4651
+ });
4547
4652
  function TypeUnary(state) {
4548
4653
  if (state.verbose)
4549
4654
  console.log("ENTER:", "TypeUnary");
@@ -4586,8 +4691,8 @@ var require_parser = __commonJS({
4586
4691
  var TypePrimary$0 = InterfaceBlock;
4587
4692
  var TypePrimary$1 = $S(__, OpenParen, Type, __, CloseParen);
4588
4693
  var TypePrimary$2 = $S($Q(_), FunctionType);
4589
- var TypePrimary$3 = $S($Q(_), IdentifierName, $Q($S(Dot, IdentifierName)), $E(TypeArguments));
4590
- var TypePrimary$4 = $S($Q(_), TypeLiteral);
4694
+ var TypePrimary$3 = $S($Q(_), TypeLiteral);
4695
+ var TypePrimary$4 = $S($Q(_), IdentifierName, $Q($S(Dot, IdentifierName)), $E(TypeArguments));
4591
4696
  function TypePrimary(state) {
4592
4697
  if (state.tokenize) {
4593
4698
  return $TOKEN("TypePrimary", state, TypePrimary$0(state) || TypePrimary$1(state) || TypePrimary$2(state) || TypePrimary$3(state) || TypePrimary$4(state));
@@ -4595,7 +4700,11 @@ var require_parser = __commonJS({
4595
4700
  return TypePrimary$0(state) || TypePrimary$1(state) || TypePrimary$2(state) || TypePrimary$3(state) || TypePrimary$4(state);
4596
4701
  }
4597
4702
  }
4598
- var TypeConditional$0 = $S(TypeBinary, $E($S(__, $EXPECT($L6, fail, 'TypeConditional "extends"'), Type, $E($S(__, QuestionMark, Type, __, Colon, Type)))));
4703
+ var TypeConditional$0 = $TS($S(TypeBinary, $E($S(__, $EXPECT($L6, fail, 'TypeConditional "extends"'), Type, $E($S(__, QuestionMark, Type, __, Colon, Type))))), function($skip, $loc, $0, $1, $2) {
4704
+ if ($2)
4705
+ return $0;
4706
+ return $1;
4707
+ });
4599
4708
  function TypeConditional(state) {
4600
4709
  if (state.verbose)
4601
4710
  console.log("ENTER:", "TypeConditional");
@@ -4606,8 +4715,12 @@ var require_parser = __commonJS({
4606
4715
  }
4607
4716
  }
4608
4717
  var TypeLiteral$0 = Literal;
4609
- var TypeLiteral$1 = $EXPECT($L70, fail, 'TypeLiteral "void"');
4610
- var TypeLiteral$2 = $EXPECT($L140, fail, 'TypeLiteral "[]"');
4718
+ var TypeLiteral$1 = $TV($EXPECT($L70, fail, 'TypeLiteral "void"'), function($skip, $loc, $0, $1) {
4719
+ return { $loc, token: "void" };
4720
+ });
4721
+ var TypeLiteral$2 = $TV($EXPECT($L140, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
4722
+ return { $loc, token: "[]" };
4723
+ });
4611
4724
  function TypeLiteral(state) {
4612
4725
  if (state.tokenize) {
4613
4726
  return $TOKEN("TypeLiteral", state, TypeLiteral$0(state) || TypeLiteral$1(state) || TypeLiteral$2(state));
@@ -4615,8 +4728,12 @@ var require_parser = __commonJS({
4615
4728
  return TypeLiteral$0(state) || TypeLiteral$1(state) || TypeLiteral$2(state);
4616
4729
  }
4617
4730
  }
4618
- var TypeBinaryOp$0 = $EXPECT($L68, fail, 'TypeBinaryOp "|"');
4619
- var TypeBinaryOp$1 = $EXPECT($L66, fail, 'TypeBinaryOp "&"');
4731
+ var TypeBinaryOp$0 = $TV($EXPECT($L68, fail, 'TypeBinaryOp "|"'), function($skip, $loc, $0, $1) {
4732
+ return { $loc, token: "|" };
4733
+ });
4734
+ var TypeBinaryOp$1 = $TV($EXPECT($L66, fail, 'TypeBinaryOp "&"'), function($skip, $loc, $0, $1) {
4735
+ return { $loc, token: "&" };
4736
+ });
4620
4737
  function TypeBinaryOp(state) {
4621
4738
  if (state.tokenize) {
4622
4739
  return $TOKEN("TypeBinaryOp", state, TypeBinaryOp$0(state) || TypeBinaryOp$1(state));
@@ -4948,7 +5065,6 @@ var require_parser = __commonJS({
4948
5065
  if (!Array.isArray(node))
4949
5066
  return;
4950
5067
  const [, exp] = node;
4951
- debugger;
4952
5068
  if (!exp)
4953
5069
  return;
4954
5070
  switch (exp.type) {
@@ -4961,7 +5077,6 @@ var require_parser = __commonJS({
4961
5077
  case "VariableDeclaration":
4962
5078
  return;
4963
5079
  case "IfStatement":
4964
- debugger;
4965
5080
  insertReturn(exp.children[2]);
4966
5081
  if (exp.children[3])
4967
5082
  insertReturn(exp.children[3][2]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "exports": {