@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/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [
|
|
6
|
+
## [2.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@2.0.2...@thi.ng/parse@2.0.3) (2021-10-15)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @thi.ng/parse
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
## [
|
|
14
|
+
## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@2.0.1...@thi.ng/parse@2.0.2) (2021-10-15)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @thi.ng/parse
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
## [
|
|
22
|
+
## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@2.0.0...@thi.ng/parse@2.0.1) (2021-10-13)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @thi.ng/parse
|
|
25
25
|
|
|
@@ -27,189 +27,137 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @thi.ng/parse
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## [0.9.25](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.9.24...@thi.ng/parse@0.9.25) (2021-08-04)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @thi.ng/parse
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [0.9.24](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.9.23...@thi.ng/parse@0.9.24) (2021-07-01)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @thi.ng/parse
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## [0.9.23](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.9.22...@thi.ng/parse@0.9.23) (2021-06-08)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @thi.ng/parse
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# [0.9.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.8.2...@thi.ng/parse@0.9.0) (2020-08-17)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Features
|
|
66
|
-
|
|
67
|
-
* **parse:** add replace/xfReplace() xform ([7291181](https://github.com/thi-ng/umbrella/commit/7291181f6eb74751aa02dffbb95bb6787a5ef02f))
|
|
68
|
-
* **parse:** enable replacement rule transforms ([ca22432](https://github.com/thi-ng/umbrella/commit/ca224328e55cb525cefd39dd53028a86a580fd7e))
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# [0.8.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.7.2...@thi.ng/parse@0.8.0) (2020-07-19)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
### Features
|
|
78
|
-
|
|
79
|
-
* **parse:** add nest()/xfNest() transform ([af9c97b](https://github.com/thi-ng/umbrella/commit/af9c97b55cba15175bff917d0b2522be8c98517d))
|
|
80
|
-
* **parse:** update grammar (xform rule refs) ([22188a4](https://github.com/thi-ng/umbrella/commit/22188a41d5db58fb9dae9cb01bd04ad8d1ac788e))
|
|
81
|
-
* **parse:** update repeat grammar ([7aae9ac](https://github.com/thi-ng/umbrella/commit/7aae9ac02d23dd7e5a0643d3a418be67044465bd))
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
## [0.7.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.7.1...@thi.ng/parse@0.7.2) (2020-07-18)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
### Bug Fixes
|
|
91
|
-
|
|
92
|
-
* **parse:** export ContextOpts, move to api.ts ([2dfc445](https://github.com/thi-ng/umbrella/commit/2dfc445971dc788abcb6576ef4e6836dec6df33a))
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
## [0.7.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.7.0...@thi.ng/parse@0.7.1) (2020-07-17)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
### Performance Improvements
|
|
102
|
-
|
|
103
|
-
* **parse:** update grammar, use discarding parsers where possible ([d269a8a](https://github.com/thi-ng/umbrella/commit/d269a8a3f5b5ee47d60f86343a163c9903ce6923))
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# [0.7.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.6.2...@thi.ng/parse@0.7.0) (2020-07-08)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
### Features
|
|
113
|
-
|
|
114
|
-
* **parse:** add lookahead() combinator, add tests ([ee35038](https://github.com/thi-ng/umbrella/commit/ee35038cdae0692cc369221eb7623ba7b973d2f1))
|
|
115
|
-
* **parse:** lookahead w/ configurable capture ([542c066](https://github.com/thi-ng/umbrella/commit/542c0662b4901a6cfd32a99e5241dace0ddde807))
|
|
116
|
-
* **parse:** turn xfPrint() into HOF xform ([d86fa53](https://github.com/thi-ng/umbrella/commit/d86fa535a530f0fe84e08e5969ca01c96ef75c23))
|
|
117
|
-
* **parse:** update grammar DSL ([accacf9](https://github.com/thi-ng/umbrella/commit/accacf9fa73b09f6cb8454cd4d85f10bb0f55795))
|
|
118
|
-
* **parse:** update lookahead ([51a8dc5](https://github.com/thi-ng/umbrella/commit/51a8dc55dd3b40fcfbffbcb5f3aeaea618441269))
|
|
119
|
-
* **parse:** update/fix grammar DSL, add trim ([f82ba1f](https://github.com/thi-ng/umbrella/commit/f82ba1f9aeed03571e50953c6d41255a569d121f))
|
|
120
|
-
|
|
121
|
-
|
|
30
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@1.0.5...@thi.ng/parse@2.0.0) (2021-10-12)
|
|
122
31
|
|
|
123
32
|
|
|
33
|
+
### Build System
|
|
124
34
|
|
|
125
|
-
|
|
35
|
+
* major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
|
|
126
36
|
|
|
127
37
|
|
|
128
|
-
###
|
|
38
|
+
### BREAKING CHANGES
|
|
129
39
|
|
|
130
|
-
*
|
|
131
|
-
* **parse:** add count/xfCount transform ([056ae08](https://github.com/thi-ng/umbrella/commit/056ae084c08a826f09c65181c01426bbdff59e87))
|
|
40
|
+
* discontinue CommonJS & UMD versions
|
|
132
41
|
|
|
42
|
+
- only ESM modules will be published from now on
|
|
43
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
44
|
+
- i.e. launch NodeJS via:
|
|
45
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
46
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
47
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
133
48
|
|
|
49
|
+
Also:
|
|
50
|
+
- normalize/restructure/reorg all package.json files
|
|
51
|
+
- cleanup all build scripts, remove obsolete
|
|
52
|
+
- switch from mocha to @thi.ng/testament for all tests
|
|
134
53
|
|
|
135
54
|
|
|
136
55
|
|
|
137
|
-
# [0.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.4.1...@thi.ng/parse@0.5.0) (2020-04-23)
|
|
138
56
|
|
|
139
57
|
|
|
140
|
-
### Features
|
|
141
58
|
|
|
142
|
-
|
|
59
|
+
## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@1.0.4...@thi.ng/parse@1.0.5) (2021-09-03)
|
|
143
60
|
|
|
61
|
+
**Note:** Version bump only for package @thi.ng/parse
|
|
144
62
|
|
|
63
|
+
# [0.9.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.8.2...@thi.ng/parse@0.9.0) (2020-08-17)
|
|
145
64
|
|
|
65
|
+
### Features
|
|
146
66
|
|
|
67
|
+
- **parse:** add replace/xfReplace() xform ([7291181](https://github.com/thi-ng/umbrella/commit/7291181f6eb74751aa02dffbb95bb6787a5ef02f))
|
|
68
|
+
- **parse:** enable replacement rule transforms ([ca22432](https://github.com/thi-ng/umbrella/commit/ca224328e55cb525cefd39dd53028a86a580fd7e))
|
|
147
69
|
|
|
148
|
-
#
|
|
70
|
+
# [0.8.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.7.2...@thi.ng/parse@0.8.0) (2020-07-19)
|
|
149
71
|
|
|
72
|
+
### Features
|
|
150
73
|
|
|
151
|
-
|
|
74
|
+
- **parse:** add nest()/xfNest() transform ([af9c97b](https://github.com/thi-ng/umbrella/commit/af9c97b55cba15175bff917d0b2522be8c98517d))
|
|
75
|
+
- **parse:** update grammar (xform rule refs) ([22188a4](https://github.com/thi-ng/umbrella/commit/22188a41d5db58fb9dae9cb01bd04ad8d1ac788e))
|
|
76
|
+
- **parse:** update repeat grammar ([7aae9ac](https://github.com/thi-ng/umbrella/commit/7aae9ac02d23dd7e5a0643d3a418be67044465bd))
|
|
152
77
|
|
|
153
|
-
|
|
78
|
+
## [0.7.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.7.1...@thi.ng/parse@0.7.2) (2020-07-18)
|
|
154
79
|
|
|
80
|
+
### Bug Fixes
|
|
155
81
|
|
|
156
|
-
|
|
82
|
+
- **parse:** export ContextOpts, move to api.ts ([2dfc445](https://github.com/thi-ng/umbrella/commit/2dfc445971dc788abcb6576ef4e6836dec6df33a))
|
|
157
83
|
|
|
158
|
-
|
|
84
|
+
## [0.7.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.7.0...@thi.ng/parse@0.7.1) (2020-07-17)
|
|
159
85
|
|
|
86
|
+
### Performance Improvements
|
|
160
87
|
|
|
88
|
+
- **parse:** update grammar, use discarding parsers where possible ([d269a8a](https://github.com/thi-ng/umbrella/commit/d269a8a3f5b5ee47d60f86343a163c9903ce6923))
|
|
161
89
|
|
|
90
|
+
# [0.7.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.6.2...@thi.ng/parse@0.7.0) (2020-07-08)
|
|
162
91
|
|
|
92
|
+
### Features
|
|
163
93
|
|
|
164
|
-
|
|
94
|
+
- **parse:** add lookahead() combinator, add tests ([ee35038](https://github.com/thi-ng/umbrella/commit/ee35038cdae0692cc369221eb7623ba7b973d2f1))
|
|
95
|
+
- **parse:** lookahead w/ configurable capture ([542c066](https://github.com/thi-ng/umbrella/commit/542c0662b4901a6cfd32a99e5241dace0ddde807))
|
|
96
|
+
- **parse:** turn xfPrint() into HOF xform ([d86fa53](https://github.com/thi-ng/umbrella/commit/d86fa535a530f0fe84e08e5969ca01c96ef75c23))
|
|
97
|
+
- **parse:** update grammar DSL ([accacf9](https://github.com/thi-ng/umbrella/commit/accacf9fa73b09f6cb8454cd4d85f10bb0f55795))
|
|
98
|
+
- **parse:** update lookahead ([51a8dc5](https://github.com/thi-ng/umbrella/commit/51a8dc55dd3b40fcfbffbcb5f3aeaea618441269))
|
|
99
|
+
- **parse:** update/fix grammar DSL, add trim ([f82ba1f](https://github.com/thi-ng/umbrella/commit/f82ba1f9aeed03571e50953c6d41255a569d121f))
|
|
165
100
|
|
|
101
|
+
# [0.6.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.5.8...@thi.ng/parse@0.6.0) (2020-06-28)
|
|
166
102
|
|
|
167
|
-
###
|
|
103
|
+
### Features
|
|
168
104
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
* **parse:** add grammar default transforms, update/fix rules ([03ed965](https://github.com/thi-ng/umbrella/commit/03ed96592f1598767d5feeac1b49b8cc4b1d6285))
|
|
172
|
-
* **parse:** add more whitespace presets ([1398e2b](https://github.com/thi-ng/umbrella/commit/1398e2b06a8eace8b61333c36db6e82d6e1478f3))
|
|
173
|
-
* **parse:** add ParseContext.reset(), update addChild() ([d47c0a2](https://github.com/thi-ng/umbrella/commit/d47c0a220e4912a30c59a7fd3c81b8376d74d720))
|
|
174
|
-
* **parse:** add skipWhile(), more discarded wrappers ([832c0b7](https://github.com/thi-ng/umbrella/commit/832c0b7e88d87b2da0e37f602e592ad7b548da09))
|
|
175
|
-
* **parse:** add withID() xform, add doc strings ([e16426b](https://github.com/thi-ng/umbrella/commit/e16426b82f0dda94ab9aa92ba6e3af8d769f3fed))
|
|
176
|
-
* **parse:** add/update combinators ([e4eab03](https://github.com/thi-ng/umbrella/commit/e4eab036243f4f646880b974624ae680e77cff7f))
|
|
177
|
-
* **parse:** add/update/rename parser presets ([12f2499](https://github.com/thi-ng/umbrella/commit/12f2499253163a923c42e3be29ce2223a6648e11))
|
|
178
|
-
* **parse:** add/update/rename parser primitives ([328103f](https://github.com/thi-ng/umbrella/commit/328103f55f4bb311470b8767a27d28a78d0dcb4b))
|
|
179
|
-
* **parse:** initial checkin grammar compiler ([38e9c66](https://github.com/thi-ng/umbrella/commit/38e9c66c25c02db4d7fb79837645dfaf654e6788))
|
|
180
|
-
* **parse:** update ESC & whitespace parsers ([069a6ef](https://github.com/thi-ng/umbrella/commit/069a6ef11c9423bdb2974b11823cc39743dfceec))
|
|
181
|
-
* **parse:** update grammar parser & compiler ([822fcba](https://github.com/thi-ng/umbrella/commit/822fcba9a29a05bad98eecf2b341d07a3a90abeb))
|
|
105
|
+
- **parse:** add `!` discard modifier to grammar ([456efdc](https://github.com/thi-ng/umbrella/commit/456efdcb6ded913b0f2b137ebe99634421d552c0))
|
|
106
|
+
- **parse:** add count/xfCount transform ([056ae08](https://github.com/thi-ng/umbrella/commit/056ae084c08a826f09c65181c01426bbdff59e87))
|
|
182
107
|
|
|
108
|
+
# [0.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.4.1...@thi.ng/parse@0.5.0) (2020-04-23)
|
|
183
109
|
|
|
110
|
+
### Features
|
|
184
111
|
|
|
112
|
+
- **parse:** add built-ins, extract STRING, minor updates ([458f5b3](https://github.com/thi-ng/umbrella/commit/458f5b34a4fa1c58f55b23be8455e6bd7b7bb72d))
|
|
185
113
|
|
|
114
|
+
# [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.3.0...@thi.ng/parse@0.4.0) (2020-04-21)
|
|
186
115
|
|
|
187
|
-
|
|
116
|
+
### Bug Fixes
|
|
188
117
|
|
|
118
|
+
- **parse:** update not() behavior, add passD() ([1d0f4c4](https://github.com/thi-ng/umbrella/commit/1d0f4c4baef5b1cfb207f606f4e3873a14c3afce))
|
|
189
119
|
|
|
190
|
-
###
|
|
120
|
+
### Features
|
|
191
121
|
|
|
192
|
-
|
|
122
|
+
- **parse:** update grammar DSL, hoist xforms ([861e7f3](https://github.com/thi-ng/umbrella/commit/861e7f32d98a9f693a9271d31235d1603700b36c))
|
|
193
123
|
|
|
124
|
+
# [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.2.0...@thi.ng/parse@0.3.0) (2020-04-20)
|
|
194
125
|
|
|
195
|
-
###
|
|
126
|
+
### Features
|
|
196
127
|
|
|
197
|
-
|
|
128
|
+
- **parse:** add discarding combinators, move discard ([e09a2c4](https://github.com/thi-ng/umbrella/commit/e09a2c40d1ad7272a5abc15c8b11e497f79eb0dd))
|
|
129
|
+
- **parse:** add dynamic() & DynamicParser ([b914267](https://github.com/thi-ng/umbrella/commit/b914267b88325d5c94a028aee192268e75736181))
|
|
130
|
+
- **parse:** add grammar default transforms, update/fix rules ([03ed965](https://github.com/thi-ng/umbrella/commit/03ed96592f1598767d5feeac1b49b8cc4b1d6285))
|
|
131
|
+
- **parse:** add more whitespace presets ([1398e2b](https://github.com/thi-ng/umbrella/commit/1398e2b06a8eace8b61333c36db6e82d6e1478f3))
|
|
132
|
+
- **parse:** add ParseContext.reset(), update addChild() ([d47c0a2](https://github.com/thi-ng/umbrella/commit/d47c0a220e4912a30c59a7fd3c81b8376d74d720))
|
|
133
|
+
- **parse:** add skipWhile(), more discarded wrappers ([832c0b7](https://github.com/thi-ng/umbrella/commit/832c0b7e88d87b2da0e37f602e592ad7b548da09))
|
|
134
|
+
- **parse:** add withID() xform, add doc strings ([e16426b](https://github.com/thi-ng/umbrella/commit/e16426b82f0dda94ab9aa92ba6e3af8d769f3fed))
|
|
135
|
+
- **parse:** add/update combinators ([e4eab03](https://github.com/thi-ng/umbrella/commit/e4eab036243f4f646880b974624ae680e77cff7f))
|
|
136
|
+
- **parse:** add/update/rename parser presets ([12f2499](https://github.com/thi-ng/umbrella/commit/12f2499253163a923c42e3be29ce2223a6648e11))
|
|
137
|
+
- **parse:** add/update/rename parser primitives ([328103f](https://github.com/thi-ng/umbrella/commit/328103f55f4bb311470b8767a27d28a78d0dcb4b))
|
|
138
|
+
- **parse:** initial checkin grammar compiler ([38e9c66](https://github.com/thi-ng/umbrella/commit/38e9c66c25c02db4d7fb79837645dfaf654e6788))
|
|
139
|
+
- **parse:** update ESC & whitespace parsers ([069a6ef](https://github.com/thi-ng/umbrella/commit/069a6ef11c9423bdb2974b11823cc39743dfceec))
|
|
140
|
+
- **parse:** update grammar parser & compiler ([822fcba](https://github.com/thi-ng/umbrella/commit/822fcba9a29a05bad98eecf2b341d07a3a90abeb))
|
|
198
141
|
|
|
142
|
+
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/parse@0.1.0...@thi.ng/parse@0.2.0) (2020-04-17)
|
|
199
143
|
|
|
144
|
+
### Features
|
|
200
145
|
|
|
146
|
+
- **parse:** add/rename/reorg parsers, xforms, ctx ([ee537f4](https://github.com/thi-ng/umbrella/commit/ee537f49c239de19326865687853e9b2814330bf))
|
|
201
147
|
|
|
148
|
+
### Performance Improvements
|
|
202
149
|
|
|
203
|
-
|
|
150
|
+
- **parse:** major speedup satisfy() (~1.6x faster) ([8ca5c7f](https://github.com/thi-ng/umbrella/commit/8ca5c7f184af3d03f06b03b9136a675fb9e63d64))
|
|
204
151
|
|
|
152
|
+
# 0.1.0 (2020-04-16)
|
|
205
153
|
|
|
206
|
-
###
|
|
154
|
+
### Features
|
|
207
155
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
156
|
+
- **parse:** add ArrayReader, update pkg info ([3bec0db](https://github.com/thi-ng/umbrella/commit/3bec0dbf759d9742adefb936e58359f95da58fc8))
|
|
157
|
+
- **parse:** add collect/xfCollect, update xfPrint ([43f3368](https://github.com/thi-ng/umbrella/commit/43f33687431f9ea8269c1eba0342d0589f7ac4dc))
|
|
158
|
+
- **parse:** add ctx getters, add presets, update maybe ([02597bf](https://github.com/thi-ng/umbrella/commit/02597bf825df3e467cf2d090c69198d85f1767f2))
|
|
159
|
+
- **parse:** import as new package ([151e50c](https://github.com/thi-ng/umbrella/commit/151e50cc1e2bfaf8d70a6bb82907eec483dd8316))
|
|
160
|
+
- **parse:** make retained state info optional ([a89ee87](https://github.com/thi-ng/umbrella/commit/a89ee871a098582c909fcf8558ed979d04942250))
|
|
161
|
+
- **parse:** update defContext, add basic array test ([cd7363d](https://github.com/thi-ng/umbrella/commit/cd7363d7f93e0db00797a9ec30bd44b399396860))
|
|
162
|
+
- **parse:** update ParseContext, repeat & lift ([bef1d4f](https://github.com/thi-ng/umbrella/commit/bef1d4f628320d1aac9cf6d924749d4f15864d07))
|
|
163
|
+
- **parse:** update repeat ops, reader, initial state ([c5cfabe](https://github.com/thi-ng/umbrella/commit/c5cfabeaf5ab6e124d5fc2455fd3f5ede96248cd))
|
package/README.md
CHANGED
|
@@ -73,15 +73,24 @@ Purely functional parser combinators & AST generation for generic inputs.
|
|
|
73
73
|
yarn add @thi.ng/parse
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
ES module import:
|
|
77
|
+
|
|
76
78
|
```html
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
<script type="module" src="https://cdn.skypack.dev/@thi.ng/parse"></script>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
[Skypack documentation](https://docs.skypack.dev/)
|
|
83
|
+
|
|
84
|
+
For Node.js REPL:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
# with flag only for < v16
|
|
88
|
+
node --experimental-repl-await
|
|
79
89
|
|
|
80
|
-
|
|
81
|
-
<script src="https://unpkg.com/@thi.ng/parse/lib/index.umd.js" crossorigin></script>
|
|
90
|
+
> const parse = await import("@thi.ng/parse");
|
|
82
91
|
```
|
|
83
92
|
|
|
84
|
-
Package sizes (gzipped, pre-treeshake): ESM: 5.
|
|
93
|
+
Package sizes (gzipped, pre-treeshake): ESM: 5.28 KB
|
|
85
94
|
|
|
86
95
|
## Dependencies
|
|
87
96
|
|
|
@@ -100,7 +109,7 @@ directory are using this package.
|
|
|
100
109
|
A selection:
|
|
101
110
|
|
|
102
111
|
| Screenshot | Description | Live demo | Source |
|
|
103
|
-
|
|
112
|
+
|:------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------|:-------------------------------------------------------|:------------------------------------------------------------------------------------|
|
|
104
113
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/parse-playground.png" width="240"/> | Parser grammar livecoding editor/playground & codegen | [Demo](https://demo.thi.ng/umbrella/parse-playground/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/parse-playground) |
|
|
105
114
|
|
|
106
115
|
**Note:** Please also see the [dedicated wiki
|
package/api.d.ts
CHANGED
package/combinators/alt.d.ts
CHANGED
package/combinators/alt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Parser } from "../api";
|
|
1
|
+
import type { Parser } from "../api.js";
|
|
2
2
|
export declare const startsWith: <T>(parser: Parser<T>) => Parser<T>;
|
|
3
3
|
export declare const endsWith: <T>(parser: Parser<T>) => Parser<T>;
|
|
4
4
|
export declare const entireLine: (parser: Parser<string>) => Parser<string>;
|
package/combinators/boundary.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inputEnd, inputStart, lineEnd, lineStart } from "../prims/anchor";
|
|
2
|
-
import { seq } from "./seq";
|
|
1
|
+
import { inputEnd, inputStart, lineEnd, lineStart } from "../prims/anchor.js";
|
|
2
|
+
import { seq } from "./seq.js";
|
|
3
3
|
export const startsWith = (parser) => seq([inputStart, parser]);
|
|
4
4
|
export const endsWith = (parser) => seq([parser, inputEnd]);
|
|
5
5
|
export const entireLine = (parser) => seq([lineStart, parser, lineEnd]);
|
package/combinators/check.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Predicate } from "@thi.ng/api";
|
|
2
|
-
import type { Parser, ParseScope } from "../api";
|
|
2
|
+
import type { Parser, ParseScope } from "../api.js";
|
|
3
3
|
export declare const check: <T>(parser: Parser<T>, pred: Predicate<ParseScope<T>>, msg?: string) => Parser<T>;
|
|
4
4
|
//# sourceMappingURL=check.d.ts.map
|
package/combinators/check.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { parseError } from "../error";
|
|
2
|
-
import { xform } from "./xform";
|
|
1
|
+
import { parseError } from "../error.js";
|
|
2
|
+
import { xform } from "./xform.js";
|
|
3
3
|
export const check = (parser, pred, msg = "check failed") => xform(parser, (scope, ctx) => {
|
|
4
4
|
if (!pred(scope))
|
|
5
5
|
parseError(ctx, msg);
|
package/combinators/dynamic.d.ts
CHANGED
package/combinators/expect.d.ts
CHANGED
package/combinators/expect.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { parseError } from "../error";
|
|
1
|
+
import { parseError } from "../error.js";
|
|
2
2
|
export const expect = (parser, err) => (ctx) => parser(ctx) || parseError(ctx, err);
|
package/combinators/lookahead.js
CHANGED
|
@@ -67,7 +67,7 @@ export const lookahead = (parser, ahead, capture = false, id = "lookahead") => (
|
|
|
67
67
|
ctx.start(id);
|
|
68
68
|
let pass = false;
|
|
69
69
|
while (true) {
|
|
70
|
-
const state = capture ? null :
|
|
70
|
+
const state = capture ? null : { ...ctx.state };
|
|
71
71
|
if (ahead(ctx)) {
|
|
72
72
|
!capture && (ctx.state = state);
|
|
73
73
|
return pass ? ctx.end() : ctx.discard();
|
package/combinators/maybe.d.ts
CHANGED
package/combinators/maybe.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { pass } from "../prims/pass";
|
|
1
|
+
import { pass } from "../prims/pass.js";
|
|
2
2
|
export const maybe = (parser, result, id = "maybe") => (ctx) => parser(ctx) || pass(result, id)(ctx);
|
package/combinators/not.d.ts
CHANGED
package/combinators/not.js
CHANGED
package/combinators/repeat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Parser } from "../api";
|
|
1
|
+
import type { Parser } from "../api.js";
|
|
2
2
|
export declare const repeat: <T>(parser: Parser<T>, min: number, max: number, id?: string) => Parser<T>;
|
|
3
3
|
export declare const zeroOrMore: <T>(parser: Parser<T>, id?: string, max?: number) => Parser<T>;
|
|
4
4
|
export declare const oneOrMore: <T>(parser: Parser<T>, id?: string, max?: number) => Parser<T>;
|
package/combinators/repeat.js
CHANGED
package/combinators/seq.d.ts
CHANGED
package/combinators/seq.js
CHANGED
package/combinators/wrap.d.ts
CHANGED
package/combinators/wrap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { litD } from "../prims/lit";
|
|
2
|
-
import { hoist } from "../xform/hoist";
|
|
3
|
-
import { seq } from "./seq";
|
|
1
|
+
import { litD } from "../prims/lit.js";
|
|
2
|
+
import { hoist } from "../xform/hoist.js";
|
|
3
|
+
import { seq } from "./seq.js";
|
|
4
4
|
export const wrap = (parser, pre, post = pre) => hoist(seq([litD(pre), parser, litD(post)]));
|
package/combinators/xform.d.ts
CHANGED
package/context.d.ts
CHANGED
package/context.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { isArrayLike
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { isArrayLike } from "@thi.ng/checks/is-arraylike";
|
|
2
|
+
import { isString } from "@thi.ng/checks/is-string";
|
|
3
|
+
import { parseError } from "./error.js";
|
|
4
|
+
import { defArrayReader } from "./readers/array-reader.js";
|
|
5
|
+
import { defStringReader } from "./readers/string-reader.js";
|
|
6
|
+
import { indent } from "./utils.js";
|
|
6
7
|
export class ParseContext {
|
|
7
8
|
constructor(reader, opts) {
|
|
8
9
|
this.reader = reader;
|
|
9
|
-
this.opts =
|
|
10
|
+
this.opts = { maxDepth: 32, debug: false, retain: false, ...opts };
|
|
10
11
|
this._maxDepth = this.opts.maxDepth;
|
|
11
12
|
this._debug = this.opts.debug;
|
|
12
13
|
this._retain = this.opts.retain;
|
|
@@ -30,7 +31,7 @@ export class ParseContext {
|
|
|
30
31
|
const scopes = this._scopes;
|
|
31
32
|
const scope = {
|
|
32
33
|
id,
|
|
33
|
-
state:
|
|
34
|
+
state: { ...scopes[scopes.length - 1].state },
|
|
34
35
|
children: null,
|
|
35
36
|
result: null,
|
|
36
37
|
};
|
package/error.d.ts
CHANGED
package/error.js
CHANGED
package/grammar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GrammarOpts, Language, Parser, RuleTransforms } from "./api";
|
|
1
|
+
import type { GrammarOpts, Language, Parser, RuleTransforms } from "./api.js";
|
|
2
2
|
export declare const GRAMMAR: Parser<string>;
|
|
3
3
|
export declare const defGrammar: (rules: string, env?: RuleTransforms | undefined, opts?: Partial<GrammarOpts> | undefined) => Language | undefined;
|
|
4
4
|
//# sourceMappingURL=grammar.d.ts.map
|