@danielx/civet 0.4.19-pre.5 → 0.4.19-pre.7

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
@@ -548,6 +548,7 @@ var Civet = (() => {
548
548
  IfClause,
549
549
  UnlessClause,
550
550
  IfExpression,
551
+ UnlessExpression,
551
552
  ExpressionBlock,
552
553
  NestedBlockExpressions,
553
554
  NestedBlockExpression,
@@ -1064,14 +1065,15 @@ var Civet = (() => {
1064
1065
  }
1065
1066
  var ExpressionizedStatement$0 = DebuggerExpression;
1066
1067
  var ExpressionizedStatement$1 = IfExpression;
1067
- var ExpressionizedStatement$2 = IterationExpression;
1068
- var ExpressionizedStatement$3 = SwitchExpression;
1069
- var ExpressionizedStatement$4 = ThrowExpression;
1068
+ var ExpressionizedStatement$2 = UnlessExpression;
1069
+ var ExpressionizedStatement$3 = IterationExpression;
1070
+ var ExpressionizedStatement$4 = SwitchExpression;
1071
+ var ExpressionizedStatement$5 = ThrowExpression;
1070
1072
  function ExpressionizedStatement(state) {
1071
1073
  if (state.tokenize) {
1072
- return $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state));
1074
+ return $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state));
1073
1075
  } else {
1074
- return ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state);
1076
+ return ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state);
1075
1077
  }
1076
1078
  }
