subscript 10.3.1 → 10.3.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/feature/if.js +3 -4
- package/jessie.min.js +8 -8
- package/justin.min.js +5 -5
- package/package.json +1 -1
- package/parse.js +10 -2
- package/subscript.min.js +4 -4
package/feature/if.js
CHANGED
|
@@ -11,12 +11,11 @@ export const block = () =>
|
|
|
11
11
|
export const body = () =>
|
|
12
12
|
space() !== 123 ? expr(STATEMENT + .5) : (skip(), expr(STATEMENT - .5, 125) || null);
|
|
13
13
|
|
|
14
|
-
// Check for `else` after optional semicolon
|
|
14
|
+
// Check for `else` after optional semicolon
|
|
15
15
|
const checkElse = () => {
|
|
16
16
|
const from = idx;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
sp();
|
|
17
|
+
if (space() === SEMI) skip();
|
|
18
|
+
space();
|
|
20
19
|
if (word('else')) return skip(4), true;
|
|
21
20
|
return seek(from), false;
|
|
22
21
|
};
|
package/jessie.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var u,
|
|
2
|
-
`),n=t.pop(),o=
|
|
3
|
-
${
|
|
4
|
-
`,""+o}${l}${f}`)},Nr=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),T=(r,e=u,t)=>{for(;t=r(
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Mr=r=>(e,t,n="")=>{if(!(e||!c.string?.[String.fromCharCode(r)]))return h(),T(o=>o-r&&(o===we?(n+=Ee[
|
|
6
|
-
`,"/*":"*/"};var hr;c.space=()=>{hr||(hr=Object.entries(c.comment).map(([o,p])=>[o,p,o.charCodeAt(0)]));for(var r;r=Le();){for(var e=0,t;t=hr[e++];)if(r===t[2]&&
|
|
7
|
-
`)for(;
|
|
8
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},re=()=>{let r=[];for(let e="",t;(t=
|
|
1
|
+
var u,d,c=r=>(u=0,d=r,c.newline=!1,r=a(),d[u]?R():r||""),R=(r="Unexpected token",e=u,t=d.slice(0,e).split(`
|
|
2
|
+
`),n=t.pop(),o=d.slice(Math.max(0,e-40),e),p="\u032D",l=(d[e]||" ")+p,f=d.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${n.length+1}
|
|
3
|
+
${d[e-41]!==`
|
|
4
|
+
`,""+o}${l}${f}`)},Nr=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),T=(r,e=u,t)=>{for(;t=r(d.charCodeAt(u));)u+=t;return d.slice(e,u)},h=(r=1)=>d[u+=r],M=r=>u=r,a=(r=0,e)=>{let t,n,o,p,l;for(e&&c.asi&&(c.newline=!1);(t=c.space())&&(l=c.newline,1)&&t!==e&&(o=((p=I[t])&&p(n,r))??(n&&l&&c.asi?.(n,r,a))??(!n&&T(c.id)));)n=o;return e&&(t==e?(u++,e===125&&c.asi&&(c.newline=!0)):R("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),n},m=(r,e=u)=>{for(;(r=d.charCodeAt(u))<=32;)c.asi&&r===10&&(c.newline=!0),u++;return r},Rr=(r=u)=>{for(;d.charCodeAt(r)<=32;)r++;return d.charCodeAt(r)},Et=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,N=(r,e=r.length)=>d.substr(u,e)===r&&!c.id(d.charCodeAt(u+e)),P=()=>(h(),a(0,41)),I=[],H={},k=(r,e=32,t,n=r.charCodeAt(0),o=r.length,p=I[n],l=r.toUpperCase()!==r,f,A)=>(e=H[r]=!p&&H[r]||e,I[n]=(g,S,C,E=u)=>(f=C,(C?r==C:(o<2||r.charCodeAt(1)===d.charCodeAt(u+1)&&(o<3||d.substr(u,o)==r))&&(!l||!c.id(d.charCodeAt(u+o)))&&(f=C=r))&&S<e&&(u+=o,(A=t(g))?Nr(A,E):(u=E,f=0,!l&&!p&&R()),A)||p?.(g,S,f))),y=(r,e,t=!1)=>k(r,e,n=>n&&(o=>o&&[r,n,o])(a(e-(t?.5:0)))),_=(r,e,t)=>k(r,e,n=>t?n&&[r,n]:!n&&(n=a(e-.5))&&[r,n]),j=(r,e)=>k(r,200,t=>!t&&[,e]),fr=(r,e,t)=>k(r,e,(n,o)=>(o=a(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)=>k(r[0],e,t=>!t&&[r,a(0,r.charCodeAt(1))||null]),lr=(r,e)=>k(r[0],e,t=>t&&[r,t,a(0,r.charCodeAt(1))||null]),w=(r,e,t,n=r.charCodeAt(0),o=r.length,p=I[n],l)=>I[n]=(f,A,g,S=u)=>!f&&(g?r==g:(o<2||d.substr(u,o)==r)&&(g=r))&&A<e&&!c.id(d.charCodeAt(u+o))&&(!c.prop||c.prop(u+o))&&(M(u+o),(l=t())?Nr(l,S):M(S),l)||p?.(f,A,g);Object.defineProperty(c,"space",{configurable:!0,enumerable:!0,get:()=>m,set:r=>m=r});var pr={},s=(r,e,t=pr[r])=>pr[r]=(...n)=>e(...n)||t?.(...n),i=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):pr[r[0]]?.(...r.slice(1))??R(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var q=46,z=48,x=57,ue=69,ce=101,me=43,de=45,Z=95,Or=110,ae=97,he=102,ye=65,Ae=70,_r=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),ur=r=>{let e=_r(T(t=>t===q&&d.charCodeAt(u+1)!==q||t>=z&&t<=x||t===Z||((t===ue||t===ce)&&((t=d.charCodeAt(u+1))>=z&&t<=x||t===me||t===de)?2:0)));return d.charCodeAt(u)===Or?(h(),[,BigInt(e)]):(r=+e)!=r?R():[,r]},ge={2:r=>r===48||r===49||r===Z,8:r=>r>=48&&r<=55||r===Z,16:r=>r>=z&&r<=x||r>=ae&&r<=he||r>=ye&&r<=Ae||r===Z};c.number=null;I[q]=r=>!r&&d.charCodeAt(u+1)!==q&&ur();for(let r=z;r<=x;r++)I[r]=e=>e?void 0:ur();I[z]=r=>{if(r)return;let e=c.number;if(e){for(let[t,n]of Object.entries(e))if(t[0]==="0"&&d[u+1]?.toLowerCase()===t[1]){h(2);let o=_r(T(ge[n]));return d.charCodeAt(u)===Or?(h(),[,BigInt("0"+t[1]+o)]):[,parseInt(o,n)]}}return ur()};var we=92,Pr=34,vr=39,Ee={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Mr=r=>(e,t,n="")=>{if(!(e||!c.string?.[String.fromCharCode(r)]))return h(),T(o=>o-r&&(o===we?(n+=Ee[d[u+1]]||d[u+1],2):(n+=d[u],1))),d[u]===String.fromCharCode(r)?h():R("Bad string"),[,n]};I[Pr]=Mr(Pr);I[vr]=Mr(vr);c.string={'"':!0};var Ce=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>y(r,Ce,!0));var Br=(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?Br(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=i(t),Br(e,(n,o,p)=>Ur[r](n,o,t(p)))));var Se=30,ke=40,Lr=140;y("!",Lr);_("!",Lr);y("||",Se);y("&&",ke);s("!",r=>(r=i(r),e=>!r(e)));s("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var Ie=50,Te=60,Ne=70,Fr=100,Re=140;y("|",Ie);y("&",Ne);y("^",Te);y(">>",Fr);y("<<",Fr);_("~",Re);s("~",r=>(r=i(r),e=>~r(e)));s("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var b=90;y("<",b);y(">",b);y("<=",b);y(">=",b);s(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var Gr=80;y("==",Gr);y("!=",Gr);s("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var Xr=110,cr=120,Dr=140;y("+",Xr);y("-",Xr);y("*",cr);y("/",cr);y("%",cr);_("+",Dr);_("-",Dr);s("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));s("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var rr=150;k("++",rr,r=>r?["++",r,null]:["++",a(rr-1)]);k("--",rr,r=>r?["--",r,null]:["--",a(rr-1)]);var mr=(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?mr(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>mr(r,e===null?(t,n)=>t[n]++:(t,n)=>++t[n]));s("--",(r,e)=>mr(r,e===null?(t,n)=>t[n]--:(t,n)=>--t[n]));var Oe=5,_e=10;fr(",",_e);fr(";",Oe,!0);var Kr=(...r)=>(r=r.map(i),e=>{let t;for(let n of r)t=n(e);return t});s(",",Kr);s(";",Kr);var Pe=170;W("()",Pe);var F=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",dr=170;lr("[]",dr);y(".",dr);lr("()",dr);var er=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=i(t[1]),n=>t(n)):(t=i(t),n=>[t(n)])),t=>r.flatMap(n=>n(t))):(e==null&&er("Missing index"),r=i(r),e=i(e),t=>{let n=e(t);return F(n)?void 0:r(t)[n]}));s(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],F(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?er("Empty ()"):i(r);let t=o=>o?.[0]===","&&o.slice(1).some(p=>p==null||t(p));t(e)&&er("Empty argument");let n=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(p=>p(o))):(e=i(e),o=>[e(o)]):()=>[];return ar(r,(o,p,l)=>o[p](...n(l)))});var U=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&U(r[1])||r[0]==="{}"),ar=(r,e,t,n)=>r==null?er("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 p=t(o);return p==null?void 0:e(p,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 p=t(o);return p==null?void 0:e(p,n(o),o)}):(r=i(r),o=>e([r(o)],0,o)),G=ar;var Qr=new WeakMap,ve=(r,...e)=>typeof r=="string"?i(c(r)):Qr.get(r)||Qr.set(r,Me(r,e)).get(r),$r=57344,Me=(r,e)=>{let t=r.reduce((p,l,f)=>p+(f?String.fromCharCode($r+f-1):"")+l,""),n=c(t),o=p=>{if(typeof p=="string"&&p.length===1){let l=p.charCodeAt(0)-$r,f;if(l>=0&&l<e.length)return f=e[l],Ue(f)?f:[,f]}return Array.isArray(p)?p.map(o):p};return i(o(n))},Ue=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),jr=ve;var Be=32,Le=c.space;c.comment??={"//":`
|
|
6
|
+
`,"/*":"*/"};var hr;c.space=()=>{hr||(hr=Object.entries(c.comment).map(([o,p])=>[o,p,o.charCodeAt(0)]));for(var r;r=Le();){for(var e=0,t;t=hr[e++];)if(r===t[2]&&d.substr(u,t[0].length)===t[0]){var n=u+t[0].length;if(t[1]===`
|
|
7
|
+
`)for(;d.charCodeAt(n)>=Be;)n++;else{for(;d[n]&&d.substr(n,t[1].length)!==t[1];)n++;d[n]&&(n+=t[1].length)}M(n),r=0;break}if(r)return r}return r};var Hr=80;y("===",Hr);y("!==",Hr);s("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));s("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));var Fe=30;y("??",Fe);s("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var Ge=130,Xe=20;y("**",Ge,!0);y("**=",Xe,!0);s("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));var De=r=>{throw Error(r)};s("**=",(r,e)=>(U(r)||De("Invalid assignment target"),e=i(e),G(r,(t,n,o)=>t[n]**=e(o))));var Wr=90;y("in",Wr);y("of",Wr);s("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var Ke=20,Qe=100,$e=r=>{throw Error(r)};y(">>>",Qe);y(">>>=",Ke,!0);s(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(U(r)||$e("Invalid assignment target"),e=i(e),G(r,(t,n,o)=>t[n]>>>=e(o))));var yr=5,je=10,He=20,We=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,p=We(o);if(n==="{}"){let l=[];for(let f of p){if(Array.isArray(f)&&f[0]==="..."){let E={};for(let O in e)l.includes(O)||(E[O]=e[O]);t[f[1]]=E;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,l.push(A);let C=e[A];C===void 0&&S&&(C=i(S)(t)),D(g,C,t)}}else if(n==="[]"){let l=0;for(let f of p){if(f===null){l++;continue}if(Array.isArray(f)&&f[0]==="..."){t[f[1]]=e.slice(l);break}let A=f,g;Array.isArray(f)&&f[0]==="="&&([,A,g]=f);let S=e[l++];S===void 0&&g&&(S=i(g)(t)),D(A,S,t)}}},zr=r=>{let e=a(je-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",yr+1,()=>zr("let"));w("const",yr+1,()=>zr("const"));w("var",yr,()=>(m(),["var",a(He)]));var Jr=(...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"?p=>{p[t]=o(p)}:p=>D(t,o(p),p)}return i(e)}),e=>{for(let t of r)t(e)});s("let",Jr);s("const",Jr);s("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var Ar=20,tr=r=>{throw Error(r)};y("||=",Ar,!0);y("&&=",Ar,!0);y("??=",Ar,!0);s("=",(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 U(r)||tr("Invalid assignment target"),e=i(e),G(r,(t,n,o)=>t[n]=e(o))});s("||=",(r,e)=>(U(r)||tr("Invalid assignment target"),e=i(e),G(r,(t,n,o)=>t[n]||=e(o))));s("&&=",(r,e)=>(U(r)||tr("Invalid assignment target"),e=i(e),G(r,(t,n,o)=>t[n]&&=e(o))));s("??=",(r,e)=>(U(r)||tr("Invalid assignment target"),e=i(e),G(r,(t,n,o)=>t[n]??=e(o))));j("true",!0);j("false",!1);j("null",null);w("undefined",200,()=>[]);j("NaN",NaN);j("Infinity",1/0);var gr=20;k("?",gr,(r,e,t)=>r&&(e=a(gr-1))&&T(n=>n===58)&&(t=a(gr-1),["?",r,e,t]));s("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),n=>r(n)?e(n):t(n)));var v=[],ze=20;y("=>",ze,!0);s("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r;let t=r?r[0]===","?r.slice(1):[r]:[],n=-1,o=null,p=t[t.length-1];Array.isArray(p)&&p[0]==="..."&&(n=t.length-1,o=p[1],t.length--);let l=e?.[0]==="{}";return e=i(l?["{",e[1]]:e),f=>(...A)=>{let g={};t.forEach((C,E)=>g[C]=A[E]),o&&(g[o]=A.slice(n));let S=new Proxy(g,{get:(C,E)=>E in C?C[E]:f?.[E],set:(C,E,O)=>((E in C?C:f)[E]=O,!0),has:(C,E)=>E in C||(f?E in f:!1)});try{let C=e(S);return l?void 0:C}catch(C){if(C===v)return C[0];throw C}}});var Je=140;_("...",Je);s("...",r=>(r=i(r),e=>Object.entries(r(e))));var Vr=170;k("?.",Vr,(r,e)=>{if(!r)return;let t=m();return t===40?(h(),["?.()",r,a(0,41)||null]):t===91?(h(),["?.[]",r,a(0,93)]):(e=a(Vr),e?["?.",r,e]:void 0)});s("?.",(r,e)=>(r=i(r),F(e)?()=>{}:t=>r(t)?.[e]));s("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let n=e(t);return F(n)?void 0:r(t)?.[n]}));s("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(p=>p(o))):(e=i(e),o=>[e(o)]):()=>[];if(r[0]==="?."){let o=i(r[1]),p=r[2];return F(p)?()=>{}:l=>o(l)?.[p]?.(...t(l))}if(r[0]==="?.[]"){let o=i(r[1]),p=i(r[2]);return l=>{let f=o(l),A=p(l);return F(A)?void 0:f?.[A]?.(...t(l))}}if(r[0]==="."){let o=i(r[1]),p=r[2];return F(p)?()=>{}:l=>o(l)?.[p]?.(...t(l))}if(r[0]==="[]"&&r.length===3){let o=i(r[1]),p=i(r[2]);return l=>{let f=o(l),A=p(l);return F(A)?void 0:f?.[A]?.(...t(l))}}let n=i(r);return o=>n(o)?.(...t(o))});var J=140;_("typeof",J);_("void",J);_("delete",J);w("new",J,()=>N(".target")?(h(7),["new.target"]):["new",a(J)]);s("typeof",r=>(r=i(r),e=>typeof r(e)));s("void",r=>(r=i(r),e=>(r(e),void 0)));s("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});s("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,n=t?t[0]===","?(o=>p=>o.map(l=>l(p)))(t.slice(1).map(i)):(o=>p=>[o(p)])(i(t)):()=>[];return o=>new(e(o))(...n(o))});var nr=Symbol("accessor"),wr=20,Ve=40,Yr=41,Zr=123,qr=125,xr=r=>e=>{if(e)return;m();let t=T(c.id);if(!t||(m(),d.charCodeAt(u)!==Ve))return!1;h();let n=a(0,Yr);return m(),d.charCodeAt(u)!==Zr?!1:(h(),[r,t,n,a(0,qr)])};k("get",wr-1,xr("get"));k("set",wr-1,xr("set"));k("(",wr-1,r=>{if(!r||typeof r!="string")return;let e=a(0,Yr)||null;if(m(),d.charCodeAt(u)===Zr)return h(),[":",r,["=>",["()",e],a(0,qr)||null]]});s("get",(r,e)=>(e=e?i(e):()=>{},t=>[[nr,r,{get:function(){let n=Object.create(t||{});return n.this=this,e(n)}}]]));s("set",(r,e,t)=>(t=t?i(t):()=>{},n=>[[nr,r,{set:function(o){let p=Object.create(n||{});p.this=this,p[e]=o,t(p)}}]]));var Ye=20,br=200;c.prop=r=>Rr(r)!==58;var Ze=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);W("[]",br);W("{}",br);y(":",Ye-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;if(!Ze(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={},p={};for(let l of t.flatMap(f=>f(n)))if(l[0]===nr){let[,f,A]=l;p[f]={...p[f],...A,configurable:!0,enumerable:!0}}else o[l[0]]=l[1];for(let l in p)Object.defineProperty(o,l,p[l]);return o}});s("{",r=>(r=r?i(r):()=>{},e=>r(Object.create(e))));s(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var qe=170,or=96,xe=36,be=123,rt=92,et={n:`
|
|
8
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},re=()=>{let r=[];for(let e="",t;(t=d.charCodeAt(u))!==or;)t?t===rt?(h(),e+=et[d[u]]||d[u],h()):t===xe&&d.charCodeAt(u+1)===be?(e&&r.push([,e]),e="",h(2),r.push(a(0,125))):(e+=d[u],h(),t=d.charCodeAt(u),t===or&&e&&r.push([,e])):R("Unterminated template");return h(),r},tt=I[or];I[or]=(r,e)=>r&&e<qe?c.asi&&c.newline?void 0:(h(),["``",r,...re()]):r?tt?.(r,e):(h(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(re()));s("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));s("``",(r,...e)=>{r=i(r);let t=[],n=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):n.push(i(p));let o=Object.assign([...t],{raw:t});return p=>r(p)(o,...n.map(l=>l(p)))});c.string["'"]=!0;c.number={"0x":16,"0b":2,"0o":8};var ir=5,nt=59,B=()=>(m()===123||R("Expected {"),h(),a(ir-.5,125)||null),X=()=>m()!==123?a(ir+.5):(h(),a(ir-.5,125)||null),ot=()=>{let r=u;return m()===nt&&h(),m(),N("else")?(h(4),!0):(M(r),!1)};w("if",ir+1,()=>{m();let r=["if",P(),X()];return ot()&&r.push(X()),r});s("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 it=200;w("function",it,()=>{m();let r=!1;d[u]==="*"&&(r=!0,h(),m());let e=T(c.id);return e&&m(),r?["function*",e,P()||null,B()]:["function",e,P()||null,B()]});s("function",(r,e,t)=>{t=t?i(t):()=>{};let n=e?e[0]===","?e.slice(1):[e]:[],o=null,p=-1,l=n[n.length-1];return Array.isArray(l)&&l[0]==="..."&&(p=n.length-1,o=l[1],n.length--),f=>{let A=(...g)=>{let S={};n.forEach((E,O)=>S[E]=g[O]),o&&(S[o]=g.slice(p));let C=new Proxy(S,{get:(E,O)=>O in E?E[O]:f[O],set:(E,O,le)=>((O in E?E:f)[O]=le,!0),has:(E,O)=>O in E||O in f});try{return t(C)}catch(E){if(E===v)return E[0];throw E}};return r&&(f[r]=A),A}});s("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});var sr=140,Er=20;_("await",sr);w("yield",sr,()=>(m(),d[u]==="*"?(h(),m(),["yield*",a(Er)]):["yield",a(Er)]));w("async",sr,()=>{if(m(),N("function"))return["async",a(sr)];let r=a(Er-.5);return r&&["async",r]});s("async",r=>{let e=i(r);return t=>{let n=e(t);return async function(...o){return n(...o)}}});s("await",r=>(r=i(r),async e=>await r(e)));s("yield",r=>(r=r?i(r):null,e=>{throw{__yield__:r?r(e):void 0}}));s("yield*",r=>(r=i(r),e=>{throw{__yield_all__:r(e)}}));var Cr=200,st=140,pt=90,ft=Symbol("static");_("static",st);y("instanceof",pt);k("#",Cr,r=>{if(r)return;let e=T(c.id);return e?"#"+e:void 0});w("class",Cr,()=>{m();let r=T(c.id)||null;if(r==="extends")r=null,m();else{if(m(),!N("extends"))return["class",r,null,B()];h(7),m()}return["class",r,a(Cr),B()]});var lt=r=>{throw Error(r)};s("instanceof",(r,e)=>(r=i(r),e=i(e),t=>r(t)instanceof e(t)));s("class",(r,e,t)=>(e=e?i(e):null,t=t?i(t):null,n=>{let o=e?e(n):Object,p=function(...l){if(!(this instanceof p))return lt("Class constructor must be called with new");let f=e?Reflect.construct(o,l,p):this;return p.prototype.__constructor__&&p.prototype.__constructor__.apply(f,l),f};if(Object.setPrototypeOf(p.prototype,o.prototype),Object.setPrototypeOf(p,o),t){let l=Object.create(n);l.super=o;let f=t(l),A=Array.isArray(f)&&typeof f[0]?.[0]=="string"?f:[];for(let[g,S]of A)g==="constructor"?p.prototype.__constructor__=S:p.prototype[g]=S}return r&&(n[r]=p),p}));s("static",r=>(r=i(r),e=>[[ft,r(e)]]));var ut=140,Sr=47,ct=92,mt=r=>r===ct?2:r&&r!==Sr,dt=r=>r===103||r===105||r===109||r===115||r===117||r===121;k("/",ut,r=>{if(r)return;let e=d.charCodeAt(u);if(e===Sr||e===42||e===43||e===63||e===61)return;let t=T(mt);d.charCodeAt(u)===Sr||R("Unterminated regex"),h();let n=T(dt);try{new RegExp(t,n)}catch(o){R("Invalid regex: "+o.message)}return n?["//",t,n]:["//",t]});s("//",(r,e)=>{let t=new RegExp(r,e||"");return()=>t});var L=Symbol("break"),K=Symbol("continue"),Q=5,V=125,Y=59;w("while",Q+1,()=>(m(),["while",P(),X()]));w("do",Q+1,()=>(r=>(m(),h(5),m(),["do",r,P()]))(X()));w("for",Q+1,()=>(m(),N("await")?(h(5),m(),["for await",P(),X()]):["for",P(),X()]));w("break",Q+1,()=>{c.asi&&(c.newline=!1);let r=u;m();let e=d.charCodeAt(u);if(!e||e===V||e===Y||c.newline)return["break"];let t=T(c.id);if(!t)return["break"];m();let n=d.charCodeAt(u);return!n||n===V||n===Y||c.newline?["break",t]:(M(r),["break"])});w("continue",Q+1,()=>{c.asi&&(c.newline=!1);let r=u;m();let e=d.charCodeAt(u);if(!e||e===V||e===Y||c.newline)return["continue"];let t=T(c.id);if(!t)return["continue"];m();let n=d.charCodeAt(u);return!n||n===V||n===Y||c.newline?["continue",t]:(M(r),["continue"])});w("return",Q+1,()=>{c.asi&&(c.newline=!1);let r=m();return!r||r===V||r===Y||c.newline?["return"]:["return",a(Q)]});s("while",(r,e)=>(r=i(r),e=i(e),t=>{let n;for(;r(t);)try{n=e(t)}catch(o){if(o===L)break;if(o===K)continue;if(o===v)return o[0];throw o}return n}));s("do",(r,e)=>(r=i(r),e=i(e),t=>{let n;do try{n=r(t)}catch(o){if(o===L)break;if(o===K)continue;if(o===v)return o[0];throw o}while(e(t));return n}));s("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),p=>{let l;for(t?.(p);n(p);o?.(p))try{l=e(p)}catch(f){if(f===L)break;if(f===K)continue;if(f===v)return f[0];throw f}return l}}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 ht(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 p,l=n?null:o[r];for(let f of e(o)){n?D(r,f,o):o[r]=f;try{p=t(o)}catch(A){if(A===L)break;if(A===K)continue;if(A===v)return A[0];throw A}}return n||(o[r]=l),p}},ht=(r,e,t)=>{e=i(e),t=i(t);let n=Array.isArray(r);return o=>{let p,l=n?null:o[r];for(let f in e(o)){n?D(r,f,o):o[r]=f;try{p=t(o)}catch(A){if(A===L)break;if(A===K)continue;if(A===v)return A[0];throw A}}return n||(o[r]=l),p}};s("break",()=>()=>{throw L});s("continue",()=>()=>{throw K});s("return",r=>(r=r!==void 0?i(r):null,e=>{throw v[0]=r?.(e),v}));var kr=5;w("try",kr+1,()=>{let r=["try",B()];return m(),N("catch")&&(h(5),m(),r.push(["catch",P(),B()])),m(),N("finally")&&(h(7),r.push(["finally",B()])),r});w("throw",kr+1,()=>{if(c.asi&&(c.newline=!1),m(),c.newline)throw SyntaxError("Unexpected newline after throw");return["throw",a(kr)]});s("try",(r,...e)=>{r=r?i(r):null;let t=e.find(f=>f?.[0]==="catch"),n=e.find(f=>f?.[0]==="finally"),o=t?.[1],p=t?.[2]?i(t[2]):null,l=n?.[1]?i(n[1]):null;return f=>{let A;try{A=r?.(f)}catch(g){if(g===L||g===K||g===v)throw g;if(o!=null&&p){let S=o in f,C=f[o];f[o]=g;try{A=p(f)}finally{S?f[o]=C:delete f[o]}}else if(!p)throw g}finally{l?.(f)}return A}});s("throw",r=>(r=i(r),e=>{throw r(e)}));var ne=5,yt=20,ee=58,At=59,oe=125,Ir=0,ie=(r,e=r.length,t=r.charCodeAt(0),n=I[t])=>I[t]=(o,p,l)=>N(r)&&!o&&Ir||n?.(o,p,l);ie("case");ie("default");var te=r=>{let e=[];for(;(r=m())!==oe&&!N("case")&&!N("default");){if(r===At){h();continue}e.push(a(ne-.5))||R()}return e.length>1?[";",...e]:e[0]||null},gt=()=>{m()===123||R("Expected {"),h(),Ir++;let r=[];try{for(;m()!==oe;)if(N("case")){M(u+4),m();let e=a(yt-.5);m()===ee&&h(),r.push(["case",e,te()])}else N("default")?(M(u+7),m()===ee&&h(),r.push(["default",te()])):R("Expected case or default")}finally{Ir--}return h(),r};w("switch",ne+1,()=>m()===40&&["switch",P(),...gt()]);s("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,p;for(let[f,A]of e)if(o||f===null||f(t)===n)for(o=!0,l=0;l<A.length;l++)try{p=A[l](t)}catch(g){if(g===L)return p;throw g}var l;return p}):t=>r(t)));var se=5;w("debugger",se+1,()=>["debugger"]);w("with",se+1,()=>(m(),["with",P(),X()]));var Tr=5,$=10,pe=42,wt=I[pe];I[pe]=(r,e)=>r?wt?.(r,e):(h(),"*");k("from",$+1,r=>r?r[0]!=="="&&r[0]!==","&&(m(),["from",r,a($+1)]):!1);k("as",$+2,r=>r?(m(),["as",r,a($+2)]):!1);w("import",Tr,()=>N(".meta")?(h(5),["import.meta"]):["import",a($)]);w("export",Tr,()=>(m(),["export",a(Tr)]));w("default",$+1,()=>m()!==58&&(m(),["default",a($)]));s("import",()=>()=>{});s("export",()=>()=>{});s("from",(r,e)=>()=>{});s("as",(r,e)=>()=>{});s("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,y as binary,i as compile,d as cur,jr as default,R as err,a as expr,W as group,Et as id,u as idx,w as keyword,j as literal,Nr as loc,I as lookup,fr as nary,T as next,s as operator,pr as operators,P as parens,c as parse,Rr as peek,H as prec,M as seek,h as skip,m as space,k as token,_ as unary,N as word};
|
package/justin.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var l,c,d=r=>(l=0,c=r,d.newline=!1,r=A(),c[l]?
|
|
1
|
+
var l,c,d=r=>(l=0,c=r,d.newline=!1,r=A(),c[l]?v():r||""),v=(r="Unexpected token",e=l,t=c.slice(0,e).split(`
|
|
2
2
|
`),n=t.pop(),i=c.slice(Math.max(0,e-40),e),p="\u032D",f=(c[e]||" ")+p,u=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${n.length+1}
|
|
3
3
|
${c[e-41]!==`
|
|
4
|
-
`,""+i}${f}${u}`)},pr=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ar=r=>(e,t,n="")=>{if(!(e||!d.string?.[String.fromCharCode(r)]))return h(),
|
|
4
|
+
`,""+i}${f}${u}`)},pr=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),k=(r,e=l,t)=>{for(;t=r(c.charCodeAt(l));)l+=t;return c.slice(e,l)},h=(r=1)=>c[l+=r],F=r=>l=r,A=(r=0,e)=>{let t,n,i,p,f;for(e&&d.asi&&(d.newline=!1);(t=d.space())&&(f=d.newline,1)&&t!==e&&(i=((p=I[t])&&p(n,r))??(n&&f&&d.asi?.(n,r,A))??(!n&&k(d.id)));)n=i;return e&&(t==e?(l++,e===125&&d.asi&&(d.newline=!0)):v("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),n},N=(r,e=l)=>{for(;(r=c.charCodeAt(l))<=32;)d.asi&&r===10&&(d.newline=!0),l++;return r},fr=(r=l)=>{for(;c.charCodeAt(r)<=32;)r++;return c.charCodeAt(r)},Le=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,ur=(r,e=r.length)=>c.substr(l,e)===r&&!d.id(c.charCodeAt(l+e)),_e=()=>(h(),A(0,41)),I=[],sr={},E=(r,e=32,t,n=r.charCodeAt(0),i=r.length,p=I[n],f=r.toUpperCase()!==r,u,g)=>(e=sr[r]=!p&&sr[r]||e,I[n]=(C,w,y,S=l)=>(u=y,(y?r==y:(i<2||r.charCodeAt(1)===c.charCodeAt(l+1)&&(i<3||c.substr(l,i)==r))&&(!f||!d.id(c.charCodeAt(l+i)))&&(u=y=r))&&w<e&&(l+=i,(g=t(C))?pr(g,S):(l=S,u=0,!f&&!p&&v()),g)||p?.(C,w,u))),m=(r,e,t=!1)=>E(r,e,n=>n&&(i=>i&&[r,n,i])(A(e-(t?.5:0)))),a=(r,e,t)=>E(r,e,n=>t?n&&[r,n]:!n&&(n=A(e-.5))&&[r,n]),L=(r,e)=>E(r,200,t=>!t&&[,e]),V=(r,e,t)=>E(r,e,(n,i)=>(i=A(e-(t?.5:0)),n?.[0]!==r&&(n=[r,n||null]),i?.[0]===r?n.push(...i.slice(1)):n.push(i||null),n)),U=(r,e)=>E(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),Y=(r,e)=>E(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),T=(r,e,t,n=r.charCodeAt(0),i=r.length,p=I[n],f)=>I[n]=(u,g,C,w=l)=>!u&&(C?r==C:(i<2||c.substr(l,i)==r)&&(C=r))&&g<e&&!d.id(c.charCodeAt(l+i))&&(!d.prop||d.prop(l+i))&&(F(l+i),(f=t())?pr(f,w):F(w),f)||p?.(u,g,C);Object.defineProperty(d,"space",{configurable:!0,enumerable:!0,get:()=>N,set:r=>N=r});var J={},s=(r,e,t=J[r])=>J[r]=(...n)=>e(...n)||t?.(...n),o=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):J[r[0]]?.(...r.slice(1))??v(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var X=46,B=48,$=57,Dr=69,Fr=101,Gr=43,Xr=45,G=95,lr=110,$r=97,Qr=102,jr=65,Hr=70,mr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),Z=r=>{let e=mr(k(t=>t===X&&c.charCodeAt(l+1)!==X||t>=B&&t<=$||t===G||((t===Dr||t===Fr)&&((t=c.charCodeAt(l+1))>=B&&t<=$||t===Gr||t===Xr)?2:0)));return c.charCodeAt(l)===lr?(h(),[,BigInt(e)]):(r=+e)!=r?v():[,r]},Kr={2:r=>r===48||r===49||r===G,8:r=>r>=48&&r<=55||r===G,16:r=>r>=B&&r<=$||r>=$r&&r<=Qr||r>=jr&&r<=Hr||r===G};d.number=null;I[X]=r=>!r&&c.charCodeAt(l+1)!==X&&Z();for(let r=B;r<=$;r++)I[r]=e=>e?void 0:Z();I[B]=r=>{if(r)return;let e=d.number;if(e){for(let[t,n]of Object.entries(e))if(t[0]==="0"&&c[l+1]?.toLowerCase()===t[1]){h(2);let i=mr(k(Kr[n]));return c.charCodeAt(l)===lr?(h(),[,BigInt("0"+t[1]+i)]):[,parseInt(i,n)]}}return Z()};var Wr=92,cr=34,dr=39,zr={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ar=r=>(e,t,n="")=>{if(!(e||!d.string?.[String.fromCharCode(r)]))return h(),k(i=>i-r&&(i===Wr?(n+=zr[c[l+1]]||c[l+1],2):(n+=c[l],1))),c[l]===String.fromCharCode(r)?h():v("Bad string"),[,n]};I[cr]=Ar(cr);I[dr]=Ar(dr);d.string={'"':!0};var Jr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>m(r,Jr,!0));var hr=(r,e,t,n)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=o(r[1]),n=r[2],i=>e(t(i),n,i)):r[0]==="[]"&&r.length===3?(t=o(r[1]),n=o(r[2]),i=>e(t(i),n(i),i)):r[0]==="()"&&r.length===2?hr(r[1],e):(()=>{throw Error("Invalid assignment target")})(),gr={"=":(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 gr)s(r,(e,t)=>(t=o(t),hr(e,(n,i,p)=>gr[r](n,i,t(p)))));var Vr=30,Yr=40,yr=140;m("!",yr);a("!",yr);m("||",Vr);m("&&",Yr);s("!",r=>(r=o(r),e=>!r(e)));s("||",(r,e)=>(r=o(r),e=o(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=o(r),e=o(e),t=>r(t)&&e(t)));var Zr=50,qr=60,xr=70,Cr=100,br=140;m("|",Zr);m("&",xr);m("^",qr);m(">>",Cr);m("<<",Cr);a("~",br);s("~",r=>(r=o(r),e=>~r(e)));s("|",(r,e)=>(r=o(r),e=o(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=o(r),e=o(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=o(r),e=o(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=o(r),e=o(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=o(r),e=o(e),t=>r(t)<<e(t)));var Q=90;m("<",Q);m(">",Q);m("<=",Q);m(">=",Q);s(">",(r,e)=>(r=o(r),e=o(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=o(r),e=o(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=o(r),e=o(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=o(r),e=o(e),t=>r(t)<=e(t)));var Sr=80;m("==",Sr);m("!=",Sr);s("==",(r,e)=>(r=o(r),e=o(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=o(r),e=o(e),t=>r(t)!=e(t)));var Er=110,q=120,wr=140;m("+",Er);m("-",Er);m("*",q);m("/",q);m("%",q);a("+",wr);a("-",wr);s("+",(r,e)=>e!==void 0?(r=o(r),e=o(e),t=>r(t)+e(t)):(r=o(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=o(r),e=o(e),t=>r(t)-e(t)):(r=o(r),t=>-r(t)));s("*",(r,e)=>(r=o(r),e=o(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=o(r),e=o(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=o(r),e=o(e),t=>r(t)%e(t)));var j=150;E("++",j,r=>r?["++",r,null]:["++",A(j-1)]);E("--",j,r=>r?["--",r,null]:["--",A(j-1)]);var x=(r,e,t,n)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=o(r[1]),n=r[2],i=>e(t(i),n)):r[0]==="[]"&&r.length===3?(t=o(r[1]),n=o(r[2]),i=>e(t(i),n(i))):r[0]==="()"&&r.length===2?x(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>x(r,e===null?(t,n)=>t[n]++:(t,n)=>++t[n]));s("--",(r,e)=>x(r,e===null?(t,n)=>t[n]--:(t,n)=>--t[n]));var re=5,ee=10;V(",",ee);V(";",re,!0);var Ir=(...r)=>(r=r.map(o),e=>{let t;for(let n of r)t=n(e);return t});s(",",Ir);s(";",Ir);var te=170;U("()",te);var P=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",b=170;Y("[]",b);m(".",b);Y("()",b);var H=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=o(t[1]),n=>t(n)):(t=o(t),n=>[t(n)])),t=>r.flatMap(n=>n(t))):(e==null&&H("Missing index"),r=o(r),e=o(e),t=>{let n=e(t);return P(n)?void 0:r(t)[n]}));s(".",(r,e)=>(r=o(r),e=e[0]?e:e[1],P(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?H("Empty ()"):o(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&H("Empty argument");let n=e?e[0]===","?(e=e.slice(1).map(o),i=>e.map(p=>p(i))):(e=o(e),i=>[e(i)]):()=>[];return rr(r,(i,p,f)=>i[p](...n(f)))});var O=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&O(r[1])||r[0]==="{}"),rr=(r,e,t,n)=>r==null?H("Empty ()"):r[0]==="()"&&r.length==2?rr(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=o(r[1]),n=r[2],i=>e(t(i),n,i)):r[0]==="?."?(t=o(r[1]),n=r[2],i=>{let p=t(i);return p==null?void 0:e(p,n,i)}):r[0]==="[]"&&r.length===3?(t=o(r[1]),n=o(r[2]),i=>e(t(i),n(i),i)):r[0]==="?.[]"?(t=o(r[1]),n=o(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,n(i),i)}):(r=o(r),i=>e([r(i)],0,i)),R=rr;var ar=new WeakMap,ne=(r,...e)=>typeof r=="string"?o(d(r)):ar.get(r)||ar.set(r,oe(r,e)).get(r),Nr=57344,oe=(r,e)=>{let t=r.reduce((p,f,u)=>p+(u?String.fromCharCode(Nr+u-1):"")+f,""),n=d(t),i=p=>{if(typeof p=="string"&&p.length===1){let f=p.charCodeAt(0)-Nr,u;if(f>=0&&f<e.length)return u=e[f],ie(u)?u:[,u]}return Array.isArray(p)?p.map(i):p};return o(i(n))},ie=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),se=ne;var pe=32,fe=d.space;d.comment??={"//":`
|
|
6
6
|
`,"/*":"*/"};var er;d.space=()=>{er||(er=Object.entries(d.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=fe();){for(var e=0,t;t=er[e++];)if(r===t[2]&&c.substr(l,t[0].length)===t[0]){var n=l+t[0].length;if(t[1]===`
|
|
7
|
-
`)for(;c.charCodeAt(n)>=pe;)n++;else{for(;c[n]&&c.substr(n,t[1].length)!==t[1];)n++;c[n]&&(n+=t[1].length)}F(n),r=0;break}if(r)return r}return r};var vr=80;m("===",vr);m("!==",vr);s("===",(r,e)=>(r=o(r),e=o(e),t=>r(t)===e(t)));s("!==",(r,e)=>(r=o(r),e=o(e),t=>r(t)!==e(t)));var ue=30;m("??",ue);s("??",(r,e)=>(r=o(r),e=o(e),t=>r(t)??e(t)));var le=130,me=20;m("**",le,!0);m("**=",me,!0);s("**",(r,e)=>(r=o(r),e=o(e),t=>r(t)**e(t)));var ce=r=>{throw Error(r)};s("**=",(r,e)=>(
|
|
8
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Mr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(l))!==z;)t?t===
|
|
7
|
+
`)for(;c.charCodeAt(n)>=pe;)n++;else{for(;c[n]&&c.substr(n,t[1].length)!==t[1];)n++;c[n]&&(n+=t[1].length)}F(n),r=0;break}if(r)return r}return r};var vr=80;m("===",vr);m("!==",vr);s("===",(r,e)=>(r=o(r),e=o(e),t=>r(t)===e(t)));s("!==",(r,e)=>(r=o(r),e=o(e),t=>r(t)!==e(t)));var ue=30;m("??",ue);s("??",(r,e)=>(r=o(r),e=o(e),t=>r(t)??e(t)));var le=130,me=20;m("**",le,!0);m("**=",me,!0);s("**",(r,e)=>(r=o(r),e=o(e),t=>r(t)**e(t)));var ce=r=>{throw Error(r)};s("**=",(r,e)=>(O(r)||ce("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]**=e(i))));var kr=90;m("in",kr);m("of",kr);s("in",(r,e)=>(r=o(r),e=o(e),t=>r(t)in e(t)));var de=20,Ae=100,ge=r=>{throw Error(r)};m(">>>",Ae);m(">>>=",de,!0);s(">>>",(r,e)=>(r=o(r),e=o(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(O(r)||ge("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]>>>=e(i))));var tr=5,he=10,ye=20,Ce=r=>r[0]?.[0]===","?r[0].slice(1):r,M=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[n,...i]=r,p=Ce(i);if(n==="{}"){let f=[];for(let u of p){if(Array.isArray(u)&&u[0]==="..."){let S={};for(let _ in e)f.includes(_)||(S[_]=e[_]);t[u[1]]=S;break}let g,C,w;typeof u=="string"?g=C=u:u[0]==="="?(typeof u[1]=="string"?g=C=u[1]:[,g,C]=u[1],w=u[2]):[,g,C]=u,f.push(g);let y=e[g];y===void 0&&w&&(y=o(w)(t)),M(C,y,t)}}else if(n==="[]"){let f=0;for(let u of p){if(u===null){f++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(f);break}let g=u,C;Array.isArray(u)&&u[0]==="="&&([,g,C]=u);let w=e[f++];w===void 0&&C&&(w=o(C)(t)),M(g,w,t)}}},Or=r=>{let e=A(he-1);return e?.[0]==="in"||e?.[0]==="of"?[e[0],[r,e[1]],e[2]]:e?.[0]===","?[r,...e.slice(1)]:[r,e]};T("let",tr+1,()=>Or("let"));T("const",tr+1,()=>Or("const"));T("var",tr,()=>(N(),["var",A(ye)]));var Pr=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,n]=e,i=o(n);return typeof t=="string"?p=>{p[t]=i(p)}:p=>M(t,i(p),p)}return o(e)}),e=>{for(let t of r)t(e)});s("let",Pr);s("const",Pr);s("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var nr=20,K=r=>{throw Error(r)};m("||=",nr,!0);m("&&=",nr,!0);m("??=",nr,!0);s("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=o(e),typeof t=="string"?n=>{n[t]=e(n)}:n=>M(t,e(n),n)}return O(r)||K("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]=e(i))});s("||=",(r,e)=>(O(r)||K("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]||=e(i))));s("&&=",(r,e)=>(O(r)||K("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]&&=e(i))));s("??=",(r,e)=>(O(r)||K("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]??=e(i))));L("true",!0);L("false",!1);L("null",null);T("undefined",200,()=>[]);L("NaN",NaN);L("Infinity",1/0);var or=20;E("?",or,(r,e,t)=>r&&(e=A(or-1))&&k(n=>n===58)&&(t=A(or-1),["?",r,e,t]));s("?",(r,e,t)=>(r=o(r),e=o(e),t=o(t),n=>r(n)?e(n):t(n)));var Se=[],Ee=20;m("=>",Ee,!0);s("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r;let t=r?r[0]===","?r.slice(1):[r]:[],n=-1,i=null,p=t[t.length-1];Array.isArray(p)&&p[0]==="..."&&(n=t.length-1,i=p[1],t.length--);let f=e?.[0]==="{}";return e=o(f?["{",e[1]]:e),u=>(...g)=>{let C={};t.forEach((y,S)=>C[y]=g[S]),i&&(C[i]=g.slice(n));let w=new Proxy(C,{get:(y,S)=>S in y?y[S]:u?.[S],set:(y,S,_)=>((S in y?y:u)[S]=_,!0),has:(y,S)=>S in y||(u?S in u:!1)});try{let y=e(w);return f?void 0:y}catch(y){if(y===Se)return y[0];throw y}}});var we=140;a("...",we);s("...",r=>(r=o(r),e=>Object.entries(r(e))));var Rr=170;E("?.",Rr,(r,e)=>{if(!r)return;let t=N();return t===40?(h(),["?.()",r,A(0,41)||null]):t===91?(h(),["?.[]",r,A(0,93)]):(e=A(Rr),e?["?.",r,e]:void 0)});s("?.",(r,e)=>(r=o(r),P(e)?()=>{}:t=>r(t)?.[e]));s("?.[]",(r,e)=>(r=o(r),e=o(e),t=>{let n=e(t);return P(n)?void 0:r(t)?.[n]}));s("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(o),i=>e.map(p=>p(i))):(e=o(e),i=>[e(i)]):()=>[];if(r[0]==="?."){let i=o(r[1]),p=r[2];return P(p)?()=>{}:f=>i(f)?.[p]?.(...t(f))}if(r[0]==="?.[]"){let i=o(r[1]),p=o(r[2]);return f=>{let u=i(f),g=p(f);return P(g)?void 0:u?.[g]?.(...t(f))}}if(r[0]==="."){let i=o(r[1]),p=r[2];return P(p)?()=>{}:f=>i(f)?.[p]?.(...t(f))}if(r[0]==="[]"&&r.length===3){let i=o(r[1]),p=o(r[2]);return f=>{let u=i(f),g=p(f);return P(g)?void 0:u?.[g]?.(...t(f))}}let n=o(r);return i=>n(i)?.(...t(i))});var D=140;a("typeof",D);a("void",D);a("delete",D);T("new",D,()=>ur(".target")?(h(7),["new.target"]):["new",A(D)]);s("typeof",r=>(r=o(r),e=>typeof r(e)));s("void",r=>(r=o(r),e=>(r(e),void 0)));s("delete",r=>{if(r[0]==="."){let e=o(r[1]),t=r[2];return n=>delete e(n)[t]}if(r[0]==="[]"){let e=o(r[1]),t=o(r[2]);return n=>delete e(n)[t(n)]}return()=>!0});s("new",r=>{let e=o(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,n=t?t[0]===","?(i=>p=>i.map(f=>f(p)))(t.slice(1).map(o)):(i=>p=>[i(p)])(o(t)):()=>[];return i=>new(e(i))(...n(i))});var W=Symbol("accessor"),ir=20,Ie=40,Tr=41,Lr=123,_r=125,Ur=r=>e=>{if(e)return;N();let t=k(d.id);if(!t||(N(),c.charCodeAt(l)!==Ie))return!1;h();let n=A(0,Tr);return N(),c.charCodeAt(l)!==Lr?!1:(h(),[r,t,n,A(0,_r)])};E("get",ir-1,Ur("get"));E("set",ir-1,Ur("set"));E("(",ir-1,r=>{if(!r||typeof r!="string")return;let e=A(0,Tr)||null;if(N(),c.charCodeAt(l)===Lr)return h(),[":",r,["=>",["()",e],A(0,_r)||null]]});s("get",(r,e)=>(e=e?o(e):()=>{},t=>[[W,r,{get:function(){let n=Object.create(t||{});return n.this=this,e(n)}}]]));s("set",(r,e,t)=>(t=t?o(t):()=>{},n=>[[W,r,{set:function(i){let p=Object.create(n||{});p.this=this,p[e]=i,t(p)}}]]));var ae=20,Br=200;d.prop=r=>fr(r)!==58;var Ne=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);U("[]",Br);U("{}",Br);m(":",ae-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;if(!Ne(r))return o(["{",r]);r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(n=>o(typeof n=="string"?[":",n,n]:n));return n=>{let i={},p={};for(let f of t.flatMap(u=>u(n)))if(f[0]===W){let[,u,g]=f;p[u]={...p[u],...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?o(r):()=>{},e=>r(Object.create(e))));s(":",(r,e)=>(e=o(e),Array.isArray(r)?(r=o(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var ve=170,z=96,ke=36,Oe=123,Pe=92,Re={n:`
|
|
8
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Mr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(l))!==z;)t?t===Pe?(h(),e+=Re[c[l]]||c[l],h()):t===ke&&c.charCodeAt(l+1)===Oe?(e&&r.push([,e]),e="",h(2),r.push(A(0,125))):(e+=c[l],h(),t=c.charCodeAt(l),t===z&&e&&r.push([,e])):v("Unterminated template");return h(),r},Te=I[z];I[z]=(r,e)=>r&&e<ve?d.asi&&d.newline?void 0:(h(),["``",r,...Mr()]):r?Te?.(r,e):(h(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Mr()));s("`",(...r)=>(r=r.map(o),e=>r.map(t=>t(e)).join("")));s("``",(r,...e)=>{r=o(r);let t=[],n=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):n.push(o(p));let i=Object.assign([...t],{raw:t});return p=>r(p)(i,...n.map(f=>f(p)))});d.string["'"]=!0;d.number={"0x":16,"0b":2,"0o":8};export{Y as access,m as binary,o as compile,c as cur,se as default,v as err,A as expr,U as group,Le as id,l as idx,T as keyword,L as literal,pr as loc,I as lookup,V as nary,k as next,s as operator,J as operators,_e as parens,d as parse,fr as peek,sr as prec,F as seek,h as skip,N as space,E as token,a as unary,ur as word};
|
package/package.json
CHANGED
package/parse.js
CHANGED
|
@@ -51,13 +51,13 @@ export let idx, cur,
|
|
|
51
51
|
)
|
|
52
52
|
) token = newNode;
|
|
53
53
|
|
|
54
|
-
if (end) cc == end ? idx
|
|
54
|
+
if (end) cc == end ? (idx++, end === 125 && parse.asi && (parse.newline = true)) : err('Unclosed ' + String.fromCharCode(end - (end > 42 ? 2 : 1)));
|
|
55
55
|
|
|
56
56
|
return token;
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
// skip space chars, return first non-space character
|
|
60
|
-
space =
|
|
60
|
+
space = (cc, from = idx) => {
|
|
61
61
|
while ((cc = cur.charCodeAt(idx)) <= SPACE) {
|
|
62
62
|
if (parse.asi && cc === 10) parse.newline = true
|
|
63
63
|
idx++
|
|
@@ -143,6 +143,14 @@ export let idx, cur,
|
|
|
143
143
|
(seek(idx + l), (r = map()) ? loc(r, from) : seek(from), r) ||
|
|
144
144
|
prev?.(a, curPrec, curOp);
|
|
145
145
|
|
|
146
|
+
// Keep parse.space overrides in sync with the exported binding used by features.
|
|
147
|
+
Object.defineProperty(parse, 'space', {
|
|
148
|
+
configurable: true,
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: () => space,
|
|
151
|
+
set: fn => (space = fn)
|
|
152
|
+
});
|
|
153
|
+
|
|
146
154
|
// === Compile: AST → Evaluator ===
|
|
147
155
|
|
|
148
156
|
|
package/subscript.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var s,u,f=r=>(s=0,u=r,f.newline=!1,r=h(),u[s]?
|
|
2
|
-
`),
|
|
1
|
+
var s,u,f=r=>(s=0,u=r,f.newline=!1,r=h(),u[s]?C():r||""),C=(r="Unexpected token",e=s,t=u.slice(0,e).split(`
|
|
2
|
+
`),n=t.pop(),o=u.slice(Math.max(0,e-40),e),p="\u032D",d=(u[e]||" ")+p,A=u.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${n.length+1}
|
|
3
3
|
${u[e-41]!==`
|
|
4
|
-
`,""+
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},
|
|
4
|
+
`,""+o}${d}${A}`)},z=(r,e=s)=>(Array.isArray(r)&&(r.loc=e),r),_=(r,e=s,t)=>{for(;t=r(u.charCodeAt(s));)s+=t;return u.slice(e,s)},y=(r=1)=>u[s+=r],v=r=>s=r,h=(r=0,e)=>{let t,n,o,p,d;for(e&&f.asi&&(f.newline=!1);(t=f.space())&&(d=f.newline,1)&&t!==e&&(o=((p=c[t])&&p(n,r))??(n&&d&&f.asi?.(n,r,h))??(!n&&_(f.id)));)n=o;return e&&(t==e?(s++,e===125&&f.asi&&(f.newline=!0)):C("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),n},G=(r,e=s)=>{for(;(r=u.charCodeAt(s))<=32;)f.asi&&r===10&&(f.newline=!0),s++;return r},Nr=(r=s)=>{for(;u.charCodeAt(r)<=32;)r++;return u.charCodeAt(r)},$r=f.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,Fr=(r,e=r.length)=>u.substr(s,e)===r&&!f.id(u.charCodeAt(s+e)),Or=()=>(y(),h(0,41)),c=[],W={},g=(r,e=32,t,n=r.charCodeAt(0),o=r.length,p=c[n],d=r.toUpperCase()!==r,A,w)=>(e=W[r]=!p&&W[r]||e,c[n]=(S,I,T,H=s)=>(A=T,(T?r==T:(o<2||r.charCodeAt(1)===u.charCodeAt(s+1)&&(o<3||u.substr(s,o)==r))&&(!d||!f.id(u.charCodeAt(s+o)))&&(A=T=r))&&I<e&&(s+=o,(w=t(S))?z(w,H):(s=H,A=0,!d&&!p&&C()),w)||p?.(S,I,A))),m=(r,e,t=!1)=>g(r,e,n=>n&&(o=>o&&[r,n,o])(h(e-(t?.5:0)))),E=(r,e,t)=>g(r,e,n=>t?n&&[r,n]:!n&&(n=h(e-.5))&&[r,n]),Xr=(r,e)=>g(r,200,t=>!t&&[,e]),$=(r,e,t)=>g(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)),J=(r,e)=>g(r[0],e,t=>!t&&[r,h(0,r.charCodeAt(1))||null]),F=(r,e)=>g(r[0],e,t=>t&&[r,t,h(0,r.charCodeAt(1))||null]),Br=(r,e,t,n=r.charCodeAt(0),o=r.length,p=c[n],d)=>c[n]=(A,w,S,I=s)=>!A&&(S?r==S:(o<2||u.substr(s,o)==r)&&(S=r))&&w<e&&!f.id(u.charCodeAt(s+o))&&(!f.prop||f.prop(s+o))&&(v(s+o),(d=t())?z(d,I):v(I),d)||p?.(A,w,S);Object.defineProperty(f,"space",{configurable:!0,enumerable:!0,get:()=>G,set:r=>G=r});var N={},l=(r,e,t=N[r])=>N[r]=(...n)=>e(...n)||t?.(...n),i=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):N[r[0]]?.(...r.slice(1))??C(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var R=46,P=48,D=57,pr=69,ur=101,mr=43,fr=45,U=95,K=110,dr=97,Ar=102,cr=65,hr=70,V=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),O=r=>{let e=V(_(t=>t===R&&u.charCodeAt(s+1)!==R||t>=P&&t<=D||t===U||((t===pr||t===ur)&&((t=u.charCodeAt(s+1))>=P&&t<=D||t===mr||t===fr)?2:0)));return u.charCodeAt(s)===K?(y(),[,BigInt(e)]):(r=+e)!=r?C():[,r]},gr={2:r=>r===48||r===49||r===U,8:r=>r>=48&&r<=55||r===U,16:r=>r>=P&&r<=D||r>=dr&&r<=Ar||r>=cr&&r<=hr||r===U};f.number=null;c[R]=r=>!r&&u.charCodeAt(s+1)!==R&&O();for(let r=P;r<=D;r++)c[r]=e=>e?void 0:O();c[P]=r=>{if(r)return;let e=f.number;if(e){for(let[t,n]of Object.entries(e))if(t[0]==="0"&&u[s+1]?.toLowerCase()===t[1]){y(2);let o=V(_(gr[n]));return u.charCodeAt(s)===K?(y(),[,BigInt("0"+t[1]+o)]):[,parseInt(o,n)]}}return O()};var Cr=92,Y=34,Z=39,yr={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},q=r=>(e,t,n="")=>{if(!(e||!f.string?.[String.fromCharCode(r)]))return y(),_(o=>o-r&&(o===Cr?(n+=yr[u[s+1]]||u[s+1],2):(n+=u[s],1))),u[s]===String.fromCharCode(r)?y():C("Bad string"),[,n]};c[Y]=q(Y);c[Z]=q(Z);f.string={'"':!0};var Sr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>m(r,Sr,!0));var j=(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?j(r[1],e):(()=>{throw Error("Invalid assignment target")})(),x={"=":(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 x)l(r,(e,t)=>(t=i(t),j(e,(n,o,p)=>x[r](n,o,t(p)))));var Er=30,wr=40,a=140;m("!",a);E("!",a);m("||",Er);m("&&",wr);l("!",r=>(r=i(r),e=>!r(e)));l("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));l("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var _r=50,Ir=60,Pr=70,b=100,Tr=140;m("|",_r);m("&",Pr);m("^",Ir);m(">>",b);m("<<",b);E("~",Tr);l("~",r=>(r=i(r),e=>~r(e)));l("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));l("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));l("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));l(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));l("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var M=90;m("<",M);m(">",M);m("<=",M);m(">=",M);l(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));l("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));l(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));l("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var rr=80;m("==",rr);m("!=",rr);l("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));l("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var er=110,X=120,tr=140;m("+",er);m("-",er);m("*",X);m("/",X);m("%",X);E("+",tr);E("-",tr);l("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));l("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));l("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));l("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));l("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var k=150;g("++",k,r=>r?["++",r,null]:["++",h(k-1)]);g("--",k,r=>r?["--",r,null]:["--",h(k-1)]);var B=(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?B(r[1],e):(()=>{throw Error("Invalid increment target")})();l("++",(r,e)=>B(r,e===null?(t,n)=>t[n]++:(t,n)=>++t[n]));l("--",(r,e)=>B(r,e===null?(t,n)=>t[n]--:(t,n)=>--t[n]));var Ur=5,Rr=10;$(",",Rr);$(";",Ur,!0);var nr=(...r)=>(r=r.map(i),e=>{let t;for(let n of r)t=n(e);return t});l(",",nr);l(";",nr);var Dr=170;J("()",Dr);var or=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",Q=170;F("[]",Q);m(".",Q);F("()",Q);var L=r=>{throw Error(r)};l("[]",(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&&L("Missing index"),r=i(r),e=i(e),t=>{let n=e(t);return or(n)?void 0:r(t)[n]}));l(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],or(e)?()=>{}:t=>r(t)[e]));l("()",(r,e)=>{if(e===void 0)return r==null?L("Empty ()"):i(r);let t=o=>o?.[0]===","&&o.slice(1).some(p=>p==null||t(p));t(e)&&L("Empty argument");let n=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(p=>p(o))):(e=i(e),o=>[e(o)]):()=>[];return ir(r,(o,p,d)=>o[p](...n(d)))});var ir=(r,e,t,n)=>r==null?L("Empty ()"):r[0]==="()"&&r.length==2?ir(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 p=t(o);return p==null?void 0:e(p,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 p=t(o);return p==null?void 0:e(p,n(o),o)}):(r=i(r),o=>e([r(o)],0,o));var sr=new WeakMap,Mr=(r,...e)=>typeof r=="string"?i(f(r)):sr.get(r)||sr.set(r,kr(r,e)).get(r),lr=57344,kr=(r,e)=>{let t=r.reduce((p,d,A)=>p+(A?String.fromCharCode(lr+A-1):"")+d,""),n=f(t),o=p=>{if(typeof p=="string"&&p.length===1){let d=p.charCodeAt(0)-lr,A;if(d>=0&&d<e.length)return A=e[d],Lr(A)?A:[,A]}return Array.isArray(p)?p.map(o):p};return i(o(n))},Lr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),de=Mr;export{F as access,m as binary,i as compile,u as cur,de as default,C as err,h as expr,J as group,$r as id,s as idx,Br as keyword,Xr as literal,z as loc,c as lookup,$ as nary,_ as next,l as operator,N as operators,Or as parens,f as parse,Nr as peek,W as prec,v as seek,y as skip,G as space,g as token,E as unary,Fr as word};
|