subscript 10.3.5 → 10.4.0

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.
Files changed (93) hide show
  1. package/README.md +9 -2
  2. package/eval/access.js +57 -0
  3. package/eval/accessor.js +19 -0
  4. package/eval/async.js +13 -0
  5. package/eval/class.js +35 -0
  6. package/eval/collection.js +41 -0
  7. package/eval/function.js +37 -0
  8. package/eval/if.js +7 -0
  9. package/eval/jessie.js +19 -0
  10. package/eval/justin.js +21 -0
  11. package/eval/loop.js +108 -0
  12. package/eval/module.js +8 -0
  13. package/eval/op/arithmetic.js +12 -0
  14. package/eval/op/arrow.js +35 -0
  15. package/eval/op/assign-logical.js +23 -0
  16. package/eval/op/assignment.js +15 -0
  17. package/eval/op/bitwise-unsigned.js +8 -0
  18. package/eval/op/bitwise.js +9 -0
  19. package/eval/op/comparison.js +7 -0
  20. package/eval/op/defer.js +4 -0
  21. package/eval/op/equality.js +5 -0
  22. package/eval/op/identity.js +5 -0
  23. package/eval/op/increment.js +13 -0
  24. package/eval/op/logical.js +6 -0
  25. package/eval/op/membership.js +4 -0
  26. package/eval/op/nullish.js +4 -0
  27. package/eval/op/optional.js +38 -0
  28. package/eval/op/pow.js +8 -0
  29. package/eval/op/range.js +13 -0
  30. package/eval/op/spread.js +4 -0
  31. package/eval/op/ternary.js +4 -0
  32. package/eval/op/type.js +5 -0
  33. package/eval/op/unary.js +24 -0
  34. package/eval/prop.js +16 -0
  35. package/eval/regex.js +7 -0
  36. package/eval/seq.js +10 -0
  37. package/eval/subscript.js +15 -0
  38. package/eval/switch.js +27 -0
  39. package/eval/template.js +14 -0
  40. package/eval/try.js +36 -0
  41. package/eval/unit.js +10 -0
  42. package/eval/var.js +69 -0
  43. package/feature/access.js +2 -58
  44. package/feature/accessor.js +2 -21
  45. package/feature/asi.js +57 -12
  46. package/feature/async.js +2 -14
  47. package/feature/class.js +2 -35
  48. package/feature/collection.js +2 -43
  49. package/feature/function.js +2 -39
  50. package/feature/if.js +2 -8
  51. package/feature/jessie.js +32 -0
  52. package/feature/justin.js +36 -0
  53. package/feature/loop.js +2 -109
  54. package/feature/module.js +1 -10
  55. package/feature/op/arithmetic.js +2 -13
  56. package/feature/op/arrow.js +2 -38
  57. package/feature/op/assign-logical.js +3 -24
  58. package/feature/op/assignment.js +2 -18
  59. package/feature/op/bitwise-unsigned.js +2 -8
  60. package/feature/op/bitwise.js +2 -14
  61. package/feature/op/comparison.js +2 -8
  62. package/feature/op/defer.js +2 -7
  63. package/feature/op/equality.js +2 -7
  64. package/feature/op/identity.js +2 -6
  65. package/feature/op/increment.js +2 -14
  66. package/feature/op/logical.js +2 -8
  67. package/feature/op/membership.js +2 -7
  68. package/feature/op/nullish.js +2 -5
  69. package/feature/op/optional.js +2 -41
  70. package/feature/op/pow.js +2 -10
  71. package/feature/op/range.js +2 -16
  72. package/feature/op/spread.js +2 -7
  73. package/feature/op/ternary.js +2 -7
  74. package/feature/op/type.js +2 -8
  75. package/feature/op/unary.js +2 -27
  76. package/feature/prop.js +2 -17
  77. package/feature/regex.js +3 -12
  78. package/feature/seq.js +2 -11
  79. package/feature/shebang.js +7 -0
  80. package/feature/subscript.js +23 -0
  81. package/feature/switch.js +2 -28
  82. package/feature/template.js +4 -16
  83. package/feature/try.js +4 -38
  84. package/feature/unit.js +4 -7
  85. package/feature/var.js +2 -70
  86. package/jessie.js +4 -25
  87. package/jessie.min.js +9 -8
  88. package/justin.js +4 -30
  89. package/justin.min.js +8 -8
  90. package/package.json +10 -2
  91. package/parse.js +27 -29
  92. package/subscript.js +7 -16
  93. package/subscript.min.js +5 -5
