rip-lang 2.8.0 → 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 +7 -5
- package/docs/dist/rip.browser.min.js +14 -14
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/package.json +1 -1
- package/src/lexer.js +10 -5
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.8.
|
|
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;
|
|
@@ -2029,7 +2030,7 @@ Rewriter = function() {
|
|
|
2029
2030
|
});
|
|
2030
2031
|
return isFunc;
|
|
2031
2032
|
};
|
|
2032
|
-
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 === "=>"))) {
|
|
2033
2034
|
if (tag === "?") {
|
|
2034
2035
|
tag = token[0] = "FUNC_EXIST";
|
|
2035
2036
|
}
|
|
@@ -2125,7 +2126,7 @@ Rewriter = function() {
|
|
|
2125
2126
|
});
|
|
2126
2127
|
}
|
|
2127
2128
|
addImplicitCallCommas() {
|
|
2128
|
-
var callDepth, i, prevTag, tag, tokens;
|
|
2129
|
+
var callDepth, i, prevTag, ref, tag, tokens;
|
|
2129
2130
|
tokens = this.tokens;
|
|
2130
2131
|
callDepth = 0;
|
|
2131
2132
|
i = 0;
|
|
@@ -2137,7 +2138,7 @@ Rewriter = function() {
|
|
|
2137
2138
|
} else if (tag === "CALL_END" || tag === ")") {
|
|
2138
2139
|
callDepth--;
|
|
2139
2140
|
}
|
|
2140
|
-
if (callDepth > 0 && (tag === "->" || tag === "=>") && (
|
|
2141
|
+
if (callDepth > 0 && (tag === "->" || tag === "=>") && (ref = prevTag, indexOf.call(IMPLICIT_COMMA_BEFORE_ARROW, ref) >= 0)) {
|
|
2141
2142
|
tokens.splice(i, 0, generate(",", ",", tokens[i], tokens[i - 1]));
|
|
2142
2143
|
i++;
|
|
2143
2144
|
}
|
|
@@ -2624,6 +2625,7 @@ IMPLICIT_FUNC = ["IDENTIFIER", "PROPERTY", "SUPER", ")", "CALL_END", "]", "INDEX
|
|
|
2624
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", "@", "->", "=>", "[", "(", "{", "--", "++"];
|
|
2625
2626
|
IMPLICIT_UNSPACED_CALL = ["+", "-"];
|
|
2626
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", "]", "}"];
|
|
2627
2629
|
SINGLE_LINERS = ["ELSE", "->", "=>", "TRY", "FINALLY", "THEN"];
|
|
2628
2630
|
SINGLE_CLOSERS = ["TERMINATOR", "CATCH", "FINALLY", "ELSE", "OUTDENT", "LEADING_WHEN"];
|
|
2629
2631
|
LINEBREAKS = ["TERMINATOR", "INDENT", "OUTDENT"];
|
|
@@ -7509,8 +7511,8 @@ function compileToJS(source, options = {}) {
|
|
|
7509
7511
|
return new Compiler(options).compileToJS(source);
|
|
7510
7512
|
}
|
|
7511
7513
|
// src/browser.js
|
|
7512
|
-
var VERSION = "2.8.
|
|
7513
|
-
var BUILD_DATE = "2026-02-04@03:
|
|
7514
|
+
var VERSION = "2.8.1";
|
|
7515
|
+
var BUILD_DATE = "2026-02-04@03:40:08GMT";
|
|
7514
7516
|
var dedent = (s) => {
|
|
7515
7517
|
const m = s.match(/^[ \t]*(?=\S)/gm);
|
|
7516
7518
|
const i = Math.min(...(m || []).map((x) => x.length));
|