@thomasfosterau/effect-parse 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +550 -2
- package/dist/Ascii.d.ts +392 -0
- package/dist/Ascii.d.ts.map +1 -0
- package/dist/Ascii.js +610 -0
- package/dist/Ascii.js.map +1 -0
- package/dist/Binary.d.ts +153 -0
- package/dist/Binary.d.ts.map +1 -0
- package/dist/Binary.js +171 -0
- package/dist/Binary.js.map +1 -0
- package/dist/Bits.d.ts +60 -0
- package/dist/Bits.d.ts.map +1 -0
- package/dist/Bits.js +144 -0
- package/dist/Bits.js.map +1 -0
- package/dist/Encoding.d.ts +116 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +85 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Expression.d.ts +124 -0
- package/dist/Expression.d.ts.map +1 -0
- package/dist/Expression.js +139 -0
- package/dist/Expression.js.map +1 -0
- package/dist/Input.d.ts +301 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +312 -0
- package/dist/Input.js.map +1 -0
- package/dist/Nom.d.ts +518 -0
- package/dist/Nom.d.ts.map +1 -0
- package/dist/Nom.js +519 -0
- package/dist/Nom.js.map +1 -0
- package/dist/ParseError.d.ts +120 -0
- package/dist/ParseError.d.ts.map +1 -0
- package/dist/ParseError.js +301 -0
- package/dist/ParseError.js.map +1 -0
- package/dist/Parser.d.ts +1312 -0
- package/dist/Parser.d.ts.map +1 -0
- package/dist/Parser.js +1936 -0
- package/dist/Parser.js.map +1 -0
- package/dist/ParserSchema.d.ts +31 -0
- package/dist/ParserSchema.d.ts.map +1 -0
- package/dist/ParserSchema.js +56 -0
- package/dist/ParserSchema.js.map +1 -0
- package/dist/ParserStream.d.ts +127 -0
- package/dist/ParserStream.d.ts.map +1 -0
- package/dist/ParserStream.js +270 -0
- package/dist/ParserStream.js.map +1 -0
- package/dist/Text.d.ts +330 -0
- package/dist/Text.d.ts.map +1 -0
- package/dist/Text.js +529 -0
- package/dist/Text.js.map +1 -0
- package/dist/Token.d.ts +225 -0
- package/dist/Token.d.ts.map +1 -0
- package/dist/Token.js +294 -0
- package/dist/Token.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/compiler/closure.d.ts +25 -0
- package/dist/internal/compiler/closure.d.ts.map +1 -0
- package/dist/internal/compiler/closure.js +1668 -0
- package/dist/internal/compiler/closure.js.map +1 -0
- package/dist/internal/compiler/entries.d.ts +19 -0
- package/dist/internal/compiler/entries.d.ts.map +1 -0
- package/dist/internal/compiler/entries.js +32 -0
- package/dist/internal/compiler/entries.js.map +1 -0
- package/dist/internal/compiler/first.d.ts +33 -0
- package/dist/internal/compiler/first.d.ts.map +1 -0
- package/dist/internal/compiler/first.js +235 -0
- package/dist/internal/compiler/first.js.map +1 -0
- package/dist/internal/compiler/jit.d.ts +20 -0
- package/dist/internal/compiler/jit.d.ts.map +1 -0
- package/dist/internal/compiler/jit.js +1030 -0
- package/dist/internal/compiler/jit.js.map +1 -0
- package/dist/internal/compiler/registry.d.ts +34 -0
- package/dist/internal/compiler/registry.d.ts.map +1 -0
- package/dist/internal/compiler/registry.js +46 -0
- package/dist/internal/compiler/registry.js.map +1 -0
- package/dist/internal/compiler/sets.d.ts +29 -0
- package/dist/internal/compiler/sets.d.ts.map +1 -0
- package/dist/internal/compiler/sets.js +85 -0
- package/dist/internal/compiler/sets.js.map +1 -0
- package/dist/internal/entries.d.ts +27 -0
- package/dist/internal/entries.d.ts.map +1 -0
- package/dist/internal/entries.js +42 -0
- package/dist/internal/entries.js.map +1 -0
- package/dist/internal/node.d.ts +251 -0
- package/dist/internal/node.d.ts.map +1 -0
- package/dist/internal/node.js +73 -0
- package/dist/internal/node.js.map +1 -0
- package/dist/internal/numbers.d.ts +41 -0
- package/dist/internal/numbers.d.ts.map +1 -0
- package/dist/internal/numbers.js +302 -0
- package/dist/internal/numbers.js.map +1 -0
- package/dist/internal/resume.d.ts +39 -0
- package/dist/internal/resume.d.ts.map +1 -0
- package/dist/internal/resume.js +37 -0
- package/dist/internal/resume.js.map +1 -0
- package/dist/internal/text.d.ts +72 -0
- package/dist/internal/text.d.ts.map +1 -0
- package/dist/internal/text.js +391 -0
- package/dist/internal/text.js.map +1 -0
- package/dist/internal/tokens.d.ts +93 -0
- package/dist/internal/tokens.d.ts.map +1 -0
- package/dist/internal/tokens.js +400 -0
- package/dist/internal/tokens.js.map +1 -0
- package/package.json +115 -3
- package/src/Ascii.ts +741 -0
- package/src/Binary.ts +228 -0
- package/src/Bits.ts +192 -0
- package/src/Encoding.ts +128 -0
- package/src/Expression.ts +245 -0
- package/src/Input.ts +429 -0
- package/src/Nom.ts +642 -0
- package/src/ParseError.ts +378 -0
- package/src/Parser.ts +2763 -0
- package/src/ParserSchema.ts +87 -0
- package/src/ParserStream.ts +390 -0
- package/src/Text.ts +757 -0
- package/src/Token.ts +416 -0
- package/src/index.ts +16 -0
- package/src/internal/compiler/closure.ts +1583 -0
- package/src/internal/compiler/entries.ts +36 -0
- package/src/internal/compiler/first.ts +252 -0
- package/src/internal/compiler/jit.ts +1091 -0
- package/src/internal/compiler/registry.ts +79 -0
- package/src/internal/compiler/sets.ts +100 -0
- package/src/internal/entries.ts +51 -0
- package/src/internal/node.ts +207 -0
- package/src/internal/numbers.ts +291 -0
- package/src/internal/resume.ts +55 -0
- package/src/internal/text.ts +411 -0
- package/src/internal/tokens.ts +409 -0
package/dist/Ascii.d.ts
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsers for ASCII text: character classes, line endings, numbers and
|
|
3
|
+
* escaped strings (winnow's `ascii` module, nom's `character` module).
|
|
4
|
+
*
|
|
5
|
+
* The parsers are typed for `string` input. Each also works on
|
|
6
|
+
* `Uint8Array` input (treating bytes as ASCII), and `Ascii.bytes` gives the
|
|
7
|
+
* same parsers typed for bytes:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Ascii, Parser } from "@thomasfosterau/effect-parse"
|
|
11
|
+
*
|
|
12
|
+
* Parser.parse(Ascii.decUint, "42") // 42
|
|
13
|
+
* Parser.parse(Ascii.bytes.decUint, new TextEncoder().encode("42")) // 42
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Partial (streaming) input is supported: for example `digit1` on the
|
|
17
|
+
* partial input `"123"` reports `Incomplete`, since more digits may follow.
|
|
18
|
+
*
|
|
19
|
+
* For Unicode character classes, or for text in other encodings (UTF-8,
|
|
20
|
+
* UTF-16), use the `Text` module.
|
|
21
|
+
*
|
|
22
|
+
* @since 0.1.0
|
|
23
|
+
*/
|
|
24
|
+
import * as Result from "effect/Result";
|
|
25
|
+
import type { Encoding } from "./Encoding.js";
|
|
26
|
+
import type { Input, Slice, State } from "./Input.js";
|
|
27
|
+
import type { Parser } from "./Parser.js";
|
|
28
|
+
/**
|
|
29
|
+
* `[a-zA-Z]`
|
|
30
|
+
*
|
|
31
|
+
* @since 0.1.0
|
|
32
|
+
* @category predicates
|
|
33
|
+
*/
|
|
34
|
+
export declare const isAlpha: (c: string | number) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* `[0-9]`
|
|
37
|
+
*
|
|
38
|
+
* @since 0.1.0
|
|
39
|
+
* @category predicates
|
|
40
|
+
*/
|
|
41
|
+
export declare const isDigit: (c: string | number) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* `[0-9a-fA-F]`
|
|
44
|
+
*
|
|
45
|
+
* @since 0.1.0
|
|
46
|
+
* @category predicates
|
|
47
|
+
*/
|
|
48
|
+
export declare const isHexDigit: (c: string | number) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* `[0-7]`
|
|
51
|
+
*
|
|
52
|
+
* @since 0.1.0
|
|
53
|
+
* @category predicates
|
|
54
|
+
*/
|
|
55
|
+
export declare const isOctDigit: (c: string | number) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* `[0-9a-zA-Z]`
|
|
58
|
+
*
|
|
59
|
+
* @since 0.1.0
|
|
60
|
+
* @category predicates
|
|
61
|
+
*/
|
|
62
|
+
export declare const isAlphanumeric: (c: string | number) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* `[ \t]`
|
|
65
|
+
*
|
|
66
|
+
* @since 0.1.0
|
|
67
|
+
* @category predicates
|
|
68
|
+
*/
|
|
69
|
+
export declare const isSpace: (c: string | number) => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* `[ \t\r\n]`
|
|
72
|
+
*
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
* @category predicates
|
|
75
|
+
*/
|
|
76
|
+
export declare const isMultispace: (c: string | number) => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* `\n`
|
|
79
|
+
*
|
|
80
|
+
* @since 0.1.0
|
|
81
|
+
* @category predicates
|
|
82
|
+
*/
|
|
83
|
+
export declare const isNewline: (c: string | number) => boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Zero or more ASCII letters, `[a-zA-Z]*`.
|
|
86
|
+
*
|
|
87
|
+
* @since 0.1.0
|
|
88
|
+
* @category character classes
|
|
89
|
+
*/
|
|
90
|
+
export declare const alpha0: Parser<string>;
|
|
91
|
+
/**
|
|
92
|
+
* One or more ASCII letters, `[a-zA-Z]+`.
|
|
93
|
+
*
|
|
94
|
+
* @since 0.1.0
|
|
95
|
+
* @category character classes
|
|
96
|
+
*/
|
|
97
|
+
export declare const alpha1: Parser<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Zero or more ASCII digits, `[0-9]*`.
|
|
100
|
+
*
|
|
101
|
+
* @since 0.1.0
|
|
102
|
+
* @category character classes
|
|
103
|
+
*/
|
|
104
|
+
export declare const digit0: Parser<string>;
|
|
105
|
+
/**
|
|
106
|
+
* One or more ASCII digits, `[0-9]+`.
|
|
107
|
+
*
|
|
108
|
+
* @since 0.1.0
|
|
109
|
+
* @category character classes
|
|
110
|
+
*/
|
|
111
|
+
export declare const digit1: Parser<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Zero or more hexadecimal digits, `[0-9a-fA-F]*`.
|
|
114
|
+
*
|
|
115
|
+
* @since 0.1.0
|
|
116
|
+
* @category character classes
|
|
117
|
+
*/
|
|
118
|
+
export declare const hexDigit0: Parser<string>;
|
|
119
|
+
/**
|
|
120
|
+
* One or more hexadecimal digits, `[0-9a-fA-F]+`.
|
|
121
|
+
*
|
|
122
|
+
* @since 0.1.0
|
|
123
|
+
* @category character classes
|
|
124
|
+
*/
|
|
125
|
+
export declare const hexDigit1: Parser<string>;
|
|
126
|
+
/**
|
|
127
|
+
* Zero or more octal digits, `[0-7]*`.
|
|
128
|
+
*
|
|
129
|
+
* @since 0.1.0
|
|
130
|
+
* @category character classes
|
|
131
|
+
*/
|
|
132
|
+
export declare const octDigit0: Parser<string>;
|
|
133
|
+
/**
|
|
134
|
+
* One or more octal digits, `[0-7]+`.
|
|
135
|
+
*
|
|
136
|
+
* @since 0.1.0
|
|
137
|
+
* @category character classes
|
|
138
|
+
*/
|
|
139
|
+
export declare const octDigit1: Parser<string>;
|
|
140
|
+
/**
|
|
141
|
+
* Zero or more ASCII letters or digits, `[0-9a-zA-Z]*`.
|
|
142
|
+
*
|
|
143
|
+
* @since 0.1.0
|
|
144
|
+
* @category character classes
|
|
145
|
+
*/
|
|
146
|
+
export declare const alphanumeric0: Parser<string>;
|
|
147
|
+
/**
|
|
148
|
+
* One or more ASCII letters or digits, `[0-9a-zA-Z]+`.
|
|
149
|
+
*
|
|
150
|
+
* @since 0.1.0
|
|
151
|
+
* @category character classes
|
|
152
|
+
*/
|
|
153
|
+
export declare const alphanumeric1: Parser<string>;
|
|
154
|
+
/**
|
|
155
|
+
* Zero or more spaces and tabs, `[ \t]*`.
|
|
156
|
+
*
|
|
157
|
+
* @since 0.1.0
|
|
158
|
+
* @category character classes
|
|
159
|
+
*/
|
|
160
|
+
export declare const space0: Parser<string>;
|
|
161
|
+
/**
|
|
162
|
+
* One or more spaces and tabs, `[ \t]+`.
|
|
163
|
+
*
|
|
164
|
+
* @since 0.1.0
|
|
165
|
+
* @category character classes
|
|
166
|
+
*/
|
|
167
|
+
export declare const space1: Parser<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Zero or more spaces, tabs, carriage returns and line feeds,
|
|
170
|
+
* `[ \t\r\n]*`.
|
|
171
|
+
*
|
|
172
|
+
* @since 0.1.0
|
|
173
|
+
* @category character classes
|
|
174
|
+
*/
|
|
175
|
+
export declare const multispace0: Parser<string>;
|
|
176
|
+
/**
|
|
177
|
+
* One or more spaces, tabs, carriage returns and line feeds,
|
|
178
|
+
* `[ \t\r\n]+`.
|
|
179
|
+
*
|
|
180
|
+
* @since 0.1.0
|
|
181
|
+
* @category character classes
|
|
182
|
+
*/
|
|
183
|
+
export declare const multispace1: Parser<string>;
|
|
184
|
+
/**
|
|
185
|
+
* A carriage return followed by a line feed, `\r\n`.
|
|
186
|
+
*
|
|
187
|
+
* @since 0.1.0
|
|
188
|
+
* @category line endings
|
|
189
|
+
*/
|
|
190
|
+
export declare const crlf: Parser<"\r\n">;
|
|
191
|
+
/**
|
|
192
|
+
* A line feed, `\n` (nom's `newline`).
|
|
193
|
+
*
|
|
194
|
+
* @since 0.1.0
|
|
195
|
+
* @category line endings
|
|
196
|
+
*/
|
|
197
|
+
export declare const newline: Parser<"\n">;
|
|
198
|
+
/**
|
|
199
|
+
* A tab, `\t`.
|
|
200
|
+
*
|
|
201
|
+
* @since 0.1.0
|
|
202
|
+
* @category line endings
|
|
203
|
+
*/
|
|
204
|
+
export declare const tab: Parser<"\t">;
|
|
205
|
+
/**
|
|
206
|
+
* A line ending: `\n` or `\r\n`.
|
|
207
|
+
*
|
|
208
|
+
* @since 0.1.0
|
|
209
|
+
* @category line endings
|
|
210
|
+
*/
|
|
211
|
+
export declare const lineEnding: Parser<"\n" | "\r\n">;
|
|
212
|
+
/**
|
|
213
|
+
* Everything up to (not including) a line ending, `[^\r\n]*` (winnow's
|
|
214
|
+
* `till_line_ending`, nom's `not_line_ending`). A carriage return that is
|
|
215
|
+
* not followed by a line feed is an error.
|
|
216
|
+
*
|
|
217
|
+
* @since 0.1.0
|
|
218
|
+
* @category line endings
|
|
219
|
+
*/
|
|
220
|
+
export declare const tillLineEnding: Parser<string>;
|
|
221
|
+
/** @internal */
|
|
222
|
+
export declare const overflow: (value: number) => Result.Result<number, string>;
|
|
223
|
+
/**
|
|
224
|
+
* An unsigned decimal integer: one or more digits (winnow's `dec_uint`,
|
|
225
|
+
* nom's `u32`/`u64`). Fails if the value is not a safe integer.
|
|
226
|
+
*
|
|
227
|
+
* @since 0.1.0
|
|
228
|
+
* @category numbers
|
|
229
|
+
*/
|
|
230
|
+
export declare const decUint: Parser<number, string>;
|
|
231
|
+
/**
|
|
232
|
+
* A signed decimal integer: an optional `+` or `-` followed by one or more
|
|
233
|
+
* digits (winnow's `dec_int`, nom's `i32`/`i64`). Fails if the value is not
|
|
234
|
+
* a safe integer.
|
|
235
|
+
*
|
|
236
|
+
* @since 0.1.0
|
|
237
|
+
* @category numbers
|
|
238
|
+
*/
|
|
239
|
+
export declare const decInt: Parser<number, string>;
|
|
240
|
+
/**
|
|
241
|
+
* An unsigned decimal integer as a `bigint`, of any size.
|
|
242
|
+
*
|
|
243
|
+
* @since 0.1.0
|
|
244
|
+
* @category numbers
|
|
245
|
+
*/
|
|
246
|
+
export declare const decBigUint: Parser<bigint>;
|
|
247
|
+
/**
|
|
248
|
+
* A signed decimal integer as a `bigint`, of any size.
|
|
249
|
+
*
|
|
250
|
+
* @since 0.1.0
|
|
251
|
+
* @category numbers
|
|
252
|
+
*/
|
|
253
|
+
export declare const decBigInt: Parser<bigint>;
|
|
254
|
+
/**
|
|
255
|
+
* A hexadecimal unsigned integer, without prefix (winnow's `hex_uint`, nom's
|
|
256
|
+
* `hex_u32`). Fails if the value is not a safe integer.
|
|
257
|
+
*
|
|
258
|
+
* @since 0.1.0
|
|
259
|
+
* @category numbers
|
|
260
|
+
*/
|
|
261
|
+
export declare const hexUint: Parser<number, string>;
|
|
262
|
+
/** @internal */
|
|
263
|
+
export declare const toFloat: (s: Input) => number;
|
|
264
|
+
/**
|
|
265
|
+
* A floating point number in decimal or scientific notation, including
|
|
266
|
+
* `inf`, `infinity` and `nan` (case insensitive), as accepted by winnow's
|
|
267
|
+
* `float` and nom's `double`.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* import { Ascii, Parser } from "@thomasfosterau/effect-parse"
|
|
272
|
+
*
|
|
273
|
+
* Parser.parse(Ascii.float, "-1.5e3") // Result.succeed(-1500)
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @since 0.1.0
|
|
277
|
+
* @category numbers
|
|
278
|
+
*/
|
|
279
|
+
export declare const float: Parser<number>;
|
|
280
|
+
/**
|
|
281
|
+
* Matches a literal ignoring ASCII case (winnow's `Caseless`, nom's
|
|
282
|
+
* `tag_no_case`). Returns the input as written.
|
|
283
|
+
*
|
|
284
|
+
* @since 0.1.0
|
|
285
|
+
* @category literals
|
|
286
|
+
*/
|
|
287
|
+
export declare const caseless: {
|
|
288
|
+
(literal: string): Parser<string>;
|
|
289
|
+
(literal: Uint8Array): Parser<Uint8Array, never, never, Uint8Array>;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Recognizes a string containing escape sequences, returning the raw slice
|
|
293
|
+
* (winnow's `take_escaped`, nom's `escaped`).
|
|
294
|
+
*
|
|
295
|
+
* - `normal` matches runs of ordinary characters (it must consume input)
|
|
296
|
+
* - `control` is the escape character, e.g. `"\\"`
|
|
297
|
+
* - `escapable` matches what may follow the control character
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```ts
|
|
301
|
+
* import { Ascii, Parser, Token } from "@thomasfosterau/effect-parse"
|
|
302
|
+
*
|
|
303
|
+
* const raw = Ascii.takeEscaped(Ascii.alpha1, "\\", Token.oneOf("\"n\\"))
|
|
304
|
+
* Parser.parse(raw, "ab\\\"cd") // Result.succeed("ab\\\"cd")
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @since 0.1.0
|
|
308
|
+
* @category escapes
|
|
309
|
+
*/
|
|
310
|
+
export declare const takeEscaped: <A, E, R, I extends Input, B, E2, R2, I2 extends Input>(normal: Parser<A, E, R, I>, control: string | number, escapable: Parser<B, E2, R2, I2>) => Parser<Slice<I & I2>, E | E2, R | R2, I & I2>;
|
|
311
|
+
/** @internal */
|
|
312
|
+
export declare const takeEscapedImpl: <A, E, R, I extends Input, B, E2, R2, I2 extends Input, S>(normal: Parser<A, E, R, I>, matchControl: (state: State<any>) => boolean, escapable: Parser<B, E2, R2, I2>, slice: (state: State<any>, start: number) => S, control: number, encoding: Encoding<any> | undefined) => Parser<S, E | E2, R | R2, I & I2>;
|
|
313
|
+
/**
|
|
314
|
+
* Parses a string containing escape sequences, returning the *unescaped*
|
|
315
|
+
* string (winnow's `escaped`, nom's `escaped_transform`).
|
|
316
|
+
*
|
|
317
|
+
* - `normal` matches runs of ordinary characters, returning them
|
|
318
|
+
* - `control` is the escape character, e.g. `"\\"`
|
|
319
|
+
* - `escape` parses what follows the control character, returning its
|
|
320
|
+
* replacement
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* import { Ascii, Parser, Token } from "@thomasfosterau/effect-parse"
|
|
325
|
+
*
|
|
326
|
+
* const unescaped = Ascii.escaped(
|
|
327
|
+
* Token.takeTill("\\\""),
|
|
328
|
+
* "\\",
|
|
329
|
+
* Parser.alt(
|
|
330
|
+
* Token.literal("n").pipe(Parser.as("\n")),
|
|
331
|
+
* Token.literal("\\"),
|
|
332
|
+
* Token.literal("\"")
|
|
333
|
+
* )
|
|
334
|
+
* )
|
|
335
|
+
* Parser.parse(unescaped, "a\\nb") // Result.succeed("a\nb")
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @since 0.1.0
|
|
339
|
+
* @category escapes
|
|
340
|
+
*/
|
|
341
|
+
export declare const escaped: <E, R, I extends Input, E2, R2, I2 extends Input>(normal: Parser<string, E, R, I>, control: string | number, escape: Parser<string, E2, R2, I2>) => Parser<string, E | E2, R | R2, I & I2>;
|
|
342
|
+
/** @internal */
|
|
343
|
+
export declare const escapedImpl: <E, R, I extends Input, E2, R2, I2 extends Input>(normal: Parser<string, E, R, I>, matchControl: (state: State<any>) => boolean, escape: Parser<string, E2, R2, I2>, control: number, encoding: Encoding<any> | undefined) => Parser<string, E | E2, R | R2, I & I2>;
|
|
344
|
+
type Bytes<P> = P extends Parser<infer A, infer E, infer R, infer _I> ? Parser<A extends string ? Uint8Array : A, E, R, Uint8Array> : never;
|
|
345
|
+
/**
|
|
346
|
+
* The parsers of this module, typed for `Uint8Array` input. Slices are
|
|
347
|
+
* returned as `Uint8Array`s.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* import { Ascii, Parser, Token } from "@thomasfosterau/effect-parse"
|
|
352
|
+
*
|
|
353
|
+
* const encode = (s: string) => new TextEncoder().encode(s)
|
|
354
|
+
* const header = Parser.separatedPair(
|
|
355
|
+
* Ascii.bytes.alpha1,
|
|
356
|
+
* Token.literal(encode(": ")),
|
|
357
|
+
* Ascii.bytes.tillLineEnding
|
|
358
|
+
* )
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* @since 0.1.0
|
|
362
|
+
* @category byte views
|
|
363
|
+
*/
|
|
364
|
+
export declare const bytes: {
|
|
365
|
+
readonly alpha0: Bytes<typeof alpha0>;
|
|
366
|
+
readonly alpha1: Bytes<typeof alpha1>;
|
|
367
|
+
readonly digit0: Bytes<typeof digit0>;
|
|
368
|
+
readonly digit1: Bytes<typeof digit1>;
|
|
369
|
+
readonly hexDigit0: Bytes<typeof hexDigit0>;
|
|
370
|
+
readonly hexDigit1: Bytes<typeof hexDigit1>;
|
|
371
|
+
readonly octDigit0: Bytes<typeof octDigit0>;
|
|
372
|
+
readonly octDigit1: Bytes<typeof octDigit1>;
|
|
373
|
+
readonly alphanumeric0: Bytes<typeof alphanumeric0>;
|
|
374
|
+
readonly alphanumeric1: Bytes<typeof alphanumeric1>;
|
|
375
|
+
readonly space0: Bytes<typeof space0>;
|
|
376
|
+
readonly space1: Bytes<typeof space1>;
|
|
377
|
+
readonly multispace0: Bytes<typeof multispace0>;
|
|
378
|
+
readonly multispace1: Bytes<typeof multispace1>;
|
|
379
|
+
readonly crlf: Parser<Uint8Array, never, never, Uint8Array>;
|
|
380
|
+
readonly newline: Parser<Uint8Array, never, never, Uint8Array>;
|
|
381
|
+
readonly tab: Parser<Uint8Array, never, never, Uint8Array>;
|
|
382
|
+
readonly lineEnding: Parser<Uint8Array, never, never, Uint8Array>;
|
|
383
|
+
readonly tillLineEnding: Bytes<typeof tillLineEnding>;
|
|
384
|
+
readonly decUint: Parser<number, string, never, Uint8Array>;
|
|
385
|
+
readonly decInt: Parser<number, string, never, Uint8Array>;
|
|
386
|
+
readonly decBigUint: Parser<bigint, never, never, Uint8Array>;
|
|
387
|
+
readonly decBigInt: Parser<bigint, never, never, Uint8Array>;
|
|
388
|
+
readonly hexUint: Parser<number, string, never, Uint8Array>;
|
|
389
|
+
readonly float: Parser<number, never, never, Uint8Array>;
|
|
390
|
+
};
|
|
391
|
+
export {};
|
|
392
|
+
//# sourceMappingURL=Ascii.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ascii.d.ts","sourceRoot":"","sources":["../src/Ascii.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGrD,OAAO,KA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