rip-lang 3.8.8 → 3.8.9

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.
Binary file
@@ -3184,7 +3184,7 @@ var parserInstance = {
3184
3184
  case 229:
3185
3185
  return $[$0 - 4].length === 3 ? ["if", $[$0 - 4][1], $[$0 - 4][2], ["if", $[$0 - 1], $[$0]]] : [...$[$0 - 4], ["if", $[$0 - 1], $[$0]]];
3186
3186
  case 230:
3187
- return ["unless", $[$0 - 1], $[$0]];
3187
+ return ["if", ["!", $[$0 - 1]], $[$0]];
3188
3188
  case 231:
3189
3189
  return ["if", ["!", $[$0 - 3]], $[$0 - 2], $[$0]];
3190
3190
  case 233:
@@ -3196,7 +3196,7 @@ var parserInstance = {
3196
3196
  return ["?:", $[$0 - 4], $[$0 - 6], $[$0 - 1]];
3197
3197
  case 238:
3198
3198
  case 239:
3199
- return ["unless", $[$0], [$[$0 - 2]]];
3199
+ return ["if", ["!", $[$0]], [$[$0 - 2]]];
3200
3200
  case 240:
3201
3201
  return ["try", $[$0]];
3202
3202
  case 241:
@@ -3230,9 +3230,9 @@ var parserInstance = {
3230
3230
  case 256:
3231
3231
  return ["while", $[$0 - 2], $[$0]];
3232
3232
  case 257:
3233
- return ["until", $[$0]];
3233
+ return ["while", ["!", $[$0]]];
3234
3234
  case 258:
3235
- return ["until", $[$0 - 2], $[$0]];
3235
+ return ["while", ["!", $[$0 - 2]], $[$0]];
3236
3236
  case 259:
3237
3237
  return $[$0 - 1].length === 2 ? [$[$0 - 1][0], $[$0 - 1][1], $[$0]] : [$[$0 - 1][0], $[$0 - 1][1], $[$0 - 1][2], $[$0]];
3238
3238
  case 260:
@@ -4742,6 +4742,7 @@ class CodeGenerator {
4742
4742
  ">>": "generateBinaryOp",
4743
4743
  ">>>": "generateBinaryOp",
4744
4744
  "%%": "generateModulo",
4745
+ "%%=": "generateModuloAssign",
4745
4746
  "//": "generateFloorDiv",
4746
4747
  "//=": "generateFloorDivAssign",
4747
4748
  "..": "generateRange",
@@ -4802,12 +4803,10 @@ class CodeGenerator {
4802
4803
  yield: "generateYield",
4803
4804
  "yield-from": "generateYieldFrom",
4804
4805
  if: "generateIf",
4805
- unless: "generateIf",
4806
4806
  "for-in": "generateForIn",
4807
4807
  "for-of": "generateForOf",
4808
4808
  "for-as": "generateForAs",
4809
4809
  while: "generateWhile",
4810
- until: "generateUntil",
4811
4810
  try: "generateTry",
4812
4811
  throw: "generateThrow",
4813
4812
  control: "generateControl",
@@ -4883,7 +4882,7 @@ class CodeGenerator {
4883
4882
  continue;
4884
4883
  if (trimmed.startsWith("let ") || trimmed.startsWith("var "))
4885
4884
  continue;
4886
- if (trimmed.startsWith("const slice") || trimmed.startsWith("const modulo") || trimmed.startsWith("const toSearchable"))
4885
+ if (trimmed.startsWith("const slice") || trimmed.startsWith("const modulo") || trimmed.startsWith("const toMatchable"))
4887
4886
  continue;
4888
4887
  if (trimmed.startsWith("const {") && trimmed.includes("__"))
4889
4888
  continue;
@@ -4945,12 +4944,6 @@ class CodeGenerator {
4945
4944
  this.collectProgramVariables(elseBranch);
4946
4945
  return;
4947
4946
  }
4948
- if (head === "unless") {
4949
- let [condition, body] = rest;
4950
- this.collectProgramVariables(condition);
4951
- this.collectProgramVariables(body);
4952
- return;
4953
- }
4954
4947
  if (head === "try") {
4955
4948
  this.collectProgramVariables(rest[0]);
4956
4949
  if (rest.length >= 2 && Array.isArray(rest[1]) && rest[1].length === 2 && rest[1][0] !== "block") {
@@ -5107,7 +5100,7 @@ class CodeGenerator {
5107
5100
  let condCode = this.generate(cond.condition, "value");
5108
5101
  let valCode = this.generate(argWithout, "value");
5109
5102
  let callStr2 = `${callee}(${valCode})`;
5110
- return cond.type === "unless" ? `if (!${condCode}) ${callStr2}` : `if (${condCode}) ${callStr2}`;
5103
+ return `if (${condCode}) ${callStr2}`;
5111
5104
  }
5112
5105
  }
5113
5106
  let needsAwait = headAwaitMeta === true;
@@ -5117,7 +5110,7 @@ class CodeGenerator {
5117
5110
  return needsAwait ? `await ${callStr}` : callStr;
5118
5111
  }
5119
5112
  if (Array.isArray(head) && typeof head[0] === "string") {
5120
- let stmtOps = ["=", "+=", "-=", "*=", "/=", "%=", "**=", "&&=", "||=", "??=", "if", "unless", "return", "throw"];
5113
+ let stmtOps = ["=", "+=", "-=", "*=", "/=", "%=", "**=", "&&=", "||=", "??=", "if", "return", "throw"];
5121
5114
  if (stmtOps.includes(head[0])) {
5122
5115
  let exprs = sexpr.map((stmt) => this.generate(stmt, "value"));
5123
5116
  return `(${exprs.join(", ")})`;
@@ -5139,7 +5132,7 @@ class CodeGenerator {
5139
5132
  let condCode = this.generate(cond.condition, "value");
5140
5133
  let valCode = this.generate(argWithout, "value");
5141
5134
  let callStr2 = `${calleeCode2}(${valCode})`;
5142
- return cond.type === "unless" ? `if (!${condCode}) ${callStr2}` : `if (${condCode}) ${callStr2}`;
5135
+ return `if (${condCode}) ${callStr2}`;
5143
5136
  }
5144
5137
  }
5145
5138
  let needsAwait = false;
@@ -5176,7 +5169,7 @@ class CodeGenerator {
5176
5169
  else
5177
5170
  other.push(stmt);
5178
5171
  }
5179
- let blockStmts = ["def", "class", "if", "unless", "for-in", "for-of", "for-as", "while", "until", "loop", "switch", "try"];
5172
+ let blockStmts = ["def", "class", "if", "for-in", "for-of", "for-as", "while", "loop", "switch", "try"];
5180
5173
  let statementsCode = other.map((stmt, index) => {
5181
5174
  let isSingle = other.length === 1 && imports.length === 0 && exports.length === 0;
5182
5175
  let isObj = this.is(stmt, "object");
@@ -5228,8 +5221,8 @@ class CodeGenerator {
5228
5221
  `;
5229
5222
  needsBlank = true;
5230
5223
  }
5231
- if (this.helpers.has("toSearchable")) {
5232
- code += `const toSearchable = (v, allowNewlines) => {
5224
+ if (this.helpers.has("toMatchable")) {
5225
+ code += `const toMatchable = (v, allowNewlines) => {
5233
5226
  `;
5234
5227
  code += ` if (typeof v === "string") return !allowNewlines && /[\\n\\r]/.test(v) ? null : v;
5235
5228
  `;
@@ -5340,6 +5333,12 @@ function _setDataSection() {
5340
5333
  this.helpers.add("modulo");
5341
5334
  return `modulo(${this.generate(left, "value")}, ${this.generate(right, "value")})`;
5342
5335
  }
5336
+ generateModuloAssign(head, rest) {
5337
+ let [target, value] = rest;
5338
+ this.helpers.add("modulo");
5339
+ let t = this.generate(target, "value"), v = this.generate(value, "value");
5340
+ return `${t} = modulo(${t}, ${v})`;
5341
+ }
5343
5342
  generateFloorDiv(head, rest) {
5344
5343
  let [left, right] = rest;
5345
5344
  return `Math.floor(${this.generate(left, "value")} / ${this.generate(right, "value")})`;
@@ -5423,27 +5422,22 @@ function _setDataSection() {
5423
5422
  }
5424
5423
  if (context === "statement" && head === "=" && Array.isArray(value) && (value[0] === "||" || value[0] === "&&") && value.length === 3) {
5425
5424
  let [binOp, left, right] = value;
5426
- if ((this.is(right, "unless") || this.is(right, "if")) && right.length === 3) {
5427
- let [condType, condition, wrappedValue] = right;
5425
+ if (this.is(right, "if") && right.length === 3) {
5426
+ let [, condition, wrappedValue] = right;
5428
5427
  let unwrapped = Array.isArray(wrappedValue) && wrappedValue.length === 1 ? wrappedValue[0] : wrappedValue;
5429
5428
  let fullValue = [binOp, left, unwrapped];
5430
5429
  let t = this.generate(target, "value"), c = this.generate(condition, "value"), v = this.generate(fullValue, "value");
5431
- return condType === "unless" ? `if (!${c}) ${t} = ${v}` : `if (${c}) ${t} = ${v}`;
5430
+ return `if (${c}) ${t} = ${v}`;
5432
5431
  }
5433
5432
  }
5434
5433
  if (context === "statement" && head === "=" && Array.isArray(value) && value.length === 3) {
5435
5434
  let [valHead, condition, actualValue] = value;
5436
5435
  let isPostfix = Array.isArray(actualValue) && actualValue.length === 1 && (!Array.isArray(actualValue[0]) || actualValue[0][0] !== "block");
5437
- if ((valHead === "unless" || valHead === "if") && isPostfix) {
5436
+ if (valHead === "if" && isPostfix) {
5438
5437
  let unwrapped = Array.isArray(actualValue) && actualValue.length === 1 ? actualValue[0] : actualValue;
5439
5438
  let t = this.generate(target, "value");
5440
5439
  let condCode = this.unwrapLogical(this.generate(condition, "value"));
5441
5440
  let v = this.generate(unwrapped, "value");
5442
- if (valHead === "unless") {
5443
- if (condCode.includes(" ") || /[<>=&|]/.test(condCode))
5444
- condCode = `(${condCode})`;
5445
- return `if (!${condCode}) ${t} = ${v}`;
5446
- }
5447
5441
  return `if (${condCode}) ${t} = ${v}`;
5448
5442
  }
5449
5443
  }
@@ -5491,12 +5485,12 @@ function _setDataSection() {
5491
5485
  }
5492
5486
  generateRegexIndex(head, rest) {
5493
5487
  let [value, regex, captureIndex] = rest;
5494
- this.helpers.add("toSearchable");
5488
+ this.helpers.add("toMatchable");
5495
5489
  this.programVars.add("_");
5496
5490
  let v = this.generate(value, "value"), r = this.generate(regex, "value");
5497
5491
  let idx = captureIndex !== null ? this.generate(captureIndex, "value") : "0";
5498
5492
  let allowNL = r.includes("/m") ? ", true" : "";
5499
- return `(_ = toSearchable(${v}${allowNL}).match(${r})) && _[${idx}]`;
5493
+ return `(_ = toMatchable(${v}${allowNL}).match(${r})) && _[${idx}]`;
5500
5494
  }
5501
5495
  generateIndexAccess(head, rest) {
5502
5496
  let [arr, index] = rest;
@@ -5596,11 +5590,6 @@ function _setDataSection() {
5596
5590
  let [expr] = rest;
5597
5591
  if (this.sideEffectOnly)
5598
5592
  return "return";
5599
- if (this.is(expr, "unless")) {
5600
- let [, condition, body] = expr;
5601
- let val = Array.isArray(body) && body.length === 1 ? body[0] : body;
5602
- return `if (!${this.generate(condition, "value")}) return ${this.generate(val, "value")}`;
5603
- }
5604
5593
  if (this.is(expr, "if")) {
5605
5594
  let [, condition, body, ...elseParts] = expr;
5606
5595
  if (elseParts.length === 0) {
@@ -5608,11 +5597,10 @@ function _setDataSection() {
5608
5597
  return `if (${this.generate(condition, "value")}) return ${this.generate(val, "value")}`;
5609
5598
  }
5610
5599
  }
5611
- if (this.is(expr, "new") && Array.isArray(expr[1]) && expr[1][0] === "unless") {
5612
- let [, unlessNode] = expr;
5613
- let [, condition, body] = unlessNode;
5600
+ if (this.is(expr, "new") && Array.isArray(expr[1]) && expr[1][0] === "if") {
5601
+ let [, condition, body] = expr[1];
5614
5602
  let val = Array.isArray(body) && body.length === 1 ? body[0] : body;
5615
- return `if (!${this.generate(condition, "value")}) return ${this.generate(["new", val], "value")}`;
5603
+ return `if (${this.generate(condition, "value")}) return ${this.generate(["new", val], "value")}`;
5616
5604
  }
5617
5605
  return `return ${this.generate(expr, "value")}`;
5618
5606
  }
@@ -5713,18 +5701,6 @@ ${this.indent()}}`;
5713
5701
  return `yield* ${this.generate(rest[0], "value")}`;
5714
5702
  }
5715
5703
  generateIf(head, rest, context, sexpr) {
5716
- if (head === "unless") {
5717
- let [condition2, body] = rest;
5718
- if (Array.isArray(body) && body.length === 1 && (!Array.isArray(body[0]) || body[0][0] !== "block"))
5719
- body = body[0];
5720
- if (context === "value") {
5721
- return `(!${this.generate(condition2, "value")} ? ${this.extractExpression(body)} : undefined)`;
5722
- }
5723
- let condCode = this.unwrap(this.generate(condition2, "value"));
5724
- if (/[ <>=&|]/.test(condCode))
5725
- condCode = `(${condCode})`;
5726
- return `if (!${condCode}) ` + this.generate(body, "statement");
5727
- }
5728
5704
  let [condition, thenBranch, ...elseBranches] = rest;
5729
5705
  return context === "value" ? this.generateIfAsExpression(condition, thenBranch, elseBranches) : this.generateIfAsStatement(condition, thenBranch, elseBranches);
5730
5706
  }
@@ -5943,10 +5919,6 @@ ${this.indent()}}`;
5943
5919
  let code = `while (${this.unwrap(this.generate(cond, "value"))}) `;
5944
5920
  return code + (guard ? this.generateLoopBodyWithGuard(body, guard) : this.generateLoopBody(body));
5945
5921
  }
5946
- generateUntil(head, rest) {
5947
- let [cond, body] = rest;
5948
- return `while (!(${this.unwrap(this.generate(cond, "value"))})) ` + this.generateLoopBody(body);
5949
- }
5950
5922
  generateRange(head, rest) {
5951
5923
  if (head === "...") {
5952
5924
  if (rest.length === 1)
@@ -6012,11 +5984,11 @@ ${this.indent()}}`;
6012
5984
  }
6013
5985
  generateRegexMatch(head, rest) {
6014
5986
  let [left, right] = rest;
6015
- this.helpers.add("toSearchable");
5987
+ this.helpers.add("toMatchable");
6016
5988
  this.programVars.add("_");
6017
5989
  let r = this.generate(right, "value");
6018
5990
  let allowNL = r.includes("/m") ? ", true" : "";
6019
- return `(_ = toSearchable(${this.generate(left, "value")}${allowNL}).match(${r}))`;
5991
+ return `(_ = toMatchable(${this.generate(left, "value")}${allowNL}).match(${r}))`;
6020
5992
  }
6021
5993
  generateNew(head, rest) {
6022
5994
  let [call] = rest;
@@ -6147,21 +6119,19 @@ ${this.indent()}}`;
6147
6119
  let [expr] = rest;
6148
6120
  if (Array.isArray(expr)) {
6149
6121
  let checkExpr = expr, wrapperType = null;
6150
- if (expr[0] === "new" && Array.isArray(expr[1]) && (expr[1][0] === "if" || expr[1][0] === "unless")) {
6122
+ if (expr[0] === "new" && Array.isArray(expr[1]) && expr[1][0] === "if") {
6151
6123
  wrapperType = "new";
6152
6124
  checkExpr = expr[1];
6153
- } else if (expr[0] === "if" || expr[0] === "unless") {
6125
+ } else if (expr[0] === "if") {
6154
6126
  checkExpr = expr;
6155
6127
  }
6156
- if (checkExpr[0] === "if" || checkExpr[0] === "unless") {
6157
- let [condType, condition, body] = checkExpr;
6128
+ if (checkExpr[0] === "if") {
6129
+ let [, condition, body] = checkExpr;
6158
6130
  let unwrapped = Array.isArray(body) && body.length === 1 ? body[0] : body;
6159
6131
  expr = wrapperType === "new" ? ["new", unwrapped] : unwrapped;
6160
6132
  let condCode = this.generate(condition, "value");
6161
6133
  let throwCode = `throw ${this.generate(expr, "value")}`;
6162
- return condType === "unless" ? `if (!(${condCode})) {
6163
- ${this.indent()} ${throwCode};
6164
- ${this.indent()}}` : `if (${condCode}) {
6134
+ return `if (${condCode}) {
6165
6135
  ${this.indent()} ${throwCode};
6166
6136
  ${this.indent()}}`;
6167
6137
  }
@@ -6332,11 +6302,11 @@ ${this.indent()}}`;
6332
6302
  return false;
6333
6303
  if (["break", "continue", "return", "throw"].includes(node[0]))
6334
6304
  return true;
6335
- if (node[0] === "if" || node[0] === "unless")
6305
+ if (node[0] === "if")
6336
6306
  return node.slice(1).some(hasCtrl);
6337
6307
  return node.some(hasCtrl);
6338
6308
  };
6339
- let loopStmts = ["for-in", "for-of", "for-as", "while", "until", "loop"];
6309
+ let loopStmts = ["for-in", "for-of", "for-as", "while", "loop"];
6340
6310
  if (this.is(expr, "block")) {
6341
6311
  for (let i = 0;i < expr.length - 1; i++) {
6342
6312
  let s = expr[i + 1], isLast = i === expr.length - 2;
@@ -6668,7 +6638,7 @@ export default ${expr[1]}`;
6668
6638
  if (!Array.isArray(expr))
6669
6639
  return null;
6670
6640
  let h = expr[0];
6671
- if ((h === "unless" || h === "if") && expr.length === 3)
6641
+ if (h === "if" && expr.length === 3)
6672
6642
  return { type: h, condition: expr[1], value: expr[2] };
6673
6643
  if (h === "+" || h === "-" || h === "*" || h === "/") {
6674
6644
  for (let i = 1;i < expr.length; i++) {
@@ -6777,7 +6747,7 @@ export default ${expr[1]}`;
6777
6747
  let bodyVars = this.collectFunctionVariables(body);
6778
6748
  let newVars = new Set([...bodyVars].filter((v) => !this.programVars.has(v) && !this.reactiveVars?.has(v) && !paramNames.has(v) && !this.scopeStack.some((s) => s.has(v))));
6779
6749
  let noRetStmts = ["return", "throw", "break", "continue"];
6780
- let loopStmts = ["for-in", "for-of", "for-as", "while", "until", "loop"];
6750
+ let loopStmts = ["for-in", "for-of", "for-as", "while", "loop"];
6781
6751
  this.scopeStack.push(new Set([...newVars, ...paramNames]));
6782
6752
  if (this.is(body, "block")) {
6783
6753
  let statements = this.unwrapBlock(body);
@@ -6819,7 +6789,7 @@ export default ${expr[1]}`;
6819
6789
  `;
6820
6790
  return;
6821
6791
  }
6822
- if (!isConstructor && !sideEffectOnly && isLast && (h === "if" || h === "unless")) {
6792
+ if (!isConstructor && !sideEffectOnly && isLast && h === "if") {
6823
6793
  let [cond, thenB, ...elseB] = stmt.slice(1);
6824
6794
  let hasMulti = (b) => this.is(b, "block") && b.length > 2;
6825
6795
  if (hasMulti(thenB) || elseB.some(hasMulti)) {
@@ -7066,7 +7036,7 @@ ${this.indent()}}`;
7066
7036
  generateIfElseWithEarlyReturns(ifStmt) {
7067
7037
  let [head, condition, thenBranch, ...elseBranches] = ifStmt;
7068
7038
  let code = "";
7069
- let condCode = head === "unless" ? `!${this.generate(condition, "value")}` : this.generate(condition, "value");
7039
+ let condCode = this.generate(condition, "value");
7070
7040
  code += this.indent() + `if (${condCode}) {
7071
7041
  `;
7072
7042
  code += this.withIndent(() => this.generateBranchWithReturn(thenBranch));
@@ -7246,7 +7216,7 @@ ${this.indent()}}`;
7246
7216
  if (!generated.endsWith("}"))
7247
7217
  return true;
7248
7218
  let h = Array.isArray(stmt) ? stmt[0] : null;
7249
- return !["def", "class", "if", "unless", "for-in", "for-of", "for-as", "while", "until", "loop", "switch", "try"].includes(h);
7219
+ return !["def", "class", "if", "for-in", "for-of", "for-as", "while", "loop", "switch", "try"].includes(h);
7250
7220
  }
7251
7221
  addSemicolon(stmt, generated) {
7252
7222
  return generated + (this.needsSemicolon(stmt, generated) ? ";" : "");
@@ -7276,7 +7246,7 @@ ${this.indent()}}`;
7276
7246
  return stmts.some((s) => Array.isArray(s) && ["return", "throw", "break", "continue"].includes(s[0]));
7277
7247
  });
7278
7248
  }
7279
- if (t === "if" || t === "unless") {
7249
+ if (t === "if") {
7280
7250
  let [, , thenB, elseB] = body;
7281
7251
  return this.branchHasControlFlow(thenB) && elseB && this.branchHasControlFlow(elseB);
7282
7252
  }
@@ -7940,8 +7910,8 @@ function getComponentRuntime() {
7940
7910
  return new CodeGenerator({}).getComponentRuntime();
7941
7911
  }
7942
7912
  // src/browser.js
7943
- var VERSION = "3.8.8";
7944
- var BUILD_DATE = "2026-02-16@19:03:24GMT";
7913
+ var VERSION = "3.8.9";
7914
+ var BUILD_DATE = "2026-02-16@20:02:36GMT";
7945
7915
  if (typeof globalThis !== "undefined" && !globalThis.__rip) {
7946
7916
  new Function(getReactiveRuntime())();
7947
7917
  }