rip-lang 2.8.3 → 2.8.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/README.md +1 -1
- package/bin/rip +8 -4
- package/docs/dist/rip.browser.js +44 -19
- package/docs/dist/rip.browser.min.js +170 -167
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/package.json +1 -1
- package/src/compiler.js +40 -18
- package/src/grammar/grammar.rip +6 -6
- package/src/parser.js +5 -6
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.4-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/bin/rip
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
3
|
+
import { readFileSync, writeFileSync, existsSync, statSync } from 'fs';
|
|
4
4
|
import { execSync, spawn } from 'child_process';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { dirname, join } from 'path';
|
|
@@ -183,9 +183,13 @@ async function main() {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
// Helper to check if path is a regular file (not a directory)
|
|
187
|
+
const isFile = (path) => existsSync(path) && statSync(path).isFile();
|
|
188
|
+
|
|
186
189
|
// Fallback: Check for bin/ script in git repo root
|
|
187
190
|
// Allows `rip migrate --status` to find and run {repo}/bin/migrate
|
|
188
|
-
if
|
|
191
|
+
// Also triggers if inputFile is a directory (not a compilable file)
|
|
192
|
+
if (inputFile && !inputFile.startsWith('-') && !isFile(inputFile)) {
|
|
189
193
|
try {
|
|
190
194
|
// Check if we're in a git repo
|
|
191
195
|
const repoRoot = execSync('git rev-parse --show-toplevel', {
|
|
@@ -220,8 +224,8 @@ async function main() {
|
|
|
220
224
|
// Read from stdin if no file specified (file descriptor 0)
|
|
221
225
|
source = readFileSync(0, 'utf-8');
|
|
222
226
|
} else {
|
|
223
|
-
// Check if file exists
|
|
224
|
-
if (!
|
|
227
|
+
// Check if file exists and is a regular file
|
|
228
|
+
if (!isFile(inputFile)) {
|
|
225
229
|
console.error(`Error: File not found: ${inputFile}`);
|
|
226
230
|
process.exit(1);
|
|
227
231
|
}
|
package/docs/dist/rip.browser.js
CHANGED
|
@@ -2693,6 +2693,7 @@ var parserInstance = {
|
|
|
2693
2693
|
case 267:
|
|
2694
2694
|
case 281:
|
|
2695
2695
|
case 285:
|
|
2696
|
+
case 289:
|
|
2696
2697
|
case 344:
|
|
2697
2698
|
case 350:
|
|
2698
2699
|
return [$[$0]];
|
|
@@ -2702,6 +2703,7 @@ var parserInstance = {
|
|
|
2702
2703
|
case 213:
|
|
2703
2704
|
case 236:
|
|
2704
2705
|
case 268:
|
|
2706
|
+
case 290:
|
|
2705
2707
|
return [...$[$0 - 2], $[$0]];
|
|
2706
2708
|
case 5:
|
|
2707
2709
|
case 63:
|
|
@@ -2789,7 +2791,6 @@ var parserInstance = {
|
|
|
2789
2791
|
case 273:
|
|
2790
2792
|
case 274:
|
|
2791
2793
|
case 276:
|
|
2792
|
-
case 289:
|
|
2793
2794
|
case 309:
|
|
2794
2795
|
case 342:
|
|
2795
2796
|
case 358:
|
|
@@ -3116,8 +3117,6 @@ var parserInstance = {
|
|
|
3116
3117
|
return [...$[$0 - 5], ...$[$0 - 4], ...$[$0 - 2], ...$[$0 - 1]];
|
|
3117
3118
|
case 284:
|
|
3118
3119
|
return [...$[$0]];
|
|
3119
|
-
case 290:
|
|
3120
|
-
return Array.isArray($[$0 - 2]) ? [...$[$0 - 2], $[$0]] : [$[$0 - 2], $[$0]];
|
|
3121
3120
|
case 291:
|
|
3122
3121
|
return ["try", $[$0]];
|
|
3123
3122
|
case 292:
|
|
@@ -3139,9 +3138,9 @@ var parserInstance = {
|
|
|
3139
3138
|
case 299:
|
|
3140
3139
|
return ["throw", $[$0 - 1]];
|
|
3141
3140
|
case 300:
|
|
3142
|
-
return $[$0 - 1].length === 1 ? $[$0 - 1][0] :
|
|
3141
|
+
return $[$0 - 1].length === 1 ? $[$0 - 1][0] : ["block", ...$[$0 - 1]];
|
|
3143
3142
|
case 301:
|
|
3144
|
-
return $[$0 - 2].length === 1 ? $[$0 - 2][0] :
|
|
3143
|
+
return $[$0 - 2].length === 1 ? $[$0 - 2][0] : ["block", ...$[$0 - 2]];
|
|
3145
3144
|
case 302:
|
|
3146
3145
|
return ["while", $[$0]];
|
|
3147
3146
|
case 303:
|
|
@@ -5205,7 +5204,21 @@ ${stmts.join(`
|
|
|
5205
5204
|
`)}
|
|
5206
5205
|
${this.indent()}}`;
|
|
5207
5206
|
}
|
|
5208
|
-
|
|
5207
|
+
if (statements.length === 0)
|
|
5208
|
+
return "undefined";
|
|
5209
|
+
if (statements.length === 1)
|
|
5210
|
+
return this.generate(statements[0], context);
|
|
5211
|
+
const last = statements[statements.length - 1];
|
|
5212
|
+
const lastIsControl = Array.isArray(last) && ["break", "continue", "return", "throw"].includes(last[0]);
|
|
5213
|
+
if (lastIsControl) {
|
|
5214
|
+
const bodyParts = statements.map((s) => this.addSemicolon(s, this.generate(s, "statement")));
|
|
5215
|
+
return `{
|
|
5216
|
+
${this.withIndent(() => bodyParts.map((p) => this.indent() + p).join(`
|
|
5217
|
+
`))}
|
|
5218
|
+
${this.indent()}}`;
|
|
5219
|
+
}
|
|
5220
|
+
const parts = statements.map((s) => this.generate(s, "value"));
|
|
5221
|
+
return `(${parts.join(", ")})`;
|
|
5209
5222
|
}
|
|
5210
5223
|
generateTry(head, rest, context, sexpr) {
|
|
5211
5224
|
const needsReturns = context === "value";
|
|
@@ -5304,9 +5317,7 @@ ${this.indent()}}`;
|
|
|
5304
5317
|
const normalize = (v) => v instanceof String ? v.valueOf() : v;
|
|
5305
5318
|
for (const whenClause of whens) {
|
|
5306
5319
|
const [, test, body] = whenClause;
|
|
5307
|
-
const
|
|
5308
|
-
const isTestList = Array.isArray(test) && test.length > 0 && typeof firstTest === "string" && !firstTest.match(/^[-+*\/%<>=!&|^~]$|^(typeof|delete|new|not|await|yield)$/);
|
|
5309
|
-
const tests = isTestList ? test : [test];
|
|
5320
|
+
const tests = test;
|
|
5310
5321
|
for (const t of tests) {
|
|
5311
5322
|
const tValue = normalize(t);
|
|
5312
5323
|
let caseValue;
|
|
@@ -6910,18 +6921,31 @@ ${this.indent()}}`;
|
|
|
6910
6921
|
if (typeof code !== "string")
|
|
6911
6922
|
return code;
|
|
6912
6923
|
while (code.startsWith("(") && code.endsWith(")")) {
|
|
6913
|
-
let
|
|
6924
|
+
let parenDepth = 0;
|
|
6925
|
+
let bracketDepth = 0;
|
|
6914
6926
|
let canUnwrap = true;
|
|
6927
|
+
let hasCommaAtDepth1 = false;
|
|
6915
6928
|
for (let i = 0;i < code.length; i++) {
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6929
|
+
const ch = code[i];
|
|
6930
|
+
if (ch === "(")
|
|
6931
|
+
parenDepth++;
|
|
6932
|
+
if (ch === ")")
|
|
6933
|
+
parenDepth--;
|
|
6934
|
+
if (ch === "[" || ch === "{")
|
|
6935
|
+
bracketDepth++;
|
|
6936
|
+
if (ch === "]" || ch === "}")
|
|
6937
|
+
bracketDepth--;
|
|
6938
|
+
if (ch === "," && parenDepth === 1 && bracketDepth === 0) {
|
|
6939
|
+
hasCommaAtDepth1 = true;
|
|
6940
|
+
}
|
|
6941
|
+
if (parenDepth === 0 && i < code.length - 1) {
|
|
6921
6942
|
canUnwrap = false;
|
|
6922
6943
|
break;
|
|
6923
6944
|
}
|
|
6924
6945
|
}
|
|
6946
|
+
if (hasCommaAtDepth1) {
|
|
6947
|
+
canUnwrap = false;
|
|
6948
|
+
}
|
|
6925
6949
|
if (canUnwrap) {
|
|
6926
6950
|
code = code.slice(1, -1);
|
|
6927
6951
|
} else {
|
|
@@ -7147,11 +7171,12 @@ ${this.indent()}}`;
|
|
|
7147
7171
|
for (let i = 0;i < whens.length; i++) {
|
|
7148
7172
|
const whenClause = whens[i];
|
|
7149
7173
|
const [, test, body] = whenClause;
|
|
7174
|
+
const condition = Array.isArray(test) ? test[0] : test;
|
|
7150
7175
|
if (i === 0) {
|
|
7151
|
-
code += `if (${this.generate(
|
|
7176
|
+
code += `if (${this.generate(condition, "value")}) {
|
|
7152
7177
|
`;
|
|
7153
7178
|
} else {
|
|
7154
|
-
code += ` else if (${this.generate(
|
|
7179
|
+
code += ` else if (${this.generate(condition, "value")}) {
|
|
7155
7180
|
`;
|
|
7156
7181
|
}
|
|
7157
7182
|
this.indentLevel++;
|
|
@@ -7534,8 +7559,8 @@ function compileToJS(source, options = {}) {
|
|
|
7534
7559
|
return new Compiler(options).compileToJS(source);
|
|
7535
7560
|
}
|
|
7536
7561
|
// src/browser.js
|
|
7537
|
-
var VERSION = "2.8.
|
|
7538
|
-
var BUILD_DATE = "2026-02-04@
|
|
7562
|
+
var VERSION = "2.8.4";
|
|
7563
|
+
var BUILD_DATE = "2026-02-04@10:18:01GMT";
|
|
7539
7564
|
var dedent = (s) => {
|
|
7540
7565
|
const m = s.match(/^[ \t]*(?=\S)/gm);
|
|
7541
7566
|
const i = Math.min(...(m || []).map((x) => x.length));
|