subscript 10.3.6 → 10.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/eval/access.js +57 -0
- package/eval/accessor.js +19 -0
- package/eval/async.js +13 -0
- package/eval/class.js +35 -0
- package/eval/collection.js +41 -0
- package/eval/function.js +37 -0
- package/eval/if.js +7 -0
- package/eval/jessie.js +19 -0
- package/eval/justin.js +21 -0
- package/eval/loop.js +108 -0
- package/eval/module.js +8 -0
- package/eval/op/arithmetic.js +12 -0
- package/eval/op/arrow.js +35 -0
- package/eval/op/assign-logical.js +23 -0
- package/eval/op/assignment.js +15 -0
- package/eval/op/bitwise-unsigned.js +8 -0
- package/eval/op/bitwise.js +9 -0
- package/eval/op/comparison.js +7 -0
- package/eval/op/defer.js +4 -0
- package/eval/op/equality.js +5 -0
- package/eval/op/identity.js +5 -0
- package/eval/op/increment.js +13 -0
- package/eval/op/logical.js +6 -0
- package/eval/op/membership.js +4 -0
- package/eval/op/nullish.js +4 -0
- package/eval/op/optional.js +38 -0
- package/eval/op/pow.js +8 -0
- package/eval/op/range.js +13 -0
- package/eval/op/spread.js +4 -0
- package/eval/op/ternary.js +4 -0
- package/eval/op/type.js +5 -0
- package/eval/op/unary.js +24 -0
- package/eval/prop.js +16 -0
- package/eval/regex.js +7 -0
- package/eval/seq.js +10 -0
- package/eval/subscript.js +15 -0
- package/eval/switch.js +27 -0
- package/eval/template.js +14 -0
- package/eval/try.js +36 -0
- package/eval/unit.js +10 -0
- package/eval/var.js +69 -0
- package/feature/access.js +2 -58
- package/feature/accessor.js +2 -21
- package/feature/asi.js +55 -11
- package/feature/async.js +2 -14
- package/feature/class.js +2 -35
- package/feature/collection.js +2 -43
- package/feature/function.js +2 -39
- package/feature/if.js +2 -8
- package/feature/jessie.js +32 -0
- package/feature/justin.js +36 -0
- package/feature/loop.js +2 -109
- package/feature/module.js +1 -10
- package/feature/op/arithmetic.js +2 -13
- package/feature/op/arrow.js +2 -38
- package/feature/op/assign-logical.js +3 -24
- package/feature/op/assignment.js +2 -18
- package/feature/op/bitwise-unsigned.js +2 -8
- package/feature/op/bitwise.js +2 -14
- package/feature/op/comparison.js +2 -8
- package/feature/op/defer.js +2 -7
- package/feature/op/equality.js +2 -7
- package/feature/op/identity.js +2 -6
- package/feature/op/increment.js +2 -14
- package/feature/op/logical.js +2 -8
- package/feature/op/membership.js +2 -7
- package/feature/op/nullish.js +2 -5
- package/feature/op/optional.js +2 -41
- package/feature/op/pow.js +2 -10
- package/feature/op/range.js +2 -16
- package/feature/op/spread.js +2 -7
- package/feature/op/ternary.js +2 -7
- package/feature/op/type.js +2 -8
- package/feature/op/unary.js +2 -27
- package/feature/prop.js +2 -17
- package/feature/regex.js +3 -12
- package/feature/seq.js +2 -11
- package/feature/shebang.js +7 -0
- package/feature/subscript.js +23 -0
- package/feature/switch.js +2 -28
- package/feature/template.js +4 -16
- package/feature/try.js +4 -38
- package/feature/unit.js +4 -7
- package/feature/var.js +2 -70
- package/jessie.js +4 -25
- package/jessie.min.js +9 -8
- package/justin.js +4 -30
- package/justin.min.js +8 -8
- package/package.json +9 -1
- package/parse.js +27 -29
- package/subscript.js +7 -16
- package/subscript.min.js +5 -5
package/subscript.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),n=
|
|
3
|
-
${
|
|
4
|
-
`,""+o}${d}${
|
|
5
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},x=r=>(e,
|
|
1
|
+
var s,l,f=r=>(s=0,l=r,f.enter?.(),r=g(),l[s]?y():r||""),y=(r="Unexpected token",t=s,e=l.slice(0,t).split(`
|
|
2
|
+
`),n=e.pop(),o=l.slice(Math.max(0,t-40),t),m="\u032D",d=(l[t]||" ")+m,c=l.slice(t+1,t+20))=>{throw SyntaxError(`${r} at ${e.length+1}:${n.length+1}
|
|
3
|
+
${l[t-41]!==`
|
|
4
|
+
`,""+o}${d}${c}`)},J=(r,t=s)=>(Array.isArray(r)&&(r.loc=t),r),I=(r,t=s,e)=>{for(;e=r(l.charCodeAt(s));)s+=e;return l.slice(t,s)},S=(r=1)=>l[s+=r],W=r=>s=r,g=(r=0,t)=>{let e,n,o;for(t&&f.enter?.(r,t);(e=O())&&e!==t&&(o=N(n,r,e,g));)n=o;return t&&(e==t?(s++,f.exit?.(r,t)):y("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),n},N=(r,t,e,n,o)=>(o=A[e])&&o(r,t)||(r?null:I(f.id)||null),O=r=>{for(;(r=l.charCodeAt(s))<=32;)s++;return r},Or=(r=s)=>{for(;l.charCodeAt(r)<=32;)r++;return l.charCodeAt(r)},$r=f.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,Fr=(r,t=r.length)=>l.substr(s,t)===r&&!f.id(l.charCodeAt(s+t)),Xr=()=>(S(),g(0,41)),A=[],z={},h=(r,t=32,e,n=r.charCodeAt(0),o=r.length,m=A[n],d=r.toUpperCase()!==r,c,_)=>(t=z[r]=!m&&z[r]||t,A[n]=(C,w,T,G=s)=>(c=T,(T?r==T:(o<2||r.charCodeAt(1)===l.charCodeAt(s+1)&&(o<3||l.substr(s,o)==r))&&(!d||!f.id(l.charCodeAt(s+o)))&&(c=T=r))&&w<t&&(s+=o,(_=e(C))?J(_,G):(s=G,c=0,!d&&!m&&!C&&y()),_)||m?.(C,w,c))),u=(r,t,e=!1)=>h(r,t,n=>n&&(o=>o&&[r,n,o])(g(t-(e?.5:0)))),E=(r,t,e)=>h(r,t,n=>e?n&&[r,n]:!n&&(n=g(t-.5))&&[r,n]),Br=(r,t)=>h(r,200,e=>!e&&[,t]),F=(r,t,e)=>h(r,t,(n,o)=>(o=g(t-(e?.5:0)),n?.[0]!==r&&(n=[r,n||null]),o?.[0]===r?n.push(...o.slice(1)):n.push(o||null),n)),K=(r,t)=>h(r[0],t,e=>!e&&[r,g(0,r.charCodeAt(1))||null]),X=(r,t)=>h(r[0],t,e=>e&&[r,e,g(0,r.charCodeAt(1))||null]),Qr=(r,t,e,n=r.charCodeAt(0),o=r.length,m=A[n],d)=>A[n]=(c,_,C,w=s)=>!c&&(C?r==C:(o<2||l.substr(s,o)==r)&&(C=r))&&_<t&&!f.id(l.charCodeAt(s+o))&&(!f.prop||f.prop(s+o))&&(W(s+o),(d=e())?J(d,w):W(w),d)||m?.(c,_,C);Object.defineProperty(f,"space",{configurable:!0,enumerable:!0,get:()=>O,set:r=>O=r});Object.defineProperty(f,"step",{configurable:!0,enumerable:!0,get:()=>N,set:r=>N=r});var $={},p=(r,t,e=$[r])=>$[r]=(...n)=>t(...n)||e?.(...n),i=r=>Array.isArray(r)?r[0]==null?(t=>()=>t)(r[1]):$[r[0]]?.(...r.slice(1))??y(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:t=>t?.[r];var R=46,P=48,D=57,lr=69,mr=101,ur=43,fr=45,U=95,V=110,cr=97,dr=102,Ar=65,gr=70,Y=r=>r.indexOf("_")<0?r:r.replaceAll("_",""),B=r=>{let t=Y(I(e=>e===R&&l.charCodeAt(s+1)!==R||e>=P&&e<=D||e===U||((e===lr||e===mr)&&((e=l.charCodeAt(s+1))>=P&&e<=D||e===ur||e===fr)?2:0)));return l.charCodeAt(s)===V?(S(),[,BigInt(t)]):(r=+t)!=r?y():[,r]},hr={2:r=>r===48||r===49||r===U,8:r=>r>=48&&r<=55||r===U,16:r=>r>=P&&r<=D||r>=cr&&r<=dr||r>=Ar&&r<=gr||r===U};f.number=null;A[R]=r=>!r&&l.charCodeAt(s+1)!==R&&B();for(let r=P;r<=D;r++)A[r]=t=>t?void 0:B();A[P]=r=>{if(r)return;let t=f.number;if(t){for(let[e,n]of Object.entries(t))if(e[0]==="0"&&l[s+1]?.toLowerCase()===e[1]){S(2);let o=Y(I(hr[n]));return l.charCodeAt(s)===V?(S(),[,BigInt("0"+e[1]+o)]):[,parseInt(o,n)]}}return B()};var Cr=92,Z=34,q=39,yr={n:`
|
|
5
|
+
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},x=r=>(t,e,n="")=>{if(!(t||!f.string?.[String.fromCharCode(r)]))return S(),I(o=>o-r&&(o===Cr?(n+=yr[l[s+1]]||l[s+1],2):(n+=l[s],1))),l[s]===String.fromCharCode(r)?S():y("Bad string"),[,n]};A[Z]=x(Z);A[q]=x(q);f.string={'"':!0};var Sr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>u(r,Sr,!0));var Er=30,_r=40,Ir=140;E("!",Ir);u("||",Er);u("&&",_r);var wr=50,Pr=60,Tr=70,j=100,Ur=140;u("|",wr);u("&",Tr);u("^",Pr);u(">>",j);u("<<",j);E("~",Ur);var M=90;u("<",M);u(">",M);u("<=",M);u(">=",M);var a=80;u("==",a);u("!=",a);var b=110,Q=120,rr=140;u("+",b);u("-",b);u("*",Q);u("/",Q);u("%",Q);E("+",rr);E("-",rr);var k=150;h("++",k,r=>r?["++",r,null]:["++",g(k-1)]);h("--",k,r=>r?["--",r,null]:["--",g(k-1)]);var Rr=5,Dr=10;F(",",Dr);F(";",Rr,!0);var Mr=170;K("()",Mr);var H=170;X("[]",H);u(".",H);X("()",H);var er=(r,t,e,n)=>typeof r=="string"?o=>t(o,r,o):r[0]==="."?(e=i(r[1]),n=r[2],o=>t(e(o),n,o)):r[0]==="[]"&&r.length===3?(e=i(r[1]),n=i(r[2]),o=>t(e(o),n(o),o)):r[0]==="()"&&r.length===2?er(r[1],t):(()=>{throw Error("Invalid assignment target")})(),tr={"=":(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 tr)p(r,(t,e)=>(e=i(e),er(t,(n,o,m)=>tr[r](n,o,e(m)))));p("!",r=>(r=i(r),t=>!r(t)));p("||",(r,t)=>(r=i(r),t=i(t),e=>r(e)||t(e)));p("&&",(r,t)=>(r=i(r),t=i(t),e=>r(e)&&t(e)));p("~",r=>(r=i(r),t=>~r(t)));p("|",(r,t)=>(r=i(r),t=i(t),e=>r(e)|t(e)));p("&",(r,t)=>(r=i(r),t=i(t),e=>r(e)&t(e)));p("^",(r,t)=>(r=i(r),t=i(t),e=>r(e)^t(e)));p(">>",(r,t)=>(r=i(r),t=i(t),e=>r(e)>>t(e)));p("<<",(r,t)=>(r=i(r),t=i(t),e=>r(e)<<t(e)));p(">",(r,t)=>(r=i(r),t=i(t),e=>r(e)>t(e)));p("<",(r,t)=>(r=i(r),t=i(t),e=>r(e)<t(e)));p(">=",(r,t)=>(r=i(r),t=i(t),e=>r(e)>=t(e)));p("<=",(r,t)=>(r=i(r),t=i(t),e=>r(e)<=t(e)));p("==",(r,t)=>(r=i(r),t=i(t),e=>r(e)==t(e)));p("!=",(r,t)=>(r=i(r),t=i(t),e=>r(e)!=t(e)));p("+",(r,t)=>t!==void 0?(r=i(r),t=i(t),e=>r(e)+t(e)):(r=i(r),e=>+r(e)));p("-",(r,t)=>t!==void 0?(r=i(r),t=i(t),e=>r(e)-t(e)):(r=i(r),e=>-r(e)));p("*",(r,t)=>(r=i(r),t=i(t),e=>r(e)*t(e)));p("/",(r,t)=>(r=i(r),t=i(t),e=>r(e)/t(e)));p("%",(r,t)=>(r=i(r),t=i(t),e=>r(e)%t(e)));var v=(r,t,e,n)=>typeof r=="string"?o=>t(o,r):r[0]==="."?(e=i(r[1]),n=r[2],o=>t(e(o),n)):r[0]==="[]"&&r.length===3?(e=i(r[1]),n=i(r[2]),o=>t(e(o),n(o))):r[0]==="()"&&r.length===2?v(r[1],t):(()=>{throw Error("Invalid increment target")})();p("++",(r,t)=>v(r,t===null?(e,n)=>e[n]++:(e,n)=>++e[n]));p("--",(r,t)=>v(r,t===null?(e,n)=>e[n]--:(e,n)=>--e[n]));var or=(...r)=>(r=r.map(i),t=>{let e;for(let n of r)e=n(t);return e});p(",",or);p(";",or);var nr=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",L=r=>{throw Error(r)};p("[]",(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]),n=>e(n)):(e=i(e),n=>[e(n)])),e=>r.flatMap(n=>n(e))):(t==null&&L("Missing index"),r=i(r),t=i(t),e=>{let n=t(e);return nr(n)?void 0:r(e)[n]}));p(".",(r,t)=>(r=i(r),t=t[0]?t:t[1],nr(t)?()=>{}:e=>r(e)[t]));p("()",(r,t)=>{if(t===void 0)return r==null?L("Empty ()"):i(r);let e=o=>o?.[0]===","&&o.slice(1).some(m=>m==null||e(m));e(t)&&L("Empty argument");let n=t?t[0]===","?(t=t.slice(1).map(i),o=>t.map(m=>m(o))):(t=i(t),o=>[t(o)]):()=>[];return ir(r,(o,m,d)=>o[m](...n(d)))});var ir=(r,t,e,n)=>r==null?L("Empty ()"):r[0]==="()"&&r.length==2?ir(r[1],t):typeof r=="string"?o=>t(o,r,o):r[0]==="."?(e=i(r[1]),n=r[2],o=>t(e(o),n,o)):r[0]==="?."?(e=i(r[1]),n=r[2],o=>{let m=e(o);return m==null?void 0:t(m,n,o)}):r[0]==="[]"&&r.length===3?(e=i(r[1]),n=i(r[2]),o=>t(e(o),n(o),o)):r[0]==="?.[]"?(e=i(r[1]),n=i(r[2]),o=>{let m=e(o);return m==null?void 0:t(m,n(o),o)}):(r=i(r),o=>t([r(o)],0,o));var sr=new WeakMap,kr=(r,...t)=>typeof r=="string"?i(f(r)):sr.get(r)||sr.set(r,Lr(r,t)).get(r),pr=57344,Lr=(r,t)=>{let e=r.reduce((m,d,c)=>m+(c?String.fromCharCode(pr+c-1):"")+d,""),n=f(e),o=m=>{if(typeof m=="string"&&m.length===1){let d=m.charCodeAt(0)-pr,c;if(d>=0&&d<t.length)return c=t[d],Nr(c)?c:[,c]}return Array.isArray(m)?m.map(o):m};return i(o(n))},Nr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Ft=kr;export{X as access,u as binary,i as compile,l as cur,Ft as default,y as err,g as expr,K as group,$r as id,s as idx,Qr as keyword,Br as literal,J as loc,A as lookup,F as nary,I as next,p as operator,$ as operators,Xr as parens,f as parse,Or as peek,z as prec,W as seek,S as skip,O as space,N as step,h as token,E as unary,Fr as word};
|