UNPKG

subscript

Version:

Modular expression parser & evaluator

8 lines (7 loc) 14.8 kB
var f,u,d=r=>(f=0,u=r,d.enter?.(),r=y(),u[f]?N():r||""),N=(r="Unexpected token",t=f,e=u.slice(0,t).split(` `),o=e.pop(),i=u.slice(Math.max(0,t-40),t),p="\u032D",l=(u[t]||" ")+p,m=u.slice(t+1,t+20))=>{throw SyntaxError(`${r} at ${e.length+1}:${o.length+1} ${i}${l}${m}`)},ir=(r,t=f)=>(Array.isArray(r)&&(r.loc=t),r),L=(r,t=f,e)=>{for(;e=r(u.charCodeAt(f));)f+=e;return u.slice(t,f)},C=(r=1)=>u[f+=r],M=r=>f=r,y=(r=0,t)=>{let e,o,i;for(t&&d.enter?.(r,t);(e=d.space())&&e!==t&&(i=d.step(o,r,e,y));)o=i;return t&&(e==t?(f++,d.exit?.(r,t)):N("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),o},K=(r=f)=>{for(;u.charCodeAt(r)<=32;)r++;return u.charCodeAt(r)},Bt=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,sr=(r,t=r.length)=>u.substr(f,t)===r&&!d.id(u.charCodeAt(f+t)),Mt=()=>(C(),y(0,41)),w=[],H={},I=(r,t=32,e,o=r.charCodeAt(0),i=r.length,p=w[o],l=r.toUpperCase()!==r,m,A)=>(t=H[r]=!p&&H[r]||t,w[o]=(h,S,g,E=f)=>(m=g,(g?r==g:(i<2||r.charCodeAt(1)===u.charCodeAt(f+1)&&(i<3||u.substr(f,i)==r))&&(!l||!d.id(u.charCodeAt(f+i)))&&(m=g=r))&&S<t&&(f+=i,(A=e(h))?ir(A,E):(f=E,m=0,!l&&!p&&!h&&N()),A)||p?.(h,S,m))),c=(r,t,e=!1)=>I(r,t,o=>o&&(i=>i&&[r,o,i])(y(t-(e?.5:0)))),k=(r,t,e)=>I(r,t,o=>e?o&&[r,o]:!o&&(o=y(t-.5))&&[r,o]),T=(r,t)=>I(r,200,e=>!e&&[,t]),W=(r,t,e,o)=>I(r,t,(i,p,l=i)=>(p=y(t-(e?.5:0)),i?.[0]!==r&&(i=[r,i||null]),p?.[0]===r?i.push(...p.slice(1)):p?i.push(p):o||K()===r.charCodeAt(0)?i.push(null):l&&i.length===2&&(i=i[1]),i)),a=(r,t)=>I(r[0],t,e=>!e&&[r,y(0,r.charCodeAt(1))||null]),z=(r,t)=>I(r[0],t,e=>e&&[r,e,y(0,r.charCodeAt(1))||null]),J=(r,t)=>(d.space(),t=u.charCodeAt(f),d.id(t)&&(t<48||t>57)?L(d.id):y(r)),pr=(r,t)=>I(r,t,e=>e&&(o=>o&&[r,e,o])(J(t))),D=(r,t,e,o=r.charCodeAt(0),i=r.length,p=w[o],l)=>(H[r]??=t,w[o]=(m,A,h,S=f)=>!m&&(h?r==h:(i<2||u.substr(f,i)==r)&&(h=r))&&A<t&&!d.id(u.charCodeAt(f+i))&&(!d.prop||d.prop(f+i))&&(M(f+i),(l=e())?ir(l,S):M(S),l)||p?.(m,A,h));d.space=r=>{for(;(r=u.charCodeAt(f))<=32;)f++;return r};d.step=(r,t,e,o,i)=>(i=w[e])&&i(r,t)||(r?null:L(d.id)||null);var j={},s=(r,t,e=j[r])=>j[r]=(...o)=>t(...o)||e?.(...o),n=r=>Array.isArray(r)?r[0]==null?(t=>()=>t)(r[1]):j[r[0]]?.(...r.slice(1))??N(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:t=>t?.[r];var V=46,R=48,U=57,mr=69,fr=101,Dr=43,Fr=45,lr=95,ur=110,Gr=97,Xr=102,$r=65,Qr=70,cr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),Y=r=>{let t=cr(L(e=>e===V&&(e=u.charCodeAt(f+1))!==V&&!(d.id(e)&&e>U&&e!==fr&&e!==mr)||e>=R&&e<=U||e===lr||((e===mr||e===fr)&&((e=u.charCodeAt(f+1))>=R&&e<=U||e===Dr||e===Fr)?2:0)));return u.charCodeAt(f)===ur?(C(),[,BigInt(t)]):(r=+t)!=r?N():[,r]},Hr=r=>t=>t===lr||t>=R&&t<=U&&t-R<r||r===16&&(t>=Gr&&t<=Xr||t>=$r&&t<=Qr);d.number=null;w[V]=r=>!r&&u.charCodeAt(f+1)>=R&&u.charCodeAt(f+1)<=U&&Y();for(let r=R;r<=U;r++)w[r]=t=>t?void 0:Y();w[R]=r=>{if(r)return;let t=d.number;if(t){for(let[e,o]of Object.entries(t))if(e[0]==="0"&&u[f+1]?.toLowerCase()===e[1]){C(2);let i=cr(L(Hr(o)));return u.charCodeAt(f)===ur?(C(),[,BigInt("0"+e[1]+i)]):[,parseInt(i,o)]}}return Y()};var jr=92,dr=34,Ar=39,hr=117,gr=120,Kr=123,Wr=125,yr=10,zr=13,Jr={n:` `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v",0:"\0"},Cr=r=>r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:-1,Sr=r=>(t,e,o="",i=String.fromCharCode(r))=>{if(t||!d.string?.[i])return;C();let p=()=>{let l=u.charCodeAt(f+1);if(l===yr)return 2;if(l===zr)return u.charCodeAt(f+2)===yr?3:2;if(l===gr||l===hr&&u.charCodeAt(f+2)!==Kr){let m=l===gr?2:4,A=0,h;for(let S=0;S<m;S++){if((h=Cr(u.charCodeAt(f+2+S)))<0)return o+=u[f+1],2;A=A*16+h}return o+=String.fromCharCode(A),2+m}if(l===hr){let m=0,A=f+3,h;for(;(h=Cr(u.charCodeAt(A)))>=0;)m=m*16+h,A++;return A>f+3&&m<=1114111&&u.charCodeAt(A)===Wr?(o+=String.fromCodePoint(m),A-f+1):(o+=u[f+1],2)}return o+=Jr[u[f+1]]||u[f+1],2};return L(l=>l-r&&(l!==jr?(o+=u[f],1):p())),u[f]===i?C():N("Bad string"),[,o]};w[dr]=Sr(dr);w[Ar]=Sr(Ar);d.string={'"':!0};var Vr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>c(r,Vr,!0));var Yr=30,Zr=40,qr=140;k("!",qr);c("||",Yr);c("&&",Zr);var xr=50,br=60,rt=70,Er=100,tt=140;c("|",xr);c("&",rt);c("^",br);c(">>",Er);c("<<",Er);k("~",tt);var F=90;c("<",F);c(">",F);c("<=",F);c(">=",F);var wr=80;c("==",wr);c("!=",wr);var Ir=110,Z=120,kr=140;c("+",Ir);c("-",Ir);c("*",Z);c("/",Z);c("%",Z);k("+",kr);k("-",kr);var G=150;I("++",G,r=>r?["++",r,null]:["++",y(G-1)]);I("--",G,r=>r?["--",r,null]:["--",y(G-1)]);var et=5,ot=10;W(",",ot);W(";",et,!0,!0);var nt=170;a("()",nt);var Nr=170,it=160;z("[]",Nr);pr(".",Nr);z("()",it);var st=32,pt=d.space;d.comment??={"//":` `,"/*":"*/"};var q;d.space=()=>{q||(q=Object.entries(d.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=pt();){for(var t=0,e;e=q[t++];)if(r===e[2]&&u.substr(f,e[0].length)===e[0]){var o=f+e[0].length;if(e[1]===` `)for(;u.charCodeAt(o)>=st;)o++;else{for(;u[o]&&u.substr(o,e[1].length)!==e[1];)o++;u[o]&&(o+=e[1].length)}M(o),r=0;break}if(r)return r}return r};var vr=80;c("===",vr);c("!==",vr);var mt=30;c("??",mt);var ft=130,lt=20;c("**",ft,!0);c("**=",lt,!0);var Lr=90;c("in",Lr);c("of",Lr);var ut=20,ct=100;c(">>>",ct);c(">>>=",ut,!0);var x=20;c("||=",x,!0);c("&&=",x,!0);c("??=",x,!0);T("true",!0);T("false",!1);T("null",null);D("undefined",200,()=>[]);T("NaN",NaN);T("Infinity",1/0);var b=20;I("?",b,(r,t,e)=>r&&(t=y(b-1))&&L(o=>o===58)&&(e=y(b-1),["?",r,t,e]));var dt=20;c("=>",dt,!0);var At=20;k("...",At);var Or=170;I("?.",Or,(r,t)=>{if(!r)return;let e=d.space();return e===40?(C(),["?.()",r,y(0,41)||null]):e===91?(C(),["?.[]",r,y(0,93)]):(t=J(Or),t?["?.",r,t]:void 0)});var rr=140,Rr=160,ht=Rr+1;k("typeof",rr);k("void",rr);k("delete",rr);var gt=r=>d.space()===40?(C(),["()",r,y(0,41)||null]):r;D("new",ht,()=>sr(".target")?(C(7),["new.target"]):["new",gt(y(Rr))]);var yt=20,Pr=200;d.prop=r=>K(r)!==58;a("[]",Pr);a("{}",Pr);c(":",yt-1,!0);var Ct=170,tr=96,St=36,Et=123,wt=92,It={n:` `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Tr=()=>{let r=[],t="",e;for(;(e=u.charCodeAt(f))!==tr;)e?e===wt?(C(),t+=It[u[f]]||u[f],C()):e===St&&u.charCodeAt(f+1)===Et?(r.push([,t]),t="",C(2),r.push(y(0,125))):(t+=u[f],C()):N("Unterminated template");return r.push([,t]),C(),r},kt=r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r],Nt=w[tr];w[tr]=(r,t)=>r&&t<Ct?d.asi&&d.newline?void 0:(C(),["``",r,...Tr()]):r?Nt?.(r,t):(C(),kt(Tr()));d.string["'"]=!0;d.number={"0x":16,"0b":2,"0o":8};var _r=(r,t,e,o)=>typeof r=="string"?i=>t(i,r,i):r[0]==="."?(e=n(r[1]),o=r[2],i=>t(e(i),o,i)):r[0]==="[]"&&r.length===3?(e=n(r[1]),o=n(r[2]),i=>t(e(i),o(i),i)):r[0]==="()"&&r.length===2?_r(r[1],t):(()=>{throw Error("Invalid assignment target")})(),Ur={"=":(r,t,e)=>r[t]=e,"+=":(r,t,e)=>r[t]+=e,"-=":(r,t,e)=>r[t]-=e,"*=":(r,t,e)=>r[t]*=e,"/=":(r,t,e)=>r[t]/=e,"%=":(r,t,e)=>r[t]%=e,"|=":(r,t,e)=>r[t]|=e,"&=":(r,t,e)=>r[t]&=e,"^=":(r,t,e)=>r[t]^=e,">>=":(r,t,e)=>r[t]>>=e,"<<=":(r,t,e)=>r[t]<<=e};for(let r in Ur)s(r,(t,e)=>(e=n(e),_r(t,(o,i,p)=>Ur[r](o,i,e(p)))));s("!",r=>(r=n(r),t=>!r(t)));s("||",(r,t)=>(r=n(r),t=n(t),e=>r(e)||t(e)));s("&&",(r,t)=>(r=n(r),t=n(t),e=>r(e)&&t(e)));s("~",r=>(r=n(r),t=>~r(t)));s("|",(r,t)=>(r=n(r),t=n(t),e=>r(e)|t(e)));s("&",(r,t)=>(r=n(r),t=n(t),e=>r(e)&t(e)));s("^",(r,t)=>(r=n(r),t=n(t),e=>r(e)^t(e)));s(">>",(r,t)=>(r=n(r),t=n(t),e=>r(e)>>t(e)));s("<<",(r,t)=>(r=n(r),t=n(t),e=>r(e)<<t(e)));s(">",(r,t)=>(r=n(r),t=n(t),e=>r(e)>t(e)));s("<",(r,t)=>(r=n(r),t=n(t),e=>r(e)<t(e)));s(">=",(r,t)=>(r=n(r),t=n(t),e=>r(e)>=t(e)));s("<=",(r,t)=>(r=n(r),t=n(t),e=>r(e)<=t(e)));s("==",(r,t)=>(r=n(r),t=n(t),e=>r(e)==t(e)));s("!=",(r,t)=>(r=n(r),t=n(t),e=>r(e)!=t(e)));s("+",(r,t)=>t!==void 0?(r=n(r),t=n(t),e=>r(e)+t(e)):(r=n(r),e=>+r(e)));s("-",(r,t)=>t!==void 0?(r=n(r),t=n(t),e=>r(e)-t(e)):(r=n(r),e=>-r(e)));s("*",(r,t)=>(r=n(r),t=n(t),e=>r(e)*t(e)));s("/",(r,t)=>(r=n(r),t=n(t),e=>r(e)/t(e)));s("%",(r,t)=>(r=n(r),t=n(t),e=>r(e)%t(e)));var er=(r,t,e,o)=>typeof r=="string"?i=>t(i,r):r[0]==="."?(e=n(r[1]),o=r[2],i=>t(e(i),o)):r[0]==="[]"&&r.length===3?(e=n(r[1]),o=n(r[2]),i=>t(e(i),o(i))):r[0]==="()"&&r.length===2?er(r[1],t):(()=>{throw Error("Invalid increment target")})();s("++",(r,t)=>er(r,t===null?(e,o)=>e[o]++:(e,o)=>++e[o]));s("--",(r,t)=>er(r,t===null?(e,o)=>e[o]--:(e,o)=>--e[o]));var ar=(...r)=>(r=r.map(n),t=>{let e;for(let o of r)e=o(t);return e});s(",",ar);s(";",ar);var P=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",X=r=>{throw Error(r)};s("[]",(r,t)=>t===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(e=>e==null?(()=>{}):e[0]==="..."?(e=n(e[1]),o=>e(o)):(e=n(e),o=>[e(o)])),e=>r.flatMap(o=>o(e))):(t==null&&X("Missing index"),r=n(r),t=n(t),e=>{let o=t(e);return P(o)?void 0:r(e)[o]}));s(".",(r,t)=>(r=n(r),t=t[0]?t:t[1],P(t)?()=>{}:e=>r(e)[t]));s("()",(r,t)=>{if(t===void 0)return r==null?X("Empty ()"):n(r);let e=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||e(p));e(t)&&X("Empty argument");let o=t?t[0]===","?(t=t.slice(1).map(n),i=>t.map(p=>p(i))):(t=n(t),i=>[t(i)]):()=>[];return or(r,(i,p,l)=>i[p](...o(l)))});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]==="{}"),or=(r,t,e,o)=>r==null?X("Empty ()"):r[0]==="()"&&r.length==2?or(r[1],t):typeof r=="string"?i=>t(i,r,i):r[0]==="."?(e=n(r[1]),o=r[2],i=>t(e(i),o,i)):r[0]==="?."?(e=n(r[1]),o=r[2],i=>{let p=e(i);return p==null?void 0:t(p,o,i)}):r[0]==="[]"&&r.length===3?(e=n(r[1]),o=n(r[2]),i=>t(e(i),o(i),i)):r[0]==="?.[]"?(e=n(r[1]),o=n(r[2]),i=>{let p=e(i);return p==null?void 0:t(p,o(i),i)}):(r=n(r),i=>t([r(i)],0,i)),O=or;s("===",(r,t)=>(r=n(r),t=n(t),e=>r(e)===t(e)));s("!==",(r,t)=>(r=n(r),t=n(t),e=>r(e)!==t(e)));s("??",(r,t)=>(r=n(r),t=n(t),e=>r(e)??t(e)));var vt=r=>{throw Error(r)};s("**",(r,t)=>(r=n(r),t=n(t),e=>r(e)**t(e)));s("**=",(r,t)=>(v(r)||vt("Invalid assignment target"),t=n(t),O(r,(e,o,i)=>e[o]**=t(i))));s("in",(r,t)=>(r=n(r),t=n(t),e=>r(e)in t(e)));var Lt=r=>{throw Error(r)};s(">>>",(r,t)=>(r=n(r),t=n(t),e=>r(e)>>>t(e)));s(">>>=",(r,t)=>(v(r)||Lt("Invalid assignment target"),t=n(t),O(r,(e,o,i)=>e[o]>>>=t(i))));var Ot=r=>r[0]?.[0]===","?r[0].slice(1):r,B=(r,t,e)=>{if(typeof r=="string"){e[r]=t;return}let[o,...i]=r,p=Ot(i);if(o==="{}"){let l=[];for(let m of p){if(Array.isArray(m)&&m[0]==="..."){let E={};for(let _ in t)l.includes(_)||(E[_]=t[_]);e[m[1]]=E;break}let A,h,S;typeof m=="string"?A=h=m:m[0]==="="?(typeof m[1]=="string"?A=h=m[1]:[,A,h]=m[1],S=m[2]):[,A,h]=m,l.push(A);let g=t[A];g===void 0&&S&&(g=n(S)(e)),B(h,g,e)}}else if(o==="[]"){let l=0;for(let m of p){if(m===null){l++;continue}if(Array.isArray(m)&&m[0]==="..."){e[m[1]]=t.slice(l);break}let A=m,h;Array.isArray(m)&&m[0]==="="&&([,A,h]=m);let S=t[l++];S===void 0&&h&&(S=n(h)(e)),B(A,S,e)}}},nr=(...r)=>(r=r.map(t=>{if(typeof t=="string")return e=>{e[t]=void 0};if(t[0]==="="){let[,e,o]=t,i=n(o);return typeof e=="string"?p=>{p[e]=i(p)}:p=>B(e,i(p),p)}return n(t)}),t=>{for(let e of r)e(t)});s("let",nr);s("const",nr);s("var",nr);var $=r=>{throw Error(r)};s("=",(r,t)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let e=r[1];return t=n(t),typeof e=="string"?o=>{o[e]=t(o)}:o=>B(e,t(o),o)}return v(r)||$("Invalid assignment target"),t=n(t),O(r,(e,o,i)=>e[o]=t(i))});s("||=",(r,t)=>(v(r)||$("Invalid assignment target"),t=n(t),O(r,(e,o,i)=>e[o]||=t(i))));s("&&=",(r,t)=>(v(r)||$("Invalid assignment target"),t=n(t),O(r,(e,o,i)=>e[o]&&=t(i))));s("??=",(r,t)=>(v(r)||$("Invalid assignment target"),t=n(t),O(r,(e,o,i)=>e[o]??=t(i))));s("?",(r,t,e)=>(r=n(r),t=n(t),e=n(e),o=>r(o)?t(o):e(o)));var Rt=[];s("=>",(r,t)=>{r=r?.[0]==="()"?r[1]:r;let e=r?r[0]===","?r.slice(1):[r]:[],o=-1,i=null,p=e[e.length-1];Array.isArray(p)&&p[0]==="..."&&(o=e.length-1,i=p[1],e.length--);let l=t?.[0]==="{}";return t=n(l?["{",t[1]]:t),m=>(...A)=>{let h={};e.forEach((g,E)=>h[g]=A[E]),i&&(h[i]=A.slice(o));let S=new Proxy(h,{get:(g,E)=>E in g?g[E]:m?.[E],set:(g,E,_)=>((E in g?g:m)[E]=_,!0),has:(g,E)=>E in g||(m?E in m:!1)});try{let g=t(S);return l?void 0:g}catch(g){if(g===Rt)return g[0];throw g}}});s("...",r=>(r=n(r),t=>Object.entries(r(t))));s("?.",(r,t)=>(r=n(r),P(t)?()=>{}:e=>r(e)?.[t]));s("?.[]",(r,t)=>(r=n(r),t=n(t),e=>{let o=t(e);return P(o)?void 0:r(e)?.[o]}));s("?.()",(r,t)=>{let e=t?t[0]===","?(t=t.slice(1).map(n),i=>t.map(p=>p(i))):(t=n(t),i=>[t(i)]):()=>[];if(r[0]==="."||r[0]==="?."){let i=n(r[1]),p=r[2];return P(p)?()=>{}:l=>i(l)?.[p]?.(...e(l))}if((r[0]==="[]"||r[0]==="?.[]")&&r.length===3){let i=n(r[1]),p=n(r[2]);return l=>{let m=p(l);return P(m)?void 0:i(l)?.[m]?.(...e(l))}}let o=n(r);return i=>o(i)?.(...e(i))});s("typeof",r=>(r=n(r),t=>typeof r(t)));s("void",r=>(r=n(r),t=>(r(t),void 0)));s("delete",r=>{if(r[0]==="."){let t=n(r[1]),e=r[2];return o=>delete t(o)[e]}if(r[0]==="[]"){let t=n(r[1]),e=n(r[2]);return o=>delete t(o)[e(o)]}return()=>!0});s("new",r=>{let t=n(r?.[0]==="()"?r[1]:r),e=r?.[0]==="()"?r[2]:null,o=e?e[0]===","?(i=>p=>i.map(l=>l(p)))(e.slice(1).map(n)):(i=>p=>[i(p)])(n(e)):()=>[];return i=>new(t(i))(...o(i))});var Q=Symbol("accessor");s("get",(r,t)=>(t=t?n(t):()=>{},e=>[[Q,r,{get:function(){let o=Object.create(e||{});return o.this=this,t(o)}}]]));s("set",(r,t,e)=>(e=e?n(e):()=>{},o=>[[Q,r,{set:function(i){let p=Object.create(o||{});p.this=this,p[t]=i,e(p)}}]]));var Pt=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);s("{}",(r,t)=>{if(t!==void 0)return;if(!Pt(r))return n(["{",r]);r=r?r[0]!==","?[r]:r.slice(1):[];let e=r.map(o=>n(typeof o=="string"?[":",o,o]:o));return o=>{let i={},p={};for(let l of e.flatMap(m=>m(o)))if(l[0]===Q){let[,m,A]=l;p[m]={...p[m],...A,configurable:!0,enumerable:!0}}else i[l[0]]=l[1];for(let l in p)Object.defineProperty(i,l,p[l]);return i}});s("{",r=>(r=r?n(r):()=>{},t=>r(Object.create(t))));s(":",(r,t)=>(t=n(t),Array.isArray(r)?(r=n(r),e=>[[r(e),t(e)]]):e=>[[r,t(e)]]));s("`",(...r)=>(r=r.map(n),t=>r.map(e=>e(t)).join("")));s("``",(r,...t)=>{r=n(r);let e=[],o=[];for(let p of t)Array.isArray(p)&&p[0]===void 0?e.push(p[1]):o.push(n(p));let i=Object.assign([...e],{raw:e});return p=>r(p)(i,...o.map(l=>l(p)))});var Br=new WeakMap,Tt=(r,...t)=>typeof r=="string"?n(d(r)):Br.get(r)||Br.set(r,Ut(r,t)).get(r),Mr=57344,Ut=(r,t)=>{let e=r.reduce((p,l,m)=>p+(m?String.fromCharCode(Mr+m-1):"")+l,""),o=d(e),i=p=>{if(typeof p=="string"&&p.length===1){let l=p.charCodeAt(0)-Mr,m;if(l>=0&&l<t.length)return m=t[l],_t(m)?m:[,m]}return Array.isArray(p)?p.map(i):p};return n(i(o))},_t=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),at=Tt;export{z as access,c as binary,n as compile,u as cur,at as default,N as err,y as expr,a as group,Bt as id,f as idx,D as keyword,T as literal,ir as loc,w as lookup,pr as member,W as nary,L as next,s as operator,j as operators,Mt as parens,d as parse,K as peek,H as prec,J as propName,M as seek,C as skip,I as token,k as unary,sr as word};