@thomasfosterau/effect-parse 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -230
- package/dist/Ascii.d.ts +32 -53
- package/dist/Ascii.d.ts.map +1 -1
- package/dist/Ascii.js +576 -571
- package/dist/Ascii.js.map +1 -1
- package/dist/Binary.d.ts +6 -29
- package/dist/Binary.d.ts.map +1 -1
- package/dist/Binary.js +129 -116
- package/dist/Binary.js.map +1 -1
- package/dist/Bits.d.ts +4 -2
- package/dist/Bits.d.ts.map +1 -1
- package/dist/Bits.js +121 -123
- package/dist/Bits.js.map +1 -1
- package/dist/Compiler.d.ts +39 -0
- package/dist/Compiler.d.ts.map +1 -0
- package/dist/Compiler.js +48 -0
- package/dist/Compiler.js.map +1 -0
- package/dist/Encoding.d.ts +29 -46
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +76 -75
- package/dist/Encoding.js.map +1 -1
- package/dist/Expression.d.ts +15 -49
- package/dist/Expression.d.ts.map +1 -1
- package/dist/Expression.js +143 -131
- package/dist/Expression.js.map +1 -1
- package/dist/Input.d.ts +206 -177
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +317 -299
- package/dist/Input.js.map +1 -1
- package/dist/Nom.d.ts +44 -84
- package/dist/Nom.d.ts.map +1 -1
- package/dist/Nom.js +423 -453
- package/dist/Nom.js.map +1 -1
- package/dist/ParseError.d.ts +54 -49
- package/dist/ParseError.d.ts.map +1 -1
- package/dist/ParseError.js +233 -275
- package/dist/ParseError.js.map +1 -1
- package/dist/Parser.d.ts +345 -313
- package/dist/Parser.d.ts.map +1 -1
- package/dist/Parser.js +2010 -1802
- package/dist/Parser.js.map +1 -1
- package/dist/ParserSchema.d.ts +8 -7
- package/dist/ParserSchema.d.ts.map +1 -1
- package/dist/ParserSchema.js +49 -49
- package/dist/ParserSchema.js.map +1 -1
- package/dist/ParserStream.d.ts +26 -20
- package/dist/ParserStream.d.ts.map +1 -1
- package/dist/ParserStream.js +267 -255
- package/dist/ParserStream.js.map +1 -1
- package/dist/Syntax.d.ts +401 -0
- package/dist/Syntax.d.ts.map +1 -0
- package/dist/Syntax.js +717 -0
- package/dist/Syntax.js.map +1 -0
- package/dist/Text.d.ts +98 -134
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +534 -496
- package/dist/Text.js.map +1 -1
- package/dist/Token.d.ts +60 -42
- package/dist/Token.d.ts.map +1 -1
- package/dist/Token.js +331 -265
- package/dist/Token.js.map +1 -1
- package/dist/index.d.ts +16 -17
- package/dist/index.js +16 -17
- package/dist/internal/compiler/closure.d.ts +14 -16
- package/dist/internal/compiler/closure.d.ts.map +1 -1
- package/dist/internal/compiler/closure.js +1458 -1637
- package/dist/internal/compiler/closure.js.map +1 -1
- package/dist/internal/compiler/entries.d.ts +11 -11
- package/dist/internal/compiler/entries.d.ts.map +1 -1
- package/dist/internal/compiler/entries.js +36 -26
- package/dist/internal/compiler/entries.js.map +1 -1
- package/dist/internal/compiler/first.d.ts +19 -19
- package/dist/internal/compiler/first.d.ts.map +1 -1
- package/dist/internal/compiler/first.js +251 -227
- package/dist/internal/compiler/first.js.map +1 -1
- package/dist/internal/compiler/jit.d.ts +6 -17
- package/dist/internal/compiler/jit.d.ts.map +1 -1
- package/dist/internal/compiler/jit.js +860 -988
- package/dist/internal/compiler/jit.js.map +1 -1
- package/dist/internal/compiler/registry.d.ts +20 -21
- package/dist/internal/compiler/registry.d.ts.map +1 -1
- package/dist/internal/compiler/registry.js +21 -41
- package/dist/internal/compiler/registry.js.map +1 -1
- package/dist/internal/compiler/sets.d.ts +9 -13
- package/dist/internal/compiler/sets.d.ts.map +1 -1
- package/dist/internal/compiler/sets.js +76 -73
- package/dist/internal/compiler/sets.js.map +1 -1
- package/dist/internal/entries.d.ts +3 -3
- package/dist/internal/entries.d.ts.map +1 -1
- package/dist/internal/entries.js +38 -30
- package/dist/internal/entries.js.map +1 -1
- package/dist/internal/node.d.ts +177 -173
- package/dist/internal/node.d.ts.map +1 -1
- package/dist/internal/node.js +77 -66
- package/dist/internal/node.js.map +1 -1
- package/dist/internal/numbers.d.ts +7 -8
- package/dist/internal/numbers.d.ts.map +1 -1
- package/dist/internal/numbers.js +246 -276
- package/dist/internal/numbers.js.map +1 -1
- package/dist/internal/resume.d.ts +6 -24
- package/dist/internal/resume.d.ts.map +1 -1
- package/dist/internal/resume.js +30 -29
- package/dist/internal/resume.js.map +1 -1
- package/dist/internal/run.d.ts +15 -0
- package/dist/internal/run.d.ts.map +1 -0
- package/dist/internal/run.js +36 -0
- package/dist/internal/run.js.map +1 -0
- package/dist/internal/stack.d.ts +16 -0
- package/dist/internal/stack.d.ts.map +1 -0
- package/dist/internal/stack.js +26 -0
- package/dist/internal/stack.js.map +1 -0
- package/dist/internal/syntax.d.ts +146 -0
- package/dist/internal/syntax.d.ts.map +1 -0
- package/dist/internal/syntax.js +305 -0
- package/dist/internal/syntax.js.map +1 -0
- package/dist/internal/text.d.ts +10 -2
- package/dist/internal/text.d.ts.map +1 -1
- package/dist/internal/text.js +295 -345
- package/dist/internal/text.js.map +1 -1
- package/dist/internal/tokens.d.ts +25 -30
- package/dist/internal/tokens.d.ts.map +1 -1
- package/dist/internal/tokens.js +369 -363
- package/dist/internal/tokens.js.map +1 -1
- package/package.json +42 -28
- package/src/Ascii.ts +278 -187
- package/src/Binary.ts +150 -44
- package/src/Bits.ts +6 -3
- package/src/Compiler.ts +98 -0
- package/src/Expression.ts +10 -5
- package/src/Input.ts +106 -28
- package/src/Nom.ts +4 -3
- package/src/ParseError.ts +48 -51
- package/src/Parser.ts +1163 -795
- package/src/ParserStream.ts +104 -80
- package/src/Syntax.ts +900 -0
- package/src/Text.ts +272 -187
- package/src/Token.ts +180 -87
- package/src/index.ts +2 -0
- package/src/internal/compiler/closure.ts +121 -88
- package/src/internal/compiler/entries.ts +21 -8
- package/src/internal/compiler/first.ts +17 -15
- package/src/internal/compiler/jit.ts +360 -157
- package/src/internal/compiler/registry.ts +12 -33
- package/src/internal/compiler/sets.ts +17 -11
- package/src/internal/entries.ts +4 -2
- package/src/internal/node.ts +51 -37
- package/src/internal/numbers.ts +22 -20
- package/src/internal/resume.ts +8 -4
- package/src/internal/run.ts +41 -0
- package/src/internal/stack.ts +36 -0
- package/src/internal/syntax.ts +421 -0
- package/src/internal/text.ts +32 -25
- package/src/internal/tokens.ts +96 -51
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/Nom.js
CHANGED
|
@@ -1,519 +1,489 @@
|
|
|
1
|
-
|
|
2
|
-
* nom-flavoured names for effect-parse's parsers and combinators.
|
|
3
|
-
*
|
|
4
|
-
* effect-parse's main API follows winnow's naming (in camelCase). This module
|
|
5
|
-
* offers the names, and argument orders, that nom users know, so grammars
|
|
6
|
-
* can be ported with minimal changes:
|
|
7
|
-
*
|
|
8
|
-
* | nom | effect-parse |
|
|
9
|
-
* |---|---|
|
|
10
|
-
* | `tag("abc")` | `Token.literal("abc")` |
|
|
11
|
-
* | `many0(p)` | `Parser.repeat(p)` |
|
|
12
|
-
* | `separated_list1(sep, p)` | `Parser.separated(p, sep, { min: 1 })` |
|
|
13
|
-
* | `map_res(p, f)` | `Parser.tryMap(p, f)` |
|
|
14
|
-
* | `recognize(p)` | `Parser.taken(p)` |
|
|
15
|
-
* | `value(v, p)` | `Parser.as(p, v)` |
|
|
16
|
-
*
|
|
17
|
-
* nom's `streaming` and `complete` variants are not separate functions here.
|
|
18
|
-
* Whether input is partial is decided by the runner (`Parser.parsePartial`
|
|
19
|
-
* vs `Parser.parse`).
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { Result } from "effect"
|
|
24
|
-
* import { Nom, Parser } from "@thomasfosterau/effect-parse"
|
|
25
|
-
*
|
|
26
|
-
* const hexPrimary = Nom.mapRes(
|
|
27
|
-
* Nom.takeWhileMN(2, 2, (c: string) => /[0-9a-fA-F]/.test(c)),
|
|
28
|
-
* (s) => Result.succeed(parseInt(s, 16))
|
|
29
|
-
* )
|
|
30
|
-
* const hexColor = Nom.preceded(
|
|
31
|
-
* Nom.tag("#"),
|
|
32
|
-
* Nom.tuple(hexPrimary, hexPrimary, hexPrimary)
|
|
33
|
-
* )
|
|
34
|
-
*
|
|
35
|
-
* Parser.parse(hexColor, "#2F14DF") // Result.succeed([47, 20, 223])
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @since 0.1.0
|
|
39
|
-
*/
|
|
40
|
-
import * as Option from "effect/Option";
|
|
41
|
-
import * as Result from "effect/Result";
|
|
42
|
-
import * as Ascii from "./Ascii.js";
|
|
43
|
-
import * as Binary from "./Binary.js";
|
|
1
|
+
import "effect/Result";
|
|
44
2
|
import * as P from "./Parser.js";
|
|
45
3
|
import * as Token from "./Token.js";
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
4
|
+
import "effect/Option";
|
|
5
|
+
import * as Ascii from "./Ascii.js";
|
|
6
|
+
import * as Binary from "./Binary.js";
|
|
7
|
+
//#region src/Nom.ts
|
|
8
|
+
/**
|
|
9
|
+
* Matches a literal (nom's `tag`).
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
* @category bytes
|
|
13
|
+
*/
|
|
14
|
+
const tag = Token.literal;
|
|
15
|
+
/**
|
|
16
|
+
* Matches a literal, ignoring ASCII case (nom's `tag_no_case`).
|
|
17
|
+
*
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
* @category bytes
|
|
20
|
+
*/
|
|
21
|
+
const tagNoCase = Ascii.caseless;
|
|
22
|
+
/**
|
|
23
|
+
* Matches a single character (nom's `char`).
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
* @category character
|
|
27
|
+
*/
|
|
28
|
+
const char = (c) => Token.literal(c);
|
|
29
|
+
/**
|
|
30
|
+
* Matches any character (nom's `anychar`).
|
|
31
|
+
*
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
* @category character
|
|
34
|
+
*/
|
|
35
|
+
const anychar = Token.any;
|
|
36
|
+
/**
|
|
37
|
+
* @since 0.1.0
|
|
38
|
+
* @category character
|
|
39
|
+
*/
|
|
40
|
+
const oneOf = Token.oneOf;
|
|
41
|
+
/**
|
|
42
|
+
* @since 0.1.0
|
|
43
|
+
* @category character
|
|
44
|
+
*/
|
|
45
|
+
const noneOf = Token.noneOf;
|
|
46
|
+
/**
|
|
47
|
+
* @since 0.1.0
|
|
48
|
+
* @category character
|
|
49
|
+
*/
|
|
50
|
+
const satisfy = Token.satisfy;
|
|
51
|
+
/**
|
|
52
|
+
* The longest non-empty run of tokens from a set (nom's `is_a`).
|
|
53
|
+
*
|
|
54
|
+
* @since 0.1.0
|
|
55
|
+
* @category bytes
|
|
56
|
+
*/
|
|
57
|
+
const isA = (set) => Token.takeWhile(set, { min: 1 });
|
|
58
|
+
/**
|
|
59
|
+
* The longest non-empty run of tokens *not* from a set (nom's `is_not`).
|
|
60
|
+
*
|
|
61
|
+
* @since 0.1.0
|
|
62
|
+
* @category bytes
|
|
63
|
+
*/
|
|
64
|
+
const isNot = (set) => Token.takeTill(set, { min: 1 });
|
|
65
|
+
/**
|
|
66
|
+
* @since 0.1.0
|
|
67
|
+
* @category bytes
|
|
68
|
+
*/
|
|
69
|
+
const take = Token.take;
|
|
70
|
+
/**
|
|
71
|
+
* @since 0.1.0
|
|
72
|
+
* @category bytes
|
|
73
|
+
*/
|
|
74
|
+
const takeWhile = (predicate) => Token.takeWhile(predicate);
|
|
75
|
+
/**
|
|
76
|
+
* @since 0.1.0
|
|
77
|
+
* @category bytes
|
|
78
|
+
*/
|
|
79
|
+
const takeWhile1 = (predicate) => Token.takeWhile(predicate, { min: 1 });
|
|
80
|
+
/**
|
|
81
|
+
* @since 0.1.0
|
|
82
|
+
* @category bytes
|
|
83
|
+
*/
|
|
84
|
+
const takeWhileMN = (m, n, predicate) => Token.takeWhile(predicate, {
|
|
85
|
+
min: m,
|
|
86
|
+
max: n
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* @since 0.1.0
|
|
90
|
+
* @category bytes
|
|
91
|
+
*/
|
|
92
|
+
const takeTill = (predicate) => Token.takeTill(predicate);
|
|
93
|
+
/**
|
|
94
|
+
* @since 0.1.0
|
|
95
|
+
* @category bytes
|
|
96
|
+
*/
|
|
97
|
+
const takeTill1 = (predicate) => Token.takeTill(predicate, { min: 1 });
|
|
98
|
+
/**
|
|
99
|
+
* @since 0.1.0
|
|
100
|
+
* @category bytes
|
|
101
|
+
*/
|
|
102
|
+
const takeUntil = Token.takeUntil;
|
|
103
|
+
/**
|
|
104
|
+
* Recognizes an escaped string (nom's `escaped`).
|
|
105
|
+
*
|
|
106
|
+
* @since 0.1.0
|
|
107
|
+
* @category bytes
|
|
108
|
+
*/
|
|
109
|
+
const escaped = Ascii.takeEscaped;
|
|
110
|
+
/**
|
|
111
|
+
* Unescapes an escaped string (nom's `escaped_transform`).
|
|
112
|
+
*
|
|
113
|
+
* @since 0.1.0
|
|
114
|
+
* @category bytes
|
|
115
|
+
*/
|
|
116
|
+
const escapedTransform = Ascii.escaped;
|
|
155
117
|
/** @since 0.1.0 @category character */
|
|
156
|
-
|
|
118
|
+
const alpha0 = Ascii.alpha0;
|
|
157
119
|
/** @since 0.1.0 @category character */
|
|
158
|
-
|
|
120
|
+
const alpha1 = Ascii.alpha1;
|
|
159
121
|
/** @since 0.1.0 @category character */
|
|
160
|
-
|
|
122
|
+
const digit0 = Ascii.digit0;
|
|
161
123
|
/** @since 0.1.0 @category character */
|
|
162
|
-
|
|
124
|
+
const digit1 = Ascii.digit1;
|
|
163
125
|
/** @since 0.1.0 @category character */
|
|
164
|
-
|
|
126
|
+
const hexDigit0 = Ascii.hexDigit0;
|
|
165
127
|
/** @since 0.1.0 @category character */
|
|
166
|
-
|
|
128
|
+
const hexDigit1 = Ascii.hexDigit1;
|
|
167
129
|
/** @since 0.1.0 @category character */
|
|
168
|
-
|
|
130
|
+
const octDigit0 = Ascii.octDigit0;
|
|
169
131
|
/** @since 0.1.0 @category character */
|
|
170
|
-
|
|
132
|
+
const octDigit1 = Ascii.octDigit1;
|
|
171
133
|
/** @since 0.1.0 @category character */
|
|
172
|
-
|
|
134
|
+
const alphanumeric0 = Ascii.alphanumeric0;
|
|
173
135
|
/** @since 0.1.0 @category character */
|
|
174
|
-
|
|
136
|
+
const alphanumeric1 = Ascii.alphanumeric1;
|
|
175
137
|
/** @since 0.1.0 @category character */
|
|
176
|
-
|
|
138
|
+
const space0 = Ascii.space0;
|
|
177
139
|
/** @since 0.1.0 @category character */
|
|
178
|
-
|
|
140
|
+
const space1 = Ascii.space1;
|
|
179
141
|
/** @since 0.1.0 @category character */
|
|
180
|
-
|
|
142
|
+
const multispace0 = Ascii.multispace0;
|
|
181
143
|
/** @since 0.1.0 @category character */
|
|
182
|
-
|
|
144
|
+
const multispace1 = Ascii.multispace1;
|
|
183
145
|
/** @since 0.1.0 @category character */
|
|
184
|
-
|
|
146
|
+
const lineEnding = Ascii.lineEnding;
|
|
185
147
|
/** @since 0.1.0 @category character */
|
|
186
|
-
|
|
148
|
+
const newline = Ascii.newline;
|
|
187
149
|
/** @since 0.1.0 @category character */
|
|
188
|
-
|
|
150
|
+
const tab = Ascii.tab;
|
|
189
151
|
/** @since 0.1.0 @category character */
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
* @category number
|
|
234
|
-
*/
|
|
235
|
-
export const hexU32 = Ascii.hexUint;
|
|
152
|
+
const crlf = Ascii.crlf;
|
|
153
|
+
/**
|
|
154
|
+
* nom's `not_line_ending`.
|
|
155
|
+
*
|
|
156
|
+
* @since 0.1.0
|
|
157
|
+
* @category character
|
|
158
|
+
*/
|
|
159
|
+
const notLineEnding = Ascii.tillLineEnding;
|
|
160
|
+
/**
|
|
161
|
+
* A decimal unsigned integer (nom's `character::complete::u64` and friends).
|
|
162
|
+
*
|
|
163
|
+
* @since 0.1.0
|
|
164
|
+
* @category character
|
|
165
|
+
*/
|
|
166
|
+
const u64 = Ascii.decUint;
|
|
167
|
+
/**
|
|
168
|
+
* A decimal signed integer (nom's `character::complete::i64` and friends).
|
|
169
|
+
*
|
|
170
|
+
* @since 0.1.0
|
|
171
|
+
* @category character
|
|
172
|
+
*/
|
|
173
|
+
const i64 = Ascii.decInt;
|
|
174
|
+
/**
|
|
175
|
+
* nom's `double` (and `float`).
|
|
176
|
+
*
|
|
177
|
+
* @since 0.1.0
|
|
178
|
+
* @category number
|
|
179
|
+
*/
|
|
180
|
+
const double = Ascii.float;
|
|
181
|
+
/**
|
|
182
|
+
* nom's `recognize_float`.
|
|
183
|
+
*
|
|
184
|
+
* @since 0.1.0
|
|
185
|
+
* @category number
|
|
186
|
+
*/
|
|
187
|
+
const recognizeFloat = /*#__PURE__*/ P.taken(Ascii.float);
|
|
188
|
+
/**
|
|
189
|
+
* nom's `hex_u32`.
|
|
190
|
+
*
|
|
191
|
+
* @since 0.1.0
|
|
192
|
+
* @category number
|
|
193
|
+
*/
|
|
194
|
+
const hexU32 = Ascii.hexUint;
|
|
236
195
|
/** @since 0.1.0 @category number */
|
|
237
|
-
|
|
196
|
+
const beU8 = Binary.u8;
|
|
238
197
|
/** @since 0.1.0 @category number */
|
|
239
|
-
|
|
198
|
+
const beI8 = Binary.i8;
|
|
240
199
|
/** @since 0.1.0 @category number */
|
|
241
|
-
|
|
200
|
+
const leU8 = Binary.u8;
|
|
242
201
|
/** @since 0.1.0 @category number */
|
|
243
|
-
|
|
202
|
+
const leI8 = Binary.i8;
|
|
244
203
|
/** @since 0.1.0 @category number */
|
|
245
|
-
|
|
204
|
+
const beU16 = Binary.beU16;
|
|
246
205
|
/** @since 0.1.0 @category number */
|
|
247
|
-
|
|
206
|
+
const leU16 = Binary.leU16;
|
|
248
207
|
/** @since 0.1.0 @category number */
|
|
249
|
-
|
|
208
|
+
const beI16 = Binary.beI16;
|
|
250
209
|
/** @since 0.1.0 @category number */
|
|
251
|
-
|
|
210
|
+
const leI16 = Binary.leI16;
|
|
252
211
|
/** @since 0.1.0 @category number */
|
|
253
|
-
|
|
212
|
+
const beU24 = Binary.beU24;
|
|
254
213
|
/** @since 0.1.0 @category number */
|
|
255
|
-
|
|
214
|
+
const leU24 = Binary.leU24;
|
|
256
215
|
/** @since 0.1.0 @category number */
|
|
257
|
-
|
|
216
|
+
const beI24 = Binary.beI24;
|
|
258
217
|
/** @since 0.1.0 @category number */
|
|
259
|
-
|
|
218
|
+
const leI24 = Binary.leI24;
|
|
260
219
|
/** @since 0.1.0 @category number */
|
|
261
|
-
|
|
220
|
+
const beU32 = Binary.beU32;
|
|
262
221
|
/** @since 0.1.0 @category number */
|
|
263
|
-
|
|
222
|
+
const leU32 = Binary.leU32;
|
|
264
223
|
/** @since 0.1.0 @category number */
|
|
265
|
-
|
|
224
|
+
const beI32 = Binary.beI32;
|
|
266
225
|
/** @since 0.1.0 @category number */
|
|
267
|
-
|
|
226
|
+
const leI32 = Binary.leI32;
|
|
268
227
|
/** @since 0.1.0 @category number */
|
|
269
|
-
|
|
228
|
+
const beU64 = Binary.beU64;
|
|
270
229
|
/** @since 0.1.0 @category number */
|
|
271
|
-
|
|
230
|
+
const leU64 = Binary.leU64;
|
|
272
231
|
/** @since 0.1.0 @category number */
|
|
273
|
-
|
|
232
|
+
const beI64 = Binary.beI64;
|
|
274
233
|
/** @since 0.1.0 @category number */
|
|
275
|
-
|
|
234
|
+
const leI64 = Binary.leI64;
|
|
276
235
|
/** @since 0.1.0 @category number */
|
|
277
|
-
|
|
236
|
+
const beU128 = Binary.beU128;
|
|
278
237
|
/** @since 0.1.0 @category number */
|
|
279
|
-
|
|
238
|
+
const leU128 = Binary.leU128;
|
|
280
239
|
/** @since 0.1.0 @category number */
|
|
281
|
-
|
|
240
|
+
const beI128 = Binary.beI128;
|
|
282
241
|
/** @since 0.1.0 @category number */
|
|
283
|
-
|
|
242
|
+
const leI128 = Binary.leI128;
|
|
284
243
|
/** @since 0.1.0 @category number */
|
|
285
|
-
|
|
244
|
+
const beF32 = Binary.beF32;
|
|
286
245
|
/** @since 0.1.0 @category number */
|
|
287
|
-
|
|
246
|
+
const leF32 = Binary.leF32;
|
|
288
247
|
/** @since 0.1.0 @category number */
|
|
289
|
-
|
|
248
|
+
const beF64 = Binary.beF64;
|
|
290
249
|
/** @since 0.1.0 @category number */
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
250
|
+
const leF64 = Binary.leF64;
|
|
251
|
+
/**
|
|
252
|
+
* Zero or more (nom's `many0`).
|
|
253
|
+
*
|
|
254
|
+
* @since 0.1.0
|
|
255
|
+
* @category multi
|
|
256
|
+
*/
|
|
257
|
+
const many0 = (parser) => P.repeat(parser);
|
|
258
|
+
/**
|
|
259
|
+
* One or more (nom's `many1`).
|
|
260
|
+
*
|
|
261
|
+
* @since 0.1.0
|
|
262
|
+
* @category multi
|
|
263
|
+
*/
|
|
264
|
+
const many1 = (parser) => P.repeat(parser, { min: 1 });
|
|
265
|
+
/**
|
|
266
|
+
* Between `m` and `n` times (nom's `many_m_n`).
|
|
267
|
+
*
|
|
268
|
+
* @since 0.1.0
|
|
269
|
+
* @category multi
|
|
270
|
+
*/
|
|
271
|
+
const manyMN = (m, n, parser) => P.repeat(parser, {
|
|
272
|
+
min: m,
|
|
273
|
+
max: n
|
|
274
|
+
});
|
|
275
|
+
/**
|
|
276
|
+
* Exactly `count` times (nom's `count`).
|
|
277
|
+
*
|
|
278
|
+
* @since 0.1.0
|
|
279
|
+
* @category multi
|
|
280
|
+
*/
|
|
281
|
+
const count = (parser, count) => P.repeat(parser, count);
|
|
282
|
+
/**
|
|
283
|
+
* Repeats `parser` until `end` succeeds (nom's `many_till`).
|
|
284
|
+
*
|
|
285
|
+
* @since 0.1.0
|
|
286
|
+
* @category multi
|
|
287
|
+
*/
|
|
288
|
+
const manyTill = (parser, end) => P.repeatTill(parser, end);
|
|
289
|
+
/**
|
|
290
|
+
* Zero or more `parser` separated by `separator` (nom's `separated_list0`;
|
|
291
|
+
* note the separator comes first).
|
|
292
|
+
*
|
|
293
|
+
* @since 0.1.0
|
|
294
|
+
* @category multi
|
|
295
|
+
*/
|
|
296
|
+
const separatedList0 = (separator, parser) => P.separated(parser, separator);
|
|
297
|
+
/**
|
|
298
|
+
* One or more `parser` separated by `separator` (nom's `separated_list1`;
|
|
299
|
+
* note the separator comes first).
|
|
300
|
+
*
|
|
301
|
+
* @since 0.1.0
|
|
302
|
+
* @category multi
|
|
303
|
+
*/
|
|
304
|
+
const separatedList1 = (separator, parser) => P.separated(parser, separator, { min: 1 });
|
|
305
|
+
/**
|
|
306
|
+
* Folds zero or more (nom's `fold_many0`).
|
|
307
|
+
*
|
|
308
|
+
* @since 0.1.0
|
|
309
|
+
* @category multi
|
|
310
|
+
*/
|
|
311
|
+
const foldMany0 = (parser, init, f) => P.fold(parser, {
|
|
312
|
+
init,
|
|
313
|
+
f
|
|
314
|
+
});
|
|
315
|
+
/**
|
|
316
|
+
* Folds one or more (nom's `fold_many1`).
|
|
317
|
+
*
|
|
318
|
+
* @since 0.1.0
|
|
319
|
+
* @category multi
|
|
320
|
+
*/
|
|
321
|
+
const foldMany1 = (parser, init, f) => P.fold(parser, {
|
|
322
|
+
init,
|
|
323
|
+
f,
|
|
324
|
+
range: { min: 1 }
|
|
325
|
+
});
|
|
326
|
+
/**
|
|
327
|
+
* Folds between `m` and `n` times (nom's `fold_many_m_n`).
|
|
328
|
+
*
|
|
329
|
+
* @since 0.1.0
|
|
330
|
+
* @category multi
|
|
331
|
+
*/
|
|
332
|
+
const foldManyMN = (m, n, parser, init, f) => P.fold(parser, {
|
|
333
|
+
init,
|
|
334
|
+
f,
|
|
335
|
+
range: {
|
|
336
|
+
min: m,
|
|
337
|
+
max: n
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
/**
|
|
341
|
+
* nom's `length_data`.
|
|
342
|
+
*
|
|
343
|
+
* @since 0.1.0
|
|
344
|
+
* @category multi
|
|
345
|
+
*/
|
|
346
|
+
const lengthData = Binary.lengthTake;
|
|
347
|
+
/**
|
|
348
|
+
* nom's `length_value`.
|
|
349
|
+
*
|
|
350
|
+
* @since 0.1.0
|
|
351
|
+
* @category multi
|
|
352
|
+
*/
|
|
353
|
+
const lengthValue = Binary.lengthAndThen;
|
|
354
|
+
/**
|
|
355
|
+
* nom's `length_count`.
|
|
356
|
+
*
|
|
357
|
+
* @since 0.1.0
|
|
358
|
+
* @category multi
|
|
359
|
+
*/
|
|
360
|
+
const lengthCount = Binary.lengthRepeat;
|
|
361
|
+
/**
|
|
362
|
+
* nom's `pair`.
|
|
363
|
+
*
|
|
364
|
+
* @since 0.1.0
|
|
365
|
+
* @category sequence
|
|
366
|
+
*/
|
|
367
|
+
const pair = (first, second) => P.zip(first, second);
|
|
368
|
+
/**
|
|
369
|
+
* nom's tuples of parsers (`(a, b, c)`, formerly `tuple`).
|
|
370
|
+
*
|
|
371
|
+
* @since 0.1.0
|
|
372
|
+
* @category sequence
|
|
373
|
+
*/
|
|
374
|
+
const tuple = P.seq;
|
|
405
375
|
/** @since 0.1.0 @category sequence */
|
|
406
|
-
|
|
376
|
+
const preceded = P.preceded;
|
|
407
377
|
/** @since 0.1.0 @category sequence */
|
|
408
|
-
|
|
378
|
+
const terminated = P.terminated;
|
|
409
379
|
/** @since 0.1.0 @category sequence */
|
|
410
|
-
|
|
380
|
+
const delimited = P.delimited;
|
|
411
381
|
/** @since 0.1.0 @category sequence */
|
|
412
|
-
|
|
382
|
+
const separatedPair = P.separatedPair;
|
|
413
383
|
/** @since 0.1.0 @category branch */
|
|
414
|
-
|
|
384
|
+
const alt = P.alt;
|
|
415
385
|
/** @since 0.1.0 @category branch */
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
* @category combinator
|
|
481
|
-
*/
|
|
482
|
-
export const consumed = (parser) => P.map(P.withTaken(parser), ([a, s]) => [s, a]);
|
|
386
|
+
const permutation = P.permutation;
|
|
387
|
+
/**
|
|
388
|
+
* nom's `map`.
|
|
389
|
+
*
|
|
390
|
+
* @since 0.1.0
|
|
391
|
+
* @category combinator
|
|
392
|
+
*/
|
|
393
|
+
const map = (parser, f) => P.map(parser, f);
|
|
394
|
+
/**
|
|
395
|
+
* nom's `map_res`: the function returns a `Result`.
|
|
396
|
+
*
|
|
397
|
+
* @since 0.1.0
|
|
398
|
+
* @category combinator
|
|
399
|
+
*/
|
|
400
|
+
const mapRes = (parser, f) => P.tryMap(parser, f);
|
|
401
|
+
/**
|
|
402
|
+
* nom's `map_opt`: the function returns an `Option`.
|
|
403
|
+
*
|
|
404
|
+
* @since 0.1.0
|
|
405
|
+
* @category combinator
|
|
406
|
+
*/
|
|
407
|
+
const mapOpt = (parser, f) => P.filterMap(parser, f);
|
|
408
|
+
/**
|
|
409
|
+
* nom's `map_parser`.
|
|
410
|
+
*
|
|
411
|
+
* @since 0.1.0
|
|
412
|
+
* @category combinator
|
|
413
|
+
*/
|
|
414
|
+
const mapParser = (parser, applied) => P.mapParser(parser, applied);
|
|
415
|
+
/**
|
|
416
|
+
* nom's `flat_map`.
|
|
417
|
+
*
|
|
418
|
+
* @since 0.1.0
|
|
419
|
+
* @category combinator
|
|
420
|
+
*/
|
|
421
|
+
const flatMap = (parser, f) => P.flatMap(parser, f);
|
|
422
|
+
/**
|
|
423
|
+
* nom's `value` (note the value comes first).
|
|
424
|
+
*
|
|
425
|
+
* @since 0.1.0
|
|
426
|
+
* @category combinator
|
|
427
|
+
*/
|
|
428
|
+
const value = (val, parser) => P.as(parser, val);
|
|
429
|
+
/**
|
|
430
|
+
* nom's `verify`.
|
|
431
|
+
*
|
|
432
|
+
* @since 0.1.0
|
|
433
|
+
* @category combinator
|
|
434
|
+
*/
|
|
435
|
+
const verify = (parser, predicate) => P.filter(parser, predicate);
|
|
436
|
+
/**
|
|
437
|
+
* nom's `recognize`.
|
|
438
|
+
*
|
|
439
|
+
* @since 0.1.0
|
|
440
|
+
* @category combinator
|
|
441
|
+
*/
|
|
442
|
+
const recognize = P.taken;
|
|
443
|
+
/**
|
|
444
|
+
* nom's `consumed`: returns `[consumed, output]`.
|
|
445
|
+
*
|
|
446
|
+
* @since 0.1.0
|
|
447
|
+
* @category combinator
|
|
448
|
+
*/
|
|
449
|
+
const consumed = (parser) => P.map(P.withTaken(parser), ([a, s]) => [s, a]);
|
|
483
450
|
/** @since 0.1.0 @category combinator */
|
|
484
|
-
|
|
451
|
+
const opt = P.opt;
|
|
485
452
|
/** @since 0.1.0 @category combinator */
|
|
486
|
-
|
|
453
|
+
const cond = P.cond;
|
|
487
454
|
/** @since 0.1.0 @category combinator */
|
|
488
|
-
|
|
455
|
+
const peek = P.peek;
|
|
489
456
|
/** @since 0.1.0 @category combinator */
|
|
490
|
-
|
|
457
|
+
const not = P.not;
|
|
491
458
|
/** @since 0.1.0 @category combinator */
|
|
492
|
-
|
|
459
|
+
const eof = P.eof;
|
|
493
460
|
/** @since 0.1.0 @category combinator */
|
|
494
|
-
|
|
461
|
+
const allConsuming = P.allConsuming;
|
|
495
462
|
/** @since 0.1.0 @category combinator */
|
|
496
|
-
|
|
463
|
+
const complete = P.complete;
|
|
497
464
|
/** @since 0.1.0 @category combinator */
|
|
498
|
-
|
|
465
|
+
const cut = P.cut;
|
|
499
466
|
/** @since 0.1.0 @category combinator */
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
467
|
+
const success = P.succeed;
|
|
468
|
+
/**
|
|
469
|
+
* nom's `fail()`.
|
|
470
|
+
*
|
|
471
|
+
* @since 0.1.0
|
|
472
|
+
* @category combinator
|
|
473
|
+
*/
|
|
474
|
+
const fail = P.reject;
|
|
508
475
|
/** @since 0.1.0 @category combinator */
|
|
509
|
-
|
|
476
|
+
const rest = Token.rest;
|
|
510
477
|
/** @since 0.1.0 @category combinator */
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
478
|
+
const restLen = Token.restLen;
|
|
479
|
+
/**
|
|
480
|
+
* nom's `context` (note the label comes first).
|
|
481
|
+
*
|
|
482
|
+
* @since 0.1.0
|
|
483
|
+
* @category error
|
|
484
|
+
*/
|
|
485
|
+
const context = (label, parser) => P.context(parser, label);
|
|
486
|
+
//#endregion
|
|
487
|
+
export { allConsuming, alpha0, alpha1, alphanumeric0, alphanumeric1, alt, anychar, beF32, beF64, beI128, beI16, beI24, beI32, beI64, beI8, beU128, beU16, beU24, beU32, beU64, beU8, char, complete, cond, consumed, context, count, crlf, cut, delimited, digit0, digit1, double, eof, escaped, escapedTransform, fail, flatMap, foldMany0, foldMany1, foldManyMN, hexDigit0, hexDigit1, hexU32, i64, isA, isNot, leF32, leF64, leI128, leI16, leI24, leI32, leI64, leI8, leU128, leU16, leU24, leU32, leU64, leU8, lengthCount, lengthData, lengthValue, lineEnding, many0, many1, manyMN, manyTill, map, mapOpt, mapParser, mapRes, multispace0, multispace1, newline, noneOf, not, notLineEnding, octDigit0, octDigit1, oneOf, opt, pair, peek, permutation, preceded, recognize, recognizeFloat, rest, restLen, satisfy, separatedList0, separatedList1, separatedPair, space0, space1, success, tab, tag, tagNoCase, take, takeTill, takeTill1, takeUntil, takeWhile, takeWhile1, takeWhileMN, terminated, tuple, u64, value, verify };
|
|
488
|
+
|
|
519
489
|
//# sourceMappingURL=Nom.js.map
|