rip-lang 3.2.0 → 3.3.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/docs/dist/rip.browser.js +43 -42
- package/docs/dist/rip.browser.min.js +45 -45
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/docs/index.html +1574 -2
- package/docs/rip-square.png +0 -0
- package/package.json +1 -1
- package/src/compiler.js +2 -2
- package/src/grammar/solar.rip +55 -136
- package/src/parser.js +38 -37
- package/docs/repl.html +0 -1079
package/docs/dist/rip.browser.js
CHANGED
|
@@ -2977,25 +2977,25 @@ var parserInstance = {
|
|
|
2977
2977
|
}
|
|
2978
2978
|
},
|
|
2979
2979
|
parse(input) {
|
|
2980
|
-
let EOF, TERROR, action, errStr, expected, len, lex, lexer,
|
|
2981
|
-
[stk,
|
|
2982
|
-
[parseTable,
|
|
2980
|
+
let EOF, TERROR, action, errStr, expected, len, lex, lexer, locFirst, locLast, locs, newState, p, parseTable, preErrorSymbol, r, ranges, recovering, rv, sharedState, state, stk, symbol, tokenLen, tokenLine, tokenLoc, tokenText, vals;
|
|
2981
|
+
[stk, vals, locs] = [[0], [null], []];
|
|
2982
|
+
[parseTable, tokenText, tokenLine, tokenLen, recovering] = [this.parseTable, "", 0, 0, 0];
|
|
2983
2983
|
[TERROR, EOF] = [2, 1];
|
|
2984
2984
|
lexer = Object.create(this.lexer);
|
|
2985
|
-
sharedState = {
|
|
2986
|
-
for (const k in this.
|
|
2987
|
-
if (Object.hasOwn(this.
|
|
2988
|
-
const v = this.
|
|
2989
|
-
sharedState.
|
|
2990
|
-
}
|
|
2991
|
-
lexer.setInput(input, sharedState.
|
|
2992
|
-
[sharedState.
|
|
2993
|
-
if (lexer.
|
|
2994
|
-
lexer.
|
|
2995
|
-
|
|
2996
|
-
|
|
2985
|
+
sharedState = { ctx: {} };
|
|
2986
|
+
for (const k in this.ctx)
|
|
2987
|
+
if (Object.hasOwn(this.ctx, k)) {
|
|
2988
|
+
const v = this.ctx[k];
|
|
2989
|
+
sharedState.ctx[k] = v;
|
|
2990
|
+
}
|
|
2991
|
+
lexer.setInput(input, sharedState.ctx);
|
|
2992
|
+
[sharedState.ctx.lexer, sharedState.ctx.parser] = [lexer, this];
|
|
2993
|
+
if (lexer.loc == null)
|
|
2994
|
+
lexer.loc = {};
|
|
2995
|
+
tokenLoc = lexer.loc;
|
|
2996
|
+
locs.push(tokenLoc);
|
|
2997
2997
|
ranges = lexer.options?.ranges;
|
|
2998
|
-
this.parseError = typeof sharedState.
|
|
2998
|
+
this.parseError = typeof sharedState.ctx.parseError === "function" ? sharedState.ctx.parseError : Object.getPrototypeOf(this).parseError;
|
|
2999
2999
|
lex = () => {
|
|
3000
3000
|
let token;
|
|
3001
3001
|
token = lexer.lex() || EOF;
|
|
@@ -3003,7 +3003,8 @@ var parserInstance = {
|
|
|
3003
3003
|
token = this.symbolIds[token] || token;
|
|
3004
3004
|
return token;
|
|
3005
3005
|
};
|
|
3006
|
-
|
|
3006
|
+
symbol = preErrorSymbol = state = action = r = p = len = newState = expected = null;
|
|
3007
|
+
rv = {};
|
|
3007
3008
|
while (true) {
|
|
3008
3009
|
state = stk[stk.length - 1];
|
|
3009
3010
|
if (symbol == null)
|
|
@@ -3024,58 +3025,58 @@ var parserInstance = {
|
|
|
3024
3025
|
})();
|
|
3025
3026
|
errStr = (() => {
|
|
3026
3027
|
if (lexer.showPosition)
|
|
3027
|
-
return `Parse error on line ${
|
|
3028
|
+
return `Parse error on line ${tokenLine + 1}:
|
|
3028
3029
|
${lexer.showPosition()}
|
|
3029
3030
|
Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
3030
3031
|
else {
|
|
3031
|
-
`Parse error on line ${
|
|
3032
|
-
return this.parseError(errStr, { text: lexer.match, token: this.tokenNames[symbol] || symbol, line: lexer.
|
|
3032
|
+
`Parse error on line ${tokenLine + 1}: Unexpected ${symbol === EOF ? "end of input" : `'${this.tokenNames[symbol] || symbol}'`}`;
|
|
3033
|
+
return this.parseError(errStr, { text: lexer.match, token: this.tokenNames[symbol] || symbol, line: lexer.line, loc: tokenLoc, expected });
|
|
3033
3034
|
}
|
|
3034
3035
|
})();
|
|
3035
3036
|
throw Error(errStr);
|
|
3036
3037
|
}
|
|
3037
3038
|
if (action > 0) {
|
|
3038
3039
|
stk.push(symbol, action);
|
|
3039
|
-
|
|
3040
|
-
|
|
3040
|
+
vals.push(lexer.text);
|
|
3041
|
+
locs.push(lexer.loc);
|
|
3041
3042
|
symbol = null;
|
|
3042
3043
|
if (!preErrorSymbol) {
|
|
3043
|
-
[
|
|
3044
|
+
[tokenLen, tokenText, tokenLine, tokenLoc] = [lexer.len, lexer.text, lexer.line, lexer.loc];
|
|
3044
3045
|
if (recovering > 0)
|
|
3045
3046
|
recovering--;
|
|
3046
3047
|
} else
|
|
3047
3048
|
[symbol, preErrorSymbol] = [preErrorSymbol, null];
|
|
3048
3049
|
} else if (action < 0) {
|
|
3049
3050
|
len = this.ruleTable[-action * 2 + 1];
|
|
3050
|
-
|
|
3051
|
-
[locFirst, locLast] = [
|
|
3052
|
-
|
|
3051
|
+
rv.$ = vals[vals.length - len];
|
|
3052
|
+
[locFirst, locLast] = [locs[locs.length - (len || 1)], locs[locs.length - 1]];
|
|
3053
|
+
rv._$ = { first_line: locFirst.first_line, last_line: locLast.last_line, first_column: locFirst.first_column, last_column: locLast.last_column };
|
|
3053
3054
|
if (ranges)
|
|
3054
|
-
|
|
3055
|
-
r = this.ruleActions.
|
|
3055
|
+
rv._$.range = [locFirst.range[0], locLast.range[1]];
|
|
3056
|
+
r = this.ruleActions.call(rv, -action, vals, locs, sharedState.ctx);
|
|
3056
3057
|
if (r != null)
|
|
3057
|
-
|
|
3058
|
+
rv.$ = r;
|
|
3058
3059
|
if (len) {
|
|
3059
3060
|
stk.length -= len * 2;
|
|
3060
|
-
|
|
3061
|
-
|
|
3061
|
+
vals.length -= len;
|
|
3062
|
+
locs.length -= len;
|
|
3062
3063
|
}
|
|
3063
3064
|
stk.push(this.ruleTable[-action * 2]);
|
|
3064
|
-
|
|
3065
|
-
|
|
3065
|
+
vals.push(rv.$);
|
|
3066
|
+
locs.push(rv._$);
|
|
3066
3067
|
newState = parseTable[stk[stk.length - 2]][stk[stk.length - 1]];
|
|
3067
3068
|
stk.push(newState);
|
|
3068
3069
|
} else if (action === 0)
|
|
3069
|
-
return
|
|
3070
|
+
return vals[vals.length - 1];
|
|
3070
3071
|
}
|
|
3071
3072
|
},
|
|
3072
3073
|
trace() {},
|
|
3073
|
-
|
|
3074
|
+
ctx: {}
|
|
3074
3075
|
};
|
|
3075
|
-
var createParser = (
|
|
3076
|
+
var createParser = (init = {}) => {
|
|
3076
3077
|
const p = Object.create(parserInstance);
|
|
3077
|
-
Object.defineProperty(p, "
|
|
3078
|
-
value: { ...
|
|
3078
|
+
Object.defineProperty(p, "ctx", {
|
|
3079
|
+
value: { ...init },
|
|
3079
3080
|
enumerable: false,
|
|
3080
3081
|
writable: true,
|
|
3081
3082
|
configurable: true
|
|
@@ -7334,8 +7335,8 @@ class Compiler {
|
|
|
7334
7335
|
val = new String(val);
|
|
7335
7336
|
Object.assign(val, token.data);
|
|
7336
7337
|
}
|
|
7337
|
-
this.
|
|
7338
|
-
this.
|
|
7338
|
+
this.text = val;
|
|
7339
|
+
this.loc = token.loc;
|
|
7339
7340
|
return token[0];
|
|
7340
7341
|
}
|
|
7341
7342
|
};
|
|
@@ -7383,8 +7384,8 @@ function getComponentRuntime() {
|
|
|
7383
7384
|
return new CodeGenerator({}).getComponentRuntime();
|
|
7384
7385
|
}
|
|
7385
7386
|
// src/browser.js
|
|
7386
|
-
var VERSION = "3.
|
|
7387
|
-
var BUILD_DATE = "2026-02-
|
|
7387
|
+
var VERSION = "3.3.0";
|
|
7388
|
+
var BUILD_DATE = "2026-02-09@04:28:55GMT";
|
|
7388
7389
|
var dedent = (s) => {
|
|
7389
7390
|
const m = s.match(/^[ \t]*(?=\S)/gm);
|
|
7390
7391
|
const i = Math.min(...(m || []).map((x) => x.length));
|