rip-lang 2.8.1 → 2.8.2
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/README.md +1 -1
- package/docs/dist/rip.browser.js +26 -26
- package/docs/dist/rip.browser.min.js +3 -3
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/package.json +1 -1
- package/src/compiler.js +1 -1
- package/src/lexer.js +2 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-2.8.
|
|
12
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-2.8.2-blue.svg" alt="Version"></a>
|
|
13
13
|
<a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
|
|
14
14
|
<a href="#"><img src="https://img.shields.io/badge/tests-1021%2F1021-brightgreen.svg" alt="Tests"></a>
|
|
15
15
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
|
package/docs/dist/rip.browser.js
CHANGED
|
@@ -2624,7 +2624,7 @@ EXPRESSION_CLOSE = ["CATCH", "THEN", "ELSE", "FINALLY"].concat(EXPRESSION_END);
|
|
|
2624
2624
|
IMPLICIT_FUNC = ["IDENTIFIER", "PROPERTY", "SUPER", ")", "CALL_END", "]", "INDEX_END", "@", "THIS"];
|
|
2625
2625
|
IMPLICIT_CALL = ["IDENTIFIER", "PROPERTY", "NUMBER", "INFINITY", "NAN", "STRING", "STRING_START", "REGEX", "REGEX_START", "JS", "NEW", "PARAM_START", "CLASS", "IF", "TRY", "SWITCH", "THIS", "DYNAMIC_IMPORT", "IMPORT_META", "NEW_TARGET", "UNDEFINED", "NULL", "BOOL", "UNARY", "DO", "DO_IIFE", "YIELD", "AWAIT", "UNARY_MATH", "SUPER", "THROW", "@", "->", "=>", "[", "(", "{", "--", "++"];
|
|
2626
2626
|
IMPLICIT_UNSPACED_CALL = ["+", "-"];
|
|
2627
|
-
IMPLICIT_END = ["POST_IF", "FOR", "WHILE", "UNTIL", "WHEN", "BY", "LOOP", "TERMINATOR"];
|
|
2627
|
+
IMPLICIT_END = ["POST_IF", "FOR", "WHILE", "UNTIL", "WHEN", "BY", "LOOP", "TERMINATOR", "||", "&&"];
|
|
2628
2628
|
IMPLICIT_COMMA_BEFORE_ARROW = ["STRING", "STRING_END", "REGEX", "REGEX_END", "NUMBER", "BOOL", "NULL", "UNDEFINED", "INFINITY", "NAN", "]", "}"];
|
|
2629
2629
|
SINGLE_LINERS = ["ELSE", "->", "=>", "TRY", "FINALLY", "THEN"];
|
|
2630
2630
|
SINGLE_CLOSERS = ["TERMINATOR", "CATCH", "FINALLY", "ELSE", "OUTDENT", "LEADING_WHEN"];
|
|
@@ -4648,27 +4648,27 @@ ${this.indent()}}`;
|
|
|
4648
4648
|
}
|
|
4649
4649
|
if (step && step !== null) {
|
|
4650
4650
|
const iterableCode = this.generate(iterable, "value");
|
|
4651
|
-
const
|
|
4651
|
+
const indexVarName = indexVar || "_i";
|
|
4652
4652
|
const stepCode = this.generate(step, "value");
|
|
4653
4653
|
const isNegativeStep = this.isNegativeStep(step);
|
|
4654
4654
|
const isMinusOne = isNegativeStep && (step[1] === "1" || step[1] === 1 || step[1] instanceof String && step[1].valueOf() === "1");
|
|
4655
4655
|
const isPlusOne = !isNegativeStep && (step === "1" || step === 1 || step instanceof String && step.valueOf() === "1");
|
|
4656
4656
|
let loopHeader;
|
|
4657
4657
|
if (isMinusOne) {
|
|
4658
|
-
loopHeader = `for (let ${
|
|
4658
|
+
loopHeader = `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName}--) `;
|
|
4659
4659
|
} else if (isPlusOne) {
|
|
4660
|
-
loopHeader = `for (let ${
|
|
4660
|
+
loopHeader = `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName}++) `;
|
|
4661
4661
|
} else if (isNegativeStep) {
|
|
4662
|
-
loopHeader = `for (let ${
|
|
4662
|
+
loopHeader = `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) `;
|
|
4663
4663
|
} else {
|
|
4664
|
-
loopHeader = `for (let ${
|
|
4664
|
+
loopHeader = `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) `;
|
|
4665
4665
|
}
|
|
4666
4666
|
if (Array.isArray(body) && body[0] === "block") {
|
|
4667
4667
|
const statements = body.slice(1);
|
|
4668
4668
|
this.indentLevel++;
|
|
4669
4669
|
const stmts = [];
|
|
4670
4670
|
if (!noVar) {
|
|
4671
|
-
stmts.push(`const ${itemVarPattern} = ${iterableCode}[${
|
|
4671
|
+
stmts.push(`const ${itemVarPattern} = ${iterableCode}[${indexVarName}];`);
|
|
4672
4672
|
}
|
|
4673
4673
|
if (guard) {
|
|
4674
4674
|
const guardCode = this.generate(guard, "value");
|
|
@@ -4696,9 +4696,9 @@ ${this.indent()}}`;
|
|
|
4696
4696
|
} else {
|
|
4697
4697
|
if (guard) {
|
|
4698
4698
|
const guardCode = this.generate(guard, "value");
|
|
4699
|
-
return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${
|
|
4699
|
+
return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${indexVarName}]; if (${guardCode}) ${this.generate(body, "statement")}; }`;
|
|
4700
4700
|
} else {
|
|
4701
|
-
return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${
|
|
4701
|
+
return loopHeader + `{ const ${itemVarPattern} = ${iterableCode}[${indexVarName}]; ${this.generate(body, "statement")}; }`;
|
|
4702
4702
|
}
|
|
4703
4703
|
}
|
|
4704
4704
|
}
|
|
@@ -5366,19 +5366,19 @@ ${this.indent()}}`;
|
|
|
5366
5366
|
this.indentLevel++;
|
|
5367
5367
|
} else {
|
|
5368
5368
|
const iterableCode = this.generate(iterable, "value");
|
|
5369
|
-
const
|
|
5369
|
+
const indexVarName = indexVar || "_i";
|
|
5370
5370
|
const stepCode = this.generate(step, "value");
|
|
5371
5371
|
const isNegativeStep = this.isNegativeStep(step);
|
|
5372
5372
|
if (isNegativeStep) {
|
|
5373
|
-
code += this.indent() + `for (let ${
|
|
5373
|
+
code += this.indent() + `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) {
|
|
5374
5374
|
`;
|
|
5375
5375
|
} else {
|
|
5376
|
-
code += this.indent() + `for (let ${
|
|
5376
|
+
code += this.indent() + `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) {
|
|
5377
5377
|
`;
|
|
5378
5378
|
}
|
|
5379
5379
|
this.indentLevel++;
|
|
5380
5380
|
if (!noVar) {
|
|
5381
|
-
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${
|
|
5381
|
+
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName}];
|
|
5382
5382
|
`;
|
|
5383
5383
|
}
|
|
5384
5384
|
}
|
|
@@ -6574,19 +6574,19 @@ ${this.indent()}}`;
|
|
|
6574
6574
|
`;
|
|
6575
6575
|
} else {
|
|
6576
6576
|
const iterableCode = this.generate(iterable, "value");
|
|
6577
|
-
const
|
|
6577
|
+
const indexVarName = indexVar || "_i";
|
|
6578
6578
|
const stepCode = this.generate(step, "value");
|
|
6579
6579
|
const isNegativeStep = this.isNegativeStep(step);
|
|
6580
6580
|
if (isNegativeStep) {
|
|
6581
|
-
code += this.indent() + `for (let ${
|
|
6581
|
+
code += this.indent() + `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) {
|
|
6582
6582
|
`;
|
|
6583
6583
|
} else {
|
|
6584
|
-
code += this.indent() + `for (let ${
|
|
6584
|
+
code += this.indent() + `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) {
|
|
6585
6585
|
`;
|
|
6586
6586
|
}
|
|
6587
6587
|
this.indentLevel++;
|
|
6588
6588
|
if (!noVar) {
|
|
6589
|
-
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${
|
|
6589
|
+
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName}];
|
|
6590
6590
|
`;
|
|
6591
6591
|
}
|
|
6592
6592
|
}
|
|
@@ -6650,25 +6650,25 @@ ${this.indent()}}`;
|
|
|
6650
6650
|
code += `for (let ${itemVarPattern} = ${startCode}; ${itemVarPattern} ${comparison} ${endCode}; ${itemVarPattern} += ${stepCode}) `;
|
|
6651
6651
|
} else {
|
|
6652
6652
|
const iterableCode = this.generate(iterable, "value");
|
|
6653
|
-
const
|
|
6653
|
+
const indexVarName = indexVar || "_i";
|
|
6654
6654
|
const stepCode = this.generate(step, "value");
|
|
6655
6655
|
const isNegativeStep = this.isNegativeStep(step);
|
|
6656
6656
|
const isMinusOne = isNegativeStep && (step[1] === "1" || step[1] === 1 || step[1] instanceof String && step[1].valueOf() === "1");
|
|
6657
6657
|
const isPlusOne = !isNegativeStep && (step === "1" || step === 1 || step instanceof String && step.valueOf() === "1");
|
|
6658
6658
|
if (isMinusOne) {
|
|
6659
|
-
code += `for (let ${
|
|
6659
|
+
code += `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName}--) `;
|
|
6660
6660
|
} else if (isPlusOne) {
|
|
6661
|
-
code += `for (let ${
|
|
6661
|
+
code += `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName}++) `;
|
|
6662
6662
|
} else if (isNegativeStep) {
|
|
6663
|
-
code += `for (let ${
|
|
6663
|
+
code += `for (let ${indexVarName} = ${iterableCode}.length - 1; ${indexVarName} >= 0; ${indexVarName} += ${stepCode}) `;
|
|
6664
6664
|
} else {
|
|
6665
|
-
code += `for (let ${
|
|
6665
|
+
code += `for (let ${indexVarName} = 0; ${indexVarName} < ${iterableCode}.length; ${indexVarName} += ${stepCode}) `;
|
|
6666
6666
|
}
|
|
6667
6667
|
code += `{
|
|
6668
6668
|
`;
|
|
6669
6669
|
this.indentLevel++;
|
|
6670
6670
|
if (!noVar) {
|
|
6671
|
-
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${
|
|
6671
|
+
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVarName}];
|
|
6672
6672
|
`;
|
|
6673
6673
|
}
|
|
6674
6674
|
}
|
|
@@ -6711,7 +6711,7 @@ ${this.indent()}}`;
|
|
|
6711
6711
|
code += `{
|
|
6712
6712
|
`;
|
|
6713
6713
|
this.indentLevel++;
|
|
6714
|
-
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${
|
|
6714
|
+
code += this.indent() + `const ${itemVarPattern} = ${iterableCode}[${indexVar}];
|
|
6715
6715
|
`;
|
|
6716
6716
|
} else {
|
|
6717
6717
|
code += `for (const ${itemVarPattern} of ${this.generate(iterable, "value")}) `;
|
|
@@ -7511,8 +7511,8 @@ function compileToJS(source, options = {}) {
|
|
|
7511
7511
|
return new Compiler(options).compileToJS(source);
|
|
7512
7512
|
}
|
|
7513
7513
|
// src/browser.js
|
|
7514
|
-
var VERSION = "2.8.
|
|
7515
|
-
var BUILD_DATE = "2026-02-04@
|
|
7514
|
+
var VERSION = "2.8.2";
|
|
7515
|
+
var BUILD_DATE = "2026-02-04@07:57:52GMT";
|
|
7516
7516
|
var dedent = (s) => {
|
|
7517
7517
|
const m = s.match(/^[ \t]*(?=\S)/gm);
|
|
7518
7518
|
const i = Math.min(...(m || []).map((x) => x.length));
|