subscript 10.1.5 → 10.1.6
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/feature/control.js +2 -1
- package/feature/function.js +1 -1
- package/feature/loop.js +39 -26
- package/feature/op/arrow.js +1 -1
- package/feature/switch.js +1 -1
- package/feature/try.js +1 -1
- package/jessie.min.js +7 -7
- package/justin.min.js +5 -5
- package/package.json +1 -1
package/feature/control.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
// Control flow symbols (shared by loop, group, switch, try, function)
|
|
2
|
-
|
|
2
|
+
// RETURN is array to hold value - reused, no allocation per throw
|
|
3
|
+
export const BREAK = Symbol('break'), CONTINUE = Symbol('continue'), RETURN = [];
|
package/feature/function.js
CHANGED
|
@@ -44,7 +44,7 @@ operator('function', (name, params, body) => {
|
|
|
44
44
|
has: (l, k) => k in l || k in ctx
|
|
45
45
|
});
|
|
46
46
|
try { return body(fnCtx); }
|
|
47
|
-
catch (e) { if (e
|
|
47
|
+
catch (e) { if (e === RETURN) return e[0]; throw e; }
|
|
48
48
|
};
|
|
49
49
|
if (name) ctx[name] = fn;
|
|
50
50
|
return fn;
|
package/feature/loop.js
CHANGED
|
@@ -6,17 +6,6 @@ import { BREAK, CONTINUE, RETURN } from './control.js';
|
|
|
6
6
|
|
|
7
7
|
export { BREAK, CONTINUE, RETURN };
|
|
8
8
|
|
|
9
|
-
// Loop body executor - catches control flow and returns status
|
|
10
|
-
export const loop = (body, ctx) => {
|
|
11
|
-
try { return { v: body(ctx) }; }
|
|
12
|
-
catch (e) {
|
|
13
|
-
if (e?.type === BREAK) return { b: 1 };
|
|
14
|
-
if (e?.type === CONTINUE) return { c: 1 };
|
|
15
|
-
if (e?.type === RETURN) return { r: 1, v: e.value };
|
|
16
|
-
throw e;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
9
|
const STATEMENT = 5, CBRACE = 125, SEMI = 59;
|
|
21
10
|
|
|
22
11
|
keyword('while', STATEMENT + 1, () => (space(), ['while', parens(), body()]));
|
|
@@ -71,12 +60,17 @@ keyword('return', STATEMENT + 1, () => {
|
|
|
71
60
|
return !c || c === CBRACE || c === SEMI || parse.newline ? ['return'] : ['return', expr(STATEMENT)];
|
|
72
61
|
});
|
|
73
62
|
|
|
74
|
-
// Compile
|
|
63
|
+
// Compile - inline try/catch, use JS break/continue directly
|
|
75
64
|
operator('while', (cond, body) => {
|
|
76
65
|
cond = compile(cond); body = compile(body);
|
|
77
66
|
return ctx => {
|
|
78
|
-
let
|
|
79
|
-
while (cond(ctx))
|
|
67
|
+
let res;
|
|
68
|
+
while (cond(ctx)) try { res = body(ctx); } catch (e) {
|
|
69
|
+
if (e === BREAK) break;
|
|
70
|
+
if (e === CONTINUE) continue;
|
|
71
|
+
if (e === RETURN) return e[0];
|
|
72
|
+
throw e;
|
|
73
|
+
}
|
|
80
74
|
return res;
|
|
81
75
|
};
|
|
82
76
|
});
|
|
@@ -84,8 +78,13 @@ operator('while', (cond, body) => {
|
|
|
84
78
|
operator('do', (body, cond) => {
|
|
85
79
|
body = compile(body); cond = compile(cond);
|
|
86
80
|
return ctx => {
|
|
87
|
-
let
|
|
88
|
-
do {
|
|
81
|
+
let res;
|
|
82
|
+
do try { res = body(ctx); } catch (e) {
|
|
83
|
+
if (e === BREAK) break;
|
|
84
|
+
if (e === CONTINUE) continue;
|
|
85
|
+
if (e === RETURN) return e[0];
|
|
86
|
+
throw e;
|
|
87
|
+
} while (cond(ctx));
|
|
89
88
|
return res;
|
|
90
89
|
};
|
|
91
90
|
});
|
|
@@ -99,9 +98,13 @@ operator('for', (head, body) => {
|
|
|
99
98
|
step = step ? compile(step) : null;
|
|
100
99
|
body = compile(body);
|
|
101
100
|
return ctx => {
|
|
102
|
-
let
|
|
103
|
-
for (init?.(ctx); cond(ctx); step?.(ctx))
|
|
104
|
-
if (
|
|
101
|
+
let res;
|
|
102
|
+
for (init?.(ctx); cond(ctx); step?.(ctx)) try { res = body(ctx); } catch (e) {
|
|
103
|
+
if (e === BREAK) break;
|
|
104
|
+
if (e === CONTINUE) continue;
|
|
105
|
+
if (e === RETURN) return e[0];
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
105
108
|
return res;
|
|
106
109
|
};
|
|
107
110
|
}
|
|
@@ -119,11 +122,16 @@ const forOf = (name, iterable, body) => {
|
|
|
119
122
|
iterable = compile(iterable); body = compile(body);
|
|
120
123
|
const isPattern = Array.isArray(name);
|
|
121
124
|
return ctx => {
|
|
122
|
-
let
|
|
125
|
+
let res;
|
|
123
126
|
const prev = isPattern ? null : ctx[name];
|
|
124
127
|
for (const val of iterable(ctx)) {
|
|
125
128
|
if (isPattern) destructure(name, val, ctx); else ctx[name] = val;
|
|
126
|
-
|
|
129
|
+
try { res = body(ctx); } catch (e) {
|
|
130
|
+
if (e === BREAK) break;
|
|
131
|
+
if (e === CONTINUE) continue;
|
|
132
|
+
if (e === RETURN) return e[0];
|
|
133
|
+
throw e;
|
|
134
|
+
}
|
|
127
135
|
}
|
|
128
136
|
if (!isPattern) ctx[name] = prev;
|
|
129
137
|
return res;
|
|
@@ -134,18 +142,23 @@ const forIn = (name, obj, body) => {
|
|
|
134
142
|
obj = compile(obj); body = compile(body);
|
|
135
143
|
const isPattern = Array.isArray(name);
|
|
136
144
|
return ctx => {
|
|
137
|
-
let
|
|
145
|
+
let res;
|
|
138
146
|
const prev = isPattern ? null : ctx[name];
|
|
139
147
|
for (const key in obj(ctx)) {
|
|
140
148
|
if (isPattern) destructure(name, key, ctx); else ctx[name] = key;
|
|
141
|
-
|
|
149
|
+
try { res = body(ctx); } catch (e) {
|
|
150
|
+
if (e === BREAK) break;
|
|
151
|
+
if (e === CONTINUE) continue;
|
|
152
|
+
if (e === RETURN) return e[0];
|
|
153
|
+
throw e;
|
|
154
|
+
}
|
|
142
155
|
}
|
|
143
156
|
if (!isPattern) ctx[name] = prev;
|
|
144
157
|
return res;
|
|
145
158
|
};
|
|
146
159
|
};
|
|
147
160
|
|
|
148
|
-
operator('break', () => () => { throw
|
|
149
|
-
operator('continue', () => () => { throw
|
|
161
|
+
operator('break', () => () => { throw BREAK; });
|
|
162
|
+
operator('continue', () => () => { throw CONTINUE; });
|
|
150
163
|
operator('return', val => (val = val !== undefined ? compile(val) : null,
|
|
151
|
-
ctx => { throw
|
|
164
|
+
ctx => { throw (RETURN[0] = val?.(ctx), RETURN); }));
|
package/feature/op/arrow.js
CHANGED
|
@@ -32,7 +32,7 @@ operator('=>', (a, b) => {
|
|
|
32
32
|
a.forEach((p, i) => ctx[p] = args[i]);
|
|
33
33
|
if (restName) ctx[restName] = args.slice(restIdx);
|
|
34
34
|
try { const r = b(ctx); return isBlock ? undefined : r; }
|
|
35
|
-
catch (e) { if (e
|
|
35
|
+
catch (e) { if (e === RETURN) return e[0]; throw e; }
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
});
|
package/feature/switch.js
CHANGED
|
@@ -64,7 +64,7 @@ operator('switch', (val, ...cases) => {
|
|
|
64
64
|
if (matched || test === null || test(ctx) === v)
|
|
65
65
|
for (matched = true, i = 0; i < stmts.length; i++)
|
|
66
66
|
try { r = stmts[i](ctx); }
|
|
67
|
-
catch (e) { if (e
|
|
67
|
+
catch (e) { if (e === BREAK) return r; throw e; }
|
|
68
68
|
var i;
|
|
69
69
|
return r;
|
|
70
70
|
};
|
package/feature/try.js
CHANGED
|
@@ -31,7 +31,7 @@ operator('catch', (tryNode, catchName, catchBody) => {
|
|
|
31
31
|
try {
|
|
32
32
|
result = tryBody?.(ctx);
|
|
33
33
|
} catch (e) {
|
|
34
|
-
if (e
|
|
34
|
+
if (e === BREAK || e === CONTINUE || e === RETURN) throw e;
|
|
35
35
|
if (catchName !== null && catchBody) {
|
|
36
36
|
const had = catchName in ctx, orig = ctx[catchName];
|
|
37
37
|
ctx[catchName] = e;
|
package/jessie.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),n=t.pop(),
|
|
1
|
+
var l,m,c=r=>(l=0,m=r,c.newline=!1,r=h(),m[l]?T():r||""),T=(r="Unexpected token",e=l,t=m.slice(0,e).split(`
|
|
2
|
+
`),n=t.pop(),o=m.slice(Math.max(0,e-40),e),s="\u032D",u=(m[e]||" ")+s,f=m.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${n.length+1}
|
|
3
3
|
${m[e-41]!==`
|
|
4
|
-
`,""+
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
6
|
-
`,"/*":"*/"};var
|
|
7
|
-
`)for(;m.charCodeAt(n)>=
|
|
8
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
4
|
+
`,""+o}${u}${f}`)},q=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),k=(r,e=l,t)=>{for(;t=r(m.charCodeAt(l));)l+=t;return m.slice(e,l)},y=(r=1)=>m[l+=r],_=r=>l=r,h=(r=0,e)=>{let t,n,o,s,u=c.reserved,f;for(e&&c.asi&&(c.newline=!1),c.reserved=0;(t=c.space())&&(f=c.newline,1)&&t!==e&&(o=((s=C[t])&&s(n,r))??(n&&f&&c.asi?.(n,r,h))??(!n&&!c.reserved&&k(c.id)));)n=o,c.reserved=0;return c.reserved=u,e&&(t==e?l++:T("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),n},d=c.space=(r,e=l)=>{for(;(r=m.charCodeAt(l))<=32;)c.asi&&r===10&&(c.newline=!0),l++;return r},St=c.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,R=(r,e=r.length)=>m.substr(l,e)===r&&!c.id(m.charCodeAt(l+e)),v=()=>(y(),h(0,41)),C=[],H={},w=(r,e=32,t,n=r.charCodeAt(0),o=r.length,s=C[n],u=r.toUpperCase()!==r,f,A)=>(e=H[r]=!s&&H[r]||e,C[n]=(g,S,U,I=l)=>(f=U,(U?r==U:(o<2||r.charCodeAt(1)===m.charCodeAt(l+1)&&(o<3||m.substr(l,o)==r))&&(!u||!c.id(m.charCodeAt(l+o)))&&(f=U=r))&&S<e&&(l+=o,(A=t(g))?q(A,I):(l=I,f=0,u&&A!==!1&&(c.reserved=1),!u&&!s&&T()),A)||s?.(g,S,f))),a=(r,e,t=!1)=>w(r,e,(n,o)=>n&&(o=h(e-(t?.5:0)))&&[r,n,o]),N=(r,e,t)=>w(r,e,n=>t?n&&[r,n]:!n&&(n=h(e-.5))&&[r,n]),j=(r,e)=>w(r,200,t=>!t&&[,e]),ur=(r,e,t)=>{w(r,e,(n,o)=>(o=h(e-(t?.5:0)),n?.[0]!==r&&(n=[r,n||null]),o?.[0]===r?n.push(...o.slice(1)):n.push(o||null),n))},W=(r,e)=>w(r[0],e,t=>!t&&[r,h(0,r.charCodeAt(1))||null]),lr=(r,e)=>w(r[0],e,t=>t&&[r,t,h(0,r.charCodeAt(1))||null]),fr={},p=(r,e,t=fr[r])=>fr[r]=(...n)=>e(...n)||t?.(...n),i=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):fr[r[0]]?.(...r.slice(1))??T(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var b=46,z=48,rr=57,le=69,ce=101,me=43,de=45,x=95,he=110,Ae=97,ae=102,ye=65,ge=70,Nr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),cr=r=>{let e=Nr(k(t=>t===b&&m.charCodeAt(l+1)!==b||t>=z&&t<=rr||t===x||((t===le||t===ce)&&((t=m.charCodeAt(l+1))>=z&&t<=rr||t===me||t===de)?2:0)));return m.charCodeAt(l)===he?(y(),[,BigInt(e)]):(r=+e)!=r?T():[,r]},we={2:r=>r===48||r===49||r===x,8:r=>r>=48&&r<=55||r===x,16:r=>r>=z&&r<=rr||r>=Ae&&r<=ae||r>=ye&&r<=ge||r===x};c.number=null;C[b]=r=>!r&&m.charCodeAt(l+1)!==b&&cr();for(let r=z;r<=rr;r++)C[r]=e=>e?void 0:cr();C[z]=r=>{if(r)return;let e=c.number;if(e){for(let[t,n]of Object.entries(e))if(t[0]==="0"&&m[l+1]?.toLowerCase()===t[1])return y(2),[,parseInt(Nr(k(we[n])),n)]}return cr()};var Ee=92,vr=34,Or=39,Ce={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},_r=r=>(e,t,n="")=>{if(!(e||!c.string?.[String.fromCharCode(r)]))return y(),k(o=>o-r&&(o===Ee?(n+=Ce[m[l+1]]||m[l+1],2):(n+=m[l],1))),m[l]===String.fromCharCode(r)?y():T("Bad string"),[,n]};C[vr]=_r(vr);C[Or]=_r(Or);c.string={'"':!0};var Se=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>a(r,Se,!0));var Mr=(r,e,t,n)=>typeof r=="string"?o=>e(o,r,o):r[0]==="."?(t=i(r[1]),n=r[2],o=>e(t(o),n,o)):r[0]==="[]"&&r.length===3?(t=i(r[1]),n=i(r[2]),o=>e(t(o),n(o),o)):r[0]==="()"&&r.length===2?Mr(r[1],e):(()=>{throw Error("Invalid assignment target")})(),Pr={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in Pr)p(r,(e,t)=>(t=i(t),Mr(e,(n,o,s)=>Pr[r](n,o,t(s)))));var ke=30,Te=40,Ur=140;a("!",Ur);N("!",Ur);a("||",ke);a("&&",Te);p("!",r=>(r=i(r),e=>!r(e)));p("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));p("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var Ie=50,Re=60,Ne=70,Lr=100,ve=140;a("|",Ie);a("&",Ne);a("^",Re);a(">>",Lr);a("<<",Lr);N("~",ve);p("~",r=>(r=i(r),e=>~r(e)));p("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));p("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));p("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));p(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));p("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var er=90;a("<",er);a(">",er);a("<=",er);a(">=",er);p(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));p("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));p(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));p("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var Fr=80;a("==",Fr);a("!=",Fr);p("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));p("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var Br=110,mr=120,Gr=140;a("+",Br);a("-",Br);a("*",mr);a("/",mr);a("%",mr);N("+",Gr);N("-",Gr);p("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));p("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));p("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));p("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));p("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var tr=150;w("++",tr,r=>r?["++",r,null]:["++",h(tr-1)]);w("--",tr,r=>r?["--",r,null]:["--",h(tr-1)]);var dr=(r,e,t,n)=>typeof r=="string"?o=>e(o,r):r[0]==="."?(t=i(r[1]),n=r[2],o=>e(t(o),n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),n=i(r[2]),o=>e(t(o),n(o))):r[0]==="()"&&r.length===2?dr(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>dr(r,e===null?(t,n)=>t[n]++:(t,n)=>++t[n]));p("--",(r,e)=>dr(r,e===null?(t,n)=>t[n]--:(t,n)=>--t[n]));var Oe=5,_e=10,Pe=170;W("()",Pe);ur(",",_e);ur(";",Oe,!0);var Xr=(...r)=>(r=r.map(i),e=>{let t;for(let n of r)t=n(e);return t});p(",",Xr);p(";",Xr);var G=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",hr=170;lr("[]",hr);a(".",hr);lr("()",hr);var nr=r=>{throw Error(r)};p("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=i(t[1]),n=>t(n)):(t=i(t),n=>[t(n)])),t=>r.flatMap(n=>n(t))):(e==null&&nr("Missing index"),r=i(r),e=i(e),t=>{let n=e(t);return G(n)?void 0:r(t)[n]}));p(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],G(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?nr("Empty ()"):i(r);let t=o=>o?.[0]===","&&o.slice(1).some(s=>s==null||t(s));t(e)&&nr("Empty argument");let n=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(s=>s(o))):(e=i(e),o=>[e(o)]):()=>[];return Ar(r,(o,s,u)=>o[s](...n(u)))});var L=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&L(r[1])||r[0]==="{}"),Ar=(r,e,t,n)=>r==null?nr("Empty ()"):r[0]==="()"&&r.length==2?Ar(r[1],e):typeof r=="string"?o=>e(o,r,o):r[0]==="."?(t=i(r[1]),n=r[2],o=>e(t(o),n,o)):r[0]==="?."?(t=i(r[1]),n=r[2],o=>{let s=t(o);return s==null?void 0:e(s,n,o)}):r[0]==="[]"&&r.length===3?(t=i(r[1]),n=i(r[2]),o=>e(t(o),n(o),o)):r[0]==="?.[]"?(t=i(r[1]),n=i(r[2]),o=>{let s=t(o);return s==null?void 0:e(s,n(o),o)}):(r=i(r),o=>e([r(o)],0,o)),X=Ar;var Dr=new WeakMap,Me=(r,...e)=>typeof r=="string"?i(c(r)):Dr.get(r)||Dr.set(r,Ue(r,e)).get(r),Kr=57344,Ue=(r,e)=>{let t=r.reduce((s,u,f)=>s+(f?String.fromCharCode(Kr+f-1):"")+u,""),n=c(t),o=s=>{if(typeof s=="string"&&s.length===1){let u=s.charCodeAt(0)-Kr,f;if(u>=0&&u<e.length)return f=e[u],Le(f)?f:[,f]}return Array.isArray(s)?s.map(o):s};return i(o(n))},Le=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Qr=Me;var Fe=32,Be=c.space;c.comment??={"//":`
|
|
6
|
+
`,"/*":"*/"};var ar;c.space=()=>{ar||(ar=Object.entries(c.comment).map(([o,s])=>[o,s,o.charCodeAt(0)]));for(var r;r=Be();){for(var e=0,t;t=ar[e++];)if(r===t[2]&&m.substr(l,t[0].length)===t[0]){var n=l+t[0].length;if(t[1]===`
|
|
7
|
+
`)for(;m.charCodeAt(n)>=Fe;)n++;else{for(;m[n]&&m.substr(n,t[1].length)!==t[1];)n++;m[n]&&(n+=t[1].length)}_(n),r=0;break}if(r)return r}return r};var $r=80;a("===",$r);a("!==",$r);p("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));p("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));var Ge=30;a("??",Ge);p("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var Xe=130,De=20;a("**",Xe,!0);a("**=",De,!0);p("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));var Ke=r=>{throw Error(r)};p("**=",(r,e)=>(L(r)||Ke("Invalid assignment target"),e=i(e),X(r,(t,n,o)=>t[n]**=e(o))));var jr=90;a("in",jr);a("of",jr);p("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var Qe=20,$e=100,je=r=>{throw Error(r)};a(">>>",$e);a(">>>=",Qe,!0);p(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(L(r)||je("Invalid assignment target"),e=i(e),X(r,(t,n,o)=>t[n]>>>=e(o))));var He=r=>r[0]?.[0]===","?r[0].slice(1):r,D=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[n,...o]=r,s=He(o);if(n==="{}"){let u=[];for(let f of s){if(Array.isArray(f)&&f[0]==="..."){let I={};for(let O in e)u.includes(O)||(I[O]=e[O]);t[f[1]]=I;break}let A,g,S;typeof f=="string"?A=g=f:f[0]==="="?(typeof f[1]=="string"?A=g=f[1]:[,A,g]=f[1],S=f[2]):[,A,g]=f,u.push(A);let U=e[A];U===void 0&&S&&(U=i(S)(t)),D(g,U,t)}}else if(n==="[]"){let u=0;for(let f of s){if(f===null){u++;continue}if(Array.isArray(f)&&f[0]==="..."){t[f[1]]=e.slice(u);break}let A=f,g;Array.isArray(f)&&f[0]==="="&&([,A,g]=f);let S=e[u++];S===void 0&&g&&(S=i(g)(t)),D(A,S,t)}}};var yr=20,or=r=>{throw Error(r)};a("||=",yr,!0);a("&&=",yr,!0);a("??=",yr,!0);p("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=i(e),typeof t=="string"?n=>{n[t]=e(n)}:n=>D(t,e(n),n)}return L(r)||or("Invalid assignment target"),e=i(e),X(r,(t,n,o)=>t[n]=e(o))});p("||=",(r,e)=>(L(r)||or("Invalid assignment target"),e=i(e),X(r,(t,n,o)=>t[n]||=e(o))));p("&&=",(r,e)=>(L(r)||or("Invalid assignment target"),e=i(e),X(r,(t,n,o)=>t[n]&&=e(o))));p("??=",(r,e)=>(L(r)||or("Invalid assignment target"),e=i(e),X(r,(t,n,o)=>t[n]??=e(o))));j("true",!0);j("false",!1);j("null",null);w("undefined",200,r=>!r&&[]);j("NaN",NaN);j("Infinity",1/0);var gr=20;w("?",gr,(r,e,t)=>r&&(e=h(gr-1))&&k(n=>n===58)&&(t=h(gr-1),["?",r,e,t]));p("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),n=>r(n)?e(n):t(n)));var M=Symbol("break"),K=Symbol("continue"),P=[];var We=20;a("=>",We,!0);p("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,n=null;r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,n=r[t][1],r=r.slice(0,-1));let o=e?.[0]==="{}";return e=i(o?["{",e[1]]:e),(s=null)=>(s=Object.create(s),(...u)=>{r.forEach((f,A)=>s[f]=u[A]),n&&(s[n]=u.slice(t));try{let f=e(s);return o?void 0:f}catch(f){if(f===P)return f[0];throw f}})});var ze=140;N("...",ze);p("...",r=>(r=i(r),e=>Object.entries(r(e))));var Hr=170;w("?.",Hr,(r,e)=>{if(!r)return;let t=d();return t===40?(y(),["?.()",r,h(0,41)||null]):t===91?(y(),["?.[]",r,h(0,93)]):(e=h(Hr),e?["?.",r,e]:void 0)});p("?.",(r,e)=>(r=i(r),G(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let n=e(t);return G(n)?void 0:r(t)?.[n]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(s=>s(o))):(e=i(e),o=>[e(o)]):()=>[];if(r[0]==="?."){let o=i(r[1]),s=r[2];return G(s)?()=>{}:u=>o(u)?.[s]?.(...t(u))}if(r[0]==="?.[]"){let o=i(r[1]),s=i(r[2]);return u=>{let f=o(u),A=s(u);return G(A)?void 0:f?.[A]?.(...t(u))}}if(r[0]==="."){let o=i(r[1]),s=r[2];return G(s)?()=>{}:u=>o(u)?.[s]?.(...t(u))}if(r[0]==="[]"&&r.length===3){let o=i(r[1]),s=i(r[2]);return u=>{let f=o(u),A=s(u);return G(A)?void 0:f?.[A]?.(...t(u))}}let n=i(r);return o=>n(o)?.(...t(o))});var J=140;N("typeof",J);N("void",J);N("delete",J);w("new",J,r=>!r&&(R(".target")?(y(7),["new.target"]):["new",h(J)]));p("typeof",r=>(r=i(r),e=>typeof r(e)));p("void",r=>(r=i(r),e=>(r(e),void 0)));p("delete",r=>{if(r[0]==="."){let e=i(r[1]),t=r[2];return n=>delete e(n)[t]}if(r[0]==="[]"){let e=i(r[1]),t=i(r[2]);return n=>delete e(n)[t(n)]}return()=>!0});p("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,n=t?t[0]===","?(o=>s=>o.map(u=>u(s)))(t.slice(1).map(i)):(o=>s=>[o(s)])(i(t)):()=>[];return o=>new(e(o))(...n(o))});var ir=Symbol("accessor"),wr=20,Je=40,Wr=41,zr=123,Jr=125,Vr=r=>e=>{if(e)return;d();let t=k(c.id);if(!t||(d(),m.charCodeAt(l)!==Je))return!1;y();let n=h(0,Wr);return d(),m.charCodeAt(l)!==zr?!1:(y(),[r,t,n,h(0,Jr)])};w("get",wr-1,Vr("get"));w("set",wr-1,Vr("set"));w("(",wr-1,r=>{if(!r||typeof r!="string")return;let e=h(0,Wr)||null;if(d(),m.charCodeAt(l)===zr)return y(),[":",r,["=>",["()",e],h(0,Jr)||null]]});p("get",(r,e)=>(e=e?i(e):()=>{},t=>[[ir,r,{get:function(){let n=Object.create(t||{});return n.this=this,e(n)}}]]));p("set",(r,e,t)=>(t=t?i(t):()=>{},n=>[[ir,r,{set:function(o){let s=Object.create(n||{});s.this=this,s[e]=o,t(s)}}]]));var Ve=20,Yr=200,Ye=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);W("[]",Yr);W("{}",Yr);a(":",Ve-1,!0);p("{}",(r,e)=>{if(e!==void 0)return;if(!Ye(r))return i(["{",r]);r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(n=>i(typeof n=="string"?[":",n,n]:n));return n=>{let o={},s={};for(let u of t.flatMap(f=>f(n)))if(u[0]===ir){let[,f,A]=u;s[f]={...s[f],...A,configurable:!0,enumerable:!0}}else o[u[0]]=u[1];for(let u in s)Object.defineProperty(o,u,s[u]);return o}});p("{",r=>(r=r?i(r):()=>{},e=>r(Object.create(e))));p(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var Ze=170,sr=96,qe=36,xe=123,be=92,rt={n:`
|
|
8
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Zr=()=>{let r=[];for(let e="",t;(t=m.charCodeAt(l))!==sr;)t?t===be?(y(),e+=rt[m[l]]||m[l],y()):t===qe&&m.charCodeAt(l+1)===xe?(e&&r.push([,e]),e="",y(2),r.push(h(0,125))):(e+=m[l],y(),t=m.charCodeAt(l),t===sr&&e&&r.push([,e])):T("Unterminated template");return y(),r},et=C[sr];C[sr]=(r,e)=>r&&e<Ze?c.asi&&c.newline?void 0:(y(),["``",r,...Zr()]):r?et?.(r,e):(y(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Zr()));p("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=i(r);let t=[],n=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):n.push(i(s));let o=Object.assign([...t],{raw:t});return s=>r(s)(o,...n.map(u=>u(s)))});c.string["'"]=!0;c.number={"0x":16,"0b":2,"0o":8};var Er=5,qr=123,xr=125,E=(r,e,t,n=r.charCodeAt(0),o=r.length,s=C[n],u)=>C[n]=(f,A,g,S=l)=>!f&&(g?r==g:(o<2||m.substr(l,o)==r)&&(g=r))&&A<e&&!c.id(m.charCodeAt(l+o))&&(_(l+o),(u=t())?q(u,S):(_(S),!s&&T()),u)||s?.(f,A,g),Cr=(r,e,t,n=r.charCodeAt(0),o=r.length,s=C[n],u)=>C[n]=(f,A,g,S=l)=>f&&(g?r==g:(o<2||m.substr(l,o)==r)&&(g=r))&&A<e&&!c.id(m.charCodeAt(l+o))&&(_(l+o),q(u=t(f),S),u)||s?.(f,A,g),F=()=>(d()===qr||T("Expected {"),y(),h(Er-.5,xr)||null),B=()=>d()!==qr?h(Er+.5):(y(),h(Er-.5,xr)||null);var Sr=5,tt=10,nt=20,br=r=>{let e=h(tt-1);return e?.[0]==="in"||e?.[0]==="of"?[e[0],[r,e[1]],e[2]]:e?.[0]===","?[r,...e.slice(1)]:[r,e]};w("let",Sr+1,r=>!r&&br("let"));w("const",Sr+1,r=>!r&&br("const"));E("var",Sr,()=>(d(),["var",h(nt)]));var re=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,n]=e,o=i(n);return typeof t=="string"?s=>{s[t]=o(s)}:s=>D(t,o(s),s)}return i(e)}),e=>{for(let t of r)t(e)});p("let",re);p("const",re);p("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var ot=200;E("function",ot,()=>{d();let r=!1;m[l]==="*"&&(r=!0,y(),d());let e=k(c.id);return e&&d(),r?["function*",e,v()||null,F()]:["function",e,v()||null,F()]});p("function",(r,e,t)=>{t=t?i(t):()=>{};let n=e?e[0]===","?e.slice(1):[e]:[],o=null,s=-1,u=n[n.length-1];return Array.isArray(u)&&u[0]==="..."&&(s=n.length-1,o=u[1],n.length--),f=>{let A=(...g)=>{let S={};n.forEach((I,O)=>S[I]=g[O]),o&&(S[o]=g.slice(s));let U=new Proxy(S,{get:(I,O)=>O in I?I[O]:f[O],set:(I,O,ue)=>((O in I?I:f)[O]=ue,!0),has:(I,O)=>O in I||O in f});try{return t(U)}catch(I){if(I===P)return I[0];throw I}};return r&&(f[r]=A),A}});p("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});var pr=140,kr=20;N("await",pr);E("yield",pr,()=>(d(),m[l]==="*"?(y(),d(),["yield*",h(kr)]):["yield",h(kr)]));E("async",pr,()=>{if(d(),R("function"))return["async",h(pr)];let r=h(kr-.5);return r&&["async",r]});p("async",r=>{let e=i(r);return t=>{let n=e(t);return async function(...o){return n(...o)}}});p("await",r=>(r=i(r),async e=>await r(e)));p("yield",r=>(r=r?i(r):null,e=>{throw{__yield__:r?r(e):void 0}}));p("yield*",r=>(r=i(r),e=>{throw{__yield_all__:r(e)}}));var Tr=200,it=140,st=90,pt=Symbol("static");N("static",it);a("instanceof",st);w("#",Tr,r=>{if(r)return;let e=k(c.id);return e?"#"+e:void 0});E("class",Tr,()=>{d();let r=k(c.id)||null;if(r==="extends")r=null,d();else{if(d(),!R("extends"))return["class",r,null,F()];y(7),d()}return["class",r,h(Tr),F()]});var ft=r=>{throw Error(r)};p("instanceof",(r,e)=>(r=i(r),e=i(e),t=>r(t)instanceof e(t)));p("class",(r,e,t)=>(e=e?i(e):null,t=t?i(t):null,n=>{let o=e?e(n):Object,s=function(...u){if(!(this instanceof s))return ft("Class constructor must be called with new");let f=e?Reflect.construct(o,u,s):this;return s.prototype.__constructor__&&s.prototype.__constructor__.apply(f,u),f};if(Object.setPrototypeOf(s.prototype,o.prototype),Object.setPrototypeOf(s,o),t){let u=Object.create(n);u.super=o;let f=t(u),A=Array.isArray(f)&&typeof f[0]?.[0]=="string"?f:[];for(let[g,S]of A)g==="constructor"?s.prototype.__constructor__=S:s.prototype[g]=S}return r&&(n[r]=s),s}));p("static",r=>(r=i(r),e=>[[pt,r(e)]]));var ut=140,Ir=47,lt=92,ct=r=>r===lt?2:r&&r!==Ir,mt=r=>r===103||r===105||r===109||r===115||r===117||r===121;w("/",ut,r=>{if(r)return;let e=m.charCodeAt(l);if(e===Ir||e===42||e===43||e===63||e===61)return;let t=k(ct);m.charCodeAt(l)===Ir||T("Unterminated regex"),y();let n=k(mt);try{new RegExp(t,n)}catch(o){T("Invalid regex: "+o.message)}return n?["//",t,n]:["//",t]});p("//",(r,e)=>{let t=new RegExp(r,e||"");return()=>t});var dt=5,ht=59,At=()=>{let r=l;return d()===ht&&y(),d(),R("else")?(y(4),!0):(_(r),!1)};E("if",dt+1,()=>{d();let r=["if",v(),B()];return At()&&r.push(B()),r});p("if",(r,e,t)=>(r=i(r),e=i(e),t=t!==void 0?i(t):null,n=>r(n)?e(n):t?.(n)));var Q=5,V=125,Y=59;E("while",Q+1,()=>(d(),["while",v(),B()]));E("do",Q+1,()=>(r=>(d(),y(5),d(),["do",r,v()]))(B()));E("for",Q+1,()=>(d(),R("await")?(y(5),d(),["for await",v(),B()]):["for",v(),B()]));E("break",Q+1,()=>{c.asi&&(c.newline=!1);let r=l;d();let e=m.charCodeAt(l);if(!e||e===V||e===Y||c.newline)return["break"];let t=k(c.id);if(!t)return["break"];d();let n=m.charCodeAt(l);return!n||n===V||n===Y||c.newline?["break",t]:(_(r),["break"])});E("continue",Q+1,()=>{c.asi&&(c.newline=!1);let r=l;d();let e=m.charCodeAt(l);if(!e||e===V||e===Y||c.newline)return["continue"];let t=k(c.id);if(!t)return["continue"];d();let n=m.charCodeAt(l);return!n||n===V||n===Y||c.newline?["continue",t]:(_(r),["continue"])});E("return",Q+1,()=>{c.asi&&(c.newline=!1),d();let r=m.charCodeAt(l);return!r||r===V||r===Y||c.newline?["return"]:["return",h(Q)]});p("while",(r,e)=>(r=i(r),e=i(e),t=>{let n;for(;r(t);)try{n=e(t)}catch(o){if(o===M)break;if(o===K)continue;if(o===P)return o[0];throw o}return n}));p("do",(r,e)=>(r=i(r),e=i(e),t=>{let n;do try{n=r(t)}catch(o){if(o===M)break;if(o===K)continue;if(o===P)return o[0];throw o}while(e(t));return n}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,n,o]=r;return t=t?i(t):null,n=n?i(n):()=>!0,o=o?i(o):null,e=i(e),s=>{let u;for(t?.(s);n(s);o?.(s))try{u=e(s)}catch(f){if(f===M)break;if(f===K)continue;if(f===P)return f[0];throw f}return u}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,n,o]=r;if(Array.isArray(n)&&(n[0]==="let"||n[0]==="const"||n[0]==="var")&&(n=n[1]),t==="in")return yt(n,o,e);if(t==="of")return at(n,o,e)}});var at=(r,e,t)=>{e=i(e),t=i(t);let n=Array.isArray(r);return o=>{let s,u=n?null:o[r];for(let f of e(o)){n?D(r,f,o):o[r]=f;try{s=t(o)}catch(A){if(A===M)break;if(A===K)continue;if(A===P)return A[0];throw A}}return n||(o[r]=u),s}},yt=(r,e,t)=>{e=i(e),t=i(t);let n=Array.isArray(r);return o=>{let s,u=n?null:o[r];for(let f in e(o)){n?D(r,f,o):o[r]=f;try{s=t(o)}catch(A){if(A===M)break;if(A===K)continue;if(A===P)return A[0];throw A}}return n||(o[r]=u),s}};p("break",()=>()=>{throw M});p("continue",()=>()=>{throw K});p("return",r=>(r=r!==void 0?i(r):null,e=>{throw P[0]=r?.(e),P}));var Z=5;E("try",Z+1,()=>["try",F()]);Cr("catch",Z+1,r=>(d(),["catch",r,v(),F()]));Cr("finally",Z+1,r=>["finally",r,F()]);E("throw",Z+1,()=>{if(c.asi&&(c.newline=!1),d(),c.newline)throw SyntaxError("Unexpected newline after throw");return["throw",h(Z)]});p("try",r=>(r=r?i(r):null,e=>r?.(e)));p("catch",(r,e,t)=>{let n=r?.[1]?i(r[1]):null;return t=t?i(t):null,o=>{let s;try{s=n?.(o)}catch(u){if(u===M||u===K||u===P)throw u;if(e!==null&&t){let f=e in o,A=o[e];o[e]=u;try{s=t(o)}finally{f?o[e]=A:delete o[e]}}else if(e===null)throw u}return s}});p("finally",(r,e)=>(r=r?i(r):null,e=e?i(e):null,t=>{let n;try{n=r?.(t)}finally{e?.(t)}return n}));p("throw",r=>(r=i(r),e=>{throw r(e)}));var ne=5,gt=20,ee=58,wt=59,oe=125,ie=(r,e=r.charCodeAt(0),t=C[e])=>C[e]=(n,o,s)=>R(r)&&!n&&(c.reserved=1)||t?.(n,o,s);ie("case");ie("default");var te=r=>{let e=[];for(;(r=d())!==oe&&!R("case")&&!R("default");){if(r===wt){y();continue}e.push(h(ne-.5))||T()}return e.length>1?[";",...e]:e[0]||null},Et=()=>{d()===123||T("Expected {"),y();let r=[];for(;d()!==oe;)if(R("case")){_(l+4),d();let e=h(gt-.5);d()===ee&&y(),r.push(["case",e,te()])}else R("default")?(_(l+7),d()===ee&&y(),r.push(["default",te()])):T("Expected case or default");return y(),r};E("switch",ne+1,()=>(d(),["switch",v(),...Et()]));p("switch",(r,...e)=>(r=i(r),e.length?(e=e.map(t=>[t[0]==="case"?i(t[1]):null,(t[0]==="case"?t[2]:t[1])?.[0]===";"?(t[0]==="case"?t[2]:t[1]).slice(1).map(i):(t[0]==="case"?t[2]:t[1])?[i(t[0]==="case"?t[2]:t[1])]:[]]),t=>{let n=r(t),o=!1,s;for(let[f,A]of e)if(o||f===null||f(t)===n)for(o=!0,u=0;u<A.length;u++)try{s=A[u](t)}catch(g){if(g===M)return s;throw g}var u;return s}):t=>r(t)));var se=5;E("debugger",se+1,()=>["debugger"]);E("with",se+1,()=>(d(),["with",v(),B()]));var Rr=5,$=10,pe=42,Ct=C[pe];C[pe]=(r,e)=>r?Ct?.(r,e):(y(),"*");w("from",$+1,r=>r?r[0]!=="="&&r[0]!==","&&(d(),["from",r,h($+1)]):!1);w("as",$+2,r=>r?(d(),["as",r,h($+2)]):!1);E("import",Rr,()=>R(".meta")?(y(5),["import.meta"]):["import",h($)]);E("export",Rr,()=>(d(),["export",h(Rr)]));E("default",$+1,()=>d()!==58&&(d(),["default",h($)]));p("import",()=>()=>{});p("export",()=>()=>{});p("from",(r,e)=>()=>{});p("as",(r,e)=>()=>{});p("default",r=>i(r));var fe=H.asi??H[";"];c.asi=(r,e,t,n,o)=>e<fe&&(n=t(fe-.5))&&(o=n?.[0]===";"?n.slice(1):[n],r?.[0]===";"?(r.push(...o),r):[";",r,...o]);export{lr as access,a as binary,i as compile,m as cur,Qr as default,T as err,h as expr,W as group,St as id,l as idx,j as literal,q as loc,C as lookup,ur as nary,k as next,p as operator,fr as operators,v as parens,c as parse,H as prec,_ as seek,y as skip,d as space,w as token,N as unary,R as word};
|
package/justin.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var m,c,d=r=>(m=0,c=r,d.newline=!1,r=A(),c[m]?w():r||""),w=(r="Unexpected token",e=m,t=c.slice(0,e).split(`
|
|
2
|
-
`),o=t.pop(),i=c.slice(Math.max(0,e-40),e),p="\u032D",
|
|
2
|
+
`),o=t.pop(),i=c.slice(Math.max(0,e-40),e),p="\u032D",f=(c[e]||" ")+p,l=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
|
|
3
3
|
${c[e-41]!==`
|
|
4
|
-
`,""+i}${
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
4
|
+
`,""+i}${f}${l}`)},Lr=(r,e=m)=>(Array.isArray(r)&&(r.loc=e),r),k=(r,e=m,t)=>{for(;t=r(c.charCodeAt(m));)m+=t;return c.slice(e,m)},h=(r=1)=>c[m+=r],nr=r=>m=r,A=(r=0,e)=>{let t,o,i,p,f=d.reserved,l;for(e&&d.asi&&(d.newline=!1),d.reserved=0;(t=d.space())&&(l=d.newline,1)&&t!==e&&(i=((p=C[t])&&p(o,r))??(o&&l&&d.asi?.(o,r,A))??(!o&&!d.reserved&&k(d.id)));)o=i,d.reserved=0;return d.reserved=f,e&&(t==e?m++:w("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},P=d.space=(r,e=m)=>{for(;(r=c.charCodeAt(m))<=32;)d.asi&&r===10&&(d.newline=!0),m++;return r},ve=d.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,ir=(r,e=r.length)=>c.substr(m,e)===r&&!d.id(c.charCodeAt(m+e)),Ne=()=>(h(),A(0,41)),C=[],or={},y=(r,e=32,t,o=r.charCodeAt(0),i=r.length,p=C[o],f=r.toUpperCase()!==r,l,g)=>(e=or[r]=!p&&or[r]||e,C[o]=(E,I,R,L=m)=>(l=R,(R?r==R:(i<2||r.charCodeAt(1)===c.charCodeAt(m+1)&&(i<3||c.substr(m,i)==r))&&(!f||!d.id(c.charCodeAt(m+i)))&&(l=R=r))&&I<e&&(m+=i,(g=t(E))?Lr(g,L):(m=L,l=0,f&&g!==!1&&(d.reserved=1),!f&&!p&&w()),g)||p?.(E,I,l))),u=(r,e,t=!1)=>y(r,e,(o,i)=>o&&(i=A(e-(t?.5:0)))&&[r,o,i]),S=(r,e,t)=>y(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),T=(r,e)=>y(r,200,t=>!t&&[,e]),z=(r,e,t)=>{y(r,e,(o,i)=>(i=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},U=(r,e)=>y(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),J=(r,e)=>y(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),W={},s=(r,e,t=W[r])=>W[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):W[r[0]]?.(...r.slice(1))??w(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var D=46,_=48,F=57,Ur=69,_r=101,Br=43,Mr=45,M=95,Dr=110,Fr=97,Gr=102,Xr=65,$r=70,sr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),V=r=>{let e=sr(k(t=>t===D&&c.charCodeAt(m+1)!==D||t>=_&&t<=F||t===M||((t===Ur||t===_r)&&((t=c.charCodeAt(m+1))>=_&&t<=F||t===Br||t===Mr)?2:0)));return c.charCodeAt(m)===Dr?(h(),[,BigInt(e)]):(r=+e)!=r?w():[,r]},Qr={2:r=>r===48||r===49||r===M,8:r=>r>=48&&r<=55||r===M,16:r=>r>=_&&r<=F||r>=Fr&&r<=Gr||r>=Xr&&r<=$r||r===M};d.number=null;C[D]=r=>!r&&c.charCodeAt(m+1)!==D&&V();for(let r=_;r<=F;r++)C[r]=e=>e?void 0:V();C[_]=r=>{if(r)return;let e=d.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[m+1]?.toLowerCase()===t[1])return h(2),[,parseInt(sr(k(Qr[o])),o)]}return V()};var jr=92,pr=34,lr=39,Hr={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},fr=r=>(e,t,o="")=>{if(!(e||!d.string?.[String.fromCharCode(r)]))return h(),k(i=>i-r&&(i===jr?(o+=Hr[c[m+1]]||c[m+1],2):(o+=c[m],1))),c[m]===String.fromCharCode(r)?h():w("Bad string"),[,o]};C[pr]=fr(pr);C[lr]=fr(lr);d.string={'"':!0};var Kr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>u(r,Kr,!0));var mr=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?mr(r[1],e):(()=>{throw Error("Invalid assignment target")})(),ur={"=":(r,e,t)=>r[e]=t,"+=":(r,e,t)=>r[e]+=t,"-=":(r,e,t)=>r[e]-=t,"*=":(r,e,t)=>r[e]*=t,"/=":(r,e,t)=>r[e]/=t,"%=":(r,e,t)=>r[e]%=t,"|=":(r,e,t)=>r[e]|=t,"&=":(r,e,t)=>r[e]&=t,"^=":(r,e,t)=>r[e]^=t,">>=":(r,e,t)=>r[e]>>=t,"<<=":(r,e,t)=>r[e]<<=t};for(let r in ur)s(r,(e,t)=>(t=n(t),mr(e,(o,i,p)=>ur[r](o,i,t(p)))));var ar=30,Wr=40,cr=140;u("!",cr);S("!",cr);u("||",ar);u("&&",Wr);s("!",r=>(r=n(r),e=>!r(e)));s("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var zr=50,Jr=60,Vr=70,dr=100,Yr=140;u("|",zr);u("&",Vr);u("^",Jr);u(">>",dr);u("<<",dr);S("~",Yr);s("~",r=>(r=n(r),e=>~r(e)));s("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var G=90;u("<",G);u(">",G);u("<=",G);u(">=",G);s(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var Ar=80;u("==",Ar);u("!=",Ar);s("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var gr=110,Y=120,hr=140;u("+",gr);u("-",gr);u("*",Y);u("/",Y);u("%",Y);S("+",hr);S("-",hr);s("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));s("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var X=150;y("++",X,r=>r?["++",r,null]:["++",A(X-1)]);y("--",X,r=>r?["--",r,null]:["--",A(X-1)]);var Z=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?Z(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>Z(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));s("--",(r,e)=>Z(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Zr=5,qr=10,xr=170;U("()",xr);z(",",qr);z(";",Zr,!0);var yr=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});s(",",yr);s(";",yr);var N=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",q=170;J("[]",q);u(".",q);J("()",q);var $=r=>{throw Error(r)};s("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&$("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return N(o)?void 0:r(t)[o]}));s(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],N(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?$("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&$("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];return x(r,(i,p,f)=>i[p](...o(f)))});var v=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&v(r[1])||r[0]==="{}"),x=(r,e,t,o)=>r==null?$("Empty ()"):r[0]==="()"&&r.length==2?x(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let p=t(i);return p==null?void 0:e(p,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,o(i),i)}):(r=n(r),i=>e([r(i)],0,i)),O=x;var Cr=new WeakMap,br=(r,...e)=>typeof r=="string"?n(d(r)):Cr.get(r)||Cr.set(r,re(r,e)).get(r),Sr=57344,re=(r,e)=>{let t=r.reduce((p,f,l)=>p+(l?String.fromCharCode(Sr+l-1):"")+f,""),o=d(t),i=p=>{if(typeof p=="string"&&p.length===1){let f=p.charCodeAt(0)-Sr,l;if(f>=0&&f<e.length)return l=e[f],ee(l)?l:[,l]}return Array.isArray(p)?p.map(i):p};return n(i(o))},ee=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),te=br;var oe=32,ne=d.space;d.comment??={"//":`
|
|
6
6
|
`,"/*":"*/"};var b;d.space=()=>{b||(b=Object.entries(d.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=ne();){for(var e=0,t;t=b[e++];)if(r===t[2]&&c.substr(m,t[0].length)===t[0]){var o=m+t[0].length;if(t[1]===`
|
|
7
|
-
`)for(;c.charCodeAt(o)>=oe;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}nr(o),r=0;break}if(r)return r}return r};var Er=80;
|
|
8
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Tr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(m))!==K;)t?t===Ie?(h(),e+=we[c[m]]||c[m],h()):t===Se&&c.charCodeAt(m+1)===Ee?(e&&r.push([,e]),e="",h(2),r.push(A(0,125))):(e+=c[m],h(),t=c.charCodeAt(m),t===K&&e&&r.push([,e])):w("Unterminated template");return h(),r},
|
|
7
|
+
`)for(;c.charCodeAt(o)>=oe;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}nr(o),r=0;break}if(r)return r}return r};var Er=80;u("===",Er);u("!==",Er);s("===",(r,e)=>(r=n(r),e=n(e),t=>r(t)===e(t)));s("!==",(r,e)=>(r=n(r),e=n(e),t=>r(t)!==e(t)));var ie=30;u("??",ie);s("??",(r,e)=>(r=n(r),e=n(e),t=>r(t)??e(t)));var se=130,pe=20;u("**",se,!0);u("**=",pe,!0);s("**",(r,e)=>(r=n(r),e=n(e),t=>r(t)**e(t)));var le=r=>{throw Error(r)};s("**=",(r,e)=>(v(r)||le("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]**=e(i))));var Ir=90;u("in",Ir);u("of",Ir);s("in",(r,e)=>(r=n(r),e=n(e),t=>r(t)in e(t)));var fe=20,ue=100,me=r=>{throw Error(r)};u(">>>",ue);u(">>>=",fe,!0);s(">>>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(v(r)||me("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]>>>=e(i))));var ce=r=>r[0]?.[0]===","?r[0].slice(1):r,Q=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...i]=r,p=ce(i);if(o==="{}"){let f=[];for(let l of p){if(Array.isArray(l)&&l[0]==="..."){let L={};for(let a in e)f.includes(a)||(L[a]=e[a]);t[l[1]]=L;break}let g,E,I;typeof l=="string"?g=E=l:l[0]==="="?(typeof l[1]=="string"?g=E=l[1]:[,g,E]=l[1],I=l[2]):[,g,E]=l,f.push(g);let R=e[g];R===void 0&&I&&(R=n(I)(t)),Q(E,R,t)}}else if(o==="[]"){let f=0;for(let l of p){if(l===null){f++;continue}if(Array.isArray(l)&&l[0]==="..."){t[l[1]]=e.slice(f);break}let g=l,E;Array.isArray(l)&&l[0]==="="&&([,g,E]=l);let I=e[f++];I===void 0&&E&&(I=n(E)(t)),Q(g,I,t)}}};var rr=20,j=r=>{throw Error(r)};u("||=",rr,!0);u("&&=",rr,!0);u("??=",rr,!0);s("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=n(e),typeof t=="string"?o=>{o[t]=e(o)}:o=>Q(t,e(o),o)}return v(r)||j("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]=e(i))});s("||=",(r,e)=>(v(r)||j("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]||=e(i))));s("&&=",(r,e)=>(v(r)||j("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]&&=e(i))));s("??=",(r,e)=>(v(r)||j("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]??=e(i))));T("true",!0);T("false",!1);T("null",null);y("undefined",200,r=>!r&&[]);T("NaN",NaN);T("Infinity",1/0);var er=20;y("?",er,(r,e,t)=>r&&(e=A(er-1))&&k(o=>o===58)&&(t=A(er-1),["?",r,e,t]));s("?",(r,e,t)=>(r=n(r),e=n(e),t=n(t),o=>r(o)?e(o):t(o)));var wr=[];var de=20;u("=>",de,!0);s("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1));let i=e?.[0]==="{}";return e=n(i?["{",e[1]]:e),(p=null)=>(p=Object.create(p),(...f)=>{r.forEach((l,g)=>p[l]=f[g]),o&&(p[o]=f.slice(t));try{let l=e(p);return i?void 0:l}catch(l){if(l===wr)return l[0];throw l}})});var Ae=140;S("...",Ae);s("...",r=>(r=n(r),e=>Object.entries(r(e))));var kr=170;y("?.",kr,(r,e)=>{if(!r)return;let t=P();return t===40?(h(),["?.()",r,A(0,41)||null]):t===91?(h(),["?.[]",r,A(0,93)]):(e=A(kr),e?["?.",r,e]:void 0)});s("?.",(r,e)=>(r=n(r),N(e)?()=>{}:t=>r(t)?.[e]));s("?.[]",(r,e)=>(r=n(r),e=n(e),t=>{let o=e(t);return N(o)?void 0:r(t)?.[o]}));s("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];if(r[0]==="?."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:f=>i(f)?.[p]?.(...t(f))}if(r[0]==="?.[]"){let i=n(r[1]),p=n(r[2]);return f=>{let l=i(f),g=p(f);return N(g)?void 0:l?.[g]?.(...t(f))}}if(r[0]==="."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:f=>i(f)?.[p]?.(...t(f))}if(r[0]==="[]"&&r.length===3){let i=n(r[1]),p=n(r[2]);return f=>{let l=i(f),g=p(f);return N(g)?void 0:l?.[g]?.(...t(f))}}let o=n(r);return i=>o(i)?.(...t(i))});var B=140;S("typeof",B);S("void",B);S("delete",B);y("new",B,r=>!r&&(ir(".target")?(h(7),["new.target"]):["new",A(B)]));s("typeof",r=>(r=n(r),e=>typeof r(e)));s("void",r=>(r=n(r),e=>(r(e),void 0)));s("delete",r=>{if(r[0]==="."){let e=n(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=n(r[1]),t=n(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});s("new",r=>{let e=n(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(i=>p=>i.map(f=>f(p)))(t.slice(1).map(n)):(i=>p=>[i(p)])(n(t)):()=>[];return i=>new(e(i))(...o(i))});var H=Symbol("accessor"),tr=20,ge=40,vr=41,Nr=123,Or=125,Rr=r=>e=>{if(e)return;P();let t=k(d.id);if(!t||(P(),c.charCodeAt(m)!==ge))return!1;h();let o=A(0,vr);return P(),c.charCodeAt(m)!==Nr?!1:(h(),[r,t,o,A(0,Or)])};y("get",tr-1,Rr("get"));y("set",tr-1,Rr("set"));y("(",tr-1,r=>{if(!r||typeof r!="string")return;let e=A(0,vr)||null;if(P(),c.charCodeAt(m)===Nr)return h(),[":",r,["=>",["()",e],A(0,Or)||null]]});s("get",(r,e)=>(e=e?n(e):()=>{},t=>[[H,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));s("set",(r,e,t)=>(t=t?n(t):()=>{},o=>[[H,r,{set:function(i){let p=Object.create(o||{});p.this=this,p[e]=i,t(p)}}]]));var he=20,Pr=200,ye=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);U("[]",Pr);U("{}",Pr);u(":",he-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;if(!ye(r))return n(["{",r]);r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>n(typeof o=="string"?[":",o,o]:o));return o=>{let i={},p={};for(let f of t.flatMap(l=>l(o)))if(f[0]===H){let[,l,g]=f;p[l]={...p[l],...g,configurable:!0,enumerable:!0}}else i[f[0]]=f[1];for(let f in p)Object.defineProperty(i,f,p[f]);return i}});s("{",r=>(r=r?n(r):()=>{},e=>r(Object.create(e))));s(":",(r,e)=>(e=n(e),Array.isArray(r)?(r=n(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var Ce=170,K=96,Se=36,Ee=123,Ie=92,we={n:`
|
|
8
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Tr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(m))!==K;)t?t===Ie?(h(),e+=we[c[m]]||c[m],h()):t===Se&&c.charCodeAt(m+1)===Ee?(e&&r.push([,e]),e="",h(2),r.push(A(0,125))):(e+=c[m],h(),t=c.charCodeAt(m),t===K&&e&&r.push([,e])):w("Unterminated template");return h(),r},ke=C[K];C[K]=(r,e)=>r&&e<Ce?d.asi&&d.newline?void 0:(h(),["``",r,...Tr()]):r?ke?.(r,e):(h(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Tr()));s("`",(...r)=>(r=r.map(n),e=>r.map(t=>t(e)).join("")));s("``",(r,...e)=>{r=n(r);let t=[],o=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):o.push(n(p));let i=Object.assign([...t],{raw:t});return p=>r(p)(i,...o.map(f=>f(p)))});d.string["'"]=!0;d.number={"0x":16,"0b":2,"0o":8};export{J as access,u as binary,n as compile,c as cur,te as default,w as err,A as expr,U as group,ve as id,m as idx,T as literal,Lr as loc,C as lookup,z as nary,k as next,s as operator,W as operators,Ne as parens,d as parse,or as prec,nr as seek,h as skip,P as space,y as token,S as unary,ir as word};
|