subscript 8.2.1 → 8.3.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.
package/README.md CHANGED
@@ -52,11 +52,11 @@ _Just-in_ is no-keywords JS subset, _JSON_ + _expressions_ (see [thread](https:/
52
52
  + `a ?? b`, `a ??= b`
53
53
  + `a ||= b`, `a &&= b`
54
54
  + `a ? b : c`, `a?.b`
55
+ + `...a`
55
56
  + `[a, b]` Array
56
57
  + `{a: b}` Object
57
58
  + `(a, b) => c` Function
58
59
  + `// foo`, `/* bar */`
59
- + `a ||= b`
60
60
  + `true`, `false`, `null`, `NaN`, `undefined`
61
61
  + `a in b`
62
62
  <!-- + `...x` unary operator -->
@@ -145,7 +145,7 @@ token('undefined', 20, a => a ? err() : [, undefined])
145
145
  token('NaN', 20, a => a ? err() : [, NaN])
146
146
  ```
147
147
 
148
- See [`./feature/*`](./feature) for examples.
148
+ See [`./feature/*`](./feature) or [`./justin.js`](./justin.js) for examples.
149
149
 
150
150
 
151
151
  <!--
@@ -224,18 +224,6 @@ math-parser: -
224
224
 
225
225
  ## Alternatives
226
226
 
227
- * [jexpr](https://github.com/justinfagnani/jexpr)
228
- * [jsep](https://github.com/EricSmekens/jsep)
229
- * [jexl](https://github.com/TomFrost/Jexl)
230
- * [mozjexl](https://github.com/mozilla/mozjexl)
231
- * [expr-eval](https://github.com/silentmatt/expr-eval)
232
- * [expression-eval](https://github.com/donmccurdy/expression-eval)
233
- * [string-math](https://github.com/devrafalko/string-math)
234
- * [nerdamer](https://github.com/jiggzson/nerdamer)
235
- * [math-codegen](https://github.com/mauriciopoppe/math-codegen)
236
- * [math-parser](https://www.npmjs.com/package/math-parser)
237
- * [math.js](https://mathjs.org/docs/expressions/parsing.html)
238
- * [nx-compile](https://github.com/nx-js/compiler-util)
239
- * [built-in-math-eval](https://github.com/mauriciopoppe/built-in-math-eval)
227
+ [jexpr](https://github.com/justinfagnani/jexpr), [jsep](https://github.com/EricSmekens/jsep), [jexl](https://github.com/TomFrost/Jexl), [mozjexl](https://github.com/mozilla/mozjexl), [expr-eval](https://github.com/silentmatt/expr-eval), [expression-eval](https://github.com/donmccurdy/expression-eval), [string-math](https://github.com/devrafalko/string-math), [nerdamer](https://github.com/jiggzson/nerdamer), [math-codegen](https://github.com/mauriciopoppe/math-codegen), [math-parser](https://www.npmjs.com/package/math-parser), [math.js](https://mathjs.org/docs/expressions/parsing.html), [nx-compile](https://github.com/nx-js/compiler-util), [built-in-math-eval](https://github.com/mauriciopoppe/built-in-math-eval)
240
228
 
241
229
  <p align=center><a href="https://github.com/krsnzd/license/">🕉</a></p>
package/feature/array.js CHANGED
@@ -5,7 +5,7 @@ import { PREC_TOKEN } from '../src/const.js'
5
5
  // [a,b,c]
6
6
  group('[]', PREC_TOKEN)
7
7
  operator('[]', (a, b) => (
8
- !a ? () => [] : // []
9
- a[0] === ',' ? (a = a.slice(1).map(compile), ctx => a.map(a => a(ctx))) : // [a,b,c]
10
- (a = compile(a), ctx => [a(ctx)]) // [a]
11
- ))
8
+ a = !a ? [] : a[0] === ',' ? a.slice(1) : [a],
9
+ a = a.map(a => a[0] === '...' ? (a = compile(a[1]), ctx => a(ctx)) : (a = compile(a), ctx => [a(ctx)])),
10
+ ctx => a.flatMap(a => (a(ctx))))
11
+ )
@@ -1,7 +1,7 @@
1
1
  import { SPACE, STAR, PREC_TOKEN } from "../src/const.js"
2
- import { token, skip, cur, idx, expr } from "../src/parse.js"
2
+ import { token, skip, next, cur, idx, expr } from "../src/parse.js"
3
3
 
4
4
  // /**/, //
5
5
  // FIXME: try replacing with group
6
- token('/*', PREC_TOKEN, (a, prec) => (skip(c => c !== STAR && cur.charCodeAt(idx + 1) !== 47), skip(2), a || expr(prec) || []))
7
- token('//', PREC_TOKEN, (a, prec) => (skip(c => c >= SPACE), a || expr(prec) || ['']))
6
+ token('/*', PREC_TOKEN, (a, prec) => (next(c => c !== STAR && cur.charCodeAt(idx + 1) !== 47), skip(2), a || expr(prec) || []))
7
+ token('//', PREC_TOKEN, (a, prec) => (next(c => c >= SPACE), a || expr(prec) || ['']))
package/feature/number.js CHANGED
@@ -1,11 +1,13 @@
1
- import { lookup, skip, err } from "../src/parse.js"
1
+ import { lookup, next, skip, err, cur, idx } from "../src/parse.js"
2
2
  import { PERIOD, _0, _E, _e, _9 } from "../src/const.js"
3
3
 
4
4
  // parse number
5
- const num = a => a ? err() : [, (a = +skip(c => c === PERIOD || (c >= _0 && c <= _9) || (c === _E || c === _e ? 2 : 0))) != a ? err() : a]
5
+ const num = (a, _) => [, (
6
+ a = +next(c => (c === PERIOD) || (c >= _0 && c <= _9) || (c === _E || c === _e ? 2 : 0))
7
+ ) != a ? err() : a]
6
8
 
7
9
  // .1
8
- lookup[PERIOD] = a => (!a && num())
10
+ lookup[PERIOD] = a => !a && num()
9
11
 
10
12
  // 0-9
11
- for (let i = _0; i <= _9; i++) lookup[i] = num
13
+ for (let i = _0; i <= _9; i++) lookup[i] = a => a ? err() : num()
package/feature/object.js CHANGED
@@ -6,11 +6,12 @@ import { PREC_ASSIGN, PREC_SEQ, PREC_TOKEN } from '../src/const.js'
6
6
  // {a:1, b:2, c:3}
7
7
  group('{}', PREC_TOKEN)
8
8
  operator('{}', (a, b) => (
9
- !a ? () => ({}) : // {}
10
- a[0] === ',' ? (a = a.slice(1).map(compile), ctx => Object.fromEntries(a.map(a => a(ctx)))) : // {a:1,b:2}
11
- a[0] === ':' ? (a = compile(a), ctx => Object.fromEntries([a(ctx)])) : // {a:1}
12
- (b = compile(a), ctx => ({ [a]: b(ctx) }))
9
+ // {}, {a:b}, {a}, {a, b}
10
+ a = (!a ? [] : a[0] !== ',' ? [a] : a.slice(1)),
11
+ a = a.map(p => compile(typeof p === 'string' ? [':', p, p] : p)),
12
+ ctx => Object.fromEntries(a.flatMap(frag => frag(ctx)))
13
13
  ))
14
14
 
15
15
  binary(':', PREC_ASSIGN, true)
16
- operator(':', (a, b) => (b = compile(b), a = Array.isArray(a) ? compile(a) : (a => a).bind(0, a), ctx => [a(ctx), b(ctx)]))
16
+ // "a": a, a: a
17
+ operator(':', (a, b) => (b = compile(b), Array.isArray(a) ? (a = compile(a), ctx => [[a(ctx), b(ctx)]]) : ctx => [[a, b(ctx)]]))
@@ -0,0 +1,6 @@
1
+ import { unary } from "../src/parse.js"
2
+ import { PREC_PREFIX } from "../src/const.js"
3
+ import { operator, compile } from "../src/compile.js"
4
+
5
+ unary('...', PREC_PREFIX)
6
+ operator('...', (a) => (a = compile(a), ctx => Object.entries(a(ctx))))
package/justin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // no-keywords js, just in https://github.com/endojs/Jessie/issues/66
2
- import { err, token, binary } from './src/parse.js'
3
- import compile, { operator } from './src/compile.js'
2
+ import { err, token, binary, unary } from './src/parse.js'
3
+ import compile, { operator, prop } from './src/compile.js'
4
4
 
5
5
  import subscript from './subscript.js'
6
6
  import './feature/comment.js'
@@ -11,6 +11,7 @@ import './feature/array.js'
11
11
  import './feature/object.js'
12
12
  import './feature/arrow.js'
13
13
  import './feature/optional.js'
14
+ import './feature/spread.js'
14
15
  import { PREC_ASSIGN, PREC_EQ, PREC_LOR, PREC_COMP } from './src/const.js'
15
16
 
16
17
  binary('in', PREC_COMP), operator('in', (a, b) => b && (a = compile(a), b = compile(b), ctx => a(ctx) in b(ctx)))
package/justin.min.js CHANGED
@@ -1 +1 @@
1
- let r,e,t=t=>(r=0,e=t,t=s(),e[r]?a():t||""),a=(t="Bad syntax",a=e.slice(0,r).split("\n"),p=a.pop())=>{let s=e.slice(r-108,r).split("\n").pop(),o=e.slice(r,r+108).split("\n").shift();throw EvalError(`${t} at ${a.length}:${p.length} \`${r>=108?"…":""}${s}▶${o}\``,"font-weight: bold")},p=(t=1,a=r,p)=>{if("number"==typeof t)r+=t;else for(;p=t(e.charCodeAt(r));)r+=p;return e.slice(a,r)},s=(e=0,p,s,o,n,l)=>{for(;(s=t.space())&&(n=((l=i[s])&&l(o,e))??(!o&&t.id()));)o=n;return p&&(s==p?r++:a()),o},o=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||36==r||95==r||r>=192&&215!=r&&247!=r;t.id=()=>p(o),t.space=t=>{for(;(t=e.charCodeAt(r))<=32;)r++;return t};let i=[],n=(t,a=32,p,s=t.charCodeAt(0),n=t.length,l=i[s],c=t.toUpperCase()!==t)=>i[s]=(s,i,d=r)=>i<a&&(n<2||e.substr(r,n)==t)&&(!c||!o(e.charCodeAt(r+n)))&&(r+=n,p(s,i))||(r=d,l?.(s,i)),l=(r,e,t=!1)=>n(r,e,((a,p)=>a&&(p=s(e-(t?.5:0)))&&[r,a,p])),c=(r,e,t)=>n(r,e,(a=>t?a&&[r,a]:!a&&(a=s(e-.5))&&[r,a])),d=(r,e)=>{n(r,e,((t,a)=>(a=s(e),(!t||t[0]!==r)&&(t=[r,t]),t.push(a),t)))},f=(r,e)=>n(r[0],e,(e=>!e&&[r,s(0,r.charCodeAt(1))])),m=(r,e)=>n(r[0],e,(e=>e&&[r[0],e,s(0,r.charCodeAt(1))]));const h=r=>Array.isArray(r)?r[0]?u[r[0]](...r.slice(1)):()=>r[1]:h.id(r);h.id=r=>e=>e?.[r];const u={},A=(r,e,t=u[r])=>u[r]=(...r)=>e(...r)||t&&t(...r),y=(r,e,t,p,s)=>"()"===r[0]?y(r[1],e,t):"string"==typeof r?t=>e(t,r,t):"."===r[0]?(p=h(r[1]),s=r[2],r=>e(p(r),s,r)):"["===r[0]?(p=h(r[1]),s=h(r[2]),r=>e(p(r),s(r),r)):t?(r=h(r),t=>e([r(t)],0,t)):()=>a("Bad left value"),b=r=>r?a():[,(r=+p((r=>46===r||r>=48&&r<=57||(69===r||101===r?2:0))))!=r?a():r];i[46]=r=>!r&&b();for(let r=48;r<=57;r++)i[r]=b;const C={n:"\n",r:"\r",t:"\t",b:"\b",f:"\f",v:"\v"},g=t=>(s,o,i="")=>{for(s&&a("Unexpected string"),p();(o=e.charCodeAt(r))-t;)92===o?(p(),o=p(),i+=C[o]||o):i+=p();return p()||a("Bad string"),[,i]};i[34]=g(34),i[39]=g(39),m("()",17),A("(",((r,e,t)=>(t=e?","===e[0]?(e=e.slice(1).map((r=>r?h(r):err())),r=>e.map((e=>e(r)))):(e=h(e),r=>[e(r)]):()=>[],y(r,((r,e,a)=>r[e](...t(a))),!0)))),m("[]",17),A("[",((r,e)=>e?(r=h(r),e=h(e),t=>r(t)[e(t)]):err())),l(".",17),A(".",((r,e)=>(r=h(r),e=e[0]?e:e[1],t=>r(t)[e]))),f("()",17),A("()",(r=>(!r&&a("Empty ()"),h(r))));const v=(...r)=>(r=r.map(h),e=>r.map((r=>r(e))).pop());d(",",1),A(",",v),d(";",1),A(";",v),l("*",12),A("*",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)*e(t)))),l("/",12),A("/",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)/e(t)))),l("%",12),A("%",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)%e(t)))),l("*=",2,!0),A("*=",((r,e)=>(e=h(e),y(r,((r,t,a)=>r[t]*=e(a)))))),l("/=",2,!0),A("/=",((r,e)=>(e=h(e),y(r,((r,t,a)=>r[t]/=e(a)))))),l("%=",2,!0),A("%=",((r,e)=>(e=h(e),y(r,((r,t,a)=>r[t]%=e(a)))))),c("+",14),A("+",((r,e)=>!e&&(r=h(r),e=>+r(e)))),c("-",14),A("-",((r,e)=>!e&&(r=h(r),e=>-r(e)))),l("+",11),A("+",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)+e(t)))),l("-",11),A("-",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)-e(t)))),l("+=",2,!0),A("+=",((r,e)=>(e=h(e),y(r,((r,t,a)=>r[t]+=e(a)))))),l("-=",2,!0),A("-=",((r,e)=>(e=h(e),y(r,((r,t,a)=>r[t]-=e(a)))))),n("++",15,(r=>r?["++-",r]:["++",s(14)])),A("++",(r=>y(r,((r,e,t)=>++r[e])))),A("++-",(r=>y(r,((r,e,t)=>r[e]++)))),n("--",15,(r=>r?["--+",r]:["--",s(14)])),A("--",(r=>y(r,((r,e,t)=>--r[e])))),A("--+",(r=>y(r,((r,e,t)=>r[e]--)))),c("~",14),A("~",((r,e)=>!e&&(r=h(r),e=>~r(e)))),l("|",5),A("|",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)|e(t)))),l("&",7),A("&",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)&e(t)))),l("^",6),A("^",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)^e(t)))),l(">>",10),A(">>",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)>>e(t)))),l("<<",10),A("<<",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)<<e(t)))),l("==",8),A("==",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)==e(t)))),l("!=",8),A("!=",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)!=e(t)))),l(">",9),A(">",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)>e(t)))),l("<",9),A("<",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)<e(t)))),l(">=",9),A(">=",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)>=e(t)))),l("<=",9),A("<=",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)<=e(t)))),c("!",14),A("!",((r,e)=>!e&&(r=h(r),e=>!r(e)))),l("||",3),A("||",((r,e)=>(r=h(r),e=h(e),t=>r(t)||e(t)))),l("&&",4),A("&&",((r,e)=>(r=h(r),e=h(e),t=>r(t)&&e(t)))),l("=",2,!0),A("=",((r,e)=>(e=h(e),y(r,((r,t,a)=>r[t]=e(a))))));var $=r=>h(t(r));n("/*",20,((t,a)=>(p((t=>42!==t&&47!==e.charCodeAt(r+1))),p(2),t||s(a)||[]))),n("//",20,((r,e)=>(p((r=>r>=32)),r||s(e)||[""]))),l("**",13,!0),A("**",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)**e(t)))),n("?",2,((r,e,t)=>r&&(e=s(2,58))&&["?",r,e,s(3)])),A("?",((r,e,t)=>(r=h(r),e=h(e),t=h(t),a=>r(a)?e(a):t(a)))),n("true",20,(r=>r?err():[,!0])),n("false",20,(r=>r?err():[,!1])),f("[]",20),A("[]",((r,e)=>r?","===r[0]?(r=r.slice(1).map(h),e=>r.map((r=>r(e)))):(r=h(r),e=>[r(e)]):()=>[])),f("{}",20),A("{}",((r,e)=>r?","===r[0]?(r=r.slice(1).map(h),e=>Object.fromEntries(r.map((r=>r(e))))):":"===r[0]?(r=h(r),e=>Object.fromEntries([r(e)])):(e=h(r),t=>({[r]:e(t)})):()=>({}))),l(":",2,!0),A(":",((r,e)=>(e=h(e),r=Array.isArray(r)?h(r):(r=>r).bind(0,r),t=>[r(t),e(t)]))),l("=>",2,!0),A("=>",((r,e)=>(r=(r="()"===r[0]?r[1]:r)?r=","===r[0]?r.slice(1):[r]:[],e=h("{}"===e[0]?e[1]:e),(t=null)=>(t=Object.create(t),(...a)=>(r.map(((r,e)=>t[r]=a[e])),e(t)))))),l(""),n("?.",17,(r=>r&&["?.",r])),A("?.",(r=>(r=h(r),e=>r(e)||(()=>{})))),n("?.",17,((r,e)=>r&&!(e=s(17))?.map&&["?.",r,e])),A("?.",((r,e)=>e&&(r=h(r),t=>r(t)?.[e]))),A("(",((r,e,t,a,p,s)=>"?."===r[0]&&(r[2]||Array.isArray(r[1]))&&(a=e?","===e[0]?(e=e.slice(1).map(h),r=>e.map((e=>e(r)))):(e=h(e),r=>[e(r)]):()=>[],!r[2]&&(r=r[1]),p="["===r[0]?h(r[2]):()=>r[2],t=h(r[1]),r=>t(r)?.[p(r)]?.(...a(r))))),l("in",9),A("in",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)in e(t)))),l("===",8),l("!==",9),A("===",((r,e)=>(r=h(r),e=h(e),t=>r(t)===e(t)))),A("===",((r,e)=>(r=h(r),e=h(e),t=>r(t)!==e(t)))),l("??",3),A("??",((r,e)=>e&&(r=h(r),e=h(e),t=>r(t)??e(t)))),l("??=",2,!0),A("??=",((r,e)=>(e=h(e),prop(r,((r,t,a)=>r[t]??=e(a)))))),l("||=",2,!0),A("||=",((r,e)=>(e=h(e),prop(r,((r,t,a)=>r[t]||=e(a)))))),l("&&=",2,!0),A("&&=",((r,e)=>(e=h(e),prop(r,((r,t,a)=>r[t]&&=e(a)))))),n("undefined",20,(r=>r?a():[,void 0])),n("NaN",20,(r=>r?a():[,NaN])),n("null",20,(r=>r?a():[,null]));export{m as access,l as binary,h as compile,$ as default,f as group,i as lookup,d as nary,A as operator,t as parse,y as prop,n as token,c as unary};
1
+ let e,r,t=t=>(e=0,r=t,t=l(),r[e]?a():t||""),a=(t="Bad syntax",a=r.slice(0,e).split("\n"),s=a.pop())=>{let i=r.slice(e-108,e).split("\n").pop(),l=r.slice(e,e+108).split("\n").shift();throw EvalError(`${t} at ${a.length}:${s.length} \`${e>=108?"…":""}${i}▶${l}\``,"font-weight: bold")},s=(t,a=e,s)=>{for(;s=t(r.charCodeAt(e));)e+=s;return r.slice(a,e)},i=(t=1,a=e)=>(e+=t,r.slice(a,e)),l=(r=0,i,l,p,c,o)=>{for(;(l=t.space())&&(c=((o=n[l])&&o(p,r))??(!p&&s(t.id)));)p=c;return i&&(l==i?e++:a()),p};t.id=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||36==e||95==e||e>=192&&215!=e&&247!=e,t.space=t=>{for(;(t=r.charCodeAt(e))<=32;)e++;return t};let n=[],p=(a,s=32,i,l=a.charCodeAt(0),p=a.length,c=n[l],o=a.toUpperCase()!==a)=>n[l]=(l,n,d=e)=>n<s&&(p<2||r.substr(e,p)==a)&&(!o||!t.id(r.charCodeAt(e+p)))&&(e+=p,i(l,n))||(e=d,c?.(l,n)),c=(e,r,t=!1)=>p(e,r,((a,s)=>a&&(s=l(r-(t?.5:0)))&&[e,a,s])),o=(e,r,t)=>p(e,r,(a=>t?a&&[e,a]:!a&&(a=l(r-.5))&&[e,a])),d=(e,r)=>{p(e,r,((t,a)=>(a=l(r),(!t||t[0]!==e)&&(t=[e,t]),t.push(a),t)))},f=(e,r)=>p(e[0],r,(r=>!r&&[e,l(0,e.charCodeAt(1))])),h=(e,r)=>p(e[0],r,(r=>r&&[e[0],r,l(0,e.charCodeAt(1))]));const A=e=>Array.isArray(e)?e[0]?u[e[0]](...e.slice(1)):()=>e[1]:A.id(e);A.id=e=>r=>r?.[e];const u={},m=(e,r,t=u[e])=>u[e]=(...e)=>r(...e)||t&&t(...e),y=(e,r,t,s,i)=>"()"===e[0]?y(e[1],r,t):"string"==typeof e?t=>r(t,e,t):"."===e[0]?(s=A(e[1]),i=e[2],e=>r(s(e),i,e)):"["===e[0]?(s=A(e[1]),i=A(e[2]),e=>r(s(e),i(e),e)):t?(e=A(e),t=>r([e(t)],0,t)):()=>a("Bad left value"),C=(e,r)=>[,(e=+s((e=>46===e||e>=48&&e<=57||(69===e||101===e?2:0))))!=e?a():e];n[46]=e=>!e&&C();for(let e=48;e<=57;e++)n[e]=e=>e?a():C();const g={n:"\n",r:"\r",t:"\t",b:"\b",f:"\f",v:"\v"},b=t=>(s,l,n="")=>{for(s&&a("Unexpected string"),i();(l=r.charCodeAt(e))-t;)92===l?(i(),l=i(),n+=g[l]||l):n+=i();return i()||a("Bad string"),[,n]};n[34]=b(34),n[39]=b(39),h("()",17),m("(",((e,r,t)=>(t=r?","===r[0]?(r=r.slice(1).map((e=>e?A(e):err())),e=>r.map((r=>r(e)))):(r=A(r),e=>[r(e)]):()=>[],y(e,((e,r,a)=>e[r](...t(a))),!0)))),h("[]",17),m("[",((e,r)=>r?(e=A(e),r=A(r),t=>e(t)[r(t)]):err())),c(".",17),m(".",((e,r)=>(e=A(e),r=r[0]?r:r[1],t=>e(t)[r]))),f("()",17),m("()",(e=>(!e&&a("Empty ()"),A(e))));const v=(...e)=>(e=e.map(A),r=>e.map((e=>e(r))).pop());d(",",1),m(",",v),d(";",1),m(";",v),c("*",12),m("*",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)*r(t)))),c("/",12),m("/",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)/r(t)))),c("%",12),m("%",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)%r(t)))),c("*=",2,!0),m("*=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]*=r(a)))))),c("/=",2,!0),m("/=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]/=r(a)))))),c("%=",2,!0),m("%=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]%=r(a)))))),o("+",14),m("+",((e,r)=>!r&&(e=A(e),r=>+e(r)))),o("-",14),m("-",((e,r)=>!r&&(e=A(e),r=>-e(r)))),c("+",11),m("+",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)+r(t)))),c("-",11),m("-",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)-r(t)))),c("+=",2,!0),m("+=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]+=r(a)))))),c("-=",2,!0),m("-=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]-=r(a)))))),p("++",15,(e=>e?["++-",e]:["++",l(14)])),m("++",(e=>y(e,((e,r,t)=>++e[r])))),m("++-",(e=>y(e,((e,r,t)=>e[r]++)))),p("--",15,(e=>e?["--+",e]:["--",l(14)])),m("--",(e=>y(e,((e,r,t)=>--e[r])))),m("--+",(e=>y(e,((e,r,t)=>e[r]--)))),o("~",14),m("~",((e,r)=>!r&&(e=A(e),r=>~e(r)))),c("|",5),m("|",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)|r(t)))),c("&",7),m("&",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)&r(t)))),c("^",6),m("^",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)^r(t)))),c(">>",10),m(">>",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)>>r(t)))),c("<<",10),m("<<",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)<<r(t)))),c("==",8),m("==",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)==r(t)))),c("!=",8),m("!=",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)!=r(t)))),c(">",9),m(">",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)>r(t)))),c("<",9),m("<",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)<r(t)))),c(">=",9),m(">=",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)>=r(t)))),c("<=",9),m("<=",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)<=r(t)))),o("!",14),m("!",((e,r)=>!r&&(e=A(e),r=>!e(r)))),c("||",3),m("||",((e,r)=>(e=A(e),r=A(r),t=>e(t)||r(t)))),c("&&",4),m("&&",((e,r)=>(e=A(e),r=A(r),t=>e(t)&&r(t)))),c("=",2,!0),m("=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]=r(a))))));var $=e=>A(t(e));p("/*",20,((t,a)=>(s((t=>42!==t&&47!==r.charCodeAt(e+1))),i(2),t||l(a)||[]))),p("//",20,((e,r)=>(s((e=>e>=32)),e||l(r)||[""]))),c("**",13,!0),m("**",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)**r(t)))),p("?",2,((e,r,t)=>e&&(r=l(2,58))&&["?",e,r,l(3)])),m("?",((e,r,t)=>(e=A(e),r=A(r),t=A(t),a=>e(a)?r(a):t(a)))),p("true",20,(e=>e?err():[,!0])),p("false",20,(e=>e?err():[,!1])),f("[]",20),m("[]",((e,r)=>(e=(e=e?","===e[0]?e.slice(1):[e]:[]).map((e=>"..."===e[0]?(e=A(e[1]),r=>e(r)):(e=A(e),r=>[e(r)]))),r=>e.flatMap((e=>e(r)))))),f("{}",20),m("{}",((e,r)=>(e=(e=e?","!==e[0]?[e]:e.slice(1):[]).map((e=>A("string"==typeof e?[":",e,e]:e))),r=>Object.fromEntries(e.flatMap((e=>e(r))))))),c(":",2,!0),m(":",((e,r)=>(r=A(r),Array.isArray(e)?(e=A(e),t=>[[e(t),r(t)]]):t=>[[e,r(t)]]))),c("=>",2,!0),m("=>",((e,r)=>(e=(e="()"===e[0]?e[1]:e)?e=","===e[0]?e.slice(1):[e]:[],r=A("{}"===r[0]?r[1]:r),(t=null)=>(t=Object.create(t),(...a)=>(e.map(((e,r)=>t[e]=a[r])),r(t)))))),c(""),p("?.",17,(e=>e&&["?.",e])),m("?.",(e=>(e=A(e),r=>e(r)||(()=>{})))),p("?.",17,((e,r)=>e&&!(r=l(17))?.map&&["?.",e,r])),m("?.",((e,r)=>r&&(e=A(e),t=>e(t)?.[r]))),m("(",((e,r,t,a,s,i)=>"?."===e[0]&&(e[2]||Array.isArray(e[1]))&&(a=r?","===r[0]?(r=r.slice(1).map(A),e=>r.map((r=>r(e)))):(r=A(r),e=>[r(e)]):()=>[],!e[2]&&(e=e[1]),s="["===e[0]?A(e[2]):()=>e[2],t=A(e[1]),e=>t(e)?.[s(e)]?.(...a(e))))),o("...",14),m("...",(e=>(e=A(e),r=>Object.entries(e(r))))),c("in",9),m("in",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)in r(t)))),c("===",8),c("!==",9),m("===",((e,r)=>(e=A(e),r=A(r),t=>e(t)===r(t)))),m("===",((e,r)=>(e=A(e),r=A(r),t=>e(t)!==r(t)))),c("??",3),m("??",((e,r)=>r&&(e=A(e),r=A(r),t=>e(t)??r(t)))),c("??=",2,!0),m("??=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]??=r(a)))))),c("||=",2,!0),m("||=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]||=r(a)))))),c("&&=",2,!0),m("&&=",((e,r)=>(r=A(r),y(e,((e,t,a)=>e[t]&&=r(a)))))),p("undefined",20,(e=>e?a():[,void 0])),p("NaN",20,(e=>e?a():[,NaN])),p("null",20,(e=>e?a():[,null]));export{h as access,c as binary,A as compile,$ as default,f as group,n as lookup,d as nary,m as operator,t as parse,y as prop,p as token,o as unary};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "subscript",
3
- "version": "8.2.1",
3
+ "version": "8.3.0",
4
4
  "description": "Fast and tiny expression evaluator with minimal syntax.",
