subscript 10.0.0 → 10.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,12 @@
1
- # sub<sub><sup> ✦ </sup></sub>script [![build](https://github.com/dy/subscript/actions/workflows/node.js.yml/badge.svg)](https://github.com/dy/subscript/actions/workflows/node.js.yml) [![npm](https://img.shields.io/npm/v/subscript)](http://npmjs.org/subscript) [![size](https://img.shields.io/bundlephobia/minzip/subscript?label=size)](https://bundlephobia.com/package/subscript) [![demo](https://img.shields.io/badge/play-%F0%9F%9A%80-white)](https://dy.github.io/subscript/) [![microjs](https://img.shields.io/badge/microjs-subscript-blue?color=darkslateblue)](http://microjs.com/#subscript)
1
+ <h1 align="center">sub<sub><sup> ✦ </sup></sub>script</h1>
2
2
 
3
- > Tiny expression parser & evaluator.
3
+ <p align="center">Tiny expression parser & evaluator.</p>
4
+ <div align="center">
5
+
6
+ [![build](https://github.com/dy/subscript/actions/workflows/node.js.yml/badge.svg)](https://github.com/dy/subscript/actions/workflows/node.js.yml) [![npm](https://img.shields.io/npm/v/subscript)](http://npmjs.org/subscript) [![size](https://img.shields.io/bundlephobia/minzip/subscript?label=size)](https://bundlephobia.com/package/subscript) [![microjs](https://img.shields.io/badge/µjs-subscript-darkslateblue)](http://microjs.com/#subscript) <!--[![demo](https://img.shields.io/badge/play-%F0%9F%9A%80-white)](https://dy.github.io/subscript/)-->
4
7
 
5
- * **Safe** — sandboxed, blocks `__proto__`, `constructor`, no global access
6
- * **Fast** — Pratt parser engine, see [benchmarks](#performance)
7
- * **Portable** — universal expression format, any compile target
8
- * **Metacircular** — can parse and compile itself
9
- * **Extensible** — pluggable syntax for building custom DSL
8
+ </div>
10
9
 
11
- ## Usage
12
10
 
13
11
  ```js
14
12
  import subscript from 'subscript'
@@ -17,24 +15,25 @@ let fn = subscript('a + b * 2')
17
15
  fn({ a: 1, b: 3 }) // 7
18
16
  ```
19
17
 
20
- ## Presets
18
+ * **Safe** — sandboxed, blocks `__proto__`, `constructor`, no global access
19
+ * **Fast** — Pratt parser engine, see [benchmarks](#performance)
20
+ * **Portable** — universal expression format, see [spec](./spec.md)
21
+ * **Extensible** — pluggable syntax, see [DSL builder](https://dy.github.io/subscript/)
22
+ * **Metacircular** — can parse and compile itself
23
+
21
24
 
22
- ### subscript
25
+ ## Presets
23
26
 
24
- Common expressions:
27
+ **Subscript**: common expressions:
25
28
 
26
- `a.b a[b] a(b) + - * / % < > <= >= == != ! && || ~ & | ^ << >> ++ -- = += -= *= /=`
27
29
  ```js
28
30
  import subscript from 'subscript'
29
31
 
30
32
  subscript('a.b + c * 2')({ a: { b: 1 }, c: 3 }) // 7
31
33
  ```
32
34
 
33
- ### justin
35
+ **Justin**: JSON + expressions + templates + arrows:
34
36
 
35
- JSON + expressions + templates + arrows:
36
-
37
- `` 'str' 0x 0b === !== ** ?? >>> ?. ? : => ... [] {} ` // /**/ true false null ``
38
37
  ```js
39
38
  import justin from 'subscript/justin.js'
40
39
 
@@ -42,11 +41,8 @@ justin('{ x: a?.b ?? 0, y: [1, ...rest] }')({ a: null, rest: [2, 3] })
42
41
  // { x: 0, y: [1, 2, 3] }
43
42
  ```
44
43
 
45
- ### jessie
46
-
47
- JSON + expressions + statements, functions:
44
+ **Jessie**: JSON + expressions + statements, functions (JS subset):
48
45
 
49
- `if else for while do let const var function class return throw try catch switch import export /regex/`
50
46
  ```js
51
47
  import jessie from 'subscript/jessie.js'
52
48
 
@@ -60,24 +56,7 @@ let fn = jessie(`
60
56
  fn({}) // 120
61
57
  ```
62
58
 
63
- Jessie can parse and compile its own source.
64
-
65
-
66
- ## Parse / Compile
67
-
68
- Subscript exposes `parse` to build AST and `compile` to create evaluators.
69
-
70
- ```js
71
- import { parse, compile } from 'subscript'
72
-
73
- // parse expression
74
- let tree = parse('a.b + c - 1')
75
- tree // ['-', ['+', ['.', 'a', 'b'], 'c'], [,1]]
76
-
77
- // compile tree to evaluable function
78
- fn = compile(tree)
79
- fn({ a: {b: 1}, c: 2 }) // 2
80
- ```
59
+ See [docs](./docs.md#presets) for full description.
81
60
 
82
61
  ## Extension
83
62
 
@@ -102,7 +81,7 @@ See [docs.md](./docs.md) for full API.
102
81
 
103
82
  ## Syntax Tree
104
83
 
105
- Expressions parse to a minimal JSON-compatible AST:
84
+ Expressions parse to a minimal JSON-compatible syntax tree:
106
85
 
107
86
  ```js
108
87
  import { parse } from 'subscript'
@@ -111,14 +90,6 @@ parse('a + b * 2')
111
90
  // ['+', 'a', ['*', 'b', [, 2]]]
112
91
  ```
113
92
 
114
- AST has simplified lispy tree structure (inspired by [frisk](https://ghub.io/frisk) / [nisp](https://github.com/ysmood/nisp)), opposed to [ESTree](https://github.com/estree/estree):
115
-
116
- * not limited to particular language (JS), can be compiled to different targets;
117
- * reflects execution sequence, rather than code layout;
118
- * has minimal overhead, directly maps to operators;
119
- * simplifies manual evaluation and debugging;
120
- * has conventional form and one-liner docs:
121
-
122
93
  Three forms:
123
94
 
124
95
  ```js
@@ -164,7 +135,7 @@ codegen(['+', ['*', 'min', [,60]], [,'sec']])
164
135
 
165
136
  ### Bundle
166
137
 
167
- Create custom dialect as single file:
138
+ Bundle imports into a single file:
168
139
 
169
140
  ```js
170
141
  import { bundle } from 'subscript/util/bundle.js'
@@ -181,11 +152,11 @@ const code = await bundle('subscript/jessie.js')
181
152
  <!-- * [glsl-transpiler](https://github.com/stackgl/glsl-transpiler) -->
182
153
  <!-- * [piezo](https://github.com/dy/piezo) -->
183
154
 
184
-
155
+ <!--
185
156
  ## Refs
186
157
 
187
158
  [jsep](https://github.com/EricSmekens/jsep), [jexl](https://github.com/TomFrost/Jexl), [expr-eval](https://github.com/silentmatt/expr-eval), [math.js](https://mathjs.org/).
188
159
 
189
- <!-- [mozjexl](https://github.com/mozilla/mozjexl), [jexpr](https://github.com/justinfagnani/jexpr), [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), [nx-compile](https://github.com/nx-js/compiler-util), [built-in-math-eval](https://github.com/mauriciopoppe/built-in-math-eval) -->
160
+ [mozjexl](https://github.com/mozilla/mozjexl), [jexpr](https://github.com/justinfagnani/jexpr), [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), [nx-compile](https://github.com/nx-js/compiler-util), [built-in-math-eval](https://github.com/mauriciopoppe/built-in-math-eval) -->
190
161
 
191
162
  <p align=center><a href="https://github.com/krsnzd/license/">ॐ</a></p>
package/feature/access.js CHANGED
@@ -42,7 +42,8 @@ operator('()', (a, b) => {
42
42
  const args = !b ? () => [] :
43
43
  b[0] === ',' ? (b = b.slice(1).map(compile), ctx => b.map(arg => arg(ctx))) :
44
44
  (b = compile(b), ctx => [b(ctx)]);
45
- return prop(a, (obj, path, ctx) => obj[path](...args(ctx)), true);
45
+ // Inline call handling for x(), a.b(), a[b](), (x)()
46
+ return call(a, (obj, path, ctx) => obj[path](...args(ctx)));
46
47
  });
47
48
 
48
49
  // Left-value check (valid assignment target)
@@ -55,13 +56,10 @@ export const isLval = n =>
55
56
  n[0] === '{}'
56
57
  ));
57
58
 
58
- // Compile error helper
59
- const compileErr = msg => { throw Error(msg) };
60
-
61
- // Property accessor helper - compiles property access pattern to evaluator
62
- export const prop = (a, fn, generic, obj, path) => (
63
- a == null ? compileErr('Empty ()') :
64
- a[0] === '()' && a.length == 2 ? prop(a[1], fn, generic) :
59
+ // Simple call helper (no optional chaining) - handles x(), a.b(), a[b](), (x)()
60
+ const call = (a, fn, obj, path) => (
61
+ a == null ? err('Empty ()') :
62
+ a[0] === '()' && a.length == 2 ? call(a[1], fn) :
65
63
  typeof a === 'string' ? ctx => fn(ctx, a, ctx) :
66
64
  a[0] === '.' ? (obj = compile(a[1]), path = a[2], ctx => fn(obj(ctx), path, ctx)) :
67
65
  a[0] === '?.' ? (obj = compile(a[1]), path = a[2], ctx => { const o = obj(ctx); return o == null ? undefined : fn(o, path, ctx); }) :
@@ -69,3 +67,6 @@ export const prop = (a, fn, generic, obj, path) => (
69
67
  a[0] === '?.[]' ? (obj = compile(a[1]), path = compile(a[2]), ctx => { const o = obj(ctx); return o == null ? undefined : fn(o, path(ctx), ctx); }) :
70
68
  (a = compile(a), ctx => fn([a(ctx)], 0, ctx))
71
69
  );
70
+
71
+ // Export as prop for backward compatibility with other features
72
+ export const prop = call;
package/feature/block.js CHANGED
@@ -35,7 +35,4 @@ export const block = () =>
35
35
 
36
36
  // body() - parse { body } or single statement
37
37
  export const body = () =>
38
- space() !== OBRACE ? expr(STATEMENT + .5) : (skip(), ['block', expr(STATEMENT - .5, CBRACE) || null]);
39
-
40
- // Compile
41
- operator('block', body => body === undefined ? () => {} : (body = compile(body), ctx => body(ctx)));
38
+ space() !== OBRACE ? expr(STATEMENT + .5) : (skip(), expr(STATEMENT - .5, CBRACE) || null);
@@ -0,0 +1,2 @@
1
+ // Control flow symbols (shared by loop, group, switch, try, function)
2
+ export const BREAK = Symbol('break'), CONTINUE = Symbol('continue'), RETURN = Symbol('return');
@@ -1,6 +1,6 @@
1
1
  // Function declarations and expressions
2
2
  import { space, next, parse, parens, expr, operator, compile } from '../parse.js';
3
- import { RETURN } from './loop.js';
3
+ import { RETURN } from './control.js';
4
4
  import { keyword, block } from './block.js';
5
5
 
6
6
  const TOKEN = 200;
package/feature/group.js CHANGED
@@ -1,6 +1,4 @@
1
1
  import { nary, group, operator, compile } from '../parse.js';
2
- import { BREAK, CONTINUE } from './loop.js';
3
- import { prop } from './access.js';
4
2
 
5
3
  const STATEMENT = 5, SEQ = 10, ACCESS = 170;
6
4
 
@@ -11,31 +9,7 @@ group('()', ACCESS);
11
9
  nary(',', SEQ);
12
10
  nary(';', STATEMENT, true); // right-assoc to allow same-prec statements
13
11
 
14
- // Compile
15
- const err = msg => { throw Error(msg) };
16
- operator('()', (a, b) => {
17
- // Group: (expr) - no second argument means grouping, not call
18
- if (b === undefined) return a == null ? err('Empty ()') : compile(a);
19
- // Validate: no sparse arguments in calls
20
- const hasSparse = n => n?.[0] === ',' && n.slice(1).some(a => a == null || hasSparse(a));
21
- if (hasSparse(b)) err('Empty argument');
22
- const args = !b ? () => [] :
23
- b[0] === ',' ? (b = b.slice(1).map(compile), ctx => b.map(arg => arg(ctx))) :
24
- (b = compile(b), ctx => [b(ctx)]);
25
- return prop(a, (obj, path, ctx) => obj[path](...args(ctx)), true);
26
- });
27
-
28
- // sequence returns last evaluated value; catches BREAK/CONTINUE and attaches result
29
- const seq = (...args) => (args = args.map(compile), ctx => {
30
- let r;
31
- for (const arg of args) {
32
- try { r = arg(ctx); }
33
- catch (e) {
34
- if (e?.type === BREAK || e?.type === CONTINUE) { e.value = r; throw e; }
35
- throw e;
36
- }
37
- }
38
- return r;
39
- });
12
+ // Compile sequences - returns last evaluated value
13
+ const seq = (...args) => (args = args.map(compile), ctx => { let r; for (const a of args) r = a(ctx); return r; });
40
14
  operator(',', seq);
41
15
  operator(';', seq);
package/feature/loop.js CHANGED
@@ -2,9 +2,9 @@
2
2
  import { expr, skip, space, parse, word, parens, cur, idx, operator, compile } from '../parse.js';
3
3
  import { body, keyword } from './block.js';
4
4
  import { destructure } from './destruct.js';
5
+ import { BREAK, CONTINUE, RETURN } from './control.js';
5
6
 
6
- // Control flow symbols
7
- export const BREAK = Symbol('break'), CONTINUE = Symbol('continue'), RETURN = Symbol('return');
7
+ export { BREAK, CONTINUE, RETURN };
8
8
 
9
9
  // Loop body executor - catches control flow and returns status
10
10
  export const loop = (body, ctx) => {
@@ -8,40 +8,19 @@ import { binary, operator, compile } from '../../parse.js';
8
8
 
9
9
  const ASSIGN = 20;
10
10
 
11
- // Base assignment
12
- binary('=', ASSIGN, true);
13
-
14
- // Compound arithmetic
15
- binary('+=', ASSIGN, true);
16
- binary('-=', ASSIGN, true);
17
- binary('*=', ASSIGN, true);
18
- binary('/=', ASSIGN, true);
19
- binary('%=', ASSIGN, true);
20
-
21
- // Compound bitwise
22
- binary('|=', ASSIGN, true);
23
- binary('&=', ASSIGN, true);
24
- binary('^=', ASSIGN, true);
25
- binary('>>=', ASSIGN, true);
26
- binary('<<=', ASSIGN, true);
11
+ // Register all assignment operators
12
+ '= += -= *= /= %= |= &= ^= >>= <<='.split(' ').map(op => binary(op, ASSIGN, true));
27
13
 
28
14
  // Simple assign helper for x, a.b, a[b], (x)
29
15
  const assign = (a, fn, obj, key) =>
30
16
  typeof a === 'string' ? ctx => fn(ctx, a, ctx) :
31
17
  a[0] === '.' ? (obj = compile(a[1]), key = a[2], ctx => fn(obj(ctx), key, ctx)) :
32
18
  a[0] === '[]' && a.length === 3 ? (obj = compile(a[1]), key = compile(a[2]), ctx => fn(obj(ctx), key(ctx), ctx)) :
33
- a[0] === '()' && a.length === 2 ? assign(a[1], fn) : // unwrap parens: (x) = 1
19
+ a[0] === '()' && a.length === 2 ? assign(a[1], fn) :
34
20
  (() => { throw Error('Invalid assignment target') })();
35
21
 
36
- // Compile
37
- operator('=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] = b(ctx))));
38
- operator('+=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] += b(ctx))));
39
- operator('-=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] -= b(ctx))));
40
- operator('*=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] *= b(ctx))));
41
- operator('/=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] /= b(ctx))));
42
- operator('%=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] %= b(ctx))));
43
- operator('|=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] |= b(ctx))));
44
- operator('&=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] &= b(ctx))));
45
- operator('^=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] ^= b(ctx))));
46
- operator('>>=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] >>= b(ctx))));
47
- operator('<<=', (a, b) => (b = compile(b), assign(a, (o, k, ctx) => o[k] <<= b(ctx))));
22
+ // Compile - use Function to generate operator implementations
23
+ const ops = { '=': (o,k,v)=>o[k]=v, '+=': (o,k,v)=>o[k]+=v, '-=': (o,k,v)=>o[k]-=v, '*=': (o,k,v)=>o[k]*=v,
24
+ '/=': (o,k,v)=>o[k]/=v, '%=': (o,k,v)=>o[k]%=v, '|=': (o,k,v)=>o[k]|=v, '&=': (o,k,v)=>o[k]&=v,
25
+ '^=': (o,k,v)=>o[k]^=v, '>>=': (o,k,v)=>o[k]>>=v, '<<=': (o,k,v)=>o[k]<<=v };
26
+ for (const op in ops) operator(op, (a, b) => (b = compile(b), assign(a, (o, k, ctx) => ops[op](o, k, b(ctx)))));
package/feature/switch.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // AST: ['switch', val, [';', ['case', test], stmts..., ['default'], stmts...]]
3
3
  import { expr, skip, space, parens, operator, compile } from '../parse.js';
4
4
  import { keyword, block } from './block.js';
5
- import { BREAK } from './loop.js';
5
+ import { BREAK } from './control.js';
6
6
 
7
7
  const STATEMENT = 5, ASSIGN = 20, COLON = 58;
8
8
 
package/feature/try.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // AST: ['catch', ['try', body], param, catchBody] or ['finally', inner, body]
3
3
  import { space, parse, parens, expr, operator, compile } from '../parse.js';
4
4
  import { keyword, infix, block } from './block.js';
5
- import { BREAK, CONTINUE, RETURN } from './loop.js';
5
+ import { BREAK, CONTINUE, RETURN } from './control.js';
6
6
 
7
7
  const STATEMENT = 5;
8
8
 
package/jessie.min.js CHANGED
@@ -1,8 +1,8 @@
1
- var l,d,c=r=>(l=0,d=r,c.newline=!1,r=A(),d[l]?I():r||""),I=(r="Unexpected token",e=l,t=d.slice(0,e).split(`
2
- `),o=t.pop(),n=d.slice(Math.max(0,e-40),e),s="\u032D",u=(d[e]||"\u2205")+s,f=d.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
- ${(d[e-41]!==`
4
- `?"...":"")+n}${u}${f}`)},Z=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),k=(r,e=l,t)=>{for(;t=r(d.charCodeAt(l));)l+=t;return d.slice(e,l)},E=(r=1)=>d[l+=r],K=r=>l=r,A=(r=0,e)=>{let t,o,n,s,u=c.reserved,f;for(e&&c.asi&&(c.newline=!1),c.reserved=0;(t=c.space())&&(f=c.newline,1)&&t!==e&&(n=((s=C[t])&&s(o,r))??(c.asi&&o&&f&&(n=c.asi(o,r,A)))??(!o&&!c.reserved&&k(c.id)));)o=n,c.reserved=0;return c.reserved=u,e&&(t==e?l++:I("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},h=c.space=(r,e=l)=>{for(;(r=d.charCodeAt(l))<=32;)c.asi&&r===10&&(c.newline=!0),l++;return r},dt=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,D=(r,e=r.length)=>d.substr(l,e)===r&&!c.id(d.charCodeAt(l+e)),N=()=>(E(),A(0,41)),C=[],S=(r,e=32,t,o=r.charCodeAt(0),n=r.length,s=C[o],u=r.toUpperCase()!==r,f,y)=>C[o]=(g,T,X,w=l)=>(f=X,(X?r==X:(n<2||r.charCodeAt(1)===d.charCodeAt(l+1)&&(n<3||d.substr(l,n)==r))&&(!u||!c.id(d.charCodeAt(l+n)))&&(f=X=r))&&T<e&&(l+=n,(y=t(g))?Z(y,w):(l=w,f=0,u&&y!==!1&&(c.reserved=1),!u&&!s&&I()),y)||s?.(g,T,f)),m=(r,e,t=!1)=>S(r,e,(o,n)=>o&&(n=A(e-(t?.5:0)))&&[r,o,n]),v=(r,e,t)=>S(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),L=(r,e)=>S(r,200,t=>!t&&[,e]),pr=(r,e,t)=>{S(r,e,(o,n)=>(n=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),n?.[0]===r?o.push(...n.slice(1)):o.push(n||null),o))},z=(r,e)=>S(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),ur=(r,e)=>S(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),Tr,re=(r="Compile error",e=Tr)=>I(r,e?.loc),sr={},p=(r,e,t=sr[r])=>sr[r]=(...o)=>e(...o)||t?.(...o),i=r=>(Tr=r,Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):sr[r[0]]?.(...r.slice(1))??re(`Unknown operator: ${r[0]}`):r===void 0?()=>{}:e=>e?.[r]);var q=46,J=48,x=57,ee=69,te=101,oe=43,ne=45,ie=97,se=102,pe=65,ue=70,fr=r=>[,(r=+k(e=>e===q&&d.charCodeAt(l+1)!==q||e>=J&&e<=x||((e===ee||e===te)&&((e=d.charCodeAt(l+1))>=J&&e<=x||e===oe||e===ne)?2:0)))!=r?I():r],fe={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=J&&r<=x||r>=ie&&r<=se||r>=pe&&r<=ue};c.number=null;C[q]=r=>!r&&d.charCodeAt(l+1)!==q&&fr();for(let r=J;r<=x;r++)C[r]=e=>e?void 0:fr();C[J]=r=>{if(r)return;let e=c.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&d[l+1]?.toLowerCase()===t[1])return E(2),[,parseInt(k(fe[o]),o)]}return fr()};var le=92,Ir=34,Nr=39,me={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Rr=r=>(e,t,o="")=>{if(!(e||!c.string?.[String.fromCharCode(r)]))return E(),k(n=>n-r&&(n===le?(o+=me[d[l+1]]||d[l+1],2):(o+=d[l],1))),d[l]===String.fromCharCode(r)?E():I("Bad string"),[,o]};C[Ir]=Rr(Ir);C[Nr]=Rr(Nr);c.string={'"':!0};var P=20;m("=",P,!0);m("+=",P,!0);m("-=",P,!0);m("*=",P,!0);m("/=",P,!0);m("%=",P,!0);m("|=",P,!0);m("&=",P,!0);m("^=",P,!0);m(">>=",P,!0);m("<<=",P,!0);var _=(r,e,t,o)=>typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="()"&&r.length===2?_(r[1],e):(()=>{throw Error("Invalid assignment target")})();p("=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]=e(n))));p("+=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]+=e(n))));p("-=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]-=e(n))));p("*=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]*=e(n))));p("/=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]/=e(n))));p("%=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]%=e(n))));p("|=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]|=e(n))));p("&=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]&=e(n))));p("^=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]^=e(n))));p(">>=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]>>=e(n))));p("<<=",(r,e)=>(e=i(e),_(r,(t,o,n)=>t[o]<<=e(n))));var ce=30,de=40,_r=140;m("!",_r);v("!",_r);m("||",ce);m("&&",de);p("!",r=>(r=i(r),e=>!r(e)));p("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));p("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var Ae=50,he=60,ye=70,Or=100,Ee=140;m("|",Ae);m("&",ye);m("^",he);m(">>",Or);m("<<",Or);v("~",Ee);p("~",r=>(r=i(r),e=>~r(e)));p("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));p("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));p("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));p(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));p("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var b=90;m("<",b);m(">",b);m("<=",b);m(">=",b);p(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));p("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));p(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));p("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var Pr=80;m("==",Pr);m("!=",Pr);p("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));p("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var Mr=110,lr=120,Ur=140;m("+",Mr);m("-",Mr);m("*",lr);m("/",lr);m("%",lr);v("+",Ur);v("-",Ur);p("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));p("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));p("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));p("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));p("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var rr=150;S("++",rr,r=>r?["++",r,null]:["++",A(rr-1)]);S("--",rr,r=>r?["--",r,null]:["--",A(rr-1)]);var mr=(r,e,t,o)=>typeof r=="string"?n=>e(n,r):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n))):r[0]==="()"&&r.length===2?mr(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>mr(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));p("--",(r,e)=>mr(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var cr=5,Lr=123,Fr=125,a=(r,e,t,o=r.charCodeAt(0),n=r.length,s=C[o],u)=>C[o]=(f,y,g,T=l)=>!f&&(g?r==g:(n<2||d.substr(l,n)==r)&&(g=r))&&y<e&&!c.id(d.charCodeAt(l+n))&&(K(l+n),(u=t())?Z(u,T):(K(T),!s&&I()),u)||s?.(f,y,g),dr=(r,e,t,o=r.charCodeAt(0),n=r.length,s=C[o],u)=>C[o]=(f,y,g,T=l)=>f&&(g?r==g:(n<2||d.substr(l,n)==r)&&(g=r))&&y<e&&!c.id(d.charCodeAt(l+n))&&(K(l+n),Z(u=t(f),T),u)||s?.(f,y,g),M=()=>(h()===Lr||I("Expected {"),E(),A(cr-.5,Fr)||null),B=()=>h()!==Lr?A(cr+.5):(E(),["block",A(cr-.5,Fr)||null]);p("block",r=>r===void 0?()=>{}:(r=i(r),e=>r(e)));var F=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r;if(o==="{}")for(let s of n){let u,f,y;s[0]==="="?[,[,u,f],y]=s:[,u,f]=s;let g=e[u];g===void 0&&y&&(g=i(y)(t)),F(f,g,t)}else if(o==="[]"){let s=0;for(let u of n){if(u===null){s++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(s);break}let f=u,y;Array.isArray(u)&&u[0]==="="&&([,f,y]=u);let g=e[s++];g===void 0&&y&&(g=i(y)(t)),F(f,g,t)}}};var Q=Symbol("break"),j=Symbol("continue"),W=Symbol("return"),V=(r,e)=>{try{return{v:r(e)}}catch(t){if(t?.type===Q)return{b:1};if(t?.type===j)return{c:1};if(t?.type===W)return{r:1,v:t.value};throw t}},$=5,ge=125,ae=59;a("while",$+1,()=>(h(),["while",N(),B()]));a("do",$+1,()=>(r=>(h(),E(5),h(),["do",r,N()]))(B()));a("for",$+1,()=>(h(),D("await")?(E(5),h(),["for await",N(),B()]):["for",N(),B()]));a("break",$+1,()=>["break"]);a("continue",$+1,()=>["continue"]);a("return",$+1,()=>{c.asi&&(c.newline=!1),h();let r=d.charCodeAt(l);return!r||r===ge||r===ae||c.newline?["return"]:["return",A($)]});p("while",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;for(;r(t)&&!(o=V(e,t)).b;){if(o.r)return o.v;o.c||(n=o.v)}return n}));p("do",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;do{if((o=V(r,t)).b)break;if(o.r)return o.v;o.c||(n=o.v)}while(e(t));return n}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,o,n]=r;return t=t?i(t):null,o=o?i(o):()=>!0,n=n?i(n):null,e=i(e),s=>{let u,f;for(t?.(s);o(s)&&!(u=V(e,s)).b;n?.(s)){if(u.r)return u.v;u.c||(f=u.v)}return f}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,o,n]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),t==="in")return we(o,n,e);if(t==="of")return Se(o,n,e)}});var Se=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,u,f=o?null:n[r];for(let y of e(n)){if(o?F(r,y,n):n[r]=y,(s=V(t,n)).b)break;if(s.r)return s.v;s.c||(u=s.v)}return o||(n[r]=f),u}},we=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,u,f=o?null:n[r];for(let y in e(n)){if(o?F(r,y,n):n[r]=y,(s=V(t,n)).b)break;if(s.r)return s.v;s.c||(u=s.v)}return o||(n[r]=f),u}};p("break",()=>()=>{throw{type:Q}});p("continue",()=>()=>{throw{type:j}});p("return",r=>(r=r!==void 0?i(r):null,e=>{throw{type:W,value:r?.(e)}}));var G=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",hr=170;ur("[]",hr);m(".",hr);ur("()",hr);var Ar=r=>{throw Error(r)};p("[]",(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]),o=>t(o)):(t=i(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&Ar("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return G(o)?void 0:r(t)[o]}));p(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],G(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?Ar("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&Ar("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return R(r,(n,s,u)=>n[s](...o(u)),!0)});var U=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&U(r[1])||r[0]==="{}"),Ce=r=>{throw Error(r)},R=(r,e,t,o,n)=>r==null?Ce("Empty ()"):r[0]==="()"&&r.length==2?R(r[1],e,t):typeof r=="string"?s=>e(s,r,s):r[0]==="."?(o=i(r[1]),n=r[2],s=>e(o(s),n,s)):r[0]==="?."?(o=i(r[1]),n=r[2],s=>{let u=o(s);return u==null?void 0:e(u,n,s)}):r[0]==="[]"&&r.length===3?(o=i(r[1]),n=i(r[2]),s=>e(o(s),n(s),s)):r[0]==="?.[]"?(o=i(r[1]),n=i(r[2]),s=>{let u=o(s);return u==null?void 0:e(u,n(s),s)}):(r=i(r),s=>e([r(s)],0,s));var ke=5,ve=10,Te=170;z("()",Te);pr(",",ve);pr(";",ke,!0);var Gr=r=>{throw Error(r)};p("()",(r,e)=>{if(e===void 0)return r==null?Gr("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&Gr("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return R(r,(n,s,u)=>n[s](...o(u)),!0)});var Xr=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)try{t=o(e)}catch(n){throw(n?.type===Q||n?.type===j)&&(n.value=t),n}return t});p(",",Xr);p(";",Xr);var Kr=new WeakMap,Ie=(r,...e)=>typeof r=="string"?i(c(r)):Kr.get(r)||Kr.set(r,Ne(r,e)).get(r),Dr=57344,Ne=(r,e)=>{let t=r.reduce((s,u,f)=>s+(f?String.fromCharCode(Dr+f-1):"")+u,""),o=c(t),n=s=>{if(typeof s=="string"&&s.length===1){let u=s.charCodeAt(0)-Dr,f;if(u>=0&&u<e.length)return f=e[u],Re(f)?f:[,f]}return Array.isArray(s)?s.map(n):s};return i(n(o))},Re=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Br=Ie;var _e=32,Oe=c.space;c.comment??={"//":`
6
- `,"/*":"*/"};var yr;c.space=()=>{yr||(yr=Object.entries(c.comment).map(([n,s])=>[n,s,n.charCodeAt(0)]));for(var r;r=Oe();){for(var e=0,t;t=yr[e++];)if(r===t[2]&&d.substr(l,t[0].length)===t[0]){var o=l+t[0].length;if(t[1]===`
7
- `)for(;d.charCodeAt(o)>=_e;)o++;else{for(;d[o]&&d.substr(o,t[1].length)!==t[1];)o++;d[o]&&(o+=t[1].length)}K(o),r=0;break}if(r)return r}return r};var Qr=80;m("===",Qr);m("!==",Qr);p("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));p("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));var Pe=30;m("??",Pe);p("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var Me=130,Ue=20;m("**",Me,!0);m("**=",Ue,!0);p("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));var Le=r=>{throw Error(r)};p("**=",(r,e)=>(U(r)||Le("Invalid assignment target"),e=i(e),R(r,(t,o,n)=>t[o]**=e(n))));var $r=90;m("in",$r);m("of",$r);p("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var Fe=20,Ge=100,Xe=r=>{throw Error(r)};m(">>>",Ge);m(">>>=",Fe,!0);p(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(U(r)||Xe("Invalid assignment target"),e=i(e),R(r,(t,o,n)=>t[o]>>>=e(n))));var Er=20,er=r=>{throw Error(r)};m("||=",Er,!0);m("&&=",Er,!0);m("??=",Er,!0);p("=",(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"?o=>{o[t]=e(o)}:o=>F(t,e(o),o)}return U(r)||er("Invalid assignment target"),e=i(e),R(r,(t,o,n)=>t[o]=e(n))});p("||=",(r,e)=>(U(r)||er("Invalid assignment target"),e=i(e),R(r,(t,o,n)=>t[o]||=e(n))));p("&&=",(r,e)=>(U(r)||er("Invalid assignment target"),e=i(e),R(r,(t,o,n)=>t[o]&&=e(n))));p("??=",(r,e)=>(U(r)||er("Invalid assignment target"),e=i(e),R(r,(t,o,n)=>t[o]??=e(n))));L("true",!0);L("false",!1);L("null",null);L("undefined",void 0);L("NaN",NaN);L("Infinity",1/0);var gr=20;S("?",gr,(r,e,t)=>r&&(e=A(gr-1))&&k(o=>o===58)&&(t=A(gr-1),["?",r,e,t]));p("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var Ke=20;m("=>",Ke,!0);p("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=i(e[0]==="{}"?e[1]:e),(n=null)=>(n=Object.create(n),(...s)=>(r.forEach((u,f)=>n[u]=s[f]),o&&(n[o]=s.slice(t)),e(n)))});var De=140;v("...",De);p("...",r=>(r=i(r),e=>Object.entries(r(e))));var Hr=170;S("?.",Hr,(r,e)=>{if(!r)return;let t=h();return t===40?(E(),["?.()",r,A(0,41)||null]):t===91?(E(),["?.[]",r,A(0,93)]):(e=A(Hr),e?["?.",r,e]:void 0)});p("?.",(r,e)=>(r=i(r),G(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return G(o)?void 0:r(t)?.[o]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="?."){let n=i(r[1]),s=r[2];return G(s)?()=>{}:u=>n(u)?.[s]?.(...t(u))}if(r[0]==="?.[]"){let n=i(r[1]),s=i(r[2]);return u=>{let f=n(u),y=s(u);return G(y)?void 0:f?.[y]?.(...t(u))}}if(r[0]==="."){let n=i(r[1]),s=r[2];return G(s)?()=>{}:u=>n(u)?.[s]?.(...t(u))}if(r[0]==="[]"&&r.length===3){let n=i(r[1]),s=i(r[2]);return u=>{let f=n(u),y=s(u);return G(y)?void 0:f?.[y]?.(...t(u))}}let o=i(r);return n=>o(n)?.(...t(n))});var tr=140;v("typeof",tr);v("void",tr);v("delete",tr);v("new",tr);p("typeof",r=>(r=i(r),e=>typeof r(e)));p("void",r=>(r=i(r),e=>(r(e),void 0)));p("delete",r=>{if(r[0]==="."){let e=i(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=i(r[1]),t=i(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});p("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>s=>n.map(u=>u(s)))(t.slice(1).map(i)):(n=>s=>[n(s)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var or=Symbol("accessor"),jr=20,Be=40,Qe=41,$e=123,He=125,Wr=r=>e=>{if(e)return;h();let t=k(c.id);if(!t||(h(),d.charCodeAt(l)!==Be))return!1;E();let o=A(0,Qe);return h(),d.charCodeAt(l)!==$e?!1:(E(),[r,t,o,A(0,He)])};S("get",jr-1,Wr("get"));S("set",jr-1,Wr("set"));p("get",(r,e)=>(e=e?i(e):()=>{},t=>[[or,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));p("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[or,r,{set:function(n){let s=Object.create(o||{});s.this=this,s[e]=n,t(s)}}]]));var je=20,zr=200;z("[]",zr);z("{}",zr);m(":",je-1,!0);p("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>i(typeof o=="string"?[":",o,o]:o));return o=>{let n={},s={};for(let u of t.flatMap(f=>f(o)))if(u[0]===or){let[,f,y]=u;s[f]={...s[f],...y,configurable:!0,enumerable:!0}}else n[u[0]]=u[1];for(let u in s)Object.defineProperty(n,u,s[u]);return n}});p(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var We=170,nr=96,ze=36,Je=123,Ve=92,Ye={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Jr=()=>{let r=[];for(let e="",t;(t=d.charCodeAt(l))!==nr;)t?t===Ve?(E(),e+=Ye[d[l]]||d[l],E()):t===ze&&d.charCodeAt(l+1)===Je?(e&&r.push([,e]),e="",E(2),r.push(A(0,125))):(e+=d[l],E(),t=d.charCodeAt(l),t===nr&&e&&r.push([,e])):I("Unterminated template");return E(),r},Ze=C[nr];C[nr]=(r,e)=>r&&e<We?c.asi&&c.newline?void 0:(E(),["``",r,...Jr()]):r?Ze?.(r,e):(E(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Jr()));p("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):o.push(i(s));let n=Object.assign([...t],{raw:t});return s=>r(s)(n,...o.map(u=>u(s)))});c.string["'"]=!0;c.number={"0x":16,"0b":2,"0o":8};var ar=5,qe=10,xe=20,Vr=r=>{let e=A(qe-1);return e?.[0]==="in"||e?.[0]==="of"?[e[0],[r,e[1]],e[2]]:e?.[0]===","?[r,...e.slice(1)]:[r,e]};S("let",ar+1,r=>!r&&Vr("let"));S("const",ar+1,r=>!r&&Vr("const"));a("var",ar,()=>(h(),["var",A(xe)]));var Yr=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,o]=e,n=i(o);return typeof t=="string"?s=>{s[t]=n(s)}:s=>F(t,n(s),s)}return i(e)}),e=>{for(let t of r)t(e)});p("let",Yr);p("const",Yr);p("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var be=200;a("function",be,()=>{h();let r=k(c.id);return r&&h(),["function",r,N()||null,M()]});p("function",(r,e,t)=>{t=t?i(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],n=null,s=-1,u=o[o.length-1];return Array.isArray(u)&&u[0]==="..."&&(s=o.length-1,n=u[1],o.length--),f=>{let y=(...g)=>{let T={};o.forEach((w,O)=>T[w]=g[O]),n&&(T[n]=g.slice(s));let X=new Proxy(T,{get:(w,O)=>O in w?w[O]:f[O],set:(w,O,br)=>((O in w?w:f)[O]=br,!0),has:(w,O)=>O in w||O in f});try{return t(X)}catch(w){if(w?.type===W)return w.value;throw w}};return r&&(f[r]=y),y}});var ir=140,Sr=20;v("await",ir);a("yield",ir,()=>(h(),d[l]==="*"?(E(),h(),["yield*",A(Sr)]):["yield",A(Sr)]));a("async",ir,()=>{if(h(),D("function"))return["async",A(ir)];let r=A(Sr-.5);return r&&["async",r]});p("async",r=>{let e=i(r);return t=>{let o=e(t);return async function(...n){return o(...n)}}});p("await",r=>(r=i(r),async e=>await r(e)));p("yield",r=>(r=r?i(r):null,e=>{throw{__yield__:r?r(e):void 0}}));p("yield*",r=>(r=i(r),e=>{throw{__yield_all__:r(e)}}));var wr=200,rt=140,et=90,tt=Symbol("static");L("super",Symbol.for("super"));v("static",rt);m("instanceof",et);S("#",wr,r=>{if(r)return;let e=k(c.id);return e?"#"+e:void 0});a("class",wr,()=>{h();let r=k(c.id)||null;if(r==="extends")r=null;else if(h(),!D("extends"))return["class",r,null,M()];return h(),["class",r,A(wr),M()]});var ot=r=>{throw Error(r)};p("instanceof",(r,e)=>(r=i(r),e=i(e),t=>r(t)instanceof e(t)));p("class",(r,e,t)=>(e=e?i(e):null,t=t?i(t):null,o=>{let n=e?e(o):Object,s=function(...u){if(!(this instanceof s))return ot("Class constructor must be called with new");let f=e?Reflect.construct(n,u,s):this;return s.prototype.__constructor__&&s.prototype.__constructor__.apply(f,u),f};if(Object.setPrototypeOf(s.prototype,n.prototype),Object.setPrototypeOf(s,n),t){let u=Object.create(o);u.super=n;let f=t(u),y=Array.isArray(f)&&typeof f[0]?.[0]=="string"?f:[];for(let[g,T]of y)g==="constructor"?s.prototype.__constructor__=T:s.prototype[g]=T}return r&&(o[r]=s),s}));p("static",r=>(r=i(r),e=>[[tt,r(e)]]));var nt=140,Cr=47,it=92,st=r=>r===it?2:r&&r!==Cr,pt=r=>r===103||r===105||r===109||r===115||r===117||r===121;S("/",nt,r=>{if(r)return;let e=d.charCodeAt(l);if(e===Cr||e===42||e===43||e===63||e===61)return;let t=k(st);d.charCodeAt(l)===Cr||I("Unterminated regex"),E();try{return[,new RegExp(t,k(pt))]}catch(o){I("Invalid regex: "+o.message)}});var ut=5,ft=59,lt=()=>{let r=l;return h()===ft&&E(),h(),D("else")?(E(4),!0):(K(r),!1)};a("if",ut+1,()=>{h();let r=["if",N(),B()];return lt()&&r.push(B()),r});p("if",(r,e,t)=>(r=i(r),e=i(e),t=t!==void 0?i(t):null,o=>r(o)?e(o):t?.(o)));var Y=5;a("try",Y+1,()=>["try",M()]);dr("catch",Y+1,r=>(h(),["catch",r,N(),M()]));dr("finally",Y+1,r=>["finally",r,M()]);a("throw",Y+1,()=>{if(c.asi&&(c.newline=!1),h(),c.newline)throw SyntaxError("Unexpected newline after throw");return["throw",A(Y)]});p("try",r=>(r=r?i(r):null,e=>r?.(e)));p("catch",(r,e,t)=>{let o=r?.[1]?i(r[1]):null;return t=t?i(t):null,n=>{let s;try{s=o?.(n)}catch(u){if(u?.type===Q||u?.type===j||u?.type===W)throw u;if(e!==null&&t){let f=e in n,y=n[e];n[e]=u;try{s=t(n)}finally{f?n[e]=y:delete n[e]}}else if(e===null)throw u}return s}});p("finally",(r,e)=>(r=r?i(r):null,e=e?i(e):null,t=>{let o;try{o=r?.(t)}finally{e?.(t)}return o}));p("throw",r=>(r=i(r),e=>{throw r(e)}));var kr=5,mt=20,Zr=58;a("switch",kr+1,()=>(h(),["switch",N(),M()]));a("case",kr+1,()=>(h(),(r=>(h()===Zr&&E(),["case",r]))(A(mt))));a("default",kr+1,()=>(h()===Zr&&E(),["default"]));p("switch",(r,e)=>{if(r=i(r),!e)return s=>r(s);let t=[],o=e[0]===";"?e.slice(1):[e],n=null;for(let s of o)Array.isArray(s)&&(s[0]==="case"||s[0]==="default")?(n&&t.push(n),n=[s[0]==="case"?i(s[1]):null,[]]):n&&n[1].push(i(s));return n&&t.push(n),s=>{let u=r(s),f=!1,y;for(let[g,T]of t)if(f||g===null||g(s)===u){f=!0;for(let X of T)try{y=X(s)}catch(w){if(w?.type===Q)return w.value!==void 0?w.value:y;throw w}}return y}});var vr=5,H=10,qr=42,ct=C[qr];C[qr]=(r,e)=>r?ct?.(r,e):(E(),"*");S("from",H+1,r=>r?r[0]!=="="&&r[0]!==","&&(h(),["from",r,A(H+1)]):!1);S("as",H+2,r=>r?(h(),["as",r,A(H+2)]):!1);a("import",vr,()=>(h(),["import",A(H)]));a("export",vr,()=>(h(),["export",A(vr)]));a("default",H+1,()=>(h(),["default",A(H)]));p("import",()=>()=>{});p("export",()=>()=>{});p("from",(r,e)=>()=>{});p("as",(r,e)=>()=>{});p("default",r=>i(r));var xr=5;c.asi=(r,e,t)=>{if(e>=xr)return;let o=t(xr-.5);if(o)return r?.[0]!==";"?[";",r,o]:(r.push(o),r)};export{ur as access,m as binary,i as compile,d as cur,Br as default,I as err,A as expr,z as group,dt as id,l as idx,L as literal,Z as loc,C as lookup,pr as nary,k as next,p as operator,sr as operators,N as parens,c as parse,K as seek,E as skip,h as space,S as token,v as unary,D as word};
1
+ var u,c,m=r=>(u=0,c=r,m.newline=!1,r=A(),c[u]?I():r||""),I=(r="Unexpected token",e=u,t=c.slice(0,e).split(`
2
+ `),o=t.pop(),n=c.slice(Math.max(0,e-40),e),s="\u032D",f=(c[e]||"\u2205")+s,l=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
+ ${(c[e-41]!==`
4
+ `?"...":"")+n}${f}${l}`)},V=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),k=(r,e=u,t)=>{for(;t=r(c.charCodeAt(u));)u+=t;return c.slice(e,u)},g=(r=1)=>c[u+=r],G=r=>u=r,A=(r=0,e)=>{let t,o,n,s,f=m.reserved,l;for(e&&m.asi&&(m.newline=!1),m.reserved=0;(t=m.space())&&(l=m.newline,1)&&t!==e&&(n=((s=w[t])&&s(o,r))??(m.asi&&o&&l&&(n=m.asi(o,r,A)))??(!o&&!m.reserved&&k(m.id)));)o=n,m.reserved=0;return m.reserved=f,e&&(t==e?u++:I("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},y=m.space=(r,e=u)=>{for(;(r=c.charCodeAt(u))<=32;)m.asi&&r===10&&(m.newline=!0),u++;return r},mt=m.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,X=(r,e=r.length)=>c.substr(u,e)===r&&!m.id(c.charCodeAt(u+e)),N=()=>(g(),A(0,41)),w=[],S=(r,e=32,t,o=r.charCodeAt(0),n=r.length,s=w[o],f=r.toUpperCase()!==r,l,h)=>w[o]=(E,T,F,C=u)=>(l=F,(F?r==F:(n<2||r.charCodeAt(1)===c.charCodeAt(u+1)&&(n<3||c.substr(u,n)==r))&&(!f||!m.id(c.charCodeAt(u+n)))&&(l=F=r))&&T<e&&(u+=n,(h=t(E))?V(h,C):(u=C,l=0,f&&h!==!1&&(m.reserved=1),!f&&!s&&I()),h)||s?.(E,T,l)),d=(r,e,t=!1)=>S(r,e,(o,n)=>o&&(n=A(e-(t?.5:0)))&&[r,o,n]),v=(r,e,t)=>S(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),P=(r,e)=>S(r,200,t=>!t&&[,e]),sr=(r,e,t)=>{S(r,e,(o,n)=>(n=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),n?.[0]===r?o.push(...n.slice(1)):o.push(n||null),o))},H=(r,e)=>S(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),pr=(r,e)=>S(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),ir={},p=(r,e,t=ir[r])=>ir[r]=(...o)=>e(...o)||t?.(...o),i=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):ir[r[0]]?.(...r.slice(1))??I(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var Y=46,j=48,Z=57,br=69,re=101,ee=43,te=45,oe=97,ne=102,ie=65,se=70,fr=r=>[,(r=+k(e=>e===Y&&c.charCodeAt(u+1)!==Y||e>=j&&e<=Z||((e===br||e===re)&&((e=c.charCodeAt(u+1))>=j&&e<=Z||e===ee||e===te)?2:0)))!=r?I():r],pe={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=j&&r<=Z||r>=oe&&r<=ne||r>=ie&&r<=se};m.number=null;w[Y]=r=>!r&&c.charCodeAt(u+1)!==Y&&fr();for(let r=j;r<=Z;r++)w[r]=e=>e?void 0:fr();w[j]=r=>{if(r)return;let e=m.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[u+1]?.toLowerCase()===t[1])return g(2),[,parseInt(k(pe[o]),o)]}return fr()};var fe=92,vr=34,Tr=39,le={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ir=r=>(e,t,o="")=>{if(!(e||!m.string?.[String.fromCharCode(r)]))return g(),k(n=>n-r&&(n===fe?(o+=le[c[u+1]]||c[u+1],2):(o+=c[u],1))),c[u]===String.fromCharCode(r)?g():I("Bad string"),[,o]};w[vr]=Ir(vr);w[Tr]=Ir(Tr);m.string={'"':!0};var ue=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>d(r,ue,!0));var Rr=(r,e,t,o)=>typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="()"&&r.length===2?Rr(r[1],e):(()=>{throw Error("Invalid assignment target")})(),Nr={"=":(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 Nr)p(r,(e,t)=>(t=i(t),Rr(e,(o,n,s)=>Nr[r](o,n,t(s)))));var me=30,ce=40,_r=140;d("!",_r);v("!",_r);d("||",me);d("&&",ce);p("!",r=>(r=i(r),e=>!r(e)));p("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));p("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var de=50,Ae=60,ye=70,Or=100,he=140;d("|",de);d("&",ye);d("^",Ae);d(">>",Or);d("<<",Or);v("~",he);p("~",r=>(r=i(r),e=>~r(e)));p("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));p("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));p("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));p(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));p("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var q=90;d("<",q);d(">",q);d("<=",q);d(">=",q);p(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));p("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));p(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));p("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var Pr=80;d("==",Pr);d("!=",Pr);p("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));p("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var Mr=110,lr=120,Ur=140;d("+",Mr);d("-",Mr);d("*",lr);d("/",lr);d("%",lr);v("+",Ur);v("-",Ur);p("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));p("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));p("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));p("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));p("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var x=150;S("++",x,r=>r?["++",r,null]:["++",A(x-1)]);S("--",x,r=>r?["--",r,null]:["--",A(x-1)]);var ur=(r,e,t,o)=>typeof r=="string"?n=>e(n,r):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n))):r[0]==="()"&&r.length===2?ur(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>ur(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));p("--",(r,e)=>ur(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var ge=5,Ee=10,ae=170;H("()",ae);sr(",",Ee);sr(";",ge,!0);var Lr=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)t=o(e);return t});p(",",Lr);p(";",Lr);var M=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",mr=170;pr("[]",mr);d(".",mr);pr("()",mr);var b=r=>{throw Error(r)};p("[]",(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]),o=>t(o)):(t=i(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&b("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return M(o)?void 0:r(t)[o]}));p(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],M(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?b("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&b("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return cr(r,(n,s,f)=>n[s](...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]==="{}"),cr=(r,e,t,o)=>r==null?b("Empty ()"):r[0]==="()"&&r.length==2?cr(r[1],e):typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="?."?(t=i(r[1]),o=r[2],n=>{let s=t(n);return s==null?void 0:e(s,o,n)}):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="?.[]"?(t=i(r[1]),o=i(r[2]),n=>{let s=t(n);return s==null?void 0:e(s,o(n),n)}):(r=i(r),n=>e([r(n)],0,n)),U=cr;var Fr=new WeakMap,Se=(r,...e)=>typeof r=="string"?i(m(r)):Fr.get(r)||Fr.set(r,Ce(r,e)).get(r),Gr=57344,Ce=(r,e)=>{let t=r.reduce((s,f,l)=>s+(l?String.fromCharCode(Gr+l-1):"")+f,""),o=m(t),n=s=>{if(typeof s=="string"&&s.length===1){let f=s.charCodeAt(0)-Gr,l;if(f>=0&&f<e.length)return l=e[f],we(l)?l:[,l]}return Array.isArray(s)?s.map(n):s};return i(n(o))},we=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Xr=Se;var ke=32,ve=m.space;m.comment??={"//":`
6
+ `,"/*":"*/"};var dr;m.space=()=>{dr||(dr=Object.entries(m.comment).map(([n,s])=>[n,s,n.charCodeAt(0)]));for(var r;r=ve();){for(var e=0,t;t=dr[e++];)if(r===t[2]&&c.substr(u,t[0].length)===t[0]){var o=u+t[0].length;if(t[1]===`
7
+ `)for(;c.charCodeAt(o)>=ke;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}G(o),r=0;break}if(r)return r}return r};var Kr=80;d("===",Kr);d("!==",Kr);p("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));p("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));var Te=30;d("??",Te);p("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var Ie=130,Ne=20;d("**",Ie,!0);d("**=",Ne,!0);p("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));var Re=r=>{throw Error(r)};p("**=",(r,e)=>(O(r)||Re("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]**=e(n))));var Dr=90;d("in",Dr);d("of",Dr);p("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var _e=20,Oe=100,Pe=r=>{throw Error(r)};d(">>>",Oe);d(">>>=",_e,!0);p(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(O(r)||Pe("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]>>>=e(n))));var L=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r;if(o==="{}")for(let s of n){let f,l,h;s[0]==="="?[,[,f,l],h]=s:[,f,l]=s;let E=e[f];E===void 0&&h&&(E=i(h)(t)),L(l,E,t)}else if(o==="[]"){let s=0;for(let f of n){if(f===null){s++;continue}if(Array.isArray(f)&&f[0]==="..."){t[f[1]]=e.slice(s);break}let l=f,h;Array.isArray(f)&&f[0]==="="&&([,l,h]=f);let E=e[s++];E===void 0&&h&&(E=i(h)(t)),L(l,E,t)}}};var Ar=20,rr=r=>{throw Error(r)};d("||=",Ar,!0);d("&&=",Ar,!0);d("??=",Ar,!0);p("=",(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"?o=>{o[t]=e(o)}:o=>L(t,e(o),o)}return O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]=e(n))});p("||=",(r,e)=>(O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]||=e(n))));p("&&=",(r,e)=>(O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]&&=e(n))));p("??=",(r,e)=>(O(r)||rr("Invalid assignment target"),e=i(e),U(r,(t,o,n)=>t[o]??=e(n))));P("true",!0);P("false",!1);P("null",null);P("undefined",void 0);P("NaN",NaN);P("Infinity",1/0);var yr=20;S("?",yr,(r,e,t)=>r&&(e=A(yr-1))&&k(o=>o===58)&&(t=A(yr-1),["?",r,e,t]));p("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var Me=20;d("=>",Me,!0);p("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=i(e[0]==="{}"?e[1]:e),(n=null)=>(n=Object.create(n),(...s)=>(r.forEach((f,l)=>n[f]=s[l]),o&&(n[o]=s.slice(t)),e(n)))});var Ue=140;v("...",Ue);p("...",r=>(r=i(r),e=>Object.entries(r(e))));var Br=170;S("?.",Br,(r,e)=>{if(!r)return;let t=y();return t===40?(g(),["?.()",r,A(0,41)||null]):t===91?(g(),["?.[]",r,A(0,93)]):(e=A(Br),e?["?.",r,e]:void 0)});p("?.",(r,e)=>(r=i(r),M(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return M(o)?void 0:r(t)?.[o]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="?."){let n=i(r[1]),s=r[2];return M(s)?()=>{}:f=>n(f)?.[s]?.(...t(f))}if(r[0]==="?.[]"){let n=i(r[1]),s=i(r[2]);return f=>{let l=n(f),h=s(f);return M(h)?void 0:l?.[h]?.(...t(f))}}if(r[0]==="."){let n=i(r[1]),s=r[2];return M(s)?()=>{}:f=>n(f)?.[s]?.(...t(f))}if(r[0]==="[]"&&r.length===3){let n=i(r[1]),s=i(r[2]);return f=>{let l=n(f),h=s(f);return M(h)?void 0:l?.[h]?.(...t(f))}}let o=i(r);return n=>o(n)?.(...t(n))});var er=140;v("typeof",er);v("void",er);v("delete",er);v("new",er);p("typeof",r=>(r=i(r),e=>typeof r(e)));p("void",r=>(r=i(r),e=>(r(e),void 0)));p("delete",r=>{if(r[0]==="."){let e=i(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=i(r[1]),t=i(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});p("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>s=>n.map(f=>f(s)))(t.slice(1).map(i)):(n=>s=>[n(s)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var tr=Symbol("accessor"),Qr=20,Le=40,Fe=41,Ge=123,Xe=125,$r=r=>e=>{if(e)return;y();let t=k(m.id);if(!t||(y(),c.charCodeAt(u)!==Le))return!1;g();let o=A(0,Fe);return y(),c.charCodeAt(u)!==Ge?!1:(g(),[r,t,o,A(0,Xe)])};S("get",Qr-1,$r("get"));S("set",Qr-1,$r("set"));p("get",(r,e)=>(e=e?i(e):()=>{},t=>[[tr,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));p("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[tr,r,{set:function(n){let s=Object.create(o||{});s.this=this,s[e]=n,t(s)}}]]));var Ke=20,Hr=200;H("[]",Hr);H("{}",Hr);d(":",Ke-1,!0);p("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>i(typeof o=="string"?[":",o,o]:o));return o=>{let n={},s={};for(let f of t.flatMap(l=>l(o)))if(f[0]===tr){let[,l,h]=f;s[l]={...s[l],...h,configurable:!0,enumerable:!0}}else n[f[0]]=f[1];for(let f in s)Object.defineProperty(n,f,s[f]);return n}});p(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var De=170,or=96,Be=36,Qe=123,$e=92,He={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},jr=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(u))!==or;)t?t===$e?(g(),e+=He[c[u]]||c[u],g()):t===Be&&c.charCodeAt(u+1)===Qe?(e&&r.push([,e]),e="",g(2),r.push(A(0,125))):(e+=c[u],g(),t=c.charCodeAt(u),t===or&&e&&r.push([,e])):I("Unterminated template");return g(),r},je=w[or];w[or]=(r,e)=>r&&e<De?m.asi&&m.newline?void 0:(g(),["``",r,...jr()]):r?je?.(r,e):(g(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(jr()));p("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):o.push(i(s));let n=Object.assign([...t],{raw:t});return s=>r(s)(n,...o.map(f=>f(s)))});m.string["'"]=!0;m.number={"0x":16,"0b":2,"0o":8};var hr=5,Wr=123,zr=125,a=(r,e,t,o=r.charCodeAt(0),n=r.length,s=w[o],f)=>w[o]=(l,h,E,T=u)=>!l&&(E?r==E:(n<2||c.substr(u,n)==r)&&(E=r))&&h<e&&!m.id(c.charCodeAt(u+n))&&(G(u+n),(f=t())?V(f,T):(G(T),!s&&I()),f)||s?.(l,h,E),gr=(r,e,t,o=r.charCodeAt(0),n=r.length,s=w[o],f)=>w[o]=(l,h,E,T=u)=>l&&(E?r==E:(n<2||c.substr(u,n)==r)&&(E=r))&&h<e&&!m.id(c.charCodeAt(u+n))&&(G(u+n),V(f=t(l),T),f)||s?.(l,h,E),_=()=>(y()===Wr||I("Expected {"),g(),A(hr-.5,zr)||null),K=()=>y()!==Wr?A(hr+.5):(g(),A(hr-.5,zr)||null);var Er=5,We=10,ze=20,Jr=r=>{let e=A(We-1);return e?.[0]==="in"||e?.[0]==="of"?[e[0],[r,e[1]],e[2]]:e?.[0]===","?[r,...e.slice(1)]:[r,e]};S("let",Er+1,r=>!r&&Jr("let"));S("const",Er+1,r=>!r&&Jr("const"));a("var",Er,()=>(y(),["var",A(ze)]));var Vr=(...r)=>(r=r.map(e=>{if(typeof e=="string")return t=>{t[e]=void 0};if(e[0]==="="){let[,t,o]=e,n=i(o);return typeof t=="string"?s=>{s[t]=n(s)}:s=>L(t,n(s),s)}return i(e)}),e=>{for(let t of r)t(e)});p("let",Vr);p("const",Vr);p("var",r=>typeof r=="string"?e=>{e[r]=void 0}:()=>{});var D=Symbol("break"),W=Symbol("continue"),B=Symbol("return");var Je=200;a("function",Je,()=>{y();let r=k(m.id);return r&&y(),["function",r,N()||null,_()]});p("function",(r,e,t)=>{t=t?i(t):()=>{};let o=e?e[0]===","?e.slice(1):[e]:[],n=null,s=-1,f=o[o.length-1];return Array.isArray(f)&&f[0]==="..."&&(s=o.length-1,n=f[1],o.length--),l=>{let h=(...E)=>{let T={};o.forEach((C,R)=>T[C]=E[R]),n&&(T[n]=E.slice(s));let F=new Proxy(T,{get:(C,R)=>R in C?C[R]:l[R],set:(C,R,xr)=>((R in C?C:l)[R]=xr,!0),has:(C,R)=>R in C||R in l});try{return t(F)}catch(C){if(C?.type===B)return C.value;throw C}};return r&&(l[r]=h),h}});var nr=140,ar=20;v("await",nr);a("yield",nr,()=>(y(),c[u]==="*"?(g(),y(),["yield*",A(ar)]):["yield",A(ar)]));a("async",nr,()=>{if(y(),X("function"))return["async",A(nr)];let r=A(ar-.5);return r&&["async",r]});p("async",r=>{let e=i(r);return t=>{let o=e(t);return async function(...n){return o(...n)}}});p("await",r=>(r=i(r),async e=>await r(e)));p("yield",r=>(r=r?i(r):null,e=>{throw{__yield__:r?r(e):void 0}}));p("yield*",r=>(r=i(r),e=>{throw{__yield_all__:r(e)}}));var Sr=200,Ve=140,Ye=90,Ze=Symbol("static");P("super",Symbol.for("super"));v("static",Ve);d("instanceof",Ye);S("#",Sr,r=>{if(r)return;let e=k(m.id);return e?"#"+e:void 0});a("class",Sr,()=>{y();let r=k(m.id)||null;if(r==="extends")r=null;else if(y(),!X("extends"))return["class",r,null,_()];return y(),["class",r,A(Sr),_()]});var qe=r=>{throw Error(r)};p("instanceof",(r,e)=>(r=i(r),e=i(e),t=>r(t)instanceof e(t)));p("class",(r,e,t)=>(e=e?i(e):null,t=t?i(t):null,o=>{let n=e?e(o):Object,s=function(...f){if(!(this instanceof s))return qe("Class constructor must be called with new");let l=e?Reflect.construct(n,f,s):this;return s.prototype.__constructor__&&s.prototype.__constructor__.apply(l,f),l};if(Object.setPrototypeOf(s.prototype,n.prototype),Object.setPrototypeOf(s,n),t){let f=Object.create(o);f.super=n;let l=t(f),h=Array.isArray(l)&&typeof l[0]?.[0]=="string"?l:[];for(let[E,T]of h)E==="constructor"?s.prototype.__constructor__=T:s.prototype[E]=T}return r&&(o[r]=s),s}));p("static",r=>(r=i(r),e=>[[Ze,r(e)]]));var xe=140,Cr=47,be=92,rt=r=>r===be?2:r&&r!==Cr,et=r=>r===103||r===105||r===109||r===115||r===117||r===121;S("/",xe,r=>{if(r)return;let e=c.charCodeAt(u);if(e===Cr||e===42||e===43||e===63||e===61)return;let t=k(rt);c.charCodeAt(u)===Cr||I("Unterminated regex"),g();try{return[,new RegExp(t,k(et))]}catch(o){I("Invalid regex: "+o.message)}});var tt=5,ot=59,nt=()=>{let r=u;return y()===ot&&g(),y(),X("else")?(g(4),!0):(G(r),!1)};a("if",tt+1,()=>{y();let r=["if",N(),K()];return nt()&&r.push(K()),r});p("if",(r,e,t)=>(r=i(r),e=i(e),t=t!==void 0?i(t):null,o=>r(o)?e(o):t?.(o)));var z=(r,e)=>{try{return{v:r(e)}}catch(t){if(t?.type===D)return{b:1};if(t?.type===W)return{c:1};if(t?.type===B)return{r:1,v:t.value};throw t}},Q=5,it=125,st=59;a("while",Q+1,()=>(y(),["while",N(),K()]));a("do",Q+1,()=>(r=>(y(),g(5),y(),["do",r,N()]))(K()));a("for",Q+1,()=>(y(),X("await")?(g(5),y(),["for await",N(),K()]):["for",N(),K()]));a("break",Q+1,()=>["break"]);a("continue",Q+1,()=>["continue"]);a("return",Q+1,()=>{m.asi&&(m.newline=!1),y();let r=c.charCodeAt(u);return!r||r===it||r===st||m.newline?["return"]:["return",A(Q)]});p("while",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;for(;r(t)&&!(o=z(e,t)).b;){if(o.r)return o.v;o.c||(n=o.v)}return n}));p("do",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;do{if((o=z(r,t)).b)break;if(o.r)return o.v;o.c||(n=o.v)}while(e(t));return n}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,o,n]=r;return t=t?i(t):null,o=o?i(o):()=>!0,n=n?i(n):null,e=i(e),s=>{let f,l;for(t?.(s);o(s)&&!(f=z(e,s)).b;n?.(s)){if(f.r)return f.v;f.c||(l=f.v)}return l}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,o,n]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),t==="in")return ft(o,n,e);if(t==="of")return pt(o,n,e)}});var pt=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,f,l=o?null:n[r];for(let h of e(n)){if(o?L(r,h,n):n[r]=h,(s=z(t,n)).b)break;if(s.r)return s.v;s.c||(f=s.v)}return o||(n[r]=l),f}},ft=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,f,l=o?null:n[r];for(let h in e(n)){if(o?L(r,h,n):n[r]=h,(s=z(t,n)).b)break;if(s.r)return s.v;s.c||(f=s.v)}return o||(n[r]=l),f}};p("break",()=>()=>{throw{type:D}});p("continue",()=>()=>{throw{type:W}});p("return",r=>(r=r!==void 0?i(r):null,e=>{throw{type:B,value:r?.(e)}}));var J=5;a("try",J+1,()=>["try",_()]);gr("catch",J+1,r=>(y(),["catch",r,N(),_()]));gr("finally",J+1,r=>["finally",r,_()]);a("throw",J+1,()=>{if(m.asi&&(m.newline=!1),y(),m.newline)throw SyntaxError("Unexpected newline after throw");return["throw",A(J)]});p("try",r=>(r=r?i(r):null,e=>r?.(e)));p("catch",(r,e,t)=>{let o=r?.[1]?i(r[1]):null;return t=t?i(t):null,n=>{let s;try{s=o?.(n)}catch(f){if(f?.type===D||f?.type===W||f?.type===B)throw f;if(e!==null&&t){let l=e in n,h=n[e];n[e]=f;try{s=t(n)}finally{l?n[e]=h:delete n[e]}}else if(e===null)throw f}return s}});p("finally",(r,e)=>(r=r?i(r):null,e=e?i(e):null,t=>{let o;try{o=r?.(t)}finally{e?.(t)}return o}));p("throw",r=>(r=i(r),e=>{throw r(e)}));var wr=5,lt=20,Yr=58;a("switch",wr+1,()=>(y(),["switch",N(),_()]));a("case",wr+1,()=>(y(),(r=>(y()===Yr&&g(),["case",r]))(A(lt))));a("default",wr+1,()=>(y()===Yr&&g(),["default"]));p("switch",(r,e)=>{if(r=i(r),!e)return s=>r(s);let t=[],o=e[0]===";"?e.slice(1):[e],n=null;for(let s of o)Array.isArray(s)&&(s[0]==="case"||s[0]==="default")?(n&&t.push(n),n=[s[0]==="case"?i(s[1]):null,[]]):n&&n[1].push(i(s));return n&&t.push(n),s=>{let f=r(s),l=!1,h;for(let[E,T]of t)if(l||E===null||E(s)===f){l=!0;for(let F of T)try{h=F(s)}catch(C){if(C?.type===D)return C.value!==void 0?C.value:h;throw C}}return h}});var kr=5,$=10,Zr=42,ut=w[Zr];w[Zr]=(r,e)=>r?ut?.(r,e):(g(),"*");S("from",$+1,r=>r?r[0]!=="="&&r[0]!==","&&(y(),["from",r,A($+1)]):!1);S("as",$+2,r=>r?(y(),["as",r,A($+2)]):!1);a("import",kr,()=>(y(),["import",A($)]));a("export",kr,()=>(y(),["export",A(kr)]));a("default",$+1,()=>(y(),["default",A($)]));p("import",()=>()=>{});p("export",()=>()=>{});p("from",(r,e)=>()=>{});p("as",(r,e)=>()=>{});p("default",r=>i(r));var qr=5;m.asi=(r,e,t)=>{if(e>=qr)return;let o=t(qr-.5);if(o)return r?.[0]!==";"?[";",r,o]:(r.push(o),r)};export{pr as access,d as binary,i as compile,c as cur,Xr as default,I as err,A as expr,H as group,mt as id,u as idx,P as literal,V as loc,w as lookup,sr as nary,k as next,p as operator,ir as operators,N as parens,m as parse,G as seek,g as skip,y as space,S as token,v as unary,X as word};
package/justin.min.js CHANGED
@@ -1,8 +1,8 @@
1
- var f,d,m=r=>(f=0,d=r,m.newline=!1,r=h(),d[f]?k():r||""),k=(r="Unexpected token",e=f,t=d.slice(0,e).split(`
2
- `),o=t.pop(),n=d.slice(Math.max(0,e-40),e),s="\u032D",u=(d[e]||"\u2205")+s,c=d.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
- ${(d[e-41]!==`
4
- `?"...":"")+n}${u}${c}`)},x=(r,e=f)=>(Array.isArray(r)&&(r.loc=e),r),R=(r,e=f,t)=>{for(;t=r(d.charCodeAt(f));)f+=t;return d.slice(e,f)},g=(r=1)=>d[f+=r],M=r=>f=r,h=(r=0,e)=>{let t,o,n,s,u=m.reserved,c;for(e&&m.asi&&(m.newline=!1),m.reserved=0;(t=m.space())&&(c=m.newline,1)&&t!==e&&(n=((s=y[t])&&s(o,r))??(m.asi&&o&&c&&(n=m.asi(o,r,h)))??(!o&&!m.reserved&&R(m.id)));)o=n,m.reserved=0;return m.reserved=u,e&&(t==e?f++:k("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},S=m.space=(r,e=f)=>{for(;(r=d.charCodeAt(f))<=32;)m.asi&&r===10&&(m.newline=!0),f++;return r},Be=m.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,fr=(r,e=r.length)=>d.substr(f,e)===r&&!m.id(d.charCodeAt(f+e)),_=()=>(g(),h(0,41)),y=[],C=(r,e=32,t,o=r.charCodeAt(0),n=r.length,s=y[o],u=r.toUpperCase()!==r,c,A)=>y[o]=(E,B,$,lr=f)=>(c=$,($?r==$:(n<2||r.charCodeAt(1)===d.charCodeAt(f+1)&&(n<3||d.substr(f,n)==r))&&(!u||!m.id(d.charCodeAt(f+n)))&&(c=$=r))&&B<e&&(f+=n,(A=t(E))?x(A,lr):(f=lr,c=0,u&&A!==!1&&(m.reserved=1),!u&&!s&&k()),A)||s?.(E,B,c)),l=(r,e,t=!1)=>C(r,e,(o,n)=>o&&(n=h(e-(t?.5:0)))&&[r,o,n]),v=(r,e,t)=>C(r,e,o=>t?o&&[r,o]:!o&&(o=h(e-.5))&&[r,o]),O=(r,e)=>C(r,200,t=>!t&&[,e]),b=(r,e,t)=>{C(r,e,(o,n)=>(n=h(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),n?.[0]===r?o.push(...n.slice(1)):o.push(n||null),o))},F=(r,e)=>C(r[0],e,t=>!t&&[r,h(0,r.charCodeAt(1))||null]),rr=(r,e)=>C(r[0],e,t=>t&&[r,t,h(0,r.charCodeAt(1))||null]),mr,Br=(r="Compile error",e=mr)=>k(r,e?.loc),q={},p=(r,e,t=q[r])=>q[r]=(...o)=>e(...o)||t?.(...o),i=r=>(mr=r,Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):q[r[0]]?.(...r.slice(1))??Br(`Unknown operator: ${r[0]}`):r===void 0?()=>{}:e=>e?.[r]);var K=46,D=48,Q=57,Mr=69,_r=101,Fr=43,Dr=45,Gr=97,Xr=102,$r=65,Kr=70,er=r=>[,(r=+R(e=>e===K&&d.charCodeAt(f+1)!==K||e>=D&&e<=Q||((e===Mr||e===_r)&&((e=d.charCodeAt(f+1))>=D&&e<=Q||e===Fr||e===Dr)?2:0)))!=r?k():r],Qr={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=D&&r<=Q||r>=Gr&&r<=Xr||r>=$r&&r<=Kr};m.number=null;y[K]=r=>!r&&d.charCodeAt(f+1)!==K&&er();for(let r=D;r<=Q;r++)y[r]=e=>e?void 0:er();y[D]=r=>{if(r)return;let e=m.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&d[f+1]?.toLowerCase()===t[1])return g(2),[,parseInt(R(Qr[o]),o)]}return er()};var Hr=92,cr=34,dr=39,Wr={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ar=r=>(e,t,o="")=>{if(!(e||!m.string?.[String.fromCharCode(r)]))return g(),R(n=>n-r&&(n===Hr?(o+=Wr[d[f+1]]||d[f+1],2):(o+=d[f],1))),d[f]===String.fromCharCode(r)?g():k("Bad string"),[,o]};y[cr]=Ar(cr);y[dr]=Ar(dr);m.string={'"':!0};var N=20;l("=",N,!0);l("+=",N,!0);l("-=",N,!0);l("*=",N,!0);l("/=",N,!0);l("%=",N,!0);l("|=",N,!0);l("&=",N,!0);l("^=",N,!0);l(">>=",N,!0);l("<<=",N,!0);var I=(r,e,t,o)=>typeof r=="string"?n=>e(n,r,n):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o,n)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n),n)):r[0]==="()"&&r.length===2?I(r[1],e):(()=>{throw Error("Invalid assignment target")})();p("=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]=e(n))));p("+=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]+=e(n))));p("-=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]-=e(n))));p("*=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]*=e(n))));p("/=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]/=e(n))));p("%=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]%=e(n))));p("|=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]|=e(n))));p("&=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]&=e(n))));p("^=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]^=e(n))));p(">>=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]>>=e(n))));p("<<=",(r,e)=>(e=i(e),I(r,(t,o,n)=>t[o]<<=e(n))));var jr=30,zr=40,hr=140;l("!",hr);v("!",hr);l("||",jr);l("&&",zr);p("!",r=>(r=i(r),e=>!r(e)));p("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));p("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var Jr=50,Vr=60,Yr=70,gr=100,Zr=140;l("|",Jr);l("&",Yr);l("^",Vr);l(">>",gr);l("<<",gr);v("~",Zr);p("~",r=>(r=i(r),e=>~r(e)));p("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));p("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));p("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));p(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));p("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var H=90;l("<",H);l(">",H);l("<=",H);l(">=",H);p(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));p("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));p(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));p("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var yr=80;l("==",yr);l("!=",yr);p("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));p("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var Cr=110,tr=120,Er=140;l("+",Cr);l("-",Cr);l("*",tr);l("/",tr);l("%",tr);v("+",Er);v("-",Er);p("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));p("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));p("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));p("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));p("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var W=150;C("++",W,r=>r?["++",r,null]:["++",h(W-1)]);C("--",W,r=>r?["--",r,null]:["--",h(W-1)]);var or=(r,e,t,o)=>typeof r=="string"?n=>e(n,r):r[0]==="."?(t=i(r[1]),o=r[2],n=>e(t(n),o)):r[0]==="[]"&&r.length===3?(t=i(r[1]),o=i(r[2]),n=>e(t(n),o(n))):r[0]==="()"&&r.length===2?or(r[1],e):(()=>{throw Error("Invalid increment target")})();p("++",(r,e)=>or(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));p("--",(r,e)=>or(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Sr=5,qr=123,xr=125,P=(r,e,t,o=r.charCodeAt(0),n=r.length,s=y[o],u)=>y[o]=(c,A,E,B=f)=>!c&&(E?r==E:(n<2||d.substr(f,n)==r)&&(E=r))&&A<e&&!m.id(d.charCodeAt(f+n))&&(M(f+n),(u=t())?x(u,B):(M(B),!s&&k()),u)||s?.(c,A,E);var G=()=>S()!==qr?h(Sr+.5):(g(),["block",h(Sr-.5,xr)||null]);p("block",r=>r===void 0?()=>{}:(r=i(r),e=>r(e)));var L=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...n]=r;if(o==="{}")for(let s of n){let u,c,A;s[0]==="="?[,[,u,c],A]=s:[,u,c]=s;let E=e[u];E===void 0&&A&&(E=i(A)(t)),L(c,E,t)}else if(o==="[]"){let s=0;for(let u of n){if(u===null){s++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(s);break}let c=u,A;Array.isArray(u)&&u[0]==="="&&([,c,A]=u);let E=e[s++];E===void 0&&A&&(E=i(A)(t)),L(c,E,t)}}};var j=Symbol("break"),z=Symbol("continue"),vr=Symbol("return"),X=(r,e)=>{try{return{v:r(e)}}catch(t){if(t?.type===j)return{b:1};if(t?.type===z)return{c:1};if(t?.type===vr)return{r:1,v:t.value};throw t}},U=5,br=125,re=59;P("while",U+1,()=>(S(),["while",_(),G()]));P("do",U+1,()=>(r=>(S(),g(5),S(),["do",r,_()]))(G()));P("for",U+1,()=>(S(),fr("await")?(g(5),S(),["for await",_(),G()]):["for",_(),G()]));P("break",U+1,()=>["break"]);P("continue",U+1,()=>["continue"]);P("return",U+1,()=>{m.asi&&(m.newline=!1),S();let r=d.charCodeAt(f);return!r||r===br||r===re||m.newline?["return"]:["return",h(U)]});p("while",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;for(;r(t)&&!(o=X(e,t)).b;){if(o.r)return o.v;o.c||(n=o.v)}return n}));p("do",(r,e)=>(r=i(r),e=i(e),t=>{let o,n;do{if((o=X(r,t)).b)break;if(o.r)return o.v;o.c||(n=o.v)}while(e(t));return n}));p("for",(r,e)=>{if(Array.isArray(r)&&r[0]===";"){let[,t,o,n]=r;return t=t?i(t):null,o=o?i(o):()=>!0,n=n?i(n):null,e=i(e),s=>{let u,c;for(t?.(s);o(s)&&!(u=X(e,s)).b;n?.(s)){if(u.r)return u.v;u.c||(c=u.v)}return c}}if(Array.isArray(r)&&(r[0]==="in"||r[0]==="of")){let[t,o,n]=r;if(Array.isArray(o)&&(o[0]==="let"||o[0]==="const"||o[0]==="var")&&(o=o[1]),t==="in")return te(o,n,e);if(t==="of")return ee(o,n,e)}});var ee=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,u,c=o?null:n[r];for(let A of e(n)){if(o?L(r,A,n):n[r]=A,(s=X(t,n)).b)break;if(s.r)return s.v;s.c||(u=s.v)}return o||(n[r]=c),u}},te=(r,e,t)=>{e=i(e),t=i(t);let o=Array.isArray(r);return n=>{let s,u,c=o?null:n[r];for(let A in e(n)){if(o?L(r,A,n):n[r]=A,(s=X(t,n)).b)break;if(s.r)return s.v;s.c||(u=s.v)}return o||(n[r]=c),u}};p("break",()=>()=>{throw{type:j}});p("continue",()=>()=>{throw{type:z}});p("return",r=>(r=r!==void 0?i(r):null,e=>{throw{type:vr,value:r?.(e)}}));var a=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",ir=170;rr("[]",ir);l(".",ir);rr("()",ir);var nr=r=>{throw Error(r)};p("[]",(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]),o=>t(o)):(t=i(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&nr("Missing index"),r=i(r),e=i(e),t=>{let o=e(t);return a(o)?void 0:r(t)[o]}));p(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],a(e)?()=>{}:t=>r(t)[e]));p("()",(r,e)=>{if(e===void 0)return r==null?nr("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&nr("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return w(r,(n,s,u)=>n[s](...o(u)),!0)});var T=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&T(r[1])||r[0]==="{}"),oe=r=>{throw Error(r)},w=(r,e,t,o,n)=>r==null?oe("Empty ()"):r[0]==="()"&&r.length==2?w(r[1],e,t):typeof r=="string"?s=>e(s,r,s):r[0]==="."?(o=i(r[1]),n=r[2],s=>e(o(s),n,s)):r[0]==="?."?(o=i(r[1]),n=r[2],s=>{let u=o(s);return u==null?void 0:e(u,n,s)}):r[0]==="[]"&&r.length===3?(o=i(r[1]),n=i(r[2]),s=>e(o(s),n(s),s)):r[0]==="?.[]"?(o=i(r[1]),n=i(r[2]),s=>{let u=o(s);return u==null?void 0:e(u,n(s),s)}):(r=i(r),s=>e([r(s)],0,s));var ne=5,ie=10,se=170;F("()",se);b(",",ie);b(";",ne,!0);var wr=r=>{throw Error(r)};p("()",(r,e)=>{if(e===void 0)return r==null?wr("Empty ()"):i(r);let t=n=>n?.[0]===","&&n.slice(1).some(s=>s==null||t(s));t(e)&&wr("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];return w(r,(n,s,u)=>n[s](...o(u)),!0)});var kr=(...r)=>(r=r.map(i),e=>{let t;for(let o of r)try{t=o(e)}catch(n){throw(n?.type===j||n?.type===z)&&(n.value=t),n}return t});p(",",kr);p(";",kr);var Ir=new WeakMap,pe=(r,...e)=>typeof r=="string"?i(m(r)):Ir.get(r)||Ir.set(r,ue(r,e)).get(r),Nr=57344,ue=(r,e)=>{let t=r.reduce((s,u,c)=>s+(c?String.fromCharCode(Nr+c-1):"")+u,""),o=m(t),n=s=>{if(typeof s=="string"&&s.length===1){let u=s.charCodeAt(0)-Nr,c;if(u>=0&&u<e.length)return c=e[u],le(c)?c:[,c]}return Array.isArray(s)?s.map(n):s};return i(n(o))},le=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),fe=pe;var me=32,ce=m.space;m.comment??={"//":`
6
- `,"/*":"*/"};var sr;m.space=()=>{sr||(sr=Object.entries(m.comment).map(([n,s])=>[n,s,n.charCodeAt(0)]));for(var r;r=ce();){for(var e=0,t;t=sr[e++];)if(r===t[2]&&d.substr(f,t[0].length)===t[0]){var o=f+t[0].length;if(t[1]===`
7
- `)for(;d.charCodeAt(o)>=me;)o++;else{for(;d[o]&&d.substr(o,t[1].length)!==t[1];)o++;d[o]&&(o+=t[1].length)}M(o),r=0;break}if(r)return r}return r};var Rr=80;l("===",Rr);l("!==",Rr);p("===",(r,e)=>(r=i(r),e=i(e),t=>r(t)===e(t)));p("!==",(r,e)=>(r=i(r),e=i(e),t=>r(t)!==e(t)));var de=30;l("??",de);p("??",(r,e)=>(r=i(r),e=i(e),t=>r(t)??e(t)));var Ae=130,he=20;l("**",Ae,!0);l("**=",he,!0);p("**",(r,e)=>(r=i(r),e=i(e),t=>r(t)**e(t)));var ge=r=>{throw Error(r)};p("**=",(r,e)=>(T(r)||ge("Invalid assignment target"),e=i(e),w(r,(t,o,n)=>t[o]**=e(n))));var Tr=90;l("in",Tr);l("of",Tr);p("in",(r,e)=>(r=i(r),e=i(e),t=>r(t)in e(t)));var ye=20,Ce=100,Ee=r=>{throw Error(r)};l(">>>",Ce);l(">>>=",ye,!0);p(">>>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>>e(t)));p(">>>=",(r,e)=>(T(r)||Ee("Invalid assignment target"),e=i(e),w(r,(t,o,n)=>t[o]>>>=e(n))));var pr=20,J=r=>{throw Error(r)};l("||=",pr,!0);l("&&=",pr,!0);l("??=",pr,!0);p("=",(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"?o=>{o[t]=e(o)}:o=>L(t,e(o),o)}return T(r)||J("Invalid assignment target"),e=i(e),w(r,(t,o,n)=>t[o]=e(n))});p("||=",(r,e)=>(T(r)||J("Invalid assignment target"),e=i(e),w(r,(t,o,n)=>t[o]||=e(n))));p("&&=",(r,e)=>(T(r)||J("Invalid assignment target"),e=i(e),w(r,(t,o,n)=>t[o]&&=e(n))));p("??=",(r,e)=>(T(r)||J("Invalid assignment target"),e=i(e),w(r,(t,o,n)=>t[o]??=e(n))));O("true",!0);O("false",!1);O("null",null);O("undefined",void 0);O("NaN",NaN);O("Infinity",1/0);var ur=20;C("?",ur,(r,e,t)=>r&&(e=h(ur-1))&&R(o=>o===58)&&(t=h(ur-1),["?",r,e,t]));p("?",(r,e,t)=>(r=i(r),e=i(e),t=i(t),o=>r(o)?e(o):t(o)));var Se=20;l("=>",Se,!0);p("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=i(e[0]==="{}"?e[1]:e),(n=null)=>(n=Object.create(n),(...s)=>(r.forEach((u,c)=>n[u]=s[c]),o&&(n[o]=s.slice(t)),e(n)))});var ve=140;v("...",ve);p("...",r=>(r=i(r),e=>Object.entries(r(e))));var ar=170;C("?.",ar,(r,e)=>{if(!r)return;let t=S();return t===40?(g(),["?.()",r,h(0,41)||null]):t===91?(g(),["?.[]",r,h(0,93)]):(e=h(ar),e?["?.",r,e]:void 0)});p("?.",(r,e)=>(r=i(r),a(e)?()=>{}:t=>r(t)?.[e]));p("?.[]",(r,e)=>(r=i(r),e=i(e),t=>{let o=e(t);return a(o)?void 0:r(t)?.[o]}));p("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(i),n=>e.map(s=>s(n))):(e=i(e),n=>[e(n)]):()=>[];if(r[0]==="?."){let n=i(r[1]),s=r[2];return a(s)?()=>{}:u=>n(u)?.[s]?.(...t(u))}if(r[0]==="?.[]"){let n=i(r[1]),s=i(r[2]);return u=>{let c=n(u),A=s(u);return a(A)?void 0:c?.[A]?.(...t(u))}}if(r[0]==="."){let n=i(r[1]),s=r[2];return a(s)?()=>{}:u=>n(u)?.[s]?.(...t(u))}if(r[0]==="[]"&&r.length===3){let n=i(r[1]),s=i(r[2]);return u=>{let c=n(u),A=s(u);return a(A)?void 0:c?.[A]?.(...t(u))}}let o=i(r);return n=>o(n)?.(...t(n))});var V=140;v("typeof",V);v("void",V);v("delete",V);v("new",V);p("typeof",r=>(r=i(r),e=>typeof r(e)));p("void",r=>(r=i(r),e=>(r(e),void 0)));p("delete",r=>{if(r[0]==="."){let e=i(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=i(r[1]),t=i(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});p("new",r=>{let e=i(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(n=>s=>n.map(u=>u(s)))(t.slice(1).map(i)):(n=>s=>[n(s)])(i(t)):()=>[];return n=>new(e(n))(...o(n))});var Y=Symbol("accessor"),Or=20,we=40,ke=41,Ie=123,Ne=125,Pr=r=>e=>{if(e)return;S();let t=R(m.id);if(!t||(S(),d.charCodeAt(f)!==we))return!1;g();let o=h(0,ke);return S(),d.charCodeAt(f)!==Ie?!1:(g(),[r,t,o,h(0,Ne)])};C("get",Or-1,Pr("get"));C("set",Or-1,Pr("set"));p("get",(r,e)=>(e=e?i(e):()=>{},t=>[[Y,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));p("set",(r,e,t)=>(t=t?i(t):()=>{},o=>[[Y,r,{set:function(n){let s=Object.create(o||{});s.this=this,s[e]=n,t(s)}}]]));var Re=20,Lr=200;F("[]",Lr);F("{}",Lr);l(":",Re-1,!0);p("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>i(typeof o=="string"?[":",o,o]:o));return o=>{let n={},s={};for(let u of t.flatMap(c=>c(o)))if(u[0]===Y){let[,c,A]=u;s[c]={...s[c],...A,configurable:!0,enumerable:!0}}else n[u[0]]=u[1];for(let u in s)Object.defineProperty(n,u,s[u]);return n}});p(":",(r,e)=>(e=i(e),Array.isArray(r)?(r=i(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var Te=170,Z=96,ae=36,Oe=123,Pe=92,Le={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ur=()=>{let r=[];for(let e="",t;(t=d.charCodeAt(f))!==Z;)t?t===Pe?(g(),e+=Le[d[f]]||d[f],g()):t===ae&&d.charCodeAt(f+1)===Oe?(e&&r.push([,e]),e="",g(2),r.push(h(0,125))):(e+=d[f],g(),t=d.charCodeAt(f),t===Z&&e&&r.push([,e])):k("Unterminated template");return g(),r},Ue=y[Z];y[Z]=(r,e)=>r&&e<Te?m.asi&&m.newline?void 0:(g(),["``",r,...Ur()]):r?Ue?.(r,e):(g(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Ur()));p("`",(...r)=>(r=r.map(i),e=>r.map(t=>t(e)).join("")));p("``",(r,...e)=>{r=i(r);let t=[],o=[];for(let s of e)Array.isArray(s)&&s[0]===void 0?t.push(s[1]):o.push(i(s));let n=Object.assign([...t],{raw:t});return s=>r(s)(n,...o.map(u=>u(s)))});m.string["'"]=!0;m.number={"0x":16,"0b":2,"0o":8};export{rr as access,l as binary,i as compile,d as cur,fe as default,k as err,h as expr,F as group,Be as id,f as idx,O as literal,x as loc,y as lookup,b as nary,R as next,p as operator,q as operators,_ as parens,m as parse,M as seek,g as skip,S as space,C as token,v as unary,fr as word};
1
+ var u,c,f=r=>(u=0,c=r,f.newline=!1,r=A(),c[u]?I():r||""),I=(r="Unexpected token",e=u,t=c.slice(0,e).split(`
2
+ `),o=t.pop(),i=c.slice(Math.max(0,e-40),e),p="\u032D",m=(c[e]||"\u2205")+p,d=c.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
+ ${(c[e-41]!==`
4
+ `?"...":"")+i}${m}${d}`)},Ir=(r,e=u)=>(Array.isArray(r)&&(r.loc=e),r),v=(r,e=u,t)=>{for(;t=r(c.charCodeAt(u));)u+=t;return c.slice(e,u)},h=(r=1)=>c[u+=r],rr=r=>u=r,A=(r=0,e)=>{let t,o,i,p,m=f.reserved,d;for(e&&f.asi&&(f.newline=!1),f.reserved=0;(t=f.space())&&(d=f.newline,1)&&t!==e&&(i=((p=S[t])&&p(o,r))??(f.asi&&o&&d&&(i=f.asi(o,r,A)))??(!o&&!f.reserved&&v(f.id)));)o=i,f.reserved=0;return f.reserved=m,e&&(t==e?u++:I("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},P=f.space=(r,e=u)=>{for(;(r=c.charCodeAt(u))<=32;)f.asi&&r===10&&(f.newline=!0),u++;return r},ge=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,he=(r,e=r.length)=>c.substr(u,e)===r&&!f.id(c.charCodeAt(u+e)),ye=()=>(h(),A(0,41)),S=[],y=(r,e=32,t,o=r.charCodeAt(0),i=r.length,p=S[o],m=r.toUpperCase()!==r,d,g)=>S[o]=(E,x,T,b=u)=>(d=T,(T?r==T:(i<2||r.charCodeAt(1)===c.charCodeAt(u+1)&&(i<3||c.substr(u,i)==r))&&(!m||!f.id(c.charCodeAt(u+i)))&&(d=T=r))&&x<e&&(u+=i,(g=t(E))?Ir(g,b):(u=b,d=0,m&&g!==!1&&(f.reserved=1),!m&&!p&&I()),g)||p?.(E,x,d)),l=(r,e,t=!1)=>y(r,e,(o,i)=>o&&(i=A(e-(t?.5:0)))&&[r,o,i]),C=(r,e,t)=>y(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),k=(r,e)=>y(r,200,t=>!t&&[,e]),K=(r,e,t)=>{y(r,e,(o,i)=>(i=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},R=(r,e)=>y(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),j=(r,e)=>y(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),H={},s=(r,e,t=H[r])=>H[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):H[r[0]]?.(...r.slice(1))??I(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var U=46,L=48,_=57,vr=69,wr=101,Nr=43,Or=45,kr=97,Pr=102,Rr=65,Lr=70,W=r=>[,(r=+v(e=>e===U&&c.charCodeAt(u+1)!==U||e>=L&&e<=_||((e===vr||e===wr)&&((e=c.charCodeAt(u+1))>=L&&e<=_||e===Nr||e===Or)?2:0)))!=r?I():r],Tr={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=L&&r<=_||r>=kr&&r<=Pr||r>=Rr&&r<=Lr};f.number=null;S[U]=r=>!r&&c.charCodeAt(u+1)!==U&&W();for(let r=L;r<=_;r++)S[r]=e=>e?void 0:W();S[L]=r=>{if(r)return;let e=f.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&c[u+1]?.toLowerCase()===t[1])return h(2),[,parseInt(v(Tr[o]),o)]}return W()};var Ur=92,er=34,tr=39,_r={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},or=r=>(e,t,o="")=>{if(!(e||!f.string?.[String.fromCharCode(r)]))return h(),v(i=>i-r&&(i===Ur?(o+=_r[c[u+1]]||c[u+1],2):(o+=c[u],1))),c[u]===String.fromCharCode(r)?h():I("Bad string"),[,o]};S[er]=or(er);S[tr]=or(tr);f.string={'"':!0};var Mr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>l(r,Mr,!0));var ir=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?ir(r[1],e):(()=>{throw Error("Invalid assignment target")})(),nr={"=":(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 nr)s(r,(e,t)=>(t=n(t),ir(e,(o,i,p)=>nr[r](o,i,t(p)))));var Fr=30,Br=40,sr=140;l("!",sr);C("!",sr);l("||",Fr);l("&&",Br);s("!",r=>(r=n(r),e=>!r(e)));s("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var Dr=50,Gr=60,Xr=70,pr=100,$r=140;l("|",Dr);l("&",Xr);l("^",Gr);l(">>",pr);l("<<",pr);C("~",$r);s("~",r=>(r=n(r),e=>~r(e)));s("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var M=90;l("<",M);l(">",M);l("<=",M);l(">=",M);s(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var mr=80;l("==",mr);l("!=",mr);s("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var lr=110,z=120,ur=140;l("+",lr);l("-",lr);l("*",z);l("/",z);l("%",z);C("+",ur);C("-",ur);s("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));s("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var F=150;y("++",F,r=>r?["++",r,null]:["++",A(F-1)]);y("--",F,r=>r?["--",r,null]:["--",A(F-1)]);var J=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?J(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>J(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));s("--",(r,e)=>J(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Qr=5,Hr=10,Kr=170;R("()",Kr);K(",",Hr);K(";",Qr,!0);var fr=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});s(",",fr);s(";",fr);var N=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",V=170;j("[]",V);l(".",V);j("()",V);var B=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=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&B("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return N(o)?void 0:r(t)[o]}));s(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],N(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?B("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&B("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];return Y(r,(i,p,m)=>i[p](...o(m)))});var w=r=>typeof r=="string"||Array.isArray(r)&&(r[0]==="."||r[0]==="?."||r[0]==="[]"&&r.length===3||r[0]==="?.[]"||r[0]==="()"&&r.length===2&&w(r[1])||r[0]==="{}"),Y=(r,e,t,o)=>r==null?B("Empty ()"):r[0]==="()"&&r.length==2?Y(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let p=t(i);return p==null?void 0:e(p,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,o(i),i)}):(r=n(r),i=>e([r(i)],0,i)),O=Y;var cr=new WeakMap,jr=(r,...e)=>typeof r=="string"?n(f(r)):cr.get(r)||cr.set(r,Wr(r,e)).get(r),dr=57344,Wr=(r,e)=>{let t=r.reduce((p,m,d)=>p+(d?String.fromCharCode(dr+d-1):"")+m,""),o=f(t),i=p=>{if(typeof p=="string"&&p.length===1){let m=p.charCodeAt(0)-dr,d;if(m>=0&&m<e.length)return d=e[m],zr(d)?d:[,d]}return Array.isArray(p)?p.map(i):p};return n(i(o))},zr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),Jr=jr;var Vr=32,Yr=f.space;f.comment??={"//":`
6
+ `,"/*":"*/"};var Z;f.space=()=>{Z||(Z=Object.entries(f.comment).map(([i,p])=>[i,p,i.charCodeAt(0)]));for(var r;r=Yr();){for(var e=0,t;t=Z[e++];)if(r===t[2]&&c.substr(u,t[0].length)===t[0]){var o=u+t[0].length;if(t[1]===`
7
+ `)for(;c.charCodeAt(o)>=Vr;)o++;else{for(;c[o]&&c.substr(o,t[1].length)!==t[1];)o++;c[o]&&(o+=t[1].length)}rr(o),r=0;break}if(r)return r}return r};var Ar=80;l("===",Ar);l("!==",Ar);s("===",(r,e)=>(r=n(r),e=n(e),t=>r(t)===e(t)));s("!==",(r,e)=>(r=n(r),e=n(e),t=>r(t)!==e(t)));var Zr=30;l("??",Zr);s("??",(r,e)=>(r=n(r),e=n(e),t=>r(t)??e(t)));var qr=130,ar=20;l("**",qr,!0);l("**=",ar,!0);s("**",(r,e)=>(r=n(r),e=n(e),t=>r(t)**e(t)));var xr=r=>{throw Error(r)};s("**=",(r,e)=>(w(r)||xr("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]**=e(i))));var gr=90;l("in",gr);l("of",gr);s("in",(r,e)=>(r=n(r),e=n(e),t=>r(t)in e(t)));var br=20,re=100,ee=r=>{throw Error(r)};l(">>>",re);l(">>>=",br,!0);s(">>>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>>e(t)));s(">>>=",(r,e)=>(w(r)||ee("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]>>>=e(i))));var D=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[o,...i]=r;if(o==="{}")for(let p of i){let m,d,g;p[0]==="="?[,[,m,d],g]=p:[,m,d]=p;let E=e[m];E===void 0&&g&&(E=n(g)(t)),D(d,E,t)}else if(o==="[]"){let p=0;for(let m of i){if(m===null){p++;continue}if(Array.isArray(m)&&m[0]==="..."){t[m[1]]=e.slice(p);break}let d=m,g;Array.isArray(m)&&m[0]==="="&&([,d,g]=m);let E=e[p++];E===void 0&&g&&(E=n(g)(t)),D(d,E,t)}}};var q=20,G=r=>{throw Error(r)};l("||=",q,!0);l("&&=",q,!0);l("??=",q,!0);s("=",(r,e)=>{if(Array.isArray(r)&&(r[0]==="let"||r[0]==="const"||r[0]==="var")){let t=r[1];return e=n(e),typeof t=="string"?o=>{o[t]=e(o)}:o=>D(t,e(o),o)}return w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]=e(i))});s("||=",(r,e)=>(w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]||=e(i))));s("&&=",(r,e)=>(w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]&&=e(i))));s("??=",(r,e)=>(w(r)||G("Invalid assignment target"),e=n(e),O(r,(t,o,i)=>t[o]??=e(i))));k("true",!0);k("false",!1);k("null",null);k("undefined",void 0);k("NaN",NaN);k("Infinity",1/0);var a=20;y("?",a,(r,e,t)=>r&&(e=A(a-1))&&v(o=>o===58)&&(t=A(a-1),["?",r,e,t]));s("?",(r,e,t)=>(r=n(r),e=n(e),t=n(t),o=>r(o)?e(o):t(o)));var te=20;l("=>",te,!0);s("=>",(r,e)=>{r=r[0]==="()"?r[1]:r,r=r?r[0]===","?r.slice(1):[r]:[];let t=-1,o=null;return r.length&&Array.isArray(r[r.length-1])&&r[r.length-1][0]==="..."&&(t=r.length-1,o=r[t][1],r=r.slice(0,-1)),e=n(e[0]==="{}"?e[1]:e),(i=null)=>(i=Object.create(i),(...p)=>(r.forEach((m,d)=>i[m]=p[d]),o&&(i[o]=p.slice(t)),e(i)))});var oe=140;C("...",oe);s("...",r=>(r=n(r),e=>Object.entries(r(e))));var hr=170;y("?.",hr,(r,e)=>{if(!r)return;let t=P();return t===40?(h(),["?.()",r,A(0,41)||null]):t===91?(h(),["?.[]",r,A(0,93)]):(e=A(hr),e?["?.",r,e]:void 0)});s("?.",(r,e)=>(r=n(r),N(e)?()=>{}:t=>r(t)?.[e]));s("?.[]",(r,e)=>(r=n(r),e=n(e),t=>{let o=e(t);return N(o)?void 0:r(t)?.[o]}));s("?.()",(r,e)=>{let t=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];if(r[0]==="?."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:m=>i(m)?.[p]?.(...t(m))}if(r[0]==="?.[]"){let i=n(r[1]),p=n(r[2]);return m=>{let d=i(m),g=p(m);return N(g)?void 0:d?.[g]?.(...t(m))}}if(r[0]==="."){let i=n(r[1]),p=r[2];return N(p)?()=>{}:m=>i(m)?.[p]?.(...t(m))}if(r[0]==="[]"&&r.length===3){let i=n(r[1]),p=n(r[2]);return m=>{let d=i(m),g=p(m);return N(g)?void 0:d?.[g]?.(...t(m))}}let o=n(r);return i=>o(i)?.(...t(i))});var X=140;C("typeof",X);C("void",X);C("delete",X);C("new",X);s("typeof",r=>(r=n(r),e=>typeof r(e)));s("void",r=>(r=n(r),e=>(r(e),void 0)));s("delete",r=>{if(r[0]==="."){let e=n(r[1]),t=r[2];return o=>delete e(o)[t]}if(r[0]==="[]"){let e=n(r[1]),t=n(r[2]);return o=>delete e(o)[t(o)]}return()=>!0});s("new",r=>{let e=n(r?.[0]==="()"?r[1]:r),t=r?.[0]==="()"?r[2]:null,o=t?t[0]===","?(i=>p=>i.map(m=>m(p)))(t.slice(1).map(n)):(i=>p=>[i(p)])(n(t)):()=>[];return i=>new(e(i))(...o(i))});var $=Symbol("accessor"),yr=20,ne=40,ie=41,se=123,pe=125,Cr=r=>e=>{if(e)return;P();let t=v(f.id);if(!t||(P(),c.charCodeAt(u)!==ne))return!1;h();let o=A(0,ie);return P(),c.charCodeAt(u)!==se?!1:(h(),[r,t,o,A(0,pe)])};y("get",yr-1,Cr("get"));y("set",yr-1,Cr("set"));s("get",(r,e)=>(e=e?n(e):()=>{},t=>[[$,r,{get:function(){let o=Object.create(t||{});return o.this=this,e(o)}}]]));s("set",(r,e,t)=>(t=t?n(t):()=>{},o=>[[$,r,{set:function(i){let p=Object.create(o||{});p.this=this,p[e]=i,t(p)}}]]));var me=20,Sr=200;R("[]",Sr);R("{}",Sr);l(":",me-1,!0);s("{}",(r,e)=>{if(e!==void 0)return;r=r?r[0]!==","?[r]:r.slice(1):[];let t=r.map(o=>n(typeof o=="string"?[":",o,o]:o));return o=>{let i={},p={};for(let m of t.flatMap(d=>d(o)))if(m[0]===$){let[,d,g]=m;p[d]={...p[d],...g,configurable:!0,enumerable:!0}}else i[m[0]]=m[1];for(let m in p)Object.defineProperty(i,m,p[m]);return i}});s(":",(r,e)=>(e=n(e),Array.isArray(r)?(r=n(r),t=>[[r(t),e(t)]]):t=>[[r,e(t)]]));var le=170,Q=96,ue=36,fe=123,ce=92,de={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Er=()=>{let r=[];for(let e="",t;(t=c.charCodeAt(u))!==Q;)t?t===ce?(h(),e+=de[c[u]]||c[u],h()):t===ue&&c.charCodeAt(u+1)===fe?(e&&r.push([,e]),e="",h(2),r.push(A(0,125))):(e+=c[u],h(),t=c.charCodeAt(u),t===Q&&e&&r.push([,e])):I("Unterminated template");return h(),r},Ae=S[Q];S[Q]=(r,e)=>r&&e<le?f.asi&&f.newline?void 0:(h(),["``",r,...Er()]):r?Ae?.(r,e):(h(),(t=>t.length<2&&t[0]?.[0]===void 0?t[0]||[,""]:["`",...t])(Er()));s("`",(...r)=>(r=r.map(n),e=>r.map(t=>t(e)).join("")));s("``",(r,...e)=>{r=n(r);let t=[],o=[];for(let p of e)Array.isArray(p)&&p[0]===void 0?t.push(p[1]):o.push(n(p));let i=Object.assign([...t],{raw:t});return p=>r(p)(i,...o.map(m=>m(p)))});f.string["'"]=!0;f.number={"0x":16,"0b":2,"0o":8};export{j as access,l as binary,n as compile,c as cur,Jr as default,I as err,A as expr,R as group,ge as id,u as idx,k as literal,Ir as loc,S as lookup,K as nary,v as next,s as operator,H as operators,ye as parens,f as parse,rr as seek,h as skip,P as space,y as token,C as unary,he as word};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "subscript",
3
- "version": "10.0.0",
3
+ "version": "10.0.2",
4
4
  "description": "Tiny expression parser & evaluator",
5
5
  "main": "subscript.js",
6
6
  "module": "subscript.js",
package/parse.js CHANGED
@@ -129,12 +129,6 @@ export let idx, cur,
129
129
 
130
130
  // === Compile: AST → Evaluator ===
131
131
 
132
- // Current node being compiled (for error location)
133
- let curNode;
134
-
135
- // Compile error with source location
136
- const compileErr = (msg = 'Compile error', node = curNode) => err(msg, node?.loc);
137
-
138
132
  // Operator registry
139
133
  export const operators = {};
140
134
 
@@ -144,10 +138,9 @@ export const operator = (op, fn, prev = operators[op]) =>
144
138
 
145
139
  // Compile AST to evaluator function
146
140
  export const compile = node => (
147
- curNode = node,
148
141
  !Array.isArray(node) ? (node === undefined ? () => undefined : ctx => ctx?.[node]) :
149
142
  node[0] === undefined ? (v => () => v)(node[1]) :
150
- operators[node[0]]?.(...node.slice(1)) ?? compileErr(`Unknown operator: ${node[0]}`)
143
+ operators[node[0]]?.(...node.slice(1)) ?? err(`Unknown operator: ${node[0]}`, node?.loc)
151
144
  );
152
145
 
153
146
  export default parse;
package/subscript.min.js CHANGED
@@ -1,5 +1,5 @@
1
- var f,A,m=r=>(f=0,A=r,m.newline=!1,r=h(),A[f]?S():r||""),S=(r="Unexpected token",e=f,t=A.slice(0,e).split(`
2
- `),n=t.pop(),o=A.slice(Math.max(0,e-40),e),s="\u032D",u=(A[e]||"\u2205")+s,c=A.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${n.length+1}
3
- ${(A[e-41]!==`
4
- `?"...":"")+o}${u}${c}`)},W=(r,e=f)=>(Array.isArray(r)&&(r.loc=e),r),N=(r,e=f,t)=>{for(;t=r(A.charCodeAt(f));)f+=t;return A.slice(e,f)},g=(r=1)=>A[f+=r],z=r=>f=r,h=(r=0,e)=>{let t,n,o,s,u=m.reserved,c;for(e&&m.asi&&(m.newline=!1),m.reserved=0;(t=m.space())&&(c=m.newline,1)&&t!==e&&(o=((s=C[t])&&s(n,r))??(m.asi&&n&&c&&(o=m.asi(n,r,h)))??(!n&&!m.reserved&&N(m.id)));)n=o,m.reserved=0;return m.reserved=u,e&&(t==e?f++:S("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),n},k=m.space=(r,e=f)=>{for(;(r=A.charCodeAt(f))<=32;)m.asi&&r===10&&(m.newline=!0),f++;return r},Zr=m.id=r=>r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r==36||r==95||r>=192&&r!=215&&r!=247,b=(r,e=r.length)=>A.substr(f,e)===r&&!m.id(A.charCodeAt(f+e)),M=()=>(g(),h(0,41)),C=[],v=(r,e=32,t,n=r.charCodeAt(0),o=r.length,s=C[n],u=r.toUpperCase()!==r,c,d)=>C[n]=(y,U,L,x=f)=>(c=L,(L?r==L:(o<2||r.charCodeAt(1)===A.charCodeAt(f+1)&&(o<3||A.substr(f,o)==r))&&(!u||!m.id(A.charCodeAt(f+o)))&&(c=L=r))&&U<e&&(f+=o,(d=t(y))?W(d,x):(f=x,c=0,u&&d!==!1&&(m.reserved=1),!u&&!s&&S()),d)||s?.(y,U,c)),p=(r,e,t=!1)=>v(r,e,(n,o)=>n&&(o=h(e-(t?.5:0)))&&[r,n,o]),T=(r,e,t)=>v(r,e,n=>t?n&&[r,n]:!n&&(n=h(e-.5))&&[r,n]),qr=(r,e)=>v(r,200,t=>!t&&[,e]),J=(r,e,t)=>{v(r,e,(n,o)=>(o=h(e-(t?.5:0)),n?.[0]!==r&&(n=[r,n||null]),o?.[0]===r?n.push(...o.slice(1)):n.push(o||null),n))},rr=(r,e)=>v(r[0],e,t=>!t&&[r,h(0,r.charCodeAt(1))||null]),V=(r,e)=>v(r[0],e,t=>t&&[r,t,h(0,r.charCodeAt(1))||null]),er,Cr=(r="Compile error",e=er)=>S(r,e?.loc),G={},l=(r,e,t=G[r])=>G[r]=(...n)=>e(...n)||t?.(...n),i=r=>(er=r,Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):G[r[0]]?.(...r.slice(1))??Cr(`Unknown operator: ${r[0]}`):r===void 0?()=>{}:e=>e?.[r]);var $=46,_=48,F=57,Er=69,gr=101,wr=43,Sr=45,kr=97,vr=102,Tr=65,Ir=70,Y=r=>[,(r=+N(e=>e===$&&A.charCodeAt(f+1)!==$||e>=_&&e<=F||((e===Er||e===gr)&&((e=A.charCodeAt(f+1))>=_&&e<=F||e===wr||e===Sr)?2:0)))!=r?S():r],Rr={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=_&&r<=F||r>=kr&&r<=vr||r>=Tr&&r<=Ir};m.number=null;C[$]=r=>!r&&A.charCodeAt(f+1)!==$&&Y();for(let r=_;r<=F;r++)C[r]=e=>e?void 0:Y();C[_]=r=>{if(r)return;let e=m.number;if(e){for(let[t,n]of Object.entries(e))if(t[0]==="0"&&A[f+1]?.toLowerCase()===t[1])return g(2),[,parseInt(N(Rr[n]),n)]}return Y()};var Nr=92,tr=34,nr=39,Ur={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},or=r=>(e,t,n="")=>{if(!(e||!m.string?.[String.fromCharCode(r)]))return g(),N(o=>o-r&&(o===Nr?(n+=Ur[A[f+1]]||A[f+1],2):(n+=A[f],1))),A[f]===String.fromCharCode(r)?g():S("Bad string"),[,n]};C[tr]=or(tr);C[nr]=or(nr);m.string={'"':!0};var w=20;p("=",w,!0);p("+=",w,!0);p("-=",w,!0);p("*=",w,!0);p("/=",w,!0);p("%=",w,!0);p("|=",w,!0);p("&=",w,!0);p("^=",w,!0);p(">>=",w,!0);p("<<=",w,!0);var E=(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?E(r[1],e):(()=>{throw Error("Invalid assignment target")})();l("=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]=e(o))));l("+=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]+=e(o))));l("-=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]-=e(o))));l("*=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]*=e(o))));l("/=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]/=e(o))));l("%=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]%=e(o))));l("|=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]|=e(o))));l("&=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]&=e(o))));l("^=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]^=e(o))));l(">>=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]>>=e(o))));l("<<=",(r,e)=>(e=i(e),E(r,(t,n,o)=>t[n]<<=e(o))));var Mr=30,_r=40,ir=140;p("!",ir);T("!",ir);p("||",Mr);p("&&",_r);l("!",r=>(r=i(r),e=>!r(e)));l("||",(r,e)=>(r=i(r),e=i(e),t=>r(t)||e(t)));l("&&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&&e(t)));var Pr=50,Br=60,Dr=70,sr=100,Lr=140;p("|",Pr);p("&",Dr);p("^",Br);p(">>",sr);p("<<",sr);T("~",Lr);l("~",r=>(r=i(r),e=>~r(e)));l("|",(r,e)=>(r=i(r),e=i(e),t=>r(t)|e(t)));l("&",(r,e)=>(r=i(r),e=i(e),t=>r(t)&e(t)));l("^",(r,e)=>(r=i(r),e=i(e),t=>r(t)^e(t)));l(">>",(r,e)=>(r=i(r),e=i(e),t=>r(t)>>e(t)));l("<<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<<e(t)));var X=90;p("<",X);p(">",X);p("<=",X);p(">=",X);l(">",(r,e)=>(r=i(r),e=i(e),t=>r(t)>e(t)));l("<",(r,e)=>(r=i(r),e=i(e),t=>r(t)<e(t)));l(">=",(r,e)=>(r=i(r),e=i(e),t=>r(t)>=e(t)));l("<=",(r,e)=>(r=i(r),e=i(e),t=>r(t)<=e(t)));var lr=80;p("==",lr);p("!=",lr);l("==",(r,e)=>(r=i(r),e=i(e),t=>r(t)==e(t)));l("!=",(r,e)=>(r=i(r),e=i(e),t=>r(t)!=e(t)));var ur=110,Z=120,fr=140;p("+",ur);p("-",ur);p("*",Z);p("/",Z);p("%",Z);T("+",fr);T("-",fr);l("+",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)+e(t)):(r=i(r),t=>+r(t)));l("-",(r,e)=>e!==void 0?(r=i(r),e=i(e),t=>r(t)-e(t)):(r=i(r),t=>-r(t)));l("*",(r,e)=>(r=i(r),e=i(e),t=>r(t)*e(t)));l("/",(r,e)=>(r=i(r),e=i(e),t=>r(t)/e(t)));l("%",(r,e)=>(r=i(r),e=i(e),t=>r(t)%e(t)));var O=150;v("++",O,r=>r?["++",r,null]:["++",h(O-1)]);v("--",O,r=>r?["--",r,null]:["--",h(O-1)]);var q=(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?q(r[1],e):(()=>{throw Error("Invalid increment target")})();l("++",(r,e)=>q(r,e===null?(t,n)=>t[n]++:(t,n)=>++t[n]));l("--",(r,e)=>q(r,e===null?(t,n)=>t[n]--:(t,n)=>--t[n]));var pr=5,$r=123,Fr=125,I=(r,e,t,n=r.charCodeAt(0),o=r.length,s=C[n],u)=>C[n]=(c,d,y,U=f)=>!c&&(y?r==y:(o<2||A.substr(f,o)==r)&&(y=r))&&d<e&&!m.id(A.charCodeAt(f+o))&&(z(f+o),(u=t())?W(u,U):(z(U),!s&&S()),u)||s?.(c,d,y);var P=()=>k()!==$r?h(pr+.5):(g(),["block",h(pr-.5,Fr)||null]);l("block",r=>r===void 0?()=>{}:(r=i(r),e=>r(e)));var B=(r,e,t)=>{if(typeof r=="string"){t[r]=e;return}let[n,...o]=r;if(n==="{}")for(let s of o){let u,c,d;s[0]==="="?[,[,u,c],d]=s:[,u,c]=s;let y=e[u];y===void 0&&d&&(y=i(d)(t)),B(c,y,t)}else if(n==="[]"){let s=0;for(let u of o){if(u===null){s++;continue}if(Array.isArray(u)&&u[0]==="..."){t[u[1]]=e.slice(s);break}let c=u,d;Array.isArray(u)&&u[0]==="="&&([,c,d]=u);let y=e[s++];y===void 0&&d&&(y=i(d)(t)),B(c,y,t)}}};var Q=Symbol("break"),H=Symbol("continue"),mr=Symbol("return"),D=(r,e)=>{try{return{v:r(e)}}catch(t){if(t?.type===Q)return{b:1};if(t?.type===H)return{c:1};if(t?.type===mr)return{r:1,v:t.value};throw t}},R=5,Xr=125,Or=59;I("while",R+1,()=>(k(),["while",M(),P()]));I("do",R+1,()=>(r=>(k(),g(5),k(),["do",r,M()]))(P()));I("for",R+1,()=>(k(),b("await")?(g(5),k(),["for await",M(),P()]):["for",M(),P()]));I("break",R+1,()=>["break"]);I("continue",R+1,()=>["continue"]);I("return",R+1,()=>{m.asi&&(m.newline=!1),k();let r=A.charCodeAt(f);return!r||r===Xr||r===Or||m.newline?["return"]:["return",h(R)]});l("while",(r,e)=>(r=i(r),e=i(e),t=>{let n,o;for(;r(t)&&!(n=D(e,t)).b;){if(n.r)return n.v;n.c||(o=n.v)}return o}));l("do",(r,e)=>(r=i(r),e=i(e),t=>{let n,o;do{if((n=D(r,t)).b)break;if(n.r)return n.v;n.c||(o=n.v)}while(e(t));return o}));l("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),s=>{let u,c;for(t?.(s);n(s)&&!(u=D(e,s)).b;o?.(s)){if(u.r)return u.v;u.c||(c=u.v)}return c}}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 Hr(n,o,e);if(t==="of")return Qr(n,o,e)}});var Qr=(r,e,t)=>{e=i(e),t=i(t);let n=Array.isArray(r);return o=>{let s,u,c=n?null:o[r];for(let d of e(o)){if(n?B(r,d,o):o[r]=d,(s=D(t,o)).b)break;if(s.r)return s.v;s.c||(u=s.v)}return n||(o[r]=c),u}},Hr=(r,e,t)=>{e=i(e),t=i(t);let n=Array.isArray(r);return o=>{let s,u,c=n?null:o[r];for(let d in e(o)){if(n?B(r,d,o):o[r]=d,(s=D(t,o)).b)break;if(s.r)return s.v;s.c||(u=s.v)}return n||(o[r]=c),u}};l("break",()=>()=>{throw{type:Q}});l("continue",()=>()=>{throw{type:H}});l("return",r=>(r=r!==void 0?i(r):null,e=>{throw{type:mr,value:r?.(e)}}));var cr=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",j=170;V("[]",j);p(".",j);V("()",j);var a=r=>{throw Error(r)};l("[]",(r,e)=>e===void 0?(r=r?r[0]===","?r.slice(1):[r]:[],r=r.map(t=>t==null?(()=>{}):t[0]==="..."?(t=i(t[1]),n=>t(n)):(t=i(t),n=>[t(n)])),t=>r.flatMap(n=>n(t))):(e==null&&a("Missing index"),r=i(r),e=i(e),t=>{let n=e(t);return cr(n)?void 0:r(t)[n]}));l(".",(r,e)=>(r=i(r),e=e[0]?e:e[1],cr(e)?()=>{}:t=>r(t)[e]));l("()",(r,e)=>{if(e===void 0)return r==null?a("Empty ()"):i(r);let t=o=>o?.[0]===","&&o.slice(1).some(s=>s==null||t(s));t(e)&&a("Empty argument");let n=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(s=>s(o))):(e=i(e),o=>[e(o)]):()=>[];return K(r,(o,s,u)=>o[s](...n(u)),!0)});var Kr=r=>{throw Error(r)},K=(r,e,t,n,o)=>r==null?Kr("Empty ()"):r[0]==="()"&&r.length==2?K(r[1],e,t):typeof r=="string"?s=>e(s,r,s):r[0]==="."?(n=i(r[1]),o=r[2],s=>e(n(s),o,s)):r[0]==="?."?(n=i(r[1]),o=r[2],s=>{let u=n(s);return u==null?void 0:e(u,o,s)}):r[0]==="[]"&&r.length===3?(n=i(r[1]),o=i(r[2]),s=>e(n(s),o(s),s)):r[0]==="?.[]"?(n=i(r[1]),o=i(r[2]),s=>{let u=n(s);return u==null?void 0:e(u,o(s),s)}):(r=i(r),s=>e([r(s)],0,s));var Gr=5,Wr=10,zr=170;rr("()",zr);J(",",Wr);J(";",Gr,!0);var Ar=r=>{throw Error(r)};l("()",(r,e)=>{if(e===void 0)return r==null?Ar("Empty ()"):i(r);let t=o=>o?.[0]===","&&o.slice(1).some(s=>s==null||t(s));t(e)&&Ar("Empty argument");let n=e?e[0]===","?(e=e.slice(1).map(i),o=>e.map(s=>s(o))):(e=i(e),o=>[e(o)]):()=>[];return K(r,(o,s,u)=>o[s](...n(u)),!0)});var dr=(...r)=>(r=r.map(i),e=>{let t;for(let n of r)try{t=n(e)}catch(o){throw(o?.type===Q||o?.type===H)&&(o.value=t),o}return t});l(",",dr);l(";",dr);var hr=new WeakMap,Jr=(r,...e)=>typeof r=="string"?i(m(r)):hr.get(r)||hr.set(r,Vr(r,e)).get(r),yr=57344,Vr=(r,e)=>{let t=r.reduce((s,u,c)=>s+(c?String.fromCharCode(yr+c-1):"")+u,""),n=m(t),o=s=>{if(typeof s=="string"&&s.length===1){let u=s.charCodeAt(0)-yr,c;if(u>=0&&u<e.length)return c=e[u],Yr(c)?c:[,c]}return Array.isArray(s)?s.map(o):s};return i(o(n))},Yr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),De=Jr;export{V as access,p as binary,i as compile,A as cur,De as default,S as err,h as expr,rr as group,Zr as id,f as idx,qr as literal,W as loc,C as lookup,J as nary,N as next,l as operator,G as operators,M as parens,m as parse,z as seek,g as skip,k as space,v as token,T as unary,b as word};
1
+ var l,f,u=r=>(l=0,f=r,u.newline=!1,r=A(),f[l]?y():r||""),y=(r="Unexpected token",e=l,t=f.slice(0,e).split(`
2
+ `),o=t.pop(),i=f.slice(Math.max(0,e-40),e),p="\u032D",c=(f[e]||"\u2205")+p,d=f.slice(e+1,e+20))=>{throw SyntaxError(`${r} at ${t.length+1}:${o.length+1}
3
+ ${(f[e-41]!==`
4
+ `?"...":"")+i}${c}${d}`)},er=(r,e=l)=>(Array.isArray(r)&&(r.loc=e),r),S=(r,e=l,t)=>{for(;t=r(f.charCodeAt(l));)l+=t;return f.slice(e,l)},E=(r=1)=>f[l+=r],Pr=r=>l=r,A=(r=0,e)=>{let t,o,i,p,c=u.reserved,d;for(e&&u.asi&&(u.newline=!1),u.reserved=0;(t=u.space())&&(d=u.newline,1)&&t!==e&&(i=((p=g[t])&&p(o,r))??(u.asi&&o&&d&&(i=u.asi(o,r,A)))??(!o&&!u.reserved&&S(u.id)));)o=i,u.reserved=0;return u.reserved=c,e&&(t==e?l++:y("Unclosed "+String.fromCharCode(e-(e>42?2:1)))),o},Ur=u.space=(r,e=l)=>{for(;(r=f.charCodeAt(l))<=32;)u.asi&&r===10&&(u.newline=!0),l++;return r},Mr=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,Rr=(r,e=r.length)=>f.substr(l,e)===r&&!u.id(f.charCodeAt(l+e)),Dr=()=>(E(),A(0,41)),g=[],h=(r,e=32,t,o=r.charCodeAt(0),i=r.length,p=g[o],c=r.toUpperCase()!==r,d,I)=>g[o]=(k,X,T,Q=l)=>(d=T,(T?r==T:(i<2||r.charCodeAt(1)===f.charCodeAt(l+1)&&(i<3||f.substr(l,i)==r))&&(!c||!u.id(f.charCodeAt(l+i)))&&(d=T=r))&&X<e&&(l+=i,(I=t(k))?er(I,Q):(l=Q,d=0,c&&I!==!1&&(u.reserved=1),!c&&!p&&y()),I)||p?.(k,X,d)),m=(r,e,t=!1)=>h(r,e,(o,i)=>o&&(i=A(e-(t?.5:0)))&&[r,o,i]),C=(r,e,t)=>h(r,e,o=>t?o&&[r,o]:!o&&(o=A(e-.5))&&[r,o]),Lr=(r,e)=>h(r,200,t=>!t&&[,e]),D=(r,e,t)=>{h(r,e,(o,i)=>(i=A(e-(t?.5:0)),o?.[0]!==r&&(o=[r,o||null]),i?.[0]===r?o.push(...i.slice(1)):o.push(i||null),o))},B=(r,e)=>h(r[0],e,t=>!t&&[r,A(0,r.charCodeAt(1))||null]),L=(r,e)=>h(r[0],e,t=>t&&[r,t,A(0,r.charCodeAt(1))||null]),R={},s=(r,e,t=R[r])=>R[r]=(...o)=>e(...o)||t?.(...o),n=r=>Array.isArray(r)?r[0]===void 0?(e=>()=>e)(r[1]):R[r[0]]?.(...r.slice(1))??y(`Unknown operator: ${r[0]}`,r?.loc):r===void 0?()=>{}:e=>e?.[r];var _=46,w=48,v=57,tr=69,or=101,nr=43,ir=45,sr=97,lr=102,pr=65,ur=70,$=r=>[,(r=+S(e=>e===_&&f.charCodeAt(l+1)!==_||e>=w&&e<=v||((e===tr||e===or)&&((e=f.charCodeAt(l+1))>=w&&e<=v||e===nr||e===ir)?2:0)))!=r?y():r],mr={2:r=>r===48||r===49,8:r=>r>=48&&r<=55,16:r=>r>=w&&r<=v||r>=sr&&r<=lr||r>=pr&&r<=ur};u.number=null;g[_]=r=>!r&&f.charCodeAt(l+1)!==_&&$();for(let r=w;r<=v;r++)g[r]=e=>e?void 0:$();g[w]=r=>{if(r)return;let e=u.number;if(e){for(let[t,o]of Object.entries(e))if(t[0]==="0"&&f[l+1]?.toLowerCase()===t[1])return E(2),[,parseInt(S(mr[o]),o)]}return $()};var fr=92,H=34,G=39,dr={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},W=r=>(e,t,o="")=>{if(!(e||!u.string?.[String.fromCharCode(r)]))return E(),S(i=>i-r&&(i===fr?(o+=dr[f[l+1]]||f[l+1],2):(o+=f[l],1))),f[l]===String.fromCharCode(r)?E():y("Bad string"),[,o]};g[H]=W(H);g[G]=W(G);u.string={'"':!0};var cr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(r=>m(r,cr,!0));var J=(r,e,t,o)=>typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="()"&&r.length===2?J(r[1],e):(()=>{throw Error("Invalid assignment target")})(),z={"=":(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 z)s(r,(e,t)=>(t=n(t),J(e,(o,i,p)=>z[r](o,i,t(p)))));var Ar=30,gr=40,K=140;m("!",K);C("!",K);m("||",Ar);m("&&",gr);s("!",r=>(r=n(r),e=>!r(e)));s("||",(r,e)=>(r=n(r),e=n(e),t=>r(t)||e(t)));s("&&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&&e(t)));var hr=50,yr=60,Cr=70,V=100,Sr=140;m("|",hr);m("&",Cr);m("^",yr);m(">>",V);m("<<",V);C("~",Sr);s("~",r=>(r=n(r),e=>~r(e)));s("|",(r,e)=>(r=n(r),e=n(e),t=>r(t)|e(t)));s("&",(r,e)=>(r=n(r),e=n(e),t=>r(t)&e(t)));s("^",(r,e)=>(r=n(r),e=n(e),t=>r(t)^e(t)));s(">>",(r,e)=>(r=n(r),e=n(e),t=>r(t)>>e(t)));s("<<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<<e(t)));var P=90;m("<",P);m(">",P);m("<=",P);m(">=",P);s(">",(r,e)=>(r=n(r),e=n(e),t=>r(t)>e(t)));s("<",(r,e)=>(r=n(r),e=n(e),t=>r(t)<e(t)));s(">=",(r,e)=>(r=n(r),e=n(e),t=>r(t)>=e(t)));s("<=",(r,e)=>(r=n(r),e=n(e),t=>r(t)<=e(t)));var Y=80;m("==",Y);m("!=",Y);s("==",(r,e)=>(r=n(r),e=n(e),t=>r(t)==e(t)));s("!=",(r,e)=>(r=n(r),e=n(e),t=>r(t)!=e(t)));var Z=110,F=120,q=140;m("+",Z);m("-",Z);m("*",F);m("/",F);m("%",F);C("+",q);C("-",q);s("+",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)+e(t)):(r=n(r),t=>+r(t)));s("-",(r,e)=>e!==void 0?(r=n(r),e=n(e),t=>r(t)-e(t)):(r=n(r),t=>-r(t)));s("*",(r,e)=>(r=n(r),e=n(e),t=>r(t)*e(t)));s("/",(r,e)=>(r=n(r),e=n(e),t=>r(t)/e(t)));s("%",(r,e)=>(r=n(r),e=n(e),t=>r(t)%e(t)));var U=150;h("++",U,r=>r?["++",r,null]:["++",A(U-1)]);h("--",U,r=>r?["--",r,null]:["--",A(U-1)]);var N=(r,e,t,o)=>typeof r=="string"?i=>e(i,r):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o)):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i))):r[0]==="()"&&r.length===2?N(r[1],e):(()=>{throw Error("Invalid increment target")})();s("++",(r,e)=>N(r,e===null?(t,o)=>t[o]++:(t,o)=>++t[o]));s("--",(r,e)=>N(r,e===null?(t,o)=>t[o]--:(t,o)=>--t[o]));var Er=5,wr=10,Ir=170;B("()",Ir);D(",",wr);D(";",Er,!0);var x=(...r)=>(r=r.map(n),e=>{let t;for(let o of r)t=o(e);return t});s(",",x);s(";",x);var j=r=>r?.[0]==="_"&&r[1]==="_"||r==="constructor"||r==="prototype",O=170;L("[]",O);m(".",O);L("()",O);var M=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=n(t[1]),o=>t(o)):(t=n(t),o=>[t(o)])),t=>r.flatMap(o=>o(t))):(e==null&&M("Missing index"),r=n(r),e=n(e),t=>{let o=e(t);return j(o)?void 0:r(t)[o]}));s(".",(r,e)=>(r=n(r),e=e[0]?e:e[1],j(e)?()=>{}:t=>r(t)[e]));s("()",(r,e)=>{if(e===void 0)return r==null?M("Empty ()"):n(r);let t=i=>i?.[0]===","&&i.slice(1).some(p=>p==null||t(p));t(e)&&M("Empty argument");let o=e?e[0]===","?(e=e.slice(1).map(n),i=>e.map(p=>p(i))):(e=n(e),i=>[e(i)]):()=>[];return a(r,(i,p,c)=>i[p](...o(c)))});var a=(r,e,t,o)=>r==null?M("Empty ()"):r[0]==="()"&&r.length==2?a(r[1],e):typeof r=="string"?i=>e(i,r,i):r[0]==="."?(t=n(r[1]),o=r[2],i=>e(t(i),o,i)):r[0]==="?."?(t=n(r[1]),o=r[2],i=>{let p=t(i);return p==null?void 0:e(p,o,i)}):r[0]==="[]"&&r.length===3?(t=n(r[1]),o=n(r[2]),i=>e(t(i),o(i),i)):r[0]==="?.[]"?(t=n(r[1]),o=n(r[2]),i=>{let p=t(i);return p==null?void 0:e(p,o(i),i)}):(r=n(r),i=>e([r(i)],0,i));var b=new WeakMap,Tr=(r,...e)=>typeof r=="string"?n(u(r)):b.get(r)||b.set(r,_r(r,e)).get(r),rr=57344,_r=(r,e)=>{let t=r.reduce((p,c,d)=>p+(d?String.fromCharCode(rr+d-1):"")+c,""),o=u(t),i=p=>{if(typeof p=="string"&&p.length===1){let c=p.charCodeAt(0)-rr,d;if(c>=0&&c<e.length)return d=e[c],vr(d)?d:[,d]}return Array.isArray(p)?p.map(i):p};return n(i(o))},vr=r=>typeof r=="string"||Array.isArray(r)&&(typeof r[0]=="string"||r[0]===void 0),ne=Tr;export{L as access,m as binary,n as compile,f as cur,ne as default,y as err,A as expr,B as group,Mr as id,l as idx,Lr as literal,er as loc,g as lookup,D as nary,S as next,s as operator,R as operators,Dr as parens,u as parse,Pr as seek,E as skip,Ur as space,h as token,C as unary,Rr as word};
package/util/stringify.js CHANGED
@@ -67,8 +67,6 @@ export const codegen = node => {
67
67
 
68
68
  // --- Statement generators (need structure) ---
69
69
 
70
- generator('block', body => body === undefined ? '{}' : '{ ' + codegen(body) + ' }');
71
-
72
70
  // Variables: ['let', decl] or ['let', decl1, decl2, ...]
73
71
  const varGen = kw => (...args) => kw + ' ' + args.map(codegen).join(', ');
74
72
  generator('let', varGen('let'));
@@ -76,7 +74,7 @@ generator('const', varGen('const'));
76
74
  generator('var', varGen('var'));
77
75
 
78
76
  // Control flow
79
- const wrap = s => s?.[0] === 'block' ? codegen(s) : '{ ' + (s ? codegen(s) : '') + ' }';
77
+ const wrap = s => '{ ' + (s ? codegen(s) : '') + ' }';
80
78
  generator('if', (cond, then, els) => 'if (' + codegen(cond) + ') ' + wrap(then) + (els ? ' else ' + wrap(els) : ''));
81
79
  generator('while', (cond, body) => 'while (' + codegen(cond) + ') ' + wrap(body));
82
80
  generator('do', (body, cond) => 'do ' + wrap(body) + ' while (' + codegen(cond) + ')');
@@ -101,8 +99,7 @@ generator('finally', (expr, body) => codegen(expr) + ' finally { ' + codegen(bod
101
99
  // Functions
102
100
  generator('function', (name, params, body) => {
103
101
  const args = !params ? '' : params[0] === ',' ? params.slice(1).map(codegen).join(', ') : codegen(params);
104
- const b = body?.[0] === 'block' ? codegen(body) : '{ ' + (body ? codegen(body) : '') + ' }';
105
- return 'function' + (name ? ' ' + name : '') + '(' + args + ') ' + b;
102
+ return 'function' + (name ? ' ' + name : '') + '(' + args + ') ' + wrap(body);
106
103
  });
107
104
 
108
105
  generator('=>', (params, body) => {