@danielx/civet 0.4.19-pre.3 → 0.4.19-pre.4

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
@@ -490,6 +490,7 @@ var Civet = (() => {
490
490
  ThinArrowFunction,
491
491
  Arrow,
492
492
  Block,
493
+ ThenClause,
493
494
  BracedOrEmptyBlock,
494
495
  EmptyBlock,
495
496
  BracedBlock,
@@ -566,6 +567,7 @@ var Civet = (() => {
566
567
  ForDeclaration,
567
568
  ForBinding,
568
569
  SwitchStatement,
570
+ EmptyCondition,
569
571
  SwitchExpression,
570
572
  CaseBlock,
571
573
  NestedCaseClauses,
@@ -2385,12 +2387,8 @@ var Civet = (() => {
2385
2387
  var exps = value[2];
2386
2388
  return { "type": "BlockStatement", "expressions": exps, "children": value };
2387
2389
  });
2388
- var Block$2 = $T($S($E(Then), Statement), function(value) {
2389
- return value[1];
2390
- });
2391
- var Block$3 = $T($S($E(Then), __, Statement), function(value) {
2392
- return [value[1], value[2]];
2393
- });
2390
+ var Block$2 = ThenClause;
2391
+ var Block$3 = $S($Q(TrailingComment), Statement);
2394
2392
  function Block(state) {
2395
2393
  if (state.tokenize) {
2396
2394
  return $TOKEN("Block", state, Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state));
@@ -2398,6 +2396,18 @@ var Civet = (() => {
2398
2396
  return Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state);
2399
2397
  }
2400
2398
  }
2399
+ var ThenClause$0 = $T($S(Then, $Q(TrailingComment), Statement), function(value) {
2400
+ return [value[1], value[2]];
2401
+ });
2402
+ function ThenClause(state) {
2403
+ if (state.verbose)
2404
+ console.log("ENTER:", "ThenClause");
2405
+ if (state.tokenize) {
2406
+ return $TOKEN("ThenClause", state, ThenClause$0(state));
2407
+ } else {
2408
+ return ThenClause$0(state);
2409
+ }
2410
+ }
2401
2411
  var BracedOrEmptyBlock$0 = BracedBlock;
2402
2412
  var BracedOrEmptyBlock$1 = EmptyBlock;
2403
2413
  function BracedOrEmptyBlock(state) {
@@ -3877,8 +3887,30 @@ var Civet = (() => {
3877
3887
  return ForBinding$0(state) || ForBinding$1(state);
3878
3888
  }
3879
3889
  }
3880
- var SwitchStatement$0 = $T($S(Switch, Condition, CaseBlock), function(value) {
3881
- return { "type": "SwitchStatement", "children": value };
3890
+ var SwitchStatement$0 = $TS($S(Switch, $C(EmptyCondition, Condition), CaseBlock), function($skip, $loc, $0, $1, $2, $3) {
3891
+ var condition = $2;
3892
+ var caseBlock = $3;
3893
+ if (condition.type === "EmptyCondition") {
3894
+ caseBlock.clauses.forEach(({ cases }) => {
3895
+ if (cases) {
3896
+ cases.forEach((c) => {
3897
+ const exp = c[1];
3898
+ switch (exp.type) {
3899
+ case "Identifier":
3900
+ case "Literal":
3901
+ c.splice(1, 0, "!");
3902
+ break;
3903
+ default:
3904
+ c.splice(1, 1, "!(", exp, ")");
3905
+ }
3906
+ });
3907
+ }
3908
+ });
3909
+ }
3910
+ return {
3911
+ type: "SwitchStatement",
3912
+ children: $0
3913
+ };
3882
3914
  });
3883
3915
  function SwitchStatement(state) {
3884
3916
  if (state.verbose)
@@ -3889,6 +3921,24 @@ var Civet = (() => {
3889
3921
  return SwitchStatement$0(state);
3890
3922
  }
3891
3923
  }
3924
+ var EmptyCondition$0 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
3925
+ return {
3926
+ type: "EmptyCondition",
3927
+ children: [{
3928
+ $loc,
3929
+ token: " (false)"
3930
+ }]
3931
+ };
3932
+ });
3933
+ function EmptyCondition(state) {
3934
+ if (state.verbose)
3935
+ console.log("ENTER:", "EmptyCondition");
3936
+ if (state.tokenize) {
3937
+ return $TOKEN("EmptyCondition", state, EmptyCondition$0(state));
3938
+ } else {
3939
+ return EmptyCondition$0(state);
3940
+ }
3941
+ }
3892
3942
  var SwitchExpression$0 = $TV(SwitchStatement, function($skip, $loc, $0, $1) {
3893
3943
  var e = $0;
3894
3944
  module.addImplicitReturns(e.children[2]);
@@ -3959,18 +4009,20 @@ var Civet = (() => {
3959
4009
  }
3960
4010
  }
3961
4011
  var CaseClause$0 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, NoExpressions)), function(value) {
3962
- var exps = value[2];
3963
- return { "type": "CaseClause", "expressions": exps, "children": value };
4012
+ var cases = value[1];
4013
+ var expressions = value[2];
4014
+ return { "type": "CaseClause", "cases": cases, "expressions": expressions, "children": value };
3964
4015
  });
3965
- var CaseClause$1 = $T($S(When, CaseExpressionList, NestedBlockStatements, InsertBreak), function(value) {
3966
- var exps = value[2];
3967
- return { "type": "WhenClause", "expressions": exps, "children": value };
4016
+ var CaseClause$1 = $T($S(When, CaseExpressionList, $C(ThenClause, NestedBlockStatements), InsertBreak), function(value) {
4017
+ var cases = value[1];
4018
+ var expressions = value[2];
4019
+ return { "type": "WhenClause", "cases": cases, "expressions": expressions, "children": value };
3968
4020
  });
3969
4021
  var CaseClause$2 = $T($S(Default, ImpliedColon, $C(NestedBlockStatements, NoExpressions)), function(value) {
3970
4022
  var exps = value[2];
3971
4023
  return { "type": "DefaultClause", "expressions": exps, "children": value };
3972
4024
  });
3973
- var CaseClause$3 = $TS($S(Else, ImpliedColon, NestedBlockStatements), function($skip, $loc, $0, $1, $2, $3) {
4025
+ var CaseClause$3 = $TS($S(Else, ImpliedColon, $C(NestedBlockStatements, $S($Q(TrailingComment), Statement))), function($skip, $loc, $0, $1, $2, $3) {
3974
4026
  var exps = $3;
3975
4027
  $1.token = "default";
3976
4028
  return {
package/dist/main.js CHANGED
@@ -489,6 +489,7 @@ var require_parser = __commonJS({
489
489
  ThinArrowFunction,
490
490
  Arrow,
491
491
  Block,
492
+ ThenClause,
492
493
  BracedOrEmptyBlock,
493
494
  EmptyBlock,
494
495
  BracedBlock,
@@ -565,6 +566,7 @@ var require_parser = __commonJS({
565
566
  ForDeclaration,
566
567
  ForBinding,
567
568
  SwitchStatement,
569
+ EmptyCondition,
568
570
  SwitchExpression,
569
571
  CaseBlock,
570
572
  NestedCaseClauses,
@@ -2384,12 +2386,8 @@ var require_parser = __commonJS({
2384
2386
  var exps = value[2];
2385
2387
  return { "type": "BlockStatement", "expressions": exps, "children": value };
2386
2388
  });
2387
- var Block$2 = $T($S($E(Then), Statement), function(value) {
2388
- return value[1];
2389
- });
2390
- var Block$3 = $T($S($E(Then), __, Statement), function(value) {
2391
- return [value[1], value[2]];
2392
- });
2389
+ var Block$2 = ThenClause;
2390
+ var Block$3 = $S($Q(TrailingComment), Statement);
2393
2391
  function Block(state) {
2394
2392
  if (state.tokenize) {
2395
2393
  return $TOKEN("Block", state, Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state));
@@ -2397,6 +2395,18 @@ var require_parser = __commonJS({
2397
2395
  return Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state);
2398
2396
  }
2399
2397
  }
2398
+ var ThenClause$0 = $T($S(Then, $Q(TrailingComment), Statement), function(value) {
2399
+ return [value[1], value[2]];
2400
+ });
2401
+ function ThenClause(state) {
2402
+ if (state.verbose)
2403
+ console.log("ENTER:", "ThenClause");
2404
+ if (state.tokenize) {
2405
+ return $TOKEN("ThenClause", state, ThenClause$0(state));
2406
+ } else {
2407
+ return ThenClause$0(state);
2408
+ }
2409
+ }
2400
2410
  var BracedOrEmptyBlock$0 = BracedBlock;
2401
2411
  var BracedOrEmptyBlock$1 = EmptyBlock;
2402
2412
  function BracedOrEmptyBlock(state) {
@@ -3876,8 +3886,30 @@ var require_parser = __commonJS({
3876
3886
  return ForBinding$0(state) || ForBinding$1(state);
3877
3887
  }
3878
3888
  }
3879
- var SwitchStatement$0 = $T($S(Switch, Condition, CaseBlock), function(value) {
3880
- return { "type": "SwitchStatement", "children": value };
3889
+ var SwitchStatement$0 = $TS($S(Switch, $C(EmptyCondition, Condition), CaseBlock), function($skip, $loc, $0, $1, $2, $3) {
3890
+ var condition = $2;
3891
+ var caseBlock = $3;
3892
+ if (condition.type === "EmptyCondition") {
3893
+ caseBlock.clauses.forEach(({ cases }) => {
3894
+ if (cases) {
3895
+ cases.forEach((c) => {
3896
+ const exp = c[1];
3897
+ switch (exp.type) {
3898
+ case "Identifier":
3899
+ case "Literal":
3900
+ c.splice(1, 0, "!");
3901
+ break;
3902
+ default:
3903
+ c.splice(1, 1, "!(", exp, ")");
3904
+ }
3905
+ });
3906
+ }
3907
+ });
3908
+ }
3909
+ return {
3910
+ type: "SwitchStatement",
3911
+ children: $0
3912
+ };
3881
3913
  });
3882
3914
  function SwitchStatement(state) {
3883
3915
  if (state.verbose)
@@ -3888,6 +3920,24 @@ var require_parser = __commonJS({
3888
3920
  return SwitchStatement$0(state);
3889
3921
  }
3890
3922
  }
3923
+ var EmptyCondition$0 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
3924
+ return {
3925
+ type: "EmptyCondition",
3926
+ children: [{
3927
+ $loc,
3928
+ token: " (false)"
3929
+ }]
3930
+ };
3931
+ });
3932
+ function EmptyCondition(state) {
3933
+ if (state.verbose)
3934
+ console.log("ENTER:", "EmptyCondition");
3935
+ if (state.tokenize) {
3936
+ return $TOKEN("EmptyCondition", state, EmptyCondition$0(state));
3937
+ } else {
3938
+ return EmptyCondition$0(state);
3939
+ }
3940
+ }
3891
3941
  var SwitchExpression$0 = $TV(SwitchStatement, function($skip, $loc, $0, $1) {
3892
3942
  var e = $0;
3893
3943
  module2.addImplicitReturns(e.children[2]);
@@ -3958,18 +4008,20 @@ var require_parser = __commonJS({
3958
4008
  }
3959
4009
  }
3960
4010
  var CaseClause$0 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, NoExpressions)), function(value) {
3961
- var exps = value[2];
3962
- return { "type": "CaseClause", "expressions": exps, "children": value };
4011
+ var cases = value[1];
4012
+ var expressions = value[2];
4013
+ return { "type": "CaseClause", "cases": cases, "expressions": expressions, "children": value };
3963
4014
  });
3964
- var CaseClause$1 = $T($S(When, CaseExpressionList, NestedBlockStatements, InsertBreak), function(value) {
3965
- var exps = value[2];
3966
- return { "type": "WhenClause", "expressions": exps, "children": value };
4015
+ var CaseClause$1 = $T($S(When, CaseExpressionList, $C(ThenClause, NestedBlockStatements), InsertBreak), function(value) {
4016
+ var cases = value[1];
4017
+ var expressions = value[2];
4018
+ return { "type": "WhenClause", "cases": cases, "expressions": expressions, "children": value };
3967
4019
  });
3968
4020
  var CaseClause$2 = $T($S(Default, ImpliedColon, $C(NestedBlockStatements, NoExpressions)), function(value) {
3969
4021
  var exps = value[2];
3970
4022
  return { "type": "DefaultClause", "expressions": exps, "children": value };
3971
4023
  });
3972
- var CaseClause$3 = $TS($S(Else, ImpliedColon, NestedBlockStatements), function($skip, $loc, $0, $1, $2, $3) {
4024
+ var CaseClause$3 = $TS($S(Else, ImpliedColon, $C(NestedBlockStatements, $S($Q(TrailingComment), Statement))), function($skip, $loc, $0, $1, $2, $3) {
3973
4025
  var exps = $3;
3974
4026
  $1.token = "default";
3975
4027
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.4.19-pre.3",
3
+ "version": "0.4.19-pre.4",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "exports": {