rip-lang 3.13.122 → 3.13.124
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/bin/rip +29 -9
- package/docs/dist/rip.js +10 -5
- package/docs/dist/rip.min.js +14 -13
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/compiler.js +5 -2
- package/src/grammar/grammar.rip +1 -1
- package/src/parser.js +1 -1
package/docs/dist/rip.min.js.br
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/compiler.js
CHANGED
|
@@ -2402,8 +2402,9 @@ export class CodeGenerator {
|
|
|
2402
2402
|
if (!isConstructor && !sideEffectOnly && isLast && h === 'if') {
|
|
2403
2403
|
let [cond, thenB, ...elseB] = stmt.slice(1);
|
|
2404
2404
|
let hasMulti = (b) => this.is(b, 'block') && b.length > 2;
|
|
2405
|
-
|
|
2406
|
-
|
|
2405
|
+
let hasCtrlStmt = this.hasStatementInBranch(thenB) || elseB.some(b => this.hasStatementInBranch(b));
|
|
2406
|
+
if (hasCtrlStmt || hasMulti(thenB) || elseB.some(hasMulti)) {
|
|
2407
|
+
code += this.generateIfElseWithEarlyReturns(stmt) + '\n';
|
|
2407
2408
|
return;
|
|
2408
2409
|
}
|
|
2409
2410
|
}
|
|
@@ -2647,6 +2648,7 @@ export class CodeGenerator {
|
|
|
2647
2648
|
}
|
|
2648
2649
|
|
|
2649
2650
|
generateBranchWithReturn(branch) {
|
|
2651
|
+
branch = this.unwrapIfBranch(branch);
|
|
2650
2652
|
let stmts = this.unwrapBlock(branch);
|
|
2651
2653
|
let code = '';
|
|
2652
2654
|
for (let i = 0; i < stmts.length; i++) {
|
|
@@ -2905,6 +2907,7 @@ export class CodeGenerator {
|
|
|
2905
2907
|
|
|
2906
2908
|
hasStatementInBranch(branch) {
|
|
2907
2909
|
if (!Array.isArray(branch)) return false;
|
|
2910
|
+
if (branch.length === 1 && Array.isArray(branch[0])) return this.hasStatementInBranch(branch[0]);
|
|
2908
2911
|
let h = branch[0];
|
|
2909
2912
|
if (h === 'return' || h === 'throw' || h === 'break' || h === 'continue') return true;
|
|
2910
2913
|
if (h === 'block') return branch.slice(1).some(s => this.hasStatementInBranch(s));
|
package/src/grammar/grammar.rip
CHANGED
|
@@ -950,7 +950,7 @@ operators = """
|
|
|
950
950
|
right = : COMPOUND_ASSIGN RIGHTWARD_ASSIGN RETURN THROW EXTENDS
|
|
951
951
|
right FORIN FOROF FORAS FORASAWAIT BY WHEN
|
|
952
952
|
right IF ELSE FOR WHILE UNTIL LOOP SUPER CLASS COMPONENT RENDER IMPORT EXPORT DYNAMIC_IMPORT OFFER ACCEPT
|
|
953
|
-
left POST_IF
|
|
953
|
+
left POST_IF POST_UNLESS
|
|
954
954
|
""".trim().split('\n').reverse().map (line) -> line.trim().split /\s+/
|
|
955
955
|
|
|
956
956
|
# ==============================================================================
|