rip-lang 2.7.2 → 2.8.0
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 +30 -0
- package/docs/WHY-YES-RIP.md +4 -4
- package/docs/dist/rip.browser.js +23 -2
- package/docs/dist/rip.browser.min.js +82 -82
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/package.json +1 -1
- package/src/lexer.js +27 -0
|
Binary file
|
package/package.json
CHANGED
package/src/lexer.js
CHANGED
|
@@ -2061,6 +2061,7 @@ Rewriter = (function() {
|
|
|
2061
2061
|
this.convertPostfixSpreadRest();
|
|
2062
2062
|
this.tagPostfixConditionals();
|
|
2063
2063
|
this.addImplicitBracesAndParens();
|
|
2064
|
+
this.addImplicitCallCommas();
|
|
2064
2065
|
this.rescueStowawayComments();
|
|
2065
2066
|
this.addLocationDataToGeneratedTokens();
|
|
2066
2067
|
this.fixIndentationLocationData();
|
|
@@ -2589,6 +2590,32 @@ Rewriter = (function() {
|
|
|
2589
2590
|
});
|
|
2590
2591
|
}
|
|
2591
2592
|
|
|
2593
|
+
// Insert commas before arrow functions in implicit calls.
|
|
2594
|
+
// Allows: get '/users' -> ... instead of: get '/users', -> ...
|
|
2595
|
+
addImplicitCallCommas() {
|
|
2596
|
+
var callDepth, i, prevTag, tag, tokens;
|
|
2597
|
+
tokens = this.tokens;
|
|
2598
|
+
callDepth = 0;
|
|
2599
|
+
i = 0;
|
|
2600
|
+
while (i < tokens.length) {
|
|
2601
|
+
tag = tokens[i][0];
|
|
2602
|
+
prevTag = i > 0 ? tokens[i - 1][0] : null;
|
|
2603
|
+
// Track call depth
|
|
2604
|
+
if (tag === 'CALL_START' || tag === '(') {
|
|
2605
|
+
callDepth++;
|
|
2606
|
+
} else if (tag === 'CALL_END' || tag === ')') {
|
|
2607
|
+
callDepth--;
|
|
2608
|
+
}
|
|
2609
|
+
// Inside a call, if we see -> or => preceded by STRING, insert comma
|
|
2610
|
+
if (callDepth > 0 && (tag === '->' || tag === '=>') &&
|
|
2611
|
+
(prevTag === 'STRING' || prevTag === 'STRING_END')) {
|
|
2612
|
+
tokens.splice(i, 0, generate(',', ',', tokens[i], tokens[i - 1]));
|
|
2613
|
+
i++; // Skip past the inserted comma
|
|
2614
|
+
}
|
|
2615
|
+
i++;
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2592
2619
|
// Not all tokens survive processing by the parser. To avoid comments getting
|
|
2593
2620
|
// lost into the ether, find comments attached to doomed tokens and move them
|
|
2594
2621
|
// to a token that will make it to the other side.
|