5
5
  "main": "subscript.js",
6
6
  "module": "subscript.js",
@@ -8,10 +8,9 @@
8
8
  "types": "./subscript.d.ts",
9
9
  "exports": {
10
10
  ".": "./subscript.js",
11
- "./parse.js": "./src/parse.js",
12
- "./compile.js": "./src/compile.js",
13
- "./subscript.js": "./subscript.js",
14
- "./justin.js": "./justin.js"
11
+ "./parse": "./src/parse.js",
12
+ "./compile": "./src/compile.js",
13
+ "./justin": "./justin.js"
15
14
  },
16
15
  "type": "module",
17
16
  "files": [
package/src/parse.d.ts CHANGED
@@ -6,7 +6,8 @@ export namespace parse {
6
6
  function id(n: any): any;
7
7
  }
8
8
  export function err(msg?: string, frag?: string): never;
9
- export function skip(is: number | ((c: number) => number)): string;
9
+ export function skip(n: number): string;
10
+ export function next(is: ((c: number) => number)): string;
10
11
  export const lookup: ((a: any, b: any) => any)[];
11
12
  export function token(op: string, prec: number, map: (a: any, curPrec: number, from: number) => any): (a: any, curPrec: number, from?: any) => any;
12
13
  export function binary(op: string, prec: number, right?: boolean | undefined): (a: any, curPrec: number, from?: any) => any;
package/src/parse.js CHANGED
@@ -15,12 +15,15 @@ export let idx, cur,
15
15
  throw EvalError(`${msg} at ${lines.length}:${last.length} \`${idx >= 108 ? '…' : ''}${before}▶${after}\``, 'font-weight: bold')
16
16
  },
