subscript 10.4.5 → 10.4.7
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/accessor.js +11 -0
- package/feature/asi.js +4 -2
- package/jessie.min.js +6 -6
- package/package.json +1 -1
package/feature/accessor.js
CHANGED
|
@@ -7,13 +7,24 @@
|
|
|
7
7
|
import { token, expr, skip, space, next, parse, cur, idx } from '../parse.js';
|
|
8
8
|
|
|
9
9
|
const ASSIGN = 20;
|
|
10
|
+
const LF = 10, CR = 13;
|
|
10
11
|
const OPAREN = 40, CPAREN = 41, OBRACE = 123, CBRACE = 125;
|
|
11
12
|
|
|
13
|
+
const hasLineTerminator = (from, to) => {
|
|
14
|
+
while (from < to) {
|
|
15
|
+
const c = cur.charCodeAt(from++);
|
|
16
|
+
if (c === LF || c === CR) return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
|
|
12
21
|
// Shared parser for get/set — returns false if not valid accessor pattern (falls through to identifier)
|
|
13
22
|
// Returns false (not undefined) to signal "fall through without setting reserved"
|
|
14
23
|
const accessor = (kind) => a => {
|
|
15
24
|
if (a) return; // not prefix
|
|
25
|
+
const from = idx;
|
|
16
26
|
space();
|
|
27
|
+
if (parse.semi || hasLineTerminator(from, idx)) return false;
|
|
17
28
|
const name = next(parse.id);
|
|
18
29
|
if (!name) return false; // no property name = not accessor (e.g. `{ get: 1 }`)
|
|
19
30
|
space();
|
package/feature/asi.js
CHANGED
|
@@ -13,6 +13,7 @@ const lvl = prec.asi ?? prec[';'];
|
|
|
13
13
|
// would leave previous ASI layers active.
|
|
14
14
|
const baseSpace = parse._baseSpace ??= parse.space;
|
|
15
15
|
const baseStep = parse._baseStep ??= parse.step;
|
|
16
|
+
const isNode = a => Array.isArray(a) || typeof a === 'string';
|
|
16
17
|
|
|
17
18
|
// LF immediately preceding the next non-space at i (used to detect `;\n`).
|
|
18
19
|
const hasLineBreak = (i, c) => {
|
|
@@ -61,9 +62,10 @@ parse.exit = (p, end) => { if (end === BLOCK_END) parse.newline = true, parse.se
|
|
|
61
62
|
// `[`/`(` on a new line; fire ASI when no operator continues across newline.
|
|
62
63
|
parse.step = (a, p, cc, expr) => {
|
|
63
64
|
if (parse.semi && p >= lvl) return false;
|
|
64
|
-
if (a && (
|
|
65
|
+
if (a && !isNode(a)) return null;
|
|
66
|
+
if (isNode(a) && (parse.semi || ((cc === BRACKET || cc === PAREN) && lineBreak()))) return asi(a, p, expr) ?? null;
|
|
65
67
|
const nl = parse.newline;
|
|
66
|
-
return baseStep(a, p, cc, expr) ?? (a && nl ? asi(a, p, expr) ?? null : null);
|
|
68
|
+
return baseStep(a, p, cc, expr) ?? (isNode(a) && nl ? asi(a, p, expr) ?? null : null);
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
// Runaway-recursion guard: asi recurses once per consecutive statement in a
|
package/jessie.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var u,c,m=r=>(u=0,c=r,m.enter?.(),r=A(),c[u]?R():r||""),R=(r="Unexpected token",e=u,t=c.slice(0,e).split(`
|
|
2
2
|
`),o=t.pop(),n=c.slice(Math.max(0,e-40),e),s="\u032D",l=(c[e]||" ")+s,f=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
|
|
3
3
|
${c[e-41]!==`
|
|
4
|
-
`,""+n}${l}${f}`)},
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v",0:"\0"},
|
|
6
|
-
`,"/*":"*/"};var hr;m.space=()=>{hr||(hr=Object.entries(m.comment).map(([n,s])=>[n,s,n.charCodeAt(0)]));for(var r;r
|
|
7
|
-
`)for(;c.charCodeAt(o)
|
|
8
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
9
|
-
`;var me=32,Or=10,Rt=59,_t=125,Ot=91,Pt=40,_r=$.asi??$[";"],vt=m._baseSpace??=m.space,Bt=m._baseStep??=m.step,Lt=(r,e)=>{for(;(e=c.charCodeAt(r))<=me;){if(e===Or)return!0;r++}return!1},Mt=(r=u,e)=>{for(;r-- >0&&(e=c.charCodeAt(r))<=me;)if(e===Or)return!0;return!1};m.space=(r,e)=>{for(;;){for(e=u,r=vt();e<u;)if(c.charCodeAt(e++)===Or){m.newline=!0;break}if(r===Rt&&Lt(u+1)){P(u+1),m.newline=m.semi=!0;continue}return r}};m.enter=()=>m.newline=m.semi=!1;m.exit=(r,e)=>{e===_t&&(m.newline=!0,m.semi=!1)};m.step=(r,e,t,o)=>{if(m.semi&&e>=_r)return!1;if(r&&(m.semi||(t===Ot||t===Pt)&&Mt()))return le(r,e,o)??null;let n=m.newline;return Bt(r,e,t,o)??(r&&n?le(r,e,o)??null:null)};var Rr=0,Ut=2e3,le=m.asi=(r,e,t,o,n)=>{if(e>=_r||Rr>=Ut)return;m.semi=!1;let s=u;Rr++;try{o=t(_r-.5)}finally{Rr--}if(!(!o||u===s))return n=o?.[0]===";"?o.slice(1):[o],r?.[0]===";"?(r.push(...n),r):[";",r,...n]};var de=(r,e,t,o)=>typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="()"&&r.length===2?de(r[1],e):(()=>{throw Error("Invalid assignment target")})(),ce={"=":(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 ce)p(r,(e,t)=>(t=i(t),de(e,(o,n,s)=>ce[r](o,n,t(s)))));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=>(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)));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)));p("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(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)=>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 Pr=(r,e,t,o)=>typeof r=="string"?n=>e(n,r):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n))):r[0]==="()"&&r.length===2?Pr(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>Pr(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));p("--",(r,e)=>Pr(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var ae=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)t=o(e);return t});p(",",ae);p(";",ae);var F=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",ir=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]),o=>t(o)):(t=i(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&ir("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return F(o)?void 0:r(t)[o]}));p(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],F(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?ir("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&ir("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return vr(r,(n,s,l)=>n[s](...o(l)))});var M=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&M(r[1])||r[0]==="{}"),vr=(r,e,t,o)=>r==null?ir("Empty ()"):r[0]==="()"&&r.length==2?vr(r[1],e):typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="?."?(t=i(r[1]),o=r[2],n=>{let s=t(n);return s==null?void 0:e(s,o,n)}):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="?.[]"?(t=i(r[1]),o=i(r[2]),n=>{let s=t(n);return s==null?void 0:e(s,o(n),n)}):(r=i(r),n=>e([r(n)],0,n)),G=vr;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 Dt=r=>{throw Error(r)};p("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));p("**=",(r,e)=>(M(r)||Dt("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]**=e(n))));p("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var Ft=r=>{throw Error(r)};p(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(M(r)||Ft("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]>>>=e(n))));var Gt=r=>r[0]?.[0]===","?r[0].slice(1):r,X=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r,s=Gt(n);if(o==="{}"){let l=[];for(let f of s){if(Array.isArray(f)&&f[0]==="..."){let w={};for(let _ in e)l.includes(_)||(w[_]=e[_]);t[f[1]]=w;break}let d,g,E;typeof f=="string"?d=g=f:f[0]==="="?(typeof f[1]=="string"?d=g=f[1]:[,d,g]=f[1],E=f[2]):[,d,g]=f,l.push(d);let S=e[d];S===void 0&&E&&(S=i(E)(t)),X(g,S,t)}}else if(o==="[]"){let l=0;for(let f of s){if(f===null){l++;continue}if(Array.isArray(f)&&f[0]==="..."){t[f[1]]=e.slice(l);break}let d=f,g;Array.isArray(f)&&f[0]==="="&&([,d,g]=f);let E=e[l++];E===void 0&&g&&(E=i(g)(t)),X(d,E,t)}}},Br=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,o]=e,n=i(o);return typeof t=="string"?s=>{s[t]=n(s)}:s=>X(t,n(s),s)}return i(e)}),e=>{for(let t of r)t(e)});p("let",Br);p("const",Br);p("var",Br);var sr=r=>{throw Error(r)};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"?o=>{o[t]=e(o)}:o=>X(t,e(o),o)}return M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]=e(n))});p("||=",(r,e)=>(M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]||=e(n))));p("&&=",(r,e)=>(M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]&&=e(n))));p("??=",(r,e)=>(M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]??=e(n))));p("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var B=[];p("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r;let t=r?r[0]===","?r.slice(1):[r]:[],o=-1,n=null,s=t[t.length-1];Array.isArray(s)&&s[0]==="..."&&(o=t.length-1,n=s[1],t.length--);let l=e?.[0]==="{}";return e=i(l?["{",e[1]]:e),f=>(...d)=>{let g={};t.forEach((S,w)=>g[S]=d[w]),n&&(g[n]=d.slice(o));let E=new Proxy(g,{get:(S,w)=>w in S?S[w]:f?.[w],set:(S,w,_)=>((w in S?S:f)[w]=_,!0),has:(S,w)=>w in S||(f?w in f:!1)});try{let S=e(E);return l?void 0:S}catch(S){if(S===B)return S[0];throw S}}});p("...",r=>(r=i(r),e=>Object.entries(r(e))));p("?.",(r,e)=>(r=i(r),F(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return F(o)?void 0:r(t)?.[o]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="?."){let n=i(r[1]),s=r[2];return F(s)?()=>{}:l=>n(l)?.[s]?.(...t(l))}if(r[0]==="?.[]"){let n=i(r[1]),s=i(r[2]);return l=>{let f=n(l),d=s(l);return F(d)?void 0:f?.[d]?.(...t(l))}}if(r[0]==="."){let n=i(r[1]),s=r[2];return F(s)?()=>{}:l=>n(l)?.[s]?.(...t(l))}if(r[0]==="[]"&&r.length===3){let n=i(r[1]),s=i(r[2]);return l=>{let f=n(l),d=s(l);return F(d)?void 0:f?.[d]?.(...t(l))}}let o=i(r);return n=>o(n)?.(...t(n))});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 o=>delete e(o)[t]}if(r[0]==="[]"){let e=i(r[1]),t=i(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});p("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>s=>n.map(l=>l(s)))(t.slice(1).map(i)):(n=>s=>[n(s)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var pr=Symbol("accessor");p("get",(r,e)=>(e=e?i(e):()=>{},t=>[[pr,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));p("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[pr,r,{set:function(n){let s=Object.create(o||{});s.this=this,s[e]=n,t(s)}}]]));var Xt=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);p("{}",(r,e)=>{if(e!==void 0)return;if(!Xt(r))return i(["{",r]);r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>i(typeof o=="string"?[":",o,o]:o));return o=>{let n={},s={};for(let l of t.flatMap(f=>f(o)))if(l[0]===pr){let[,f,d]=l;s[f]={...s[f],...d,configurable:!0,enumerable:!0}}else n[l[0]]=l[1];for(let l in s)Object.defineProperty(n,l,s[l]);return n}});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)]]));p("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):o.push(i(s));let n=Object.assign([...t],{raw:t});return s=>r(s)(n,...o.map(l=>l(s)))});p("function",(r,e,t)=>{t=t?i(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],n=null,s=-1,l=o[o.length-1];return Array.isArray(l)&&l[0]==="..."&&(s=o.length-1,n=l[1],o.length--),f=>{let d=(...g)=>{let E={};o.forEach((w,_)=>E[w]=g[_]),n&&(E[n]=g.slice(s));let S=new Proxy(E,{get:(w,_)=>_ in w?w[_]:f[_],set:(w,_,ye)=>((_ in w?w:f)[_]=ye,!0),has:(w,_)=>_ in w||_ in f});try{return t(S)}catch(w){if(w===B)return w[0];throw w}};return r&&(f[r]=d),d}});p("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});p("async",r=>{let e=i(r);return t=>{let o=e(t);return async function(...n){return o(...n)}}});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 Kt=Symbol("static"),Ht=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,o=>{let n=e?e(o):Object,s=function(...l){if(!(this instanceof s))return Ht("Class constructor must be called with new");let f=e?Reflect.construct(n,l,s):this;return s.prototype.__constructor__&&s.prototype.__constructor__.apply(f,l),f};if(Object.setPrototypeOf(s.prototype,n.prototype),Object.setPrototypeOf(s,n),t){let l=Object.create(o);l.super=n;let f=t(l),d=Array.isArray(f)&&typeof f[0]?.[0]=="string"?f:[];for(let[g,E]of d)g==="constructor"?s.prototype.__constructor__=E:s.prototype[g]=E}return r&&(o[r]=s),s}));p("static",r=>(r=i(r),e=>[[Kt,r(e)]]));p("//",(r,e)=>{let t=new RegExp(r,e||"");return()=>t});p("if",(r,e,t)=>(r=i(r),e=i(e),t=t!==void 0?i(t):null,o=>r(o)?e(o):t?.(o)));var U=Symbol("break"),K=Symbol("continue");p("while",(r,e)=>(r=i(r),e=i(e),t=>{let o;for(;r(t);)try{o=e(t)}catch(n){if(n===U)break;if(n===K)continue;if(n===B)return n[0];throw n}return o}));p("do",(r,e)=>(r=i(r),e=i(e),t=>{let o;do try{o=r(t)}catch(n){if(n===U)break;if(n===K)continue;if(n===B)return n[0];throw n}while(e(t));return o}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,o,n]=r;return t=t?i(t):null,o=o?i(o):()=>!0,n=n?i(n):null,e=i(e),s=>{let l;for(t?.(s);o(s);n?.(s))try{l=e(s)}catch(f){if(f===U)break;if(f===K)continue;if(f===B)return f[0];throw f}return l}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,o,n]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),t==="in")return Qt(o,n,e);if(t==="of")return jt(o,n,e)}});var jt=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,l=o?null:n[r];for(let f of e(n)){o?X(r,f,n):n[r]=f;try{s=t(n)}catch(d){if(d===U)break;if(d===K)continue;if(d===B)return d[0];throw d}}return o||(n[r]=l),s}},Qt=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,l=o?null:n[r];for(let f in e(n)){o?X(r,f,n):n[r]=f;try{s=t(n)}catch(d){if(d===U)break;if(d===K)continue;if(d===B)return d[0];throw d}}return o||(n[r]=l),s}};p("break",()=>()=>{throw U});p("continue",()=>()=>{throw K});p("return",r=>(r=r!==void 0?i(r):null,e=>{throw B[0]=r?.(e),B}));p("try",(r,...e)=>{r=r?i(r):null;let t=e.find(f=>f?.[0]==="catch"),o=e.find(f=>f?.[0]==="finally"),n=t?.[1],s=t?.[2]?i(t[2]):null,l=o?.[1]?i(o[1]):null;return f=>{let d;try{d=r?.(f)}catch(g){if(g===U||g===K||g===B)throw g;if(n!=null&&s){let E=n in f,S=f[n];f[n]=g;try{d=s(f)}finally{E?f[n]=S:delete f[n]}}else if(!s)throw g}finally{l?.(f)}return d}});p("throw",r=>(r=i(r),e=>{throw r(e)}));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 o=r(t),n=!1,s;for(let[f,d]of e)if(n||f===null||f(t)===o)for(n=!0,l=0;l<d.length;l++)try{s=d[l](t)}catch(g){if(g===U)return s;throw g}var l;return s}):t=>r(t)));p("import",()=>()=>{});p("export",()=>()=>{});p("from",(r,e)=>()=>{});p("as",(r,e)=>()=>{});p("default",r=>i(r));var he=new WeakMap,$t=(r,...e)=>typeof r=="string"?i(m(r)):he.get(r)||he.set(r,xt(r,e)).get(r),Ae=57344,xt=(r,e)=>{let t=r.reduce((s,l,f)=>s+(f?String.fromCharCode(Ae+f-1):"")+l,""),o=m(t),n=s=>{if(typeof s=="string"&&s.length===1){let l=s.charCodeAt(0)-Ae,f;if(l>=0&&l<e.length)return f=e[l],Wt(f)?f:[,f]}return Array.isArray(s)?s.map(n):s};return i(n(o))},Wt=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),zt=$t;export{mr as access,y as binary,i as compile,c as cur,zt as default,R as err,A as expr,x as group,Jt as id,u as idx,C as keyword,j as literal,Lr as loc,T as lookup,lr as nary,N as next,p as operator,ur as operators,v as parens,m as parse,Y as peek,$ as prec,P as seek,h as skip,a as space,fr as step,k as token,O as unary,I as word};
|
|
4
|
+
`,""+n}${l}${f}`)},Mr=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),N=(r,e=u,t)=>{for(;t=r(c.charCodeAt(u));)u+=t;return c.slice(e,u)},h=(r=1)=>c[u+=r],P=r=>u=r,A=(r=0,e)=>{let t,o,n;for(e&&m.enter?.(r,e);(t=a())&&t!==e&&(n=fr(o,r,t,A));)o=n;return e&&(t==e?(u++,m.exit?.(r,e)):R("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},fr=(r,e,t,o,n)=>(n=T[t])&&n(r,e)||(r?null:N(m.id)||null),a=r=>{for(;(r=c.charCodeAt(u))<=32;)u++;return r},Y=(r=u)=>{for(;c.charCodeAt(r)<=32;)r++;return c.charCodeAt(r)},qt=m.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,I=(r,e=r.length)=>c.substr(u,e)===r&&!m.id(c.charCodeAt(u+e)),v=()=>(h(),A(0,41)),T=[],$={},k=(r,e=32,t,o=r.charCodeAt(0),n=r.length,s=T[o],l=r.toUpperCase()!==r,f,d)=>(e=$[r]=!s&&$[r]||e,T[o]=(g,E,S,w=u)=>(f=S,(S?r==S:(n<2||r.charCodeAt(1)===c.charCodeAt(u+1)&&(n<3||c.substr(u,n)==r))&&(!l||!m.id(c.charCodeAt(u+n)))&&(f=S=r))&&E<e&&(u+=n,(d=t(g))?Mr(d,w):(u=w,f=0,!l&&!s&&!g&&R()),d)||s?.(g,E,f))),y=(r,e,t=!1)=>k(r,e,o=>o&&(n=>n&&[r,o,n])(A(e-(t?.5:0)))),O=(r,e,t)=>k(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),j=(r,e)=>k(r,200,t=>!t&&[,e]),lr=(r,e,t)=>k(r,e,(o,n)=>(n=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),n?.[0]===r?o.push(...n.slice(1)):o.push(n||null),o)),x=(r,e)=>k(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),mr=(r,e)=>k(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),C=(r,e,t,o=r.charCodeAt(0),n=r.length,s=T[o],l)=>T[o]=(f,d,g,E=u)=>!f&&(g?r==g:(n<2||c.substr(u,n)==r)&&(g=r))&&d<e&&!m.id(c.charCodeAt(u+n))&&(!m.prop||m.prop(u+n))&&(P(u+n),(l=t())?Mr(l,E):P(E),l)||s?.(f,d,g);Object.defineProperty(m,"space",{configurable:!0,enumerable:!0,get:()=>a,set:r=>a=r});Object.defineProperty(m,"step",{configurable:!0,enumerable:!0,get:()=>fr,set:r=>fr=r});var ur={},p=(r,e,t=ur[r])=>ur[r]=(...o)=>e(...o)||t?.(...o),i=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):ur[r[0]]?.(...r.slice(1))??R(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var q=46,W=48,b=57,Ce=69,we=101,Ee=43,Se=45,Z=95,Ur=110,ke=97,Ie=102,Te=65,Ne=70,Fr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),cr=r=>{let e=Fr(N(t=>t===q&&c.charCodeAt(u+1)!==q||t>=W&&t<=b||t===Z||((t===Ce||t===we)&&((t=c.charCodeAt(u+1))>=W&&t<=b||t===Ee||t===Se)?2:0)));return c.charCodeAt(u)===Ur?(h(),[,BigInt(e)]):(r=+e)!=r?R():[,r]},Re={2:r=>r===48||r===49||r===Z,8:r=>r>=48&&r<=55||r===Z,16:r=>r>=W&&r<=b||r>=ke&&r<=Ie||r>=Te&&r<=Ne||r===Z};m.number=null;T[q]=r=>!r&&c.charCodeAt(u+1)!==q&&cr();for(let r=W;r<=b;r++)T[r]=e=>e?void 0:cr();T[W]=r=>{if(r)return;let e=m.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[u+1]?.toLowerCase()===t[1]){h(2);let n=Fr(N(Re[o]));return c.charCodeAt(u)===Ur?(h(),[,BigInt("0"+t[1]+n)]):[,parseInt(n,o)]}}return cr()};var _e=92,Dr=34,Gr=39,Xr=117,Kr=120,Oe=123,Pe=125,Hr=10,ve=13,Be={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v",0:"\0"},jr=r=>r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:-1,Qr=r=>(e,t,o="",n=String.fromCharCode(r))=>{if(e||!m.string?.[n])return;h();let s=()=>{let l=c.charCodeAt(u+1);if(l===Hr)return 2;if(l===ve)return c.charCodeAt(u+2)===Hr?3:2;if(l===Kr||l===Xr&&c.charCodeAt(u+2)!==Oe){let f=l===Kr?2:4,d=0,g;for(let E=0;E<f;E++){if((g=jr(c.charCodeAt(u+2+E)))<0)return o+=c[u+1],2;d=d*16+g}return o+=String.fromCharCode(d),2+f}if(l===Xr){let f=0,d=u+3,g;for(;(g=jr(c.charCodeAt(d)))>=0;)f=f*16+g,d++;return d>u+3&&f<=1114111&&c.charCodeAt(d)===Pe?(o+=String.fromCodePoint(f),d-u+1):(o+=c[u+1],2)}return o+=Be[c[u+1]]||c[u+1],2};return N(l=>l-r&&(l!==_e?(o+=c[u],1):s())),c[u]===n?h():R("Bad string"),[,o]};T[Dr]=Qr(Dr);T[Gr]=Qr(Gr);m.string={'"':!0};var Le=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>y(r,Le,!0));var Me=30,Ue=40,Fe=140;O("!",Fe);y("||",Me);y("&&",Ue);var De=50,Ge=60,Xe=70,$r=100,Ke=140;y("|",De);y("&",Xe);y("^",Ge);y(">>",$r);y("<<",$r);O("~",Ke);var rr=90;y("<",rr);y(">",rr);y("<=",rr);y(">=",rr);var xr=80;y("==",xr);y("!=",xr);var Wr=110,dr=120,zr=140;y("+",Wr);y("-",Wr);y("*",dr);y("/",dr);y("%",dr);O("+",zr);O("-",zr);var er=150;k("++",er,r=>r?["++",r,null]:["++",A(er-1)]);k("--",er,r=>r?["--",r,null]:["--",A(er-1)]);var He=5,je=10;lr(",",je);lr(";",He,!0);var Qe=170;x("()",Qe);var ar=170;mr("[]",ar);y(".",ar);mr("()",ar);var $e=32,xe=m.space;m.comment??={"//":`
|
|
6
|
+
`,"/*":"*/"};var hr;m.space=()=>{hr||(hr=Object.entries(m.comment).map(([n,s])=>[n,s,n.charCodeAt(0)]));for(var r;r=xe();){for(var e=0,t;t=hr[e++];)if(r===t[2]&&c.substr(u,t[0].length)===t[0]){var o=u+t[0].length;if(t[1]===`
|
|
7
|
+
`)for(;c.charCodeAt(o)>=$e;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}P(o),r=0;break}if(r)return r}return r};var Jr=80;y("===",Jr);y("!==",Jr);var We=30;y("??",We);var ze=130,Je=20;y("**",ze,!0);y("**=",Je,!0);var Vr=90;y("in",Vr);y("of",Vr);var Ve=20,Ye=100;y(">>>",Ye);y(">>>=",Ve,!0);var Ar=20;y("||=",Ar,!0);y("&&=",Ar,!0);y("??=",Ar,!0);j("true",!0);j("false",!1);j("null",null);C("undefined",200,()=>[]);j("NaN",NaN);j("Infinity",1/0);var yr=20;k("?",yr,(r,e,t)=>r&&(e=A(yr-1))&&N(o=>o===58)&&(t=A(yr-1),["?",r,e,t]));var Ze=20;y("=>",Ze,!0);var qe=20;O("...",qe);var Yr=170;k("?.",Yr,(r,e)=>{if(!r)return;let t=a();return t===40?(h(),["?.()",r,A(0,41)||null]):t===91?(h(),["?.[]",r,A(0,93)]):(e=A(Yr),e?["?.",r,e]:void 0)});var z=140;O("typeof",z);O("void",z);O("delete",z);C("new",z,()=>I(".target")?(h(7),["new.target"]):["new",A(z)]);var be=20,Zr=200;m.prop=r=>Y(r)!==58;x("[]",Zr);x("{}",Zr);y(":",be-1,!0);var rt=170,tr=96,et=36,tt=123,ot=92,nt={n:`
|
|
8
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},qr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(u))!==tr;)t?t===ot?(h(),e+=nt[c[u]]||c[u],h()):t===et&&c.charCodeAt(u+1)===tt?(e&&r.push([,e]),e="",h(2),r.push(A(0,125))):(e+=c[u],h(),t=c.charCodeAt(u),t===tr&&e&&r.push([,e])):R("Unterminated template");return h(),r},it=T[tr];T[tr]=(r,e)=>r&&e<rt?m.asi&&m.newline?void 0:(h(),["``",r,...qr()]):r?it?.(r,e):(h(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(qr()));m.string["'"]=!0;m.number={"0x":16,"0b":2,"0o":8};var st=92,pt=117,ft=123,ut=125,lt=183,mt=m.id,br=r=>r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102,ct=(r=u+2,e,t=0,o=0)=>{if(c.charCodeAt(u)!==st||c.charCodeAt(u+1)!==pt)return 0;if(c.charCodeAt(r)===ft){for(;br(e=c.charCodeAt(++r));)t=t*16+(e<=57?e-48:(e&31)+9);return r>u+3&&t<=1114111&&c.charCodeAt(r)===ut?r-u+1:0}for(;o<4&&br(c.charCodeAt(r+o));)o++;return o===4?6:0};m.id=r=>mt(r)||r===lt||ct();var gr=5,dt=10,Cr=r=>{let e=u,t=A(dt-1);return t==null?r:r==="let"&&(t==="in"||t==="of")?(P(e),r):t[0]==="in"||t[0]==="of"?[t[0],[r,t[1]],t[2]]:t[0]===","?[r,...t.slice(1)]:[r,t]};C("let",gr+1,()=>Cr("let"));C("const",gr+1,()=>Cr("const"));C("var",gr+1,()=>Cr("var"));var or=5,at=59,L=()=>(a()===123||R("Expected {"),h(),A(or-.5,125)||null),F=()=>a()!==123?A(or+.5):(h(),A(or-.5,125)||null),ht=()=>{let r=u;return a()===at&&h(),a(),I("else")?(h(4),!0):(P(r),!1)};C("if",or+1,()=>{a();let r=["if",v(),F()];return ht()&&r.push(F()),r});var At=200;C("function",At,()=>{a();let r=!1;c[u]==="*"&&(r=!0,h(),a());let e=N(m.id);return e&&a(),r?["function*",e,v()||null,L()]:["function",e,v()||null,L()]});var nr=140,wr=20;O("await",nr);C("yield",nr,()=>(a(),c[u]==="*"?(h(),a(),["yield*",A(wr)]):["yield",A(wr)]));C("async",nr,()=>{if(a(),I("function"))return["async",A(nr)];let r=A(wr-.5);return r&&["async",r]});var Er=200,yt=140,gt=90;O("static",yt);y("instanceof",gt);k("#",Er,r=>{if(r)return;let e=N(m.id);return e?"#"+e:void 0});C("class",Er,()=>{a();let r=N(m.id)||null;if(r==="extends")r=null,a();else{if(a(),!I("extends"))return["class",r,null,L()];h(7),a()}return["class",r,A(Er),L()]});var Ct=140,Sr=47,wt=92,Et=r=>r===wt?2:r&&r!==Sr,St=r=>r===103||r===105||r===109||r===115||r===117||r===121;k("/",Ct,r=>{if(r)return;let e=c.charCodeAt(u);if(e===Sr||e===42||e===43||e===63||e===61)return;let t=N(Et);c.charCodeAt(u)===Sr||R("Unterminated regex"),h();let o=N(St);try{new RegExp(t,o)}catch(n){R("Invalid regex: "+n.message)}return o?["//",t,o]:["//",t]});var H=5,J=125,V=59;C("while",H+1,()=>(a(),["while",v(),F()]));C("do",H+1,()=>(r=>(a(),h(5),a(),["do",r,v()]))(F()));C("for",H+1,()=>(a(),I("await")?(h(5),a(),["for await",v(),F()]):["for",v(),F()]));C("break",H+1,()=>{m.asi&&(m.newline=!1);let r=u;a();let e=c.charCodeAt(u);if(!e||e===J||e===V||m.newline)return["break"];let t=N(m.id);if(!t)return["break"];a();let o=c.charCodeAt(u);return!o||o===J||o===V||m.newline?["break",t]:(P(r),["break"])});C("continue",H+1,()=>{m.asi&&(m.newline=!1);let r=u;a();let e=c.charCodeAt(u);if(!e||e===J||e===V||m.newline)return["continue"];let t=N(m.id);if(!t)return["continue"];a();let o=c.charCodeAt(u);return!o||o===J||o===V||m.newline?["continue",t]:(P(r),["continue"])});C("return",H+1,()=>{m.asi&&(m.newline=!1);let r=a();return!r||r===J||r===V||m.newline?["return"]:["return",A(H)]});var kr=5;C("try",kr+1,()=>{let r=["try",L()];return a(),I("catch")&&(h(5),a(),r.push(["catch",Y()===40?v():null,L()])),a(),I("finally")&&(h(7),r.push(["finally",L()])),r});C("throw",kr+1,()=>{if(m.asi&&(m.newline=!1),a(),m.newline)throw SyntaxError("Unexpected newline after throw");return["throw",A(kr)]});var te=5,kt=20,re=58,It=59,oe=125,Ir=0,ne=(r,e=r.length,t=r.charCodeAt(0),o=T[t])=>T[t]=(n,s,l)=>I(r)&&!n&&Ir||o?.(n,s,l);ne("case");ne("default");var ee=r=>{let e=[];for(;(r=a())!==oe&&!I("case")&&!I("default");){if(r===It){h();continue}e.push(A(te-.5))||R()}return e.length>1?[";",...e]:e[0]||null},Tt=()=>{a()===123||R("Expected {"),h(),Ir++;let r=[];try{for(;a()!==oe;)if(I("case")){P(u+4),a();let e=A(kt-.5);a()===re&&h(),r.push(["case",e,ee()])}else I("default")?(P(u+7),a()===re&&h(),r.push(["default",ee()])):R("Expected case or default")}finally{Ir--}return h(),r};C("switch",te+1,()=>a()===40&&["switch",v(),...Tt()]);var ie=5;C("debugger",ie+1,()=>["debugger"]);C("with",ie+1,()=>(a(),["with",v(),F()]));var Tr=5,Q=10,se=42,Nt=T[se];T[se]=(r,e)=>r?Nt?.(r,e):(h(),"*");k("from",Q+1,r=>r?r[0]!=="="&&r[0]!==","&&(a(),["from",r,A(Q+1)]):!1);k("as",Q+2,r=>r?(a(),["as",r,A(Q+2)]):!1);C("import",Tr,()=>I(".meta")?(h(5),["import.meta"]):["import",A(Q)]);C("export",Tr,()=>(a(),I("default")?(h(7),["export",["default",A(Q)]]):["export",A(Tr)]));var Nr=20,Rt=10,_t=13,Ot=40,pe=41,fe=123,ue=125,Pt=(r,e)=>{for(;r<e;){let t=c.charCodeAt(r++);if(t===Rt||t===_t)return!0}return!1},le=r=>e=>{if(e)return;let t=u;if(a(),m.semi||Pt(t,u))return!1;let o=N(m.id);if(!o||(a(),c.charCodeAt(u)!==Ot))return!1;h();let n=A(0,pe);return a(),c.charCodeAt(u)!==fe?!1:(h(),[r,o,n,A(0,ue)])};k("get",Nr-1,le("get"));k("set",Nr-1,le("set"));k("(",Nr-1,r=>{if(!r||typeof r!="string")return;let e=A(0,pe)||null;if(a(),c.charCodeAt(u)===fe)return h(),[":",r,["=>",["()",e],A(0,ue)||null]]});m.comment["#!"]=`
|
|
9
|
+
`;var ce=32,Pr=10,vt=59,Bt=125,Lt=91,Mt=40,Or=$.asi??$[";"],Ut=m._baseSpace??=m.space,Ft=m._baseStep??=m.step,Rr=r=>Array.isArray(r)||typeof r=="string",Dt=(r,e)=>{for(;(e=c.charCodeAt(r))<=ce;){if(e===Pr)return!0;r++}return!1},Gt=(r=u,e)=>{for(;r-- >0&&(e=c.charCodeAt(r))<=ce;)if(e===Pr)return!0;return!1};m.space=(r,e)=>{for(;;){for(e=u,r=Ut();e<u;)if(c.charCodeAt(e++)===Pr){m.newline=!0;break}if(r===vt&&Dt(u+1)){P(u+1),m.newline=m.semi=!0;continue}return r}};m.enter=()=>m.newline=m.semi=!1;m.exit=(r,e)=>{e===Bt&&(m.newline=!0,m.semi=!1)};m.step=(r,e,t,o)=>{if(m.semi&&e>=Or)return!1;if(r&&!Rr(r))return null;if(Rr(r)&&(m.semi||(t===Lt||t===Mt)&&Gt()))return me(r,e,o)??null;let n=m.newline;return Ft(r,e,t,o)??(Rr(r)&&n?me(r,e,o)??null:null)};var _r=0,Xt=2e3,me=m.asi=(r,e,t,o,n)=>{if(e>=Or||_r>=Xt)return;m.semi=!1;let s=u;_r++;try{o=t(Or-.5)}finally{_r--}if(!(!o||u===s))return n=o?.[0]===";"?o.slice(1):[o],r?.[0]===";"?(r.push(...n),r):[";",r,...n]};var ae=(r,e,t,o)=>typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="()"&&r.length===2?ae(r[1],e):(()=>{throw Error("Invalid assignment target")})(),de={"=":(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 de)p(r,(e,t)=>(t=i(t),ae(e,(o,n,s)=>de[r](o,n,t(s)))));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=>(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)));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)));p("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(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)=>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 vr=(r,e,t,o)=>typeof r=="string"?n=>e(n,r):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n))):r[0]==="()"&&r.length===2?vr(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>vr(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));p("--",(r,e)=>vr(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var he=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)t=o(e);return t});p(",",he);p(";",he);var D=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",ir=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]),o=>t(o)):(t=i(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&ir("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return D(o)?void 0:r(t)[o]}));p(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],D(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?ir("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&ir("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return Br(r,(n,s,l)=>n[s](...o(l)))});var M=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&M(r[1])||r[0]==="{}"),Br=(r,e,t,o)=>r==null?ir("Empty ()"):r[0]==="()"&&r.length==2?Br(r[1],e):typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="?."?(t=i(r[1]),o=r[2],n=>{let s=t(n);return s==null?void 0:e(s,o,n)}):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="?.[]"?(t=i(r[1]),o=i(r[2]),n=>{let s=t(n);return s==null?void 0:e(s,o(n),n)}):(r=i(r),n=>e([r(n)],0,n)),G=Br;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 Kt=r=>{throw Error(r)};p("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));p("**=",(r,e)=>(M(r)||Kt("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]**=e(n))));p("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var Ht=r=>{throw Error(r)};p(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(M(r)||Ht("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]>>>=e(n))));var jt=r=>r[0]?.[0]===","?r[0].slice(1):r,X=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r,s=jt(n);if(o==="{}"){let l=[];for(let f of s){if(Array.isArray(f)&&f[0]==="..."){let w={};for(let _ in e)l.includes(_)||(w[_]=e[_]);t[f[1]]=w;break}let d,g,E;typeof f=="string"?d=g=f:f[0]==="="?(typeof f[1]=="string"?d=g=f[1]:[,d,g]=f[1],E=f[2]):[,d,g]=f,l.push(d);let S=e[d];S===void 0&&E&&(S=i(E)(t)),X(g,S,t)}}else if(o==="[]"){let l=0;for(let f of s){if(f===null){l++;continue}if(Array.isArray(f)&&f[0]==="..."){t[f[1]]=e.slice(l);break}let d=f,g;Array.isArray(f)&&f[0]==="="&&([,d,g]=f);let E=e[l++];E===void 0&&g&&(E=i(g)(t)),X(d,E,t)}}},Lr=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,o]=e,n=i(o);return typeof t=="string"?s=>{s[t]=n(s)}:s=>X(t,n(s),s)}return i(e)}),e=>{for(let t of r)t(e)});p("let",Lr);p("const",Lr);p("var",Lr);var sr=r=>{throw Error(r)};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"?o=>{o[t]=e(o)}:o=>X(t,e(o),o)}return M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]=e(n))});p("||=",(r,e)=>(M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]||=e(n))));p("&&=",(r,e)=>(M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]&&=e(n))));p("??=",(r,e)=>(M(r)||sr("Invalid assignment target"),e=i(e),G(r,(t,o,n)=>t[o]??=e(n))));p("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var B=[];p("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r;let t=r?r[0]===","?r.slice(1):[r]:[],o=-1,n=null,s=t[t.length-1];Array.isArray(s)&&s[0]==="..."&&(o=t.length-1,n=s[1],t.length--);let l=e?.[0]==="{}";return e=i(l?["{",e[1]]:e),f=>(...d)=>{let g={};t.forEach((S,w)=>g[S]=d[w]),n&&(g[n]=d.slice(o));let E=new Proxy(g,{get:(S,w)=>w in S?S[w]:f?.[w],set:(S,w,_)=>((w in S?S:f)[w]=_,!0),has:(S,w)=>w in S||(f?w in f:!1)});try{let S=e(E);return l?void 0:S}catch(S){if(S===B)return S[0];throw S}}});p("...",r=>(r=i(r),e=>Object.entries(r(e))));p("?.",(r,e)=>(r=i(r),D(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return D(o)?void 0:r(t)?.[o]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="?."){let n=i(r[1]),s=r[2];return D(s)?()=>{}:l=>n(l)?.[s]?.(...t(l))}if(r[0]==="?.[]"){let n=i(r[1]),s=i(r[2]);return l=>{let f=n(l),d=s(l);return D(d)?void 0:f?.[d]?.(...t(l))}}if(r[0]==="."){let n=i(r[1]),s=r[2];return D(s)?()=>{}:l=>n(l)?.[s]?.(...t(l))}if(r[0]==="[]"&&r.length===3){let n=i(r[1]),s=i(r[2]);return l=>{let f=n(l),d=s(l);return D(d)?void 0:f?.[d]?.(...t(l))}}let o=i(r);return n=>o(n)?.(...t(n))});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 o=>delete e(o)[t]}if(r[0]==="[]"){let e=i(r[1]),t=i(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});p("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>s=>n.map(l=>l(s)))(t.slice(1).map(i)):(n=>s=>[n(s)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var pr=Symbol("accessor");p("get",(r,e)=>(e=e?i(e):()=>{},t=>[[pr,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));p("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[pr,r,{set:function(n){let s=Object.create(o||{});s.this=this,s[e]=n,t(s)}}]]));var Qt=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);p("{}",(r,e)=>{if(e!==void 0)return;if(!Qt(r))return i(["{",r]);r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>i(typeof o=="string"?[":",o,o]:o));return o=>{let n={},s={};for(let l of t.flatMap(f=>f(o)))if(l[0]===pr){let[,f,d]=l;s[f]={...s[f],...d,configurable:!0,enumerable:!0}}else n[l[0]]=l[1];for(let l in s)Object.defineProperty(n,l,s[l]);return n}});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)]]));p("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):o.push(i(s));let n=Object.assign([...t],{raw:t});return s=>r(s)(n,...o.map(l=>l(s)))});p("function",(r,e,t)=>{t=t?i(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],n=null,s=-1,l=o[o.length-1];return Array.isArray(l)&&l[0]==="..."&&(s=o.length-1,n=l[1],o.length--),f=>{let d=(...g)=>{let E={};o.forEach((w,_)=>E[w]=g[_]),n&&(E[n]=g.slice(s));let S=new Proxy(E,{get:(w,_)=>_ in w?w[_]:f[_],set:(w,_,ge)=>((_ in w?w:f)[_]=ge,!0),has:(w,_)=>_ in w||_ in f});try{return t(S)}catch(w){if(w===B)return w[0];throw w}};return r&&(f[r]=d),d}});p("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});p("async",r=>{let e=i(r);return t=>{let o=e(t);return async function(...n){return o(...n)}}});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 $t=Symbol("static"),xt=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,o=>{let n=e?e(o):Object,s=function(...l){if(!(this instanceof s))return xt("Class constructor must be called with new");let f=e?Reflect.construct(n,l,s):this;return s.prototype.__constructor__&&s.prototype.__constructor__.apply(f,l),f};if(Object.setPrototypeOf(s.prototype,n.prototype),Object.setPrototypeOf(s,n),t){let l=Object.create(o);l.super=n;let f=t(l),d=Array.isArray(f)&&typeof f[0]?.[0]=="string"?f:[];for(let[g,E]of d)g==="constructor"?s.prototype.__constructor__=E:s.prototype[g]=E}return r&&(o[r]=s),s}));p("static",r=>(r=i(r),e=>[[$t,r(e)]]));p("//",(r,e)=>{let t=new RegExp(r,e||"");return()=>t});p("if",(r,e,t)=>(r=i(r),e=i(e),t=t!==void 0?i(t):null,o=>r(o)?e(o):t?.(o)));var U=Symbol("break"),K=Symbol("continue");p("while",(r,e)=>(r=i(r),e=i(e),t=>{let o;for(;r(t);)try{o=e(t)}catch(n){if(n===U)break;if(n===K)continue;if(n===B)return n[0];throw n}return o}));p("do",(r,e)=>(r=i(r),e=i(e),t=>{let o;do try{o=r(t)}catch(n){if(n===U)break;if(n===K)continue;if(n===B)return n[0];throw n}while(e(t));return o}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,o,n]=r;return t=t?i(t):null,o=o?i(o):()=>!0,n=n?i(n):null,e=i(e),s=>{let l;for(t?.(s);o(s);n?.(s))try{l=e(s)}catch(f){if(f===U)break;if(f===K)continue;if(f===B)return f[0];throw f}return l}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,o,n]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),t==="in")return zt(o,n,e);if(t==="of")return Wt(o,n,e)}});var Wt=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,l=o?null:n[r];for(let f of e(n)){o?X(r,f,n):n[r]=f;try{s=t(n)}catch(d){if(d===U)break;if(d===K)continue;if(d===B)return d[0];throw d}}return o||(n[r]=l),s}},zt=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,l=o?null:n[r];for(let f in e(n)){o?X(r,f,n):n[r]=f;try{s=t(n)}catch(d){if(d===U)break;if(d===K)continue;if(d===B)return d[0];throw d}}return o||(n[r]=l),s}};p("break",()=>()=>{throw U});p("continue",()=>()=>{throw K});p("return",r=>(r=r!==void 0?i(r):null,e=>{throw B[0]=r?.(e),B}));p("try",(r,...e)=>{r=r?i(r):null;let t=e.find(f=>f?.[0]==="catch"),o=e.find(f=>f?.[0]==="finally"),n=t?.[1],s=t?.[2]?i(t[2]):null,l=o?.[1]?i(o[1]):null;return f=>{let d;try{d=r?.(f)}catch(g){if(g===U||g===K||g===B)throw g;if(n!=null&&s){let E=n in f,S=f[n];f[n]=g;try{d=s(f)}finally{E?f[n]=S:delete f[n]}}else if(!s)throw g}finally{l?.(f)}return d}});p("throw",r=>(r=i(r),e=>{throw r(e)}));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 o=r(t),n=!1,s;for(let[f,d]of e)if(n||f===null||f(t)===o)for(n=!0,l=0;l<d.length;l++)try{s=d[l](t)}catch(g){if(g===U)return s;throw g}var l;return s}):t=>r(t)));p("import",()=>()=>{});p("export",()=>()=>{});p("from",(r,e)=>()=>{});p("as",(r,e)=>()=>{});p("default",r=>i(r));var Ae=new WeakMap,Jt=(r,...e)=>typeof r=="string"?i(m(r)):Ae.get(r)||Ae.set(r,Vt(r,e)).get(r),ye=57344,Vt=(r,e)=>{let t=r.reduce((s,l,f)=>s+(f?String.fromCharCode(ye+f-1):"")+l,""),o=m(t),n=s=>{if(typeof s=="string"&&s.length===1){let l=s.charCodeAt(0)-ye,f;if(l>=0&&l<e.length)return f=e[l],Yt(f)?f:[,f]}return Array.isArray(s)?s.map(n):s};return i(n(o))},Yt=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Zt=Jt;export{mr as access,y as binary,i as compile,c as cur,Zt as default,R as err,A as expr,x as group,qt as id,u as idx,C as keyword,j as literal,Mr as loc,T as lookup,lr as nary,N as next,p as operator,ur as operators,v as parens,m as parse,Y as peek,$ as prec,P as seek,h as skip,a as space,fr as step,k as token,O as unary,I as word};
|