rip-lang 2.9.1 → 2.9.2
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/docs/dist/rip.browser.js +2 -33
- package/docs/dist/rip.browser.min.js +87 -87
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/package.json +1 -1
- package/src/grammar/grammar.rip +1 -1
- package/src/grammar/solar.rip +1 -1
- package/src/lexer.js +0 -59
|
Binary file
|
package/package.json
CHANGED
package/src/grammar/grammar.rip
CHANGED
package/src/grammar/solar.rip
CHANGED
|
@@ -105,7 +105,7 @@ class Generator
|
|
|
105
105
|
|
|
106
106
|
dedent: (s, indent) ->
|
|
107
107
|
m = s.match /^[ \t]+(?=\S)/gm
|
|
108
|
-
i = Math.min ...(m
|
|
108
|
+
i = Math.min ...(m ?? []).map (x) => x.length
|
|
109
109
|
s = s.replace(///^[ \t]{#{i}}///gm, '').trim()
|
|
110
110
|
s = s.replace /^/gm, indent if indent
|
|
111
111
|
s
|
package/src/lexer.js
CHANGED
|
@@ -2062,7 +2062,6 @@ Rewriter = (function() {
|
|
|
2062
2062
|
this.closeOpenCalls();
|
|
2063
2063
|
this.closeOpenIndexes();
|
|
2064
2064
|
this.normalizeLines();
|
|
2065
|
-
this.convertLegacyExistential();
|
|
2066
2065
|
this.convertPostfixSpreadRest();
|
|
2067
2066
|
this.tagPostfixConditionals();
|
|
2068
2067
|
this.addImplicitBracesAndParens();
|
|
@@ -3030,64 +3029,6 @@ Rewriter = (function() {
|
|
|
3030
3029
|
});
|
|
3031
3030
|
}
|
|
3032
3031
|
|
|
3033
|
-
// =========================================================================
|
|
3034
|
-
// BACKWARDS COMPATIBILITY / TRANSITION SUPPORT
|
|
3035
|
-
// =========================================================================
|
|
3036
|
-
// Convert legacy CoffeeScript existential operator syntax to Rip's nullish
|
|
3037
|
-
// coalescing operator. In CoffeeScript, "SPACE?" (a question mark with a
|
|
3038
|
-
// space before it, e.g., "x ? y") was used as an existential operator.
|
|
3039
|
-
// Rip uses ES6's "??" for this purpose instead.
|
|
3040
|
-
//
|
|
3041
|
-
// This rewriter converts standalone "SPACE?" tokens (those NOT part of
|
|
3042
|
-
// ternary expressions) into "??" operators to ease migration of old code.
|
|
3043
|
-
//
|
|
3044
|
-
// Examples:
|
|
3045
|
-
// x ? y → x ?? y (legacy existential, converted)
|
|
3046
|
-
// x ? y : z → x ? y : z (ternary, left unchanged)
|
|
3047
|
-
//
|
|
3048
|
-
// NOTE: This is for COMPATIBILITY and TRANSITION purposes only.
|
|
3049
|
-
// New code should use "??" explicitly instead of relying on this conversion.
|
|
3050
|
-
// =========================================================================
|
|
3051
|
-
convertLegacyExistential() {
|
|
3052
|
-
return this.scanTokens(function(token, i, tokens) {
|
|
3053
|
-
var colonFound, j, nestLevel, ref, tag;
|
|
3054
|
-
// Only process SPACE? tokens
|
|
3055
|
-
if (token[0] !== 'SPACE?') {
|
|
3056
|
-
return 1;
|
|
3057
|
-
}
|
|
3058
|
-
// Look ahead to determine if this is part of a ternary expression
|
|
3059
|
-
// A ternary has the pattern: Expression SPACE? Expression : Expression
|
|
3060
|
-
// If we find a ':' at the same nesting level, it's a ternary
|
|
3061
|
-
colonFound = false;
|
|
3062
|
-
nestLevel = 0;
|
|
3063
|
-
for (j = i + 1; j < tokens.length; j++) {
|
|
3064
|
-
tag = tokens[j][0];
|
|
3065
|
-
// Track nesting level (parentheses, brackets, braces)
|
|
3066
|
-
if (ref = tag, indexOf.call(EXPRESSION_START, ref) >= 0) {
|
|
3067
|
-
nestLevel++;
|
|
3068
|
-
} else if (ref = tag, indexOf.call(EXPRESSION_END, ref) >= 0) {
|
|
3069
|
-
nestLevel--;
|
|
3070
|
-
}
|
|
3071
|
-
// Found colon at same level = it's a ternary operator
|
|
3072
|
-
if (tag === ':' && nestLevel === 0) {
|
|
3073
|
-
colonFound = true;
|
|
3074
|
-
break;
|
|
3075
|
-
}
|
|
3076
|
-
// Hit statement boundary without finding colon = not a ternary
|
|
3077
|
-
if (nestLevel === 0 && (tag === 'TERMINATOR' || tag === 'INDENT' || tag === 'OUTDENT')) {
|
|
3078
|
-
break;
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
// No colon found = legacy existential operator, convert to ??
|
|
3082
|
-
if (!colonFound) {
|
|
3083
|
-
token[0] = '??';
|
|
3084
|
-
token[1] = '??';
|
|
3085
|
-
}
|
|
3086
|
-
// Otherwise leave as SPACE? for ternary handling
|
|
3087
|
-
return 1;
|
|
3088
|
-
});
|
|
3089
|
-
}
|
|
3090
|
-
|
|
3091
3032
|
// =========================================================================
|
|
3092
3033
|
// BACKWARDS COMPATIBILITY / TRANSITION SUPPORT
|
|
3093
3034
|
// =========================================================================
|