17
17
 
18
- skip = (is = 1, from = idx, l) => {
19
- if (typeof is == 'number') idx += is
20
- else while (l = is(cur.charCodeAt(idx))) idx += l
18
+ // advance until condition meets
19
+ next = (is, from = idx, l) => {
20
+ while (l = is(cur.charCodeAt(idx))) idx += l
21
21
  return cur.slice(from, idx)
22
22
  },
23
23
 
24
+ // consume n characters
25
+ skip = (n = 1, from = idx) => (idx += n, cur.slice(from, idx)),
26
+
24
27
  // a + b - c
25
28
  expr = (prec = 0, end, cc, token, newNode, fn) => {
26
29
  // chunk/token parser
@@ -30,7 +33,7 @@ export let idx, cur,
30
33
  // it makes extra `space` call for parent exprs on the same character to check precedence again
31
34
  (newNode =
32
35
  ((fn = lookup[cc]) && fn(token, prec)) ?? // if operator with higher precedence isn't found
33
- (!token && parse.id()) // parse literal or quit. token seqs are forbidden: `a b`, `a "b"`, `1.32 a`
36
+ (!token && next(parse.id)) // parse literal or quit. token seqs are forbidden: `a b`, `a "b"`, `1.32 a`
34
37
  )
35
38
  ) token = newNode;
36
39
 
@@ -40,16 +43,14 @@ export let idx, cur,
40
43
  return token
41
44
  },
