rip-lang 2.7.3 → 2.8.1
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 +25 -3
- package/docs/dist/rip.browser.js +26 -3
- package/docs/dist/rip.browser.min.js +84 -84
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/package.json +1 -1
- package/src/lexer.js +34 -2
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-2.
|
|
12
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-2.8.1-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
|
-
<a href="#"><img src="https://img.shields.io/badge/tests-
|
|
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>
|
|
16
16
|
</p>
|
|
17
17
|
|
|
@@ -231,6 +231,28 @@ bun add @rip-lang/api @rip-lang/server
|
|
|
231
231
|
|
|
232
232
|
---
|
|
233
233
|
|
|
234
|
+
## Implicit Commas
|
|
235
|
+
|
|
236
|
+
Rip rescues what would be invalid syntax and gives it elegant meaning. When a literal value is followed directly by an arrow function, Rip inserts the comma for you:
|
|
237
|
+
|
|
238
|
+
```coffee
|
|
239
|
+
# Clean route handlers (no comma needed!)
|
|
240
|
+
get '/users' -> User.all!
|
|
241
|
+
get '/users/:id' -> User.find params.id
|
|
242
|
+
post '/users' -> User.create body
|
|
243
|
+
|
|
244
|
+
# Works with all literal types
|
|
245
|
+
handle 404 -> { error: 'Not found' }
|
|
246
|
+
match /^\/api/ -> { version: 'v1' }
|
|
247
|
+
check true -> enable()
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
This works because `'/users' ->` was previously a syntax error — there's no valid interpretation. Rip detects this pattern and transforms it into `'/users', ->`, giving dead syntax a beautiful new life.
|
|
251
|
+
|
|
252
|
+
**Supported literals:** strings, numbers, regex, booleans, null, undefined, arrays, objects
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
234
256
|
## Quick Reference
|
|
235
257
|
|
|
236
258
|
```bash
|
|
@@ -239,7 +261,7 @@ rip file.rip # Run
|
|
|
239
261
|
rip -c file.rip # Compile
|
|
240
262
|
rip -t file.rip # Tokens
|
|
241
263
|
rip -s file.rip # S-expressions
|
|
242
|
-
bun run test #
|
|
264
|
+
bun run test # 1021 tests
|
|
243
265
|
bun run parser # Rebuild parser
|
|
244
266
|
bun run browser # Build browser bundle
|
|
245
267
|
```
|
package/docs/dist/rip.browser.js
CHANGED
|
@@ -23,6 +23,7 @@ var HEREGEX_COMMENT;
|
|
|
23
23
|
var HERE_JSTOKEN;
|
|
24
24
|
var IDENTIFIER;
|
|
25
25
|
var IMPLICIT_CALL;
|
|
26
|
+
var IMPLICIT_COMMA_BEFORE_ARROW;
|
|
26
27
|
var IMPLICIT_END;
|
|
27
28
|
var IMPLICIT_FUNC;
|
|
28
29
|
var IMPLICIT_UNSPACED_CALL;
|
|
@@ -1712,6 +1713,7 @@ Rewriter = function() {
|
|
|
1712
1713
|
this.convertPostfixSpreadRest();
|
|
1713
1714
|
this.tagPostfixConditionals();
|
|
1714
1715
|
this.addImplicitBracesAndParens();
|
|
1716
|
+
this.addImplicitCallCommas();
|
|
1715
1717
|
this.rescueStowawayComments();
|
|
1716
1718
|
this.addLocationDataToGeneratedTokens();
|
|
1717
1719
|
this.fixIndentationLocationData();
|
|
@@ -2028,7 +2030,7 @@ Rewriter = function() {
|
|
|
2028
2030
|
});
|
|
2029
2031
|
return isFunc;
|
|
2030
2032
|
};
|
|
2031
|
-
if ((indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced || tag === "?" && i > 0 && !tokens[i - 1].spaced) && (indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || nextTag === "..." && (ref = this.tag(i + 2), indexOf.call(IMPLICIT_CALL, ref) >= 0) && !this.findTagsBackwards(i, ["INDEX_START", "["]) || indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !nextToken.spaced && !nextToken.newLine) && !inControlFlow()) {
|
|
2033
|
+
if ((indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced || tag === "?" && i > 0 && !tokens[i - 1].spaced) && (indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || nextTag === "..." && (ref = this.tag(i + 2), indexOf.call(IMPLICIT_CALL, ref) >= 0) && !this.findTagsBackwards(i, ["INDEX_START", "["]) || indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !nextToken.spaced && !nextToken.newLine) && !inControlFlow() && !((tag === "]" || tag === "}") && (nextTag === "->" || nextTag === "=>"))) {
|
|
2032
2034
|
if (tag === "?") {
|
|
2033
2035
|
tag = token[0] = "FUNC_EXIST";
|
|
2034
2036
|
}
|
|
@@ -2123,6 +2125,26 @@ Rewriter = function() {
|
|
|
2123
2125
|
return forward(1);
|
|
2124
2126
|
});
|
|
2125
2127
|
}
|
|
2128
|
+
addImplicitCallCommas() {
|
|
2129
|
+
var callDepth, i, prevTag, ref, tag, tokens;
|
|
2130
|
+
tokens = this.tokens;
|
|
2131
|
+
callDepth = 0;
|
|
2132
|
+
i = 0;
|
|
2133
|
+
while (i < tokens.length) {
|
|
2134
|
+
tag = tokens[i][0];
|
|
2135
|
+
prevTag = i > 0 ? tokens[i - 1][0] : null;
|
|
2136
|
+
if (tag === "CALL_START" || tag === "(") {
|
|
2137
|
+
callDepth++;
|
|
2138
|
+
} else if (tag === "CALL_END" || tag === ")") {
|
|
2139
|
+
callDepth--;
|
|
2140
|
+
}
|
|
2141
|
+
if (callDepth > 0 && (tag === "->" || tag === "=>") && (ref = prevTag, indexOf.call(IMPLICIT_COMMA_BEFORE_ARROW, ref) >= 0)) {
|
|
2142
|
+
tokens.splice(i, 0, generate(",", ",", tokens[i], tokens[i - 1]));
|
|
2143
|
+
i++;
|
|
2144
|
+
}
|
|
2145
|
+
i++;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2126
2148
|
rescueStowawayComments() {
|
|
2127
2149
|
var dontShiftForward, insertPlaceholder, shiftCommentsBackward, shiftCommentsForward;
|
|
2128
2150
|
insertPlaceholder = function(token, j, tokens, method) {
|
|
@@ -2603,6 +2625,7 @@ IMPLICIT_FUNC = ["IDENTIFIER", "PROPERTY", "SUPER", ")", "CALL_END", "]", "INDEX
|
|
|
2603
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", "@", "->", "=>", "[", "(", "{", "--", "++"];
|
|
2604
2626
|
IMPLICIT_UNSPACED_CALL = ["+", "-"];
|
|
2605
2627
|
IMPLICIT_END = ["POST_IF", "FOR", "WHILE", "UNTIL", "WHEN", "BY", "LOOP", "TERMINATOR"];
|
|
2628
|
+
IMPLICIT_COMMA_BEFORE_ARROW = ["STRING", "STRING_END", "REGEX", "REGEX_END", "NUMBER", "BOOL", "NULL", "UNDEFINED", "INFINITY", "NAN", "]", "}"];
|
|
2606
2629
|
SINGLE_LINERS = ["ELSE", "->", "=>", "TRY", "FINALLY", "THEN"];
|
|
2607
2630
|
SINGLE_CLOSERS = ["TERMINATOR", "CATCH", "FINALLY", "ELSE", "OUTDENT", "LEADING_WHEN"];
|
|
2608
2631
|
LINEBREAKS = ["TERMINATOR", "INDENT", "OUTDENT"];
|
|
@@ -7488,8 +7511,8 @@ function compileToJS(source, options = {}) {
|
|
|
7488
7511
|
return new Compiler(options).compileToJS(source);
|
|
7489
7512
|
}
|
|
7490
7513
|
// src/browser.js
|
|
7491
|
-
var VERSION = "2.
|
|
7492
|
-
var BUILD_DATE = "2026-02-03
|
|
7514
|
+
var VERSION = "2.8.1";
|
|
7515
|
+
var BUILD_DATE = "2026-02-04@03:40:08GMT";
|
|
7493
7516
|
var dedent = (s) => {
|
|
7494
7517
|
const m = s.match(/^[ \t]*(?=\S)/gm);
|
|
7495
7518
|
const i = Math.min(...(m || []).map((x) => x.length));
|