@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.
Files changed (133) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +550 -2
  3. package/dist/Ascii.d.ts +392 -0
  4. package/dist/Ascii.d.ts.map +1 -0
  5. package/dist/Ascii.js +610 -0
  6. package/dist/Ascii.js.map +1 -0
  7. package/dist/Binary.d.ts +153 -0
  8. package/dist/Binary.d.ts.map +1 -0
  9. package/dist/Binary.js +171 -0
  10. package/dist/Binary.js.map +1 -0
  11. package/dist/Bits.d.ts +60 -0
  12. package/dist/Bits.d.ts.map +1 -0
  13. package/dist/Bits.js +144 -0
  14. package/dist/Bits.js.map +1 -0
  15. package/dist/Encoding.d.ts +116 -0
  16. package/dist/Encoding.d.ts.map +1 -0
  17. package/dist/Encoding.js +85 -0
  18. package/dist/Encoding.js.map +1 -0
  19. package/dist/Expression.d.ts +124 -0
  20. package/dist/Expression.d.ts.map +1 -0
  21. package/dist/Expression.js +139 -0
  22. package/dist/Expression.js.map +1 -0
  23. package/dist/Input.d.ts +301 -0
  24. package/dist/Input.d.ts.map +1 -0
  25. package/dist/Input.js +312 -0
  26. package/dist/Input.js.map +1 -0
  27. package/dist/Nom.d.ts +518 -0
  28. package/dist/Nom.d.ts.map +1 -0
  29. package/dist/Nom.js +519 -0
  30. package/dist/Nom.js.map +1 -0
  31. package/dist/ParseError.d.ts +120 -0
  32. package/dist/ParseError.d.ts.map +1 -0
  33. package/dist/ParseError.js +301 -0
  34. package/dist/ParseError.js.map +1 -0
  35. package/dist/Parser.d.ts +1312 -0
  36. package/dist/Parser.d.ts.map +1 -0
  37. package/dist/Parser.js +1936 -0
  38. package/dist/Parser.js.map +1 -0
  39. package/dist/ParserSchema.d.ts +31 -0
  40. package/dist/ParserSchema.d.ts.map +1 -0
  41. package/dist/ParserSchema.js +56 -0
  42. package/dist/ParserSchema.js.map +1 -0
  43. package/dist/ParserStream.d.ts +127 -0
  44. package/dist/ParserStream.d.ts.map +1 -0
  45. package/dist/ParserStream.js +270 -0
  46. package/dist/ParserStream.js.map +1 -0
  47. package/dist/Text.d.ts +330 -0
  48. package/dist/Text.d.ts.map +1 -0
  49. package/dist/Text.js +529 -0
  50. package/dist/Text.js.map +1 -0
  51. package/dist/Token.d.ts +225 -0
  52. package/dist/Token.d.ts.map +1 -0
  53. package/dist/Token.js +294 -0
  54. package/dist/Token.js.map +1 -0
  55. package/dist/index.d.ts +17 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +17 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/internal/compiler/closure.d.ts +25 -0
  60. package/dist/internal/compiler/closure.d.ts.map +1 -0
  61. package/dist/internal/compiler/closure.js +1668 -0
  62. package/dist/internal/compiler/closure.js.map +1 -0
  63. package/dist/internal/compiler/entries.d.ts +19 -0
  64. package/dist/internal/compiler/entries.d.ts.map +1 -0
  65. package/dist/internal/compiler/entries.js +32 -0
  66. package/dist/internal/compiler/entries.js.map +1 -0
  67. package/dist/internal/compiler/first.d.ts +33 -0
  68. package/dist/internal/compiler/first.d.ts.map +1 -0
  69. package/dist/internal/compiler/first.js +235 -0
  70. package/dist/internal/compiler/first.js.map +1 -0
  71. package/dist/internal/compiler/jit.d.ts +20 -0
  72. package/dist/internal/compiler/jit.d.ts.map +1 -0
  73. package/dist/internal/compiler/jit.js +1030 -0
  74. package/dist/internal/compiler/jit.js.map +1 -0
  75. package/dist/internal/compiler/registry.d.ts +34 -0
  76. package/dist/internal/compiler/registry.d.ts.map +1 -0
  77. package/dist/internal/compiler/registry.js +46 -0
  78. package/dist/internal/compiler/registry.js.map +1 -0
  79. package/dist/internal/compiler/sets.d.ts +29 -0
  80. package/dist/internal/compiler/sets.d.ts.map +1 -0
  81. package/dist/internal/compiler/sets.js +85 -0
  82. package/dist/internal/compiler/sets.js.map +1 -0
  83. package/dist/internal/entries.d.ts +27 -0
  84. package/dist/internal/entries.d.ts.map +1 -0
  85. package/dist/internal/entries.js +42 -0
  86. package/dist/internal/entries.js.map +1 -0
  87. package/dist/internal/node.d.ts +251 -0
  88. package/dist/internal/node.d.ts.map +1 -0
  89. package/dist/internal/node.js +73 -0
  90. package/dist/internal/node.js.map +1 -0
  91. package/dist/internal/numbers.d.ts +41 -0
  92. package/dist/internal/numbers.d.ts.map +1 -0
  93. package/dist/internal/numbers.js +302 -0
  94. package/dist/internal/numbers.js.map +1 -0
  95. package/dist/internal/resume.d.ts +39 -0
  96. package/dist/internal/resume.d.ts.map +1 -0
  97. package/dist/internal/resume.js +37 -0
  98. package/dist/internal/resume.js.map +1 -0
  99. package/dist/internal/text.d.ts +72 -0
  100. package/dist/internal/text.d.ts.map +1 -0
  101. package/dist/internal/text.js +391 -0
  102. package/dist/internal/text.js.map +1 -0
  103. package/dist/internal/tokens.d.ts +93 -0
  104. package/dist/internal/tokens.d.ts.map +1 -0
  105. package/dist/internal/tokens.js +400 -0
  106. package/dist/internal/tokens.js.map +1 -0
  107. package/package.json +115 -3
  108. package/src/Ascii.ts +741 -0
  109. package/src/Binary.ts +228 -0
  110. package/src/Bits.ts +192 -0
  111. package/src/Encoding.ts +128 -0
  112. package/src/Expression.ts +245 -0
  113. package/src/Input.ts +429 -0
  114. package/src/Nom.ts +642 -0
  115. package/src/ParseError.ts +378 -0
  116. package/src/Parser.ts +2763 -0
  117. package/src/ParserSchema.ts +87 -0
  118. package/src/ParserStream.ts +390 -0
  119. package/src/Text.ts +757 -0
  120. package/src/Token.ts +416 -0
  121. package/src/index.ts +16 -0
  122. package/src/internal/compiler/closure.ts +1583 -0
  123. package/src/internal/compiler/entries.ts +36 -0
  124. package/src/internal/compiler/first.ts +252 -0
  125. package/src/internal/compiler/jit.ts +1091 -0
  126. package/src/internal/compiler/registry.ts +79 -0
  127. package/src/internal/compiler/sets.ts +100 -0
  128. package/src/internal/entries.ts +51 -0
  129. package/src/internal/node.ts +207 -0
  130. package/src/internal/numbers.ts +291 -0
  131. package/src/internal/resume.ts +55 -0
  132. package/src/internal/text.ts +411 -0
  133. package/src/internal/tokens.ts +409 -0
