@thi.ng/parse 2.4.9 → 2.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/api.js +0 -1
  4. package/combinators/alt.js +15 -21
  5. package/combinators/boundary.js +10 -4
  6. package/combinators/check.js +7 -4
  7. package/combinators/dynamic.js +8 -18
  8. package/combinators/expect.js +4 -1
  9. package/combinators/lookahead.js +17 -77
  10. package/combinators/maybe.js +4 -1
  11. package/combinators/not.js +10 -17
  12. package/combinators/repeat.js +26 -18
  13. package/combinators/seq.js +14 -10
  14. package/combinators/wrap.js +4 -1
  15. package/combinators/xform.js +16 -14
  16. package/context.js +134 -137
  17. package/error.js +6 -3
  18. package/grammar.js +241 -185
  19. package/package.json +12 -9
  20. package/presets/alpha.js +14 -17
  21. package/presets/bits.js +6 -2
  22. package/presets/digits.js +6 -8
  23. package/presets/escape.js +14 -11
  24. package/presets/hex.js +8 -13
  25. package/presets/numbers.js +12 -23
  26. package/presets/string.js +6 -1
  27. package/presets/whitespace.js +18 -32
  28. package/prims/always.js +6 -2
  29. package/prims/anchor.js +24 -21
  30. package/prims/fail.js +4 -1
  31. package/prims/lit.js +8 -19
  32. package/prims/none-of.js +10 -15
  33. package/prims/one-of.js +10 -14
  34. package/prims/pass.js +6 -12
  35. package/prims/range.js +18 -37
  36. package/prims/satisfy.js +17 -19
  37. package/prims/skip.js +13 -30
  38. package/prims/string.js +48 -43
  39. package/readers/array-reader.js +22 -20
  40. package/readers/string-reader.js +27 -26
  41. package/utils.js +4 -9
  42. package/xform/collect.js +9 -16
  43. package/xform/comp.js +19 -22
  44. package/xform/count.js +9 -16
  45. package/xform/discard.js +6 -10
  46. package/xform/hoist.js +15 -30
  47. package/xform/join.js +17 -24
  48. package/xform/json.js +8 -15
  49. package/xform/nest.js +21 -32
  50. package/xform/number.js +16 -36
  51. package/xform/print.js +21 -47
  52. package/xform/replace.js +9 -17
  53. package/xform/trim.js +8 -17
  54. package/xform/with-id.js +6 -8
package/error.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { defError } from "@thi.ng/errors/deferror";
2
2
  const ParseError = defError(() => `ParseError`);
