@danielx/civet 0.4.17 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +11 -23
  2. package/dist/browser.js +583 -242
  3. package/dist/main.js +583 -242
  4. package/package.json +1 -1
package/dist/browser.js CHANGED
@@ -550,6 +550,10 @@ var Civet = (() => {
550
550
  ForStatement,
551
551
  ForClause,
552
552
  ForStatementControl,
553
+ WhenCondition,
554
+ CoffeeForStatementParameters,
555
+ CoffeeForDeclaration,
556
+ ForStatementParameters,
553
557
  ForInOfDeclaration,
554
558
  ForDeclaration,
555
559
  ForBinding,
@@ -643,6 +647,7 @@ var Civet = (() => {
643
647
  StatementDelimiter,
644
648
  NonIdContinue,
645
649
  Loc,
650
+ Ampersand,
646
651
  As,
647
652
  Async,
648
653
  Await,
@@ -781,9 +786,11 @@ var Civet = (() => {
781
786
  InsertBreak,
782
787
  CoffeeCommentEnabled,
783
788
  CoffeeBooleansEnabled,
789
+ CoffeeForLoopsEnabled,
784
790
  CoffeeInterpolationEnabled,
785
791
  CoffeeIsntEnabled,
786
792
  CoffeeNotEnabled,
793
+ CoffeeOfEnabled,
787
794
  Reset,
788
795
  Init,
789
796
  Indent,
@@ -859,95 +866,96 @@ var Civet = (() => {
859
866
  var $L62 = $L("==");
860
867
  var $L63 = $L("and");
861
868
  var $L64 = $L("&&");
862
- var $L65 = $L("or");
863
- var $L66 = $L("||");
864
- var $L67 = $L("??");
865
- var $L68 = $L("instanceof");
866
- var $L69 = $L("in");
867
- var $L70 = $L("&");
868
- var $L71 = $L("^");
869
- var $L72 = $L("|");
870
- var $L73 = $L(";");
871
- var $L74 = $L("finally");
872
- var $L75 = $L("break");
873
- var $L76 = $L("continue");
874
- var $L77 = $L("debugger");
875
- var $L78 = $L("import type");
876
- var $L79 = $L("default");
877
- var $L80 = $L(":=");
878
- var $L81 = $L("/*");
879
- var $L82 = $L("*/");
880
- var $L83 = $L("###");
881
- var $L84 = $L("as");
882
- var $L85 = $L("async");
883
- var $L86 = $L("await");
884
- var $L87 = $L("`");
885
- var $L88 = $L("case");
886
- var $L89 = $L("catch");
887
- var $L90 = $L("class");
888
- var $L91 = $L("#{");
889
- var $L92 = $L(":");
890
- var $L93 = $L("delete");
891
- var $L94 = $L("do");
892
- var $L95 = $L("..");
893
- var $L96 = $L("...");
894
- var $L97 = $L('"');
895
- var $L98 = $L("else");
896
- var $L99 = $L("export");
897
- var $L100 = $L("for");
898
- var $L101 = $L("from");
899
- var $L102 = $L("function");
900
- var $L103 = $L("get");
901
- var $L104 = $L("set");
902
- var $L105 = $L("if");
903
- var $L106 = $L(" ");
904
- var $L107 = $L("let");
905
- var $L108 = $L("const");
906
- var $L109 = $L("loop");
907
- var $L110 = $L("new");
908
- var $L111 = $L("not");
909
- var $L112 = $L("of");
910
- var $L113 = $L("{");
911
- var $L114 = $L("[");
912
- var $L115 = $L("(");
913
- var $L116 = $L("?");
914
- var $L117 = $L("return");
915
- var $L118 = $L("'");
916
- var $L119 = $L("static");
917
- var $L120 = $L("${");
918
- var $L121 = $L("switch");
919
- var $L122 = $L("target");
920
- var $L123 = $L("then");
921
- var $L124 = $L("throw");
922
- var $L125 = $L('"""');
923
- var $L126 = $L("'''");
924
- var $L127 = $L("```");
925
- var $L128 = $L("try");
926
- var $L129 = $L("typeof");
927
- var $L130 = $L("unless");
928
- var $L131 = $L("until");
929
- var $L132 = $L("var");
930
- var $L133 = $L("void");
931
- var $L134 = $L("when");
932
- var $L135 = $L("while");
933
- var $L136 = $L("yield");
934
- var $L137 = $L("/>");
935
- var $L138 = $L("</");
936
- var $L139 = $L("<>");
937
- var $L140 = $L("</>");
938
- var $L141 = $L("declare");
939
- var $L142 = $L("type");
940
- var $L143 = $L("interface");
941
- var $L144 = $L("namespace");
942
- var $L145 = $L("readonly");
943
- var $L146 = $L("asserts");
944
- var $L147 = $L("keyof");
945
- var $L148 = $L("infer");
946
- var $L149 = $L("[]");
947
- var $L150 = $L("civet");
948
- var $L151 = $L(" ");
949
- var $L152 = $L(" ");
950
- var $R0 = $R(new RegExp("(of|then)(?!\\p{ID_Continue}|[\\u200C\\u200D$])", "suy"));
869
+ var $L65 = $L("of");
870
+ var $L66 = $L("or");
871
+ var $L67 = $L("||");
872
+ var $L68 = $L("??");
873
+ var $L69 = $L("instanceof");
874
+ var $L70 = $L("in");
875
+ var $L71 = $L("&");
876
+ var $L72 = $L("^");
877
+ var $L73 = $L("|");
878
+ var $L74 = $L(";");
879
+ var $L75 = $L("own");
880
+ var $L76 = $L("finally");
881
+ var $L77 = $L("break");
882
+ var $L78 = $L("continue");
883
+ var $L79 = $L("debugger");
884
+ var $L80 = $L("import type");
885
+ var $L81 = $L("default");
886
+ var $L82 = $L(":=");
887
+ var $L83 = $L("/*");
888
+ var $L84 = $L("*/");
889
+ var $L85 = $L("###");
890
+ var $L86 = $L("as");
891
+ var $L87 = $L("async");
892
+ var $L88 = $L("await");
893
+ var $L89 = $L("`");
894
+ var $L90 = $L("case");
895
+ var $L91 = $L("catch");
896
+ var $L92 = $L("class");
897
+ var $L93 = $L("#{");
898
+ var $L94 = $L(":");
899
+ var $L95 = $L("delete");
900
+ var $L96 = $L("do");
901
+ var $L97 = $L("..");
902
+ var $L98 = $L("...");
903
+ var $L99 = $L('"');
904
+ var $L100 = $L("else");
905
+ var $L101 = $L("export");
906
+ var $L102 = $L("for");
907
+ var $L103 = $L("from");
908
+ var $L104 = $L("function");
909
+ var $L105 = $L("get");
910
+ var $L106 = $L("set");
911
+ var $L107 = $L("if");
912
+ var $L108 = $L(" ");
913
+ var $L109 = $L("let");
914
+ var $L110 = $L("const");
915
+ var $L111 = $L("loop");
916
+ var $L112 = $L("new");
917
+ var $L113 = $L("not");
918
+ var $L114 = $L("{");
919
+ var $L115 = $L("[");
920
+ var $L116 = $L("(");
921
+ var $L117 = $L("?");
922
+ var $L118 = $L("return");
923
+ var $L119 = $L("'");
924
+ var $L120 = $L("static");
925
+ var $L121 = $L("${");
926
+ var $L122 = $L("switch");
927
+ var $L123 = $L("target");
928
+ var $L124 = $L("then");
929
+ var $L125 = $L("throw");
930
+ var $L126 = $L('"""');
931
+ var $L127 = $L("'''");
932
+ var $L128 = $L("```");
933
+ var $L129 = $L("try");
934
+ var $L130 = $L("typeof");
935
+ var $L131 = $L("unless");
936
+ var $L132 = $L("until");
937
+ var $L133 = $L("var");
938
+ var $L134 = $L("void");
939
+ var $L135 = $L("when");
940
+ var $L136 = $L("while");
941
+ var $L137 = $L("yield");
942
+ var $L138 = $L("/>");
943
+ var $L139 = $L("</");
944
+ var $L140 = $L("<>");
945
+ var $L141 = $L("</>");
946
+ var $L142 = $L("declare");
947
+ var $L143 = $L("type");
948
+ var $L144 = $L("interface");
949
+ var $L145 = $L("namespace");
950
+ var $L146 = $L("readonly");
951
+ var $L147 = $L("asserts");
952
+ var $L148 = $L("keyof");
953
+ var $L149 = $L("infer");
954
+ var $L150 = $L("[]");
955
+ var $L151 = $L("civet");
956
+ var $L152 = $L(" ");
957
+ var $L153 = $L(" ");
958
+ var $R0 = $R(new RegExp("(of|then|when)(?!\\p{ID_Continue}|[\\u200C\\u200D$])", "suy"));
951
959
  var $R1 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$])*", "suy"));
952
960
  var $R2 = $R(new RegExp("[!~+-](?!\\s)", "suy"));
953
961
  var $R3 = $R(new RegExp("(?=[\\s\\)])", "suy"));
@@ -1016,7 +1024,12 @@ var Civet = (() => {
1016
1024
  return TopLevelStatement$0(state);
1017
1025
  }
1018
1026
  }
1019
- var ExtendedExpression$0 = $S(__, ExpressionizedStatement);
1027
+ var ExtendedExpression$0 = $TS($S(__, ExpressionizedStatement), function($skip, $loc, $0, $1, $2) {
1028
+ if ($1.length) {
1029
+ $2.children.splice(0, 0, ...$1);
1030
+ }
1031
+ return $2;
1032
+ });
1020
1033
  var ExtendedExpression$1 = AssignmentExpression;
1021
1034
  function ExtendedExpression(state) {
1022
1035
  if (state.tokenize) {
@@ -1161,7 +1174,23 @@ var Civet = (() => {
1161
1174
  }
1162
1175
  var BinaryOpExpression$0 = $TS($S(UnaryExpression, $Q($S(__, BinaryOp, __, UnaryExpression))), function($skip, $loc, $0, $1, $2) {
1163
1176
  if ($2.length) {
1164
- return module.expandChainedComparisons($0);
1177
+ const expandedOps = module.expandChainedComparisons($0);
1178
+ let i = 2;
1179
+ while (i < expandedOps.length) {
1180
+ const op = expandedOps[i];
1181
+ if (op.type === "Ref") {
1182
+ const [a, wsOp, op2, wsB, b] = expandedOps.slice(i - 2, i + 3);
1183
+ module.insertTrimmingSpace(wsOp, "");
1184
+ module.insertTrimmingSpace(wsB, "");
1185
+ expandedOps.splice(i - 2, 5, {
1186
+ type: "Call",
1187
+ children: [wsOp, op2, ".call(", wsB, b, ", ", a, ") >= 0"]
1188
+ });
1189
+ } else {
1190
+ i += 4;
1191
+ }
1192
+ }
1193
+ return expandedOps;
1165
1194
  }
1166
1195
  return $1;
1167
1196
  });
@@ -1256,40 +1285,56 @@ var Civet = (() => {
1256
1285
  var AssignmentExpressionTail$0 = YieldExpression;
1257
1286
  var AssignmentExpressionTail$1 = ArrowFunction;
1258
1287
  var AssignmentExpressionTail$2 = $TS($S($P($S(__, LeftHandSideExpression, __, AssignmentOp)), ExtendedExpression), function($skip, $loc, $0, $1, $2) {
1259
- const lastAssignment = $1[$1.length - 1];
1260
- let tail = [];
1261
- if (lastAssignment[3].token === "=") {
1262
- const lhs = lastAssignment[1];
1288
+ let tail = [], i = 0, len = $1.length;
1289
+ while (i < len) {
1290
+ const lastAssignment = $1[i++];
1291
+ const [, lhs, , op] = lastAssignment;
1292
+ if (op.token !== "=")
1293
+ continue;
1263
1294
  if (lhs.type === "ObjectExpression") {
1264
1295
  lhs.children.splice(0, 0, "(");
1265
1296
  tail.push(")");
1297
+ break;
1266
1298
  }
1267
- if (Array.isArray(lhs) && lhs.length > 1) {
1268
- const props = lhs[lhs.length - 1];
1269
- if (Array.isArray(props)) {
1270
- const lastProp = props[props.length - 1];
1271
- if (lastProp.type === "SliceExpression") {
1272
- const { start, end, children: c } = lastProp;
1273
- c[0].token = ".splice(";
1274
- c[1] = start;
1275
- c[2] = ", ";
1276
- if (end)
1277
- c[3] = [end, " - ", start];
1278
- else
1279
- c[3] = ["1/0"];
1280
- c[4] = [", ...", $2];
1281
- c[5] = ")";
1282
- lastAssignment.pop();
1283
- if (module.isWhitespaceOrEmpty(lastAssignment[2]))
1299
+ }
1300
+ i = len - 1;
1301
+ while (i >= 0) {
1302
+ const lastAssignment = $1[i];
1303
+ if (lastAssignment[3].token === "=") {
1304
+ const lhs = lastAssignment[1];
1305
+ if (Array.isArray(lhs) && lhs.length > 1) {
1306
+ const props = lhs[lhs.length - 1];
1307
+ if (Array.isArray(props)) {
1308
+ const lastProp = props[props.length - 1];
1309
+ if (lastProp.type === "SliceExpression") {
1310
+ const { start, end, children: c } = lastProp;
1311
+ c[0].token = ".splice(";
1312
+ c[1] = start;
1313
+ c[2] = ", ";
1314
+ if (end)
1315
+ c[3] = [end, " - ", start];
1316
+ else
1317
+ c[3] = ["1/0"];
1318
+ c[4] = [", ...", $2];
1319
+ c[5] = ")";
1284
1320
  lastAssignment.pop();
1285
- return $1;
1321
+ if (module.isWhitespaceOrEmpty(lastAssignment[2]))
1322
+ lastAssignment.pop();
1323
+ if ($1.length > 1) {
1324
+ throw new Error("Not implemented yet! TODO: Handle multiple splice assignments");
1325
+ }
1326
+ return $1;
1327
+ }
1286
1328
  }
1287
1329
  }
1288
1330
  }
1331
+ i--;
1289
1332
  }
1333
+ const names = $1.flatMap(([, l]) => l.names || []);
1290
1334
  return {
1291
1335
  type: "AssignmentExpression",
1292
- children: [...$0, ...tail]
1336
+ children: [...$0, ...tail],
1337
+ names
1293
1338
  };
1294
1339
  });
1295
1340
  var AssignmentExpressionTail$3 = ConditionalExpression;
@@ -1623,7 +1668,7 @@ var Civet = (() => {
1623
1668
  return NonNullAssertion$0(state);
1624
1669
  }
1625
1670
  }
1626
- var AdditionalReservedWords$0 = $R$0($EXPECT($R0, fail, "AdditionalReservedWords /(of|then)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
1671
+ var AdditionalReservedWords$0 = $R$0($EXPECT($R0, fail, "AdditionalReservedWords /(of|then|when)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
1627
1672
  function AdditionalReservedWords(state) {
1628
1673
  if (state.verbose)
1629
1674
  console.log("ENTER:", "AdditionalReservedWords");
@@ -1648,11 +1693,19 @@ var Civet = (() => {
1648
1693
  }
1649
1694
  }
1650
1695
  var MemberExpressionRest$0 = $TS($S($E($C(OptionalShorthand, NonNullAssertion)), MemberBracketContent), function($skip, $loc, $0, $1, $2) {
1651
- if ($1)
1696
+ if ($1) {
1697
+ if ($1.length === 2 && $2.type === "SliceExpression") {
1698
+ $1.pop();
1699
+ }
1652
1700
  return $0;
1701
+ }
1702
+ return $2;
1703
+ });
1704
+ var MemberExpressionRest$1 = $TS($S($E($S($Y(EOS), IndentedFurther)), PropertyAccess), function($skip, $loc, $0, $1, $2) {
1705
+ if ($1)
1706
+ $2.children.unshift($1[1]);
1653
1707
  return $2;
1654
1708
  });
1655
- var MemberExpressionRest$1 = $S($E($S($Y(EOS), IndentedFurther)), PropertyAccess);
1656
1709
  var MemberExpressionRest$2 = $TS($S($E($S($Y(EOS), IndentedFurther)), $EXPECT($L13, fail, 'MemberExpressionRest "::"'), $E(IdentifierName)), function($skip, $loc, $0, $1, $2, $3) {
1657
1710
  var id = $3;
1658
1711
  if (id)
@@ -1709,7 +1762,14 @@ var Civet = (() => {
1709
1762
  return MemberBracketContent$0(state);
1710
1763
  }
1711
1764
  }
1712
- var PropertyAccess$0 = $S($E($C(QuestionMark, NonNullAssertion)), Dot, $C(IdentifierName, PrivateIdentifier));
1765
+ var PropertyAccess$0 = $TS($S($E($C(QuestionMark, NonNullAssertion)), Dot, $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
1766
+ var id = $3;
1767
+ id.type = "PropertyAccess";
1768
+ id.children.unshift($2);
1769
+ if ($1)
1770
+ id.children.unshift($1);
1771
+ return id;
1772
+ });
1713
1773
  function PropertyAccess(state) {
1714
1774
  if (state.verbose)
1715
1775
  console.log("ENTER:", "PropertyAccess");
@@ -2136,13 +2196,18 @@ var Civet = (() => {
2136
2196
  $1.type = "FunctionExpression";
2137
2197
  return $1;
2138
2198
  });
2199
+ var FunctionExpression$1 = $TS($S(Ampersand, $P(MemberExpressionRest)), function($skip, $loc, $0, $1, $2) {
2200
+ $1.token = "$ => $";
2201
+ return {
2202
+ type: "FunctionExpression",
2203
+ children: [$1, $2]
2204
+ };
2205
+ });
2139
2206
  function FunctionExpression(state) {
2140
- if (state.verbose)
2141
- console.log("ENTER:", "FunctionExpression");
2142
2207
  if (state.tokenize) {
2143
- return $TOKEN("FunctionExpression", state, FunctionExpression$0(state));
2208
+ return $TOKEN("FunctionExpression", state, FunctionExpression$0(state) || FunctionExpression$1(state));
2144
2209
  } else {
2145
- return FunctionExpression$0(state);
2210
+ return FunctionExpression$0(state) || FunctionExpression$1(state);
2146
2211
  }
2147
2212
  }
2148
2213
  var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
@@ -2770,8 +2835,13 @@ var Civet = (() => {
2770
2835
  }
2771
2836
  var PrivateIdentifier$0 = $TV($TEXT($S($EXPECT($L7, fail, 'PrivateIdentifier "#"'), IdentifierName)), function($skip, $loc, $0, $1) {
2772
2837
  return {
2773
- $loc,
2774
- token: $1
2838
+ type: "Identifier",
2839
+ name: $0,
2840
+ names: [$0],
2841
+ children: [{
2842
+ $loc,
2843
+ token: $0
2844
+ }]
2775
2845
  };
2776
2846
  });
2777
2847
  function PrivateIdentifier(state) {
@@ -2822,7 +2892,9 @@ var Civet = (() => {
2822
2892
  }
2823
2893
  }
2824
2894
  var BinaryOp$0 = $TS($S(BinaryOpSymbol), function($skip, $loc, $0, $1) {
2825
- return { $loc, token: $1 };
2895
+ if (typeof $1 === "string")
2896
+ return { $loc, token: $1 };
2897
+ return $1;
2826
2898
  });
2827
2899
  function BinaryOp(state) {
2828
2900
  if (state.verbose)
@@ -2870,25 +2942,31 @@ var Civet = (() => {
2870
2942
  return "&&";
2871
2943
  });
2872
2944
  var BinaryOpSymbol$20 = $EXPECT($L64, fail, 'BinaryOpSymbol "&&"');
2873
- var BinaryOpSymbol$21 = $T($S($EXPECT($L65, fail, 'BinaryOpSymbol "or"'), NonIdContinue), function(value) {
2945
+ var BinaryOpSymbol$21 = $T($S(CoffeeOfEnabled, $EXPECT($L65, fail, 'BinaryOpSymbol "of"'), NonIdContinue), function(value) {
2946
+ return "in";
2947
+ });
2948
+ var BinaryOpSymbol$22 = $T($S($EXPECT($L66, fail, 'BinaryOpSymbol "or"'), NonIdContinue), function(value) {
2874
2949
  return "||";
2875
2950
  });
2876
- var BinaryOpSymbol$22 = $EXPECT($L66, fail, 'BinaryOpSymbol "||"');
2877
- var BinaryOpSymbol$23 = $EXPECT($L67, fail, 'BinaryOpSymbol "??"');
2878
- var BinaryOpSymbol$24 = $TS($S($EXPECT($L68, fail, 'BinaryOpSymbol "instanceof"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
2951
+ var BinaryOpSymbol$23 = $EXPECT($L67, fail, 'BinaryOpSymbol "||"');
2952
+ var BinaryOpSymbol$24 = $EXPECT($L68, fail, 'BinaryOpSymbol "??"');
2953
+ var BinaryOpSymbol$25 = $TS($S($EXPECT($L69, fail, 'BinaryOpSymbol "instanceof"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
2879
2954
  return $1;
2880
2955
  });
2881
- var BinaryOpSymbol$25 = $TS($S($EXPECT($L69, fail, 'BinaryOpSymbol "in"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
2956
+ var BinaryOpSymbol$26 = $TS($S(CoffeeOfEnabled, $EXPECT($L70, fail, 'BinaryOpSymbol "in"'), NonIdContinue), function($skip, $loc, $0, $1, $2, $3) {
2957
+ return module.getIndexOfRef();
2958
+ });
2959
+ var BinaryOpSymbol$27 = $TS($S($EXPECT($L70, fail, 'BinaryOpSymbol "in"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
2882
2960
  return $1;
2883
2961
  });
2884
- var BinaryOpSymbol$26 = $EXPECT($L70, fail, 'BinaryOpSymbol "&"');
2885
- var BinaryOpSymbol$27 = $EXPECT($L71, fail, 'BinaryOpSymbol "^"');
2886
- var BinaryOpSymbol$28 = $EXPECT($L72, fail, 'BinaryOpSymbol "|"');
2962
+ var BinaryOpSymbol$28 = $EXPECT($L71, fail, 'BinaryOpSymbol "&"');
2963
+ var BinaryOpSymbol$29 = $EXPECT($L72, fail, 'BinaryOpSymbol "^"');
2964
+ var BinaryOpSymbol$30 = $EXPECT($L73, fail, 'BinaryOpSymbol "|"');
2887
2965
  function BinaryOpSymbol(state) {
2888
2966
  if (state.tokenize) {
2889
- return $TOKEN("BinaryOpSymbol", state, BinaryOpSymbol$0(state) || BinaryOpSymbol$1(state) || BinaryOpSymbol$2(state) || BinaryOpSymbol$3(state) || BinaryOpSymbol$4(state) || BinaryOpSymbol$5(state) || BinaryOpSymbol$6(state) || BinaryOpSymbol$7(state) || BinaryOpSymbol$8(state) || BinaryOpSymbol$9(state) || BinaryOpSymbol$10(state) || BinaryOpSymbol$11(state) || BinaryOpSymbol$12(state) || BinaryOpSymbol$13(state) || BinaryOpSymbol$14(state) || BinaryOpSymbol$15(state) || BinaryOpSymbol$16(state) || BinaryOpSymbol$17(state) || BinaryOpSymbol$18(state) || BinaryOpSymbol$19(state) || BinaryOpSymbol$20(state) || BinaryOpSymbol$21(state) || BinaryOpSymbol$22(state) || BinaryOpSymbol$23(state) || BinaryOpSymbol$24(state) || BinaryOpSymbol$25(state) || BinaryOpSymbol$26(state) || BinaryOpSymbol$27(state) || BinaryOpSymbol$28(state));
2967
+ return $TOKEN("BinaryOpSymbol", state, BinaryOpSymbol$0(state) || BinaryOpSymbol$1(state) || BinaryOpSymbol$2(state) || BinaryOpSymbol$3(state) || BinaryOpSymbol$4(state) || BinaryOpSymbol$5(state) || BinaryOpSymbol$6(state) || BinaryOpSymbol$7(state) || BinaryOpSymbol$8(state) || BinaryOpSymbol$9(state) || BinaryOpSymbol$10(state) || BinaryOpSymbol$11(state) || BinaryOpSymbol$12(state) || BinaryOpSymbol$13(state) || BinaryOpSymbol$14(state) || BinaryOpSymbol$15(state) || BinaryOpSymbol$16(state) || BinaryOpSymbol$17(state) || BinaryOpSymbol$18(state) || BinaryOpSymbol$19(state) || BinaryOpSymbol$20(state) || BinaryOpSymbol$21(state) || BinaryOpSymbol$22(state) || BinaryOpSymbol$23(state) || BinaryOpSymbol$24(state) || BinaryOpSymbol$25(state) || BinaryOpSymbol$26(state) || BinaryOpSymbol$27(state) || BinaryOpSymbol$28(state) || BinaryOpSymbol$29(state) || BinaryOpSymbol$30(state));
2890
2968
  } else {
2891
- return BinaryOpSymbol$0(state) || BinaryOpSymbol$1(state) || BinaryOpSymbol$2(state) || BinaryOpSymbol$3(state) || BinaryOpSymbol$4(state) || BinaryOpSymbol$5(state) || BinaryOpSymbol$6(state) || BinaryOpSymbol$7(state) || BinaryOpSymbol$8(state) || BinaryOpSymbol$9(state) || BinaryOpSymbol$10(state) || BinaryOpSymbol$11(state) || BinaryOpSymbol$12(state) || BinaryOpSymbol$13(state) || BinaryOpSymbol$14(state) || BinaryOpSymbol$15(state) || BinaryOpSymbol$16(state) || BinaryOpSymbol$17(state) || BinaryOpSymbol$18(state) || BinaryOpSymbol$19(state) || BinaryOpSymbol$20(state) || BinaryOpSymbol$21(state) || BinaryOpSymbol$22(state) || BinaryOpSymbol$23(state) || BinaryOpSymbol$24(state) || BinaryOpSymbol$25(state) || BinaryOpSymbol$26(state) || BinaryOpSymbol$27(state) || BinaryOpSymbol$28(state);
2969
+ return BinaryOpSymbol$0(state) || BinaryOpSymbol$1(state) || BinaryOpSymbol$2(state) || BinaryOpSymbol$3(state) || BinaryOpSymbol$4(state) || BinaryOpSymbol$5(state) || BinaryOpSymbol$6(state) || BinaryOpSymbol$7(state) || BinaryOpSymbol$8(state) || BinaryOpSymbol$9(state) || BinaryOpSymbol$10(state) || BinaryOpSymbol$11(state) || BinaryOpSymbol$12(state) || BinaryOpSymbol$13(state) || BinaryOpSymbol$14(state) || BinaryOpSymbol$15(state) || BinaryOpSymbol$16(state) || BinaryOpSymbol$17(state) || BinaryOpSymbol$18(state) || BinaryOpSymbol$19(state) || BinaryOpSymbol$20(state) || BinaryOpSymbol$21(state) || BinaryOpSymbol$22(state) || BinaryOpSymbol$23(state) || BinaryOpSymbol$24(state) || BinaryOpSymbol$25(state) || BinaryOpSymbol$26(state) || BinaryOpSymbol$27(state) || BinaryOpSymbol$28(state) || BinaryOpSymbol$29(state) || BinaryOpSymbol$30(state);
2892
2970
  }
2893
2971
  }
2894
2972
  var UnaryOp$0 = $TR($EXPECT($R2, fail, "UnaryOp /[!~+-](?!\\s)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
@@ -2919,7 +2997,18 @@ var Civet = (() => {
2919
2997
  var ws = $2;
2920
2998
  var post = $3;
2921
2999
  if (post) {
2922
- post.children.push(statement);
3000
+ let block;
3001
+ if (post.type === "ForStatement") {
3002
+ if (post.blockPrefix?.length) {
3003
+ block = [" {", ...post.blockPrefix, ...statement, " }"];
3004
+ } else {
3005
+ block = statement;
3006
+ }
3007
+ } else {
3008
+ block = statement;
3009
+ }
3010
+ post.block = block;
3011
+ post.children.push(block);
2923
3012
  if (!module.isWhitespaceOrEmpty(ws))
2924
3013
  post.children.push(ws);
2925
3014
  return post;
@@ -2961,7 +3050,7 @@ var Civet = (() => {
2961
3050
  return Statement$0(state) || Statement$1(state) || Statement$2(state) || Statement$3(state) || Statement$4(state) || Statement$5(state) || Statement$6(state) || Statement$7(state) || Statement$8(state);
2962
3051
  }
2963
3052
  }
2964
- var EmptyStatement$0 = $T($S($Q(TrailingComment), $Y($EXPECT($L73, fail, 'EmptyStatement ";"'))), function(value) {
3053
+ var EmptyStatement$0 = $T($S($Q(TrailingComment), $Y($EXPECT($L74, fail, 'EmptyStatement ";"'))), function(value) {
2965
3054
  return { "type": "EmptyStatement", "children": value[0] };
2966
3055
  });
2967
3056
  function EmptyStatement(state) {
@@ -3201,6 +3290,9 @@ var Civet = (() => {
3201
3290
  var block = $2;
3202
3291
  clause.children.push(block);
3203
3292
  clause.block = block;
3293
+ if (clause.blockPrefix) {
3294
+ block.expressions.splice(0, 0, ...clause.blockPrefix);
3295
+ }
3204
3296
  return clause;
3205
3297
  });
3206
3298
  function ForStatement(state) {
@@ -3220,7 +3312,8 @@ var Civet = (() => {
3220
3312
  type: "ForStatement",
3221
3313
  children,
3222
3314
  declaration,
3223
- block: null
3315
+ block: null,
3316
+ blockPrefix: c.blockPrefix
3224
3317
  };
3225
3318
  });
3226
3319
  function ForClause(state) {
@@ -3232,39 +3325,155 @@ var Civet = (() => {
3232
3325
  return ForClause$0(state);
3233
3326
  }
3234
3327
  }
3235
- var ForStatementControl$0 = $TS($S(OpenParen, __, $C(LexicalDeclaration, VariableStatement, $E(Expression)), __, Semicolon, $E(Expression), Semicolon, $E(Expression), __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) {
3328
+ var ForStatementControl$0 = $T($S($N(CoffeeForLoopsEnabled), ForStatementParameters), function(value) {
3329
+ return value[1];
3330
+ });
3331
+ var ForStatementControl$1 = $TS($S(CoffeeForLoopsEnabled, CoffeeForStatementParameters, $E(WhenCondition)), function($skip, $loc, $0, $1, $2, $3) {
3332
+ if ($3) {
3333
+ const indent = "".padStart((module.currentIndent + 1) * 2);
3334
+ module.insertTrimmingSpace($3, "");
3335
+ $2.blockPrefix.push({
3336
+ type: "IfStatement",
3337
+ children: [indent, "if (!(", $3, ")) continue\n"]
3338
+ });
3339
+ }
3340
+ return $2;
3341
+ });
3342
+ function ForStatementControl(state) {
3343
+ if (state.tokenize) {
3344
+ return $TOKEN("ForStatementControl", state, ForStatementControl$0(state) || ForStatementControl$1(state));
3345
+ } else {
3346
+ return ForStatementControl$0(state) || ForStatementControl$1(state);
3347
+ }
3348
+ }
3349
+ var WhenCondition$0 = $T($S(__, When, ExtendedExpression), function(value) {
3350
+ var exp = value[2];
3351
+ return exp;
3352
+ });
3353
+ function WhenCondition(state) {
3354
+ if (state.verbose)
3355
+ console.log("ENTER:", "WhenCondition");
3356
+ if (state.tokenize) {
3357
+ return $TOKEN("WhenCondition", state, WhenCondition$0(state));
3358
+ } else {
3359
+ return WhenCondition$0(state);
3360
+ }
3361
+ }
3362
+ var CoffeeForStatementParameters$0 = $TS($S($E($S(Await, __)), InsertOpenParen, CoffeeForDeclaration, __, $C(In, Of, From), ExtendedExpression, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
3363
+ var declaration = $3;
3364
+ var kind = $5;
3365
+ var exp = $6;
3366
+ let blockPrefix = [];
3367
+ if (kind.token === "from") {
3368
+ kind.token = "of";
3369
+ } else if (kind.token === "of") {
3370
+ module.insertTrimmingSpace(declaration, "");
3371
+ module.insertTrimmingSpace(exp, "");
3372
+ if (declaration.own) {
3373
+ const indent = "".padStart((module.currentIndent + 1) * 2);
3374
+ const hasPropRef = module.getHasPropRef();
3375
+ blockPrefix.push([indent, "if (!", hasPropRef, ".call(", exp, ", ", declaration, ")) continue\n"]);
3376
+ }
3377
+ kind.token = "in ";
3378
+ } else if (kind.token === "in") {
3379
+ const counterRef = {
3380
+ type: "Ref",
3381
+ base: "i"
3382
+ };
3383
+ const lenRef = {
3384
+ type: "Ref",
3385
+ base: "len"
3386
+ };
3387
+ const expRef = exp.type === "Identifier" ? exp : {
3388
+ type: "Ref",
3389
+ base: "ref"
3390
+ };
3391
+ const varRef = declaration;
3392
+ module.insertTrimmingSpace(exp, "");
3393
+ const expRefDec = expRef !== exp ? [expRef, " = ", exp, ", "] : [];
3394
+ declaration = {
3395
+ type: "Declaration",
3396
+ children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", expRef, ".length"],
3397
+ names: []
3398
+ };
3399
+ const indent = "".padStart((module.currentIndent + 1) * 2);
3400
+ blockPrefix.push([{
3401
+ type: "AssignmentExpression",
3402
+ children: [indent, varRef, " = ", expRef, "[", counterRef, "]\n"],
3403
+ names: varRef.names
3404
+ }]);
3405
+ return {
3406
+ declaration,
3407
+ children: [$1, $2, declaration, "; ", counterRef, " < ", lenRef, "; ", counterRef, "++", $7],
3408
+ blockPrefix
3409
+ };
3410
+ }
3411
+ return {
3412
+ declaration,
3413
+ children: $0,
3414
+ blockPrefix
3415
+ };
3416
+ });
3417
+ function CoffeeForStatementParameters(state) {
3418
+ if (state.verbose)
3419
+ console.log("ENTER:", "CoffeeForStatementParameters");
3420
+ if (state.tokenize) {
3421
+ return $TOKEN("CoffeeForStatementParameters", state, CoffeeForStatementParameters$0(state));
3422
+ } else {
3423
+ return CoffeeForStatementParameters$0(state);
3424
+ }
3425
+ }
3426
+ var CoffeeForDeclaration$0 = $TS($S($E($S(__, $EXPECT($L75, fail, 'CoffeeForDeclaration "own"'))), ForBinding), function($skip, $loc, $0, $1, $2) {
3427
+ var own = $1;
3428
+ var binding = $2;
3429
+ if (own) {
3430
+ binding.own = true;
3431
+ }
3432
+ binding.type = "AssignmentExpression";
3433
+ return binding;
3434
+ });
3435
+ function CoffeeForDeclaration(state) {
3436
+ if (state.verbose)
3437
+ console.log("ENTER:", "CoffeeForDeclaration");
3438
+ if (state.tokenize) {
3439
+ return $TOKEN("CoffeeForDeclaration", state, CoffeeForDeclaration$0(state));
3440
+ } else {
3441
+ return CoffeeForDeclaration$0(state);
3442
+ }
3443
+ }
3444
+ var ForStatementParameters$0 = $TS($S(OpenParen, __, $C(LexicalDeclaration, VariableStatement, $E(Expression)), __, Semicolon, $E(Expression), Semicolon, $E(Expression), __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) {
3236
3445
  var declaration = $3;
3237
3446
  return {
3238
3447
  declaration,
3239
3448
  children: $0
3240
3449
  };
3241
3450
  });
3242
- var ForStatementControl$1 = $TS($S(InsertOpenParen, __, $C(LexicalDeclaration, VariableStatement, $E(Expression)), __, Semicolon, $E(Expression), Semicolon, $E($S($N(EOS), Expression)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
3451
+ var ForStatementParameters$1 = $TS($S(InsertOpenParen, __, $C(LexicalDeclaration, VariableStatement, $E(Expression)), __, Semicolon, $E(Expression), Semicolon, $E($S($N(EOS), Expression)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
3243
3452
  var declaration = $3;
3244
3453
  return {
3245
3454
  declaration,
3246
3455
  children: $0
3247
3456
  };
3248
3457
  });
3249
- var ForStatementControl$2 = $TS($S($E($S(Await, __)), OpenParen, __, ForInOfDeclaration, __, $C(In, Of), ExtendedExpression, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
3458
+ var ForStatementParameters$2 = $TS($S($E($S(Await, __)), OpenParen, __, ForInOfDeclaration, __, $C(In, Of), ExtendedExpression, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
3250
3459
  var declaration = $4;
3251
3460
  return {
3252
3461
  declaration,
3253
3462
  children: $0
3254
3463
  };
3255
3464
  });
3256
- var ForStatementControl$3 = $TS($S($E($S(Await, __)), InsertOpenParen, ForInOfDeclaration, __, $C(In, Of), ExtendedExpression, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
3465
+ var ForStatementParameters$3 = $TS($S($E($S(Await, __)), InsertOpenParen, ForInOfDeclaration, __, $C(In, Of), ExtendedExpression, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
3257
3466
  var declaration = $3;
3258
3467
  return {
3259
3468
  declaration,
3260
3469
  children: $0
3261
3470
  };
3262
3471
  });
3263
- function ForStatementControl(state) {
3472
+ function ForStatementParameters(state) {
3264
3473
  if (state.tokenize) {
3265
- return $TOKEN("ForStatementControl", state, ForStatementControl$0(state) || ForStatementControl$1(state) || ForStatementControl$2(state) || ForStatementControl$3(state));
3474
+ return $TOKEN("ForStatementParameters", state, ForStatementParameters$0(state) || ForStatementParameters$1(state) || ForStatementParameters$2(state) || ForStatementParameters$3(state));
3266
3475
  } else {
3267
- return ForStatementControl$0(state) || ForStatementControl$1(state) || ForStatementControl$2(state) || ForStatementControl$3(state);
3476
+ return ForStatementParameters$0(state) || ForStatementParameters$1(state) || ForStatementParameters$2(state) || ForStatementParameters$3(state);
3268
3477
  }
3269
3478
  }
3270
3479
  var ForInOfDeclaration$0 = $TS($S(Var, ForBinding), function($skip, $loc, $0, $1, $2) {
@@ -3513,7 +3722,7 @@ var Civet = (() => {
3513
3722
  return CatchBind$0(state) || CatchBind$1(state);
3514
3723
  }
3515
3724
  }
3516
- var Finally$0 = $S(__, $EXPECT($L74, fail, 'Finally "finally"'), BracedBlock);
3725
+ var Finally$0 = $S(__, $EXPECT($L76, fail, 'Finally "finally"'), BracedBlock);
3517
3726
  function Finally(state) {
3518
3727
  if (state.verbose)
3519
3728
  console.log("ENTER:", "Finally");
@@ -3582,13 +3791,13 @@ var Civet = (() => {
3582
3791
  return ExpressionStatement$0(state);
3583
3792
  }
3584
3793
  }
3585
- var KeywordStatement$0 = $T($S($EXPECT($L75, fail, 'KeywordStatement "break"'), NonIdContinue), function(value) {
3794
+ var KeywordStatement$0 = $T($S($EXPECT($L77, fail, 'KeywordStatement "break"'), NonIdContinue), function(value) {
3586
3795
  return { "type": "BreakStatement", "children": value };
3587
3796
  });
3588
- var KeywordStatement$1 = $T($S($EXPECT($L76, fail, 'KeywordStatement "continue"'), NonIdContinue), function(value) {
3797
+ var KeywordStatement$1 = $T($S($EXPECT($L78, fail, 'KeywordStatement "continue"'), NonIdContinue), function(value) {
3589
3798
  return { "type": "ContinueStatement", "children": value };
3590
3799
  });
3591
- var KeywordStatement$2 = $T($S($EXPECT($L77, fail, 'KeywordStatement "debugger"'), NonIdContinue), function(value) {
3800
+ var KeywordStatement$2 = $T($S($EXPECT($L79, fail, 'KeywordStatement "debugger"'), NonIdContinue), function(value) {
3592
3801
  return { "type": "DebuggerStatement", "children": value };
3593
3802
  });
3594
3803
  var KeywordStatement$3 = $T($S(Return, $E(MaybeNestedExpression)), function(value) {
@@ -3604,7 +3813,7 @@ var Civet = (() => {
3604
3813
  return KeywordStatement$0(state) || KeywordStatement$1(state) || KeywordStatement$2(state) || KeywordStatement$3(state) || KeywordStatement$4(state);
3605
3814
  }
3606
3815
  }
3607
- var DebuggerExpression$0 = $TS($S($EXPECT($L77, fail, 'DebuggerExpression "debugger"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3816
+ var DebuggerExpression$0 = $TS($S($EXPECT($L79, fail, 'DebuggerExpression "debugger"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3608
3817
  return {
3609
3818
  type: "DebuggerExpression",
3610
3819
  children: ["($=>{", $1, "})()"]
@@ -3647,7 +3856,7 @@ var Civet = (() => {
3647
3856
  return MaybeNestedExpression$0(state) || MaybeNestedExpression$1(state);
3648
3857
  }
3649
3858
  }
3650
- var ImportDeclaration$0 = $T($S($EXPECT($L78, fail, 'ImportDeclaration "import type"'), NonIdContinue, __, ImportClause, __, FromClause), function(value) {
3859
+ var ImportDeclaration$0 = $T($S($EXPECT($L80, fail, 'ImportDeclaration "import type"'), NonIdContinue, __, ImportClause, __, FromClause), function(value) {
3651
3860
  return { "ts": true, "children": value };
3652
3861
  });
3653
3862
  var ImportDeclaration$1 = $S(Import, __, ImportClause, __, FromClause);
@@ -3826,7 +4035,7 @@ var Civet = (() => {
3826
4035
  return ImportedBinding$0(state);
3827
4036
  }
3828
4037
  }
3829
- var ExportDeclaration$0 = $S(Export, __, $EXPECT($L79, fail, 'ExportDeclaration "default"'), NonIdContinue, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression));
4038
+ var ExportDeclaration$0 = $S(Export, __, $EXPECT($L81, fail, 'ExportDeclaration "default"'), NonIdContinue, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression));
3830
4039
  var ExportDeclaration$1 = $S(Export, __, ExportFromClause, __, FromClause);
3831
4040
  var ExportDeclaration$2 = $S(Export, __, $C(NamedExports, VariableStatement, Declaration));
3832
4041
  function ExportDeclaration(state) {
@@ -3933,7 +4142,7 @@ var Civet = (() => {
3933
4142
  return LexicalDeclaration$0(state) || LexicalDeclaration$1(state);
3934
4143
  }
3935
4144
  }
3936
- var ConstAssignment$0 = $TV($EXPECT($L80, fail, 'ConstAssignment ":="'), function($skip, $loc, $0, $1) {
4145
+ var ConstAssignment$0 = $TV($EXPECT($L82, fail, 'ConstAssignment ":="'), function($skip, $loc, $0, $1) {
3937
4146
  return { $loc, token: "=" };
3938
4147
  });
3939
4148
  function ConstAssignment(state) {
@@ -4381,7 +4590,7 @@ var Civet = (() => {
4381
4590
  return MultiLineComment$0(state) || MultiLineComment$1(state);
4382
4591
  }
4383
4592
  }
4384
- var JSMultiLineComment$0 = $TV($TEXT($S($EXPECT($L81, fail, 'JSMultiLineComment "/*"'), $Q($S($N($EXPECT($L82, fail, 'JSMultiLineComment "*/"')), $EXPECT($R27, fail, "JSMultiLineComment /./"))), $EXPECT($L82, fail, 'JSMultiLineComment "*/"'))), function($skip, $loc, $0, $1) {
4593
+ var JSMultiLineComment$0 = $TV($TEXT($S($EXPECT($L83, fail, 'JSMultiLineComment "/*"'), $Q($S($N($EXPECT($L84, fail, 'JSMultiLineComment "*/"')), $EXPECT($R27, fail, "JSMultiLineComment /./"))), $EXPECT($L84, fail, 'JSMultiLineComment "*/"'))), function($skip, $loc, $0, $1) {
4385
4594
  return { $loc, token: $1 };
4386
4595
  });
4387
4596
  function JSMultiLineComment(state) {
@@ -4405,7 +4614,7 @@ var Civet = (() => {
4405
4614
  return CoffeeSingleLineComment$0(state);
4406
4615
  }
4407
4616
  }
4408
- var CoffeeMultiLineComment$0 = $TS($S($EXPECT($L83, fail, 'CoffeeMultiLineComment "###"'), $TEXT($Q($S($N($C($EXPECT($L83, fail, 'CoffeeMultiLineComment "###"'), $EXPECT($L82, fail, 'CoffeeMultiLineComment "*/"'))), $EXPECT($R27, fail, "CoffeeMultiLineComment /./")))), $EXPECT($L83, fail, 'CoffeeMultiLineComment "###"')), function($skip, $loc, $0, $1, $2, $3) {
4617
+ var CoffeeMultiLineComment$0 = $TS($S($EXPECT($L85, fail, 'CoffeeMultiLineComment "###"'), $TEXT($Q($S($N($C($EXPECT($L85, fail, 'CoffeeMultiLineComment "###"'), $EXPECT($L84, fail, 'CoffeeMultiLineComment "*/"'))), $EXPECT($R27, fail, "CoffeeMultiLineComment /./")))), $EXPECT($L85, fail, 'CoffeeMultiLineComment "###"')), function($skip, $loc, $0, $1, $2, $3) {
4409
4618
  return { $loc, token: `/*${$2}*/` };
4410
4619
  });
4411
4620
  function CoffeeMultiLineComment(state) {
@@ -4417,7 +4626,7 @@ var Civet = (() => {
4417
4626
  return CoffeeMultiLineComment$0(state);
4418
4627
  }
4419
4628
  }
4420
- var InlineComment$0 = $TV($TEXT($S($EXPECT($L81, fail, 'InlineComment "/*"'), $TEXT($Q($S($N($EXPECT($L82, fail, 'InlineComment "*/"')), $EXPECT($R29, fail, "InlineComment /[^\\r\\n]/")))), $EXPECT($L82, fail, 'InlineComment "*/"'))), function($skip, $loc, $0, $1) {
4629
+ var InlineComment$0 = $TV($TEXT($S($EXPECT($L83, fail, 'InlineComment "/*"'), $TEXT($Q($S($N($EXPECT($L84, fail, 'InlineComment "*/"')), $EXPECT($R29, fail, "InlineComment /[^\\r\\n]/")))), $EXPECT($L84, fail, 'InlineComment "*/"'))), function($skip, $loc, $0, $1) {
4421
4630
  return { $loc, token: $1 };
4422
4631
  });
4423
4632
  function InlineComment(state) {
@@ -4538,7 +4747,19 @@ var Civet = (() => {
4538
4747
  return Loc$0(state);
4539
4748
  }
4540
4749
  }
4541
- var As$0 = $TS($S($EXPECT($L84, fail, 'As "as"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4750
+ var Ampersand$0 = $TV($EXPECT($L71, fail, 'Ampersand "&"'), function($skip, $loc, $0, $1) {
4751
+ return { $loc, token: $1 };
4752
+ });
4753
+ function Ampersand(state) {
4754
+ if (state.verbose)
4755
+ console.log("ENTER:", "Ampersand");
4756
+ if (state.tokenize) {
4757
+ return $TOKEN("Ampersand", state, Ampersand$0(state));
4758
+ } else {
4759
+ return Ampersand$0(state);
4760
+ }
4761
+ }
4762
+ var As$0 = $TS($S($EXPECT($L86, fail, 'As "as"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4542
4763
  return { $loc, token: $1 };
4543
4764
  });
4544
4765
  function As(state) {
@@ -4550,7 +4771,7 @@ var Civet = (() => {
4550
4771
  return As$0(state);
4551
4772
  }
4552
4773
  }
4553
- var Async$0 = $TV($EXPECT($L85, fail, 'Async "async"'), function($skip, $loc, $0, $1) {
4774
+ var Async$0 = $TV($EXPECT($L87, fail, 'Async "async"'), function($skip, $loc, $0, $1) {
4554
4775
  return { $loc, token: $1 };
4555
4776
  });
4556
4777
  function Async(state) {
@@ -4562,7 +4783,7 @@ var Civet = (() => {
4562
4783
  return Async$0(state);
4563
4784
  }
4564
4785
  }
4565
- var Await$0 = $TS($S($EXPECT($L86, fail, 'Await "await"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4786
+ var Await$0 = $TS($S($EXPECT($L88, fail, 'Await "await"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4566
4787
  return { $loc, token: $1 };
4567
4788
  });
4568
4789
  function Await(state) {
@@ -4574,7 +4795,7 @@ var Civet = (() => {
4574
4795
  return Await$0(state);
4575
4796
  }
4576
4797
  }
4577
- var Backtick$0 = $TV($EXPECT($L87, fail, 'Backtick "`"'), function($skip, $loc, $0, $1) {
4798
+ var Backtick$0 = $TV($EXPECT($L89, fail, 'Backtick "`"'), function($skip, $loc, $0, $1) {
4578
4799
  return { $loc, token: $1 };
4579
4800
  });
4580
4801
  function Backtick(state) {
@@ -4586,7 +4807,7 @@ var Civet = (() => {
4586
4807
  return Backtick$0(state);
4587
4808
  }
4588
4809
  }
4589
- var Case$0 = $TS($S($EXPECT($L88, fail, 'Case "case"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4810
+ var Case$0 = $TS($S($EXPECT($L90, fail, 'Case "case"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4590
4811
  return { $loc, token: $1 };
4591
4812
  });
4592
4813
  function Case(state) {
@@ -4598,7 +4819,7 @@ var Civet = (() => {
4598
4819
  return Case$0(state);
4599
4820
  }
4600
4821
  }
4601
- var Catch$0 = $TV($EXPECT($L89, fail, 'Catch "catch"'), function($skip, $loc, $0, $1) {
4822
+ var Catch$0 = $TV($EXPECT($L91, fail, 'Catch "catch"'), function($skip, $loc, $0, $1) {
4602
4823
  return { $loc, token: $1 };
4603
4824
  });
4604
4825
  function Catch(state) {
@@ -4610,7 +4831,7 @@ var Civet = (() => {
4610
4831
  return Catch$0(state);
4611
4832
  }
4612
4833
  }
4613
- var Class$0 = $TV($EXPECT($L90, fail, 'Class "class"'), function($skip, $loc, $0, $1) {
4834
+ var Class$0 = $TV($EXPECT($L92, fail, 'Class "class"'), function($skip, $loc, $0, $1) {
4614
4835
  return { $loc, token: $1 };
4615
4836
  });
4616
4837
  function Class(state) {
@@ -4658,7 +4879,7 @@ var Civet = (() => {
4658
4879
  return CloseParen$0(state);
4659
4880
  }
4660
4881
  }
4661
- var CoffeeSubstitutionStart$0 = $TV($EXPECT($L91, fail, 'CoffeeSubstitutionStart "#{"'), function($skip, $loc, $0, $1) {
4882
+ var CoffeeSubstitutionStart$0 = $TV($EXPECT($L93, fail, 'CoffeeSubstitutionStart "#{"'), function($skip, $loc, $0, $1) {
4662
4883
  return { $loc, token: "${" };
4663
4884
  });
4664
4885
  function CoffeeSubstitutionStart(state) {
@@ -4670,7 +4891,7 @@ var Civet = (() => {
4670
4891
  return CoffeeSubstitutionStart$0(state);
4671
4892
  }
4672
4893
  }
4673
- var Colon$0 = $TV($EXPECT($L92, fail, 'Colon ":"'), function($skip, $loc, $0, $1) {
4894
+ var Colon$0 = $TV($EXPECT($L94, fail, 'Colon ":"'), function($skip, $loc, $0, $1) {
4674
4895
  return { $loc, token: $1 };
4675
4896
  });
4676
4897
  function Colon(state) {
@@ -4694,7 +4915,7 @@ var Civet = (() => {
4694
4915
  return ConstructorShorthand$0(state);
4695
4916
  }
4696
4917
  }
4697
- var Default$0 = $TS($S($EXPECT($L79, fail, 'Default "default"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4918
+ var Default$0 = $TS($S($EXPECT($L81, fail, 'Default "default"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4698
4919
  return { $loc, token: $1 };
4699
4920
  });
4700
4921
  function Default(state) {
@@ -4706,7 +4927,7 @@ var Civet = (() => {
4706
4927
  return Default$0(state);
4707
4928
  }
4708
4929
  }
4709
- var Delete$0 = $TS($S($EXPECT($L93, fail, 'Delete "delete"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4930
+ var Delete$0 = $TS($S($EXPECT($L95, fail, 'Delete "delete"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4710
4931
  return { $loc, token: $1 };
4711
4932
  });
4712
4933
  function Delete(state) {
@@ -4718,7 +4939,7 @@ var Civet = (() => {
4718
4939
  return Delete$0(state);
4719
4940
  }
4720
4941
  }
4721
- var Do$0 = $TS($S($EXPECT($L94, fail, 'Do "do"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4942
+ var Do$0 = $TS($S($EXPECT($L96, fail, 'Do "do"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4722
4943
  return { $loc, token: $1 };
4723
4944
  });
4724
4945
  function Do(state) {
@@ -4742,7 +4963,7 @@ var Civet = (() => {
4742
4963
  return Dot$0(state);
4743
4964
  }
4744
4965
  }
4745
- var DotDot$0 = $TV($EXPECT($L95, fail, 'DotDot ".."'), function($skip, $loc, $0, $1) {
4966
+ var DotDot$0 = $TV($EXPECT($L97, fail, 'DotDot ".."'), function($skip, $loc, $0, $1) {
4746
4967
  return { $loc, token: $1 };
4747
4968
  });
4748
4969
  function DotDot(state) {
@@ -4754,7 +4975,7 @@ var Civet = (() => {
4754
4975
  return DotDot$0(state);
4755
4976
  }
4756
4977
  }
4757
- var DotDotDot$0 = $TV($EXPECT($L96, fail, 'DotDotDot "..."'), function($skip, $loc, $0, $1) {
4978
+ var DotDotDot$0 = $TV($EXPECT($L98, fail, 'DotDotDot "..."'), function($skip, $loc, $0, $1) {
4758
4979
  return { $loc, token: $1 };
4759
4980
  });
4760
4981
  function DotDotDot(state) {
@@ -4766,7 +4987,7 @@ var Civet = (() => {
4766
4987
  return DotDotDot$0(state);
4767
4988
  }
4768
4989
  }
4769
- var DoubleQuote$0 = $TV($EXPECT($L97, fail, 'DoubleQuote "\\\\\\""'), function($skip, $loc, $0, $1) {
4990
+ var DoubleQuote$0 = $TV($EXPECT($L99, fail, 'DoubleQuote "\\\\\\""'), function($skip, $loc, $0, $1) {
4770
4991
  return { $loc, token: $1 };
4771
4992
  });
4772
4993
  function DoubleQuote(state) {
@@ -4778,7 +4999,7 @@ var Civet = (() => {
4778
4999
  return DoubleQuote$0(state);
4779
5000
  }
4780
5001
  }
4781
- var Else$0 = $TV($EXPECT($L98, fail, 'Else "else"'), function($skip, $loc, $0, $1) {
5002
+ var Else$0 = $TV($EXPECT($L100, fail, 'Else "else"'), function($skip, $loc, $0, $1) {
4782
5003
  return { $loc, token: $1 };
4783
5004
  });
4784
5005
  function Else(state) {
@@ -4802,7 +5023,7 @@ var Civet = (() => {
4802
5023
  return Equals$0(state);
4803
5024
  }
4804
5025
  }
4805
- var Export$0 = $TS($S($EXPECT($L99, fail, 'Export "export"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5026
+ var Export$0 = $TS($S($EXPECT($L101, fail, 'Export "export"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4806
5027
  return { $loc, token: $1 };
4807
5028
  });
4808
5029
  function Export(state) {
@@ -4814,7 +5035,7 @@ var Civet = (() => {
4814
5035
  return Export$0(state);
4815
5036
  }
4816
5037
  }
4817
- var For$0 = $TS($S($EXPECT($L100, fail, 'For "for"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5038
+ var For$0 = $TS($S($EXPECT($L102, fail, 'For "for"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4818
5039
  return { $loc, token: $1 };
4819
5040
  });
4820
5041
  function For(state) {
@@ -4826,7 +5047,7 @@ var Civet = (() => {
4826
5047
  return For$0(state);
4827
5048
  }
4828
5049
  }
4829
- var From$0 = $TS($S($EXPECT($L101, fail, 'From "from"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5050
+ var From$0 = $TS($S($EXPECT($L103, fail, 'From "from"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4830
5051
  return { $loc, token: $1 };
4831
5052
  });
4832
5053
  function From(state) {
@@ -4838,7 +5059,7 @@ var Civet = (() => {
4838
5059
  return From$0(state);
4839
5060
  }
4840
5061
  }
4841
- var Function$0 = $TV($EXPECT($L102, fail, 'Function "function"'), function($skip, $loc, $0, $1) {
5062
+ var Function$0 = $TV($EXPECT($L104, fail, 'Function "function"'), function($skip, $loc, $0, $1) {
4842
5063
  return { $loc, token: $1 };
4843
5064
  });
4844
5065
  function Function(state) {
@@ -4850,7 +5071,7 @@ var Civet = (() => {
4850
5071
  return Function$0(state);
4851
5072
  }
4852
5073
  }
4853
- var GetOrSet$0 = $TS($S($C($EXPECT($L103, fail, 'GetOrSet "get"'), $EXPECT($L104, fail, 'GetOrSet "set"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5074
+ var GetOrSet$0 = $TS($S($C($EXPECT($L105, fail, 'GetOrSet "get"'), $EXPECT($L106, fail, 'GetOrSet "set"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4854
5075
  return { $loc, token: $1 };
4855
5076
  });
4856
5077
  function GetOrSet(state) {
@@ -4862,7 +5083,7 @@ var Civet = (() => {
4862
5083
  return GetOrSet$0(state);
4863
5084
  }
4864
5085
  }
4865
- var If$0 = $TV($TEXT($S($EXPECT($L105, fail, 'If "if"'), $E($EXPECT($L106, fail, 'If " "')))), function($skip, $loc, $0, $1) {
5086
+ var If$0 = $TV($TEXT($S($EXPECT($L107, fail, 'If "if"'), $E($EXPECT($L108, fail, 'If " "')))), function($skip, $loc, $0, $1) {
4866
5087
  return { $loc, token: $1 };
4867
5088
  });
4868
5089
  function If(state) {
@@ -4886,7 +5107,7 @@ var Civet = (() => {
4886
5107
  return Import$0(state);
4887
5108
  }
4888
5109
  }
4889
- var In$0 = $TV($EXPECT($L69, fail, 'In "in"'), function($skip, $loc, $0, $1) {
5110
+ var In$0 = $TV($EXPECT($L70, fail, 'In "in"'), function($skip, $loc, $0, $1) {
4890
5111
  return { $loc, token: $1 };
4891
5112
  });
4892
5113
  function In(state) {
@@ -4898,7 +5119,7 @@ var Civet = (() => {
4898
5119
  return In$0(state);
4899
5120
  }
4900
5121
  }
4901
- var LetOrConst$0 = $TV($C($EXPECT($L107, fail, 'LetOrConst "let"'), $EXPECT($L108, fail, 'LetOrConst "const"')), function($skip, $loc, $0, $1) {
5122
+ var LetOrConst$0 = $TV($C($EXPECT($L109, fail, 'LetOrConst "let"'), $EXPECT($L110, fail, 'LetOrConst "const"')), function($skip, $loc, $0, $1) {
4902
5123
  return { $loc, token: $1 };
4903
5124
  });
4904
5125
  function LetOrConst(state) {
@@ -4910,7 +5131,7 @@ var Civet = (() => {
4910
5131
  return LetOrConst$0(state);
4911
5132
  }
4912
5133
  }
4913
- var Loop$0 = $TS($S($EXPECT($L109, fail, 'Loop "loop"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5134
+ var Loop$0 = $TS($S($EXPECT($L111, fail, 'Loop "loop"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
4914
5135
  return { $loc, token: "while(true)" };
4915
5136
  });
4916
5137
  function Loop(state) {
@@ -4922,7 +5143,7 @@ var Civet = (() => {
4922
5143
  return Loop$0(state);
4923
5144
  }
4924
5145
  }
4925
- var New$0 = $TV($EXPECT($L110, fail, 'New "new"'), function($skip, $loc, $0, $1) {
5146
+ var New$0 = $TV($EXPECT($L112, fail, 'New "new"'), function($skip, $loc, $0, $1) {
4926
5147
  return { $loc, token: $1 };
4927
5148
  });
4928
5149
  function New(state) {
@@ -4934,7 +5155,7 @@ var Civet = (() => {
4934
5155
  return New$0(state);
4935
5156
  }
4936
5157
  }
4937
- var Not$0 = $TS($S(CoffeeNotEnabled, $EXPECT($L111, fail, 'Not "not"'), NonIdContinue, $E($EXPECT($L106, fail, 'Not " "'))), function($skip, $loc, $0, $1, $2, $3, $4) {
5158
+ var Not$0 = $TS($S(CoffeeNotEnabled, $EXPECT($L113, fail, 'Not "not"'), NonIdContinue, $E($EXPECT($L108, fail, 'Not " "'))), function($skip, $loc, $0, $1, $2, $3, $4) {
4938
5159
  return { $loc, token: "!" };
4939
5160
  });
4940
5161
  function Not(state) {
@@ -4946,7 +5167,7 @@ var Civet = (() => {
4946
5167
  return Not$0(state);
4947
5168
  }
4948
5169
  }
4949
- var Of$0 = $TV($EXPECT($L112, fail, 'Of "of"'), function($skip, $loc, $0, $1) {
5170
+ var Of$0 = $TV($EXPECT($L65, fail, 'Of "of"'), function($skip, $loc, $0, $1) {
4950
5171
  return { $loc, token: $1 };
4951
5172
  });
4952
5173
  function Of(state) {
@@ -4958,7 +5179,7 @@ var Civet = (() => {
4958
5179
  return Of$0(state);
4959
5180
  }
4960
5181
  }
4961
- var OpenBrace$0 = $TV($EXPECT($L113, fail, 'OpenBrace "{"'), function($skip, $loc, $0, $1) {
5182
+ var OpenBrace$0 = $TV($EXPECT($L114, fail, 'OpenBrace "{"'), function($skip, $loc, $0, $1) {
4962
5183
  return { $loc, token: $1 };
4963
5184
  });
4964
5185
  function OpenBrace(state) {
@@ -4970,7 +5191,7 @@ var Civet = (() => {
4970
5191
  return OpenBrace$0(state);
4971
5192
  }
4972
5193
  }
4973
- var OpenBracket$0 = $TV($EXPECT($L114, fail, 'OpenBracket "["'), function($skip, $loc, $0, $1) {
5194
+ var OpenBracket$0 = $TV($EXPECT($L115, fail, 'OpenBracket "["'), function($skip, $loc, $0, $1) {
4974
5195
  return { $loc, token: $1 };
4975
5196
  });
4976
5197
  function OpenBracket(state) {
@@ -4982,7 +5203,7 @@ var Civet = (() => {
4982
5203
  return OpenBracket$0(state);
4983
5204
  }
4984
5205
  }
4985
- var OpenParen$0 = $TV($EXPECT($L115, fail, 'OpenParen "("'), function($skip, $loc, $0, $1) {
5206
+ var OpenParen$0 = $TV($EXPECT($L116, fail, 'OpenParen "("'), function($skip, $loc, $0, $1) {
4986
5207
  return { $loc, token: $1 };
4987
5208
  });
4988
5209
  function OpenParen(state) {
@@ -4994,7 +5215,7 @@ var Civet = (() => {
4994
5215
  return OpenParen$0(state);
4995
5216
  }
4996
5217
  }
4997
- var QuestionMark$0 = $TV($EXPECT($L116, fail, 'QuestionMark "?"'), function($skip, $loc, $0, $1) {
5218
+ var QuestionMark$0 = $TV($EXPECT($L117, fail, 'QuestionMark "?"'), function($skip, $loc, $0, $1) {
4998
5219
  return { $loc, token: $1 };
4999
5220
  });
5000
5221
  function QuestionMark(state) {
@@ -5006,7 +5227,7 @@ var Civet = (() => {
5006
5227
  return QuestionMark$0(state);
5007
5228
  }
5008
5229
  }
5009
- var Return$0 = $TS($S($EXPECT($L117, fail, 'Return "return"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5230
+ var Return$0 = $TS($S($EXPECT($L118, fail, 'Return "return"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5010
5231
  return { $loc, token: $1 };
5011
5232
  });
5012
5233
  function Return(state) {
@@ -5018,7 +5239,7 @@ var Civet = (() => {
5018
5239
  return Return$0(state);
5019
5240
  }
5020
5241
  }
5021
- var Semicolon$0 = $TV($EXPECT($L73, fail, 'Semicolon ";"'), function($skip, $loc, $0, $1) {
5242
+ var Semicolon$0 = $TV($EXPECT($L74, fail, 'Semicolon ";"'), function($skip, $loc, $0, $1) {
5022
5243
  return { $loc, token: $1 };
5023
5244
  });
5024
5245
  function Semicolon(state) {
@@ -5030,7 +5251,7 @@ var Civet = (() => {
5030
5251
  return Semicolon$0(state);
5031
5252
  }
5032
5253
  }
5033
- var SingleQuote$0 = $TV($EXPECT($L118, fail, `SingleQuote "'"`), function($skip, $loc, $0, $1) {
5254
+ var SingleQuote$0 = $TV($EXPECT($L119, fail, `SingleQuote "'"`), function($skip, $loc, $0, $1) {
5034
5255
  return { $loc, token: $1 };
5035
5256
  });
5036
5257
  function SingleQuote(state) {
@@ -5054,10 +5275,10 @@ var Civet = (() => {
5054
5275
  return Star$0(state);
5055
5276
  }
5056
5277
  }
5057
- var Static$0 = $TV($EXPECT($L119, fail, 'Static "static"'), function($skip, $loc, $0, $1) {
5278
+ var Static$0 = $TV($EXPECT($L120, fail, 'Static "static"'), function($skip, $loc, $0, $1) {
5058
5279
  return { $loc, token: $1 };
5059
5280
  });
5060
- var Static$1 = $TS($S($EXPECT($L8, fail, 'Static "@"'), $N($EXPECT($L115, fail, 'Static "("'))), function($skip, $loc, $0, $1, $2) {
5281
+ var Static$1 = $TS($S($EXPECT($L8, fail, 'Static "@"'), $N($EXPECT($L116, fail, 'Static "("'))), function($skip, $loc, $0, $1, $2) {
5061
5282
  return { $loc, token: "static " };
5062
5283
  });
5063
5284
  function Static(state) {
@@ -5067,7 +5288,7 @@ var Civet = (() => {
5067
5288
  return Static$0(state) || Static$1(state);
5068
5289
  }
5069
5290
  }
5070
- var SubstitutionStart$0 = $TV($EXPECT($L120, fail, 'SubstitutionStart "${"'), function($skip, $loc, $0, $1) {
5291
+ var SubstitutionStart$0 = $TV($EXPECT($L121, fail, 'SubstitutionStart "${"'), function($skip, $loc, $0, $1) {
5071
5292
  return { $loc, token: $1 };
5072
5293
  });
5073
5294
  function SubstitutionStart(state) {
@@ -5079,7 +5300,7 @@ var Civet = (() => {
5079
5300
  return SubstitutionStart$0(state);
5080
5301
  }
5081
5302
  }
5082
- var Switch$0 = $TS($S($EXPECT($L121, fail, 'Switch "switch"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5303
+ var Switch$0 = $TS($S($EXPECT($L122, fail, 'Switch "switch"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5083
5304
  return { $loc, token: $1 };
5084
5305
  });
5085
5306
  function Switch(state) {
@@ -5091,7 +5312,7 @@ var Civet = (() => {
5091
5312
  return Switch$0(state);
5092
5313
  }
5093
5314
  }
5094
- var Target$0 = $TV($EXPECT($L122, fail, 'Target "target"'), function($skip, $loc, $0, $1) {
5315
+ var Target$0 = $TV($EXPECT($L123, fail, 'Target "target"'), function($skip, $loc, $0, $1) {
5095
5316
  return { $loc, token: $1 };
5096
5317
  });
5097
5318
  function Target(state) {
@@ -5103,7 +5324,7 @@ var Civet = (() => {
5103
5324
  return Target$0(state);
5104
5325
  }
5105
5326
  }
5106
- var Then$0 = $TS($S(__, $EXPECT($L123, fail, 'Then "then"'), NonIdContinue), function($skip, $loc, $0, $1, $2, $3) {
5327
+ var Then$0 = $TS($S(__, $EXPECT($L124, fail, 'Then "then"'), NonIdContinue), function($skip, $loc, $0, $1, $2, $3) {
5107
5328
  return { $loc, token: "" };
5108
5329
  });
5109
5330
  function Then(state) {
@@ -5115,7 +5336,7 @@ var Civet = (() => {
5115
5336
  return Then$0(state);
5116
5337
  }
5117
5338
  }
5118
- var Throw$0 = $TS($S($EXPECT($L124, fail, 'Throw "throw"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5339
+ var Throw$0 = $TS($S($EXPECT($L125, fail, 'Throw "throw"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5119
5340
  return { $loc, token: $1 };
5120
5341
  });
5121
5342
  function Throw(state) {
@@ -5127,7 +5348,7 @@ var Civet = (() => {
5127
5348
  return Throw$0(state);
5128
5349
  }
5129
5350
  }
5130
- var TripleDoubleQuote$0 = $TV($EXPECT($L125, fail, 'TripleDoubleQuote "\\\\\\"\\\\\\"\\\\\\""'), function($skip, $loc, $0, $1) {
5351
+ var TripleDoubleQuote$0 = $TV($EXPECT($L126, fail, 'TripleDoubleQuote "\\\\\\"\\\\\\"\\\\\\""'), function($skip, $loc, $0, $1) {
5131
5352
  return { $loc, token: "`" };
5132
5353
  });
5133
5354
  function TripleDoubleQuote(state) {
@@ -5139,7 +5360,7 @@ var Civet = (() => {
5139
5360
  return TripleDoubleQuote$0(state);
5140
5361
  }
5141
5362
  }
5142
- var TripleSingleQuote$0 = $TV($EXPECT($L126, fail, `TripleSingleQuote "'''"`), function($skip, $loc, $0, $1) {
5363
+ var TripleSingleQuote$0 = $TV($EXPECT($L127, fail, `TripleSingleQuote "'''"`), function($skip, $loc, $0, $1) {
5143
5364
  return { $loc, token: "`" };
5144
5365
  });
5145
5366
  function TripleSingleQuote(state) {
@@ -5151,7 +5372,7 @@ var Civet = (() => {
5151
5372
  return TripleSingleQuote$0(state);
5152
5373
  }
5153
5374
  }
5154
- var TripleTick$0 = $TV($EXPECT($L127, fail, 'TripleTick "```"'), function($skip, $loc, $0, $1) {
5375
+ var TripleTick$0 = $TV($EXPECT($L128, fail, 'TripleTick "```"'), function($skip, $loc, $0, $1) {
5155
5376
  return { $loc, token: "`" };
5156
5377
  });
5157
5378
  function TripleTick(state) {
@@ -5163,7 +5384,7 @@ var Civet = (() => {
5163
5384
  return TripleTick$0(state);
5164
5385
  }
5165
5386
  }
5166
- var Try$0 = $TV($EXPECT($L128, fail, 'Try "try"'), function($skip, $loc, $0, $1) {
5387
+ var Try$0 = $TV($EXPECT($L129, fail, 'Try "try"'), function($skip, $loc, $0, $1) {
5167
5388
  return { $loc, token: $1 };
5168
5389
  });
5169
5390
  function Try(state) {
@@ -5175,7 +5396,7 @@ var Civet = (() => {
5175
5396
  return Try$0(state);
5176
5397
  }
5177
5398
  }
5178
- var Typeof$0 = $TS($S($EXPECT($L129, fail, 'Typeof "typeof"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5399
+ var Typeof$0 = $TS($S($EXPECT($L130, fail, 'Typeof "typeof"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5179
5400
  return { $loc, token: $1 };
5180
5401
  });
5181
5402
  function Typeof(state) {
@@ -5187,7 +5408,7 @@ var Civet = (() => {
5187
5408
  return Typeof$0(state);
5188
5409
  }
5189
5410
  }
5190
- var Unless$0 = $TV($EXPECT($L130, fail, 'Unless "unless"'), function($skip, $loc, $0, $1) {
5411
+ var Unless$0 = $TV($EXPECT($L131, fail, 'Unless "unless"'), function($skip, $loc, $0, $1) {
5191
5412
  return { $loc, token: $1 };
5192
5413
  });
5193
5414
  function Unless(state) {
@@ -5199,7 +5420,7 @@ var Civet = (() => {
5199
5420
  return Unless$0(state);
5200
5421
  }
5201
5422
  }
5202
- var Until$0 = $TS($S($EXPECT($L131, fail, 'Until "until"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5423
+ var Until$0 = $TS($S($EXPECT($L132, fail, 'Until "until"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5203
5424
  return { $loc, token: $1 };
5204
5425
  });
5205
5426
  function Until(state) {
@@ -5211,7 +5432,7 @@ var Civet = (() => {
5211
5432
  return Until$0(state);
5212
5433
  }
5213
5434
  }
5214
- var Var$0 = $TV($EXPECT($L132, fail, 'Var "var"'), function($skip, $loc, $0, $1) {
5435
+ var Var$0 = $TV($EXPECT($L133, fail, 'Var "var"'), function($skip, $loc, $0, $1) {
5215
5436
  return { $loc, token: $1 };
5216
5437
  });
5217
5438
  function Var(state) {
@@ -5223,7 +5444,7 @@ var Civet = (() => {
5223
5444
  return Var$0(state);
5224
5445
  }
5225
5446
  }
5226
- var Void$0 = $TS($S($EXPECT($L133, fail, 'Void "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5447
+ var Void$0 = $TS($S($EXPECT($L134, fail, 'Void "void"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5227
5448
  return { $loc, token: $1 };
5228
5449
  });
5229
5450
  function Void(state) {
@@ -5235,7 +5456,7 @@ var Civet = (() => {
5235
5456
  return Void$0(state);
5236
5457
  }
5237
5458
  }
5238
- var When$0 = $TS($S($EXPECT($L134, fail, 'When "when"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5459
+ var When$0 = $TS($S($EXPECT($L135, fail, 'When "when"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5239
5460
  return { $loc, token: "case" };
5240
5461
  });
5241
5462
  function When(state) {
@@ -5247,7 +5468,7 @@ var Civet = (() => {
5247
5468
  return When$0(state);
5248
5469
  }
5249
5470
  }
5250
- var While$0 = $TS($S($EXPECT($L135, fail, 'While "while"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5471
+ var While$0 = $TS($S($EXPECT($L136, fail, 'While "while"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5251
5472
  return { $loc, token: $1 };
5252
5473
  });
5253
5474
  function While(state) {
@@ -5259,7 +5480,7 @@ var Civet = (() => {
5259
5480
  return While$0(state);
5260
5481
  }
5261
5482
  }
5262
- var Yield$0 = $TS($S($EXPECT($L136, fail, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5483
+ var Yield$0 = $TS($S($EXPECT($L137, fail, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
5263
5484
  return { $loc, token: $1 };
5264
5485
  });
5265
5486
  function Yield(state) {
@@ -5285,7 +5506,7 @@ var Civet = (() => {
5285
5506
  return JSXElement$0(state) || JSXElement$1(state);
5286
5507
  }
5287
5508
  }
5288
- var JSXSelfClosingElement$0 = $S($EXPECT($L4, fail, 'JSXSelfClosingElement "<"'), $TEXT(JSXElementName), $E(JSXAttributes), __, $EXPECT($L137, fail, 'JSXSelfClosingElement "/>"'));
5509
+ var JSXSelfClosingElement$0 = $S($EXPECT($L4, fail, 'JSXSelfClosingElement "<"'), $TEXT(JSXElementName), $E(JSXAttributes), __, $EXPECT($L138, fail, 'JSXSelfClosingElement "/>"'));
5289
5510
  function JSXSelfClosingElement(state) {
5290
5511
  if (state.verbose)
5291
5512
  console.log("ENTER:", "JSXSelfClosingElement");
@@ -5305,7 +5526,7 @@ var Civet = (() => {
5305
5526
  return JSXOpeningElement$0(state);
5306
5527
  }
5307
5528
  }
5308
- var JSXClosingElement$0 = $S($EXPECT($L138, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L56, fail, 'JSXClosingElement ">"'));
5529
+ var JSXClosingElement$0 = $S($EXPECT($L139, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L56, fail, 'JSXClosingElement ">"'));
5309
5530
  function JSXClosingElement(state) {
5310
5531
  if (state.verbose)
5311
5532
  console.log("ENTER:", "JSXClosingElement");
@@ -5315,7 +5536,7 @@ var Civet = (() => {
5315
5536
  return JSXClosingElement$0(state);
5316
5537
  }
5317
5538
  }
5318
- var JSXFragment$0 = $S($EXPECT($L139, fail, 'JSXFragment "<>"'), $E(JSXChildren), $EXPECT($L140, fail, 'JSXFragment "</>"'));
5539
+ var JSXFragment$0 = $S($EXPECT($L140, fail, 'JSXFragment "<>"'), $E(JSXChildren), $EXPECT($L141, fail, 'JSXFragment "</>"'));
5319
5540
  function JSXFragment(state) {
5320
5541
  if (state.verbose)
5321
5542
  console.log("ENTER:", "JSXFragment");
@@ -5449,7 +5670,7 @@ var Civet = (() => {
5449
5670
  return TypeDeclaration$0(state);
5450
5671
  }
5451
5672
  }
5452
- var TypeDeclarationModifier$0 = $S($EXPECT($L141, fail, 'TypeDeclarationModifier "declare"'), NonIdContinue);
5673
+ var TypeDeclarationModifier$0 = $S($EXPECT($L142, fail, 'TypeDeclarationModifier "declare"'), NonIdContinue);
5453
5674
  var TypeDeclarationModifier$1 = Export;
5454
5675
  function TypeDeclarationModifier(state) {
5455
5676
  if (state.tokenize) {
@@ -5469,7 +5690,7 @@ var Civet = (() => {
5469
5690
  return TypeDeclarationRest$0(state) || TypeDeclarationRest$1(state) || TypeDeclarationRest$2(state) || TypeDeclarationRest$3(state);
5470
5691
  }
5471
5692
  }
5472
- var TypeKeyword$0 = $S($EXPECT($L142, fail, 'TypeKeyword "type"'), NonIdContinue);
5693
+ var TypeKeyword$0 = $S($EXPECT($L143, fail, 'TypeKeyword "type"'), NonIdContinue);
5473
5694
  function TypeKeyword(state) {
5474
5695
  if (state.verbose)
5475
5696
  console.log("ENTER:", "TypeKeyword");
@@ -5479,7 +5700,7 @@ var Civet = (() => {
5479
5700
  return TypeKeyword$0(state);
5480
5701
  }
5481
5702
  }
5482
- var Interface$0 = $S($EXPECT($L143, fail, 'Interface "interface"'), NonIdContinue);
5703
+ var Interface$0 = $S($EXPECT($L144, fail, 'Interface "interface"'), NonIdContinue);
5483
5704
  function Interface(state) {
5484
5705
  if (state.verbose)
5485
5706
  console.log("ENTER:", "Interface");
@@ -5489,7 +5710,7 @@ var Civet = (() => {
5489
5710
  return Interface$0(state);
5490
5711
  }
5491
5712
  }
5492
- var Namespace$0 = $S($EXPECT($L144, fail, 'Namespace "namespace"'), NonIdContinue);
5713
+ var Namespace$0 = $S($EXPECT($L145, fail, 'Namespace "namespace"'), NonIdContinue);
5493
5714
  function Namespace(state) {
5494
5715
  if (state.verbose)
5495
5716
  console.log("ENTER:", "Namespace");
@@ -5589,7 +5810,7 @@ var Civet = (() => {
5589
5810
  return NestedTypeDeclaration$0(state);
5590
5811
  }
5591
5812
  }
5592
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R38, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L145, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R39, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
5813
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R38, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L146, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R39, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
5593
5814
  function TypeIndexSignature(state) {
5594
5815
  if (state.verbose)
5595
5816
  console.log("ENTER:", "TypeIndexSignature");
@@ -5620,7 +5841,7 @@ var Civet = (() => {
5620
5841
  return TypeSuffix$0(state);
5621
5842
  }
5622
5843
  }
5623
- var ReturnTypeSuffix$0 = $TS($S(__, Colon, $E($S(__, $EXPECT($L146, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
5844
+ var ReturnTypeSuffix$0 = $TS($S(__, Colon, $E($S(__, $EXPECT($L147, fail, 'ReturnTypeSuffix "asserts"'), NonIdContinue)), TypePredicate), function($skip, $loc, $0, $1, $2, $3, $4) {
5624
5845
  if (!$3)
5625
5846
  $0.splice(2, 1);
5626
5847
  if ($1.length === 0)
@@ -5703,9 +5924,9 @@ var Civet = (() => {
5703
5924
  return TypeUnarySuffix$0(state) || TypeUnarySuffix$1(state);
5704
5925
  }
5705
5926
  }
5706
- var TypeUnaryOp$0 = $EXPECT($L147, fail, 'TypeUnaryOp "keyof"');
5707
- var TypeUnaryOp$1 = $EXPECT($L129, fail, 'TypeUnaryOp "typeof"');
5708
- var TypeUnaryOp$2 = $EXPECT($L148, fail, 'TypeUnaryOp "infer"');
5927
+ var TypeUnaryOp$0 = $EXPECT($L148, fail, 'TypeUnaryOp "keyof"');
5928
+ var TypeUnaryOp$1 = $EXPECT($L130, fail, 'TypeUnaryOp "typeof"');
5929
+ var TypeUnaryOp$2 = $EXPECT($L149, fail, 'TypeUnaryOp "infer"');
5709
5930
  function TypeUnaryOp(state) {
5710
5931
  if (state.tokenize) {
5711
5932
  return $TOKEN("TypeUnaryOp", state, TypeUnaryOp$0(state) || TypeUnaryOp$1(state) || TypeUnaryOp$2(state));
@@ -5795,10 +6016,10 @@ var Civet = (() => {
5795
6016
  }
5796
6017
  }
5797
6018
  var TypeLiteral$0 = Literal;
5798
- var TypeLiteral$1 = $TV($EXPECT($L133, fail, 'TypeLiteral "void"'), function($skip, $loc, $0, $1) {
6019
+ var TypeLiteral$1 = $TV($EXPECT($L134, fail, 'TypeLiteral "void"'), function($skip, $loc, $0, $1) {
5799
6020
  return { $loc, token: "void" };
5800
6021
  });
5801
- var TypeLiteral$2 = $TV($EXPECT($L149, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
6022
+ var TypeLiteral$2 = $TV($EXPECT($L150, fail, 'TypeLiteral "[]"'), function($skip, $loc, $0, $1) {
5802
6023
  return { $loc, token: "[]" };
5803
6024
  });
5804
6025
  function TypeLiteral(state) {
@@ -5808,10 +6029,10 @@ var Civet = (() => {
5808
6029
  return TypeLiteral$0(state) || TypeLiteral$1(state) || TypeLiteral$2(state);
5809
6030
  }
5810
6031
  }
5811
- var TypeBinaryOp$0 = $TV($EXPECT($L72, fail, 'TypeBinaryOp "|"'), function($skip, $loc, $0, $1) {
6032
+ var TypeBinaryOp$0 = $TV($EXPECT($L73, fail, 'TypeBinaryOp "|"'), function($skip, $loc, $0, $1) {
5812
6033
  return { $loc, token: "|" };
5813
6034
  });
5814
- var TypeBinaryOp$1 = $TV($EXPECT($L70, fail, 'TypeBinaryOp "&"'), function($skip, $loc, $0, $1) {
6035
+ var TypeBinaryOp$1 = $TV($EXPECT($L71, fail, 'TypeBinaryOp "&"'), function($skip, $loc, $0, $1) {
5815
6036
  return { $loc, token: "&" };
5816
6037
  });
5817
6038
  function TypeBinaryOp(state) {
@@ -5913,7 +6134,7 @@ var Civet = (() => {
5913
6134
  return CivetPrologue$0(state) || CivetPrologue$1(state);
5914
6135
  }
5915
6136
  }
5916
- var CivetPrologueContent$0 = $TS($S($EXPECT($L150, fail, 'CivetPrologueContent "civet"'), $Q(CivetOption), $EXPECT($R42, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3) {
6137
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L151, fail, 'CivetPrologueContent "civet"'), $Q(CivetOption), $EXPECT($R42, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3) {
5917
6138
  var options = $2;
5918
6139
  return {
5919
6140
  type: "CivetPrologue",
@@ -6161,6 +6382,20 @@ var Civet = (() => {
6161
6382
  return CoffeeBooleansEnabled$0(state);
6162
6383
  }
6163
6384
  }
6385
+ var CoffeeForLoopsEnabled$0 = $TV($EXPECT($L0, fail, 'CoffeeForLoopsEnabled ""'), function($skip, $loc, $0, $1) {
6386
+ if (module.config.coffeeForLoops)
6387
+ return;
6388
+ return $skip;
6389
+ });
6390
+ function CoffeeForLoopsEnabled(state) {
6391
+ if (state.verbose)
6392
+ console.log("ENTER:", "CoffeeForLoopsEnabled");
6393
+ if (state.tokenize) {
6394
+ return $TOKEN("CoffeeForLoopsEnabled", state, CoffeeForLoopsEnabled$0(state));
6395
+ } else {
6396
+ return CoffeeForLoopsEnabled$0(state);
6397
+ }
6398
+ }
6164
6399
  var CoffeeInterpolationEnabled$0 = $TV($EXPECT($L0, fail, 'CoffeeInterpolationEnabled ""'), function($skip, $loc, $0, $1) {
6165
6400
  if (module.config.coffeeInterpolation)
6166
6401
  return;
@@ -6203,6 +6438,20 @@ var Civet = (() => {
6203
6438
  return CoffeeNotEnabled$0(state);
6204
6439
  }
6205
6440
  }
6441
+ var CoffeeOfEnabled$0 = $TV($EXPECT($L0, fail, 'CoffeeOfEnabled ""'), function($skip, $loc, $0, $1) {
6442
+ if (module.config.coffeeOf)
6443
+ return;
6444
+ return $skip;
6445
+ });
6446
+ function CoffeeOfEnabled(state) {
6447
+ if (state.verbose)
6448
+ console.log("ENTER:", "CoffeeOfEnabled");
6449
+ if (state.tokenize) {
6450
+ return $TOKEN("CoffeeOfEnabled", state, CoffeeOfEnabled$0(state));
6451
+ } else {
6452
+ return CoffeeOfEnabled$0(state);
6453
+ }
6454
+ }
6206
6455
  var Reset$0 = $TV($EXPECT($L0, fail, 'Reset ""'), function($skip, $loc, $0, $1) {
6207
6456
  module.currentIndent = 0;
6208
6457
  module.indentLevels = [0];
@@ -6212,11 +6461,51 @@ var Civet = (() => {
6212
6461
  coffeeBooleans: false,
6213
6462
  coffeeComment: false,
6214
6463
  coffeeEq: false,
6464
+ coffeeForLoops: false,
6215
6465
  coffeeInterpolation: false,
6216
6466
  coffeeIsnt: false,
6217
6467
  coffeeNot: false,
6468
+ coffeeOf: false,
6218
6469
  implicitReturns: true
6219
6470
  };
6471
+ let indexOfRef, hasPropRef;
6472
+ module.prelude = [];
6473
+ module.getIndexOfRef = function() {
6474
+ if (indexOfRef)
6475
+ return indexOfRef;
6476
+ indexOfRef = {
6477
+ type: "Ref",
6478
+ base: "indexOf"
6479
+ };
6480
+ const typeSuffix = {
6481
+ ts: true,
6482
+ children: [": <T>(this: T[], searchElement: T) => boolean"]
6483
+ };
6484
+ const asAny = {
6485
+ ts: true,
6486
+ children: [" as any"]
6487
+ };
6488
+ module.prelude.push(["", "const ", indexOfRef, typeSuffix, " = [].indexOf", asAny, "\n"]);
6489
+ return indexOfRef;
6490
+ };
6491
+ module.getHasPropRef = function() {
6492
+ if (hasPropRef)
6493
+ return hasPropRef;
6494
+ hasPropRef = {
6495
+ type: "Ref",
6496
+ base: "hasProp"
6497
+ };
6498
+ const typeSuffix = {
6499
+ ts: true,
6500
+ children: [": <T>(this: T, prop: keyof T) => boolean"]
6501
+ };
6502
+ const asAny = {
6503
+ ts: true,
6504
+ children: [" as any"]
6505
+ };
6506
+ module.prelude.push(["", "const ", hasPropRef, typeSuffix, " = {}.hasOwnProperty", asAny, "\n"]);
6507
+ return hasPropRef;
6508
+ };
6220
6509
  Object.defineProperty(module.config, "coffeeCompat", {
6221
6510
  set(b) {
6222
6511
  if (b) {
@@ -6224,17 +6513,21 @@ var Civet = (() => {
6224
6513
  this.coffeeBooleans = true;
6225
6514
  this.coffeeComment = true;
6226
6515
  this.coffeeEq = true;
6516
+ this.coffeeForLoops = true;
6227
6517
  this.coffeeInterpolation = true;
6228
6518
  this.coffeeIsnt = true;
6229
6519
  this.coffeeNot = true;
6520
+ this.coffeeOf = true;
6230
6521
  } else {
6231
6522
  this.autoVar = false;
6232
6523
  this.coffeeBooleans = false;
6233
6524
  this.coffeeComment = false;
6234
6525
  this.coffeeEq = false;
6526
+ this.coffeeForLoops = false;
6235
6527
  this.coffeeInterpolation = false;
6236
6528
  this.coffeeIsnt = false;
6237
6529
  this.coffeeNot = false;
6530
+ this.coffeeOf = false;
6238
6531
  }
6239
6532
  }
6240
6533
  });
@@ -6349,7 +6642,7 @@ var Civet = (() => {
6349
6642
  let chains = [];
6350
6643
  while (i < l) {
6351
6644
  const [, op] = binops[i];
6352
- if (relationalOps.includes(op.token)) {
6645
+ if (relationalOps.includes(op.token) || op.type === "Ref") {
6353
6646
  chains.push(i);
6354
6647
  } else if (lowerPrecedenceOps.includes(op.token)) {
6355
6648
  processChains();
@@ -6363,7 +6656,7 @@ var Civet = (() => {
6363
6656
  if (chains.length > 1) {
6364
6657
  chains.forEach((index, k) => {
6365
6658
  if (k > 0) {
6366
- results.push(" && ");
6659
+ results.push(" ", "&&", " ");
6367
6660
  }
6368
6661
  const [pre, op, post, exp] = binops[index];
6369
6662
  let endIndex;
@@ -6411,6 +6704,8 @@ var Civet = (() => {
6411
6704
  };
6412
6705
  module.insertTrimmingSpace = function(spacing, c) {
6413
6706
  let target = spacing;
6707
+ if (!target)
6708
+ return;
6414
6709
  if (Array.isArray(target))
6415
6710
  return module.insertTrimmingSpace(target[0], c);
6416
6711
  if (target.children)
@@ -6483,18 +6778,34 @@ var Civet = (() => {
6483
6778
  case "BlockStatement":
6484
6779
  return [];
6485
6780
  case "ForStatement":
6486
- if (node.declaration.type === "Declaration")
6487
- return [];
6488
- return gatherNodes(node.declaration, predicate);
6781
+ const isDec = node.declaration?.type === "Declaration";
6782
+ return node.children.flatMap((n) => {
6783
+ if (isDec && n === node.declaration)
6784
+ return [];
6785
+ return gatherNodes(n, predicate);
6786
+ });
6489
6787
  default:
6490
6788
  return gatherNodes(node.children, predicate);
6491
6789
  }
6492
6790
  return [];
6493
6791
  }
6792
+ function gatherRecursive(node, predicate) {
6793
+ if (node == null)
6794
+ return [];
6795
+ if (Array.isArray(node)) {
6796
+ return node.flatMap((n) => gatherNodes(n, predicate));
6797
+ }
6798
+ if (predicate(node)) {
6799
+ return [node];
6800
+ }
6801
+ return gatherNodes(node.children, predicate);
6802
+ }
6494
6803
  module.processProgram = function(statements) {
6804
+ statements.unshift(...module.prelude);
6495
6805
  if (module.config.autoVar) {
6496
- module.autoVar(statements, []);
6806
+ createVarDecs(statements, []);
6497
6807
  }
6808
+ populateRefs(statements);
6498
6809
  };
6499
6810
  function findDecs(statements) {
6500
6811
  const declarationNames = gatherNodes(statements, (node) => {
@@ -6504,7 +6815,39 @@ var Civet = (() => {
6504
6815
  }).flatMap((d) => d.names);
6505
6816
  return new Set(declarationNames);
6506
6817
  }
6507
- module.autoVar = function(statements, scopes, pushVar) {
6818
+ function populateRefs(statements) {
6819
+ const refNodes = gatherNodes(statements, ({ type }) => type === "Ref");
6820
+ const blockNodes = new Set(gatherNodes(statements, ({ type }) => type === "BlockStatement"));
6821
+ const forNodes = gatherNodes(statements, ({ type }) => type === "ForStatement");
6822
+ forNodes.forEach(({ declaration, block }) => {
6823
+ if (block.type === "BlockStatement") {
6824
+ populateRefs([declaration, ...block.children]);
6825
+ } else {
6826
+ populateRefs([declaration, ...block]);
6827
+ }
6828
+ blockNodes.delete(block);
6829
+ });
6830
+ blockNodes.forEach(({ expressions }) => populateRefs(expressions));
6831
+ if (refNodes.length) {
6832
+ const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
6833
+ const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
6834
+ refNodes.forEach((ref) => {
6835
+ const { type, base } = ref;
6836
+ if (type !== "Ref")
6837
+ return;
6838
+ ref.type = "Identifier";
6839
+ let n = 0;
6840
+ let name = base;
6841
+ while (names.has(name)) {
6842
+ n++;
6843
+ name = `${base}${n}`;
6844
+ }
6845
+ names.add(name);
6846
+ ref.children = ref.names = [name];
6847
+ });
6848
+ }
6849
+ }
6850
+ function createVarDecs(statements, scopes, pushVar) {
6508
6851
  function hasDec(name) {
6509
6852
  return scopes.some((s) => s.has(name));
6510
6853
  }
@@ -6513,9 +6856,7 @@ var Civet = (() => {
6513
6856
  return node.type === "AssignmentExpression";
6514
6857
  });
6515
6858
  const undeclaredIdentifiers = assignmentStatements.flatMap((a) => {
6516
- return a.children[0].flatMap((x) => {
6517
- return x[1].names || [];
6518
- });
6859
+ return a.names;
6519
6860
  });
6520
6861
  return undeclaredIdentifiers.filter((x, i, a) => {
6521
6862
  if (!hasDec(x))
@@ -6538,23 +6879,23 @@ var Civet = (() => {
6538
6879
  fnNodes.forEach(({ block }) => blockNodes.delete(block));
6539
6880
  forNodes.forEach(({ block }) => blockNodes.delete(block));
6540
6881
  blockNodes.forEach((block) => {
6541
- module.autoVar(block.expressions, scopes, pushVar);
6882
+ createVarDecs(block.expressions, scopes, pushVar);
6542
6883
  });
6543
6884
  forNodes.forEach(({ block, declaration }) => {
6544
6885
  scopes.push(new Set(declaration.names));
6545
- module.autoVar(block.expressions, scopes, pushVar);
6886
+ createVarDecs(block.expressions, scopes, pushVar);
6546
6887
  scopes.pop();
6547
6888
  });
6548
6889
  fnNodes.forEach(({ block, parameters }) => {
6549
6890
  scopes.push(new Set(parameters.names));
6550
- module.autoVar(block.expressions, scopes);
6891
+ createVarDecs(block.expressions, scopes);
6551
6892
  scopes.pop();
6552
6893
  });
6553
6894
  if (varIds.length) {
6554
6895
  const indent = statements[0][0];
6555
6896
  statements.unshift([indent, "var ", varIds.join(", "), "\n"]);
6556
6897
  }
6557
- };
6898
+ }
6558
6899
  return $0;
6559
6900
  });
6560
6901
  function Init(state) {
@@ -6566,7 +6907,7 @@ var Civet = (() => {
6566
6907
  return Init$0(state);
6567
6908
  }
6568
6909
  }
6569
- var Indent$0 = $TV($Q($C($EXPECT($L151, fail, 'Indent " "'), $EXPECT($L152, fail, 'Indent "\\\\t"'))), function($skip, $loc, $0, $1) {
6910
+ var Indent$0 = $TV($Q($C($EXPECT($L152, fail, 'Indent " "'), $EXPECT($L153, fail, 'Indent "\\\\t"'))), function($skip, $loc, $0, $1) {
6570
6911
  const level = $1.length;
6571
6912
  return {
6572
6913
  $loc,