package/dist/Nom.js ADDED
@@ -0,0 +1,519 @@
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";
44
+ import * as P from "./Parser.js";
45
+ import * as Token from "./Token.js";
46
+ // -----------------------------------------------------------------------------
47
+ // bytes / character
48
+ // -----------------------------------------------------------------------------
49
+ /**
50
+ * Matches a literal (nom's `tag`).
51
+ *
52
+ * @since 0.1.0
53
+ * @category bytes
54
+ */
55
+ export const tag = Token.literal;
56
+ /**
57
+ * Matches a literal, ignoring ASCII case (nom's `tag_no_case`).
58
+ *
59
+ * @since 0.1.0
60
+ * @category bytes
61
+ */
62
+ export const tagNoCase = Ascii.caseless;
63
+ /**
64
+ * Matches a single character (nom's `char`).
65
+ *
66
+ * @since 0.1.0
67
+ * @category character
68
+ */
69
+ export const char = (c) => Token.literal(c);
70
+ /**
71
+ * Matches any character (nom's `anychar`).
72
+ *
73
+ * @since 0.1.0
74
+ * @category character
75
+ */
76
+ export const anychar = Token.any;
77
+ /**
78
+ * @since 0.1.0
79
+ * @category character
80
+ */
81
+ export const oneOf = Token.oneOf;
82
+ /**
83
+ * @since 0.1.0
84
+ * @category character
85
+ */
86
+ export const noneOf = Token.noneOf;
87
+ /**
88
+ * @since 0.1.0
89
+ * @category character
90
+ */
91
+ export const satisfy = Token.satisfy;
92
+ /**
93
+ * The longest non-empty run of tokens from a set (nom's `is_a`).
94
+ *
95
+ * @since 0.1.0
96
+ * @category bytes
97
+ */
98
+ export const isA = (set) => Token.takeWhile(set, { min: 1 });
99
+ /**
100
+ * The longest non-empty run of tokens *not* from a set (nom's `is_not`).
101
+ *
102
+ * @since 0.1.0
103
+ * @category bytes
104
+ */
105
+ export const isNot = (set) => Token.takeTill(set, { min: 1 });
106
+ /**
107
+ * @since 0.1.0
108
+ * @category bytes
109
+ */
110
+ export const take = Token.take;
111
+ /**
112
+ * @since 0.1.0
113
+ * @category bytes
114
+ */
115
+ export const takeWhile = (predicate) => Token.takeWhile(predicate);
116
+ /**
117
+ * @since 0.1.0
118
+ * @category bytes
119
+ */
120
+ export const takeWhile1 = (predicate) => Token.takeWhile(predicate, { min: 1 });
121
+ /**
122
+ * @since 0.1.0
123
+ * @category bytes
124
+ */
125
+ export const takeWhileMN = (m, n, predicate) => Token.takeWhile(predicate, { min: m, max: n });
126
+ /**
127
+ * @since 0.1.0
128
+ * @category bytes
129
+ */
130
+ export const takeTill = (predicate) => Token.takeTill(predicate);
131
+ /**
132
+ * @since 0.1.0
133
+ * @category bytes
134
+ */
135
+ export const takeTill1 = (predicate) => Token.takeTill(predicate, { min: 1 });
136
+ /**
137
+ * @since 0.1.0
138
+ * @category bytes
139
+ */
140
+ export const takeUntil = Token.takeUntil;
141
+ /**
142
+ * Recognizes an escaped string (nom's `escaped`).
143
+ *
144
+ * @since 0.1.0
145
+ * @category bytes
146
+ */
147
+ export const escaped = Ascii.takeEscaped;
148
+ /**
149
+ * Unescapes an escaped string (nom's `escaped_transform`).
150
+ *
151
+ * @since 0.1.0
152
+ * @category bytes
153
+ */
154
+ export const escapedTransform = Ascii.escaped;
155
+ /** @since 0.1.0 @category character */
156
+ export const alpha0 = Ascii.alpha0;
157
+ /** @since 0.1.0 @category character */
158
+ export const alpha1 = Ascii.alpha1;
159
+ /** @since 0.1.0 @category character */
160
+ export const digit0 = Ascii.digit0;
161
+ /** @since 0.1.0 @category character */
162
+ export const digit1 = Ascii.digit1;
163
+ /** @since 0.1.0 @category character */
164
+ export const hexDigit0 = Ascii.hexDigit0;
165
+ /** @since 0.1.0 @category character */
166
+ export const hexDigit1 = Ascii.hexDigit1;
167
+ /** @since 0.1.0 @category character */
168
+ export const octDigit0 = Ascii.octDigit0;
169
+ /** @since 0.1.0 @category character */
170
+ export const octDigit1 = Ascii.octDigit1;
171
+ /** @since 0.1.0 @category character */
172
+ export const alphanumeric0 = Ascii.alphanumeric0;
173
+ /** @since 0.1.0 @category character */
174
+ export const alphanumeric1 = Ascii.alphanumeric1;
175
+ /** @since 0.1.0 @category character */
176
+ export const space0 = Ascii.space0;
177
+ /** @since 0.1.0 @category character */
178
+ export const space1 = Ascii.space1;
179
+ /** @since 0.1.0 @category character */
180
+ export const multispace0 = Ascii.multispace0;
181
+ /** @since 0.1.0 @category character */
182
+ export const multispace1 = Ascii.multispace1;
183
+ /** @since 0.1.0 @category character */
184
+ export const lineEnding = Ascii.lineEnding;
185
+ /** @since 0.1.0 @category character */
186
+ export const newline = Ascii.newline;
187
+ /** @since 0.1.0 @category character */
188
+ export const tab = Ascii.tab;
189
+ /** @since 0.1.0 @category character */
190
+ export const crlf = Ascii.crlf;
191
+ /**
192
+ * nom's `not_line_ending`.
193
+ *
194
+ * @since 0.1.0
195
+ * @category character
196
+ */
197
+ export const notLineEnding = Ascii.tillLineEnding;
198
+ /**
199
+ * A decimal unsigned integer (nom's `character::complete::u64` and friends).
200
+ *
201
+ * @since 0.1.0
202
+ * @category character
203
+ */
204
+ export const u64 = Ascii.decUint;
205
+ /**
206
+ * A decimal signed integer (nom's `character::complete::i64` and friends).
207
+ *
208
+ * @since 0.1.0
209
+ * @category character
210
+ */
211
+ export const i64 = Ascii.decInt;
212
+ // -----------------------------------------------------------------------------
213
+ // number
214
+ // -----------------------------------------------------------------------------
215
+ /**
216
+ * nom's `double` (and `float`).
217
+ *
218
+ * @since 0.1.0
219
+ * @category number
220
+ */
221
+ export const double = Ascii.float;
222
+ /**
223
+ * nom's `recognize_float`.
224
+ *
225
+ * @since 0.1.0
226
+ * @category number
227
+ */
228
+ export const recognizeFloat = P.taken(Ascii.float);
229
+ /**
230
+ * nom's `hex_u32`.
231
+ *
232
+ * @since 0.1.0
233
+ * @category number
234
+ */
235
+ export const hexU32 = Ascii.hexUint;
236
+ /** @since 0.1.0 @category number */
237
+ export const beU8 = Binary.u8;
238
+ /** @since 0.1.0 @category number */
239
+ export const beI8 = Binary.i8;
240
+ /** @since 0.1.0 @category number */
241
+ export const leU8 = Binary.u8;
242
+ /** @since 0.1.0 @category number */
243
+ export const leI8 = Binary.i8;
244
+ /** @since 0.1.0 @category number */
245
+ export const beU16 = Binary.beU16;
246
+ /** @since 0.1.0 @category number */
247
+ export const leU16 = Binary.leU16;
248
+ /** @since 0.1.0 @category number */
249
+ export const beI16 = Binary.beI16;
250
+ /** @since 0.1.0 @category number */
251
+ export const leI16 = Binary.leI16;
252
+ /** @since 0.1.0 @category number */
253
+ export const beU24 = Binary.beU24;
254
+ /** @since 0.1.0 @category number */
255
+ export const leU24 = Binary.leU24;
256
+ /** @since 0.1.0 @category number */
257
+ export const beI24 = Binary.beI24;
258
+ /** @since 0.1.0 @category number */
259
+ export const leI24 = Binary.leI24;
260
+ /** @since 0.1.0 @category number */
261
+ export const beU32 = Binary.beU32;
262
+ /** @since 0.1.0 @category number */
263
+ export const leU32 = Binary.leU32;
264
+ /** @since 0.1.0 @category number */
265
+ export const beI32 = Binary.beI32;
266
+ /** @since 0.1.0 @category number */
267
+ export const leI32 = Binary.leI32;
268
+ /** @since 0.1.0 @category number */
269
+ export const beU64 = Binary.beU64;
270
+ /** @since 0.1.0 @category number */
271
+ export const leU64 = Binary.leU64;
272
+ /** @since 0.1.0 @category number */
273
+ export const beI64 = Binary.beI64;
274
+ /** @since 0.1.0 @category number */
275
+ export const leI64 = Binary.leI64;
276
+ /** @since 0.1.0 @category number */
277
+ export const beU128 = Binary.beU128;
278
+ /** @since 0.1.0 @category number */
279
+ export const leU128 = Binary.leU128;
280
+ /** @since 0.1.0 @category number */
281
+ export const beI128 = Binary.beI128;
282
+ /** @since 0.1.0 @category number */
283
+ export const leI128 = Binary.leI128;
284
+ /** @since 0.1.0 @category number */
285
+ export const beF32 = Binary.beF32;
286
+ /** @since 0.1.0 @category number */
287
+ export const leF32 = Binary.leF32;
288
+ /** @since 0.1.0 @category number */
289
+ export const beF64 = Binary.beF64;
290
+ /** @since 0.1.0 @category number */
291
+ export const leF64 = Binary.leF64;
292
+ // -----------------------------------------------------------------------------
293
+ // multi
294
+ // -----------------------------------------------------------------------------
295
+ /**
296
+ * Zero or more (nom's `many0`).
297
+ *
298
+ * @since 0.1.0
299
+ * @category multi
300
+ */
301
+ export const many0 = (parser) => P.repeat(parser);
302
+ /**
303
+ * One or more (nom's `many1`).
304
+ *
305
+ * @since 0.1.0
306
+ * @category multi
307
+ */
308
+ export const many1 = (parser) => P.repeat(parser, { min: 1 });
309
+ /**
310
+ * Between `m` and `n` times (nom's `many_m_n`).
311
+ *
312
+ * @since 0.1.0
313
+ * @category multi
314
+ */
315
+ export const manyMN = (m, n, parser) => P.repeat(parser, { min: m, max: n });
316
+ /**
317
+ * Exactly `count` times (nom's `count`).
318
+ *
319
+ * @since 0.1.0
320
+ * @category multi
321
+ */
322
+ export const count = (parser, count) => P.repeat(parser, count);
323
+ /**
324
+ * Repeats `parser` until `end` succeeds (nom's `many_till`).
325
+ *
326
+ * @since 0.1.0
327
+ * @category multi
328
+ */
329
+ export const manyTill = (parser, end) => P.repeatTill(parser, end);
330
+ /**
331
+ * Zero or more `parser` separated by `separator` (nom's `separated_list0`;
332
+ * note the separator comes first).
333
+ *
334
+ * @since 0.1.0
335
+ * @category multi
336
+ */
337
+ export const separatedList0 = (separator, parser) => P.separated(parser, separator);
338
+ /**
339
+ * One or more `parser` separated by `separator` (nom's `separated_list1`;
340
+ * note the separator comes first).
341
+ *
342
+ * @since 0.1.0
343
+ * @category multi
344
+ */
345
+ export const separatedList1 = (separator, parser) => P.separated(parser, separator, { min: 1 });
346
+ /**
347
+ * Folds zero or more (nom's `fold_many0`).
348
+ *
349
+ * @since 0.1.0
350
+ * @category multi
351
+ */
352
+ export const foldMany0 = (parser, init, f) => P.fold(parser, { init, f });
353
+ /**
354
+ * Folds one or more (nom's `fold_many1`).
355
+ *
356
+ * @since 0.1.0
357
+ * @category multi
358
+ */
359
+ export const foldMany1 = (parser, init, f) => P.fold(parser, { init, f, range: { min: 1 } });
360
+ /**
361
+ * Folds between `m` and `n` times (nom's `fold_many_m_n`).
362
+ *
363
+ * @since 0.1.0
364
+ * @category multi
365
+ */
366
+ export const foldManyMN = (m, n, parser, init, f) => P.fold(parser, { init, f, range: { min: m, max: n } });
367
+ /**
368
+ * nom's `length_data`.
369
+ *
370
+ * @since 0.1.0
371
+ * @category multi
372
+ */
373
+ export const lengthData = Binary.lengthTake;
374
+ /**
375
+ * nom's `length_value`.
376
+ *
377
+ * @since 0.1.0
378
+ * @category multi
379
+ */
380
+ export const lengthValue = Binary.lengthAndThen;
381
+ /**
382
+ * nom's `length_count`.
383
+ *
384
+ * @since 0.1.0
385
+ * @category multi
386
+ */
387
+ export const lengthCount = Binary.lengthRepeat;
388
+ // -----------------------------------------------------------------------------
389
+ // sequence / branch
390
+ // -----------------------------------------------------------------------------
391
+ /**
392
+ * nom's `pair`.
393
+ *
394
+ * @since 0.1.0
395
+ * @category sequence
396
+ */
397
+ export const pair = (first, second) => P.zip(first, second);
398
+ /**
399
+ * nom's tuples of parsers (`(a, b, c)`, formerly `tuple`).
400
+ *
401
+ * @since 0.1.0
402
+ * @category sequence
403
+ */
404
+ export const tuple = P.seq;
405
+ /** @since 0.1.0 @category sequence */
406
+ export const preceded = P.preceded;
407
+ /** @since 0.1.0 @category sequence */
408
+ export const terminated = P.terminated;
409
+ /** @since 0.1.0 @category sequence */
410
+ export const delimited = P.delimited;
411
+ /** @since 0.1.0 @category sequence */
412
+ export const separatedPair = P.separatedPair;
413
+ /** @since 0.1.0 @category branch */
414
+ export const alt = P.alt;
415
+ /** @since 0.1.0 @category branch */
416
+ export const permutation = P.permutation;
417
+ // -----------------------------------------------------------------------------
418
+ // combinator
419
+ // -----------------------------------------------------------------------------
420
+ /**
421
+ * nom's `map`.
422
+ *
423
+ * @since 0.1.0
424
+ * @category combinator
425
+ */
426
+ export const map = (parser, f) => P.map(parser, f);
427
+ /**
428
+ * nom's `map_res`: the function returns a `Result`.
429
+ *
430
+ * @since 0.1.0
431
+ * @category combinator
432
+ */
433
+ export const mapRes = (parser, f) => P.tryMap(parser, f);
434
+ /**
435
+ * nom's `map_opt`: the function returns an `Option`.
436
+ *
437
+ * @since 0.1.0
438
+ * @category combinator
439
+ */
440
+ export const mapOpt = (parser, f) => P.filterMap(parser, f);
441
+ /**
442
+ * nom's `map_parser`.
443
+ *
444
+ * @since 0.1.0
445
+ * @category combinator
446
+ */
447
+ export const mapParser = (parser, applied) => P.mapParser(parser, applied);
448
+ /**
449
+ * nom's `flat_map`.
450
+ *
451
+ * @since 0.1.0
452
+ * @category combinator
453
+ */
454
+ export const flatMap = (parser, f) => P.flatMap(parser, f);
455
+ /**
456
+ * nom's `value` (note the value comes first).
457
+ *
458
+ * @since 0.1.0
459
+ * @category combinator
460
+ */
461
+ export const value = (val, parser) => P.as(parser, val);
462
+ /**
463
+ * nom's `verify`.
464
+ *
465
+ * @since 0.1.0
466
+ * @category combinator
467
+ */
468
+ export const verify = (parser, predicate) => P.filter(parser, predicate);
469
+ /**
470
+ * nom's `recognize`.
471
+ *
472
+ * @since 0.1.0
473
+ * @category combinator
474
+ */
475
+ export const recognize = P.taken;
476
+ /**
477
+ * nom's `consumed`: returns `[consumed, output]`.
478
+ *
479
+ * @since 0.1.0
480
+ * @category combinator
481
+ */
482
+ export const consumed = (parser) => P.map(P.withTaken(parser), ([a, s]) => [s, a]);
483
+ /** @since 0.1.0 @category combinator */
484
+ export const opt = P.opt;
485
+ /** @since 0.1.0 @category combinator */
486
+ export const cond = P.cond;
487
+ /** @since 0.1.0 @category combinator */
488
+ export const peek = P.peek;
489
+ /** @since 0.1.0 @category combinator */
490
+ export const not = P.not;
491
+ /** @since 0.1.0 @category combinator */
492
+ export const eof = P.eof;
493
+ /** @since 0.1.0 @category combinator */
494
+ export const allConsuming = P.allConsuming;
495
+ /** @since 0.1.0 @category combinator */
496
+ export const complete = P.complete;
497
+ /** @since 0.1.0 @category combinator */
498
+ export const cut = P.cut;
499
+ /** @since 0.1.0 @category combinator */
500
+ export const success = P.succeed;
501
+ /**
502
+ * nom's `fail()`.
503
+ *
504
+ * @since 0.1.0
505
+ * @category combinator
506
+ */
507
+ export const fail = P.reject;
508
+ /** @since 0.1.0 @category combinator */
509
+ export const rest = Token.rest;
510
+ /** @since 0.1.0 @category combinator */
511
+ export const restLen = Token.restLen;
512
+ /**
513
+ * nom's `context` (note the label comes first).
514
+ *
515
+ * @since 0.1.0
516
+ * @category error
517
+ */
518
+ export const context = (label, parser) => P.context(parser, label);
519
+ //# sourceMappingURL=Nom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nom.js","sourceRoot":"","sources":["../src/Nom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAGrC,OAAO,KAAK,CAAC,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAGnC,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAA;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAyB,CAAI,EAAa,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAEjF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAmB,KAAK,CAAC,GAAG,CAAA;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAA2B,GAAgB,EAAuD,EAAE,CACrH,KAAK,CAAC,SAAS,CAAI,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;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C,CAAC,GAAG,CAAA;AACxB,wCAAwC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAA;AAC1C,wCAAwC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAA;AAClC,wCAAwC;AACxC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAA;AACxB,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAA;AAChC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAA;AAC5B,wCAAwC;AACxC,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;AAC9B,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAA2B,KAAa,EAAE,MAA0B,EAAsB,EAAE,CACjH,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA"}
@@ -0,0 +1,120 @@
1
+ import * as Option from "effect/Option";
2
+ import type { Encoding } from "./Encoding.js";
3
+ import type { ErrMode, Failure, Input } from "./Input.js";
4
+ /**
5
+ * The kind of parser that produced an error, in the spirit of nom's
6
+ * `ErrorKind`.
7
+ *
8
+ * @since 0.1.0
9
+ * @category models
10
+ */
11
+ export type ErrorKind = "Alpha" | "AlphaNumeric" | "Alt" | "Assert" | "Bits" | "Complete" | "CrLf" | "Digit" | "Dispatch" | "Eof" | "Escaped" | "Fail" | "Float" | "HexDigit" | "Incomplete" | "LineEnding" | "Literal" | "Many" | "MultiSpace" | "NoneOf" | "Not" | "OctDigit" | "OneOf" | "Permutation" | "Separated" | "Slice" | "Space" | "Take" | "TakeUntil" | "TakeWhile" | "Token" | "Verify";
12
+ /**
13
+ * @since 0.1.0
14
+ * @category type ids
15
+ */
16
+ export declare const TypeId: "~effect-parse/ParseError";
17
+ declare const ParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
18
+ readonly _tag: "ParseError";
19
+ } & Readonly<A>;
20
+ /**
21
+ * An error produced by running a parser.
22
+ *
23
+ * @since 0.1.0
24
+ * @category models
25
+ */
26
+ export declare class ParseError<out E = never> extends ParseError_base<{
27
+ /** The input that was being parsed. */
28
+ readonly input: Input;
29
+ /** The offset of the failure in the input. */
30
+ readonly offset: number;
31
+ /** The kind of parser that failed. */
32
+ readonly kind: ErrorKind;
33
+ /** How the error propagated before parsing stopped. */
34
+ readonly mode: ErrMode;
35
+ /** Descriptions of what was expected at `offset`. */
36
+ readonly expected: ReadonlyArray<string>;
37
+ /** Context labels (`Parser.context`), innermost first. */
38
+ readonly context: ReadonlyArray<string>;
39
+ /** The user supplied cause, if any. */
40
+ readonly cause: E | undefined;
41
+ /** An optional free-form description. */
42
+ readonly description: string | undefined;
43
+ /**
44
+ * For byte inputs parsed by `Text` parsers, the text encoding. Errors
45
+ * then show the input as text, with line and column numbers.
46
+ */
47
+ readonly encoding?: Encoding<Uint8Array> | undefined;
48
+ }> {
49
+ /**
50
+ * @since 0.1.0
51
+ */
52
+ readonly [TypeId]: typeof TypeId;
53
+ /**
54
+ * The 1-based line and column of the failure (for strings and encoded
55
+ * text; for other inputs the line is 1 and the column is `offset + 1`).
56
+ *
57
+ * @since 0.1.0
58
+ */
59
+ get position(): LineColumn;
60
+ /**
61
+ * The rendered, human-readable error message.
62
+ *
63
+ * @since 0.1.0
64
+ */
65
+ get message(): string;
66
+ /**
67
+ * @since 0.1.0
68
+ */
69
+ toString(): string;
70
+ }
71
+ /**
72
+ * @since 0.1.0
73
+ * @category guards
74
+ */
75
+ export declare const isParseError: (u: unknown) => u is ParseError<unknown>;
76
+ /**
77
+ * Builds a `ParseError` from the failure details recorded while parsing.
78
+ *
79
+ * @since 0.1.0
80
+ * @category constructors
81
+ */
82
+ export declare const fromFailure: <E = never>(input: Input, failure: Failure, mode: ErrMode, encoding?: Encoding<any> | undefined) => ParseError<E>;
83
+ /**
84
+ * The user supplied cause of an error, if any.
85
+ *
86
+ * @since 0.1.0
87
+ * @category getters
88
+ */
89
+ export declare const getCause: <E>(self: ParseError<E>) => Option.Option<E>;
90
+ /**
91
+ * A 1-based line/column position.
92
+ *
93
+ * @since 0.1.0
94
+ * @category models
95
+ */
96
+ export interface LineColumn {
97
+ readonly line: number;
98
+ readonly column: number;
99
+ }
100
+ /**
101
+ * Computes the 1-based line and column (in code points) of an offset. Lines
102
+ * are separated by `\n`. Byte inputs are read as text when an `encoding`
103
+ * is given. For other inputs the line is always 1 and the column is
104
+ * `offset + 1`.
105
+ *
106
+ * @since 0.1.0
107
+ * @category utils
108
+ */
109
+ export declare const lineColumn: (input: Input, offset: number, encoding?: Encoding<any> | undefined) => LineColumn;
110
+ /**
111
+ * Formats a list of expectations: `a`, `a or b`, `a, b or c`.
112
+ *
113
+ * @since 0.1.0
114
+ * @category utils
115
+ */
116
+ export declare const formatExpected: (expected: ReadonlyArray<string>) => string;
117
+ /** @internal */
118
+ export declare const inspectToken: (u: unknown) => string;
119
+ export {};
120
+ //# sourceMappingURL=ParseError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParseError.d.ts","sourceRoot":"","sources":["../src/ParseError.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGzD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,cAAc,GACd,KAAK,GACL,QAAQ,GACR,MAAM,GACN,UAAU,GACV,MAAM,GACN,OAAO,GACP,UAAU,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