3
- export const parseError = (ctx, msg) => {
4
- const info = ctx.reader.format(ctx.scope.state);
5
- throw new ParseError(msg + (info ? ` @ ${info}` : ""));
3
+ const parseError = (ctx, msg) => {
4
+ const info = ctx.reader.format(ctx.scope.state);
5
+ throw new ParseError(msg + (info ? ` @ ${info}` : ""));
6
+ };
7
+ export {
8
+ parseError
6
9
  };
package/grammar.js CHANGED
@@ -19,7 +19,13 @@ import { FLOAT, INT, UINT } from "./presets/numbers.js";
19
19
  import { STRING } from "./presets/string.js";
20
20
  import { DNL, NL, WS, WS0, WS1 } from "./presets/whitespace.js";
21
21
  import { always, alwaysD } from "./prims/always.js";
22
- import { inputEnd, inputStart, lineEnd, lineStart, wordBoundary, } from "./prims/anchor.js";
22
+ import {
23
+ inputEnd,
24
+ inputStart,
25
+ lineEnd,
26
+ lineStart,
27
+ wordBoundary
28
+ } from "./prims/anchor.js";
23
29
  import { lit, litD } from "./prims/lit.js";
24
30
  import { noneOf } from "./prims/none-of.js";
25
31
  import { oneOf } from "./prims/one-of.js";
@@ -39,32 +45,50 @@ import { xfTrim } from "./xform/trim.js";
39
45
  import { withID } from "./xform/with-id.js";
40
46
  const apos = litD("'");
41
47
  const dash = litD("-");
42
- const REPEAT = maybe(alt([
48
+ const REPEAT = maybe(
49
+ alt([
43
50
  oneOf("?*+", "repeat"),
44
- collect(seq([litD("{"), UINT, maybe(lit(",")), maybe(UINT), litD("}")], "repeatN")),
45
- ]));
46
- const DISCARD = maybe(lit("!"), undefined, "discard");
51
+ collect(
52
+ seq(
53
+ [litD("{"), UINT, maybe(lit(",")), maybe(UINT), litD("}")],
54
+ "repeatN"
55
+ )
56
+ )
57
+ ])
58
+ );
59
+ const DISCARD = maybe(lit("!"), void 0, "discard");
47
60
  const CHAR_OR_ESC = alt([UNICODE, ESC, always()]);
48
61
  const CHAR_RANGE = seq([CHAR_OR_ESC, dash, CHAR_OR_ESC], "charRange");
49
- const CHAR_SEL = seq([
62
+ const CHAR_SEL = seq(
63
+ [
50
64
  litD("["),
51
65
  maybe(lit("^", "invert")),
52
66
  oneOrMore(alt([CHAR_RANGE, UNICODE, noneOf("]", "char")]), "choice"),
53
- litD("]"),
54
- ], "charSel");
67
+ litD("]")
68
+ ],
69
+ "charSel"
70
+ );
55
71
  const ANY = lit(".", "any");
56
72
  const LIT = hoistResult(seq([apos, CHAR_OR_ESC, apos], "char"));
57
73
  const SYM = join(oneOrMore(alt([ALPHA_NUM, oneOf(".-_$")]), "sym"));
58
74
  const RULE_REF = seq([litD("<"), SYM, litD(">")], "ref");
59
75
  const TERM_BODY = alt([RULE_REF, ANY, LIT, STRING, CHAR_SEL]);
60
- const LOOK_AHEAD = maybe(seq([
61
- stringD("(?"),
62
- oneOf("-+"),
63
- seq([TERM_BODY, REPEAT, DISCARD], "lhterm"),
64
- litD(")"),
65
- ], "lhspec"), undefined, "lhnone");
76
+ const LOOK_AHEAD = maybe(
77
+ seq(
78
+ [
79
+ stringD("(?"),
80
+ oneOf("-+"),
81
+ seq([TERM_BODY, REPEAT, DISCARD], "lhterm"),
82
+ litD(")")
83
+ ],
84
+ "lhspec"
85
+ ),
86
+ void 0,
87
+ "lhnone"
88
+ );
66
89
  const TERM = seq([TERM_BODY, REPEAT, DISCARD, LOOK_AHEAD], "term");
67
- const ALT = seq([
90
+ const ALT = seq(
91
+ [
68
92
  litD("("),
69
93
  WS0,
70
94
  TERM,
@@ -73,10 +97,15 @@ const ALT = seq([
73
97
  litD(")"),
74
98
  REPEAT,
75
99
  DISCARD,
76
- LOOK_AHEAD,
77
- ], "alt");
78
- const RULE_XF = hoist(seq([stringD("=>"), WS1, alt([SYM, RULE_REF, STRING]), WS1], "xform"));
79
- const RULE = seq([
100
+ LOOK_AHEAD
101
+ ],
102
+ "alt"
103
+ );
104
+ const RULE_XF = hoist(
105
+ seq([stringD("=>"), WS1, alt([SYM, RULE_REF, STRING]), WS1], "xform")
106
+ );
107
+ const RULE = seq(
108
+ [
80
109
  WS0,
81
110
  SYM,
82
111
  WS0,
@@ -84,204 +113,231 @@ const RULE = seq([
84
113
  oneOrMore(alt([TERM, ALT, WS1]), "body"),
85
114
  maybe(RULE_XF),
86
115
  litD(";"),
87
- WS0,
88
- ], "rule");
116
+ WS0
117
+ ],
118
+ "rule"
119
+ );
89
120
  const COMMENT = seqD([WS0, litD("#"), lookahead(always(), DNL)]);
90
- export const GRAMMAR = zeroOrMore(alt([RULE, COMMENT]), "rules");
121
+ const GRAMMAR = zeroOrMore(alt([RULE, COMMENT]), "rules");
91
122
  const first = ($) => $.children[0];
92
123
  const nth = ($, n) => $.children[n];
93
- const compile = defmulti((scope) => scope.id, {
94
- unicode: "char",
95
- }, {
124
+ const compile = defmulti(
125
+ (scope) => scope.id,
126
+ {
127
+ unicode: "char"
128
+ },
129
+ {
96
130
  [DEFAULT]: ($) => unsupported(`unknown op: ${$.id}`),
97
131
  root: ($, lang, opts, flags) => {
98
- const rules = first($).children;
99
- rules.reduce((acc, r) => ((acc[first(r).result] = dynamic()), acc), lang.rules);
100
- for (let r of rules) {
101
- const id = first(r).result;
102
- lang.rules[id].set(compile(r, lang, opts, flags));
103
- }
104
- return lang;
132
+ const rules = first($).children;
133
+ rules.reduce(
134
+ (acc, r) => (acc[first(r).result] = dynamic(), acc),
135
+ lang.rules
136
+ );
137
+ for (let r of rules) {
138
+ const id = first(r).result;
139
+ lang.rules[id].set(
140
+ compile(r, lang, opts, flags)
141
+ );
142
+ }
143
+ return lang;
105
144
  },
106
145
  rule: ($, lang, opts, flags) => {
107
- const [id, body, xf] = $.children;
108
- opts.debug && console.log(`rule: ${id.result}`, xf);
109
- const acc = [];
110
- for (let b of body.children) {
111
- const c = compile(b, lang, opts, flags);
112
- c && acc.push(c);
113
- }
114
- let parser = acc.length > 1
115
- ? seq(acc, id.result)
116
- : withID(id.result, acc[0]);
117
- if (xf.id === "sym") {
118
- const $xf = lang.env[xf.result];
119
- if (!$xf)
120
- illegalArgs(`missing xform: ${xf.result}`);
121
- parser = xform(parser, $xf);
122
- }
123
- else if (xf.id === "ref") {
124
- const $id = first(xf).result;
125
- if ($id === id)
126
- illegalArgs(`self-referential: ${$id}`);
127
- const $xf = lang.rules[$id];
128
- if (!$xf)
129
- illegalArgs(`missing xform rule: ${$id}`);
130
- parser = nest(parser, $xf);
131
- }
132
- else if (xf.id === "string") {
133
- parser = xform(parser, xfReplace(xf.result));
134
- }
135
- return parser;
146
+ const [id, body, xf] = $.children;
147
+ opts.debug && console.log(`rule: ${id.result}`, xf);
148
+ const acc = [];
149
+ for (let b of body.children) {
150
+ const c = compile(b, lang, opts, flags);
151
+ c && acc.push(c);
152
+ }
153
+ let parser = acc.length > 1 ? seq(acc, id.result) : withID(id.result, acc[0]);
154
+ if (xf.id === "sym") {
155
+ const $xf = lang.env[xf.result];
156
+ if (!$xf)
157
+ illegalArgs(`missing xform: ${xf.result}`);
158
+ parser = xform(parser, $xf);
159
+ } else if (xf.id === "ref") {
160
+ const $id = first(xf).result;
161
+ if ($id === id)
162
+ illegalArgs(`self-referential: ${$id}`);
163
+ const $xf = lang.rules[$id];
164
+ if (!$xf)
165
+ illegalArgs(`missing xform rule: ${$id}`);
166
+ parser = nest(parser, $xf);
167
+ } else if (xf.id === "string") {
168
+ parser = xform(parser, xfReplace(xf.result));
169
+ }
170
+ return parser;
136
171
  },
137
172
  ref: ($, lang, opts, flags) => {
138
- const id = first($).result;
139
- opts.debug && console.log(`ref: ${id}`, flags);
140
- const ref = lang.rules[id];
141
- return ref
142
- ? flags.discard
143
- ? discard(ref)
144
- : ref
145
- : illegalArgs(`invalid rule ref: ${id}`);
173
+ const id = first($).result;
174
+ opts.debug && console.log(`ref: ${id}`, flags);
175
+ const ref = lang.rules[id];
176
+ return ref ? flags.discard ? discard(ref) : ref : illegalArgs(`invalid rule ref: ${id}`);
146
177
  },
147
178
  term: ($, lang, opts, flags) => {
148
- const [term, repeat, discard, lookahead] = $.children;
149
- opts.debug && console.log(`term: ${term.id}`, flags);
150
- return compileRDL((discard) => compile(term, lang, opts, { ...flags, discard }), repeat, discard, lookahead, lang, opts);
179
+ const [term, repeat2, discard2, lookahead2] = $.children;
180
+ opts.debug && console.log(`term: ${term.id}`, flags);
181
+ return compileRDL(
182
+ (discard3) => compile(term, lang, opts, { ...flags, discard: discard3 }),
183
+ repeat2,
184
+ discard2,
185
+ lookahead2,
186
+ lang,
187
+ opts
188
+ );
151
189
  },
152
190
  lhterm: ($, lang, opts, flags) => {
153
- const [term, repeat, discard] = $.children;
154
- opts.debug && console.log(`lhterm: ${term.id}`);
155
- return compileRD((discard) => compile(term, lang, opts, { ...flags, discard }), repeat, discard, opts);
191
+ const [term, repeat2, discard2] = $.children;
192
+ opts.debug && console.log(`lhterm: ${term.id}`);
193
+ return compileRD(
194
+ (discard3) => compile(term, lang, opts, { ...flags, discard: discard3 }),
195
+ repeat2,
196
+ discard2,
197
+ opts
198
+ );
156
199
  },
157
200
  alt: ($, lang, opts, flags) => {
158
- opts.debug && console.log(`alt: ${$.id}`, flags);
159
- const [term0, { children: terms }, repeat, disc, lookahead] = $.children;
160
- const acc = [compile(term0, lang, opts, flags)];
161
- if (terms) {
162
- for (let c of terms) {
163
- acc.push(compile(first(c), lang, opts, flags));
164
- }
201
+ opts.debug && console.log(`alt: ${$.id}`, flags);
202
+ const [term0, { children: terms }, repeat2, disc, lookahead2] = $.children;
203
+ const acc = [compile(term0, lang, opts, flags)];
204
+ if (terms) {
205
+ for (let c of terms) {
206
+ acc.push(compile(first(c), lang, opts, flags));
165
207
  }
166
- return compileRDL((optimize) => optimize || flags.discard
167
- ? acc.length > 1
168
- ? altD(acc)
169
- : discard(acc[0])
170
- : acc.length > 1
171
- ? alt(acc)
172
- : acc[0], repeat, disc, lookahead, lang, opts);
208
+ }
209
+ return compileRDL(
210
+ (optimize) => optimize || flags.discard ? acc.length > 1 ? altD(acc) : discard(acc[0]) : acc.length > 1 ? alt(acc) : acc[0],
211
+ repeat2,
212
+ disc,
213
+ lookahead2,
214
+ lang,
215
+ opts
216
+ );
173
217
  },
174
218
  any: (_, __, opts, flags) => {
175
- opts.debug && console.log(`any`, flags);
176
- return flags.discard ? alwaysD() : always("any");
219
+ opts.debug && console.log(`any`, flags);
220
+ return flags.discard ? alwaysD() : always("any");
177
221
  },
178
222
  char: ($, _, opts, flags) => {
179
- const x = $.result;
180
- opts.debug && console.log(`lit: '${x}'`, flags);
181
- return (flags.discard ? litD : lit)(x);
223
+ const x = $.result;
224
+ opts.debug && console.log(`lit: '${x}'`, flags);
225
+ return (flags.discard ? litD : lit)(x);
182
226
  },
183
227
  string: ($, _, opts, flags) => {
184
- const x = $.result;
185
- opts.debug && console.log(`string: "${x}"`, flags);
186
- return (flags.discard ? stringD : string)(x);
228
+ const x = $.result;
229
+ opts.debug && console.log(`string: "${x}"`, flags);
230
+ return (flags.discard ? stringD : string)(x);
187
231
  },
188
232
  charRange: ($, _, opts, flags) => {
189
- const [a, b] = $.children;
190
- opts.debug &&
191
- console.log(`range: ${a.result} - ${b.result}`, flags);
192
- return (flags.discard ? rangeD : range)(a.result, b.result);
233
+ const [a, b] = $.children;
234
+ opts.debug && console.log(`range: ${a.result} - ${b.result}`, flags);
235
+ return (flags.discard ? rangeD : range)(a.result, b.result);
193
236
  },
194
237
  charSel: ($, lang, opts, flags) => {
195
- opts.debug && console.log("charSel", flags);
196
- const choices = nth($, 1).children.map((c) => compile(c, lang, opts, flags));
197
- const invert = first($).result;
198
- const parser = choices.length > 1 ? alt(choices) : choices[0];
199
- opts.debug && console.log(`invert: ${invert}`);
200
- return invert
201
- ? not(parser, flags.discard ? alwaysD() : always())
202
- : parser;
203
- },
204
- });
205
- const compileRepeat = (parser, rspec, opts) => {
206
- opts.debug && console.log(`repeat: ${rspec.id}`);
207
- if (rspec.id === "repeat") {
208
- switch (rspec.result) {
209
- case "?":
210
- return maybe(parser);
211
- case "*":
212
- return zeroOrMore(parser);
213
- case "+":
214
- return oneOrMore(parser);
215
- default:
216
- return parser;
217
- }
238
+ opts.debug && console.log("charSel", flags);
239
+ const choices = nth($, 1).children.map(
240
+ (c) => compile(c, lang, opts, flags)
241
+ );
242
+ const invert = first($).result;
243
+ const parser = choices.length > 1 ? alt(choices) : choices[0];
244
+ opts.debug && console.log(`invert: ${invert}`);
245
+ return invert ? not(parser, flags.discard ? alwaysD() : always()) : parser;
218
246
  }
219
- else if (rspec.id === "repeatN") {
220
- const [n, sep, m] = rspec.result;
221
- return repeat(parser, n, sep ? m || Infinity : m || n);
247
+ }
248
+ );
249
+ const compileRepeat = (parser, rspec, opts) => {
250
+ opts.debug && console.log(`repeat: ${rspec.id}`);
251
+ if (rspec.id === "repeat") {
252
+ switch (rspec.result) {
253
+ case "?":
254
+ return maybe(parser);
255
+ case "*":
256
+ return zeroOrMore(parser);
257
+ case "+":
258
+ return oneOrMore(parser);
259
+ default:
260
+ return parser;
222
261
  }
223
- return parser;
262
+ } else if (rspec.id === "repeatN") {
263
+ const [n, sep, m] = rspec.result;
264
+ return repeat(parser, n, sep ? m || Infinity : m || n);
265
+ }
266
+ return parser;
224
267
  };
225
268
  const compileDiscard = (parser, dspec, opts) => {
226
- opts.debug && console.log(`discard:`, dspec.result);
227
- return dspec.result === "!" ? discard(parser) : parser;
269
+ opts.debug && console.log(`discard:`, dspec.result);
270
+ return dspec.result === "!" ? discard(parser) : parser;
228
271
  };
229
272
  const compileLookahead = (parser, spec, lang, opts) => {
230
- opts.debug && console.log(`lookahead:`, spec.id);
231
- return spec.id === "lhspec"
232
- ? lookahead(parser, compile(nth(spec, 1), lang, opts, {}), first(spec).result === "+")
233
- : parser;
273
+ opts.debug && console.log(`lookahead:`, spec.id);
274
+ return spec.id === "lhspec" ? lookahead(
275
+ parser,
276
+ compile(nth(spec, 1), lang, opts, {}),
277
+ first(spec).result === "+"
278
+ ) : parser;
234
279
  };
235
- const compileRD = (parser, rspec, dspec, opts) => dspec.result != null && rspec.result == null
236
- ? parser(true)
237
- : compileDiscard(compileRepeat(parser(false), rspec, opts), dspec, opts);
280
+ const compileRD = (parser, rspec, dspec, opts) => dspec.result != null && rspec.result == null ? parser(true) : compileDiscard(
281
+ compileRepeat(parser(false), rspec, opts),
282
+ dspec,
283
+ opts
284
+ );
238
285
  const compileRDL = (parser, rspec, dspec, lhspec, lang, opts) => compileLookahead(compileRD(parser, rspec, dspec, opts), lhspec, lang, opts);
239
- export const defGrammar = (rules, env, opts) => {
240
- opts = { debug: false, optimize: true, ...opts };
241
- env = {
242
- binary: xfInt(2),
243
- collect: xfCollect,
244
- count: xfCount,
245
- discard: xfDiscard,
246
- float: xfFloat,
247
- hex: xfInt(16),
248
- hoist: xfHoist,
249
- hoistR: xfHoistResult,
250
- int: xfInt(10),
251
- join: xfJoin,
252
- json: xfJson,
253
- print: xfPrint(),
254
- trim: xfTrim,
255
- ...env,
256
- };
257
- const ctx = defContext(rules);
258
- const result = (opts.debug ? print(GRAMMAR) : GRAMMAR)(ctx);
259
- if (result) {
260
- return compile(ctx.root, {
261
- env,
262
- grammar: ctx,
263
- rules: {
264
- ALPHA_NUM,
265
- ALPHA,
266
- BIT,
267
- DIGIT,
268
- DNL,
269
- END: inputEnd,
270
- ESC,
271
- FLOAT,
272
- HEX_DIGIT,
273
- INT,
274
- LEND: lineEnd,
275
- LSTART: lineStart,
276
- NL,
277
- START: inputStart,
278
- STRING,
279
- UNICODE,
280
- WB: wordBoundary,
281
- WS,
282
- WS0,
283
- WS1,
284
- },
285
- }, opts, {});
286
- }
286
+ const defGrammar = (rules, env, opts) => {
287
+ opts = { debug: false, optimize: true, ...opts };
288
+ env = {
289
+ binary: xfInt(2),
290
+ collect: xfCollect,
291
+ count: xfCount,
292
+ discard: xfDiscard,
293
+ float: xfFloat,
294
+ hex: xfInt(16),
295
+ hoist: xfHoist,
296
+ hoistR: xfHoistResult,
297
+ int: xfInt(10),
298
+ join: xfJoin,
299
+ json: xfJson,
300
+ print: xfPrint(),
301
+ trim: xfTrim,
302
+ ...env
303
+ };
304
+ const ctx = defContext(rules);
305
+ const result = (opts.debug ? print(GRAMMAR) : GRAMMAR)(ctx);
306
+ if (result) {
307
+ return compile(
308
+ ctx.root,
309
+ {
310
+ env,
311
+ grammar: ctx,
312
+ rules: {
313
+ ALPHA_NUM,
314
+ ALPHA,
315
+ BIT,
316
+ DIGIT,
317
+ DNL,
318
+ END: inputEnd,
319
+ ESC,
320
+ FLOAT,
321
+ HEX_DIGIT,
322
+ INT,
323
+ LEND: lineEnd,
324
+ LSTART: lineStart,
325
+ NL,
326
+ START: inputStart,
327
+ STRING,
328
+ UNICODE,
329
+ WB: wordBoundary,
330
+ WS,
331
+ WS0,
332
+ WS1
333
+ }
334
+ },
335
+ opts,
336
+ {}
337
+ );
338
+ }
339
+ };
340
+ export {
341
+ GRAMMAR,
342
+ defGrammar
287
343
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/parse",
3
- "version": "2.4.9",
3
+ "version": "2.4.11",
4
4
  "description": "Purely functional parser combinators & AST generation for generic inputs",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -24,7 +24,9 @@
24
24
  "author": "Karsten Schmidt (https://thi.ng)",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && tsc --declaration",
27
+ "build": "yarn build:esbuild && yarn build:decl",
28
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
29
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
28
30
  "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc combinators presets prims readers xform",
29
31
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
@@ -33,14 +35,15 @@
33
35
  "test": "bun test"
34
36
  },
35
37
  "dependencies": {
36
- "@thi.ng/api": "^8.9.11",
37
- "@thi.ng/checks": "^3.4.11",
38
- "@thi.ng/defmulti": "^3.0.9",
39
- "@thi.ng/errors": "^2.4.5",
40
- "@thi.ng/strings": "^3.7.2"
38
+ "@thi.ng/api": "^8.9.13",
39
+ "@thi.ng/checks": "^3.4.13",
40
+ "@thi.ng/defmulti": "^3.0.11",
41
+ "@thi.ng/errors": "^2.4.7",
42
+ "@thi.ng/strings": "^3.7.4"
41
43
  },
42
44
  "devDependencies": {
43
45
  "@microsoft/api-extractor": "^7.38.3",
46
+ "esbuild": "^0.19.8",
44
47
  "rimraf": "^5.0.5",
45
48
  "tools": "^0.0.1",
46
49
  "typedoc": "^0.25.4",
@@ -66,7 +69,7 @@
66
69
  "access": "public"
67
70
  },
68
71
  "engines": {
69
- "node": ">=12.7"
72
+ "node": ">=18"
70
73
  },
71
74
  "files": [
72
75
  "./*.js",
@@ -239,5 +242,5 @@
239
242
  ],
240
243
  "year": 2020
241
244
  },
242
- "gitHead": "25f2ac8ff795a432a930119661b364d4d93b59a0\n"
245
+ "gitHead": "25a42a81fac8603a1e440a7aa8bc343276211ff4\n"
243
246
  }
package/presets/alpha.js CHANGED
@@ -1,19 +1,16 @@
1
- import { ALPHA as _ALPHA, ALPHA_NUM as _ALPHA_NUM, } from "@thi.ng/strings/groups";
1
+ import {
2
+ ALPHA as _ALPHA,
3
+ ALPHA_NUM as _ALPHA_NUM
4
+ } from "@thi.ng/strings/groups";
2
5
  import { oneOf } from "../prims/one-of.js";
3
6
  import { range } from "../prims/range.js";
4
- /**
5
- * Matches single char in `a` - `z` range.
6
- */
7
- export const LOWER_CASE = range("a", "z");
8
- /**
9
- * Matches single char in `A` - `Z` range.
10
- */
11
- export const UPPER_CASE = range("A", "Z");
12
- /**
13
- * Matches single in {@link LOWER_CASE} or {@link UPPER_CASE}.
14
- */
15
- export const ALPHA = oneOf(_ALPHA);
16
- /**
17
- * Matches single in {@link ALPHA} or {@link DIGIT}.
18
- */
19
- export const ALPHA_NUM = oneOf(_ALPHA_NUM);
7
+ const LOWER_CASE = range("a", "z");
8
+ const UPPER_CASE = range("A", "Z");
9
+ const ALPHA = oneOf(_ALPHA);
10
+ const ALPHA_NUM = oneOf(_ALPHA_NUM);
11
+ export {
12
+ ALPHA,
13
+ ALPHA_NUM,
14
+ LOWER_CASE,
15
+ UPPER_CASE
16
+ };
package/presets/bits.js CHANGED
@@ -2,5 +2,9 @@ import { repeat } from "../combinators/repeat.js";
2
2
  import { xform } from "../combinators/xform.js";
3
3
  import { oneOf } from "../prims/one-of.js";
4
4
  import { xfInt } from "../xform/number.js";
5
- export const BIT = oneOf("01");
6
- export const BINARY_UINT = xform(repeat(BIT, 1, 32, "uint"), xfInt(2));
5
+ const BIT = oneOf("01");
6
+ const BINARY_UINT = xform(repeat(BIT, 1, 32, "uint"), xfInt(2));
7
+ export {
8
+ BINARY_UINT,
9
+ BIT
10
+ };
package/presets/digits.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import { oneOrMore } from "../combinators/repeat.js";
2
2
  import { range } from "../prims/range.js";
3
- /**
4
- * Matches single decimal digit.
5
- */
6
- export const DIGIT = range("0", "9", "digit");
7
- /**
8
- * Matches one or more {@link DIGIT}s.
9
- */
10
- export const DIGITS = oneOrMore(DIGIT);
3
+ const DIGIT = range("0", "9", "digit");
4
+ const DIGITS = oneOrMore(DIGIT);
5
+ export {
6
+ DIGIT,
7
+ DIGITS
8
+ };
package/presets/escape.js CHANGED
@@ -7,15 +7,18 @@ import { litD } from "../prims/lit.js";
7
7
  import { stringD } from "../prims/string.js";
8
8
  import { xfInt } from "../xform/number.js";
9
9
  import { HEX_DIGIT } from "./hex.js";
10
- export const ESC = xform(seq([litD("\\"), always()], "esc"), ($) => {
11
- const id = $.children[0].result;
12
- const resolved = ESCAPES[id];
13
- $.result = resolved !== undefined ? resolved : `\\${id}`;
14
- $.children = null;
15
- return $;
10
+ const ESC = xform(seq([litD("\\"), always()], "esc"), ($) => {
11
+ const id = $.children[0].result;
12
+ const resolved = ESCAPES[id];
13
+ $.result = resolved !== void 0 ? resolved : `\\${id}`;
14
+ $.children = null;
15
+ return $;
16
16
  });
17
- /**
18
- * Matches a single `\uNNNN` escaped unicode hex literal and transforms
19
- * it into it actual character via `String.fromCharCode()`.
20
- */
21
- export const UNICODE = xform(seq([stringD("\\u"), repeat(HEX_DIGIT, 4, 4)], "unicode"), ($, ctx) => (($.result = String.fromCharCode(xfInt(16)($, ctx).result)), $));
17
+ const UNICODE = xform(
18
+ seq([stringD("\\u"), repeat(HEX_DIGIT, 4, 4)], "unicode"),
19
+ ($, ctx) => ($.result = String.fromCharCode(xfInt(16)($, ctx).result), $)
20
+ );
21
+ export {
22
+ ESC,
23
+ UNICODE
24
+ };