package/jessie.min.js CHANGED
@@ -1,8 +1,9 @@
1
- var fr,p,m,c=r=>(p=0,m=r,c.newline=!1,r=a(),m[p]?R():r||""),R=(r="Unexpected token",e=p,t=m.slice(0,e).split(`
2
- `),n=t.pop(),o=m.slice(Math.max(0,e-40),e),f="\u032D",u=(m[e]||" ")+f,l=m.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${n.length+1}
3
- ${m[e-41]!==`
4
- `,""+o}${u}${l}`)},Or=(r,e=p)=>(Array.isArray(r)&&(r.loc=e),r),N=(r,e=p,t)=>{for(;t=r(m.charCodeAt(p));)p+=t;return m.slice(e,p)},h=(r=1)=>m[p+=r],_=r=>p=r,a=(r=0,e)=>{let t,n,o,f,u;for(e&&c.asi&&(c.newline=!1);(t=c.space())&&(u=c.newline,1)&&t!==e&&(o=(n&&t===91&&fr&&c.asi?.(n,r,a)||null)??((f=T[t])&&f(n,r))??(n&&u&&c.asi?.(n,r,a))??(!n&&N(c.id)));)n=o;return e&&(t==e?(p++,e===125&&c.asi&&(c.newline=!0)):R("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),n},d=(r,e=p)=>{for(fr=!1;(r=m.charCodeAt(p))<=32;)c.asi&&r===10&&(c.newline=fr=!0),p++;return r},_r=(r=p)=>{for(;m.charCodeAt(r)<=32;)r++;return m.charCodeAt(r)},Ft=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,I=(r,e=r.length)=>m.substr(p,e)===r&&!c.id(m.charCodeAt(p+e)),v=()=>(h(),a(0,41)),T=[],j={},k=(r,e=32,t,n=r.charCodeAt(0),o=r.length,f=T[n],u=r.toUpperCase()!==r,l,A)=>(e=j[r]=!f&&j[r]||e,T[n]=(w,S,E,C=p)=>(l=E,(E?r==E:(o<2||r.charCodeAt(1)===m.charCodeAt(p+1)&&(o<3||m.substr(p,o)==r))&&(!u||!c.id(m.charCodeAt(p+o)))&&(l=E=r))&&S<e&&(p+=o,(A=t(w))?Or(A,C):(p=C,l=0,!u&&!f&&!w&&R()),A)||f?.(w,S,l))),y=(r,e,t=!1)=>k(r,e,n=>n&&(o=>o&&[r,n,o])(a(e-(t?.5:0)))),P=(r,e,t)=>k(r,e,n=>t?n&&[r,n]:!n&&(n=a(e-.5))&&[r,n]),$=(r,e)=>k(r,200,t=>!t&&[,e]),pr=(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]),ur=(r,e)=>k(r[0],e,t=>t&&[r,t,a(0,r.charCodeAt(1))||null]),g=(r,e,t,n=r.charCodeAt(0),o=r.length,f=T[n],u)=>T[n]=(l,A,w,S=p)=>!l&&(w?r==w:(o<2||m.substr(p,o)==r)&&(w=r))&&A<e&&!c.id(m.charCodeAt(p+o))&&(!c.prop||c.prop(p+o))&&(_(p+o),(u=t())?Or(u,S):_(S),u)||f?.(l,A,w);Object.defineProperty(c,"space",{configurable:!0,enumerable:!0,get:()=>d,set:r=>d=r});var lr={},s=(r,e,t=lr[r])=>lr[r]=(...n)=>e(...n)||t?.(...n),i=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):lr[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,me=69,de=101,ae=43,he=45,Z=95,Pr=110,Ae=97,ye=102,we=65,ge=70,vr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),cr=r=>{let e=vr(N(t=>t===q&&m.charCodeAt(p+1)!==q||t>=z&&t<=x||t===Z||((t===me||t===de)&&((t=m.charCodeAt(p+1))>=z&&t<=x||t===ae||t===he)?2:0)));return m.charCodeAt(p)===Pr?(h(),[,BigInt(e)]):(r=+e)!=r?R():[,r]},Ce={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<=ye||r>=we&&r<=ge||r===Z};c.number=null;T[q]=r=>!r&&m.charCodeAt(p+1)!==q&&cr();for(let r=z;r<=x;r++)T[r]=e=>e?void 0:cr();T[z]=r=>{if(r)return;let e=c.number;if(e){for(let[t,n]of Object.entries(e))if(t[0]==="0"&&m[p+1]?.toLowerCase()===t[1]){h(2);let o=vr(N(Ce[n]));return m.charCodeAt(p)===Pr?(h(),[,BigInt("0"+t[1]+o)]):[,parseInt(o,n)]}}return cr()};var Ee=92,Mr=34,Br=39,Se={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Lr=r=>(e,t,n="")=>{if(!(e||!c.string?.[String.fromCharCode(r)]))return h(),N(o=>o-r&&(o===Ee?(n+=Se[m[p+1]]||m[p+1],2):(n+=m[p],1))),m[p]===String.fromCharCode(r)?h():R("Bad string"),[,n]};T[Mr]=Lr(Mr);T[Br]=Lr(Br);c.string={'"':!0};var ke=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>y(r,ke,!0));var Fr=(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?Fr(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),Fr(e,(n,o,f)=>Ur[r](n,o,t(f)))));var Ie=30,Te=40,Ne=140;P("!",Ne);y("||",Ie);y("&&",Te);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 Re=50,Oe=60,_e=70,Dr=100,Pe=140;y("|",Re);y("&",_e);y("^",Oe);y(">>",Dr);y("<<",Dr);P("~",Pe);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,mr=120,Hr=140;y("+",Xr);y("-",Xr);y("*",mr);y("/",mr);y("%",mr);P("+",Hr);P("-",Hr);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 dr=(r,e,t,n)=>typeof r=="string"?o=>e(o,r):r[0]==="."?(t=i(r[1]),n=r[2],o=>e(t(o),n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),n=i(r[2]),o=>e(t(o),n(o))):r[0]==="()"&&r.length===2?dr(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>dr(r,e===null?(t,n)=>t[n]++:(t,n)=>++t[n]));s("--",(r,e)=>dr(r,e===null?(t,n)=>t[n]--:(t,n)=>--t[n]));var ve=5,Me=10;pr(",",Me);pr(";",ve,!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 Be=170;W("()",Be);var F=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",ar=170;ur("[]",ar);y(".",ar);ur("()",ar);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(f=>f==null||t(f));t(e)&&er("Empty argument");let n=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(f=>f(o))):(e=i(e),o=>[e(o)]):()=>[];return hr(r,(o,f,u)=>o[f](...n(u)))});var B=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&B(r[1])||r[0]==="{}"),hr=(r,e,t,n)=>r==null?er("Empty ()"):r[0]==="()"&&r.length==2?hr(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 f=t(o);return f==null?void 0:e(f,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 f=t(o);return f==null?void 0:e(f,n(o),o)}):(r=i(r),o=>e([r(o)],0,o)),D=hr;var Qr=new WeakMap,Le=(r,...e)=>typeof r=="string"?i(c(r)):Qr.get(r)||Qr.set(r,Ue(r,e)).get(r),$r=57344,Ue=(r,e)=>{let t=r.reduce((f,u,l)=>f+(l?String.fromCharCode($r+l-1):"")+u,""),n=c(t),o=f=>{if(typeof f=="string"&&f.length===1){let u=f.charCodeAt(0)-$r,l;if(u>=0&&u<e.length)return l=e[u],Fe(l)?l:[,l]}return Array.isArray(f)?f.map(o):f};return i(o(n))},Fe=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),jr=Le;var De=32,Ge=c.space;c.comment??={"//":`
6
- `,"/*":"*/"};var Ar;c.space=()=>{Ar||(Ar=Object.entries(c.comment).map(([o,f])=>[o,f,o.charCodeAt(0)]));for(var r;r=Ge();){for(var e=0,t;t=Ar[e++];)if(r===t[2]&&m.substr(p,t[0].length)===t[0]){var n=p+t[0].length;if(t[1]===`
7
- `)for(;m.charCodeAt(n)>=De;)n++;else{for(;m[n]&&m.substr(n,t[1].length)!==t[1];)n++;m[n]&&(n+=t[1].length)}_(n),r=0;break}if(r)return r}return r};var Wr=80;y("===",Wr);y("!==",Wr);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 Xe=30;y("??",Xe);s("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var He=130,Ke=20;y("**",He,!0);y("**=",Ke,!0);s("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));var Qe=r=>{throw Error(r)};s("**=",(r,e)=>(B(r)||Qe("Invalid assignment target"),e=i(e),D(r,(t,n,o)=>t[n]**=e(o))));var zr=90;y("in",zr);y("of",zr);s("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var $e=20,je=100,We=r=>{throw Error(r)};y(">>>",je);y(">>>=",$e,!0);s(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(B(r)||We("Invalid assignment target"),e=i(e),D(r,(t,n,o)=>t[n]>>>=e(o))));var yr=5,ze=10,Je=20,Ve=r=>r[0]?.[0]===","?r[0].slice(1):r,X=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[n,...o]=r,f=Ve(o);if(n==="{}"){let u=[];for(let l of f){if(Array.isArray(l)&&l[0]==="..."){let C={};for(let O in e)u.includes(O)||(C[O]=e[O]);t[l[1]]=C;break}let A,w,S;typeof l=="string"?A=w=l:l[0]==="="?(typeof l[1]=="string"?A=w=l[1]:[,A,w]=l[1],S=l[2]):[,A,w]=l,u.push(A);let E=e[A];E===void 0&&S&&(E=i(S)(t)),X(w,E,t)}}else if(n==="[]"){let u=0;for(let l of f){if(l===null){u++;continue}if(Array.isArray(l)&&l[0]==="..."){t[l[1]]=e.slice(u);break}let A=l,w;Array.isArray(l)&&l[0]==="="&&([,A,w]=l);let S=e[u++];S===void 0&&w&&(S=i(w)(t)),X(A,S,t)}}},Jr=r=>{if(r==="let"){let t=p;if(d(),I("in")){_(t);return}_(t)}let e=a(ze-1);return e?.[0]==="in"||e?.[0]==="of"?[e[0],[r,e[1]],e[2]]:e?.[0]===","?[r,...e.slice(1)]:[r,e]};g("let",yr+1,()=>Jr("let"));g("const",yr+1,()=>Jr("const"));g("var",yr,()=>(d(),["var",a(Je)]));var Vr=(...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"?f=>{f[t]=o(f)}:f=>X(t,o(f),f)}return i(e)}),e=>{for(let t of r)t(e)});s("let",Vr);s("const",Vr);s("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var wr=20,tr=r=>{throw Error(r)};y("||=",wr,!0);y("&&=",wr,!0);y("??=",wr,!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=>X(t,e(n),n)}return B(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,n,o)=>t[n]=e(o))});s("||=",(r,e)=>(B(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,n,o)=>t[n]||=e(o))));s("&&=",(r,e)=>(B(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,n,o)=>t[n]&&=e(o))));s("??=",(r,e)=>(B(r)||tr("Invalid assignment target"),e=i(e),D(r,(t,n,o)=>t[n]??=e(o))));$("true",!0);$("false",!1);$("null",null);g("undefined",200,()=>[]);$("NaN",NaN);$("Infinity",1/0);var gr=20;k("?",gr,(r,e,t)=>r&&(e=a(gr-1))&&N(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 M=[],Ye=20;y("=>",Ye,!0);s("=>",(r,e)=>{r=r?.[0]==="()"?r[1]:r;let t=r?r[0]===","?r.slice(1):[r]:[],n=-1,o=null,f=t[t.length-1];Array.isArray(f)&&f[0]==="..."&&(n=t.length-1,o=f[1],t.length--);let u=e?.[0]==="{}";return e=i(u?["{",e[1]]:e),l=>(...A)=>{let w={};t.forEach((E,C)=>w[E]=A[C]),o&&(w[o]=A.slice(n));let S=new Proxy(w,{get:(E,C)=>C in E?E[C]:l?.[C],set:(E,C,O)=>((C in E?E:l)[C]=O,!0),has:(E,C)=>C in E||(l?C in l:!1)});try{let E=e(S);return u?void 0:E}catch(E){if(E===M)return E[0];throw E}}});var Ze=140;P("...",Ze);s("...",r=>(r=i(r),e=>Object.entries(r(e))));var Yr=170;k("?.",Yr,(r,e)=>{if(!r)return;let t=d();return t===40?(h(),["?.()",r,a(0,41)||null]):t===91?(h(),["?.[]",r,a(0,93)]):(e=a(Yr),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(f=>f(o))):(e=i(e),o=>[e(o)]):()=>[];if(r[0]==="?."){let o=i(r[1]),f=r[2];return F(f)?()=>{}:u=>o(u)?.[f]?.(...t(u))}if(r[0]==="?.[]"){let o=i(r[1]),f=i(r[2]);return u=>{let l=o(u),A=f(u);return F(A)?void 0:l?.[A]?.(...t(u))}}if(r[0]==="."){let o=i(r[1]),f=r[2];return F(f)?()=>{}:u=>o(u)?.[f]?.(...t(u))}if(r[0]==="[]"&&r.length===3){let o=i(r[1]),f=i(r[2]);return u=>{let l=o(u),A=f(u);return F(A)?void 0:l?.[A]?.(...t(u))}}let n=i(r);return o=>n(o)?.(...t(o))});var J=140;P("typeof",J);P("void",J);P("delete",J);g("new",J,()=>I(".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=>f=>o.map(u=>u(f)))(t.slice(1).map(i)):(o=>f=>[o(f)])(i(t)):()=>[];return o=>new(e(o))(...n(o))});var nr=Symbol("accessor"),Cr=20,qe=40,Zr=41,qr=123,xr=125,br=r=>e=>{if(e)return;d();let t=N(c.id);if(!t||(d(),m.charCodeAt(p)!==qe))return!1;h();let n=a(0,Zr);return d(),m.charCodeAt(p)!==qr?!1:(h(),[r,t,n,a(0,xr)])};k("get",Cr-1,br("get"));k("set",Cr-1,br("set"));k("(",Cr-1,r=>{if(!r||typeof r!="string")return;let e=a(0,Zr)||null;if(d(),m.charCodeAt(p)===qr)return h(),[":",r,["=>",["()",e],a(0,xr)||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 f=Object.create(n||{});f.this=this,f[e]=o,t(f)}}]]));var xe=20,re=200;c.prop=r=>_r(r)!==58;var be=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);W("[]",re);W("{}",re);y(":",xe-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;if(!be(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={},f={};for(let u of t.flatMap(l=>l(n)))if(u[0]===nr){let[,l,A]=u;f[l]={...f[l],...A,configurable:!0,enumerable:!0}}else o[u[0]]=u[1];for(let u in f)Object.defineProperty(o,u,f[u]);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 rt=170,or=96,et=36,tt=123,nt=92,ot={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},ee=()=>{let r=[];for(let e="",t;(t=m.charCodeAt(p))!==or;)t?t===nt?(h(),e+=ot[m[p]]||m[p],h()):t===et&&m.charCodeAt(p+1)===tt?(e&&r.push([,e]),e="",h(2),r.push(a(0,125))):(e+=m[p],h(),t=m.charCodeAt(p),t===or&&e&&r.push([,e])):R("Unterminated template");return h(),r},it=T[or];T[or]=(r,e)=>r&&e<rt?c.asi&&c.newline?void 0:(h(),["``",r,...ee()]):r?it?.(r,e):(h(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(ee()));s("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));s("``",(r,...e)=>{r=i(r);let t=[],n=[];for(let f of e)Array.isArray(f)&&f[0]===void 0?t.push(f[1]):n.push(i(f));let o=Object.assign([...t],{raw:t});return f=>r(f)(o,...n.map(u=>u(f)))});c.string["'"]=!0;c.number={"0x":16,"0b":2,"0o":8};var st=92,ft=117,lt=123,pt=125,ut=183,ct=c.id,te=r=>r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102,mt=(r=p+2,e,t=0,n=0)=>{if(m.charCodeAt(p)!==st||m.charCodeAt(p+1)!==ft)return 0;if(m.charCodeAt(r)===lt){for(;te(e=m.charCodeAt(++r));)t=t*16+(e<=57?e-48:(e&31)+9);return r>p+3&&t<=1114111&&m.charCodeAt(r)===pt?r-p+1:0}for(;n<4&&te(m.charCodeAt(r+n));)n++;return n===4?6:0};c.id=r=>ct(r)||r===ut||mt();var ir=5,dt=59,L=()=>(d()===123||R("Expected {"),h(),a(ir-.5,125)||null),G=()=>d()!==123?a(ir+.5):(h(),a(ir-.5,125)||null),at=()=>{let r=p;return d()===dt&&h(),d(),I("else")?(h(4),!0):(_(r),!1)};g("if",ir+1,()=>{d();let r=["if",v(),G()];return at()&&r.push(G()),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 ht=200;g("function",ht,()=>{d();let r=!1;m[p]==="*"&&(r=!0,h(),d());let e=N(c.id);return e&&d(),r?["function*",e,v()||null,L()]:["function",e,v()||null,L()]});s("function",(r,e,t)=>{t=t?i(t):()=>{};let n=e?e[0]===","?e.slice(1):[e]:[],o=null,f=-1,u=n[n.length-1];return Array.isArray(u)&&u[0]==="..."&&(f=n.length-1,o=u[1],n.length--),l=>{let A=(...w)=>{let S={};n.forEach((C,O)=>S[C]=w[O]),o&&(S[o]=w.slice(f));let E=new Proxy(S,{get:(C,O)=>O in C?C[O]:l[O],set:(C,O,ce)=>((O in C?C:l)[O]=ce,!0),has:(C,O)=>O in C||O in l});try{return t(E)}catch(C){if(C===M)return C[0];throw C}};return r&&(l[r]=A),A}});s("function*",(r,e,t)=>{throw Error("Generator functions are not supported in evaluation")});var sr=140,Er=20;P("await",sr);g("yield",sr,()=>(d(),m[p]==="*"?(h(),d(),["yield*",a(Er)]):["yield",a(Er)]));g("async",sr,()=>{if(d(),I("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 Sr=200,At=140,yt=90,wt=Symbol("static");P("static",At);y("instanceof",yt);k("#",Sr,r=>{if(r)return;let e=N(c.id);return e?"#"+e:void 0});g("class",Sr,()=>{d();let r=N(c.id)||null;if(r==="extends")r=null,d();else{if(d(),!I("extends"))return["class",r,null,L()];h(7),d()}return["class",r,a(Sr),L()]});var gt=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,f=function(...u){if(!(this instanceof f))return gt("Class constructor must be called with new");let l=e?Reflect.construct(o,u,f):this;return f.prototype.__constructor__&&f.prototype.__constructor__.apply(l,u),l};if(Object.setPrototypeOf(f.prototype,o.prototype),Object.setPrototypeOf(f,o),t){let u=Object.create(n);u.super=o;let l=t(u),A=Array.isArray(l)&&typeof l[0]?.[0]=="string"?l:[];for(let[w,S]of A)w==="constructor"?f.prototype.__constructor__=S:f.prototype[w]=S}return r&&(n[r]=f),f}));s("static",r=>(r=i(r),e=>[[wt,r(e)]]));var Ct=140,kr=47,Et=92,St=r=>r===Et?2:r&&r!==kr,kt=r=>r===103||r===105||r===109||r===115||r===117||r===121;k("/",Ct,r=>{if(r)return;let e=m.charCodeAt(p);if(e===kr||e===42||e===43||e===63||e===61)return;let t=N(St);m.charCodeAt(p)===kr||R("Unterminated regex"),h();let n=N(kt);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 U=Symbol("break"),H=Symbol("continue"),K=5,V=125,Y=59;g("while",K+1,()=>(d(),["while",v(),G()]));g("do",K+1,()=>(r=>(d(),h(5),d(),["do",r,v()]))(G()));g("for",K+1,()=>(d(),I("await")?(h(5),d(),["for await",v(),G()]):["for",v(),G()]));g("break",K+1,()=>{c.asi&&(c.newline=!1);let r=p;d();let e=m.charCodeAt(p);if(!e||e===V||e===Y||c.newline)return["break"];let t=N(c.id);if(!t)return["break"];d();let n=m.charCodeAt(p);return!n||n===V||n===Y||c.newline?["break",t]:(_(r),["break"])});g("continue",K+1,()=>{c.asi&&(c.newline=!1);let r=p;d();let e=m.charCodeAt(p);if(!e||e===V||e===Y||c.newline)return["continue"];let t=N(c.id);if(!t)return["continue"];d();let n=m.charCodeAt(p);return!n||n===V||n===Y||c.newline?["continue",t]:(_(r),["continue"])});g("return",K+1,()=>{c.asi&&(c.newline=!1);let r=d();return!r||r===V||r===Y||c.newline?["return"]:["return",a(K)]});s("while",(r,e)=>(r=i(r),e=i(e),t=>{let n;for(;r(t);)try{n=e(t)}catch(o){if(o===U)break;if(o===H)continue;if(o===M)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===U)break;if(o===H)continue;if(o===M)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),f=>{let u;for(t?.(f);n(f);o?.(f))try{u=e(f)}catch(l){if(l===U)break;if(l===H)continue;if(l===M)return l[0];throw l}return u}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,n,o]=r;if(Array.isArray(n)&&(n[0]==="let"||n[0]==="const"||n[0]==="var")&&(n=n[1]),t==="in")return Tt(n,o,e);if(t==="of")return It(n,o,e)}});var It=(r,e,t)=>{e=i(e),t=i(t);let n=Array.isArray(r);return o=>{let f,u=n?null:o[r];for(let l of e(o)){n?X(r,l,o):o[r]=l;try{f=t(o)}catch(A){if(A===U)break;if(A===H)continue;if(A===M)return A[0];throw A}}return n||(o[r]=u),f}},Tt=(r,e,t)=>{e=i(e),t=i(t);let n=Array.isArray(r);return o=>{let f,u=n?null:o[r];for(let l in e(o)){n?X(r,l,o):o[r]=l;try{f=t(o)}catch(A){if(A===U)break;if(A===H)continue;if(A===M)return A[0];throw A}}return n||(o[r]=u),f}};s("break",()=>()=>{throw U});s("continue",()=>()=>{throw H});s("return",r=>(r=r!==void 0?i(r):null,e=>{throw M[0]=r?.(e),M}));var Ir=5;g("try",Ir+1,()=>{let r=["try",L()];return d(),I("catch")&&(h(5),d(),r.push(["catch",v(),L()])),d(),I("finally")&&(h(7),r.push(["finally",L()])),r});g("throw",Ir+1,()=>{if(c.asi&&(c.newline=!1),d(),c.newline)throw SyntaxError("Unexpected newline after throw");return["throw",a(Ir)]});s("try",(r,...e)=>{r=r?i(r):null;let t=e.find(l=>l?.[0]==="catch"),n=e.find(l=>l?.[0]==="finally"),o=t?.[1],f=t?.[2]?i(t[2]):null,u=n?.[1]?i(n[1]):null;return l=>{let A;try{A=r?.(l)}catch(w){if(w===U||w===H||w===M)throw w;if(o!=null&&f){let S=o in l,E=l[o];l[o]=w;try{A=f(l)}finally{S?l[o]=E:delete l[o]}}else if(!f)throw w}finally{u?.(l)}return A}});s("throw",r=>(r=i(r),e=>{throw r(e)}));var ie=5,Nt=20,ne=58,Rt=59,se=125,Tr=0,fe=(r,e=r.length,t=r.charCodeAt(0),n=T[t])=>T[t]=(o,f,u)=>I(r)&&!o&&Tr||n?.(o,f,u);fe("case");fe("default");var oe=r=>{let e=[];for(;(r=d())!==se&&!I("case")&&!I("default");){if(r===Rt){h();continue}e.push(a(ie-.5))||R()}return e.length>1?[";",...e]:e[0]||null},Ot=()=>{d()===123||R("Expected {"),h(),Tr++;let r=[];try{for(;d()!==se;)if(I("case")){_(p+4),d();let e=a(Nt-.5);d()===ne&&h(),r.push(["case",e,oe()])}else I("default")?(_(p+7),d()===ne&&h(),r.push(["default",oe()])):R("Expected case or default")}finally{Tr--}return h(),r};g("switch",ie+1,()=>d()===40&&["switch",v(),...Ot()]);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,f;for(let[l,A]of e)if(o||l===null||l(t)===n)for(o=!0,u=0;u<A.length;u++)try{f=A[u](t)}catch(w){if(w===U)return f;throw w}var u;return f}):t=>r(t)));var le=5;g("debugger",le+1,()=>["debugger"]);g("with",le+1,()=>(d(),["with",v(),G()]));var Nr=5,Q=10,pe=42,_t=T[pe];T[pe]=(r,e)=>r?_t?.(r,e):(h(),"*");k("from",Q+1,r=>r?r[0]!=="="&&r[0]!==","&&(d(),["from",r,a(Q+1)]):!1);k("as",Q+2,r=>r?(d(),["as",r,a(Q+2)]):!1);g("import",Nr,()=>I(".meta")?(h(5),["import.meta"]):["import",a(Q)]);g("export",Nr,()=>(d(),["export",a(Nr)]));g("default",Q+1,()=>d()!==58&&(d(),["default",a(Q)]));s("import",()=>()=>{});s("export",()=>()=>{});s("from",(r,e)=>()=>{});s("as",(r,e)=>()=>{});s("default",r=>i(r));var ue=j.asi??j[";"],Pt=32,vt=10,Mt=59,Bt=c.space,Lt=(r=p,e)=>{for(;(e=m.charCodeAt(r))<=Pt;){if(e===vt)return!0;r++}};c.space=()=>{let r;for(;(r=Bt())===Mt&&Lt(p+1);)_(p+1),c.newline=!0;return r};var Rr=0,Ut=100;c.asi=(r,e,t,n,o)=>{if(!(e>=ue||Rr>=Ut)){Rr++;try{n=t(ue-.5)}finally{Rr--}if(n)return o=n?.[0]===";"?n.slice(1):[n],r?.[0]===";"?(r.push(...o),r):[";",r,...o]}};export{ur as access,y as binary,i as compile,m as cur,jr as default,R as err,a as expr,W as group,Ft as id,p as idx,g as keyword,$ as literal,Or as loc,T as lookup,pr as nary,N as next,s as operator,lr as operators,v as parens,c as parse,_r as peek,j as prec,_ as seek,h as skip,d as space,k as token,P as unary,I as word};
1
+ var l,c,u=r=>(l=0,c=r,u.enter?.(),r=a(),c[l]?R():r||""),R=(r="Unexpected token",t=l,e=c.slice(0,t).split(`
2
+ `),o=e.pop(),n=c.slice(Math.max(0,t-40),t),p="\u032D",m=(c[t]||" ")+p,f=c.slice(t+1,t+20))=>{throw SyntaxError(`${r} at ${e.length+1}:${o.length+1}
3
+ ${c[t-41]!==`
4
+ `,""+n}${m}${f}`)},vr=(r,t=l)=>(Array.isArray(r)&&(r.loc=t),r),N=(r,t=l,e)=>{for(;e=r(c.charCodeAt(l));)l+=e;return c.slice(t,l)},h=(r=1)=>c[l+=r],O=r=>l=r,a=(r=0,t)=>{let e,o,n;for(t&&u.enter?.(r,t);(e=d())&&e!==t&&(n=lr(o,r,e,a));)o=n;return t&&(e==t?(l++,u.exit?.(r,t)):R("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),o},lr=(r,t,e,o,n)=>(n=T[e])&&n(r,t)||(r?null:N(u.id)||null),d=r=>{for(;(r=c.charCodeAt(l))<=32;)l++;return r},Z=(r=l)=>{for(;c.charCodeAt(r)<=32;)r++;return c.charCodeAt(r)},je=u.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,I=(r,t=r.length)=>c.substr(l,t)===r&&!u.id(c.charCodeAt(l+t)),v=()=>(h(),a(0,41)),T=[],$={},k=(r,t=32,e,o=r.charCodeAt(0),n=r.length,p=T[o],m=r.toUpperCase()!==r,f,A)=>(t=$[r]=!p&&$[r]||t,T[o]=(g,S,E,C=l)=>(f=E,(E?r==E:(n<2||r.charCodeAt(1)===c.charCodeAt(l+1)&&(n<3||c.substr(l,n)==r))&&(!m||!u.id(c.charCodeAt(l+n)))&&(f=E=r))&&S<t&&(l+=n,(A=e(g))?vr(A,C):(l=C,f=0,!m&&!p&&!g&&R()),A)||p?.(g,S,f))),y=(r,t,e=!1)=>k(r,t,o=>o&&(n=>n&&[r,o,n])(a(t-(e?.5:0)))),P=(r,t,e)=>k(r,t,o=>e?o&&[r,o]:!o&&(o=a(t-.5))&&[r,o]),Q=(r,t)=>k(r,200,e=>!e&&[,t]),mr=(r,t,e)=>k(r,t,(o,n)=>(n=a(t-(e?.5:0)),o?.[0]!==r&&(o=[r,o||null]),n?.[0]===r?o.push(...n.slice(1)):o.push(n||null),o)),W=(r,t)=>k(r[0],t,e=>!e&&[r,a(0,r.charCodeAt(1))||null]),cr=(r,t)=>k(r[0],t,e=>e&&[r,e,a(0,r.charCodeAt(1))||null]),w=(r,t,e,o=r.charCodeAt(0),n=r.length,p=T[o],m)=>T[o]=(f,A,g,S=l)=>!f&&(g?r==g:(n<2||c.substr(l,n)==r)&&(g=r))&&A<t&&!u.id(c.charCodeAt(l+n))&&(!u.prop||u.prop(l+n))&&(O(l+n),(m=e())?vr(m,S):O(S),m)||p?.(f,A,g);Object.defineProperty(u,"space",{configurable:!0,enumerable:!0,get:()=>d,set:r=>d=r});Object.defineProperty(u,"step",{configurable:!0,enumerable:!0,get:()=>lr,set:r=>lr=r});var ur={},s=(r,t,e=ur[r])=>ur[r]=(...o)=>t(...o)||e?.(...o),i=r=>Array.isArray(r)?r[0]==null?(t=>()=>t)(r[1]):ur[r[0]]?.(...r.slice(1))??R(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:t=>t?.[r];var x=46,z=48,b=57,at=69,ht=101,At=43,yt=45,q=95,Br=110,gt=97,wt=102,Ct=65,Et=70,Mr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),dr=r=>{let t=Mr(N(e=>e===x&&c.charCodeAt(l+1)!==x||e>=z&&e<=b||e===q||((e===at||e===ht)&&((e=c.charCodeAt(l+1))>=z&&e<=b||e===At||e===yt)?2:0)));return c.charCodeAt(l)===Br?(h(),[,BigInt(t)]):(r=+t)!=r?R():[,r]},St={2:r=>r===48||r===49||r===q,8:r=>r>=48&&r<=55||r===q,16:r=>r>=z&&r<=b||r>=gt&&r<=wt||r>=Ct&&r<=Et||r===q};u.number=null;T[x]=r=>!r&&c.charCodeAt(l+1)!==x&&dr();for(let r=z;r<=b;r++)T[r]=t=>t?void 0:dr();T[z]=r=>{if(r)return;let t=u.number;if(t){for(let[e,o]of Object.entries(t))if(e[0]==="0"&&c[l+1]?.toLowerCase()===e[1]){h(2);let n=Mr(N(St[o]));return c.charCodeAt(l)===Br?(h(),[,BigInt("0"+e[1]+n)]):[,parseInt(n,o)]}}return dr()};var kt=92,Lr=34,Ur=39,It={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Dr=r=>(t,e,o="")=>{if(!(t||!u.string?.[String.fromCharCode(r)]))return h(),N(n=>n-r&&(n===kt?(o+=It[c[l+1]]||c[l+1],2):(o+=c[l],1))),c[l]===String.fromCharCode(r)?h():R("Bad string"),[,o]};T[Lr]=Dr(Lr);T[Ur]=Dr(Ur);u.string={'"':!0};var Tt=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>y(r,Tt,!0));var Nt=30,Rt=40,_t=140;P("!",_t);y("||",Nt);y("&&",Rt);var Ot=50,Pt=60,vt=70,Fr=100,Bt=140;y("|",Ot);y("&",vt);y("^",Pt);y(">>",Fr);y("<<",Fr);P("~",Bt);var rr=90;y("<",rr);y(">",rr);y("<=",rr);y(">=",rr);var Gr=80;y("==",Gr);y("!=",Gr);var Xr=110,ar=120,Kr=140;y("+",Xr);y("-",Xr);y("*",ar);y("/",ar);y("%",ar);P("+",Kr);P("-",Kr);var tr=150;k("++",tr,r=>r?["++",r,null]:["++",a(tr-1)]);k("--",tr,r=>r?["--",r,null]:["--",a(tr-1)]);var Mt=5,Lt=10;mr(",",Lt);mr(";",Mt,!0);var Ut=170;W("()",Ut);var hr=170;cr("[]",hr);y(".",hr);cr("()",hr);var Dt=32,Ft=u.space;u.comment??={"//":`
6
+ `,"/*":"*/"};var Ar;u.space=()=>{Ar||(Ar=Object.entries(u.comment).map(([n,p])=>[n,p,n.charCodeAt(0)]));for(var r;r=Ft();){for(var t=0,e;e=Ar[t++];)if(r===e[2]&&c.substr(l,e[0].length)===e[0]){var o=l+e[0].length;if(e[1]===`
7
+ `)for(;c.charCodeAt(o)>=Dt;)o++;else{for(;c[o]&&c.substr(o,e[1].length)!==e[1];)o++;c[o]&&(o+=e[1].length)}O(o),r=0;break}if(r)return r}return r};var Hr=80;y("===",Hr);y("!==",Hr);var Gt=30;y("??",Gt);var Xt=130,Kt=20;y("**",Xt,!0);y("**=",Kt,!0);var jr=90;y("in",jr);y("of",jr);var Ht=20,jt=100;y(">>>",jt);y(">>>=",Ht,!0);var yr=20;y("||=",yr,!0);y("&&=",yr,!0);y("??=",yr,!0);Q("true",!0);Q("false",!1);Q("null",null);w("undefined",200,()=>[]);Q("NaN",NaN);Q("Infinity",1/0);var gr=20;k("?",gr,(r,t,e)=>r&&(t=a(gr-1))&&N(o=>o===58)&&(e=a(gr-1),["?",r,t,e]));var Qt=20;y("=>",Qt,!0);var $t=140;P("...",$t);var Qr=170;k("?.",Qr,(r,t)=>{if(!r)return;let e=d();return e===40?(h(),["?.()",r,a(0,41)||null]):e===91?(h(),["?.[]",r,a(0,93)]):(t=a(Qr),t?["?.",r,t]:void 0)});var J=140;P("typeof",J);P("void",J);P("delete",J);w("new",J,()=>I(".target")?(h(7),["new.target"]):["new",a(J)]);var Wt=20,$r=200;u.prop=r=>Z(r)!==58;W("[]",$r);W("{}",$r);y(":",Wt-1,!0);var zt=170,er=96,Jt=36,Vt=123,Yt=92,Zt={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Wr=()=>{let r=[];for(let t="",e;(e=c.charCodeAt(l))!==er;)e?e===Yt?(h(),t+=Zt[c[l]]||c[l],h()):e===Jt&&c.charCodeAt(l+1)===Vt?(t&&r.push([,t]),t="",h(2),r.push(a(0,125))):(t+=c[l],h(),e=c.charCodeAt(l),e===er&&t&&r.push([,t])):R("Unterminated template");return h(),r},qt=T[er];T[er]=(r,t)=>r&&t<zt?u.asi&&u.newline?void 0:(h(),["``",r,...Wr()]):r?qt?.(r,t):(h(),(e=>e.length<2&&e[0]?.[0]===void 0?e[0]||[,""]:["`",...e])(Wr()));u.string["'"]=!0;u.number={"0x":16,"0b":2,"0o":8};var xt=92,bt=117,re=123,te=125,ee=183,oe=u.id,zr=r=>r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102,ne=(r=l+2,t,e=0,o=0)=>{if(c.charCodeAt(l)!==xt||c.charCodeAt(l+1)!==bt)return 0;if(c.charCodeAt(r)===re){for(;zr(t=c.charCodeAt(++r));)e=e*16+(t<=57?t-48:(t&31)+9);return r>l+3&&e<=1114111&&c.charCodeAt(r)===te?r-l+1:0}for(;o<4&&zr(c.charCodeAt(r+o));)o++;return o===4?6:0};u.id=r=>oe(r)||r===ee||ne();var wr=5,ie=10,se=20,Jr=r=>{if(r==="let"){let e=l;if(d(),I("in")){O(e);return}O(e)}let t=a(ie-1);return t?.[0]==="in"||t?.[0]==="of"?[t[0],[r,t[1]],t[2]]:t?.[0]===","?[r,...t.slice(1)]:[r,t]};w("let",wr+1,()=>Jr("let"));w("const",wr+1,()=>Jr("const"));w("var",wr,()=>(d(),["var",a(se)]));var or=5,pe=59,M=()=>(d()===123||R("Expected {"),h(),a(or-.5,125)||null),D=()=>d()!==123?a(or+.5):(h(),a(or-.5,125)||null),fe=()=>{let r=l;return d()===pe&&h(),d(),I("else")?(h(4),!0):(O(r),!1)};w("if",or+1,()=>{d();let r=["if",v(),D()];return fe()&&r.push(D()),r});var le=200;w("function",le,()=>{d();let r=!1;c[l]==="*"&&(r=!0,h(),d());let t=N(u.id);return t&&d(),r?["function*",t,v()||null,M()]:["function",t,v()||null,M()]});var nr=140,Cr=20;P("await",nr);w("yield",nr,()=>(d(),c[l]==="*"?(h(),d(),["yield*",a(Cr)]):["yield",a(Cr)]));w("async",nr,()=>{if(d(),I("function"))return["async",a(nr)];let r=a(Cr-.5);return r&&["async",r]});var Er=200,ue=140,me=90;P("static",ue);y("instanceof",me);k("#",Er,r=>{if(r)return;let t=N(u.id);return t?"#"+t:void 0});w("class",Er,()=>{d();let r=N(u.id)||null;if(r==="extends")r=null,d();else{if(d(),!I("extends"))return["class",r,null,M()];h(7),d()}return["class",r,a(Er),M()]});var ce=140,Sr=47,de=92,ae=r=>r===de?2:r&&r!==Sr,he=r=>r===103||r===105||r===109||r===115||r===117||r===121;k("/",ce,r=>{if(r)return;let t=c.charCodeAt(l);if(t===Sr||t===42||t===43||t===63||t===61)return;let e=N(ae);c.charCodeAt(l)===Sr||R("Unterminated regex"),h();let o=N(he);try{new RegExp(e,o)}catch(n){R("Invalid regex: "+n.message)}return o?["//",e,o]:["//",e]});var H=5,V=125,Y=59;w("while",H+1,()=>(d(),["while",v(),D()]));w("do",H+1,()=>(r=>(d(),h(5),d(),["do",r,v()]))(D()));w("for",H+1,()=>(d(),I("await")?(h(5),d(),["for await",v(),D()]):["for",v(),D()]));w("break",H+1,()=>{u.asi&&(u.newline=!1);let r=l;d();let t=c.charCodeAt(l);if(!t||t===V||t===Y||u.newline)return["break"];let e=N(u.id);if(!e)return["break"];d();let o=c.charCodeAt(l);return!o||o===V||o===Y||u.newline?["break",e]:(O(r),["break"])});w("continue",H+1,()=>{u.asi&&(u.newline=!1);let r=l;d();let t=c.charCodeAt(l);if(!t||t===V||t===Y||u.newline)return["continue"];let e=N(u.id);if(!e)return["continue"];d();let o=c.charCodeAt(l);return!o||o===V||o===Y||u.newline?["continue",e]:(O(r),["continue"])});w("return",H+1,()=>{u.asi&&(u.newline=!1);let r=d();return!r||r===V||r===Y||u.newline?["return"]:["return",a(H)]});var kr=5;w("try",kr+1,()=>{let r=["try",M()];return d(),I("catch")&&(h(5),d(),r.push(["catch",Z()===40?v():null,M()])),d(),I("finally")&&(h(7),r.push(["finally",M()])),r});w("throw",kr+1,()=>{if(u.asi&&(u.newline=!1),d(),u.newline)throw SyntaxError("Unexpected newline after throw");return["throw",a(kr)]});var Zr=5,Ae=20,Vr=58,ye=59,qr=125,Ir=0,xr=(r,t=r.length,e=r.charCodeAt(0),o=T[e])=>T[e]=(n,p,m)=>I(r)&&!n&&Ir||o?.(n,p,m);xr("case");xr("default");var Yr=r=>{let t=[];for(;(r=d())!==qr&&!I("case")&&!I("default");){if(r===ye){h();continue}t.push(a(Zr-.5))||R()}return t.length>1?[";",...t]:t[0]||null},ge=()=>{d()===123||R("Expected {"),h(),Ir++;let r=[];try{for(;d()!==qr;)if(I("case")){O(l+4),d();let t=a(Ae-.5);d()===Vr&&h(),r.push(["case",t,Yr()])}else I("default")?(O(l+7),d()===Vr&&h(),r.push(["default",Yr()])):R("Expected case or default")}finally{Ir--}return h(),r};w("switch",Zr+1,()=>d()===40&&["switch",v(),...ge()]);var br=5;w("debugger",br+1,()=>["debugger"]);w("with",br+1,()=>(d(),["with",v(),D()]));var Tr=5,j=10,rt=42,we=T[rt];T[rt]=(r,t)=>r?we?.(r,t):(h(),"*");k("from",j+1,r=>r?r[0]!=="="&&r[0]!==","&&(d(),["from",r,a(j+1)]):!1);k("as",j+2,r=>r?(d(),["as",r,a(j+2)]):!1);w("import",Tr,()=>I(".meta")?(h(5),["import.meta"]):["import",a(j)]);w("export",Tr,()=>(d(),["export",a(Tr)]));w("default",j+1,()=>d()!==58&&(d(),["default",a(j)]));var Nr=20,Ce=40,tt=41,et=123,ot=125,nt=r=>t=>{if(t)return;d();let e=N(u.id);if(!e||(d(),c.charCodeAt(l)!==Ce))return!1;h();let o=a(0,tt);return d(),c.charCodeAt(l)!==et?!1:(h(),[r,e,o,a(0,ot)])};k("get",Nr-1,nt("get"));k("set",Nr-1,nt("set"));k("(",Nr-1,r=>{if(!r||typeof r!="string")return;let t=a(0,tt)||null;if(d(),c.charCodeAt(l)===et)return h(),[":",r,["=>",["()",t],a(0,ot)||null]]});u.comment["#!"]=`
9
+ `;var Ee=32,st=10,Se=59,ke=125,Ie=91,Te=40,_r=$.asi??$[";"],Ne=u._baseSpace??=u.space,Re=u._baseStep??=u.step,ir=!1,_e=(r,t)=>{for(;(t=c.charCodeAt(r))<=Ee;){if(t===st)return!0;r++}return!1};u.space=(r,t)=>{for(ir=!1;;){for(t=l,r=Ne();t<l;)if(c.charCodeAt(t++)===st){u.newline=ir=!0;break}if(r===Se&&_e(l+1)){O(l+1),u.newline=u.semi=ir=!0;continue}return r}};u.enter=()=>u.newline=u.semi=!1;u.exit=(r,t)=>{t===ke&&(u.newline=!0)};u.step=(r,t,e,o)=>{if(u.semi&&t>=_r)return!1;if(r&&(u.semi||(e===Ie||e===Te)&&ir))return it(r,t,o)??null;let n=u.newline;return Re(r,t,e,o)??(r&&n?it(r,t,o)??null:null)};var Rr=0,Oe=100,it=u.asi=(r,t,e,o,n)=>{if(t>=_r||Rr>=Oe)return;u.semi=!1;let p=l;Rr++;try{o=e(_r-.5)}finally{Rr--}if(!(!o||l===p))return n=o?.[0]===";"?o.slice(1):[o],r?.[0]===";"?(r.push(...n),r):[";",r,...n]};var ft=(r,t,e,o)=>typeof r=="string"?n=>t(n,r,n):r[0]==="."?(e=i(r[1]),o=r[2],n=>t(e(n),o,n)):r[0]==="[]"&&r.length===3?(e=i(r[1]),o=i(r[2]),n=>t(e(n),o(n),n)):r[0]==="()"&&r.length===2?ft(r[1],t):(()=>{throw Error("Invalid assignment target")})(),pt={"=":(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 pt)s(r,(t,e)=>(e=i(e),ft(t,(o,n,p)=>pt[r](o,n,e(p)))));s("!",r=>(r=i(r),t=>!r(t)));s("||",(r,t)=>(r=i(r),t=i(t),e=>r(e)||t(e)));s("&&",(r,t)=>(r=i(r),t=i(t),e=>r(e)&&t(e)));s("~",r=>(r=i(r),t=>~r(t)));s("|",(r,t)=>(r=i(r),t=i(t),e=>r(e)|t(e)));s("&",(r,t)=>(r=i(r),t=i(t),e=>r(e)&t(e)));s("^",(r,t)=>(r=i(r),t=i(t),e=>r(e)^t(e)));s(">>",(r,t)=>(r=i(r),t=i(t),e=>r(e)>>t(e)));s("<<",(r,t)=>(r=i(r),t=i(t),e=>r(e)<<t(e)));s(">",(r,t)=>(r=i(r),t=i(t),e=>r(e)>t(e)));s("<",(r,t)=>(r=i(r),t=i(t),e=>r(e)<t(e)));s(">=",(r,t)=>(r=i(r),t=i(t),e=>r(e)>=t(e)));s("<=",(r,t)=>(r=i(r),t=i(t),e=>r(e)<=t(e)));s("==",(r,t)=>(r=i(r),t=i(t),e=>r(e)==t(e)));s("!=",(r,t)=>(r=i(r),t=i(t),e=>r(e)!=t(e)));s("+",(r,t)=>t!==void 0?(r=i(r),t=i(t),e=>r(e)+t(e)):(r=i(r),e=>+r(e)));s("-",(r,t)=>t!==void 0?(r=i(r),t=i(t),e=>r(e)-t(e)):(r=i(r),e=>-r(e)));s("*",(r,t)=>(r=i(r),t=i(t),e=>r(e)*t(e)));s("/",(r,t)=>(r=i(r),t=i(t),e=>r(e)/t(e)));s("%",(r,t)=>(r=i(r),t=i(t),e=>r(e)%t(e)));var Or=(r,t,e,o)=>typeof r=="string"?n=>t(n,r):r[0]==="."?(e=i(r[1]),o=r[2],n=>t(e(n),o)):r[0]==="[]"&&r.length===3?(e=i(r[1]),o=i(r[2]),n=>t(e(n),o(n))):r[0]==="()"&&r.length===2?Or(r[1],t):(()=>{throw Error("Invalid increment target")})();s("++",(r,t)=>Or(r,t===null?(e,o)=>e[o]++:(e,o)=>++e[o]));s("--",(r,t)=>Or(r,t===null?(e,o)=>e[o]--:(e,o)=>--e[o]));var lt=(...r)=>(r=r.map(i),t=>{let e;for(let o of r)e=o(t);return e});s(",",lt);s(";",lt);var F=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",sr=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=i(e[1]),o=>e(o)):(e=i(e),o=>[e(o)])),e=>r.flatMap(o=>o(e))):(t==null&&sr("Missing index"),r=i(r),t=i(t),e=>{let o=t(e);return F(o)?void 0:r(e)[o]}));s(".",(r,t)=>(r=i(r),t=t[0]?t:t[1],F(t)?()=>{}:e=>r(e)[t]));s("()",(r,t)=>{if(t===void 0)return r==null?sr("Empty ()"):i(r);let e=n=>n?.[0]===","&&n.slice(1).some(p=>p==null||e(p));e(t)&&sr("Empty argument");let o=t?t[0]===","?(t=t.slice(1).map(i),n=>t.map(p=>p(n))):(t=i(t),n=>[t(n)]):()=>[];return Pr(r,(n,p,m)=>n[p](...o(m)))});var L=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&L(r[1])||r[0]==="{}"),Pr=(r,t,e,o)=>r==null?sr("Empty ()"):r[0]==="()"&&r.length==2?Pr(r[1],t):typeof r=="string"?n=>t(n,r,n):r[0]==="."?(e=i(r[1]),o=r[2],n=>t(e(n),o,n)):r[0]==="?."?(e=i(r[1]),o=r[2],n=>{let p=e(n);return p==null?void 0:t(p,o,n)}):r[0]==="[]"&&r.length===3?(e=i(r[1]),o=i(r[2]),n=>t(e(n),o(n),n)):r[0]==="?.[]"?(e=i(r[1]),o=i(r[2]),n=>{let p=e(n);return p==null?void 0:t(p,o(n),n)}):(r=i(r),n=>t([r(n)],0,n)),G=Pr;s("===",(r,t)=>(r=i(r),t=i(t),e=>r(e)===t(e)));s("!==",(r,t)=>(r=i(r),t=i(t),e=>r(e)!==t(e)));s("??",(r,t)=>(r=i(r),t=i(t),e=>r(e)??t(e)));var Pe=r=>{throw Error(r)};s("**",(r,t)=>(r=i(r),t=i(t),e=>r(e)**t(e)));s("**=",(r,t)=>(L(r)||Pe("Invalid assignment target"),t=i(t),G(r,(e,o,n)=>e[o]**=t(n))));s("in",(r,t)=>(r=i(r),t=i(t),e=>r(e)in t(e)));var ve=r=>{throw Error(r)};s(">>>",(r,t)=>(r=i(r),t=i(t),e=>r(e)>>>t(e)));s(">>>=",(r,t)=>(L(r)||ve("Invalid assignment target"),t=i(t),G(r,(e,o,n)=>e[o]>>>=t(n))));var Be=r=>r[0]?.[0]===","?r[0].slice(1):r,X=(r,t,e)=>{if(typeof r=="string"){e[r]=t;return}let[o,...n]=r,p=Be(n);if(o==="{}"){let m=[];for(let f of p){if(Array.isArray(f)&&f[0]==="..."){let C={};for(let _ in t)m.includes(_)||(C[_]=t[_]);e[f[1]]=C;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,m.push(A);let E=t[A];E===void 0&&S&&(E=i(S)(e)),X(g,E,e)}}else if(o==="[]"){let m=0;for(let f of p){if(f===null){m++;continue}if(Array.isArray(f)&&f[0]==="..."){e[f[1]]=t.slice(m);break}let A=f,g;Array.isArray(f)&&f[0]==="="&&([,A,g]=f);let S=t[m++];S===void 0&&g&&(S=i(g)(e)),X(A,S,e)}}},ut=(...r)=>(r=r.map(t=>{if(typeof t=="string")return e=>{e[t]=void 0};if(t[0]==="="){let[,e,o]=t,n=i(o);return typeof e=="string"?p=>{p[e]=n(p)}:p=>X(e,n(p),p)}return i(t)}),t=>{for(let e of r)e(t)});s("let",ut);s("const",ut);s("var",r=>typeof r=="string"?t=>{t[r]=void 0}:()=>{});var pr=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=i(t),typeof e=="string"?o=>{o[e]=t(o)}:o=>X(e,t(o),o)}return L(r)||pr("Invalid assignment target"),t=i(t),G(r,(e,o,n)=>e[o]=t(n))});s("||=",(r,t)=>(L(r)||pr("Invalid assignment target"),t=i(t),G(r,(e,o,n)=>e[o]||=t(n))));s("&&=",(r,t)=>(L(r)||pr("Invalid assignment target"),t=i(t),G(r,(e,o,n)=>e[o]&&=t(n))));s("??=",(r,t)=>(L(r)||pr("Invalid assignment target"),t=i(t),G(r,(e,o,n)=>e[o]??=t(n))));s("?",(r,t,e)=>(r=i(r),t=i(t),e=i(e),o=>r(o)?t(o):e(o)));var B=[];s("=>",(r,t)=>{r=r?.[0]==="()"?r[1]:r;let e=r?r[0]===","?r.slice(1):[r]:[],o=-1,n=null,p=e[e.length-1];Array.isArray(p)&&p[0]==="..."&&(o=e.length-1,n=p[1],e.length--);let m=t?.[0]==="{}";return t=i(m?["{",t[1]]:t),f=>(...A)=>{let g={};e.forEach((E,C)=>g[E]=A[C]),n&&(g[n]=A.slice(o));let S=new Proxy(g,{get:(E,C)=>C in E?E[C]:f?.[C],set:(E,C,_)=>((C in E?E:f)[C]=_,!0),has:(E,C)=>C in E||(f?C in f:!1)});try{let E=t(S);return m?void 0:E}catch(E){if(E===B)return E[0];throw E}}});s("...",r=>(r=i(r),t=>Object.entries(r(t))));s("?.",(r,t)=>(r=i(r),F(t)?()=>{}:e=>r(e)?.[t]));s("?.[]",(r,t)=>(r=i(r),t=i(t),e=>{let o=t(e);return F(o)?void 0:r(e)?.[o]}));s("?.()",(r,t)=>{let e=t?t[0]===","?(t=t.slice(1).map(i),n=>t.map(p=>p(n))):(t=i(t),n=>[t(n)]):()=>[];if(r[0]==="?."){let n=i(r[1]),p=r[2];return F(p)?()=>{}:m=>n(m)?.[p]?.(...e(m))}if(r[0]==="?.[]"){let n=i(r[1]),p=i(r[2]);return m=>{let f=n(m),A=p(m);return F(A)?void 0:f?.[A]?.(...e(m))}}if(r[0]==="."){let n=i(r[1]),p=r[2];return F(p)?()=>{}:m=>n(m)?.[p]?.(...e(m))}if(r[0]==="[]"&&r.length===3){let n=i(r[1]),p=i(r[2]);return m=>{let f=n(m),A=p(m);return F(A)?void 0:f?.[A]?.(...e(m))}}let o=i(r);return n=>o(n)?.(...e(n))});s("typeof",r=>(r=i(r),t=>typeof r(t)));s("void",r=>(r=i(r),t=>(r(t),void 0)));s("delete",r=>{if(r[0]==="."){let t=i(r[1]),e=r[2];return o=>delete t(o)[e]}if(r[0]==="[]"){let t=i(r[1]),e=i(r[2]);return o=>delete t(o)[e(o)]}return()=>!0});s("new",r=>{let t=i(r?.[0]==="()"?r[1]:r),e=r?.[0]==="()"?r[2]:null,o=e?e[0]===","?(n=>p=>n.map(m=>m(p)))(e.slice(1).map(i)):(n=>p=>[n(p)])(i(e)):()=>[];return n=>new(t(n))(...o(n))});var fr=Symbol("accessor");s("get",(r,t)=>(t=t?i(t):()=>{},e=>[[fr,r,{get:function(){let o=Object.create(e||{});return o.this=this,t(o)}}]]));s("set",(r,t,e)=>(e=e?i(e):()=>{},o=>[[fr,r,{set:function(n){let p=Object.create(o||{});p.this=this,p[t]=n,e(p)}}]]));var Me=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);s("{}",(r,t)=>{if(t!==void 0)return;if(!Me(r))return i(["{",r]);r=r?r[0]!==","?[r]:r.slice(1):[];let e=r.map(o=>i(typeof o=="string"?[":",o,o]:o));return o=>{let n={},p={};for(let m of e.flatMap(f=>f(o)))if(m[0]===fr){let[,f,A]=m;p[f]={...p[f],...A,configurable:!0,enumerable:!0}}else n[m[0]]=m[1];for(let m in p)Object.defineProperty(n,m,p[m]);return n}});s("{",r=>(r=r?i(r):()=>{},t=>r(Object.create(t))));s(":",(r,t)=>(t=i(t),Array.isArray(r)?(r=i(r),e=>[[r(e),t(e)]]):e=>[[r,t(e)]]));s("`",(...r)=>(r=r.map(i),t=>r.map(e=>e(t)).join("")));s("``",(r,...t)=>{r=i(r);let e=[],o=[];for(let p of t)Array.isArray(p)&&p[0]===void 0?e.push(p[1]):o.push(i(p));let n=Object.assign([...e],{raw:e});return p=>r(p)(n,...o.map(m=>m(p)))});s("function",(r,t,e)=>{e=e?i(e):()=>{};let o=t?t[0]===","?t.slice(1):[t]:[],n=null,p=-1,m=o[o.length-1];return Array.isArray(m)&&m[0]==="..."&&(p=o.length-1,n=m[1],o.length--),f=>{let A=(...g)=>{let S={};o.forEach((C,_)=>S[C]=g[_]),n&&(S[n]=g.slice(p));let E=new Proxy(S,{get:(C,_)=>_ in C?C[_]:f[_],set:(C,_,dt)=>((_ in C?C:f)[_]=dt,!0),has:(C,_)=>_ in C||_ in f});try{return e(E)}catch(C){if(C===B)return C[0];throw C}};return r&&(f[r]=A),A}});s("function*",(r,t,e)=>{throw Error("Generator functions are not supported in evaluation")});s("async",r=>{let t=i(r);return e=>{let o=t(e);return async function(...n){return o(...n)}}});s("await",r=>(r=i(r),async t=>await r(t)));s("yield",r=>(r=r?i(r):null,t=>{throw{__yield__:r?r(t):void 0}}));s("yield*",r=>(r=i(r),t=>{throw{__yield_all__:r(t)}}));var Le=Symbol("static"),Ue=r=>{throw Error(r)};s("instanceof",(r,t)=>(r=i(r),t=i(t),e=>r(e)instanceof t(e)));s("class",(r,t,e)=>(t=t?i(t):null,e=e?i(e):null,o=>{let n=t?t(o):Object,p=function(...m){if(!(this instanceof p))return Ue("Class constructor must be called with new");let f=t?Reflect.construct(n,m,p):this;return p.prototype.__constructor__&&p.prototype.__constructor__.apply(f,m),f};if(Object.setPrototypeOf(p.prototype,n.prototype),Object.setPrototypeOf(p,n),e){let m=Object.create(o);m.super=n;let f=e(m),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&&(o[r]=p),p}));s("static",r=>(r=i(r),t=>[[Le,r(t)]]));s("//",(r,t)=>{let e=new RegExp(r,t||"");return()=>e});s("if",(r,t,e)=>(r=i(r),t=i(t),e=e!==void 0?i(e):null,o=>r(o)?t(o):e?.(o)));var U=Symbol("break"),K=Symbol("continue");s("while",(r,t)=>(r=i(r),t=i(t),e=>{let o;for(;r(e);)try{o=t(e)}catch(n){if(n===U)break;if(n===K)continue;if(n===B)return n[0];throw n}return o}));s("do",(r,t)=>(r=i(r),t=i(t),e=>{let o;do try{o=r(e)}catch(n){if(n===U)break;if(n===K)continue;if(n===B)return n[0];throw n}while(t(e));return o}));s("for",(r,t)=>{if(Array.isArray(r)&&r[0]===";"){let[,e,o,n]=r;return e=e?i(e):null,o=o?i(o):()=>!0,n=n?i(n):null,t=i(t),p=>{let m;for(e?.(p);o(p);n?.(p))try{m=t(p)}catch(f){if(f===U)break;if(f===K)continue;if(f===B)return f[0];throw f}return m}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[e,o,n]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),e==="in")return Fe(o,n,t);if(e==="of")return De(o,n,t)}});var De=(r,t,e)=>{t=i(t),e=i(e);let o=Array.isArray(r);return n=>{let p,m=o?null:n[r];for(let f of t(n)){o?X(r,f,n):n[r]=f;try{p=e(n)}catch(A){if(A===U)break;if(A===K)continue;if(A===B)return A[0];throw A}}return o||(n[r]=m),p}},Fe=(r,t,e)=>{t=i(t),e=i(e);let o=Array.isArray(r);return n=>{let p,m=o?null:n[r];for(let f in t(n)){o?X(r,f,n):n[r]=f;try{p=e(n)}catch(A){if(A===U)break;if(A===K)continue;if(A===B)return A[0];throw A}}return o||(n[r]=m),p}};s("break",()=>()=>{throw U});s("continue",()=>()=>{throw K});s("return",r=>(r=r!==void 0?i(r):null,t=>{throw B[0]=r?.(t),B}));s("try",(r,...t)=>{r=r?i(r):null;let e=t.find(f=>f?.[0]==="catch"),o=t.find(f=>f?.[0]==="finally"),n=e?.[1],p=e?.[2]?i(e[2]):null,m=o?.[1]?i(o[1]):null;return f=>{let A;try{A=r?.(f)}catch(g){if(g===U||g===K||g===B)throw g;if(n!=null&&p){let S=n in f,E=f[n];f[n]=g;try{A=p(f)}finally{S?f[n]=E:delete f[n]}}else if(!p)throw g}finally{m?.(f)}return A}});s("throw",r=>(r=i(r),t=>{throw r(t)}));s("switch",(r,...t)=>(r=i(r),t.length?(t=t.map(e=>[e[0]==="case"?i(e[1]):null,(e[0]==="case"?e[2]:e[1])?.[0]===";"?(e[0]==="case"?e[2]:e[1]).slice(1).map(i):(e[0]==="case"?e[2]:e[1])?[i(e[0]==="case"?e[2]:e[1])]:[]]),e=>{let o=r(e),n=!1,p;for(let[f,A]of t)if(n||f===null||f(e)===o)for(n=!0,m=0;m<A.length;m++)try{p=A[m](e)}catch(g){if(g===U)return p;throw g}var m;return p}):e=>r(e)));s("import",()=>()=>{});s("export",()=>()=>{});s("from",(r,t)=>()=>{});s("as",(r,t)=>()=>{});s("default",r=>i(r));var mt=new WeakMap,Ge=(r,...t)=>typeof r=="string"?i(u(r)):mt.get(r)||mt.set(r,Xe(r,t)).get(r),ct=57344,Xe=(r,t)=>{let e=r.reduce((p,m,f)=>p+(f?String.fromCharCode(ct+f-1):"")+m,""),o=u(e),n=p=>{if(typeof p=="string"&&p.length===1){let m=p.charCodeAt(0)-ct,f;if(m>=0&&m<t.length)return f=t[m],Ke(f)?f:[,f]}return Array.isArray(p)?p.map(n):p};return i(n(o))},Ke=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),He=Ge;export{cr as access,y as binary,i as compile,c as cur,He as default,R as err,a as expr,W as group,je as id,l as idx,w as keyword,Q as literal,vr as loc,T as lookup,mr as nary,N as next,s as operator,ur as operators,v as parens,u as parse,Z as peek,$ as prec,O as seek,h as skip,d as space,lr as step,k as token,P as unary,I as word};
package/justin.js CHANGED
@@ -3,37 +3,11 @@
3
3
  *
4
4
  * Builds on subscript with JS-specific features:
5
5
  * optional chaining, arrow functions, spread, templates.
6
+ *
7
+ * For parse-only: import { parse } from 'subscript/feature/justin.js'
6
8
  */
7
- import './subscript.js';
8
- import { parse } from './parse.js';
9
-
10
- // Add single quotes
11
- parse.string["'"] = true;
12
-
13
- // Add hex, binary, octal prefixes
14
- parse.number = { '0x': 16, '0b': 2, '0o': 8 };
15
-
16
- import './feature/comment.js';
17
-
18
- // Extended operators
19
- // Note: assignment (=) is in subscript, must come BEFORE identity (===)
20
- import './feature/op/identity.js'; // === !==
21
- import './feature/op/nullish.js'; // ??
22
- import './feature/op/pow.js'; // ** **=
23
- import './feature/op/membership.js'; // in (instanceof is in jessie/class.js)
24
- import './feature/op/bitwise-unsigned.js'; // >>> >>>=
25
- import './feature/op/assign-logical.js'; // ||= &&= ??= + destructuring
26
-
27
- // JS-specific operators (ternary, arrow, spread, optional chaining, typeof/void/delete/new)
28
- import './feature/literal.js';
29
- import './feature/op/ternary.js';
30
- import './feature/op/arrow.js';
31
- import './feature/op/spread.js';
32
- import './feature/op/optional.js';
33
- import './feature/op/unary.js';
34
-
35
- import './feature/collection.js';
36
- import './feature/template.js';
9
+ import './feature/justin.js';
10
+ import './eval/justin.js';
37
11
 
38
12
  export * from './parse.js';
39
13
  export { default } from './subscript.js';
package/justin.min.js CHANGED
@@ -1,8 +1,8 @@
1
- var V,f,m,d=r=>(f=0,m=r,d.newline=!1,r=A(),m[f]?k():r||""),k=(r="Unexpected token",e=f,t=m.slice(0,e).split(`
2
- `),n=t.pop(),i=m.slice(Math.max(0,e-40),e),p="\u032D",l=(m[e]||" ")+p,u=m.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${n.length+1}
3
- ${m[e-41]!==`
4
- `,""+i}${l}${u}`)},lr=(r,e=f)=>(Array.isArray(r)&&(r.loc=e),r),v=(r,e=f,t)=>{for(;t=r(m.charCodeAt(f));)f+=t;return m.slice(e,f)},h=(r=1)=>m[f+=r],L=r=>f=r,A=(r=0,e)=>{let t,n,i,p,l;for(e&&d.asi&&(d.newline=!1);(t=d.space())&&(l=d.newline,1)&&t!==e&&(i=(n&&t===91&&V&&d.asi?.(n,r,A)||null)??((p=I[t])&&p(n,r))??(n&&l&&d.asi?.(n,r,A))??(!n&&v(d.id)));)n=i;return e&&(t==e?(f++,e===125&&d.asi&&(d.newline=!0)):k("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),n},N=(r,e=f)=>{for(V=!1;(r=m.charCodeAt(f))<=32;)d.asi&&r===10&&(d.newline=V=!0),f++;return r},ur=(r=f)=>{for(;m.charCodeAt(r)<=32;)r++;return m.charCodeAt(r)},_e=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,G=(r,e=r.length)=>m.substr(f,e)===r&&!d.id(m.charCodeAt(f+e)),Ue=()=>(h(),A(0,41)),I=[],fr={},E=(r,e=32,t,n=r.charCodeAt(0),i=r.length,p=I[n],l=r.toUpperCase()!==r,u,g)=>(e=fr[r]=!p&&fr[r]||e,I[n]=(C,w,y,S=f)=>(u=y,(y?r==y:(i<2||r.charCodeAt(1)===m.charCodeAt(f+1)&&(i<3||m.substr(f,i)==r))&&(!l||!d.id(m.charCodeAt(f+i)))&&(u=y=r))&&w<e&&(f+=i,(g=t(C))?lr(g,S):(f=S,u=0,!l&&!p&&!C&&k()),g)||p?.(C,w,u))),c=(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]),_=(r,e)=>E(r,200,t=>!t&&[,e]),Z=(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)),B=(r,e)=>E(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),q=(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],l)=>I[n]=(u,g,C,w=f)=>!u&&(C?r==C:(i<2||m.substr(f,i)==r)&&(C=r))&&g<e&&!d.id(m.charCodeAt(f+i))&&(!d.prop||d.prop(f+i))&&(L(f+i),(l=t())?lr(l,w):L(w),l)||p?.(u,g,C);Object.defineProperty(d,"space",{configurable:!0,enumerable:!0,get:()=>N,set:r=>N=r});var Y={},s=(r,e,t=Y[r])=>Y[r]=(...n)=>e(...n)||t?.(...n),o=r=>Array.isArray(r)?r[0]==null?(e=>()=>e)(r[1]):Y[r[0]]?.(...r.slice(1))??k(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var $=46,M=48,Q=57,Dr=69,Fr=101,Gr=43,Xr=45,X=95,mr=110,$r=97,Qr=102,jr=65,Hr=70,cr=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),x=r=>{let e=cr(v(t=>t===$&&m.charCodeAt(f+1)!==$||t>=M&&t<=Q||t===X||((t===Dr||t===Fr)&&((t=m.charCodeAt(f+1))>=M&&t<=Q||t===Gr||t===Xr)?2:0)));return m.charCodeAt(f)===mr?(h(),[,BigInt(e)]):(r=+e)!=r?k():[,r]},Kr={2:r=>r===48||r===49||r===X,8:r=>r>=48&&r<=55||r===X,16:r=>r>=M&&r<=Q||r>=$r&&r<=Qr||r>=jr&&r<=Hr||r===X};d.number=null;I[$]=r=>!r&&m.charCodeAt(f+1)!==$&&x();for(let r=M;r<=Q;r++)I[r]=e=>e?void 0:x();I[M]=r=>{if(r)return;let e=d.number;if(e){for(let[t,n]of Object.entries(e))if(t[0]==="0"&&m[f+1]?.toLowerCase()===t[1]){h(2);let i=cr(v(Kr[n]));return m.charCodeAt(f)===mr?(h(),[,BigInt("0"+t[1]+i)]):[,parseInt(i,n)]}}return x()};var Wr=92,dr=34,Ar=39,zr={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},gr=r=>(e,t,n="")=>{if(!(e||!d.string?.[String.fromCharCode(r)]))return h(),v(i=>i-r&&(i===Wr?(n+=zr[m[f+1]]||m[f+1],2):(n+=m[f],1))),m[f]===String.fromCharCode(r)?h():k("Bad string"),[,n]};I[dr]=gr(dr);I[Ar]=gr(Ar);d.string={'"':!0};var Jr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>c(r,Jr,!0));var yr=(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?yr(r[1],e):(()=>{throw Error("Invalid assignment target")})(),hr={"=":(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 hr)s(r,(e,t)=>(t=o(t),yr(e,(n,i,p)=>hr[r](n,i,t(p)))));var Vr=30,Yr=40,Zr=140;a("!",Zr);c("||",Vr);c("&&",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 qr=50,xr=60,br=70,Cr=100,re=140;c("|",qr);c("&",br);c("^",xr);c(">>",Cr);c("<<",Cr);a("~",re);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 j=90;c("<",j);c(">",j);c("<=",j);c(">=",j);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;c("==",Sr);c("!=",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,b=120,wr=140;c("+",Er);c("-",Er);c("*",b);c("/",b);c("%",b);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 H=150;E("++",H,r=>r?["++",r,null]:["++",A(H-1)]);E("--",H,r=>r?["--",r,null]:["--",A(H-1)]);var rr=(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?rr(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>rr(r,e===null?(t,n)=>t[n]++:(t,n)=>++t[n]));s("--",(r,e)=>rr(r,e===null?(t,n)=>t[n]--:(t,n)=>--t[n]));var ee=5,te=10;Z(",",te);Z(";",ee,!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 ne=170;B("()",ne);var P=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",er=170;q("[]",er);c(".",er);q("()",er);var K=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&&K("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?K("Empty ()"):o(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&K("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 tr(r,(i,p,l)=>i[p](...n(l)))});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]==="{}"),tr=(r,e,t,n)=>r==null?K("Empty ()"):r[0]==="()"&&r.length==2?tr(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=tr;var ar=new WeakMap,oe=(r,...e)=>typeof r=="string"?o(d(r)):ar.get(r)||ar.set(r,ie(r,e)).get(r),Nr=57344,ie=(r,e)=>{let t=r.reduce((p,l,u)=>p+(u?String.fromCharCode(Nr+u-1):"")+l,""),n=d(t),i=p=>{if(typeof p=="string"&&p.length===1){let l=p.charCodeAt(0)-Nr,u;if(l>=0&&l<e.length)return u=e[l],se(u)?u:[,u]}return Array.isArray(p)?p.map(i):p};return o(i(n))},se=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),pe=oe;var fe=32,le=d.space;d.comment??={"//":`
6
- `,"/*":"*/"};var nr;d.space=()=>{nr||(nr=Object.entries(d.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=le();){for(var e=0,t;t=nr[e++];)if(r===t[2]&&m.substr(f,t[0].length)===t[0]){var n=f+t[0].length;if(t[1]===`
7
- `)for(;m.charCodeAt(n)>=fe;)n++;else{for(;m[n]&&m.substr(n,t[1].length)!==t[1];)n++;m[n]&&(n+=t[1].length)}L(n),r=0;break}if(r)return r}return r};var kr=80;c("===",kr);c("!==",kr);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;c("??",ue);s("??",(r,e)=>(r=o(r),e=o(e),t=>r(t)??e(t)));var me=130,ce=20;c("**",me,!0);c("**=",ce,!0);s("**",(r,e)=>(r=o(r),e=o(e),t=>r(t)**e(t)));var de=r=>{throw Error(r)};s("**=",(r,e)=>(O(r)||de("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]**=e(i))));var vr=90;c("in",vr);c("of",vr);s("in",(r,e)=>(r=o(r),e=o(e),t=>r(t)in e(t)));var Ae=20,ge=100,he=r=>{throw Error(r)};c(">>>",ge);c(">>>=",Ae,!0);s(">>>",(r,e)=>(r=o(r),e=o(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(O(r)||he("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]>>>=e(i))));var or=5,ye=10,Ce=20,Se=r=>r[0]?.[0]===","?r[0].slice(1):r,D=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[n,...i]=r,p=Se(i);if(n==="{}"){let l=[];for(let u of p){if(Array.isArray(u)&&u[0]==="..."){let S={};for(let U in e)l.includes(U)||(S[U]=e[U]);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,l.push(g);let y=e[g];y===void 0&&w&&(y=o(w)(t)),D(C,y,t)}}else if(n==="[]"){let l=0;for(let u of p){if(u===null){l++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(l);break}let g=u,C;Array.isArray(u)&&u[0]==="="&&([,g,C]=u);let w=e[l++];w===void 0&&C&&(w=o(C)(t)),D(g,w,t)}}},Or=r=>{if(r==="let"){let t=f;if(N(),G("in")){L(t);return}L(t)}let e=A(ye-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",or+1,()=>Or("let"));T("const",or+1,()=>Or("const"));T("var",or,()=>(N(),["var",A(Ce)]));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=>D(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 ir=20,W=r=>{throw Error(r)};c("||=",ir,!0);c("&&=",ir,!0);c("??=",ir,!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=>D(t,e(n),n)}return O(r)||W("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]=e(i))});s("||=",(r,e)=>(O(r)||W("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]||=e(i))));s("&&=",(r,e)=>(O(r)||W("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]&&=e(i))));s("??=",(r,e)=>(O(r)||W("Invalid assignment target"),e=o(e),R(r,(t,n,i)=>t[n]??=e(i))));_("true",!0);_("false",!1);_("null",null);T("undefined",200,()=>[]);_("NaN",NaN);_("Infinity",1/0);var sr=20;E("?",sr,(r,e,t)=>r&&(e=A(sr-1))&&v(n=>n===58)&&(t=A(sr-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 Ee=[],we=20;c("=>",we,!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 l=e?.[0]==="{}";return e=o(l?["{",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,U)=>((S in y?y:u)[S]=U,!0),has:(y,S)=>S in y||(u?S in u:!1)});try{let y=e(w);return l?void 0:y}catch(y){if(y===Ee)return y[0];throw y}}});var Ie=140;a("...",Ie);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)?()=>{}:l=>i(l)?.[p]?.(...t(l))}if(r[0]==="?.[]"){let i=o(r[1]),p=o(r[2]);return l=>{let u=i(l),g=p(l);return P(g)?void 0:u?.[g]?.(...t(l))}}if(r[0]==="."){let i=o(r[1]),p=r[2];return P(p)?()=>{}:l=>i(l)?.[p]?.(...t(l))}if(r[0]==="[]"&&r.length===3){let i=o(r[1]),p=o(r[2]);return l=>{let u=i(l),g=p(l);return P(g)?void 0:u?.[g]?.(...t(l))}}let n=o(r);return i=>n(i)?.(...t(i))});var F=140;a("typeof",F);a("void",F);a("delete",F);T("new",F,()=>G(".target")?(h(7),["new.target"]):["new",A(F)]);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(l=>l(p)))(t.slice(1).map(o)):(i=>p=>[i(p)])(o(t)):()=>[];return i=>new(e(i))(...n(i))});var z=Symbol("accessor"),pr=20,ae=40,Tr=41,Lr=123,_r=125,Ur=r=>e=>{if(e)return;N();let t=v(d.id);if(!t||(N(),m.charCodeAt(f)!==ae))return!1;h();let n=A(0,Tr);return N(),m.charCodeAt(f)!==Lr?!1:(h(),[r,t,n,A(0,_r)])};E("get",pr-1,Ur("get"));E("set",pr-1,Ur("set"));E("(",pr-1,r=>{if(!r||typeof r!="string")return;let e=A(0,Tr)||null;if(N(),m.charCodeAt(f)===Lr)return h(),[":",r,["=>",["()",e],A(0,_r)||null]]});s("get",(r,e)=>(e=e?o(e):()=>{},t=>[[z,r,{get:function(){let n=Object.create(t||{});return n.this=this,e(n)}}]]));s("set",(r,e,t)=>(t=t?o(t):()=>{},n=>[[z,r,{set:function(i){let p=Object.create(n||{});p.this=this,p[e]=i,t(p)}}]]));var Ne=20,Br=200;d.prop=r=>ur(r)!==58;var ke=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);B("[]",Br);B("{}",Br);c(":",Ne-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;if(!ke(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 l of t.flatMap(u=>u(n)))if(l[0]===z){let[,u,g]=l;p[u]={...p[u],...g,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?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,J=96,Oe=36,Pe=123,Re=92,Te={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Mr=()=>{let r=[];for(let e="",t;(t=m.charCodeAt(f))!==J;)t?t===Re?(h(),e+=Te[m[f]]||m[f],h()):t===Oe&&m.charCodeAt(f+1)===Pe?(e&&r.push([,e]),e="",h(2),r.push(A(0,125))):(e+=m[f],h(),t=m.charCodeAt(f),t===J&&e&&r.push([,e])):k("Unterminated template");return h(),r},Le=I[J];I[J]=(r,e)=>r&&e<ve?d.asi&&d.newline?void 0:(h(),["``",r,...Mr()]):r?Le?.(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(l=>l(p)))});d.string["'"]=!0;d.number={"0x":16,"0b":2,"0o":8};export{q as access,c as binary,o as compile,m as cur,pe as default,k as err,A as expr,B as group,_e as id,f as idx,T as keyword,_ as literal,lr as loc,I as lookup,Z as nary,v as next,s as operator,Y as operators,Ue as parens,d as parse,ur as peek,fr as prec,L as seek,h as skip,N as space,E as token,a as unary,G as word};
1
+ var u,c,d=r=>(u=0,c=r,d.enter?.(),r=y(),c[u]?v():r||""),v=(r="Unexpected token",t=u,e=c.slice(0,t).split(`
2
+ `),o=e.pop(),i=c.slice(Math.max(0,t-40),t),p="\u032D",f=(c[t]||" ")+p,m=c.slice(t+1,t+20))=>{throw SyntaxError(`${r} at ${e.length+1}:${o.length+1}
3
+ ${c[t-41]!==`
4
+ `,""+i}${f}${m}`)},sr=(r,t=u)=>(Array.isArray(r)&&(r.loc=t),r),R=(r,t=u,e)=>{for(;e=r(c.charCodeAt(u));)u+=e;return c.slice(t,u)},C=(r=1)=>c[u+=r],F=r=>u=r,y=(r=0,t)=>{let e,o,i;for(t&&d.enter?.(r,t);(e=_())&&e!==t&&(i=J(o,r,e,y));)o=i;return t&&(e==t?(u++,d.exit?.(r,t)):v("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),o},J=(r,t,e,o,i)=>(i=I[e])&&i(r,t)||(r?null:R(d.id)||null),_=r=>{for(;(r=c.charCodeAt(u))<=32;)u++;return r},pr=(r=u)=>{for(;c.charCodeAt(r)<=32;)r++;return c.charCodeAt(r)},wt=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,mr=(r,t=r.length)=>c.substr(u,t)===r&&!d.id(c.charCodeAt(u+t)),kt=()=>(C(),y(0,41)),I=[],ir={},w=(r,t=32,e,o=r.charCodeAt(0),i=r.length,p=I[o],f=r.toUpperCase()!==r,m,g)=>(t=ir[r]=!p&&ir[r]||t,I[o]=(h,E,A,S=u)=>(m=A,(A?r==A:(i<2||r.charCodeAt(1)===c.charCodeAt(u+1)&&(i<3||c.substr(u,i)==r))&&(!f||!d.id(c.charCodeAt(u+i)))&&(m=A=r))&&E<t&&(u+=i,(g=e(h))?sr(g,S):(u=S,m=0,!f&&!p&&!h&&v()),g)||p?.(h,E,m))),l=(r,t,e=!1)=>w(r,t,o=>o&&(i=>i&&[r,o,i])(y(t-(e?.5:0)))),k=(r,t,e)=>w(r,t,o=>e?o&&[r,o]:!o&&(o=y(t-.5))&&[r,o]),L=(r,t)=>w(r,200,e=>!e&&[,t]),Y=(r,t,e)=>w(r,t,(o,i)=>(i=y(t-(e?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o)),U=(r,t)=>w(r[0],t,e=>!e&&[r,y(0,r.charCodeAt(1))||null]),Z=(r,t)=>w(r[0],t,e=>e&&[r,e,y(0,r.charCodeAt(1))||null]),X=(r,t,e,o=r.charCodeAt(0),i=r.length,p=I[o],f)=>I[o]=(m,g,h,E=u)=>!m&&(h?r==h:(i<2||c.substr(u,i)==r)&&(h=r))&&g<t&&!d.id(c.charCodeAt(u+i))&&(!d.prop||d.prop(u+i))&&(F(u+i),(f=e())?sr(f,E):F(E),f)||p?.(m,g,h);Object.defineProperty(d,"space",{configurable:!0,enumerable:!0,get:()=>_,set:r=>_=r});Object.defineProperty(d,"step",{configurable:!0,enumerable:!0,get:()=>J,set:r=>J=r});var V={},s=(r,t,e=V[r])=>V[r]=(...o)=>t(...o)||e?.(...o),n=r=>Array.isArray(r)?r[0]==null?(t=>()=>t)(r[1]):V[r[0]]?.(...r.slice(1))??v(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:t=>t?.[r];var $=46,M=48,a=57,Lr=69,Tr=101,_r=43,Ur=45,G=95,fr=110,Mr=97,Br=102,Dr=65,Fr=70,ur=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),q=r=>{let t=ur(R(e=>e===$&&c.charCodeAt(u+1)!==$||e>=M&&e<=a||e===G||((e===Lr||e===Tr)&&((e=c.charCodeAt(u+1))>=M&&e<=a||e===_r||e===Ur)?2:0)));return c.charCodeAt(u)===fr?(C(),[,BigInt(t)]):(r=+t)!=r?v():[,r]},Xr={2:r=>r===48||r===49||r===G,8:r=>r>=48&&r<=55||r===G,16:r=>r>=M&&r<=a||r>=Mr&&r<=Br||r>=Dr&&r<=Fr||r===G};d.number=null;I[$]=r=>!r&&c.charCodeAt(u+1)!==$&&q();for(let r=M;r<=a;r++)I[r]=t=>t?void 0:q();I[M]=r=>{if(r)return;let t=d.number;if(t){for(let[e,o]of Object.entries(t))if(e[0]==="0"&&c[u+1]?.toLowerCase()===e[1]){C(2);let i=ur(R(Xr[o]));return c.charCodeAt(u)===fr?(C(),[,BigInt("0"+e[1]+i)]):[,parseInt(i,o)]}}return q()};var Gr=92,lr=34,cr=39,$r={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},dr=r=>(t,e,o="")=>{if(!(t||!d.string?.[String.fromCharCode(r)]))return C(),R(i=>i-r&&(i===Gr?(o+=$r[c[u+1]]||c[u+1],2):(o+=c[u],1))),c[u]===String.fromCharCode(r)?C():v("Bad string"),[,o]};I[lr]=dr(lr);I[cr]=dr(cr);d.string={'"':!0};var ar=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>l(r,ar,!0));var jr=30,Qr=40,Hr=140;k("!",Hr);l("||",jr);l("&&",Qr);var Kr=50,Wr=60,zr=70,gr=100,Jr=140;l("|",Kr);l("&",zr);l("^",Wr);l(">>",gr);l("<<",gr);k("~",Jr);var j=90;l("<",j);l(">",j);l("<=",j);l(">=",j);var Ar=80;l("==",Ar);l("!=",Ar);var hr=110,x=120,yr=140;l("+",hr);l("-",hr);l("*",x);l("/",x);l("%",x);k("+",yr);k("-",yr);var Q=150;w("++",Q,r=>r?["++",r,null]:["++",y(Q-1)]);w("--",Q,r=>r?["--",r,null]:["--",y(Q-1)]);var Vr=5,Yr=10;Y(",",Yr);Y(";",Vr,!0);var Zr=170;U("()",Zr);var b=170;Z("[]",b);l(".",b);Z("()",b);var qr=32,xr=d.space;d.comment??={"//":`
6
+ `,"/*":"*/"};var rr;d.space=()=>{rr||(rr=Object.entries(d.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=xr();){for(var t=0,e;e=rr[t++];)if(r===e[2]&&c.substr(u,e[0].length)===e[0]){var o=u+e[0].length;if(e[1]===`
7
+ `)for(;c.charCodeAt(o)>=qr;)o++;else{for(;c[o]&&c.substr(o,e[1].length)!==e[1];)o++;c[o]&&(o+=e[1].length)}F(o),r=0;break}if(r)return r}return r};var Cr=80;l("===",Cr);l("!==",Cr);var br=30;l("??",br);var rt=130,tt=20;l("**",rt,!0);l("**=",tt,!0);var Sr=90;l("in",Sr);l("of",Sr);var et=20,ot=100;l(">>>",ot);l(">>>=",et,!0);var tr=20;l("||=",tr,!0);l("&&=",tr,!0);l("??=",tr,!0);L("true",!0);L("false",!1);L("null",null);X("undefined",200,()=>[]);L("NaN",NaN);L("Infinity",1/0);var er=20;w("?",er,(r,t,e)=>r&&(t=y(er-1))&&R(o=>o===58)&&(e=y(er-1),["?",r,t,e]));var nt=20;l("=>",nt,!0);var it=140;k("...",it);var Er=170;w("?.",Er,(r,t)=>{if(!r)return;let e=_();return e===40?(C(),["?.()",r,y(0,41)||null]):e===91?(C(),["?.[]",r,y(0,93)]):(t=y(Er),t?["?.",r,t]:void 0)});var B=140;k("typeof",B);k("void",B);k("delete",B);X("new",B,()=>mr(".target")?(C(7),["new.target"]):["new",y(B)]);var st=20,Ir=200;d.prop=r=>pr(r)!==58;U("[]",Ir);U("{}",Ir);l(":",st-1,!0);var pt=170,H=96,mt=36,ft=123,ut=92,lt={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},wr=()=>{let r=[];for(let t="",e;(e=c.charCodeAt(u))!==H;)e?e===ut?(C(),t+=lt[c[u]]||c[u],C()):e===mt&&c.charCodeAt(u+1)===ft?(t&&r.push([,t]),t="",C(2),r.push(y(0,125))):(t+=c[u],C(),e=c.charCodeAt(u),e===H&&t&&r.push([,t])):v("Unterminated template");return C(),r},ct=I[H];I[H]=(r,t)=>r&&t<pt?d.asi&&d.newline?void 0:(C(),["``",r,...wr()]):r?ct?.(r,t):(C(),(e=>e.length<2&&e[0]?.[0]===void 0?e[0]||[,""]:["`",...e])(wr()));d.string["'"]=!0;d.number={"0x":16,"0b":2,"0o":8};var vr=(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?vr(r[1],t):(()=>{throw Error("Invalid assignment target")})(),kr={"=":(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 kr)s(r,(t,e)=>(e=n(e),vr(t,(o,i,p)=>kr[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 or=(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?or(r[1],t):(()=>{throw Error("Invalid increment target")})();s("++",(r,t)=>or(r,t===null?(e,o)=>e[o]++:(e,o)=>++e[o]));s("--",(r,t)=>or(r,t===null?(e,o)=>e[o]--:(e,o)=>--e[o]));var Or=(...r)=>(r=r.map(n),t=>{let e;for(let o of r)e=o(t);return e});s(",",Or);s(";",Or);var N=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",K=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&&K("Missing index"),r=n(r),t=n(t),e=>{let o=t(e);return N(o)?void 0:r(e)[o]}));s(".",(r,t)=>(r=n(r),t=t[0]?t:t[1],N(t)?()=>{}:e=>r(e)[t]));s("()",(r,t)=>{if(t===void 0)return r==null?K("Empty ()"):n(r);let e=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||e(p));e(t)&&K("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 nr(r,(i,p,f)=>i[p](...o(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]==="{}"),nr=(r,t,e,o)=>r==null?K("Empty ()"):r[0]==="()"&&r.length==2?nr(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)),P=nr;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 dt=r=>{throw Error(r)};s("**",(r,t)=>(r=n(r),t=n(t),e=>r(e)**t(e)));s("**=",(r,t)=>(O(r)||dt("Invalid assignment target"),t=n(t),P(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 gt=r=>{throw Error(r)};s(">>>",(r,t)=>(r=n(r),t=n(t),e=>r(e)>>>t(e)));s(">>>=",(r,t)=>(O(r)||gt("Invalid assignment target"),t=n(t),P(r,(e,o,i)=>e[o]>>>=t(i))));var At=r=>r[0]?.[0]===","?r[0].slice(1):r,D=(r,t,e)=>{if(typeof r=="string"){e[r]=t;return}let[o,...i]=r,p=At(i);if(o==="{}"){let f=[];for(let m of p){if(Array.isArray(m)&&m[0]==="..."){let S={};for(let T in t)f.includes(T)||(S[T]=t[T]);e[m[1]]=S;break}let g,h,E;typeof m=="string"?g=h=m:m[0]==="="?(typeof m[1]=="string"?g=h=m[1]:[,g,h]=m[1],E=m[2]):[,g,h]=m,f.push(g);let A=t[g];A===void 0&&E&&(A=n(E)(e)),D(h,A,e)}}else if(o==="[]"){let f=0;for(let m of p){if(m===null){f++;continue}if(Array.isArray(m)&&m[0]==="..."){e[m[1]]=t.slice(f);break}let g=m,h;Array.isArray(m)&&m[0]==="="&&([,g,h]=m);let E=t[f++];E===void 0&&h&&(E=n(h)(e)),D(g,E,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=>D(e,i(p),p)}return n(t)}),t=>{for(let e of r)e(t)});s("let",Nr);s("const",Nr);s("var",r=>typeof r=="string"?t=>{t[r]=void 0}:()=>{});var W=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=>D(e,t(o),o)}return O(r)||W("Invalid assignment target"),t=n(t),P(r,(e,o,i)=>e[o]=t(i))});s("||=",(r,t)=>(O(r)||W("Invalid assignment target"),t=n(t),P(r,(e,o,i)=>e[o]||=t(i))));s("&&=",(r,t)=>(O(r)||W("Invalid assignment target"),t=n(t),P(r,(e,o,i)=>e[o]&&=t(i))));s("??=",(r,t)=>(O(r)||W("Invalid assignment target"),t=n(t),P(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 ht=[];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 f=t?.[0]==="{}";return t=n(f?["{",t[1]]:t),m=>(...g)=>{let h={};e.forEach((A,S)=>h[A]=g[S]),i&&(h[i]=g.slice(o));let E=new Proxy(h,{get:(A,S)=>S in A?A[S]:m?.[S],set:(A,S,T)=>((S in A?A:m)[S]=T,!0),has:(A,S)=>S in A||(m?S in m:!1)});try{let A=t(E);return f?void 0:A}catch(A){if(A===ht)return A[0];throw A}}});s("...",r=>(r=n(r),t=>Object.entries(r(t))));s("?.",(r,t)=>(r=n(r),N(t)?()=>{}:e=>r(e)?.[t]));s("?.[]",(r,t)=>(r=n(r),t=n(t),e=>{let o=t(e);return N(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]==="?."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:f=>i(f)?.[p]?.(...e(f))}if(r[0]==="?.[]"){let i=n(r[1]),p=n(r[2]);return f=>{let m=i(f),g=p(f);return N(g)?void 0:m?.[g]?.(...e(f))}}if(r[0]==="."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:f=>i(f)?.[p]?.(...e(f))}if(r[0]==="[]"&&r.length===3){let i=n(r[1]),p=n(r[2]);return f=>{let m=i(f),g=p(f);return N(g)?void 0:m?.[g]?.(...e(f))}}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(f=>f(p)))(e.slice(1).map(n)):(i=>p=>[i(p)])(n(e)):()=>[];return i=>new(t(i))(...o(i))});var z=Symbol("accessor");s("get",(r,t)=>(t=t?n(t):()=>{},e=>[[z,r,{get:function(){let o=Object.create(e||{});return o.this=this,t(o)}}]]));s("set",(r,t,e)=>(e=e?n(e):()=>{},o=>[[z,r,{set:function(i){let p=Object.create(o||{});p.this=this,p[t]=i,e(p)}}]]));var yt=r=>r==null||typeof r=="string"||[":",",","...","get","set"].includes(r[0]);s("{}",(r,t)=>{if(t!==void 0)return;if(!yt(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 f of e.flatMap(m=>m(o)))if(f[0]===z){let[,m,g]=f;p[m]={...p[m],...g,configurable:!0,enumerable:!0}}else i[f[0]]=f[1];for(let f in p)Object.defineProperty(i,f,p[f]);return i}});s("{",r=>(r=r?n(r):()=>{},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(f=>f(p)))});var Pr=new WeakMap,Ct=(r,...t)=>typeof r=="string"?n(d(r)):Pr.get(r)||Pr.set(r,St(r,t)).get(r),Rr=57344,St=(r,t)=>{let e=r.reduce((p,f,m)=>p+(m?String.fromCharCode(Rr+m-1):"")+f,""),o=d(e),i=p=>{if(typeof p=="string"&&p.length===1){let f=p.charCodeAt(0)-Rr,m;if(f>=0&&f<t.length)return m=t[f],Et(m)?m:[,m]}return Array.isArray(p)?p.map(i):p};return n(i(o))},Et=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),It=Ct;export{Z as access,l as binary,n as compile,c as cur,It as default,v as err,y as expr,U as group,wt as id,u as idx,X as keyword,L as literal,sr as loc,I as lookup,Y as nary,R as next,s as operator,V as operators,kt as parens,d as parse,pr as peek,ir as prec,F as seek,C as skip,_ as space,J as step,w as token,k as unary,mr as word};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "subscript",
3
- "version": "10.3.5",
3
+ "version": "10.4.0",
4
4
  "description": "Modular expression parser & evaluator",
5
5
  "main": "subscript.js",
6
6
  "module": "subscript.js",
@@ -11,12 +11,20 @@
11
11
  "./parse": "./parse.js",
12
12
  "./justin": "./justin.js",
13
13
  "./jessie": "./jessie.js",
14
+ "./feature/subscript": "./feature/subscript.js",
15
+ "./feature/justin": "./feature/justin.js",
16
+ "./feature/jessie": "./feature/jessie.js",
14
17
  "./feature/*": "./feature/*",
18
+ "./eval/subscript": "./eval/subscript.js",
19
+ "./eval/justin": "./eval/justin.js",
20
+ "./eval/jessie": "./eval/jessie.js",
21
+ "./eval/*": "./eval/*",
15
22
  "./util/*": "./util/*"
16
23
  },
17
24
  "type": "module",
18
25
  "files": [
19
26
  "feature",
27
+ "eval",
20
28
  "util",
21
29
  "subscript.js",
22
30
  "subscript.min.js",
@@ -29,7 +37,7 @@
29
37
  ],
30
38
  "scripts": {
31
39
  "build": "esbuild subscript.js --bundle --minify --format=esm --outfile=subscript.min.js && esbuild justin.js --bundle --minify --format=esm --outfile=justin.min.js && esbuild jessie.js --bundle --minify --format=esm --outfile=jessie.min.js",
32
- "prepublishOnly": "npm run build && npm run test:e2e",
40
+ "prepublishOnly": "npm run build && npm run test && npm run test:e2e",
33
41
  "test": "node --import ./test/https-loader.js test/test.js",
34
42
  "test:e2e": "npx playwright test test/index.spec.js",
35
43
  "check-types": "tsc --noEmit subscript.d.ts"
package/parse.js CHANGED
@@ -2,13 +2,11 @@
2
2
  // Character codes
3
3
  const SPACE = 32;
4
4
 
5
- let lineBreak;
6
-
7
5
  // current string, index
8
6
  export let idx, cur,
9
7
 
10
8
  // parse input string to AST
11
- parse = s => (idx = 0, cur = s, parse.newline = false, s = expr(), cur[idx] ? err() : s || ''),
9
+ parse = s => (idx = 0, cur = s, parse.enter?.(), s = expr(), cur[idx] ? err() : s || ''),
12
10
 
13
11
  // display error with context
14
12
  err = (msg = 'Unexpected token', at = idx,
@@ -37,37 +35,30 @@ export let idx, cur,
37
35
  // set position (for backtracking)
38
36
  seek = n => idx = n,
39
37
 
40
- // a + b - c
38
+ // a + b - c. Pratt loop. Each iteration tries operator handlers via lookup,
39
+ // then identifier (when no token yet). Dialect layers (e.g. ASI) override
40
+ // step() to inject pre-empt or post-step decisions; default just inlines the
41
+ // op-then-id rule.
41
42
  expr = (p = 0, end) => {
42
- let cc, token, newNode, fn, nl;
43
- if (end) parse.asi && (parse.newline = false);
44
-
45
- while (
46
- (cc = parse.space()) &&
47
- (nl = parse.newline, 1) &&
48
- cc !== end &&
49
- (newNode =
50
- // ASI before [ on new line (access handler would consume it; lineBreak distinguishes real \n from synthetic } flag)
51
- ((token && cc === 91 && lineBreak && parse.asi?.(token, p, expr)) || null) ??
52
- ((fn = lookup[cc]) && fn(token, p)) ??
53
- (token && nl && parse.asi?.(token, p, expr)) ??
54
- (!token && next(parse.id))
55
- )
56
- ) token = newNode;
57
-
58
- if (end) cc == end ? (idx++, end === 125 && parse.asi && (parse.newline = true)) : err('Unclosed ' + String.fromCharCode(end - (end > 42 ? 2 : 1)));
43
+ let cc, token, newNode;
44
+ if (end) parse.enter?.(p, end);
45
+
46
+ while ((cc = space()) && cc !== end && (newNode = step(token, p, cc, expr))) token = newNode;
47
+
48
+ if (end) cc == end ? (idx++, parse.exit?.(p, end)) : err('Unclosed ' + String.fromCharCode(end - (end > 42 ? 2 : 1)));
59
49
 
60
50
  return token;
61
51
  },
62
52
 
53
+ // one Pratt iteration: try operator, else identifier (only at start). Returns
54
+ // truthy node or null (never `false`/`undefined`, so wrapper overrides can
55
+ // chain via `??`).
56
+ step = (a, p, cc, expr, fn) => ((fn = lookup[cc]) && fn(a, p)) || (a ? null : next(parse.id) || null),
57
+
63
58
  // skip space chars, return first non-space character
64
- space = (cc, from = idx) => {
65
- lineBreak = false
66
- while ((cc = cur.charCodeAt(idx)) <= SPACE) {
67
- if (parse.asi && cc === 10) parse.newline = lineBreak = true
68
- idx++
69
- }
70
- return cc
59
+ space = (cc) => {
60
+ while ((cc = cur.charCodeAt(idx)) <= SPACE) idx++;
61
+ return cc;
71
62
  },
72
63
 
73
64
  // peek at next non-space char without modifying idx
@@ -148,13 +139,20 @@ export let idx, cur,
148
139
  (seek(idx + l), (r = map()) ? loc(r, from) : seek(from), r) ||
149
140
  prev?.(a, curPrec, curOp);
150
141
 
151
- // Keep parse.space overrides in sync with the exported binding used by features.
142
+ // Keep parse.space / parse.step overrides in sync with the exported bindings,
143
+ // so wrappers installed via parse.X = ... are picked up by the hot loops here.
152
144
  Object.defineProperty(parse, 'space', {
153
145
  configurable: true,
154
146
  enumerable: true,
155
147
  get: () => space,
156
148
  set: fn => (space = fn)
157
149
  });
150
+ Object.defineProperty(parse, 'step', {
151
+ configurable: true,
152
+ enumerable: true,
153
+ get: () => step,
154
+ set: fn => (step = fn)
155
+ });
158
156
 
159
157
  // === Compile: AST → Evaluator ===
160
158
 
package/subscript.js CHANGED
@@ -9,24 +9,15 @@
9
9
  * For more features:
10
10
  * import { parse, compile } from 'subscript/justin.js' // + JSON, arrows, templates
11
11
  * import { parse, compile } from 'subscript/jessie.js' // + statements, functions
12
+ *
13
+ * For parse-only (no eval bundle weight):
14
+ * import { parse } from 'subscript/feature/subscript.js'
15
+ * import { parse } from 'subscript/feature/justin.js'
16
+ * import { parse } from 'subscript/feature/jessie.js'
12
17
  */
13
18
 
14
- // Expression features
15
- import './feature/number.js'; // Decimal numbers: 123, 1.5, 1e3
16
- import './feature/string.js'; // Double-quoted strings with escapes
17
-
18
- // Operators (C-family common set) - order matters for token chain performance
19
- import './feature/op/assignment.js'; // = += -= *= /= %= |= &= ^= >>= <<=
20
- import './feature/op/logical.js'; // ! && ||
21
- import './feature/op/bitwise.js'; // ~ | & ^ >> <<
22
- import './feature/op/comparison.js'; // < > <= >=
23
- import './feature/op/equality.js'; // == !=
24
- import './feature/op/arithmetic.js'; // + - * / %
25
- import './feature/op/increment.js'; // ++ --
26
-
27
- import './feature/seq.js'; // Sequences: a, b; a; b
28
- import './feature/group.js'; // Grouping: (a)
29
- import './feature/access.js'; // Property access: a.b, a[b], f(), [a,b]
19
+ import './feature/subscript.js';
20
+ import './eval/subscript.js';
30
21
 
31
22
  import { parse, compile } from './parse.js';
32
23
  export * from './parse.js';