@thomasfosterau/effect-parse 0.0.0-stage → 0.1.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/Text.d.ts
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unicode text parsers, generic over the input's encoding.
|
|
3
|
+
*
|
|
4
|
+
* `Text.make(encoding)` builds one set of parsers ({@link TextParsers}) for
|
|
5
|
+
* an {@link Encoding.Encoding}, and ready-made sets are provided for
|
|
6
|
+
* JavaScript strings and the common byte encodings:
|
|
7
|
+
*
|
|
8
|
+
* | Parsers | Input | Offsets |
|
|
9
|
+
* |---|---|---|
|
|
10
|
+
* | `Text.string` | `string` | UTF-16 code units |
|
|
11
|
+
* | `Text.utf8` | `Uint8Array` of UTF-8 | bytes |
|
|
12
|
+
* | `Text.utf16le`, `Text.utf16be` | `Uint8Array` of UTF-16 | bytes |
|
|
13
|
+
* | `Text.latin1` | `Uint8Array` of ISO-8859-1 | bytes |
|
|
14
|
+
*
|
|
15
|
+
* Every set has the same members, and every parser returns `string`s, so a
|
|
16
|
+
* grammar written against `TextParsers<I>` parses all of them:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { Parser, Text } from "@thomasfosterau/effect-parse"
|
|
20
|
+
*
|
|
21
|
+
* const greeting = <I extends string | Uint8Array>(T: Text.TextParsers<I>) =>
|
|
22
|
+
* Parser.preceded(T.literal("¡hola "), T.identifier)
|
|
23
|
+
*
|
|
24
|
+
* Parser.parse(greeting(Text.string), "¡hola mundo") // "mundo"
|
|
25
|
+
* Parser.parse(greeting(Text.utf8), new TextEncoder().encode("¡hola Zoë")) // "Zoë"
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Tokens are Unicode code points, and character classes follow Unicode
|
|
29
|
+
* properties: `alpha1` matches `"Ωμέγα"`, `space1` matches a no-break space.
|
|
30
|
+
* Use the `Ascii` module for the ASCII-only classes.
|
|
31
|
+
*
|
|
32
|
+
* Decoding is strict. Malformed input (invalid UTF-8, unpaired surrogates)
|
|
33
|
+
* never matches, and error messages point at it. On partial input, a
|
|
34
|
+
* character split across chunks reports `Incomplete`, so byte streams can be
|
|
35
|
+
* parsed as text without decoding them first.
|
|
36
|
+
*
|
|
37
|
+
* @since 0.1.0
|
|
38
|
+
*/
|
|
39
|
+
import type { Encoding } from "./Encoding.js";
|
|
40
|
+
import type { Parser, Range } from "./Parser.js";
|
|
41
|
+
import type { StringTokenSet } from "./Token.js";
|
|
42
|
+
/**
|
|
43
|
+
* A predicate over characters. It accepts a one-character string or a code
|
|
44
|
+
* point.
|
|
45
|
+
*
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
* @category models
|
|
48
|
+
*/
|
|
49
|
+
export type CharPredicate = (char: string | number) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* A predicate testing a Unicode property, using the syntax of regular
|
|
52
|
+
* expression property escapes (`\p{...}`): a general category (`"Lu"`,
|
|
53
|
+
* `"Letter"`), a binary property (`"Emoji"`, `"Dash"`) or a script
|
|
54
|
+
* (`"Script=Greek"`).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { Text } from "@thomasfosterau/effect-parse"
|
|
59
|
+
*
|
|
60
|
+
* const greek = Text.string.takeWhile(Text.property("Script=Greek"), { min: 1 })
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @since 0.1.0
|
|
64
|
+
* @category predicates
|
|
65
|
+
*/
|
|
66
|
+
export declare const property: (name: string) => CharPredicate;
|
|
67
|
+
/**
|
|
68
|
+
* Letters and other alphabetic characters (the Unicode `Alphabetic`
|
|
69
|
+
* property, Rust's `char::is_alphabetic`).
|
|
70
|
+
*
|
|
71
|
+
* @since 0.1.0
|
|
72
|
+
* @category predicates
|
|
73
|
+
*/
|
|
74
|
+
export declare const isAlphabetic: CharPredicate;
|
|
75
|
+
/**
|
|
76
|
+
* Letters (general category `L`).
|
|
77
|
+
*
|
|
78
|
+
* @since 0.1.0
|
|
79
|
+
* @category predicates
|
|
80
|
+
*/
|
|
81
|
+
export declare const isLetter: CharPredicate;
|
|
82
|
+
/**
|
|
83
|
+
* Uppercase characters (the Unicode `Uppercase` property).
|
|
84
|
+
*
|
|
85
|
+
* @since 0.1.0
|
|
86
|
+
* @category predicates
|
|
87
|
+
*/
|
|
88
|
+
export declare const isUppercase: CharPredicate;
|
|
89
|
+
/**
|
|
90
|
+
* Lowercase characters (the Unicode `Lowercase` property).
|
|
91
|
+
*
|
|
92
|
+
* @since 0.1.0
|
|
93
|
+
* @category predicates
|
|
94
|
+
*/
|
|
95
|
+
export declare const isLowercase: CharPredicate;
|
|
96
|
+
/**
|
|
97
|
+
* Decimal digits of any script (general category `Nd`): `0`–`9`, `٠`–`٩`,
|
|
98
|
+
* `०`–`९`, ...
|
|
99
|
+
*
|
|
100
|
+
* @since 0.1.0
|
|
101
|
+
* @category predicates
|
|
102
|
+
*/
|
|
103
|
+
export declare const isDecimalDigit: CharPredicate;
|
|
104
|
+
/**
|
|
105
|
+
* Numeric characters (general category `N`), including `½` and `Ⅻ` (Rust's
|
|
106
|
+
* `char::is_numeric`).
|
|
107
|
+
*
|
|
108
|
+
* @since 0.1.0
|
|
109
|
+
* @category predicates
|
|
110
|
+
*/
|
|
111
|
+
export declare const isNumeric: CharPredicate;
|
|
112
|
+
/**
|
|
113
|
+
* Alphabetic or numeric characters (Rust's `char::is_alphanumeric`).
|
|
114
|
+
*
|
|
115
|
+
* @since 0.1.0
|
|
116
|
+
* @category predicates
|
|
117
|
+
*/
|
|
118
|
+
export declare const isAlphanumeric: CharPredicate;
|
|
119
|
+
/**
|
|
120
|
+
* Whitespace, including line breaks (the Unicode `White_Space` property,
|
|
121
|
+
* Rust's `char::is_whitespace`).
|
|
122
|
+
*
|
|
123
|
+
* @since 0.1.0
|
|
124
|
+
* @category predicates
|
|
125
|
+
*/
|
|
126
|
+
export declare const isWhitespace: CharPredicate;
|
|
127
|
+
/**
|
|
128
|
+
* Whitespace that does not break lines: `White_Space` except `\n`, `\v`,
|
|
129
|
+
* `\f`, `\r`, U+0085, U+2028 and U+2029. Includes tabs and no-break spaces.
|
|
130
|
+
*
|
|
131
|
+
* @since 0.1.0
|
|
132
|
+
* @category predicates
|
|
133
|
+
*/
|
|
134
|
+
export declare const isSpace: CharPredicate;
|
|
135
|
+
/**
|
|
136
|
+
* Characters that can start an identifier (the Unicode `ID_Start` property,
|
|
137
|
+
* see UAX #31).
|
|
138
|
+
*
|
|
139
|
+
* @since 0.1.0
|
|
140
|
+
* @category predicates
|
|
141
|
+
*/
|
|
142
|
+
export declare const isIdStart: CharPredicate;
|
|
143
|
+
/**
|
|
144
|
+
* Characters that can continue an identifier (the Unicode `ID_Continue`
|
|
145
|
+
* property, see UAX #31).
|
|
146
|
+
*
|
|
147
|
+
* @since 0.1.0
|
|
148
|
+
* @category predicates
|
|
149
|
+
*/
|
|
150
|
+
export declare const isIdContinue: CharPredicate;
|
|
151
|
+
/**
|
|
152
|
+
* Punctuation (general category `P`).
|
|
153
|
+
*
|
|
154
|
+
* @since 0.1.0
|
|
155
|
+
* @category predicates
|
|
156
|
+
*/
|
|
157
|
+
export declare const isPunctuation: CharPredicate;
|
|
158
|
+
/**
|
|
159
|
+
* Control characters (general category `Cc`).
|
|
160
|
+
*
|
|
161
|
+
* @since 0.1.0
|
|
162
|
+
* @category predicates
|
|
163
|
+
*/
|
|
164
|
+
export declare const isControl: CharPredicate;
|
|
165
|
+
/**
|
|
166
|
+
* The text parsers for one encoding. Build a set with {@link make}, or use
|
|
167
|
+
* {@link string}, {@link utf8}, {@link utf16le}, {@link utf16be} or
|
|
168
|
+
* {@link latin1}.
|
|
169
|
+
*
|
|
170
|
+
* Every parser returns text as a `string`, whatever the input. To keep a
|
|
171
|
+
* slice of a byte input as bytes instead, use `Parser.taken`.
|
|
172
|
+
*
|
|
173
|
+
* @since 0.1.0
|
|
174
|
+
* @category models
|
|
175
|
+
*/
|
|
176
|
+
export interface TextParsers<I extends string | Uint8Array> {
|
|
177
|
+
/** The encoding these parsers read. */
|
|
178
|
+
readonly encoding: Encoding<I>;
|
|
179
|
+
/** Any single character (code point). */
|
|
180
|
+
readonly any: Parser<string, never, never, I>;
|
|
181
|
+
/**
|
|
182
|
+
* A literal string, returned as written. On byte inputs it is matched in
|
|
183
|
+
* its encoded form.
|
|
184
|
+
*/
|
|
185
|
+
readonly literal: <const L extends string>(literal: L) => Parser<L, never, never, I>;
|
|
186
|
+
/**
|
|
187
|
+
* A literal string, ignoring case (by simple Unicode case folding, so
|
|
188
|
+
* `"straße"` matches `"STRAßE"` but not `"STRASSE"`). Returns the input as
|
|
189
|
+
* written.
|
|
190
|
+
*/
|
|
191
|
+
readonly caseless: (literal: string) => Parser<string, never, never, I>;
|
|
192
|
+
/** One character belonging to a set (the characters of a string, a range, a predicate, or an array of these). */
|
|
193
|
+
readonly oneOf: (set: StringTokenSet) => Parser<string, never, never, I>;
|
|
194
|
+
/** One character *not* belonging to a set. */
|
|
195
|
+
readonly noneOf: (set: StringTokenSet) => Parser<string, never, never, I>;
|
|
196
|
+
/** An optional byte order mark, U+FEFF. Returns whether one was present. */
|
|
197
|
+
readonly bom: Parser<boolean, never, never, I>;
|
|
198
|
+
/** Exactly `count` characters. */
|
|
199
|
+
readonly take: (count: number) => Parser<string, never, never, I>;
|
|
200
|
+
/** The longest run of characters belonging to a set, with a count in `range` (default: any). */
|
|
201
|
+
readonly takeWhile: (set: StringTokenSet, range?: Range) => Parser<string, never, never, I>;
|
|
202
|
+
/** The longest run of characters *not* belonging to a set, with a count in `range`. */
|
|
203
|
+
readonly takeTill: (set: StringTokenSet, range?: Range) => Parser<string, never, never, I>;
|
|
204
|
+
/** Characters up to (not including) the first occurrence of a literal. */
|
|
205
|
+
readonly takeUntil: (literal: string, range?: Range) => Parser<string, never, never, I>;
|
|
206
|
+
/** The rest of the input. */
|
|
207
|
+
readonly rest: Parser<string, never, never, I>;
|
|
208
|
+
/**
|
|
209
|
+
* Runs a parser and returns the text it consumed (`Parser.taken`, decoded
|
|
210
|
+
* to a `string`).
|
|
211
|
+
*/
|
|
212
|
+
readonly taken: <A, E, R>(self: Parser<A, E, R, I>) => Parser<string, E, R, I>;
|
|
213
|
+
/** Zero or more alphabetic characters ({@link isAlphabetic}). */
|
|
214
|
+
readonly alpha0: Parser<string, never, never, I>;
|
|
215
|
+
/** One or more alphabetic characters ({@link isAlphabetic}). */
|
|
216
|
+
readonly alpha1: Parser<string, never, never, I>;
|
|
217
|
+
/** Zero or more decimal digits of any script ({@link isDecimalDigit}). */
|
|
218
|
+
readonly digit0: Parser<string, never, never, I>;
|
|
219
|
+
/** One or more decimal digits of any script ({@link isDecimalDigit}). */
|
|
220
|
+
readonly digit1: Parser<string, never, never, I>;
|
|
221
|
+
/** Zero or more alphanumeric characters ({@link isAlphanumeric}). */
|
|
222
|
+
readonly alphanumeric0: Parser<string, never, never, I>;
|
|
223
|
+
/** One or more alphanumeric characters ({@link isAlphanumeric}). */
|
|
224
|
+
readonly alphanumeric1: Parser<string, never, never, I>;
|
|
225
|
+
/** Zero or more non-breaking whitespace characters ({@link isSpace}). */
|
|
226
|
+
readonly space0: Parser<string, never, never, I>;
|
|
227
|
+
/** One or more non-breaking whitespace characters ({@link isSpace}). */
|
|
228
|
+
readonly space1: Parser<string, never, never, I>;
|
|
229
|
+
/** Zero or more whitespace characters, including line breaks ({@link isWhitespace}). */
|
|
230
|
+
readonly multispace0: Parser<string, never, never, I>;
|
|
231
|
+
/** One or more whitespace characters, including line breaks ({@link isWhitespace}). */
|
|
232
|
+
readonly multispace1: Parser<string, never, never, I>;
|
|
233
|
+
/**
|
|
234
|
+
* An identifier: an {@link isIdStart} character or `_`, then any
|
|
235
|
+
* {@link isIdContinue} characters (UAX #31 default identifiers).
|
|
236
|
+
*/
|
|
237
|
+
readonly identifier: Parser<string, never, never, I>;
|
|
238
|
+
/** `\n` */
|
|
239
|
+
readonly newline: Parser<"\n", never, never, I>;
|
|
240
|
+
/** `\r\n` */
|
|
241
|
+
readonly crlf: Parser<"\r\n", never, never, I>;
|
|
242
|
+
/** `\t` */
|
|
243
|
+
readonly tab: Parser<"\t", never, never, I>;
|
|
244
|
+
/** `\n` or `\r\n`. */
|
|
245
|
+
readonly lineEnding: Parser<"\n" | "\r\n", never, never, I>;
|
|
246
|
+
/** Everything up to (not including) a line ending. A `\r` not followed by `\n` is an error. */
|
|
247
|
+
readonly tillLineEnding: Parser<string, never, never, I>;
|
|
248
|
+
/** An unsigned decimal integer of ASCII digits. Fails if it is not a safe integer. */
|
|
249
|
+
readonly decUint: Parser<number, string, never, I>;
|
|
250
|
+
/** A signed decimal integer of ASCII digits. Fails if it is not a safe integer. */
|
|
251
|
+
readonly decInt: Parser<number, string, never, I>;
|
|
252
|
+
/** An unsigned decimal integer of ASCII digits, as a `bigint`. */
|
|
253
|
+
readonly decBigUint: Parser<bigint, never, never, I>;
|
|
254
|
+
/** A signed decimal integer of ASCII digits, as a `bigint`. */
|
|
255
|
+
readonly decBigInt: Parser<bigint, never, never, I>;
|
|
256
|
+
/** A hexadecimal unsigned integer, without prefix. Fails if it is not a safe integer. */
|
|
257
|
+
readonly hexUint: Parser<number, string, never, I>;
|
|
258
|
+
/** A floating point number, as accepted by `Ascii.float`. */
|
|
259
|
+
readonly float: Parser<number, never, never, I>;
|
|
260
|
+
/**
|
|
261
|
+
* Recognizes text containing escape sequences, returning it raw (see
|
|
262
|
+
* `Ascii.takeEscaped`). `control` is the escape character.
|
|
263
|
+
*/
|
|
264
|
+
readonly takeEscaped: <A, E, R, B, E2, R2>(normal: Parser<A, E, R, I>, control: string, escapable: Parser<B, E2, R2, I>) => Parser<string, E | E2, R | R2, I>;
|
|
265
|
+
/**
|
|
266
|
+
* Parses text containing escape sequences, returning it unescaped (see
|
|
267
|
+
* `Ascii.escaped`). `control` is the escape character.
|
|
268
|
+
*/
|
|
269
|
+
readonly escaped: <E, R, E2, R2>(normal: Parser<string, E, R, I>, control: string, escape: Parser<string, E2, R2, I>) => Parser<string, E | E2, R | R2, I>;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Builds the text parsers for an encoding.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* import { Encoding, Parser, Text } from "@thomasfosterau/effect-parse"
|
|
277
|
+
*
|
|
278
|
+
* const T = Text.make(Encoding.latin1)
|
|
279
|
+
* Parser.parse(T.alpha1, new Uint8Array([0x63, 0x61, 0x66, 0xe9])) // "café"
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @since 0.1.0
|
|
283
|
+
* @category constructors
|
|
284
|
+
*/
|
|
285
|
+
export declare const make: <I extends string | Uint8Array>(encoding: Encoding<I>) => TextParsers<I>;
|
|
286
|
+
/**
|
|
287
|
+
* Text parsers for JavaScript strings.
|
|
288
|
+
*
|
|
289
|
+
* @since 0.1.0
|
|
290
|
+
* @category instances
|
|
291
|
+
*/
|
|
292
|
+
export declare const string: TextParsers<string>;
|
|
293
|
+
/**
|
|
294
|
+
* Text parsers for UTF-8 encoded bytes.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```ts
|
|
298
|
+
* import { Parser, Text } from "@thomasfosterau/effect-parse"
|
|
299
|
+
*
|
|
300
|
+
* const bytes = new TextEncoder().encode("naïve café")
|
|
301
|
+
* Parser.parse(Parser.separatedPair(Text.utf8.alpha1, Text.utf8.space1, Text.utf8.alpha1), bytes)
|
|
302
|
+
* // Result.succeed(["naïve", "café"])
|
|
303
|
+
* ```
|
|
304
|
+
*
|
|
305
|
+
* @since 0.1.0
|
|
306
|
+
* @category instances
|
|
307
|
+
*/
|
|
308
|
+
export declare const utf8: TextParsers<Uint8Array>;
|
|
309
|
+
/**
|
|
310
|
+
* Text parsers for UTF-16 little endian bytes.
|
|
311
|
+
*
|
|
312
|
+
* @since 0.1.0
|
|
313
|
+
* @category instances
|
|
314
|
+
*/
|
|
315
|
+
export declare const utf16le: TextParsers<Uint8Array>;
|
|
316
|
+
/**
|
|
317
|
+
* Text parsers for UTF-16 big endian bytes.
|
|
318
|
+
*
|
|
319
|
+
* @since 0.1.0
|
|
320
|
+
* @category instances
|
|
321
|
+
*/
|
|
322
|
+
export declare const utf16be: TextParsers<Uint8Array>;
|
|
323
|
+
/**
|
|
324
|
+
* Text parsers for ISO-8859-1 (Latin-1) bytes.
|
|
325
|
+
*
|
|
326
|
+
* @since 0.1.0
|
|
327
|
+
* @category instances
|
|
328
|
+
*/
|
|
329
|
+
export declare const latin1: TextParsers<Uint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