42
45
 
43
- isId = c =>
46
+ // parse identifier (configurable)
47
+ id = parse.id = c =>
44
48
  (c >= 48 && c <= 57) || // 0..9
45
49
  (c >= 65 && c <= 90) || // A...Z
46
50
  (c >= 97 && c <= 122) || // a...z
47
51
  c == 36 || c == 95 || // $, _,
48
52
  (c >= 192 && c != 215 && c != 247), // any non-ASCII
49
53
 
50
- // parse identifier (configurable)
51
- id = parse.id = () => skip(isId),
52
-
53
54
  // skip space chars, return first non-space character
54
55
  space = parse.space = cc => { while ((cc = cur.charCodeAt(idx)) <= SPACE) idx++; return cc },
55
56
 
@@ -68,7 +69,7 @@ export let idx, cur,
68
69
  prev = lookup[c],
69
70
  word = op.toUpperCase() !== op // make sure word boundary comes after word operator
70
71
  ) => lookup[c] = (a, curPrec, from = idx) =>
71
- (curPrec < prec && (l < 2 || cur.substr(idx, l) == op) && (!word || !isId(cur.charCodeAt(idx + l))) && (idx += l, map(a, curPrec))) ||
72
+ (curPrec < prec && (l < 2 || cur.substr(idx, l) == op) && (!word || !parse.id(cur.charCodeAt(idx + l))) && (idx += l, map(a, curPrec))) ||
72
73
  (idx = from, prev?.(a, curPrec)),