1077
1079
  var Expression$0 = $TS($S(AssignmentExpression, $Q($S(__, Comma, AssignmentExpression))), function($skip, $loc, $0, $1, $2) {
@@ -1251,7 +1253,9 @@ var Civet = (() => {
1251
1253
  var exp = $2;
1252
1254
  var post = $3;
1253
1255
  if (post?.token === "?") {
1254
- return ["(", pre, "(", exp, ") != null)"];
1256
+ return {
1257
+ children: ["(", ...pre, "(", exp, ") != null)"]
1258
+ };
1255
1259
  }
1256
1260
  if (exp.type === "Literal") {
1257
1261
  if (pre.length === 1 && pre[0].token === "-") {
@@ -1271,12 +1275,16 @@ var Civet = (() => {
1271
1275
  exp.unshift(...pre);
1272
1276
  if (post)
1273
1277
  exp.push(post);
1274
- return exp;
1278
+ return {
1279
+ children: exp
1280
+ };
1275
1281
  } else {
1276
1282
  const result = [...pre, exp];
1277
1283
  if (post)
1278
1284
  result.push(post);
1279
- return result;
1285
+ return {
1286
+ children: result
1287
+ };
1280
1288
  }
1281
1289
  });
1282
1290
  var UnaryExpression$1 = $TS($S(CoffeeDoEnabled, Do, __, $C($S(LeftHandSideExpression, $N($S(__, AssignmentOpSymbol))), ArrowFunction, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
@@ -1568,8 +1576,21 @@ var Civet = (() => {
1568
1576
  return PrimaryExpression$0(state) || PrimaryExpression$1(state) || PrimaryExpression$2(state) || PrimaryExpression$3(state) || PrimaryExpression$4(state) || PrimaryExpression$5(state) || PrimaryExpression$6(state) || PrimaryExpression$7(state) || PrimaryExpression$8(state) || PrimaryExpression$9(state) || PrimaryExpression$10(state) || PrimaryExpression$11(state);
1569
1577
  }
1570
1578
  }
1571
- var ParenthesizedExpression$0 = $TS($S(OpenParen, ExtendedExpression, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
1579
+ var ParenthesizedExpression$0 = $TS($S(OpenParen, ExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement)), __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
1572
1580
  var exp = $2;
1581
+ var post = $3;
1582
+ if (post) {
1583
+ let clause;
1584
+ switch (post[1].type) {
1585
+ case "IterationStatement":
1586
+ case "ForStatement":
1587
+ clause = module.addPostfixStatement(exp, ...post);
1588
+ return module.expressionizeIteration(clause);
1589
+ case "IfStatement":
1590
+ clause = module.expressionizeIfClause(post[1], exp);
1591
+ return clause;
1592
+ }
1593
+ }
1573
1594
  return {
1574
1595
  type: "ParenthesizedExpression",
1575
1596
  expression: exp,
@@ -2385,14 +2406,24 @@ var Civet = (() => {
2385
2406
  }
2386
2407
  var Block$0 = $T($S(__, OpenBrace, EOS, NestedBlockStatements, __, CloseBrace), function(value) {
2387
2408
  var exps = value[3];
2388
- return { "type": "BlockStatement", "expressions": exps, "children": value };
2409
+ return { "type": "BlockStatement", "expressions": exps, "children": value, "bare": false };
2389
2410
  });
2390
2411
  var Block$1 = $T($S(InsertOpenBrace, EOS, NestedBlockStatements, InsertNewline, InsertIndent, InsertCloseBrace), function(value) {
2391
2412
  var exps = value[2];
2392
- return { "type": "BlockStatement", "expressions": exps, "children": value };
2413
+ return { "type": "BlockStatement", "expressions": exps, "children": value, "bare": false };
2393
2414
  });
2394
2415
  var Block$2 = ThenClause;
2395
- var Block$3 = $S($Q(TrailingComment), Statement);
2416
+ var Block$3 = $TS($S($Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2) {
2417
+ var ws = $1;
2418
+ var s = $2;
2419
+ const expressions = [$0];
2420
+ return {
2421
+ type: "BlockStatement",
2422
+ expressions,
2423
+ children: [expressions],
2424
+ bare: true
2425
+ };
2426
+ });
2396
2427
  function Block(state) {
2397
2428
  if (state.tokenize) {
2398
2429
  return $TOKEN("Block", state, Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state));
@@ -2400,8 +2431,16 @@ var Civet = (() => {
2400
2431
  return Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state);
2401
2432
  }
2402
2433
  }
2403
- var ThenClause$0 = $T($S(Then, $Q(TrailingComment), Statement), function(value) {
2404
- return [value[1], value[2]];
2434
+ var ThenClause$0 = $TS($S(Then, $Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2, $3) {
2435
+ var ws = $2;
2436
+ var s = $3;
2437
+ const expressions = [[ws, s]];
2438
+ return {
2439
+ type: "BlockStatement",
2440
+ expressions,
2441
+ children: [expressions],
2442
+ bare: true
2443
+ };
2405
2444
  });
2406
2445
  function ThenClause(state) {
2407
2446
  if (state.verbose)
@@ -3282,31 +3321,11 @@ var Civet = (() => {
3282
3321
  }
3283
3322
  }
3284
3323
  var StatementListItem$0 = Declaration;
3285
- var StatementListItem$1 = $TS($S(Statement, $Q(TrailingComment), $E(PostfixStatement)), function($skip, $loc, $0, $1, $2, $3) {
3324
+ var StatementListItem$1 = $TS($S(Statement, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
3286
3325
  var statement = $1;
3287
- var ws = $2;
3288
- var post = $3;
3289
- if (post) {
3290
- let children, expressions;
3291
- if (post.blockPrefix?.length) {
3292
- let indent = post.blockPrefix[0][0];
3293
- expressions = [...post.blockPrefix, [indent, statement]];
3294
- children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
3295
- } else {
3296
- expressions = [["", statement]];
3297
- children = [" { ", ...expressions, " }"];
3298
- }
3299
- const block = {
3300
- type: "BlockStatement",
3301
- children,
3302
- expressions
3303
- };
3304
- post.block = block;
3305
- post.children.push(block);
3306
- if (!module.isWhitespaceOrEmpty(ws))
3307
- post.children.push(ws);
3308
- return post;
3309
- }
3326
+ var post = $2;
3327
+ if (post)
3328
+ return module.addPostfixStatement(statement, ...post);
3310
3329
  return statement;
3311
3330
  });
3312
3331
  function StatementListItem(state) {
@@ -3434,16 +3453,7 @@ var Civet = (() => {
3434
3453
  var clause = $1;
3435
3454
  var b = $2;
3436
3455
  var e = $3;
3437
- clause.children.shift();
3438
- clause.children.push("?", b, ":");
3439
- if (e) {
3440
- e.splice(1, 1);
3441
- clause.children.push(e);
3442
- } else {
3443
- clause.children.push("void 0");
3444
- }
3445
- clause.type = "IfExpression";
3446
- return clause;
3456
+ return module.expressionizeIfClause(clause, b, e);
3447
3457
  });
3448
3458
  function IfExpression(state) {
3449
3459
  if (state.verbose)
@@ -3454,6 +3464,21 @@ var Civet = (() => {
3454
3464
  return IfExpression$0(state);
3455
3465
  }
3456
3466
  }
3467
+ var UnlessExpression$0 = $TS($S(UnlessClause, ExpressionBlock, $E($S(__, Else, ExpressionBlock))), function($skip, $loc, $0, $1, $2, $3) {
3468
+ var clause = $1;
3469
+ var b = $2;
3470
+ var e = $3;
3471
+ return module.expressionizeIfClause(clause, b, e);
3472
+ });
3473
+ function UnlessExpression(state) {
3474
+ if (state.verbose)
3475
+ console.log("ENTER:", "UnlessExpression");
3476
+ if (state.tokenize) {
3477
+ return $TOKEN("UnlessExpression", state, UnlessExpression$0(state));
3478
+ } else {
3479
+ return UnlessExpression$0(state);
3480
+ }
3481
+ }
3457
3482
  var ExpressionBlock$0 = $TS($S(InsertOpenParen, EOS, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
3458
3483
  var exps = $3;
3459
3484
  exps[exps.length - 1].pop();
@@ -3649,10 +3674,10 @@ var Civet = (() => {
3649
3674
  if ($3) {
3650
3675
  const indent = "".padStart((module.currentIndent + 1) * 2);
3651
3676
  module.insertTrimmingSpace($3, "");
3652
- $2.blockPrefix.push({
3677
+ $2.blockPrefix.push([indent, {
3653
3678
  type: "IfStatement",
3654
- children: [indent, "if (!(", $3, ")) continue\n"]
3655
- });
3679
+ children: ["if (!(", $3, ")) continue\n"]
3680
+ }]);
3656
3681
  }
3657
3682
  return $2;
3658
3683
  });
@@ -3762,7 +3787,7 @@ var Civet = (() => {
3762
3787
  children: ["let ", ...startRefDec, ...endRefDec, counterRef, " = ", varRef2, " = ", startRef, ...ascDec],
3763
3788
  names: []
3764
3789
  };
3765
- blockPrefix.push([{
3790
+ blockPrefix.push(["", {
3766
3791
  type: "AssignmentExpression",
3767
3792
  children: [],
3768
3793
  names: varRef2.names
@@ -3800,9 +3825,9 @@ var Civet = (() => {
3800
3825
  indexAssignment = [index, "="];
3801
3826
  assignmentNames.push(...index.names);
3802
3827
  }
3803
- blockPrefix.push([{
3828
+ blockPrefix.push([indent, {
3804
3829
  type: "AssignmentExpression",
3805
- children: [indent, varRef, " = ", expRef, "[", indexAssignment, counterRef, "]\n"],
3830
+ children: [varRef, " = ", expRef, "[", indexAssignment, counterRef, "]\n"],
3806
3831
  names: assignmentNames
3807
3832
  }]);
3808
3833
  return {
@@ -4070,10 +4095,18 @@ var Civet = (() => {
4070
4095
  var expressions = value[2];
4071
4096
  return { "type": "CaseClause", "cases": cases, "expressions": expressions, "children": value };
4072
4097
  });
4073
- var CaseClause$1 = $T($S(When, CaseExpressionList, $C(ThenClause, NestedBlockStatements), InsertBreak), function(value) {
4074
- var cases = value[1];
4075
- var expressions = value[2];
4076
- return { "type": "WhenClause", "cases": cases, "expressions": expressions, "children": value };
4098
+ var CaseClause$1 = $TS($S(When, CaseExpressionList, $C(ThenClause, NestedBlockStatements), InsertBreak), function($skip, $loc, $0, $1, $2, $3, $4) {
4099
+ var cases = $2;
4100
+ var expressions = $3;
4101
+ if (expressions.expressions) {
4102
+ expressions = expressions.expressions;
4103
+ }
4104
+ return {
4105
+ type: "WhenClause",
4106
+ cases,
4107
+ expressions,
4108
+ children: $0
4109
+ };
4077
4110
  });
4078
4111
  var CaseClause$2 = $T($S(Default, ImpliedColon, $C(NestedBlockStatements, NoExpressions)), function(value) {
4079
4112
  var exps = value[2];
@@ -7112,6 +7145,39 @@ var Civet = (() => {
7112
7145
  Object.assign(module.config, directive.config);
7113
7146
  }
7114
7147
  });
7148
+ module.expressionizeIfClause = function(clause, b, e) {
7149
+ clause.children.shift();
7150
+ clause.children.push("?", b, ":");
7151
+ if (e) {
7152
+ e.splice(1, 1);
7153
+ clause.children.push(e);
7154
+ } else {
7155
+ clause.children.push("void 0");
7156
+ }
7157
+ clause.type = "IfExpression";
7158
+ return clause;
7159
+ };
7160
+ module.addPostfixStatement = function(statement, ws, post) {
7161
+ let children, expressions;
7162
+ if (post.blockPrefix?.length) {
7163
+ let indent = post.blockPrefix[0][0];
7164
+ expressions = [...post.blockPrefix, [indent, statement]];
7165
+ children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
7166
+ } else {
7167
+ expressions = [["", statement]];
7168
+ children = [" { ", ...expressions, " }"];
7169
+ }
7170
+ const block = {
7171
+ type: "BlockStatement",
7172
+ children,
7173
+ expressions
7174
+ };
7175
+ post.block = block;
7176
+ post.children.push(block);
7177
+ if (!module.isWhitespaceOrEmpty(ws))
7178
+ post.children.push(ws);
7179
+ return post;
7180
+ };
7115
7181
  module.expressionizeIteration = function(statement) {
7116
7182
  const resultsRef = {
7117
7183
  type: "Ref",
package/dist/civet CHANGED
@@ -10,7 +10,13 @@ if (process.argv.includes("--version")) {
10
10
  encoding = "utf8";
11
11
  process.stdin.setEncoding(encoding);
12
12
  fs = require("fs");
13
- readline = require("node:readline");
13
+ readline = function() {
14
+ try {
15
+ return require("node:readline");
16
+ } catch (error) {
17
+ return require("readline");
18
+ }
19
+ }();
14
20
  readLines = function(rl) {
15
21
  return new Promise(function(resolve, reject) {
16
22
  var parts;
@@ -45,6 +51,6 @@ readLines(readline.createInterface(process.stdin)).then(function(input) {
45
51
  output = compile(input, { filename, js, inlineMap });
46
52
  return process.stdout.write(output);
47
53
  }).catch(function(e) {
48
- console.error(e.message);
54
+ console.error(e);
49
55
  return process.exit(1);
50
56
  });
package/dist/main.js CHANGED
@@ -547,6 +547,7 @@ var require_parser = __commonJS({
547
547
  IfClause,
548
548
  UnlessClause,
549
549
  IfExpression,
550
+ UnlessExpression,
550
551
  ExpressionBlock,
551
552
  NestedBlockExpressions,
552
553
  NestedBlockExpression,
@@ -1063,14 +1064,15 @@ var require_parser = __commonJS({
1063
1064
  }
1064
1065
  var ExpressionizedStatement$0 = DebuggerExpression;
1065
1066
  var ExpressionizedStatement$1 = IfExpression;
1066
- var ExpressionizedStatement$2 = IterationExpression;
1067
- var ExpressionizedStatement$3 = SwitchExpression;
1068
- var ExpressionizedStatement$4 = ThrowExpression;
1067
+ var ExpressionizedStatement$2 = UnlessExpression;
1068
+ var ExpressionizedStatement$3 = IterationExpression;
1069
+ var ExpressionizedStatement$4 = SwitchExpression;
1070
+ var ExpressionizedStatement$5 = ThrowExpression;
1069
1071
  function ExpressionizedStatement(state) {
1070
1072
  if (state.tokenize) {
1071
- return $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state));
1073
+ return $TOKEN("ExpressionizedStatement", state, ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state));
1072
1074
  } else {
1073
- return ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state);
1075
+ return ExpressionizedStatement$0(state) || ExpressionizedStatement$1(state) || ExpressionizedStatement$2(state) || ExpressionizedStatement$3(state) || ExpressionizedStatement$4(state) || ExpressionizedStatement$5(state);
1074
1076
  }
1075
1077
  }
1076
1078
  var Expression$0 = $TS($S(AssignmentExpression, $Q($S(__, Comma, AssignmentExpression))), function($skip, $loc, $0, $1, $2) {
@@ -1250,7 +1252,9 @@ var require_parser = __commonJS({
1250
1252
  var exp = $2;
1251
1253
  var post = $3;
1252
1254
  if (post?.token === "?") {
1253
- return ["(", pre, "(", exp, ") != null)"];
1255
+ return {
1256
+ children: ["(", ...pre, "(", exp, ") != null)"]
1257
+ };
1254
1258
  }
1255
1259
  if (exp.type === "Literal") {
1256
1260
  if (pre.length === 1 && pre[0].token === "-") {
@@ -1270,12 +1274,16 @@ var require_parser = __commonJS({
1270
1274
  exp.unshift(...pre);
1271
1275
  if (post)
1272
1276
  exp.push(post);
1273
- return exp;
1277
+ return {
1278
+ children: exp
1279
+ };
1274
1280
  } else {
1275
1281
  const result = [...pre, exp];
1276
1282
  if (post)
1277
1283
  result.push(post);
1278
- return result;
1284
+ return {
1285
+ children: result
1286
+ };
1279
1287
  }
1280
1288
  });
1281
1289
  var UnaryExpression$1 = $TS($S(CoffeeDoEnabled, Do, __, $C($S(LeftHandSideExpression, $N($S(__, AssignmentOpSymbol))), ArrowFunction, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
@@ -1567,8 +1575,21 @@ var require_parser = __commonJS({
1567
1575
  return PrimaryExpression$0(state) || PrimaryExpression$1(state) || PrimaryExpression$2(state) || PrimaryExpression$3(state) || PrimaryExpression$4(state) || PrimaryExpression$5(state) || PrimaryExpression$6(state) || PrimaryExpression$7(state) || PrimaryExpression$8(state) || PrimaryExpression$9(state) || PrimaryExpression$10(state) || PrimaryExpression$11(state);
1568
1576
  }
1569
1577
  }
1570
- var ParenthesizedExpression$0 = $TS($S(OpenParen, ExtendedExpression, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
1578
+ var ParenthesizedExpression$0 = $TS($S(OpenParen, ExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement)), __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
1571
1579
  var exp = $2;
1580
+ var post = $3;
1581
+ if (post) {
1582
+ let clause;
1583
+ switch (post[1].type) {
1584
+ case "IterationStatement":
1585
+ case "ForStatement":
1586
+ clause = module2.addPostfixStatement(exp, ...post);
1587
+ return module2.expressionizeIteration(clause);
1588
+ case "IfStatement":
1589
+ clause = module2.expressionizeIfClause(post[1], exp);
1590
+ return clause;
1591
+ }
1592
+ }
1572
1593
  return {
1573
1594
  type: "ParenthesizedExpression",
1574
1595
  expression: exp,
@@ -2384,14 +2405,24 @@ var require_parser = __commonJS({
2384
2405
  }
2385
2406
  var Block$0 = $T($S(__, OpenBrace, EOS, NestedBlockStatements, __, CloseBrace), function(value) {
2386
2407
  var exps = value[3];
2387
- return { "type": "BlockStatement", "expressions": exps, "children": value };
2408
+ return { "type": "BlockStatement", "expressions": exps, "children": value, "bare": false };
2388
2409
  });
2389
2410
  var Block$1 = $T($S(InsertOpenBrace, EOS, NestedBlockStatements, InsertNewline, InsertIndent, InsertCloseBrace), function(value) {
2390
2411
  var exps = value[2];
2391
- return { "type": "BlockStatement", "expressions": exps, "children": value };
2412
+ return { "type": "BlockStatement", "expressions": exps, "children": value, "bare": false };
2392
2413
  });
2393
2414
  var Block$2 = ThenClause;
2394
- var Block$3 = $S($Q(TrailingComment), Statement);
2415
+ var Block$3 = $TS($S($Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2) {
2416
+ var ws = $1;
2417
+ var s = $2;
2418
+ const expressions = [$0];
2419
+ return {
2420
+ type: "BlockStatement",
2421
+ expressions,
2422
+ children: [expressions],
2423
+ bare: true
2424
+ };
2425
+ });
2395
2426
  function Block(state) {
2396
2427
  if (state.tokenize) {
2397
2428
  return $TOKEN("Block", state, Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state));
@@ -2399,8 +2430,16 @@ var require_parser = __commonJS({
2399
2430
  return Block$0(state) || Block$1(state) || Block$2(state) || Block$3(state);
2400
2431
  }
2401
2432
  }
2402
- var ThenClause$0 = $T($S(Then, $Q(TrailingComment), Statement), function(value) {
2403
- return [value[1], value[2]];
2433
+ var ThenClause$0 = $TS($S(Then, $Q(TrailingComment), Statement), function($skip, $loc, $0, $1, $2, $3) {
2434
+ var ws = $2;
2435
+ var s = $3;
2436
+ const expressions = [[ws, s]];
2437
+ return {
2438
+ type: "BlockStatement",
2439
+ expressions,
2440
+ children: [expressions],
2441
+ bare: true
2442
+ };
2404
2443
  });
2405
2444
  function ThenClause(state) {
2406
2445
  if (state.verbose)
@@ -3281,31 +3320,11 @@ var require_parser = __commonJS({
3281
3320
  }
3282
3321
  }
3283
3322
  var StatementListItem$0 = Declaration;
3284
- var StatementListItem$1 = $TS($S(Statement, $Q(TrailingComment), $E(PostfixStatement)), function($skip, $loc, $0, $1, $2, $3) {
3323
+ var StatementListItem$1 = $TS($S(Statement, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
3285
3324
  var statement = $1;
3286
- var ws = $2;
3287
- var post = $3;
3288
- if (post) {
3289
- let children, expressions;
3290
- if (post.blockPrefix?.length) {
3291
- let indent = post.blockPrefix[0][0];
3292
- expressions = [...post.blockPrefix, [indent, statement]];
3293
- children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
3294
- } else {
3295
- expressions = [["", statement]];
3296
- children = [" { ", ...expressions, " }"];
3297
- }
3298
- const block = {
3299
- type: "BlockStatement",
3300
- children,
3301
- expressions
3302
- };
3303
- post.block = block;
3304
- post.children.push(block);
3305
- if (!module2.isWhitespaceOrEmpty(ws))
3306
- post.children.push(ws);
3307
- return post;
3308
- }
3325
+ var post = $2;
3326
+ if (post)
3327
+ return module2.addPostfixStatement(statement, ...post);
3309
3328
  return statement;
3310
3329
  });
3311
3330
  function StatementListItem(state) {
@@ -3433,16 +3452,7 @@ var require_parser = __commonJS({
3433
3452
  var clause = $1;
3434
3453
  var b = $2;
3435
3454
  var e = $3;
3436
- clause.children.shift();
3437
- clause.children.push("?", b, ":");
3438
- if (e) {
3439
- e.splice(1, 1);
3440
- clause.children.push(e);
3441
- } else {
3442
- clause.children.push("void 0");
3443
- }
3444
- clause.type = "IfExpression";
3445
- return clause;
3455
+ return module2.expressionizeIfClause(clause, b, e);
3446
3456
  });
3447
3457
  function IfExpression(state) {
3448
3458
  if (state.verbose)
@@ -3453,6 +3463,21 @@ var require_parser = __commonJS({
3453
3463
  return IfExpression$0(state);
3454
3464
  }
3455
3465
  }
3466
+ var UnlessExpression$0 = $TS($S(UnlessClause, ExpressionBlock, $E($S(__, Else, ExpressionBlock))), function($skip, $loc, $0, $1, $2, $3) {
3467
+ var clause = $1;
3468
+ var b = $2;
3469
+ var e = $3;
3470
+ return module2.expressionizeIfClause(clause, b, e);
3471
+ });
3472
+ function UnlessExpression(state) {
3473
+ if (state.verbose)
3474
+ console.log("ENTER:", "UnlessExpression");
3475
+ if (state.tokenize) {
3476
+ return $TOKEN("UnlessExpression", state, UnlessExpression$0(state));
3477
+ } else {
3478
+ return UnlessExpression$0(state);
3479
+ }
3480
+ }
3456
3481
  var ExpressionBlock$0 = $TS($S(InsertOpenParen, EOS, NestedBlockExpressions, InsertNewline, InsertIndent, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
3457
3482
  var exps = $3;
3458
3483
  exps[exps.length - 1].pop();
@@ -3648,10 +3673,10 @@ var require_parser = __commonJS({
3648
3673
  if ($3) {
3649
3674
  const indent = "".padStart((module2.currentIndent + 1) * 2);
3650
3675
  module2.insertTrimmingSpace($3, "");
3651
- $2.blockPrefix.push({
3676
+ $2.blockPrefix.push([indent, {
3652
3677
  type: "IfStatement",
3653
- children: [indent, "if (!(", $3, ")) continue\n"]
3654
- });
3678
+ children: ["if (!(", $3, ")) continue\n"]
3679
+ }]);
3655
3680
  }
3656
3681
  return $2;
3657
3682
  });
@@ -3761,7 +3786,7 @@ var require_parser = __commonJS({
3761
3786
  children: ["let ", ...startRefDec, ...endRefDec, counterRef, " = ", varRef2, " = ", startRef, ...ascDec],
3762
3787
  names: []
3763
3788
  };
3764
- blockPrefix.push([{
3789
+ blockPrefix.push(["", {
3765
3790
  type: "AssignmentExpression",
3766
3791
  children: [],
3767
3792
  names: varRef2.names
@@ -3799,9 +3824,9 @@ var require_parser = __commonJS({
3799
3824
  indexAssignment = [index, "="];
3800
3825
  assignmentNames.push(...index.names);
3801
3826
  }
3802
- blockPrefix.push([{
3827
+ blockPrefix.push([indent, {
3803
3828
  type: "AssignmentExpression",
3804
- children: [indent, varRef, " = ", expRef, "[", indexAssignment, counterRef, "]\n"],
3829
+ children: [varRef, " = ", expRef, "[", indexAssignment, counterRef, "]\n"],
3805
3830
  names: assignmentNames
3806
3831
  }]);
3807
3832
  return {
@@ -4069,10 +4094,18 @@ var require_parser = __commonJS({
4069
4094
  var expressions = value[2];
4070
4095
  return { "type": "CaseClause", "cases": cases, "expressions": expressions, "children": value };
4071
4096
  });
4072
- var CaseClause$1 = $T($S(When, CaseExpressionList, $C(ThenClause, NestedBlockStatements), InsertBreak), function(value) {
4073
- var cases = value[1];
4074
- var expressions = value[2];
4075
- return { "type": "WhenClause", "cases": cases, "expressions": expressions, "children": value };
4097
+ var CaseClause$1 = $TS($S(When, CaseExpressionList, $C(ThenClause, NestedBlockStatements), InsertBreak), function($skip, $loc, $0, $1, $2, $3, $4) {
4098
+ var cases = $2;
4099
+ var expressions = $3;
4100
+ if (expressions.expressions) {
4101
+ expressions = expressions.expressions;
4102
+ }
4103
+ return {
4104
+ type: "WhenClause",
4105
+ cases,
4106
+ expressions,
4107
+ children: $0
4108
+ };
4076
4109
  });
4077
4110
  var CaseClause$2 = $T($S(Default, ImpliedColon, $C(NestedBlockStatements, NoExpressions)), function(value) {
4078
4111
  var exps = value[2];
@@ -7111,6 +7144,39 @@ var require_parser = __commonJS({
7111
7144
  Object.assign(module2.config, directive.config);
7112
7145
  }
7113
7146
  });
7147
+ module2.expressionizeIfClause = function(clause, b, e) {
7148
+ clause.children.shift();
7149
+ clause.children.push("?", b, ":");
7150
+ if (e) {
7151
+ e.splice(1, 1);
7152
+ clause.children.push(e);
7153
+ } else {
7154
+ clause.children.push("void 0");
7155
+ }
7156
+ clause.type = "IfExpression";
7157
+ return clause;
7158
+ };
7159
+ module2.addPostfixStatement = function(statement, ws, post) {
7160
+ let children, expressions;
7161
+ if (post.blockPrefix?.length) {
7162
+ let indent = post.blockPrefix[0][0];
7163
+ expressions = [...post.blockPrefix, [indent, statement]];
7164
+ children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
7165
+ } else {
7166
+ expressions = [["", statement]];
7167
+ children = [" { ", ...expressions, " }"];
7168
+ }
7169
+ const block = {
7170
+ type: "BlockStatement",
7171
+ children,
7172
+ expressions
7173
+ };
7174
+ post.block = block;
7175
+ post.children.push(block);
7176
+ if (!module2.isWhitespaceOrEmpty(ws))
7177
+ post.children.push(ws);
7178
+ return post;
7179
+ };
7114
7180
  module2.expressionizeIteration = function(statement) {
7115
7181
  const resultsRef = {
7116
7182
  type: "Ref",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.4.19-pre.5",
3
+ "version": "0.4.19-pre.7",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "exports": {