@thi.ng/parse 1.0.4 → 2.0.3
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/CHANGELOG.md +85 -137
- package/README.md +15 -6
- package/api.d.ts +1 -1
- package/combinators/alt.d.ts +1 -1
- package/combinators/alt.js +1 -1
- package/combinators/boundary.d.ts +1 -1
- package/combinators/boundary.js +2 -2
- package/combinators/check.d.ts +1 -1
- package/combinators/check.js +2 -2
- package/combinators/dynamic.d.ts +1 -1
- package/combinators/expect.d.ts +1 -1
- package/combinators/expect.js +1 -1
- package/combinators/lookahead.d.ts +1 -1
- package/combinators/lookahead.js +1 -1
- package/combinators/maybe.d.ts +1 -1
- package/combinators/maybe.js +1 -1
- package/combinators/not.d.ts +1 -1
- package/combinators/not.js +1 -1
- package/combinators/repeat.d.ts +1 -1
- package/combinators/repeat.js +1 -1
- package/combinators/seq.d.ts +1 -1
- package/combinators/seq.js +1 -1
- package/combinators/wrap.d.ts +1 -1
- package/combinators/wrap.js +3 -3
- package/combinators/xform.d.ts +1 -1
- package/context.d.ts +1 -1
- package/context.js +8 -7
- package/error.d.ts +1 -1
- package/error.js +1 -1
- package/grammar.d.ts +1 -1
- package/grammar.js +65 -48
- package/index.d.ts +49 -49
- package/index.js +49 -49
- package/package.json +183 -31
- package/presets/alpha.d.ts +4 -4
- package/presets/alpha.js +3 -3
- package/presets/bits.d.ts +2 -2
- package/presets/bits.js +4 -4
- package/presets/digits.d.ts +2 -2
- package/presets/digits.js +2 -2
- package/presets/escape.d.ts +2 -2
- package/presets/escape.js +9 -9
- package/presets/hex.d.ts +3 -3
- package/presets/hex.js +5 -5
- package/presets/numbers.d.ts +5 -5
- package/presets/numbers.js +12 -12
- package/presets/string.d.ts +1 -1
- package/presets/string.js +7 -7
- package/presets/whitespace.d.ts +8 -8
- package/presets/whitespace.js +3 -3
- package/prims/always.d.ts +2 -2
- package/prims/always.js +1 -1
- package/prims/anchor.d.ts +1 -1
- package/prims/anchor.js +1 -1
- package/prims/fail.d.ts +1 -1
- package/prims/fail.js +1 -1
- package/prims/lit.d.ts +2 -2
- package/prims/lit.js +1 -1
- package/prims/none-of.d.ts +1 -1
- package/prims/none-of.js +3 -2
- package/prims/one-of.d.ts +1 -1
- package/prims/one-of.js +3 -2
- package/prims/pass.d.ts +1 -1
- package/prims/pass.js +1 -1
- package/prims/range.d.ts +1 -1
- package/prims/range.js +1 -1
- package/prims/satisfy.d.ts +1 -1
- package/prims/skip.d.ts +1 -1
- package/prims/skip.js +1 -1
- package/prims/string.d.ts +1 -1
- package/prims/string.js +2 -2
- package/readers/array-reader.d.ts +1 -1
- package/readers/string-reader.d.ts +1 -1
- package/utils.js +1 -0
- package/xform/collect.d.ts +1 -1
- package/xform/collect.js +1 -1
- package/xform/comp.d.ts +1 -1
- package/xform/count.d.ts +1 -1
- package/xform/count.js +1 -1
- package/xform/discard.d.ts +1 -1
- package/xform/discard.js +1 -1
- package/xform/hoist.d.ts +1 -1
- package/xform/hoist.js +1 -1
- package/xform/join.d.ts +1 -1
- package/xform/join.js +1 -1
- package/xform/nest.d.ts +1 -1
- package/xform/nest.js +4 -4
- package/xform/number.d.ts +1 -1
- package/xform/number.js +1 -1
- package/xform/print.d.ts +1 -1
- package/xform/print.js +2 -2
- package/xform/replace.d.ts +1 -1
- package/xform/replace.js +1 -1
- package/xform/trim.d.ts +1 -1
- package/xform/trim.js +1 -1
- package/xform/with-id.d.ts +1 -1
- package/xform/with-id.js +1 -1
- package/lib/index.js +0 -967
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
package/presets/bits.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const BIT: import("
|
|
2
|
-
export declare const BINARY_UINT: import("
|
|
1
|
+
export declare const BIT: import("../api.js").LitParser<string>;
|
|
2
|
+
export declare const BINARY_UINT: import("../api.js").Parser<string>;
|
|
3
3
|
//# sourceMappingURL=bits.d.ts.map
|
package/presets/bits.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { repeat } from "../combinators/repeat";
|
|
2
|
-
import { xform } from "../combinators/xform";
|
|
3
|
-
import { oneOf } from "../prims/one-of";
|
|
4
|
-
import { xfInt } from "../xform/number";
|
|
1
|
+
import { repeat } from "../combinators/repeat.js";
|
|
2
|
+
import { xform } from "../combinators/xform.js";
|
|
3
|
+
import { oneOf } from "../prims/one-of.js";
|
|
4
|
+
import { xfInt } from "../xform/number.js";
|
|
5
5
|
export const BIT = oneOf("01");
|
|
6
6
|
export const BINARY_UINT = xform(repeat(BIT, 1, 32, "uint"), xfInt(2));
|
package/presets/digits.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Matches single decimal digit.
|
|
3
3
|
*/
|
|
4
|
-
export declare const DIGIT: import("
|
|
4
|
+
export declare const DIGIT: import("../api.js").LitParser<string>;
|
|
5
5
|
/**
|
|
6
6
|
* Matches one or more {@link DIGIT}s.
|
|
7
7
|
*/
|
|
8
|
-
export declare const DIGITS: import("
|
|
8
|
+
export declare const DIGITS: import("../api.js").Parser<string>;
|
|
9
9
|
//# sourceMappingURL=digits.d.ts.map
|
package/presets/digits.js
CHANGED
package/presets/escape.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare const ESC: import("
|
|
1
|
+
export declare const ESC: import("../api.js").Parser<string>;
|
|
2
2
|
/**
|
|
3
3
|
* Matches a single `\uNNNN` escaped unicode hex literal and transforms
|
|
4
4
|
* it into it actual character via `String.fromCharCode()`.
|
|
5
5
|
*/
|
|
6
|
-
export declare const UNICODE: import("
|
|
6
|
+
export declare const UNICODE: import("../api.js").Parser<string>;
|
|
7
7
|
//# sourceMappingURL=escape.d.ts.map
|
package/presets/escape.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ESCAPES } from "@thi.ng/strings";
|
|
2
|
-
import { repeat } from "../combinators/repeat";
|
|
3
|
-
import { seq } from "../combinators/seq";
|
|
4
|
-
import { xform } from "../combinators/xform";
|
|
5
|
-
import { always } from "../prims/always";
|
|
6
|
-
import { litD } from "../prims/lit";
|
|
7
|
-
import { stringD } from "../prims/string";
|
|
8
|
-
import { xfInt } from "../xform/number";
|
|
9
|
-
import { HEX_DIGIT } from "./hex";
|
|
1
|
+
import { ESCAPES } from "@thi.ng/strings/escape";
|
|
2
|
+
import { repeat } from "../combinators/repeat.js";
|
|
3
|
+
import { seq } from "../combinators/seq.js";
|
|
4
|
+
import { xform } from "../combinators/xform.js";
|
|
5
|
+
import { always } from "../prims/always.js";
|
|
6
|
+
import { litD } from "../prims/lit.js";
|
|
7
|
+
import { stringD } from "../prims/string.js";
|
|
8
|
+
import { xfInt } from "../xform/number.js";
|
|
9
|
+
import { HEX_DIGIT } from "./hex.js";
|
|
10
10
|
export const ESC = xform(seq([litD("\\"), always()], "esc"), ($) => {
|
|
11
11
|
const id = $.children[0].result;
|
|
12
12
|
const resolved = ESCAPES[id];
|
package/presets/hex.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Matches single hex digit (case insensitive).
|
|
3
3
|
*/
|
|
4
|
-
export declare const HEX_DIGIT: import("
|
|
4
|
+
export declare const HEX_DIGIT: import("../api.js").LitParser<string>;
|
|
5
5
|
/**
|
|
6
6
|
* Matches one or more {@link HEX_DIGIT}s.
|
|
7
7
|
*/
|
|
8
|
-
export declare const HEX_DIGITS: import("
|
|
8
|
+
export declare const HEX_DIGITS: import("../api.js").Parser<string>;
|
|
9
9
|
/**
|
|
10
10
|
* Matches 1-8 successive {@link HEX_DIGIT} and transforms with
|
|
11
11
|
* {@link xfInt} to JS number.
|
|
12
12
|
*/
|
|
13
|
-
export declare const HEX_UINT: import("
|
|
13
|
+
export declare const HEX_UINT: import("../api.js").Parser<string>;
|
|
14
14
|
//# sourceMappingURL=hex.d.ts.map
|
package/presets/hex.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { HEX } from "@thi.ng/strings";
|
|
2
|
-
import { oneOrMore, repeat } from "../combinators/repeat";
|
|
3
|
-
import { xform } from "../combinators/xform";
|
|
4
|
-
import { oneOf } from "../prims/one-of";
|
|
5
|
-
import { xfInt } from "../xform/number";
|
|
1
|
+
import { HEX } from "@thi.ng/strings/groups";
|
|
2
|
+
import { oneOrMore, repeat } from "../combinators/repeat.js";
|
|
3
|
+
import { xform } from "../combinators/xform.js";
|
|
4
|
+
import { oneOf } from "../prims/one-of.js";
|
|
5
|
+
import { xfInt } from "../xform/number.js";
|
|
6
6
|
/**
|
|
7
7
|
* Matches single hex digit (case insensitive).
|
|
8
8
|
*/
|
package/presets/numbers.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Matches single `+` or `-` char.
|
|
3
3
|
*/
|
|
4
|
-
export declare const SIGN: import("
|
|
4
|
+
export declare const SIGN: import("../api.js").Parser<string>;
|
|
5
5
|
/**
|
|
6
6
|
* Matches optionally signed {@link DIGITS} and result transformed w/
|
|
7
7
|
* {@link xfInt} to JS number.
|
|
8
8
|
*/
|
|
9
|
-
export declare const INT: import("
|
|
9
|
+
export declare const INT: import("../api.js").Parser<string>;
|
|
10
10
|
/**
|
|
11
11
|
* Matches same as {@link DIGITS} but result transformed w/
|
|
12
12
|
* {@link xfInt} to JS number.
|
|
13
13
|
*/
|
|
14
|
-
export declare const UINT: import("
|
|
14
|
+
export declare const UINT: import("../api.js").Parser<string>;
|
|
15
15
|
/**
|
|
16
16
|
* Matches IEEE754 floating point number.
|
|
17
17
|
*/
|
|
18
|
-
export declare const REAL: import("
|
|
18
|
+
export declare const REAL: import("../api.js").Parser<string>;
|
|
19
19
|
/**
|
|
20
20
|
* Like {@link REAL} but transforms result w/ {@link xfFloat} to JS
|
|
21
21
|
* number.
|
|
22
22
|
*/
|
|
23
|
-
export declare const FLOAT: import("
|
|
23
|
+
export declare const FLOAT: import("../api.js").Parser<string>;
|
|
24
24
|
//# sourceMappingURL=numbers.d.ts.map
|
package/presets/numbers.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { alt } from "../combinators/alt";
|
|
2
|
-
import { maybe } from "../combinators/maybe";
|
|
3
|
-
import { zeroOrMore } from "../combinators/repeat";
|
|
4
|
-
import { seq } from "../combinators/seq";
|
|
5
|
-
import { xform } from "../combinators/xform";
|
|
6
|
-
import { lit } from "../prims/lit";
|
|
7
|
-
import { oneOf } from "../prims/one-of";
|
|
8
|
-
import { comp } from "../xform/comp";
|
|
9
|
-
import { join } from "../xform/join";
|
|
10
|
-
import { xfFloat, xfInt } from "../xform/number";
|
|
11
|
-
import { xfID } from "../xform/with-id";
|
|
12
|
-
import { DIGIT, DIGITS } from "./digits";
|
|
1
|
+
import { alt } from "../combinators/alt.js";
|
|
2
|
+
import { maybe } from "../combinators/maybe.js";
|
|
3
|
+
import { zeroOrMore } from "../combinators/repeat.js";
|
|
4
|
+
import { seq } from "../combinators/seq.js";
|
|
5
|
+
import { xform } from "../combinators/xform.js";
|
|
6
|
+
import { lit } from "../prims/lit.js";
|
|
7
|
+
import { oneOf } from "../prims/one-of.js";
|
|
8
|
+
import { comp } from "../xform/comp.js";
|
|
9
|
+
import { join } from "../xform/join.js";
|
|
10
|
+
import { xfFloat, xfInt } from "../xform/number.js";
|
|
11
|
+
import { xfID } from "../xform/with-id.js";
|
|
12
|
+
import { DIGIT, DIGITS } from "./digits.js";
|
|
13
13
|
/**
|
|
14
14
|
* Matches single `+` or `-` char.
|
|
15
15
|
*/
|
package/presets/string.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const STRING: import("
|
|
1
|
+
export declare const STRING: import("../api.js").Parser<string>;
|
|
2
2
|
//# sourceMappingURL=string.d.ts.map
|
package/presets/string.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { alt } from "../combinators/alt";
|
|
2
|
-
import { zeroOrMore } from "../combinators/repeat";
|
|
3
|
-
import { seq } from "../combinators/seq";
|
|
4
|
-
import { litD } from "../prims/lit";
|
|
5
|
-
import { noneOf } from "../prims/none-of";
|
|
6
|
-
import { join } from "../xform/join";
|
|
7
|
-
import { ESC, UNICODE } from "./escape";
|
|
1
|
+
import { alt } from "../combinators/alt.js";
|
|
2
|
+
import { zeroOrMore } from "../combinators/repeat.js";
|
|
3
|
+
import { seq } from "../combinators/seq.js";
|
|
4
|
+
import { litD } from "../prims/lit.js";
|
|
5
|
+
import { noneOf } from "../prims/none-of.js";
|
|
6
|
+
import { join } from "../xform/join.js";
|
|
7
|
+
import { ESC, UNICODE } from "./escape.js";
|
|
8
8
|
const quote = litD('"');
|
|
9
9
|
export const STRING = join(seq([quote, zeroOrMore(alt([UNICODE, ESC, noneOf('"')])), quote], "string"));
|
package/presets/whitespace.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Matches & discards single whitespace char: ` \t\n\r`.
|
|
3
3
|
*/
|
|
4
|
-
export declare const WS: import("
|
|
4
|
+
export declare const WS: import("../api.js").LitParser<string>;
|
|
5
5
|
/**
|
|
6
6
|
* Matches & discards single space or tab char.
|
|
7
7
|
*/
|
|
8
|
-
export declare const SPACE: import("
|
|
8
|
+
export declare const SPACE: import("../api.js").LitParser<string>;
|
|
9
9
|
/**
|
|
10
10
|
* Matches single `\n` or `\r` char.
|
|
11
11
|
*/
|
|
12
|
-
export declare const NL: import("
|
|
12
|
+
export declare const NL: import("../api.js").LitParser<string>;
|
|
13
13
|
/**
|
|
14
14
|
* Matches & discards single `\n` or `\r` char.
|
|
15
15
|
*/
|
|
16
|
-
export declare const DNL: import("
|
|
16
|
+
export declare const DNL: import("../api.js").LitParser<string>;
|
|
17
17
|
/**
|
|
18
18
|
* Zero or more {@link WS}. Result will be discarded.
|
|
19
19
|
*/
|
|
20
|
-
export declare const WS0: import("
|
|
20
|
+
export declare const WS0: import("../api.js").Parser<any>;
|
|
21
21
|
/**
|
|
22
22
|
* One or more {@link WS}. Result will be discarded.
|
|
23
23
|
*/
|
|
24
|
-
export declare const WS1: import("
|
|
24
|
+
export declare const WS1: import("../api.js").Parser<any>;
|
|
25
25
|
/**
|
|
26
26
|
* Zero or more {@link SPACE}. Result will be discarded.
|
|
27
27
|
*/
|
|
28
|
-
export declare const SPACES0: import("
|
|
28
|
+
export declare const SPACES0: import("../api.js").Parser<any>;
|
|
29
29
|
/**
|
|
30
30
|
* One or more {@link SPACE}. Result will be discarded.
|
|
31
31
|
*/
|
|
32
|
-
export declare const SPACES: import("
|
|
32
|
+
export declare const SPACES: import("../api.js").Parser<any>;
|
|
33
33
|
//# sourceMappingURL=whitespace.d.ts.map
|
package/presets/whitespace.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WS as _WS } from "@thi.ng/strings";
|
|
2
|
-
import { oneOrMoreD, zeroOrMoreD } from "../combinators/repeat";
|
|
3
|
-
import { oneOf, oneOfD } from "../prims/one-of";
|
|
1
|
+
import { WS as _WS } from "@thi.ng/strings/groups";
|
|
2
|
+
import { oneOrMoreD, zeroOrMoreD } from "../combinators/repeat.js";
|
|
3
|
+
import { oneOf, oneOfD } from "../prims/one-of.js";
|
|
4
4
|
/**
|
|
5
5
|
* Matches & discards single whitespace char: ` \t\n\r`.
|
|
6
6
|
*/
|
package/prims/always.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const always: (id?: string) => import("
|
|
2
|
-
export declare const alwaysD: () => import("
|
|
1
|
+
export declare const always: (id?: string) => import("../api.js").LitParser<any>;
|
|
2
|
+
export declare const alwaysD: () => import("../api.js").LitParser<any>;
|
|
3
3
|
//# sourceMappingURL=always.d.ts.map
|
package/prims/always.js
CHANGED
package/prims/anchor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Nullable, Predicate2 } from "@thi.ng/api";
|
|
2
|
-
import type { Parser } from "../api";
|
|
2
|
+
import type { Parser } from "../api.js";
|
|
3
3
|
export declare const anchor: <T>(fn: Predicate2<Nullable<T>>) => Parser<T>;
|
|
4
4
|
export declare const inputStart: Parser<any>;
|
|
5
5
|
export declare const inputEnd: Parser<any>;
|
package/prims/anchor.js
CHANGED
package/prims/fail.d.ts
CHANGED
package/prims/fail.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { parseError } from "../error";
|
|
1
|
+
import { parseError } from "../error.js";
|
|
2
2
|
export const fail = (msg) => (ctx) => parseError(ctx, msg);
|
package/prims/lit.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export declare const litP: <T>(c: T) => (x: T) => boolean;
|
|
|
10
10
|
* @param c
|
|
11
11
|
* @param id
|
|
12
12
|
*/
|
|
13
|
-
export declare const lit: <T>(c: T, id?: string) => import("
|
|
13
|
+
export declare const lit: <T>(c: T, id?: string) => import("../api.js").LitParser<T>;
|
|
14
14
|
/**
|
|
15
15
|
* Discarded literal. Same as {@link lit}, but result will be discarded.
|
|
16
16
|
*
|
|
17
17
|
* @param c
|
|
18
18
|
*/
|
|
19
|
-
export declare const litD: <T>(c: T) => import("
|
|
19
|
+
export declare const litD: <T>(c: T) => import("../api.js").LitParser<T>;
|
|
20
20
|
//# sourceMappingURL=lit.d.ts.map
|
package/prims/lit.js
CHANGED
package/prims/none-of.d.ts
CHANGED
package/prims/none-of.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { isPlainObject
|
|
2
|
-
import {
|
|
1
|
+
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
|
|
2
|
+
import { isSet } from "@thi.ng/checks/is-set";
|
|
3
|
+
import { satisfy, satisfyD } from "./satisfy.js";
|
|
3
4
|
/**
|
|
4
5
|
* HOF predicate for matching single char against given options. Returns
|
|
5
6
|
* true if there's no match.
|
package/prims/one-of.d.ts
CHANGED
package/prims/one-of.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { isPlainObject
|
|
2
|
-
import {
|
|
1
|
+
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
|
|
2
|
+
import { isSet } from "@thi.ng/checks/is-set";
|
|
3
|
+
import { satisfy, satisfyD } from "./satisfy.js";
|
|
3
4
|
/**
|
|
4
5
|
* HOF predicate for matching single char against given options.
|
|
5
6
|
*
|
package/prims/pass.d.ts
CHANGED
package/prims/pass.js
CHANGED
package/prims/range.d.ts
CHANGED
package/prims/range.js
CHANGED
package/prims/satisfy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Predicate } from "@thi.ng/api";
|
|
2
|
-
import type { LitParser } from "../api";
|
|
2
|
+
import type { LitParser } from "../api.js";
|
|
3
3
|
export declare const satisfy: <T>(pred: Predicate<T>, id?: string) => LitParser<T>;
|
|
4
4
|
/**
|
|
5
5
|
* Like {@link satisfy}, but avoids creating AST node and discards
|
package/prims/skip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Predicate } from "@thi.ng/api";
|
|
2
|
-
import type { Parser } from "../api";
|
|
2
|
+
import type { Parser } from "../api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Consumes input, but ignores it as long as given `pred` predicate fn
|
|
5
5
|
* returns true. The char for which `pred` fails will NOT be consumed
|
package/prims/skip.js
CHANGED
package/prims/string.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fn, Predicate } from "@thi.ng/api";
|
|
2
|
-
import type { Parser } from "../api";
|
|
2
|
+
import type { Parser } from "../api.js";
|
|
3
3
|
export declare const string: <T>(str: ArrayLike<T>, id?: string) => Parser<T>;
|
|
4
4
|
export declare const stringD: <T>(str: ArrayLike<T>) => Parser<T>;
|
|
5
5
|
export declare const stringOf: <T>(pred: Predicate<T>, id?: string, reduce?: Fn<T[], any>) => Parser<T>;
|
package/prims/string.js
CHANGED
|
@@ -19,7 +19,7 @@ export const string = (str, id = "string") => (ctx) => {
|
|
|
19
19
|
export const stringD = (str) => (ctx) => {
|
|
20
20
|
if (ctx.done)
|
|
21
21
|
return false;
|
|
22
|
-
const state =
|
|
22
|
+
const state = { ...ctx.state };
|
|
23
23
|
const reader = ctx.reader;
|
|
24
24
|
for (let i = 0, n = str.length; i < n; i++) {
|
|
25
25
|
if (state.done)
|
|
@@ -34,7 +34,7 @@ export const stringD = (str) => (ctx) => {
|
|
|
34
34
|
return true;
|
|
35
35
|
};
|
|
36
36
|
export const stringOf = (pred, id = "string", reduce = (x) => x.join("")) => (ctx) => {
|
|
37
|
-
const state =
|
|
37
|
+
const state = { ...ctx.state };
|
|
38
38
|
const reader = ctx.reader;
|
|
39
39
|
let acc = [];
|
|
40
40
|
while (!state.done) {
|
package/utils.js
CHANGED
package/xform/collect.d.ts
CHANGED
package/xform/collect.js
CHANGED
package/xform/comp.d.ts
CHANGED
package/xform/count.d.ts
CHANGED
package/xform/count.js
CHANGED
package/xform/discard.d.ts
CHANGED
package/xform/discard.js
CHANGED
package/xform/hoist.d.ts
CHANGED
package/xform/hoist.js
CHANGED
package/xform/join.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Nullable } from "@thi.ng/api";
|
|
2
|
-
import type { Parser, ParseScope } from "../api";
|
|
2
|
+
import type { Parser, ParseScope } from "../api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Recursively joins non-null results of all children into a single
|
|
5
5
|
* string, then discards children. Also see {@link join}.
|
package/xform/join.js
CHANGED
package/xform/nest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Parser, ScopeTransform } from "../api";
|
|
1
|
+
import type { Parser, ScopeTransform } from "../api.js";
|
|
2
2
|
/**
|
|
3
3
|
* HOF scope transform which applies given parser to result of given scope's
|
|
4
4
|
* result, or if result is null, first joins children using {@link xfJoin}.
|
package/xform/nest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { xform } from "../combinators/xform";
|
|
2
|
-
import { defContext } from "../context";
|
|
3
|
-
import { xfJoin } from "./join";
|
|
1
|
+
import { xform } from "../combinators/xform.js";
|
|
2
|
+
import { defContext } from "../context.js";
|
|
3
|
+
import { xfJoin } from "./join.js";
|
|
4
4
|
/**
|
|
5
5
|
* HOF scope transform which applies given parser to result of given scope's
|
|
6
6
|
* result, or if result is null, first joins children using {@link xfJoin}.
|
|
@@ -19,7 +19,7 @@ import { xfJoin } from "./join";
|
|
|
19
19
|
export const xfNest = (parser) => (scope, ctx) => {
|
|
20
20
|
if (!scope)
|
|
21
21
|
return;
|
|
22
|
-
const src = scope.result || xfJoin(
|
|
22
|
+
const src = scope.result || xfJoin({ ...scope }).result;
|
|
23
23
|
const inner = defContext(src, ctx.opts);
|
|
24
24
|
const state = scope.state;
|
|
25
25
|
if (state) {
|
package/xform/number.d.ts
CHANGED
package/xform/number.js
CHANGED
package/xform/print.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fn } from "@thi.ng/api";
|
|
2
|
-
import type { Parser, ScopeTransform } from "../api";
|
|
2
|
+
import type { Parser, ScopeTransform } from "../api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Side effect only. Higher order scope transform. Traverses current AST
|
|
5
5
|
* node and all children and prints each node's ID, result and reader
|
package/xform/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { xform } from "../combinators/xform";
|
|
2
|
-
import { indent } from "../utils";
|
|
1
|
+
import { xform } from "../combinators/xform.js";
|
|
2
|
+
import { indent } from "../utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Side effect only. Higher order scope transform. Traverses current AST
|
|
5
5
|
* node and all children and prints each node's ID, result and reader
|
package/xform/replace.d.ts
CHANGED
package/xform/replace.js
CHANGED
package/xform/trim.d.ts
CHANGED
package/xform/trim.js
CHANGED