73
74
 
74
75
  // right assoc is indicated by negative precedence (meaning go from right to left)
package/subscript.min.js CHANGED
@@ -1 +1 @@
1
- let t,e,r=r=>(t=0,e=r,r=a(),e[t]?o():r||""),o=(r="Bad syntax",o=e.slice(0,t).split("\n"),s=o.pop())=>{let a=e.slice(t-108,t).split("\n").pop(),n=e.slice(t,t+108).split("\n").shift();throw EvalError(`${r} at ${o.length}:${s.length} \`${t>=108?"…":""}${a}▶${n}\``,"font-weight: bold")},s=(r=1,o=t,s)=>{if("number"==typeof r)t+=r;else for(;s=r(e.charCodeAt(t));)t+=s;return e.slice(o,t)},a=(e=0,s,a,n,l,c)=>{for(;(a=r.space())&&(l=((c=p[a])&&c(n,e))??(!n&&r.id()));)n=l;return s&&(a==s?t++:o()),n},n=t=>t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||36==t||95==t||t>=192&&215!=t&&247!=t;r.id=()=>s(n),r.space=r=>{for(;(r=e.charCodeAt(t))<=32;)t++;return r};let p=[],l=(r,o=32,s,a=r.charCodeAt(0),l=r.length,c=p[a],i=r.toUpperCase()!==r)=>p[a]=(a,p,d=t)=>p<o&&(l<2||e.substr(t,l)==r)&&(!i||!n(e.charCodeAt(t+l)))&&(t+=l,s(a,p))||(t=d,c?.(a,p)),c=(t,e,r=!1)=>l(t,e,((o,s)=>o&&(s=a(e-(r?.5:0)))&&[t,o,s])),i=(t,e,r)=>l(t,e,(o=>r?o&&[t,o]:!o&&(o=a(e-.5))&&[t,o])),d=(t,e)=>{l(t,e,((r,o)=>(o=a(e),(!r||r[0]!==t)&&(r=[t,r]),r.push(o),r)))},f=(t,e)=>l(t[0],e,(e=>!e&&[t,a(0,t.charCodeAt(1))])),h=(t,e)=>l(t[0],e,(e=>e&&[t[0],e,a(0,t.charCodeAt(1))]));const u=t=>t?o():[,(t=+s((t=>46===t||t>=48&&t<=57||(69===t||101===t?2:0))))!=t?o():t];p[46]=t=>!t&&u();for(let t=48;t<=57;t++)p[t]=u;const A={n:"\n",r:"\r",t:"\t",b:"\b",f:"\f",v:"\v"},C=r=>(a,n,p="")=>{for(a&&o("Unexpected string"),s();(n=e.charCodeAt(t))-r;)92===n?(s(),n=s(),p+=A[n]||n):p+=s();return s()||o("Bad string"),[,p]};p[34]=C(34),p[39]=C(39);const g=t=>Array.isArray(t)?t[0]?m[t[0]](...t.slice(1)):()=>t[1]:g.id(t);g.id=t=>e=>e?.[t];const m={},y=(t,e,r=m[t])=>m[t]=(...t)=>e(...t)||r&&r(...t),$=(t,e,r,s,a)=>"()"===t[0]?$(t[1],e,r):"string"==typeof t?r=>e(r,t,r):"."===t[0]?(s=g(t[1]),a=t[2],t=>e(s(t),a,t)):"["===t[0]?(s=g(t[1]),a=g(t[2]),t=>e(s(t),a(t),t)):r?(t=g(t),r=>e([t(r)],0,r)):()=>o("Bad left value");h("()",17),y("(",((t,e,r)=>(r=e?","===e[0]?(e=e.slice(1).map((t=>t?g(t):err())),t=>e.map((e=>e(t)))):(e=g(e),t=>[e(t)]):()=>[],$(t,((t,e,o)=>t[e](...r(o))),!0)))),h("[]",17),y("[",((t,e)=>e?(t=g(t),e=g(e),r=>t(r)[e(r)]):err())),c(".",17),y(".",((t,e)=>(t=g(t),e=e[0]?e:e[1],r=>t(r)[e]))),f("()",17),y("()",(t=>(!t&&o("Empty ()"),g(t))));const b=(...t)=>(t=t.map(g),e=>t.map((t=>t(e))).pop());d(",",1),y(",",b),d(";",1),y(";",b),c("*",12),y("*",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)*e(r)))),c("/",12),y("/",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)/e(r)))),c("%",12),y("%",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)%e(r)))),c("*=",2,!0),y("*=",((t,e)=>(e=g(e),$(t,((t,r,o)=>t[r]*=e(o)))))),c("/=",2,!0),y("/=",((t,e)=>(e=g(e),$(t,((t,r,o)=>t[r]/=e(o)))))),c("%=",2,!0),y("%=",((t,e)=>(e=g(e),$(t,((t,r,o)=>t[r]%=e(o)))))),i("+",14),y("+",((t,e)=>!e&&(t=g(t),e=>+t(e)))),i("-",14),y("-",((t,e)=>!e&&(t=g(t),e=>-t(e)))),c("+",11),y("+",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)+e(r)))),c("-",11),y("-",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)-e(r)))),c("+=",2,!0),y("+=",((t,e)=>(e=g(e),$(t,((t,r,o)=>t[r]+=e(o)))))),c("-=",2,!0),y("-=",((t,e)=>(e=g(e),$(t,((t,r,o)=>t[r]-=e(o)))))),l("++",15,(t=>t?["++-",t]:["++",a(14)])),y("++",(t=>$(t,((t,e,r)=>++t[e])))),y("++-",(t=>$(t,((t,e,r)=>t[e]++)))),l("--",15,(t=>t?["--+",t]:["--",a(14)])),y("--",(t=>$(t,((t,e,r)=>--t[e])))),y("--+",(t=>$(t,((t,e,r)=>t[e]--)))),i("~",14),y("~",((t,e)=>!e&&(t=g(t),e=>~t(e)))),c("|",5),y("|",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)|e(r)))),c("&",7),y("&",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)&e(r)))),c("^",6),y("^",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)^e(r)))),c(">>",10),y(">>",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)>>e(r)))),c("<<",10),y("<<",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)<<e(r)))),c("==",8),y("==",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)==e(r)))),c("!=",8),y("!=",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)!=e(r)))),c(">",9),y(">",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)>e(r)))),c("<",9),y("<",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)<e(r)))),c(">=",9),y(">=",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)>=e(r)))),c("<=",9),y("<=",((t,e)=>e&&(t=g(t),e=g(e),r=>t(r)<=e(r)))),i("!",14),y("!",((t,e)=>!e&&(t=g(t),e=>!t(e)))),c("||",3),y("||",((t,e)=>(t=g(t),e=g(e),r=>t(r)||e(r)))),c("&&",4),y("&&",((t,e)=>(t=g(t),e=g(e),r=>t(r)&&e(r)))),c("=",2,!0),y("=",((t,e)=>(e=g(e),$(t,((t,r,o)=>t[r]=e(o))))));var v=t=>g(r(t));export{h as access,c as binary,g as compile,v as default,f as group,p as lookup,d as nary,y as operator,r as parse,$ as prop,l as token,i as unary};
1
+ let t,r,e=e=>(t=0,r=e,e=n(),r[t]?s():e||""),s=(e="Bad syntax",s=r.slice(0,t).split("\n"),o=s.pop())=>{let a=r.slice(t-108,t).split("\n").pop(),n=r.slice(t,t+108).split("\n").shift();throw EvalError(`${e} at ${s.length}:${o.length} \`${t>=108?"…":""}${a}▶${n}\``,"font-weight: bold")},o=(e,s=t,o)=>{for(;o=e(r.charCodeAt(t));)t+=o;return r.slice(s,t)},a=(e=1,s=t)=>(t+=e,r.slice(s,t)),n=(r=0,a,n,l,p,i)=>{for(;(n=e.space())&&(p=((i=c[n])&&i(l,r))??(!l&&o(e.id)));)l=p;return a&&(n==a?t++:s()),l};e.id=t=>t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||36==t||95==t||t>=192&&215!=t&&247!=t,e.space=e=>{for(;(e=r.charCodeAt(t))<=32;)t++;return e};let c=[],l=(s,o=32,a,n=s.charCodeAt(0),l=s.length,p=c[n],i=s.toUpperCase()!==s)=>c[n]=(n,c,d=t)=>c<o&&(l<2||r.substr(t,l)==s)&&(!i||!e.id(r.charCodeAt(t+l)))&&(t+=l,a(n,c))||(t=d,p?.(n,c)),p=(t,r,e=!1)=>l(t,r,((s,o)=>s&&(o=n(r-(e?.5:0)))&&[t,s,o])),i=(t,r,e)=>l(t,r,(s=>e?s&&[t,s]:!s&&(s=n(r-.5))&&[t,s])),d=(t,r)=>{l(t,r,((e,s)=>(s=n(r),(!e||e[0]!==t)&&(e=[t,e]),e.push(s),e)))},h=(t,r)=>l(t[0],r,(r=>!r&&[t,n(0,t.charCodeAt(1))])),f=(t,r)=>l(t[0],r,(r=>r&&[t[0],r,n(0,t.charCodeAt(1))]));const A=(t,r)=>[,(t=+o((t=>46===t||t>=48&&t<=57||(69===t||101===t?2:0))))!=t?s():t];c[46]=t=>!t&&A();for(let t=48;t<=57;t++)c[t]=t=>t?s():A();const u={n:"\n",r:"\r",t:"\t",b:"\b",f:"\f",v:"\v"},C=e=>(o,n,c="")=>{for(o&&s("Unexpected string"),a();(n=r.charCodeAt(t))-e;)92===n?(a(),n=a(),c+=u[n]||n):c+=a();return a()||s("Bad string"),[,c]};c[34]=C(34),c[39]=C(39);const g=t=>Array.isArray(t)?t[0]?$[t[0]](...t.slice(1)):()=>t[1]:g.id(t);g.id=t=>r=>r?.[t];const $={},m=(t,r,e=$[t])=>$[t]=(...t)=>r(...t)||e&&e(...t),v=(t,r,e,o,a)=>"()"===t[0]?v(t[1],r,e):"string"==typeof t?e=>r(e,t,e):"."===t[0]?(o=g(t[1]),a=t[2],t=>r(o(t),a,t)):"["===t[0]?(o=g(t[1]),a=g(t[2]),t=>r(o(t),a(t),t)):e?(t=g(t),e=>r([t(e)],0,e)):()=>s("Bad left value");f("()",17),m("(",((t,r,e)=>(e=r?","===r[0]?(r=r.slice(1).map((t=>t?g(t):err())),t=>r.map((r=>r(t)))):(r=g(r),t=>[r(t)]):()=>[],v(t,((t,r,s)=>t[r](...e(s))),!0)))),f("[]",17),m("[",((t,r)=>r?(t=g(t),r=g(r),e=>t(e)[r(e)]):err())),p(".",17),m(".",((t,r)=>(t=g(t),r=r[0]?r:r[1],e=>t(e)[r]))),h("()",17),m("()",(t=>(!t&&s("Empty ()"),g(t))));const y=(...t)=>(t=t.map(g),r=>t.map((t=>t(r))).pop());d(",",1),m(",",y),d(";",1),m(";",y),p("*",12),m("*",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)*r(e)))),p("/",12),m("/",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)/r(e)))),p("%",12),m("%",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)%r(e)))),p("*=",2,!0),m("*=",((t,r)=>(r=g(r),v(t,((t,e,s)=>t[e]*=r(s)))))),p("/=",2,!0),m("/=",((t,r)=>(r=g(r),v(t,((t,e,s)=>t[e]/=r(s)))))),p("%=",2,!0),m("%=",((t,r)=>(r=g(r),v(t,((t,e,s)=>t[e]%=r(s)))))),i("+",14),m("+",((t,r)=>!r&&(t=g(t),r=>+t(r)))),i("-",14),m("-",((t,r)=>!r&&(t=g(t),r=>-t(r)))),p("+",11),m("+",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)+r(e)))),p("-",11),m("-",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)-r(e)))),p("+=",2,!0),m("+=",((t,r)=>(r=g(r),v(t,((t,e,s)=>t[e]+=r(s)))))),p("-=",2,!0),m("-=",((t,r)=>(r=g(r),v(t,((t,e,s)=>t[e]-=r(s)))))),l("++",15,(t=>t?["++-",t]:["++",n(14)])),m("++",(t=>v(t,((t,r,e)=>++t[r])))),m("++-",(t=>v(t,((t,r,e)=>t[r]++)))),l("--",15,(t=>t?["--+",t]:["--",n(14)])),m("--",(t=>v(t,((t,r,e)=>--t[r])))),m("--+",(t=>v(t,((t,r,e)=>t[r]--)))),i("~",14),m("~",((t,r)=>!r&&(t=g(t),r=>~t(r)))),p("|",5),m("|",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)|r(e)))),p("&",7),m("&",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)&r(e)))),p("^",6),m("^",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)^r(e)))),p(">>",10),m(">>",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)>>r(e)))),p("<<",10),m("<<",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)<<r(e)))),p("==",8),m("==",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)==r(e)))),p("!=",8),m("!=",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)!=r(e)))),p(">",9),m(">",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)>r(e)))),p("<",9),m("<",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)<r(e)))),p(">=",9),m(">=",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)>=r(e)))),p("<=",9),m("<=",((t,r)=>r&&(t=g(t),r=g(r),e=>t(e)<=r(e)))),i("!",14),m("!",((t,r)=>!r&&(t=g(t),r=>!t(r)))),p("||",3),m("||",((t,r)=>(t=g(t),r=g(r),e=>t(e)||r(e)))),p("&&",4),m("&&",((t,r)=>(t=g(t),r=g(r),e=>t(e)&&r(e)))),p("=",2,!0),m("=",((t,r)=>(r=g(r),v(t,((t,e,s)=>t[e]=r(s))))));var b=t=>g(e(t));export{f as access,p as binary,g as compile,b as default,h as group,c as lookup,d as nary,m as operator,e as parse,v as prop,l as token,i as unary};