subscript 10.5.0 → 10.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/feature/loop.js +24 -3
- package/feature/var.js +2 -2
- package/jessie.min.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,29 +122,29 @@ subscript('constructor.constructor("alert(1)")()')({})
|
|
|
122
122
|
|
|
123
123
|
## Performance
|
|
124
124
|
|
|
125
|
-
Parsing `a + b * c - d / e + f.g[0](h) + i.j`, 30k iterations:
|
|
125
|
+
Parsing `a + b * c - d / e + f.g[0](h) + i.j`, 30k iterations — each iteration parses an unseen source, so source-keyed compile caches (`new Function`, angular-expressions) don't help:
|
|
126
126
|
|
|
127
127
|
```
|
|
128
128
|
Parse:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
subscript 26ms
|
|
130
|
+
justin 35ms
|
|
131
|
+
cel-js 45ms
|
|
132
|
+
jsep 46ms
|
|
133
|
+
jessie 51ms ← JS subset (statements + functions)
|
|
134
|
+
expr-eval 74ms
|
|
135
|
+
oxc 86ms ← full JS parser (native Rust)
|
|
136
|
+
mathjs 156ms
|
|
137
|
+
new Function 166ms
|
|
138
|
+
jexl 304ms
|
|
139
|
+
angular-expr 48s
|
|
140
140
|
|
|
141
141
|
Eval:
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
new Function 0.2ms
|
|
143
|
+
subscript 1.7ms
|
|
144
144
|
cel-js 10ms
|
|
145
|
-
mathjs
|
|
146
|
-
expression-eval
|
|
147
|
-
angular-expr
|
|
145
|
+
mathjs 10ms
|
|
146
|
+
expression-eval 24ms
|
|
147
|
+
angular-expr 44ms
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
Run via `node --import ./test/https-loader.js test/benchmark.js`.
|
package/feature/loop.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Loops: while, do-while, for, for await, break, continue, return - parse half
|
|
2
|
-
import { expr, skip, parse, word, keyword, parens,
|
|
2
|
+
import { expr, skip, parse, word, keyword, parens, idx, next, seek, prec } from '../parse.js';
|
|
3
3
|
import { body } from './if.js';
|
|
4
4
|
|
|
5
5
|
const STATEMENT = 5, CBRACE = 125, SEMI = 59;
|
|
@@ -7,15 +7,36 @@ const STATEMENT = 5, CBRACE = 125, SEMI = 59;
|
|
|
7
7
|
keyword('while', STATEMENT + 1, () => (parse.space(), ['while', parens(), body()]));
|
|
8
8
|
keyword('do', STATEMENT + 1, b => (b = body(), parse.space(), skip(5), parse.space(), ['do', b, parens()]));
|
|
9
9
|
|
|
10
|
+
// A for-in/of head is not a plain expression: the grammar makes everything right of
|
|
11
|
+
// the keyword the iteration source, while expression precedence binds relational
|
|
12
|
+
// `in`/`of` tighter than assignment/sequence/ternary/logical — `for (k in o = x)`
|
|
13
|
+
// would parse as `(k in o) = x`, stranding the wrappers around the whole head.
|
|
14
|
+
// Splice them back: descend the leftmost spine through looser-than-`in` ops to the
|
|
15
|
+
// in/of node and swap it for its own right operand.
|
|
16
|
+
const DECL = { let: 1, const: 1, var: 1 };
|
|
17
|
+
const head = (h, spine = h, parent) => {
|
|
18
|
+
// decl: `for (let k in o)` / `for (let k in o = x)` land as [let [in k o]] /
|
|
19
|
+
// [let [= [in k o] x]] — re-associate the declarator, keep the declaration
|
|
20
|
+
// on the iteration variable. A comma in the source (`let x in null, {k: 0}`)
|
|
21
|
+
// parses as EXTRA DECLARATORS ([let [in x null] {k:0}]) — those trailing
|
|
22
|
+
// "declarators" are really comma-continuations of the source expression.
|
|
23
|
+
if (DECL[h?.[0]] && Array.isArray(h[1]))
|
|
24
|
+
return (spine = head(h[1]))?.[0] === 'in' || spine?.[0] === 'of'
|
|
25
|
+
? [spine[0], [h[0], spine[1]], h.length > 2 ? [',', spine[2], ...h.slice(2)] : spine[2]] : h;
|
|
26
|
+
while (Array.isArray(spine) && prec[spine[0]] < prec.in && !DECL[spine[0]]) parent = spine, spine = spine[1];
|
|
27
|
+
return parent && Array.isArray(spine) && (spine[0] === 'in' || spine[0] === 'of')
|
|
28
|
+
? (parent[1] = spine[2], [spine[0], spine[1], h]) : h;
|
|
29
|
+
};
|
|
30
|
+
|
|
10
31
|
// for / for await
|
|
11
32
|
keyword('for', STATEMENT + 1, () => {
|
|
12
33
|
parse.space();
|
|
13
34
|
// for await (x of y)
|
|
14
35
|
if (word('await')) {
|
|
15
36
|
skip(5);
|
|
16
|
-
return (parse.space(), ['for await', parens(), body()]);
|
|
37
|
+
return (parse.space(), ['for await', head(parens()), body()]);
|
|
17
38
|
}
|
|
18
|
-
return ['for', parens(), body()];
|
|
39
|
+
return ['for', head(parens()), body()];
|
|
19
40
|
});
|
|
20
41
|
|
|
21
42
|
keyword('break', STATEMENT + 1, () => {
|
package/feature/var.js
CHANGED
|
@@ -18,13 +18,13 @@ const STATEMENT = 5, SEQ = 10;
|
|
|
18
18
|
// list. If nothing parses, the keyword falls back to identifier
|
|
19
19
|
// (`{let}`, `(let)`, bare `let`, etc.). For `for (let in/of obj)`, expr reads
|
|
20
20
|
// `in`/`of` as a bare identifier — backtrack so the binary op picks `let` up.
|
|
21
|
+
// A for-in/of head keeps its in/of inside the declarator ([let [in x o]]);
|
|
22
|
+
// loop.js re-associates it to the documented shape.
|
|
21
23
|
const decl = kw => {
|
|
22
24
|
const from = idx;
|
|
23
25
|
const node = expr(SEQ - 1);
|
|
24
26
|
if (node == null) return kw;
|
|
25
27
|
if (kw === 'let' && (node === 'in' || node === 'of')) return seek(from), kw;
|
|
26
|
-
if (node[0] === 'in' || node[0] === 'of')
|
|
27
|
-
return [node[0], [kw, node[1]], node[2]];
|
|
28
28
|
if (node[0] === ',') return [kw, ...node.slice(1)];
|
|
29
29
|
return [kw, node];
|
|
30
30
|
};
|
package/jessie.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var l,
|
|
2
|
-
`),o=t.pop(),n=
|
|
3
|
-
${n}${
|
|
4
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v",0:"\0"},
|
|
5
|
-
`,"/*":"*/"};s.space=()=>{for(var r,e,t,o,n;r=
|
|
6
|
-
`?n:n+o.length),r=0;break}if(r)return r}return r};var
|
|
7
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
8
|
-
`;var we=32,Rr=10,qt=59,bt=125,he=91,Ae=40,rr=D.asi??D[";"],ro=s._baseSpace??=s.space,eo=s._baseStep??=s.step,Tr=r=>Array.isArray(r)||typeof r=="string",to=(D[";"]??5)+1,Ir=r=>Array.isArray(r)&&(D[r[0]]<=to||r[0]==="{}"&&Ir(r[1])),oo=(r,e)=>{for(;(e=c.charCodeAt(r))<=we;){if(e===Rr)return!0;r++}return!1},no=(r=l,e)=>{for(;r-- >0&&(e=c.charCodeAt(r))<=we;)if(e===Rr)return!0;return!1};s.space=(r,e)=>{for(;;){for(e=l,r=ro();e<l;)if(c.charCodeAt(e++)===Rr){s.newline=!0;break}if(r===qt&&oo(l+1)){_(l+1),s.newline=s.semi=!0;continue}return r}};s.enter=()=>s.newline=s.semi=!1;s.exit=(r,e)=>{e===bt&&(s.newline=!0,s.semi=!1)};s.step=(r,e,t,o)=>{if(s.semi&&e>=rr)return!1;if(r&&!Tr(r))return null;if(Tr(r)){let p=(t===he||t===Ae)&&no();if(s.semi||t===he&&(p||Ir(r))||t===Ae&&(Ir(r)||p&&e>=rr))return ye(r,e,o)??null}let n=s.newline;return eo(r,e,t,o)??(Tr(r)&&n?ye(r,e,o)??null:null)};var Nr=0,io=2e3,ye=s.asi=(r,e,t,o,n)=>{if(e>=rr||Nr>=io)return;s.semi=!1;let p=l;Nr++;try{o=t(rr-.5)}finally{Nr--}if(!(!o||l===p))return n=o?.[0]===";"?o.slice(1):[o],r?.[0]===";"?(r.push(...n),r):[";",r,...n]};var ge=(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?ge(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)f(r,(e,t)=>(t=i(t),ge(e,(o,n,p)=>Ce[r](o,n,t(p)))));f("!",r=>(r=i(r),e=>!r(e)));f("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));f("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));f("~",r=>(r=i(r),e=>~r(e)));f("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));f("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));f("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));f(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));f("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));f(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));f("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));f(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));f("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));f("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));f("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));f("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));f("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));f("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));f("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));f("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var Or=(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?Or(r[1],e):(()=>{throw Error("Invalid increment target")})();f("++",(r,e)=>Or(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));f("--",(r,e)=>Or(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Ee=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)t=o(e);return t});f(",",Ee);f(";",Ee);var Q=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",er=r=>{throw Error(r)};f("[]",(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&&er("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return Q(o)?void 0:r(t)[o]}));f(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],Q(e)?()=>{}:t=>r(t)[e]));f("()",(r,e)=>{if(e===void 0)return r==null?er("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(p=>p==null||t(p));t(e)&&er("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(p=>p(n))):(e=i(e),n=>[e(n)]):()=>[];return _r(r,(n,p,m)=>n[p](...o(m)))});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]==="{}"),_r=(r,e,t,o)=>r==null?er("Empty ()"):r[0]==="()"&&r.length==2?_r(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 p=t(n);return p==null?void 0:e(p,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 p=t(n);return p==null?void 0:e(p,o(n),n)}):(r=i(r),n=>e([r(n)],0,n)),K=_r;f("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));f("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));f("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var so=r=>{throw Error(r)};f("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));f("**=",(r,e)=>(v(r)||so("Invalid assignment target"),e=i(e),K(r,(t,o,n)=>t[o]**=e(n))));f("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var po=r=>{throw Error(r)};f(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));f(">>>=",(r,e)=>(v(r)||po("Invalid assignment target"),e=i(e),K(r,(t,o,n)=>t[o]>>>=e(n))));var fo=r=>r[0]?.[0]===","?r[0].slice(1):r,G=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r,p=fo(n);if(o==="{}"){let m=[];for(let u of p){if(Array.isArray(u)&&u[0]==="..."){let C={};for(let R in e)m.includes(R)||(C[R]=e[R]);t[u[1]]=C;break}let a,y,T;typeof u=="string"?a=y=u:u[0]==="="?(typeof u[1]=="string"?a=y=u[1]:[,a,y]=u[1],T=u[2]):[,a,y]=u,m.push(a);let k=e[a];k===void 0&&T&&(k=i(T)(t)),G(y,k,t)}}else if(o==="[]"){let m=0;for(let u of p){if(u===null){m++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(m);break}let a=u,y;Array.isArray(u)&&u[0]==="="&&([,a,y]=u);let T=e[m++];T===void 0&&y&&(T=i(y)(t)),G(a,T,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"?p=>{p[t]=n(p)}:p=>G(t,n(p),p)}return i(e)}),e=>{for(let t of r)t(e)});f("let",Lr);f("const",Lr);f("var",Lr);var tr=r=>{throw Error(r)};f("=",(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=>G(t,e(o),o)}return v(r)||tr("Invalid assignment target"),e=i(e),K(r,(t,o,n)=>t[o]=e(n))});f("||=",(r,e)=>(v(r)||tr("Invalid assignment target"),e=i(e),K(r,(t,o,n)=>t[o]||=e(n))));f("&&=",(r,e)=>(v(r)||tr("Invalid assignment target"),e=i(e),K(r,(t,o,n)=>t[o]&&=e(n))));f("??=",(r,e)=>(v(r)||tr("Invalid assignment target"),e=i(e),K(r,(t,o,n)=>t[o]??=e(n))));f("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var P=[];f("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r;let t=r?r[0]===","?r.slice(1):[r]:[],o=-1,n=null,p=t[t.length-1];Array.isArray(p)&&p[0]==="..."&&(o=t.length-1,n=p[1],t.length--);let m=e?.[0]==="{}";return e=i(m?["{",e[1]]:e),u=>(...a)=>{let y={};t.forEach((k,C)=>y[k]=a[C]),n&&(y[n]=a.slice(o));let T=new Proxy(y,{get:(k,C)=>C in k?k[C]:u?.[C],set:(k,C,R)=>((C in k?k:u)[C]=R,!0),has:(k,C)=>C in k||(u?C in u:!1)});try{let k=e(T);return m?void 0:k}catch(k){if(k===P)return k[0];throw k}}});f("...",r=>(r=i(r),e=>Object.entries(r(e))));f("?.",(r,e)=>(r=i(r),Q(e)?()=>{}:t=>r(t)?.[e]));f("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return Q(o)?void 0:r(t)?.[o]}));f("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(p=>p(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="."||r[0]==="?."){let n=i(r[1]),p=r[2];return Q(p)?()=>{}:m=>n(m)?.[p]?.(...t(m))}if((r[0]==="[]"||r[0]==="?.[]")&&r.length===3){let n=i(r[1]),p=i(r[2]);return m=>{let u=p(m);return Q(u)?void 0:n(m)?.[u]?.(...t(m))}}let o=i(r);return n=>o(n)?.(...t(n))});f("typeof",r=>(r=i(r),e=>typeof r(e)));f("void",r=>(r=i(r),e=>(r(e),void 0)));f("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});f("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>p=>n.map(m=>m(p)))(t.slice(1).map(i)):(n=>p=>[n(p)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var or=Symbol("accessor");f("get",(r,e)=>(e=e?i(e):()=>{},t=>[[or,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));f("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[or,r,{set:function(n){let p=Object.create(o||{});p.this=this,p[e]=n,t(p)}}]]));var lo=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);f("{}",(r,e)=>{if(e!==void 0)return;if(!lo(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={},p={};for(let m of t.flatMap(u=>u(o)))if(m[0]===or){let[,u,a]=m;p[u]={...p[u],...a,configurable:!0,enumerable:!0}}else n[m[0]]=m[1];for(let m in p)Object.defineProperty(n,m,p[m]);return n}});f("{",r=>(r=r?i(r):()=>{},e=>r(Object.create(e))));f(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));f("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));f("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):o.push(i(p));let n=Object.assign([...t],{raw:t});return p=>r(p)(n,...o.map(m=>m(p)))});f("function",(r,e,t)=>{t=t?i(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],n=null,p=-1,m=o[o.length-1];return Array.isArray(m)&&m[0]==="..."&&(p=o.length-1,n=m[1],o.length--),u=>{let a=(...y)=>{let T={};o.forEach((C,R)=>T[C]=y[R]),n&&(T[n]=y.slice(p));let k=new Proxy(T,{get:(C,R)=>R in C?C[R]:u[R],set:(C,R,Te)=>((R in C?C:u)[R]=Te,!0),has:(C,R)=>R in C||R in u});try{return t(k)}catch(C){if(C===P)return C[0];throw C}};return r&&(u[r]=a),a}});f("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});f("async",r=>{let e=i(r);return t=>{let o=e(t);return async function(...n){return o(...n)}}});f("await",r=>(r=i(r),async e=>await r(e)));f("yield",r=>(r=r?i(r):null,e=>{throw{__yield__:r?r(e):void 0}}));f("yield*",r=>(r=i(r),e=>{throw{__yield_all__:r(e)}}));var uo=Symbol("static"),mo=r=>{throw Error(r)};f("instanceof",(r,e)=>(r=i(r),e=i(e),t=>r(t)instanceof e(t)));f("class",(r,e,t)=>(e=e?i(e):null,t=t?i(t):null,o=>{let n=e?e(o):Object,p=function(...m){if(!(this instanceof p))return mo("Class constructor must be called with new");let u=e?Reflect.construct(n,m,p):this;return p.prototype.__constructor__&&p.prototype.__constructor__.apply(u,m),u};if(Object.setPrototypeOf(p.prototype,n.prototype),Object.setPrototypeOf(p,n),t){let m=Object.create(o);m.super=n;let u=t(m),a=Array.isArray(u)&&typeof u[0]?.[0]=="string"?u:[];for(let[y,T]of a)y==="constructor"?p.prototype.__constructor__=T:p.prototype[y]=T}return r&&(o[r]=p),p}));f("static",r=>(r=i(r),e=>[[uo,r(e)]]));f("//",(r,e)=>{let t=new RegExp(r,e||"");return()=>t});f("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 M=Symbol("break"),F=Symbol("continue");f("while",(r,e)=>(r=i(r),e=i(e),t=>{let o;for(;r(t);)try{o=e(t)}catch(n){if(n===M)break;if(n===F)continue;if(n===P)return n[0];throw n}return o}));f("do",(r,e)=>(r=i(r),e=i(e),t=>{let o;do try{o=r(t)}catch(n){if(n===M)break;if(n===F)continue;if(n===P)return n[0];throw n}while(e(t));return o}));f("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),p=>{let m;for(t?.(p);o(p);n?.(p))try{m=e(p)}catch(u){if(u===M)break;if(u===F)continue;if(u===P)return u[0];throw u}return m}}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 ao(o,n,e);if(t==="of")return co(o,n,e)}});var co=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let p,m=o?null:n[r];for(let u of e(n)){o?G(r,u,n):n[r]=u;try{p=t(n)}catch(a){if(a===M)break;if(a===F)continue;if(a===P)return a[0];throw a}}return o||(n[r]=m),p}},ao=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let p,m=o?null:n[r];for(let u in e(n)){o?G(r,u,n):n[r]=u;try{p=t(n)}catch(a){if(a===M)break;if(a===F)continue;if(a===P)return a[0];throw a}}return o||(n[r]=m),p}};f("break",()=>()=>{throw M});f("continue",()=>()=>{throw F});f("return",r=>(r=r!==void 0?i(r):null,e=>{throw P[0]=r?.(e),P}));f("try",(r,...e)=>{r=r?i(r):null;let t=e.find(u=>u?.[0]==="catch"),o=e.find(u=>u?.[0]==="finally"),n=t?.[1],p=t?.[2]?i(t[2]):null,m=o?.[1]?i(o[1]):null;return u=>{let a;try{a=r?.(u)}catch(y){if(y===M||y===F||y===P)throw y;if(n!=null&&p){let T=n in u,k=u[n];u[n]=y;try{a=p(u)}finally{T?u[n]=k:delete u[n]}}else if(!p)throw y}finally{m?.(u)}return a}});f("throw",r=>(r=i(r),e=>{throw r(e)}));f("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,p;for(let[u,a]of e)if(n||u===null||u(t)===o)for(n=!0,m=0;m<a.length;m++)try{p=a[m](t)}catch(y){if(y===M)return p;throw y}var m;return p}):t=>r(t)));f("import",()=>()=>{});f("export",()=>()=>{});f("from",(r,e)=>()=>{});f("as",(r,e)=>()=>{});f("default",r=>i(r));var Se=new WeakMap,ho=(r,...e)=>typeof r=="string"?i(s(r)):Se.get(r)||Se.set(r,Ao(r,e)).get(r),ke=57344,Ao=(r,e)=>{let t=r.reduce((p,m,u)=>p+(u?String.fromCharCode(ke+u-1):"")+m,""),o=s(t),n=p=>{if(typeof p=="string"&&p.length===1){let m=p.charCodeAt(0)-ke,u;if(m>=0&&m<e.length)return u=e[m],yo(u)?u:[,u]}return Array.isArray(p)?p.map(n):p};return i(n(o))},yo=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),wo=ho;export{sr as access,A as binary,i as compile,c as cur,wo as default,I as err,d as expr,z as group,Co as id,l as idx,w as keyword,$ as literal,Ne as loc,N as lookup,Br as member,ir as nary,E as next,f as operator,nr as operators,L as parens,s as parse,W as peek,D as prec,pr as propName,_ as seek,h as skip,g as token,O as unary,S as word};
|
|
1
|
+
var l,m,s=r=>(l=0,m=r,s.enter?.(),r=d(),m[l]?I():r||""),I=(r="Unexpected token",e=l,t=m.slice(0,e).split(`
|
|
2
|
+
`),o=t.pop(),n=m.slice(Math.max(0,e-40),e),p="\u032D",c=(m[e]||" ")+p,u=m.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
|
|
3
|
+
${n}${c}${u}`)},Re=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),E=(r,e=l,t)=>{for(;t=r(m.charCodeAt(l));)l+=t;return m.slice(e,l)},h=(r=1)=>m[l+=r],_=r=>l=r,d=(r=0,e)=>{let t,o,n;for(e&&s.enter?.(r,e);(t=s.space())&&t!==e&&(n=s.step(o,r,t,d));)o=n;return e&&(t==e?(l++,s.exit?.(r,e)):I("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},W=(r=l)=>{for(;m.charCodeAt(r)<=32;)r++;return m.charCodeAt(r)},Eo=s.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,S=(r,e=r.length)=>m.substr(l,e)===r&&!s.id(m.charCodeAt(l+e)),L=()=>(h(),d(0,41)),N=[],B={},g=(r,e=32,t,o=r.charCodeAt(0))=>Mr({op:r,l:r.length,p:B[r]=!N[o]&&B[r]||e,map:t,word:r.toUpperCase()!==r,kw:!1}),A=(r,e,t=!1)=>g(r,e,(o,n)=>o&&(n=d(e-(t?.5:0)))&&[r,o,n]),O=(r,e,t)=>g(r,e,o=>t?o&&[r,o]:!o&&(o=d(e-.5))&&[r,o]),$=(r,e)=>g(r,200,t=>!t&&[,e]),ir=(r,e,t,o)=>g(r,e,(n,p,c=n)=>(p=d(e-(t?.5:0)),n?.[0]!==r&&(n=[r,n||null]),p?.[0]===r?n.push(...p.slice(1)):p?n.push(p):o||W()===r.charCodeAt(0)?n.push(null):c&&n.length===2&&(n=n[1]),n)),z=(r,e)=>g(r[0],e,t=>!t&&[r,d(0,r.charCodeAt(1))||null]),sr=(r,e)=>g(r[0],e,t=>t&&[r,t,d(0,r.charCodeAt(1))||null]),pr=(r,e)=>(s.space(),e=m.charCodeAt(l),s.id(e)&&(e<48||e>57)?E(s.id):d(r)),vr=(r,e)=>g(r,e,(t,o)=>t&&(o=pr(e))&&[r,t,o]),w=(r,e,t)=>(B[r]??=e,Mr({op:r,l:r.length,p:e,map:t,word:!0,kw:!0})),Br=(r,e,t=(o,n,p,c=l,u,a,y)=>{for(y=0;a=r[y++];)if(!(a.kw&&o)&&!(p?a.op!==p:!((a.l<2||a.op.charCodeAt(1)===m.charCodeAt(l+1)&&(a.l<3||m.substr(l,a.l)===a.op))&&(!a.word||!s.id(m.charCodeAt(l+a.l)))&&(p=a.op)))&&!(n>=a.p)&&!(a.kw&&s.prop&&!s.prop(l+a.l))){if(l+=a.l,u=a.map(o))return Re(u,c);l=c,p=0,a.word||o||e||r[y]||I()}return e?.(o,n,p)})=>(t.ops=r,t.tail=e,t),Mr=(r,e=r.op.charCodeAt(0),t=N[e])=>N[e]=t?.ops?Br([r,...t.ops],t.tail):Br([r],t);s.space=r=>{for(;(r=m.charCodeAt(l))<=32;)l++;return r};s.step=(r,e,t,o,n)=>(n=N[t])&&n(r,e)||(r?null:E(s.id)||null);var nr={},f=(r,e,t=nr[r])=>nr[r]=(...o)=>e(...o)||t?.(...o),i=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):nr[r[0]]?.(...r.slice(1))??I(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var fr=46,H=48,j=57,Ur=69,Kr=101,Oe=43,_e=45,Dr=95,Gr=110,Le=97,Pe=102,Be=65,ve=70,Fr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),Me=r=>r===fr&&(r=m.charCodeAt(l+1))!==fr&&!(s.id(r)&&r>j&&r!==Kr&&r!==Ur)||r>=H&&r<=j||r===Dr||((r===Ur||r===Kr)&&((r=m.charCodeAt(l+1))>=H&&r<=j||r===Oe||r===_e)?2:0),lr=r=>{let e=Fr(E(Me));return m.charCodeAt(l)===Gr?(h(),[,BigInt(e)]):(r=+e)!=r?I():[,r]},Ue=r=>e=>e===Dr||e>=H&&e<=j&&e-H<r||r===16&&(e>=Le&&e<=Pe||e>=Be&&e<=ve);s.number=null;N[fr]=r=>!r&&m.charCodeAt(l+1)>=H&&m.charCodeAt(l+1)<=j&&lr();for(let r=H;r<=j;r++)N[r]=e=>e?void 0:lr();N[H]=(r,e)=>{if(!r){for(let t in s.number)if(t[0]==="0"&&(m.charCodeAt(l+1)|32)===t.charCodeAt(1)){h(2);let o=Fr(E(Ue(e=s.number[t])));return m.charCodeAt(l)===Gr?(h(),[,BigInt("0"+t[1]+o)]):[,parseInt(o,e)]}return lr()}};var Ke=92,Hr=34,Xr=39,Qr=117,$r=120,De=123,Ge=125,jr=10,Fe=13,He={n:`
|
|
4
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v",0:"\0"},xr=r=>r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:-1,Wr=r=>(e,t,o="",n=String.fromCharCode(r))=>{if(e||!s.string?.[n])return;h();let p=()=>{let c=m.charCodeAt(l+1);if(c===jr)return 2;if(c===Fe)return m.charCodeAt(l+2)===jr?3:2;if(c===$r||c===Qr&&m.charCodeAt(l+2)!==De){let u=c===$r?2:4,a=0,y;for(let T=0;T<u;T++){if((y=xr(m.charCodeAt(l+2+T)))<0)return o+=m[l+1],2;a=a*16+y}return o+=String.fromCharCode(a),2+u}if(c===Qr){let u=0,a=l+3,y;for(;(y=xr(m.charCodeAt(a)))>=0;)u=u*16+y,a++;return a>l+3&&u<=1114111&&m.charCodeAt(a)===Ge?(o+=String.fromCodePoint(u),a-l+1):(o+=m[l+1],2)}return o+=He[m[l+1]]||m[l+1],2};return E(c=>c-r&&(c!==Ke?(o+=m[l],1):p())),m[l]===n?h():I("Bad string"),[,o]};N[Hr]=Wr(Hr);N[Xr]=Wr(Xr);s.string={'"':!0};var Xe=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>A(r,Xe,!0));var Qe=30,$e=40,je=140;O("!",je);A("||",Qe);A("&&",$e);var xe=50,We=60,ze=70,zr=100,Je=140;A("|",xe);A("&",ze);A("^",We);A(">>",zr);A("<<",zr);O("~",Je);var Y=90;A("<",Y);A(">",Y);A("<=",Y);A(">=",Y);var Jr=80;A("==",Jr);A("!=",Jr);var Vr=110,ur=120,Yr=140;A("+",Vr);A("-",Vr);A("*",ur);A("/",ur);A("%",ur);O("+",Yr);O("-",Yr);var Z=150;g("++",Z,r=>r?["++",r,null]:["++",d(Z-1)]);g("--",Z,r=>r?["--",r,null]:["--",d(Z-1)]);var Ve=5,Ye=10;ir(",",Ye);ir(";",Ve,!0,!0);var Ze=170;z("()",Ze);var Zr=170,qe=160;sr("[]",Zr);vr(".",Zr);sr("()",qe);var be=s.space;s.comment??={"//":`
|
|
5
|
+
`,"/*":"*/"};s.space=()=>{for(var r,e,t,o,n;r=be();){for(t in e=s.comment)if(r===t.charCodeAt(0)&&(t.length<2||m.charCodeAt(l+1)===t.charCodeAt(1))&&(t.length<3||m.substr(l,t.length)===t)){o=e[t],n=m.indexOf(o,l+t.length),_(n<0?m.length:o===`
|
|
6
|
+
`?n:n+o.length),r=0;break}if(r)return r}return r};var qr=80;A("===",qr);A("!==",qr);var rt=30;A("??",rt);var et=130,tt=20;A("**",et,!0);A("**=",tt,!0);var br=90;A("in",br);A("of",br);var ot=20,nt=100;A(">>>",nt);A(">>>=",ot,!0);var cr=20;A("||=",cr,!0);A("&&=",cr,!0);A("??=",cr,!0);$("true",!0);$("false",!1);$("null",null);w("undefined",200,()=>[]);$("NaN",NaN);$("Infinity",1/0);var mr=20;g("?",mr,(r,e,t)=>r&&(e=d(mr-1))&&E(o=>o===58)&&(t=d(mr-1),["?",r,e,t]));var it=20;A("=>",it,!0);var st=20;O("...",st);var re=170;g("?.",re,(r,e)=>{if(!r)return;let t=s.space();return t===40?(h(),["?.()",r,d(0,41)||null]):t===91?(h(),["?.[]",r,d(0,93)]):(e=pr(re),e?["?.",r,e]:void 0)});var ar=140,ee=160,pt=ee+1;O("typeof",ar);O("void",ar);O("delete",ar);var ft=r=>s.space()===40?(h(),["()",r,d(0,41)||null]):r;w("new",pt,()=>S(".target")?(h(7),["new.target"]):["new",ft(d(ee))]);var lt=20,te=200;s.prop=r=>W(r)!==58;z("[]",te);z("{}",te);A(":",lt-1,!0);var ut=170,dr=96,ct=36,mt=123,at=92,dt={n:`
|
|
7
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},oe=()=>{let r=[],e="",t;for(;(t=m.charCodeAt(l))!==dr;)t?t===at?(h(),e+=dt[m[l]]||m[l],h()):t===ct&&m.charCodeAt(l+1)===mt?(r.push([,e]),e="",h(2),r.push(d(0,125))):(e+=m[l],h()):I("Unterminated template");return r.push([,e]),h(),r},ht=r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r],At=N[dr];N[dr]=(r,e)=>r&&e<ut?s.asi&&s.newline?void 0:(h(),["``",r,...oe()]):r?At?.(r,e):(h(),ht(oe()));s.string["'"]=!0;s.number={"0x":16,"0b":2,"0o":8};var yt=92,wt=117,Ct=123,gt=125,Et=183,St=s.id,ne=r=>r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102,kt=(r=l+2,e,t=0,o=0)=>{if(m.charCodeAt(l)!==yt||m.charCodeAt(l+1)!==wt)return 0;if(m.charCodeAt(r)===Ct){for(;ne(e=m.charCodeAt(++r));)t=t*16+(e<=57?e-48:(e&31)+9);return r>l+3&&t<=1114111&&m.charCodeAt(r)===gt?r-l+1:0}for(;o<4&&ne(m.charCodeAt(r+o));)o++;return o===4?6:0};s.id=r=>St(r)||r===Et||kt();var hr=5,Tt=10,Ar=r=>{let e=l,t=d(Tt-1);return t==null?r:r==="let"&&(t==="in"||t==="of")?(_(e),r):t[0]===","?[r,...t.slice(1)]:[r,t]};w("let",hr+1,()=>Ar("let"));w("const",hr+1,()=>Ar("const"));w("var",hr+1,()=>Ar("var"));var q=5,Nt=59,v=()=>(s.space()===123||I("Expected {"),h(),d(q-.5,125)||null),K=()=>s.space()!==123?d(q+.5):(h(),d(q-.5,125)||null),It=()=>{let r=l;return s.space()===Nt&&h(),s.space(),S("else")?(h(4),s.semi=!1,!0):(_(r),!1)};w("if",q+1,()=>{s.space();let r=["if",L(),K()];return It()&&r.push(K()),r});var Rt=200;w("function",Rt,()=>{s.space();let r=!1;m[l]==="*"&&(r=!0,h(),s.space());let e=E(s.id);return e&&s.space(),r?["function*",e,L()||null,v()]:["function",e,L()||null,v()]});var b=140,yr=20,Ot=40;O("await",b);w("yield",b,()=>(s.space(),m[l]==="*"?(h(),s.space(),["yield*",d(yr)]):["yield",d(yr)]));w("async",b,()=>{if(s.space(),S("function"))return["async",d(b)];let r=l,e=E(s.id);if(e){if(s.space(),m.charCodeAt(l)===Ot)return["async",e];_(r)}let t=d(yr-.5);return t&&["async",t]});var ie=200;var _t=90,Lt=175,Pt=160,Bt=Pt-.5;O("static",Lt);A("instanceof",_t);g("#",ie,r=>{if(r)return;let e=E(s.id);return e?"#"+e:void 0});w("class",ie,()=>{s.space();let r=E(s.id)||null;if(r==="extends")r=null,s.space();else{if(s.space(),!S("extends"))return["class",r,null,v()];h(7),s.space()}return["class",r,d(Bt),v()]});var wr=47,vt=92,Mt=91,Ut=93;g("/",140,r=>{let e=m.charCodeAt(l);if(r||e===wr||e===42||e===43||e===63)return;let t=!1,o=E(p=>p===vt?2:p===Mt?(t=!0,1):p===Ut?(t=!1,1):p&&(t||p!==wr));m.charCodeAt(l)===wr||I("Unterminated regex"),h();let n=E(p=>p===103||p===105||p===109||p===115||p===117||p===121);return n?["//",o,n]:["//",o]});var X=5,J=125,V=59;w("while",X+1,()=>(s.space(),["while",L(),K()]));w("do",X+1,r=>(r=K(),s.space(),h(5),s.space(),["do",r,L()]));var se={let:1,const:1,var:1},Cr=(r,e=r,t)=>{if(se[r?.[0]]&&Array.isArray(r[1]))return(e=Cr(r[1]))?.[0]==="in"||e?.[0]==="of"?[e[0],[r[0],e[1]],r.length>2?[",",e[2],...r.slice(2)]:e[2]]:r;for(;Array.isArray(e)&&B[e[0]]<B.in&&!se[e[0]];)t=e,e=e[1];return t&&Array.isArray(e)&&(e[0]==="in"||e[0]==="of")?(t[1]=e[2],[e[0],e[1],r]):r};w("for",X+1,()=>(s.space(),S("await")?(h(5),s.space(),["for await",Cr(L()),K()]):["for",Cr(L()),K()]));w("break",X+1,()=>{s.asi&&(s.newline=!1);let r=l,e=s.space();if(!e||e===J||e===V||s.newline)return["break"];let t=E(s.id);if(!t)return["break"];let o=s.space();return!o||o===J||o===V||s.newline?["break",t]:(_(r),["break"])});w("continue",X+1,()=>{s.asi&&(s.newline=!1);let r=l,e=s.space();if(!e||e===J||e===V||s.newline)return["continue"];let t=E(s.id);if(!t)return["continue"];let o=s.space();return!o||o===J||o===V||s.newline?["continue",t]:(_(r),["continue"])});w("return",X+1,()=>{s.asi&&(s.newline=!1);let r=s.space();return!r||r===J||r===V||s.newline?["return"]:["return",d(X)]});var gr=5;w("try",gr+1,()=>{let r=["try",v()];return s.space(),S("catch")&&(h(5),s.space(),r.push(["catch",W()===40?L():null,v()])),s.space(),S("finally")&&(h(7),r.push(["finally",v()])),r});w("throw",gr+1,()=>{if(s.asi&&(s.newline=!1),s.space(),s.newline)throw SyntaxError("Unexpected newline after throw");return["throw",d(gr)]});var le=5,Kt=20,pe=58,Dt=59,ue=125,Er=0,ce=(r,e=r.length,t=r.charCodeAt(0),o=N[t])=>N[t]=(n,p,c)=>S(r)&&!n&&Er&&(!s.prop||s.prop(l+e))||o?.(n,p,c);ce("case");ce("default");var fe=r=>{let e=[];for(;(r=s.space())!==ue&&!S("case")&&!S("default");){if(r===Dt){h();continue}s.semi=!1,e.push(d(le+.5))||I()}return e.length>1?[";",...e]:e[0]||null},Gt=()=>{s.space()===123||I("Expected {"),h(),Er++;let r=[];try{for(;s.space()!==ue;)if(S("case")){_(l+4),s.space(),s.semi=!1;let e=d(Kt-.5);s.space()===pe&&h(),r.push(["case",e,fe()])}else S("default")?(_(l+7),s.space()===pe&&h(),r.push(["default",fe()])):I("Expected case or default")}finally{Er--}return h(),r};w("switch",le+1,()=>s.space()===40&&["switch",L(),...Gt()]);var Sr=5,Ft=20;w("debugger",Sr+1,()=>["debugger"]);w("with",Sr+1,()=>(s.space(),["with",L(),K()]));var Ht=["if","for","while","do","switch","try"];g(":",Ft-1,r=>typeof r=="string"&&(s.space(),Ht.some(e=>S(e)))&&[":",r,d(Sr)]);var kr=5,x=10,me=42,Xt=N[me];N[me]=(r,e)=>r?Xt?.(r,e):(h(),"*");g("from",x+1,r=>r?r[0]!=="="&&r[0]!==","&&(s.space(),["from",r,d(x+1)]):!1);g("as",x+2,r=>r?(s.space(),["as",r,d(x+2)]):!1);w("import",kr,()=>S(".meta")?(h(5),["import.meta"]):["import",d(x)]);w("export",kr,()=>(s.space(),S("default")?(h(7),["export",["default",d(x)]]):["export",d(kr)]));var Tr=20,Qt=200,$t=10,jt=13,xt=34,Wt=35,zt=39,Jt=40,ae=41,Vt=91,de=123,he=125,Yt=(r,e)=>{for(;r<e;){let t=m.charCodeAt(r++);if(t===$t||t===jt)return!0}return!1},Zt=r=>r===xt||r===zt||r===Vt||r===Wt,qt=()=>E(s.id)||(Zt(m.charCodeAt(l))?d(Qt-.5):null),bt=r=>typeof r=="string"||Array.isArray(r)&&(r[0]===void 0||r[0]==="[]"),Ae=r=>e=>{if(e)return;let t=l;if(s.space(),s.semi||Yt(t,l))return!1;let o=qt();if(!o||(s.space(),m.charCodeAt(l)!==Jt))return!1;h();let n=d(0,ae);return s.space(),m.charCodeAt(l)!==de?!1:(h(),[r,o,n,d(0,he)])};g("get",Tr-1,Ae("get"));g("set",Tr-1,Ae("set"));g("(",Tr-1,r=>{if(!r)return;let e,t;if(Array.isArray(r)&&r[0]==="static"&&(e="static",r=r[1]),Array.isArray(r)&&r[0]==="async"&&(t=!0,r=r[1]),!bt(r))return;let o=d(0,ae)||null;if(s.space(),m.charCodeAt(l)!==de)return;h();let n=["=>",["()",o],d(0,he)||null];t&&(n=["async",n]);let p=[":",r,n];return e?[e,p]:p});s.comment["#!"]=`
|
|
8
|
+
`;var ge=32,Or=10,ro=59,eo=125,ye=91,we=40,rr=B.asi??B[";"],to=s._baseSpace??=s.space,oo=s._baseStep??=s.step,Nr=r=>Array.isArray(r)||typeof r=="string",no=(B[";"]??5)+1,Rr=r=>Array.isArray(r)&&(B[r[0]]<=no||r[0]==="{}"&&Rr(r[1])),io=(r,e)=>{for(;(e=m.charCodeAt(r))<=ge;){if(e===Or)return!0;r++}return!1},so=(r=l,e)=>{for(;r-- >0&&(e=m.charCodeAt(r))<=ge;)if(e===Or)return!0;return!1};s.space=(r,e)=>{for(;;){for(e=l,r=to();e<l;)if(m.charCodeAt(e++)===Or){s.newline=!0;break}if(r===ro&&io(l+1)){_(l+1),s.newline=s.semi=!0;continue}return r}};s.enter=()=>s.newline=s.semi=!1;s.exit=(r,e)=>{e===eo&&(s.newline=!0,s.semi=!1)};s.step=(r,e,t,o)=>{if(s.semi&&e>=rr)return!1;if(r&&!Nr(r))return null;if(Nr(r)){let p=(t===ye||t===we)&&so();if(s.semi||t===ye&&(p||Rr(r))||t===we&&(Rr(r)||p&&e>=rr))return Ce(r,e,o)??null}let n=s.newline;return oo(r,e,t,o)??(Nr(r)&&n?Ce(r,e,o)??null:null)};var Ir=0,po=2e3,Ce=s.asi=(r,e,t,o,n)=>{if(e>=rr||Ir>=po)return;s.semi=!1;let p=l;Ir++;try{o=t(rr-.5)}finally{Ir--}if(!(!o||l===p))return n=o?.[0]===";"?o.slice(1):[o],r?.[0]===";"?(r.push(...n),r):[";",r,...n]};var Se=(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?Se(r[1],e):(()=>{throw Error("Invalid assignment target")})(),Ee={"=":(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 Ee)f(r,(e,t)=>(t=i(t),Se(e,(o,n,p)=>Ee[r](o,n,t(p)))));f("!",r=>(r=i(r),e=>!r(e)));f("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));f("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));f("~",r=>(r=i(r),e=>~r(e)));f("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));f("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));f("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));f(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));f("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));f(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));f("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));f(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));f("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));f("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));f("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));f("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));f("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));f("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));f("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));f("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var _r=(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?_r(r[1],e):(()=>{throw Error("Invalid increment target")})();f("++",(r,e)=>_r(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));f("--",(r,e)=>_r(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var ke=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)t=o(e);return t});f(",",ke);f(";",ke);var Q=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",er=r=>{throw Error(r)};f("[]",(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&&er("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return Q(o)?void 0:r(t)[o]}));f(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],Q(e)?()=>{}:t=>r(t)[e]));f("()",(r,e)=>{if(e===void 0)return r==null?er("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(p=>p==null||t(p));t(e)&&er("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(p=>p(n))):(e=i(e),n=>[e(n)]):()=>[];return Lr(r,(n,p,c)=>n[p](...o(c)))});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]==="{}"),Lr=(r,e,t,o)=>r==null?er("Empty ()"):r[0]==="()"&&r.length==2?Lr(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 p=t(n);return p==null?void 0:e(p,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 p=t(n);return p==null?void 0:e(p,o(n),n)}):(r=i(r),n=>e([r(n)],0,n)),D=Lr;f("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));f("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));f("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var fo=r=>{throw Error(r)};f("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));f("**=",(r,e)=>(M(r)||fo("Invalid assignment target"),e=i(e),D(r,(t,o,n)=>t[o]**=e(n))));f("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var lo=r=>{throw Error(r)};f(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));f(">>>=",(r,e)=>(M(r)||lo("Invalid assignment target"),e=i(e),D(r,(t,o,n)=>t[o]>>>=e(n))));var uo=r=>r[0]?.[0]===","?r[0].slice(1):r,G=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r,p=uo(n);if(o==="{}"){let c=[];for(let u of p){if(Array.isArray(u)&&u[0]==="..."){let C={};for(let R in e)c.includes(R)||(C[R]=e[R]);t[u[1]]=C;break}let a,y,T;typeof u=="string"?a=y=u:u[0]==="="?(typeof u[1]=="string"?a=y=u[1]:[,a,y]=u[1],T=u[2]):[,a,y]=u,c.push(a);let k=e[a];k===void 0&&T&&(k=i(T)(t)),G(y,k,t)}}else if(o==="[]"){let c=0;for(let u of p){if(u===null){c++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(c);break}let a=u,y;Array.isArray(u)&&u[0]==="="&&([,a,y]=u);let T=e[c++];T===void 0&&y&&(T=i(y)(t)),G(a,T,t)}}},Pr=(...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"?p=>{p[t]=n(p)}:p=>G(t,n(p),p)}return i(e)}),e=>{for(let t of r)t(e)});f("let",Pr);f("const",Pr);f("var",Pr);var tr=r=>{throw Error(r)};f("=",(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=>G(t,e(o),o)}return M(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,o,n)=>t[o]=e(n))});f("||=",(r,e)=>(M(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,o,n)=>t[o]||=e(n))));f("&&=",(r,e)=>(M(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,o,n)=>t[o]&&=e(n))));f("??=",(r,e)=>(M(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,o,n)=>t[o]??=e(n))));f("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var P=[];f("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r;let t=r?r[0]===","?r.slice(1):[r]:[],o=-1,n=null,p=t[t.length-1];Array.isArray(p)&&p[0]==="..."&&(o=t.length-1,n=p[1],t.length--);let c=e?.[0]==="{}";return e=i(c?["{",e[1]]:e),u=>(...a)=>{let y={};t.forEach((k,C)=>y[k]=a[C]),n&&(y[n]=a.slice(o));let T=new Proxy(y,{get:(k,C)=>C in k?k[C]:u?.[C],set:(k,C,R)=>((C in k?k:u)[C]=R,!0),has:(k,C)=>C in k||(u?C in u:!1)});try{let k=e(T);return c?void 0:k}catch(k){if(k===P)return k[0];throw k}}});f("...",r=>(r=i(r),e=>Object.entries(r(e))));f("?.",(r,e)=>(r=i(r),Q(e)?()=>{}:t=>r(t)?.[e]));f("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return Q(o)?void 0:r(t)?.[o]}));f("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(p=>p(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="."||r[0]==="?."){let n=i(r[1]),p=r[2];return Q(p)?()=>{}:c=>n(c)?.[p]?.(...t(c))}if((r[0]==="[]"||r[0]==="?.[]")&&r.length===3){let n=i(r[1]),p=i(r[2]);return c=>{let u=p(c);return Q(u)?void 0:n(c)?.[u]?.(...t(c))}}let o=i(r);return n=>o(n)?.(...t(n))});f("typeof",r=>(r=i(r),e=>typeof r(e)));f("void",r=>(r=i(r),e=>(r(e),void 0)));f("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});f("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>p=>n.map(c=>c(p)))(t.slice(1).map(i)):(n=>p=>[n(p)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var or=Symbol("accessor");f("get",(r,e)=>(e=e?i(e):()=>{},t=>[[or,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));f("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[or,r,{set:function(n){let p=Object.create(o||{});p.this=this,p[e]=n,t(p)}}]]));var co=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);f("{}",(r,e)=>{if(e!==void 0)return;if(!co(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={},p={};for(let c of t.flatMap(u=>u(o)))if(c[0]===or){let[,u,a]=c;p[u]={...p[u],...a,configurable:!0,enumerable:!0}}else n[c[0]]=c[1];for(let c in p)Object.defineProperty(n,c,p[c]);return n}});f("{",r=>(r=r?i(r):()=>{},e=>r(Object.create(e))));f(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));f("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));f("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):o.push(i(p));let n=Object.assign([...t],{raw:t});return p=>r(p)(n,...o.map(c=>c(p)))});f("function",(r,e,t)=>{t=t?i(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],n=null,p=-1,c=o[o.length-1];return Array.isArray(c)&&c[0]==="..."&&(p=o.length-1,n=c[1],o.length--),u=>{let a=(...y)=>{let T={};o.forEach((C,R)=>T[C]=y[R]),n&&(T[n]=y.slice(p));let k=new Proxy(T,{get:(C,R)=>R in C?C[R]:u[R],set:(C,R,Ie)=>((R in C?C:u)[R]=Ie,!0),has:(C,R)=>R in C||R in u});try{return t(k)}catch(C){if(C===P)return C[0];throw C}};return r&&(u[r]=a),a}});f("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});f("async",r=>{let e=i(r);return t=>{let o=e(t);return async function(...n){return o(...n)}}});f("await",r=>(r=i(r),async e=>await r(e)));f("yield",r=>(r=r?i(r):null,e=>{throw{__yield__:r?r(e):void 0}}));f("yield*",r=>(r=i(r),e=>{throw{__yield_all__:r(e)}}));var mo=Symbol("static"),ao=r=>{throw Error(r)};f("instanceof",(r,e)=>(r=i(r),e=i(e),t=>r(t)instanceof e(t)));f("class",(r,e,t)=>(e=e?i(e):null,t=t?i(t):null,o=>{let n=e?e(o):Object,p=function(...c){if(!(this instanceof p))return ao("Class constructor must be called with new");let u=e?Reflect.construct(n,c,p):this;return p.prototype.__constructor__&&p.prototype.__constructor__.apply(u,c),u};if(Object.setPrototypeOf(p.prototype,n.prototype),Object.setPrototypeOf(p,n),t){let c=Object.create(o);c.super=n;let u=t(c),a=Array.isArray(u)&&typeof u[0]?.[0]=="string"?u:[];for(let[y,T]of a)y==="constructor"?p.prototype.__constructor__=T:p.prototype[y]=T}return r&&(o[r]=p),p}));f("static",r=>(r=i(r),e=>[[mo,r(e)]]));f("//",(r,e)=>{let t=new RegExp(r,e||"");return()=>t});f("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"),F=Symbol("continue");f("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===F)continue;if(n===P)return n[0];throw n}return o}));f("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===F)continue;if(n===P)return n[0];throw n}while(e(t));return o}));f("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),p=>{let c;for(t?.(p);o(p);n?.(p))try{c=e(p)}catch(u){if(u===U)break;if(u===F)continue;if(u===P)return u[0];throw u}return c}}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 Ao(o,n,e);if(t==="of")return ho(o,n,e)}});var ho=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let p,c=o?null:n[r];for(let u of e(n)){o?G(r,u,n):n[r]=u;try{p=t(n)}catch(a){if(a===U)break;if(a===F)continue;if(a===P)return a[0];throw a}}return o||(n[r]=c),p}},Ao=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let p,c=o?null:n[r];for(let u in e(n)){o?G(r,u,n):n[r]=u;try{p=t(n)}catch(a){if(a===U)break;if(a===F)continue;if(a===P)return a[0];throw a}}return o||(n[r]=c),p}};f("break",()=>()=>{throw U});f("continue",()=>()=>{throw F});f("return",r=>(r=r!==void 0?i(r):null,e=>{throw P[0]=r?.(e),P}));f("try",(r,...e)=>{r=r?i(r):null;let t=e.find(u=>u?.[0]==="catch"),o=e.find(u=>u?.[0]==="finally"),n=t?.[1],p=t?.[2]?i(t[2]):null,c=o?.[1]?i(o[1]):null;return u=>{let a;try{a=r?.(u)}catch(y){if(y===U||y===F||y===P)throw y;if(n!=null&&p){let T=n in u,k=u[n];u[n]=y;try{a=p(u)}finally{T?u[n]=k:delete u[n]}}else if(!p)throw y}finally{c?.(u)}return a}});f("throw",r=>(r=i(r),e=>{throw r(e)}));f("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,p;for(let[u,a]of e)if(n||u===null||u(t)===o)for(n=!0,c=0;c<a.length;c++)try{p=a[c](t)}catch(y){if(y===U)return p;throw y}var c;return p}):t=>r(t)));f("import",()=>()=>{});f("export",()=>()=>{});f("from",(r,e)=>()=>{});f("as",(r,e)=>()=>{});f("default",r=>i(r));var Te=new WeakMap,yo=(r,...e)=>typeof r=="string"?i(s(r)):Te.get(r)||Te.set(r,wo(r,e)).get(r),Ne=57344,wo=(r,e)=>{let t=r.reduce((p,c,u)=>p+(u?String.fromCharCode(Ne+u-1):"")+c,""),o=s(t),n=p=>{if(typeof p=="string"&&p.length===1){let c=p.charCodeAt(0)-Ne,u;if(c>=0&&c<e.length)return u=e[c],Co(u)?u:[,u]}return Array.isArray(p)?p.map(n):p};return i(n(o))},Co=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),go=yo;export{sr as access,A as binary,i as compile,m as cur,go as default,I as err,d as expr,z as group,Eo as id,l as idx,w as keyword,$ as literal,Re as loc,N as lookup,vr as member,ir as nary,E as next,f as operator,nr as operators,L as parens,s as parse,W as peek,B as prec,pr as propName,_ as seek,h as skip,g as token,O as unary,S as word};
|