@thi.ng/parse 2.1.2 → 2.1.5
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 +7 -1
- package/README.md +1 -1
- package/combinators/lookahead.d.ts +4 -4
- package/combinators/lookahead.js +4 -4
- package/package.json +11 -11
- package/prims/lit.d.ts +4 -4
- package/prims/lit.js +4 -4
- package/prims/none-of.d.ts +4 -4
- package/prims/none-of.js +1 -1
- package/prims/one-of.d.ts +4 -4
- package/prims/one-of.js +1 -1
- package/prims/range.d.ts +6 -6
- package/prims/range.js +6 -6
- package/prims/satisfy.d.ts +1 -1
- package/prims/satisfy.js +1 -1
- package/prims/skip.d.ts +1 -1
- package/prims/skip.js +1 -1
- package/utils.d.ts +1 -1
- package/utils.js +1 -1
- package/xform/collect.d.ts +2 -2
- package/xform/collect.js +2 -2
- package/xform/comp.d.ts +1 -1
- package/xform/comp.js +1 -1
- package/xform/count.d.ts +2 -2
- package/xform/count.js +2 -2
- package/xform/discard.d.ts +1 -1
- package/xform/discard.js +1 -1
- package/xform/hoist.d.ts +4 -4
- package/xform/hoist.js +4 -4
- package/xform/join.d.ts +2 -2
- package/xform/join.js +2 -2
- package/xform/nest.d.ts +1 -1
- package/xform/nest.js +1 -1
- package/xform/number.d.ts +2 -2
- package/xform/number.js +2 -2
- package/xform/print.d.ts +4 -4
- package/xform/print.js +4 -4
- package/xform/trim.d.ts +2 -2
- package/xform/trim.js +2 -2
- package/xform/with-id.d.ts +1 -1
- package/xform/with-id.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**:
|
|
3
|
+
- **Last updated**: 2022-03-11T12:13:49Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [2.1.5](https://github.com/thi-ng/umbrella/tree/@thi.ng/parse@2.1.5) (2022-03-11)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- add type hint (TS4.6) ([6cd42e8](https://github.com/thi-ng/umbrella/commit/6cd42e8))
|
|
17
|
+
|
|
12
18
|
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/parse@2.1.0) (2021-11-17)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -57,10 +57,10 @@ import type { Parser } from "../api.js";
|
|
|
57
57
|
* // { p: 10, l: 1, c: 11, done: false, last: 'a' }
|
|
58
58
|
* ```
|
|
59
59
|
*
|
|
60
|
-
* @param parser
|
|
61
|
-
* @param ahead
|
|
62
|
-
* @param capture
|
|
63
|
-
* @param id
|
|
60
|
+
* @param parser -
|
|
61
|
+
* @param ahead -
|
|
62
|
+
* @param capture -
|
|
63
|
+
* @param id -
|
|
64
64
|
*/
|
|
65
65
|
export declare const lookahead: <T>(parser: Parser<T>, ahead: Parser<T>, capture?: boolean, id?: string) => Parser<T>;
|
|
66
66
|
//# sourceMappingURL=lookahead.d.ts.map
|
package/combinators/lookahead.js
CHANGED
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
* // { p: 10, l: 1, c: 11, done: false, last: 'a' }
|
|
57
57
|
* ```
|
|
58
58
|
*
|
|
59
|
-
* @param parser
|
|
60
|
-
* @param ahead
|
|
61
|
-
* @param capture
|
|
62
|
-
* @param id
|
|
59
|
+
* @param parser -
|
|
60
|
+
* @param ahead -
|
|
61
|
+
* @param capture -
|
|
62
|
+
* @param id -
|
|
63
63
|
*/
|
|
64
64
|
export const lookahead = (parser, ahead, capture = false, id = "lookahead") => (ctx) => {
|
|
65
65
|
if (ctx.done)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/parse",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Purely functional parser combinators & AST generation for generic inputs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/checks": "^3.1.
|
|
39
|
-
"@thi.ng/defmulti": "^2.1.
|
|
40
|
-
"@thi.ng/errors": "^2.1.
|
|
41
|
-
"@thi.ng/strings": "^3.
|
|
37
|
+
"@thi.ng/api": "^8.3.4",
|
|
38
|
+
"@thi.ng/checks": "^3.1.4",
|
|
39
|
+
"@thi.ng/defmulti": "^2.1.4",
|
|
40
|
+
"@thi.ng/errors": "^2.1.4",
|
|
41
|
+
"@thi.ng/strings": "^3.3.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-extractor": "^7.
|
|
45
|
-
"@thi.ng/testament": "^0.2.
|
|
44
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
45
|
+
"@thi.ng/testament": "^0.2.4",
|
|
46
46
|
"rimraf": "^3.0.2",
|
|
47
47
|
"tools": "^0.0.1",
|
|
48
|
-
"typedoc": "^0.22.
|
|
49
|
-
"typescript": "^4.
|
|
48
|
+
"typedoc": "^0.22.13",
|
|
49
|
+
"typescript": "^4.6.2"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"ast",
|
|
@@ -238,5 +238,5 @@
|
|
|
238
238
|
],
|
|
239
239
|
"year": 2020
|
|
240
240
|
},
|
|
241
|
-
"gitHead": "
|
|
241
|
+
"gitHead": "0fc692a3225c068aacafdc4cb6140cf603c67ad8\n"
|
|
242
242
|
}
|
package/prims/lit.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* HOF predicate for matching given single char literal.
|
|
3
3
|
*
|
|
4
|
-
* @param c
|
|
4
|
+
* @param c -
|
|
5
5
|
*/
|
|
6
6
|
export declare const litP: <T>(c: T) => (x: T) => boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Matches single char/value `c`.
|
|
9
9
|
*
|
|
10
|
-
* @param c
|
|
11
|
-
* @param id
|
|
10
|
+
* @param c -
|
|
11
|
+
* @param id -
|
|
12
12
|
*/
|
|
13
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
|
-
* @param c
|
|
17
|
+
* @param c -
|
|
18
18
|
*/
|
|
19
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
|
@@ -2,19 +2,19 @@ import { satisfyD, satisfy } from "./satisfy.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* HOF predicate for matching given single char literal.
|
|
4
4
|
*
|
|
5
|
-
* @param c
|
|
5
|
+
* @param c -
|
|
6
6
|
*/
|
|
7
7
|
export const litP = (c) => (x) => x === c;
|
|
8
8
|
/**
|
|
9
9
|
* Matches single char/value `c`.
|
|
10
10
|
*
|
|
11
|
-
* @param c
|
|
12
|
-
* @param id
|
|
11
|
+
* @param c -
|
|
12
|
+
* @param id -
|
|
13
13
|
*/
|
|
14
14
|
export const lit = (c, id = "lit") => satisfy(litP(c), id);
|
|
15
15
|
/**
|
|
16
16
|
* Discarded literal. Same as {@link lit}, but result will be discarded.
|
|
17
17
|
*
|
|
18
|
-
* @param c
|
|
18
|
+
* @param c -
|
|
19
19
|
*/
|
|
20
20
|
export const litD = (c) => satisfyD(litP(c));
|
package/prims/none-of.d.ts
CHANGED
|
@@ -4,22 +4,22 @@ import type { CharSet, LitParser } from "../api.js";
|
|
|
4
4
|
* HOF predicate for matching single char against given options. Returns
|
|
5
5
|
* true if there's no match.
|
|
6
6
|
*
|
|
7
|
-
* @param opts
|
|
7
|
+
* @param opts -
|
|
8
8
|
*/
|
|
9
9
|
export declare const noneOfP: (opts: string | CharSet | any[] | Set<any>) => Predicate<any>;
|
|
10
10
|
/**
|
|
11
11
|
* Matches single char against given options and only succeeds if
|
|
12
12
|
* there's no match. Also see {@link oneOf} for reverse logic.
|
|
13
13
|
*
|
|
14
|
-
* @param opts
|
|
15
|
-
* @param id
|
|
14
|
+
* @param opts -
|
|
15
|
+
* @param id -
|
|
16
16
|
*/
|
|
17
17
|
export declare function noneOf(opts: string | CharSet, id?: string): LitParser<string>;
|
|
18
18
|
export declare function noneOf<T>(opts: T[] | Set<T>, id?: string): LitParser<T>;
|
|
19
19
|
/**
|
|
20
20
|
* Like {@link noneOf}, but discards result.
|
|
21
21
|
*
|
|
22
|
-
* @param opts
|
|
22
|
+
* @param opts -
|
|
23
23
|
*/
|
|
24
24
|
export declare function noneOfD(opts: string | CharSet): LitParser<string>;
|
|
25
25
|
export declare function noneOfD<T>(opts: T[] | Set<T>): LitParser<T>;
|
package/prims/none-of.js
CHANGED
|
@@ -5,7 +5,7 @@ import { satisfy, satisfyD } from "./satisfy.js";
|
|
|
5
5
|
* HOF predicate for matching single char against given options. Returns
|
|
6
6
|
* true if there's no match.
|
|
7
7
|
*
|
|
8
|
-
* @param opts
|
|
8
|
+
* @param opts -
|
|
9
9
|
*/
|
|
10
10
|
export const noneOfP = (opts) => isSet(opts)
|
|
11
11
|
? (x) => !opts.has(x)
|
package/prims/one-of.d.ts
CHANGED
|
@@ -3,22 +3,22 @@ import type { CharSet, LitParser } from "../api.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* HOF predicate for matching single char against given options.
|
|
5
5
|
*
|
|
6
|
-
* @param opts
|
|
6
|
+
* @param opts -
|
|
7
7
|
*/
|
|
8
8
|
export declare const oneOfP: (opts: string | any[] | Set<any> | CharSet) => Predicate<any>;
|
|
9
9
|
/**
|
|
10
10
|
* Matches single char against given options. Also see {@link noneOf}
|
|
11
11
|
* for reverse logic.
|
|
12
12
|
*
|
|
13
|
-
* @param opts
|
|
14
|
-
* @param id
|
|
13
|
+
* @param opts -
|
|
14
|
+
* @param id -
|
|
15
15
|
*/
|
|
16
16
|
export declare function oneOf(opts: string | CharSet, id?: string): LitParser<string>;
|
|
17
17
|
export declare function oneOf<T>(opts: T[] | Set<T>, id?: string): LitParser<T>;
|
|
18
18
|
/**
|
|
19
19
|
* Like {@link oneOf}, but discards result.
|
|
20
20
|
*
|
|
21
|
-
* @param opts
|
|
21
|
+
* @param opts -
|
|
22
22
|
*/
|
|
23
23
|
export declare function oneOfD(opts: string | CharSet): LitParser<string>;
|
|
24
24
|
export declare function oneOfD<T>(opts: T[] | Set<T>): LitParser<T>;
|
package/prims/one-of.js
CHANGED
package/prims/range.d.ts
CHANGED
|
@@ -22,17 +22,17 @@ export declare function rangeD(min: number, max: number): LitParser<number>;
|
|
|
22
22
|
/**
|
|
23
23
|
* Matches single char in given UTF-16 codepoint range.
|
|
24
24
|
*
|
|
25
|
-
* @param min
|
|
26
|
-
* @param max
|
|
27
|
-
* @param id
|
|
25
|
+
* @param min -
|
|
26
|
+
* @param max -
|
|
27
|
+
* @param id -
|
|
28
28
|
*/
|
|
29
29
|
export declare const utf16Range: (min: number, max: number, id?: string) => LitParser<string>;
|
|
30
30
|
/**
|
|
31
31
|
* Matches single char in given UTF-16 codepoint range.
|
|
32
32
|
*
|
|
33
|
-
* @param min
|
|
34
|
-
* @param max
|
|
35
|
-
* @param id
|
|
33
|
+
* @param min -
|
|
34
|
+
* @param max -
|
|
35
|
+
* @param id -
|
|
36
36
|
*/
|
|
37
37
|
export declare const utf16RangeD: (min: number, max: number) => LitParser<string>;
|
|
38
38
|
//# sourceMappingURL=range.d.ts.map
|
package/prims/range.js
CHANGED
|
@@ -26,16 +26,16 @@ export function rangeD(min, max) {
|
|
|
26
26
|
/**
|
|
27
27
|
* Matches single char in given UTF-16 codepoint range.
|
|
28
28
|
*
|
|
29
|
-
* @param min
|
|
30
|
-
* @param max
|
|
31
|
-
* @param id
|
|
29
|
+
* @param min -
|
|
30
|
+
* @param max -
|
|
31
|
+
* @param id -
|
|
32
32
|
*/
|
|
33
33
|
export const utf16Range = (min, max, id = "utfLit") => satisfy(utf16RangeP(min, max), id);
|
|
34
34
|
/**
|
|
35
35
|
* Matches single char in given UTF-16 codepoint range.
|
|
36
36
|
*
|
|
37
|
-
* @param min
|
|
38
|
-
* @param max
|
|
39
|
-
* @param id
|
|
37
|
+
* @param min -
|
|
38
|
+
* @param max -
|
|
39
|
+
* @param id -
|
|
40
40
|
*/
|
|
41
41
|
export const utf16RangeD = (min, max) => satisfyD(utf16RangeP(min, max));
|
package/prims/satisfy.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const satisfy: <T>(pred: Predicate<T>, id?: string) => LitParser<
|
|
|
5
5
|
* Like {@link satisfy}, but avoids creating AST node and discards
|
|
6
6
|
* result.
|
|
7
7
|
*
|
|
8
|
-
* @param pred
|
|
8
|
+
* @param pred -
|
|
9
9
|
*/
|
|
10
10
|
export declare const satisfyD: <T>(pred: Predicate<T>) => LitParser<T>;
|
|
11
11
|
//# sourceMappingURL=satisfy.d.ts.map
|
package/prims/satisfy.js
CHANGED
package/prims/skip.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type { Parser } from "../api.js";
|
|
|
18
18
|
* // { p: 15, l: 2, c: 1, done: true, last: '\n' }
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
* @param pred
|
|
21
|
+
* @param pred -
|
|
22
22
|
*/
|
|
23
23
|
export declare const skipWhile: <T>(pred: Predicate<T>) => Parser<T>;
|
|
24
24
|
//# sourceMappingURL=skip.d.ts.map
|
package/prims/skip.js
CHANGED
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
package/xform/collect.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type { Parser, ScopeTransform } from "../api.js";
|
|
|
3
3
|
* Collects results of all direct children into an array, then discards
|
|
4
4
|
* children. Also see {@link collect}.
|
|
5
5
|
*
|
|
6
|
-
* @param scope
|
|
6
|
+
* @param scope -
|
|
7
7
|
*/
|
|
8
8
|
export declare const xfCollect: ScopeTransform<any>;
|
|
9
9
|
/**
|
|
10
10
|
* Syntax sugar for `xform(parser, xfCollect)`.
|
|
11
11
|
*
|
|
12
|
-
* @param parser
|
|
12
|
+
* @param parser -
|
|
13
13
|
*/
|
|
14
14
|
export declare const collect: <T>(parser: Parser<T>) => Parser<T>;
|
|
15
15
|
//# sourceMappingURL=collect.d.ts.map
|
package/xform/collect.js
CHANGED
|
@@ -3,7 +3,7 @@ import { xform } from "../combinators/xform.js";
|
|
|
3
3
|
* Collects results of all direct children into an array, then discards
|
|
4
4
|
* children. Also see {@link collect}.
|
|
5
5
|
*
|
|
6
|
-
* @param scope
|
|
6
|
+
* @param scope -
|
|
7
7
|
*/
|
|
8
8
|
export const xfCollect = (scope) => {
|
|
9
9
|
scope.result = scope.children.map((c) => c.result);
|
|
@@ -13,6 +13,6 @@ export const xfCollect = (scope) => {
|
|
|
13
13
|
/**
|
|
14
14
|
* Syntax sugar for `xform(parser, xfCollect)`.
|
|
15
15
|
*
|
|
16
|
-
* @param parser
|
|
16
|
+
* @param parser -
|
|
17
17
|
*/
|
|
18
18
|
export const collect = (parser) => xform(parser, xfCollect);
|
package/xform/comp.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ScopeTransform } from "../api.js";
|
|
|
3
3
|
* Takes any number of {@link ScopeTransform}s and composes them into
|
|
4
4
|
* new xform w/ left to right order of execution.
|
|
5
5
|
*
|
|
6
|
-
* @param xs
|
|
6
|
+
* @param xs -
|
|
7
7
|
*/
|
|
8
8
|
export declare const comp: <T>(...xs: ScopeTransform<T>[]) => ScopeTransform<T>;
|
|
9
9
|
//# sourceMappingURL=comp.d.ts.map
|
package/xform/comp.js
CHANGED
package/xform/count.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type { Parser, ScopeTransform } from "../api.js";
|
|
|
3
3
|
* Stores number of children as result, then discards children. Also see
|
|
4
4
|
* {@link count}.
|
|
5
5
|
*
|
|
6
|
-
* @param scope
|
|
6
|
+
* @param scope -
|
|
7
7
|
*/
|
|
8
8
|
export declare const xfCount: ScopeTransform<any>;
|
|
9
9
|
/**
|
|
10
10
|
* Syntax sugar for `xform(parser, xfCount)`.
|
|
11
11
|
*
|
|
12
|
-
* @param parser
|
|
12
|
+
* @param parser -
|
|
13
13
|
*/
|
|
14
14
|
export declare const count: <T>(parser: Parser<T>) => Parser<T>;
|
|
15
15
|
//# sourceMappingURL=count.d.ts.map
|
package/xform/count.js
CHANGED
|
@@ -3,7 +3,7 @@ import { xform } from "../combinators/xform.js";
|
|
|
3
3
|
* Stores number of children as result, then discards children. Also see
|
|
4
4
|
* {@link count}.
|
|
5
5
|
*
|
|
6
|
-
* @param scope
|
|
6
|
+
* @param scope -
|
|
7
7
|
*/
|
|
8
8
|
export const xfCount = (scope) => {
|
|
9
9
|
scope.result = scope.children ? scope.children.length : 0;
|
|
@@ -13,6 +13,6 @@ export const xfCount = (scope) => {
|
|
|
13
13
|
/**
|
|
14
14
|
* Syntax sugar for `xform(parser, xfCount)`.
|
|
15
15
|
*
|
|
16
|
-
* @param parser
|
|
16
|
+
* @param parser -
|
|
17
17
|
*/
|
|
18
18
|
export const count = (parser) => xform(parser, xfCount);
|
package/xform/discard.d.ts
CHANGED
package/xform/discard.js
CHANGED
package/xform/hoist.d.ts
CHANGED
|
@@ -2,26 +2,26 @@ import type { Parser, ScopeTransform } from "../api.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Replace AST node with its first child node. Also see {@link hoist}.
|
|
4
4
|
*
|
|
5
|
-
* @param scope
|
|
5
|
+
* @param scope -
|
|
6
6
|
*/
|
|
7
7
|
export declare const xfHoist: ScopeTransform<any>;
|
|
8
8
|
/**
|
|
9
9
|
* Moves the result of first child node to this node, then discards all
|
|
10
10
|
* children. Also see {@link hoistR}.
|
|
11
11
|
*
|
|
12
|
-
* @param scope
|
|
12
|
+
* @param scope -
|
|
13
13
|
*/
|
|
14
14
|
export declare const xfHoistResult: ScopeTransform<any>;
|
|
15
15
|
/**
|
|
16
16
|
* Syntax sugar for `xform(parser, xfHoist)`.
|
|
17
17
|
*
|
|
18
|
-
* @param parser
|
|
18
|
+
* @param parser -
|
|
19
19
|
*/
|
|
20
20
|
export declare const hoist: <T>(parser: Parser<T>) => Parser<T>;
|
|
21
21
|
/**
|
|
22
22
|
* Syntax sugar for `xform(parser, xfHoistR)`.
|
|
23
23
|
*
|
|
24
|
-
* @param parser
|
|
24
|
+
* @param parser -
|
|
25
25
|
*/
|
|
26
26
|
export declare const hoistResult: <T>(parser: Parser<T>) => Parser<T>;
|
|
27
27
|
//# sourceMappingURL=hoist.d.ts.map
|
package/xform/hoist.js
CHANGED
|
@@ -2,7 +2,7 @@ import { xform } from "../combinators/xform.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Replace AST node with its first child node. Also see {@link hoist}.
|
|
4
4
|
*
|
|
5
|
-
* @param scope
|
|
5
|
+
* @param scope -
|
|
6
6
|
*/
|
|
7
7
|
export const xfHoist = (scope) => {
|
|
8
8
|
Object.assign(scope, scope.children[0]);
|
|
@@ -12,7 +12,7 @@ export const xfHoist = (scope) => {
|
|
|
12
12
|
* Moves the result of first child node to this node, then discards all
|
|
13
13
|
* children. Also see {@link hoistR}.
|
|
14
14
|
*
|
|
15
|
-
* @param scope
|
|
15
|
+
* @param scope -
|
|
16
16
|
*/
|
|
17
17
|
export const xfHoistResult = (scope) => {
|
|
18
18
|
scope.result = scope.children[0].result;
|
|
@@ -22,12 +22,12 @@ export const xfHoistResult = (scope) => {
|
|
|
22
22
|
/**
|
|
23
23
|
* Syntax sugar for `xform(parser, xfHoist)`.
|
|
24
24
|
*
|
|
25
|
-
* @param parser
|
|
25
|
+
* @param parser -
|
|
26
26
|
*/
|
|
27
27
|
export const hoist = (parser) => xform(parser, xfHoist);
|
|
28
28
|
/**
|
|
29
29
|
* Syntax sugar for `xform(parser, xfHoistR)`.
|
|
30
30
|
*
|
|
31
|
-
* @param parser
|
|
31
|
+
* @param parser -
|
|
32
32
|
*/
|
|
33
33
|
export const hoistResult = (parser) => xform(parser, xfHoistResult);
|
package/xform/join.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import type { Parser, ParseScope } from "../api.js";
|
|
|
4
4
|
* Recursively joins non-null results of all children into a single
|
|
5
5
|
* string, then discards children. Also see {@link join}.
|
|
6
6
|
*
|
|
7
|
-
* @param scope
|
|
7
|
+
* @param scope -
|
|
8
8
|
*/
|
|
9
9
|
export declare const xfJoin: <T>(scope: Nullable<ParseScope<T>>) => ParseScope<T> | null;
|
|
10
10
|
/**
|
|
11
11
|
* Syntax sugar for `xform(parser, xfJoin)`.
|
|
12
12
|
*
|
|
13
|
-
* @param parser
|
|
13
|
+
* @param parser -
|
|
14
14
|
*/
|
|
15
15
|
export declare const join: <T>(parser: Parser<T>) => Parser<T>;
|
|
16
16
|
//# sourceMappingURL=join.d.ts.map
|
package/xform/join.js
CHANGED
|
@@ -3,7 +3,7 @@ import { xform } from "../combinators/xform.js";
|
|
|
3
3
|
* Recursively joins non-null results of all children into a single
|
|
4
4
|
* string, then discards children. Also see {@link join}.
|
|
5
5
|
*
|
|
6
|
-
* @param scope
|
|
6
|
+
* @param scope -
|
|
7
7
|
*/
|
|
8
8
|
export const xfJoin = (scope) => {
|
|
9
9
|
if (!scope || !scope.children)
|
|
@@ -21,6 +21,6 @@ export const xfJoin = (scope) => {
|
|
|
21
21
|
/**
|
|
22
22
|
* Syntax sugar for `xform(parser, xfJoin)`.
|
|
23
23
|
*
|
|
24
|
-
* @param parser
|
|
24
|
+
* @param parser -
|
|
25
25
|
*/
|
|
26
26
|
export const join = (parser) => xform(parser, xfJoin);
|
package/xform/nest.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { Parser, ScopeTransform } from "../api.js";
|
|
|
12
12
|
* context will be configured to produce true absolute offsets for its results
|
|
13
13
|
* as if they were in the main context.
|
|
14
14
|
*
|
|
15
|
-
* @param parser
|
|
15
|
+
* @param parser -
|
|
16
16
|
*/
|
|
17
17
|
export declare const xfNest: (parser: Parser<string>) => ScopeTransform<string>;
|
|
18
18
|
export declare const nest: (outer: Parser<string>, inner: Parser<string>) => Parser<string>;
|
package/xform/nest.js
CHANGED
|
@@ -14,7 +14,7 @@ import { xfJoin } from "./join.js";
|
|
|
14
14
|
* context will be configured to produce true absolute offsets for its results
|
|
15
15
|
* as if they were in the main context.
|
|
16
16
|
*
|
|
17
|
-
* @param parser
|
|
17
|
+
* @param parser -
|
|
18
18
|
*/
|
|
19
19
|
export const xfNest = (parser) => (scope, ctx) => {
|
|
20
20
|
if (!scope)
|
package/xform/number.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { ScopeTransform } from "../api.js";
|
|
|
3
3
|
* Higher order transform. First joins all children via {@link xfJoin},
|
|
4
4
|
* then parses resulting string into an integer with given `radix`.
|
|
5
5
|
*
|
|
6
|
-
* @param radix
|
|
6
|
+
* @param radix -
|
|
7
7
|
*/
|
|
8
8
|
export declare const xfInt: (radix?: number) => ScopeTransform<string>;
|
|
9
9
|
/**
|
|
10
10
|
* First joins all children via {@link xfJoin}, then parses resulting
|
|
11
11
|
* string into a floating point value.
|
|
12
12
|
*
|
|
13
|
-
* @param scope
|
|
13
|
+
* @param scope -
|
|
14
14
|
*/
|
|
15
15
|
export declare const xfFloat: ScopeTransform<string>;
|
|
16
16
|
//# sourceMappingURL=number.d.ts.map
|
package/xform/number.js
CHANGED
|
@@ -3,7 +3,7 @@ import { xfJoin } from "./join.js";
|
|
|
3
3
|
* Higher order transform. First joins all children via {@link xfJoin},
|
|
4
4
|
* then parses resulting string into an integer with given `radix`.
|
|
5
5
|
*
|
|
6
|
-
* @param radix
|
|
6
|
+
* @param radix -
|
|
7
7
|
*/
|
|
8
8
|
export const xfInt = (radix = 10) => (scope) => {
|
|
9
9
|
scope.result = parseInt(xfJoin(scope).result, radix);
|
|
@@ -13,7 +13,7 @@ export const xfInt = (radix = 10) => (scope) => {
|
|
|
13
13
|
* First joins all children via {@link xfJoin}, then parses resulting
|
|
14
14
|
* string into a floating point value.
|
|
15
15
|
*
|
|
16
|
-
* @param scope
|
|
16
|
+
* @param scope -
|
|
17
17
|
*/
|
|
18
18
|
export const xfFloat = (scope) => {
|
|
19
19
|
scope.result = parseFloat(xfJoin(scope).result);
|
package/xform/print.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ import type { Parser, ScopeTransform } from "../api.js";
|
|
|
9
9
|
* The optional `fn` function is used to print each AST node (default:
|
|
10
10
|
* `console.log`).
|
|
11
11
|
*
|
|
12
|
-
* @param scope
|
|
13
|
-
* @param ctx
|
|
14
|
-
* @param level
|
|
12
|
+
* @param scope -
|
|
13
|
+
* @param ctx -
|
|
14
|
+
* @param level -
|
|
15
15
|
*/
|
|
16
16
|
export declare const xfPrint: (fn?: Fn<string, void>) => ScopeTransform<any>;
|
|
17
17
|
/**
|
|
@@ -29,7 +29,7 @@ export declare const xfPrint: (fn?: Fn<string, void>) => ScopeTransform<any>;
|
|
|
29
29
|
* // lit: "]"
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
|
-
* @param parser
|
|
32
|
+
* @param parser -
|
|
33
33
|
*/
|
|
34
34
|
export declare const print: <T>(parser: Parser<T>, fn?: Fn<string, void> | undefined) => Parser<T>;
|
|
35
35
|
//# sourceMappingURL=print.d.ts.map
|
package/xform/print.js
CHANGED
|
@@ -9,9 +9,9 @@ import { indent } from "../utils.js";
|
|
|
9
9
|
* The optional `fn` function is used to print each AST node (default:
|
|
10
10
|
* `console.log`).
|
|
11
11
|
*
|
|
12
|
-
* @param scope
|
|
13
|
-
* @param ctx
|
|
14
|
-
* @param level
|
|
12
|
+
* @param scope -
|
|
13
|
+
* @param ctx -
|
|
14
|
+
* @param level -
|
|
15
15
|
*/
|
|
16
16
|
export const xfPrint = (fn = console.log) => {
|
|
17
17
|
const $print = (scope, _, level = 0) => {
|
|
@@ -45,6 +45,6 @@ export const xfPrint = (fn = console.log) => {
|
|
|
45
45
|
* // lit: "]"
|
|
46
46
|
* ```
|
|
47
47
|
*
|
|
48
|
-
* @param parser
|
|
48
|
+
* @param parser -
|
|
49
49
|
*/
|
|
50
50
|
export const print = (parser, fn) => xform(parser, xfPrint(fn));
|
package/xform/trim.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ import type { Parser, ScopeTransform } from "../api.js";
|
|
|
5
5
|
*
|
|
6
6
|
* {@link trim}.
|
|
7
7
|
*
|
|
8
|
-
* @param scope
|
|
8
|
+
* @param scope -
|
|
9
9
|
*/
|
|
10
10
|
export declare const xfTrim: ScopeTransform<string>;
|
|
11
11
|
/**
|
|
12
12
|
* Syntax sugar for `xform(parser, xfTrim)`.
|
|
13
13
|
*
|
|
14
|
-
* @param parser
|
|
14
|
+
* @param parser -
|
|
15
15
|
*/
|
|
16
16
|
export declare const trim: (parser: Parser<string>) => Parser<string>;
|
|
17
17
|
//# sourceMappingURL=trim.d.ts.map
|
package/xform/trim.js
CHANGED
|
@@ -5,7 +5,7 @@ import { xform } from "../combinators/xform.js";
|
|
|
5
5
|
*
|
|
6
6
|
* {@link trim}.
|
|
7
7
|
*
|
|
8
|
-
* @param scope
|
|
8
|
+
* @param scope -
|
|
9
9
|
*/
|
|
10
10
|
export const xfTrim = (scope) => {
|
|
11
11
|
scope.result = scope.result.trim();
|
|
@@ -14,6 +14,6 @@ export const xfTrim = (scope) => {
|
|
|
14
14
|
/**
|
|
15
15
|
* Syntax sugar for `xform(parser, xfTrim)`.
|
|
16
16
|
*
|
|
17
|
-
* @param parser
|
|
17
|
+
* @param parser -
|
|
18
18
|
*/
|
|
19
19
|
export const trim = (parser) => xform(parser, xfTrim);
|
package/xform/with-id.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ScopeTransform, Parser } from "../api.js";
|
|
|
3
3
|
* Assigns given `id` to AST node. E.g. used for re-labeling parser
|
|
4
4
|
* results defined by {@link defGrammar}.
|
|
5
5
|
*
|
|
6
|
-
* @param id
|
|
6
|
+
* @param id -
|
|
7
7
|
*/
|
|
8
8
|
export declare const xfID: (id: string) => ScopeTransform<any>;
|
|
9
9
|
export declare const withID: <T>(id: string, parser: Parser<T>) => Parser<T>;
|
package/xform/with-id.js
CHANGED
|
@@ -3,7 +3,7 @@ import { xform } from "../combinators/xform.js";
|
|
|
3
3
|
* Assigns given `id` to AST node. E.g. used for re-labeling parser
|
|
4
4
|
* results defined by {@link defGrammar}.
|
|
5
5
|
*
|
|
6
|
-
* @param id
|
|
6
|
+
* @param id -
|
|
7
7
|
*/
|
|
8
8
|
export const xfID = (id) => (scope) => ((scope.id = id), scope);
|
|
9
9
|
export const withID = (id, parser) => xform(parser, xfID(id));
|