@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.
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
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Input types and the mutable parse {@link State} cursor.
3
+ *
4
+ * Like winnow, effect-parse parsers advance a mutable cursor rather than
5
+ * returning the remaining input. A {@link State} wraps the original input
6
+ * together with the current offset, the streaming (partial) flag, the
7
+ * services available to the parser, and the details of the most recent
8
+ * failure.
9
+ *
10
+ * Most users never touch `State` directly. It is exposed for writing custom
11
+ * low-level parsers with `Parser.make`.
12
+ *
13
+ * @since 0.1.0
14
+ */
15
+ import * as Context from "effect/Context";
16
+ import type { Encoding } from "./Encoding.js";
17
+ import type { ErrorKind } from "./ParseError.js";
18
+ /**
19
+ * The kinds of input a parser can consume.
20
+ *
21
+ * - `string`: tokens are Unicode code points (returned as strings), offsets
22
+ * are UTF-16 code-unit indices.
23
+ * - `Uint8Array`: tokens are bytes (numbers), slices are `subarray` views.
24
+ * - `ReadonlyArray<T>`: tokens are elements, e.g. the output of a lexer.
25
+ *
26
+ * @since 0.1.0
27
+ * @category models
28
+ */
29
+ export type Input = string | Uint8Array | ReadonlyArray<unknown>;
30
+ /**
31
+ * Binary data that can be passed wherever a `Uint8Array` input is expected:
32
+ * an `ArrayBuffer`, a `SharedArrayBuffer`, a `DataView` or any typed array.
33
+ *
34
+ * It is viewed, not copied, as a `Uint8Array` of its bytes. A typed array
35
+ * with wider elements is viewed in the platform's byte order, which is
36
+ * little endian on all common platforms, so a `Uint16Array` of UTF-16 code
37
+ * units can be parsed with `Text.utf16le`.
38
+ *
39
+ * @since 0.1.0
40
+ * @category models
41
+ */
42
+ export type BinaryInput = ArrayBufferLike | ArrayBufferView;
43
+ /**
44
+ * What the runners accept for a parser over `I`: the input itself, or, for
45
+ * byte parsers, any {@link BinaryInput}.
46
+ *
47
+ * @since 0.1.0
48
+ * @category models
49
+ */
50
+ export type Source<I> = I | ([I] extends [Uint8Array] ? BinaryInput : never);
51
+ /**
52
+ * Converts a {@link Source} to the input parsers read: binary data becomes a
53
+ * `Uint8Array` view of the same memory, everything else is returned as is.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { Input } from "@thomasfosterau/effect-parse"
58
+ *
59
+ * Input.fromSource(new Uint16Array([0x41]).buffer) // Uint8Array [0x41, 0x00]
60
+ * ```
61
+ *
62
+ * @since 0.1.0
63
+ * @category constructors
64
+ */
65
+ export declare const fromSource: {
66
+ (source: BinaryInput): Uint8Array;
67
+ <I extends Input>(source: Source<I>): I;
68
+ };
69
+ /**
70
+ * The type of a single token of an input.
71
+ *
72
+ * @since 0.1.0
73
+ * @category models
74
+ */
75
+ export type Token<I> = I extends string ? string : I extends Uint8Array ? number : I extends ReadonlyArray<infer T> ? T : never;
76
+ /**
77
+ * The type of a contiguous slice of an input.
78
+ *
79
+ * @since 0.1.0
80
+ * @category models
81
+ */
82
+ export type Slice<I> = I extends string ? string : I extends Uint8Array ? Uint8Array : I extends ReadonlyArray<infer T> ? ReadonlyArray<T> : never;
83
+ /**
84
+ * Sentinel returned by a parser step to signal failure. The failure details
85
+ * are stored on the {@link State}.
86
+ *
87
+ * @since 0.1.0
88
+ * @category failure
89
+ */
90
+ export declare const Fail: unique symbol;
91
+ /**
92
+ * @since 0.1.0
93
+ * @category failure
94
+ */
95
+ export type Fail = typeof Fail;
96
+ /**
97
+ * How a failure propagates (winnow's `ErrMode`, nom's `Err`).
98
+ *
99
+ * - `Backtrack`: recoverable; `alt`, `opt`, `repeat`, ... try something else.
100
+ * - `Cut`: unrecoverable; alternatives are not attempted.
101
+ * - `Incomplete`: a partial (streaming) input ran out; more data is needed.
102
+ *
103
+ * @since 0.1.0
104
+ * @category failure
105
+ */
106
+ export type ErrMode = "Backtrack" | "Cut" | "Incomplete";
107
+ /**
108
+ * The details of a parse failure.
109
+ *
110
+ * @since 0.1.0
111
+ * @category failure
112
+ */
113
+ export declare class Failure {
114
+ /** Offset into the input where the failure occurred. */
115
+ readonly offset: number;
116
+ /** The kind of parser that failed. */
117
+ readonly kind: ErrorKind;
118
+ /** Rendered descriptions of what was expected at `offset`. */
119
+ readonly expected: ReadonlyArray<string>;
120
+ /** Context labels added by `Parser.context`, innermost first. */
121
+ readonly context: ReadonlyArray<string>;
122
+ /** Whether a user supplied cause is present. */
123
+ readonly hasCause: boolean;
124
+ /** A user supplied (typed) cause. */
125
+ readonly cause: unknown;
126
+ /** An optional free-form message. */
127
+ readonly message: string | undefined;
128
+ /** For `Incomplete` failures, how many more tokens are needed (0 if unknown). */
129
+ readonly needed: number;
130
+ constructor(
131
+ /** Offset into the input where the failure occurred. */
132
+ offset: number,
133
+ /** The kind of parser that failed. */
134
+ kind: ErrorKind,
135
+ /** Rendered descriptions of what was expected at `offset`. */
136
+ expected: ReadonlyArray<string>,
137
+ /** Context labels added by `Parser.context`, innermost first. */
138
+ context: ReadonlyArray<string>,
139
+ /** Whether a user supplied cause is present. */
140
+ hasCause: boolean,
141
+ /** A user supplied (typed) cause. */
142
+ cause: unknown,
143
+ /** An optional free-form message. */
144
+ message: string | undefined,
145
+ /** For `Incomplete` failures, how many more tokens are needed (0 if unknown). */
146
+ needed: number);
147
+ }
148
+ /** @internal */
149
+ export declare const emptyStrings: readonly string[];
150
+ /**
151
+ * A tracing event emitted by `Parser.trace`.
152
+ *
153
+ * @since 0.1.0
154
+ * @category tracing
155
+ */
156
+ export interface TraceEvent {
157
+ readonly _tag: "Enter" | "Exit";
158
+ readonly name: string;
159
+ readonly depth: number;
160
+ readonly offset: number;
161
+ /** For `Exit` events: the outcome. */
162
+ readonly result?: "Ok" | ErrMode;
163
+ /** For `Exit` events: the offset reached. */
164
+ readonly endOffset?: number;
165
+ readonly state: State;
166
+ }
167
+ /**
168
+ * The mutable parsing cursor.
169
+ *
170
+ * @since 0.1.0
171
+ * @category models
172
+ */
173
+ export declare class State<I extends Input = Input> {
174
+ /** The full input being parsed. */
175
+ readonly input: I;
176
+ /** The current offset. Advanced by parsers, rewound on backtracking. */
177
+ pos: number;
178
+ /** The end offset (the input's length; in bits inside `Bits.bits`). */
179
+ end: number;
180
+ /** 0 = string, 1 = Uint8Array, 2 = array. */
181
+ readonly inputKind: 0 | 1 | 2;
182
+ /** Whether the input is partial (streaming): running out yields `Incomplete`. */
183
+ partial: boolean;
184
+ /** Services available to `Parser.service`. */
185
+ context: Context.Context<never>;
186
+ /** Mode of the latest failure. Only meaningful after a step returned {@link Fail}. */
187
+ mode: ErrMode;
188
+ /** Details of the latest failure. Only meaningful after a step returned {@link Fail}. */
189
+ failure: Failure;
190
+ /**
191
+ * The offset of a recoverable failure that occurred without consuming
192
+ * input (for example the last attempt of a `repeat`). Its
193
+ * expectations are merged into new failures at the same offset, producing
194
+ * messages like `expected digit or ")"`.
195
+ */
196
+ hintOffset: number;
197
+ /** The expectations of the hint at {@link hintOffset}. */
198
+ hintExpected: ReadonlyArray<string>;
199
+ /**
200
+ * The furthest recoverable failure seen so far, including failures that
201
+ * were later swallowed by backtracking (for example a trailing separator
202
+ * followed by an invalid element). It is reported instead of the final
203
+ * failure when it lies further into the input. This is the classic PEG
204
+ * "farthest failure" heuristic.
205
+ */
206
+ deepest: Failure | undefined;
207
+ /** When defined, `Parser.resumeAfter`/`retryAfter` record failures here. */
208
+ recovered: Array<Failure> | undefined;
209
+ /** When defined, `Parser.trace` reports events here. */
210
+ tracer: ((event: TraceEvent) => void) | undefined;
211
+ /** Current tracing depth. */
212
+ depth: number;
213
+ /**
214
+ * The text encoding of a byte input, recorded by `Text` parsers when they
215
+ * fail so that errors can show the input as text.
216
+ */
217
+ encoding: Encoding<any> | undefined;
218
+ /**
219
+ * The checkpoints of a resumable streaming parse (see
220
+ * `ParserStream.parseAll`); `undefined` otherwise.
221
+ *
222
+ * @internal
223
+ */
224
+ resume: Map<object, Map<number, unknown>> | undefined;
225
+ constructor(source: I | Source<I>, options?: {
226
+ readonly partial?: boolean | undefined;
227
+ readonly context?: Context.Context<never> | undefined;
228
+ readonly offset?: number | undefined;
229
+ });
230
+ /**
231
+ * The number of input units (code units, bytes or elements) remaining.
232
+ */
233
+ remaining(): number;
234
+ /**
235
+ * Whether the cursor is at the end of the input.
236
+ */
237
+ atEnd(): boolean;
238
+ /**
239
+ * Extracts the slice `[start, end)` of the input.
240
+ */
241
+ slice(start: number, end: number): Slice<I>;
242
+ /**
243
+ * Records a recoverable failure at the current offset and returns {@link Fail}.
244
+ */
245
+ backtrack(kind: ErrorKind, expected?: ReadonlyArray<string>, offset?: number): Fail;
246
+ /**
247
+ * Records an unrecoverable failure at the current offset and returns {@link Fail}.
248
+ */
249
+ cut(kind: ErrorKind, expected?: ReadonlyArray<string>, offset?: number): Fail;
250
+ /**
251
+ * Records an `Incomplete` failure (only meaningful for partial input) and
252
+ * returns {@link Fail}.
253
+ */
254
+ incomplete(needed: number, expected?: ReadonlyArray<string>): Fail;
255
+ /**
256
+ * Fails because the input ended: `Incomplete` for partial input, otherwise
257
+ * a `Backtrack` failure of the given kind.
258
+ */
259
+ eoi(kind: ErrorKind, expected: ReadonlyArray<string>, needed: number): Fail;
260
+ /**
261
+ * Records a failure carrying a user supplied cause.
262
+ */
263
+ failCause(mode: ErrMode, kind: ErrorKind, cause: unknown, offset?: number): Fail;
264
+ /**
265
+ * Records a failure carrying a message.
266
+ */
267
+ failMessage(mode: ErrMode, kind: ErrorKind, message: string, offset?: number): Fail;
268
+ /**
269
+ * Records the given failure and returns {@link Fail}.
270
+ */
271
+ failWith(mode: ErrMode, failure: Failure): Fail;
272
+ /**
273
+ * Replaces the details of the current failure (for example to add context),
274
+ * keeping the record of the furthest failure consistent.
275
+ */
276
+ replaceFailure(failure: Failure): void;
277
+ /**
278
+ * The failure to report to the user: the current failure, or the furthest
279
+ * failure if it lies beyond the current one and the current failure is a
280
+ * plain syntax error (no user cause or message).
281
+ */
282
+ reportedFailure(): Failure;
283
+ /**
284
+ * Records that, at `offset`, any of `expected` could also have been
285
+ * accepted. Used by parsers that stop without failing, such as `opt`,
286
+ * `repeat` and `Ascii.digit1`.
287
+ */
288
+ setHint(offset: number, expected: ReadonlyArray<string>): void;
289
+ /** @internal */
290
+ makeFailure(offset: number, kind: ErrorKind, expected: ReadonlyArray<string>): Failure;
291
+ }
292
+ /** @internal */
293
+ export declare const mergeExpected: (a: ReadonlyArray<string>, b: ReadonlyArray<string>) => ReadonlyArray<string>;
294
+ /**
295
+ * Combines the failures of two alternatives: the furthest failure wins, and
296
+ * failures at the same offset have their expectations merged.
297
+ *
298
+ * @internal
299
+ */
300
+ export declare const mergeFailures: (a: Failure, b: Failure) => Failure;
301
+ //# sourceMappingURL=Input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,eAAe,CAAA;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,WAAW,GAAG,KAAK,CAAC,CAAA;AAE5E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAAA;IACjC,CAAC,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;CAOxC,CAAA;AAKD;;;;;GAKG;AACH,MAAM,MAAM,KAAK,CAAC,CAA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MAAM,aAAa,MAAO,OAAO,KAAK,OAAO,KAAG,OAetD,CAAA"}
package/dist/Input.js ADDED
@@ -0,0 +1,312 @@
1
+ /**
2
+ * Input types and the mutable parse {@link State} cursor.
3
+ *
4
+ * Like winnow, effect-parse parsers advance a mutable cursor rather than
5
+ * returning the remaining input. A {@link State} wraps the original input
6
+ * together with the current offset, the streaming (partial) flag, the
7
+ * services available to the parser, and the details of the most recent
8
+ * failure.
9
+ *
10
+ * Most users never touch `State` directly. It is exposed for writing custom
11
+ * low-level parsers with `Parser.make`.
12
+ *
13
+ * @since 0.1.0
14
+ */
15
+ import * as Context from "effect/Context";
16
+ /**
17
+ * Converts a {@link Source} to the input parsers read: binary data becomes a
18
+ * `Uint8Array` view of the same memory, everything else is returned as is.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { Input } from "@thomasfosterau/effect-parse"
23
+ *
24
+ * Input.fromSource(new Uint16Array([0x41]).buffer) // Uint8Array [0x41, 0x00]
25
+ * ```
26
+ *
27
+ * @since 0.1.0
28
+ * @category constructors
29
+ */
30
+ export const fromSource = (source) => {
31
+ if (typeof source === "string" || source instanceof Uint8Array || Array.isArray(source))
32
+ return source;
33
+ if (ArrayBuffer.isView(source))
34
+ return new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
35
+ // An explicit length fixes the view's size even for a resizable buffer
36
+ if (isArrayBufferLike(source))
37
+ return new Uint8Array(source, 0, source.byteLength);
38
+ return source;
39
+ };
40
+ const isArrayBufferLike = (u) => u instanceof ArrayBuffer || (typeof SharedArrayBuffer !== "undefined" && u instanceof SharedArrayBuffer);
41
+ /**
42
+ * Sentinel returned by a parser step to signal failure. The failure details
43
+ * are stored on the {@link State}.
44
+ *
45
+ * @since 0.1.0
46
+ * @category failure
47
+ */
48
+ export const Fail = Symbol.for("effect-parse/Fail");
49
+ /**
50
+ * The details of a parse failure.
51
+ *
52
+ * @since 0.1.0
53
+ * @category failure
54
+ */
55
+ export class Failure {
56
+ offset;
57
+ kind;
58
+ expected;
59
+ context;
60
+ hasCause;
61
+ cause;
62
+ message;
63
+ needed;
64
+ constructor(
65
+ /** Offset into the input where the failure occurred. */
66
+ offset,
67
+ /** The kind of parser that failed. */
68
+ kind,
69
+ /** Rendered descriptions of what was expected at `offset`. */
70
+ expected,
71
+ /** Context labels added by `Parser.context`, innermost first. */
72
+ context,
73
+ /** Whether a user supplied cause is present. */
74
+ hasCause,
75
+ /** A user supplied (typed) cause. */
76
+ cause,
77
+ /** An optional free-form message. */
78
+ message,
79
+ /** For `Incomplete` failures, how many more tokens are needed (0 if unknown). */
80
+ needed) {
81
+ this.offset = offset;
82
+ this.kind = kind;
83
+ this.expected = expected;
84
+ this.context = context;
85
+ this.hasCause = hasCause;
86
+ this.cause = cause;
87
+ this.message = message;
88
+ this.needed = needed;
89
+ }
90
+ }
91
+ const empty = [];
92
+ /** @internal */
93
+ export const emptyStrings = empty;
94
+ /**
95
+ * The mutable parsing cursor.
96
+ *
97
+ * @since 0.1.0
98
+ * @category models
99
+ */
100
+ export class State {
101
+ /** The full input being parsed. */
102
+ input;
103
+ /** The current offset. Advanced by parsers, rewound on backtracking. */
104
+ pos;
105
+ /** The end offset (the input's length; in bits inside `Bits.bits`). */
106
+ end;
107
+ /** 0 = string, 1 = Uint8Array, 2 = array. */
108
+ inputKind;
109
+ /** Whether the input is partial (streaming): running out yields `Incomplete`. */
110
+ partial;
111
+ /** Services available to `Parser.service`. */
112
+ context;
113
+ /** Mode of the latest failure. Only meaningful after a step returned {@link Fail}. */
114
+ mode = "Backtrack";
115
+ /** Details of the latest failure. Only meaningful after a step returned {@link Fail}. */
116
+ failure;
117
+ /**
118
+ * The offset of a recoverable failure that occurred without consuming
119
+ * input (for example the last attempt of a `repeat`). Its
120
+ * expectations are merged into new failures at the same offset, producing
121
+ * messages like `expected digit or ")"`.
122
+ */
123
+ hintOffset = -1;
124
+ /** The expectations of the hint at {@link hintOffset}. */
125
+ hintExpected = empty;
126
+ /**
127
+ * The furthest recoverable failure seen so far, including failures that
128
+ * were later swallowed by backtracking (for example a trailing separator
129
+ * followed by an invalid element). It is reported instead of the final
130
+ * failure when it lies further into the input. This is the classic PEG
131
+ * "farthest failure" heuristic.
132
+ */
133
+ deepest = undefined;
134
+ /** When defined, `Parser.resumeAfter`/`retryAfter` record failures here. */
135
+ recovered = undefined;
136
+ /** When defined, `Parser.trace` reports events here. */
137
+ tracer = undefined;
138
+ /** Current tracing depth. */
139
+ depth = 0;
140
+ /**
141
+ * The text encoding of a byte input, recorded by `Text` parsers when they
142
+ * fail so that errors can show the input as text.
143
+ */
144
+ encoding = undefined;
145
+ /**
146
+ * The checkpoints of a resumable streaming parse (see
147
+ * `ParserStream.parseAll`); `undefined` otherwise.
148
+ *
149
+ * @internal
150
+ */
151
+ resume = undefined;
152
+ constructor(source, options) {
153
+ const input = fromSource(source);
154
+ this.input = input;
155
+ this.end = input.length;
156
+ this.pos = options?.offset ?? 0;
157
+ this.partial = options?.partial ?? false;
158
+ this.context = options?.context ?? Context.empty();
159
+ this.inputKind = typeof input === "string" ? 0 : input instanceof Uint8Array ? 1 : 2;
160
+ this.failure = new Failure(0, "Fail", empty, empty, false, undefined, undefined, 0);
161
+ }
162
+ /**
163
+ * The number of input units (code units, bytes or elements) remaining.
164
+ */
165
+ remaining() {
166
+ return this.end - this.pos;
167
+ }
168
+ /**
169
+ * Whether the cursor is at the end of the input.
170
+ */
171
+ atEnd() {
172
+ return this.pos >= this.end;
173
+ }
174
+ /**
175
+ * Extracts the slice `[start, end)` of the input.
176
+ */
177
+ slice(start, end) {
178
+ const input = this.input;
179
+ switch (this.inputKind) {
180
+ case 0:
181
+ return input.slice(start, end);
182
+ case 1:
183
+ return input.subarray(start, end);
184
+ default:
185
+ return input.slice(start, end);
186
+ }
187
+ }
188
+ /**
189
+ * Records a recoverable failure at the current offset and returns {@link Fail}.
190
+ */
191
+ backtrack(kind, expected = empty, offset = this.pos) {
192
+ return this.failWith("Backtrack", this.makeFailure(offset, kind, expected));
193
+ }
194
+ /**
195
+ * Records an unrecoverable failure at the current offset and returns {@link Fail}.
196
+ */
197
+ cut(kind, expected = empty, offset = this.pos) {
198
+ return this.failWith("Cut", this.makeFailure(offset, kind, expected));
199
+ }
200
+ /**
201
+ * Records an `Incomplete` failure (only meaningful for partial input) and
202
+ * returns {@link Fail}.
203
+ */
204
+ incomplete(needed, expected = empty) {
205
+ return this.failWith("Incomplete", new Failure(this.pos, "Incomplete", expected, empty, false, undefined, undefined, needed));
206
+ }
207
+ /**
208
+ * Fails because the input ended: `Incomplete` for partial input, otherwise
209
+ * a `Backtrack` failure of the given kind.
210
+ */
211
+ eoi(kind, expected, needed) {
212
+ return this.partial ? this.incomplete(needed, expected) : this.backtrack(kind, expected);
213
+ }
214
+ /**
215
+ * Records a failure carrying a user supplied cause.
216
+ */
217
+ failCause(mode, kind, cause, offset = this.pos) {
218
+ return this.failWith(mode, new Failure(offset, kind, empty, empty, true, cause, undefined, 0));
219
+ }
220
+ /**
221
+ * Records a failure carrying a message.
222
+ */
223
+ failMessage(mode, kind, message, offset = this.pos) {
224
+ return this.failWith(mode, new Failure(offset, kind, empty, empty, false, undefined, message, 0));
225
+ }
226
+ /**
227
+ * Records the given failure and returns {@link Fail}.
228
+ */
229
+ failWith(mode, failure) {
230
+ this.mode = mode;
231
+ this.failure = failure;
232
+ if (mode === "Backtrack" && (this.deepest === undefined || failure.offset >= this.deepest.offset)) {
233
+ this.deepest = failure;
234
+ }
235
+ return Fail;
236
+ }
237
+ /**
238
+ * Replaces the details of the current failure (for example to add context),
239
+ * keeping the record of the furthest failure consistent.
240
+ */
241
+ replaceFailure(failure) {
242
+ if (this.deepest === this.failure)
243
+ this.deepest = failure;
244
+ this.failure = failure;
245
+ }
246
+ /**
247
+ * The failure to report to the user: the current failure, or the furthest
248
+ * failure if it lies beyond the current one and the current failure is a
249
+ * plain syntax error (no user cause or message).
250
+ */
251
+ reportedFailure() {
252
+ const f = this.failure;
253
+ const d = this.deepest;
254
+ if (d === undefined || d === f || d.offset <= f.offset || this.mode === "Incomplete" ||
255
+ f.hasCause || f.message !== undefined) {
256
+ return f;
257
+ }
258
+ const context = d.context.length === 0 ? f.context : [...d.context, ...f.context.filter((l) => !d.context.includes(l))];
259
+ return new Failure(d.offset, d.kind, d.expected, context, d.hasCause, d.cause, d.message, d.needed);
260
+ }
261
+ /**
262
+ * Records that, at `offset`, any of `expected` could also have been
263
+ * accepted. Used by parsers that stop without failing, such as `opt`,
264
+ * `repeat` and `Ascii.digit1`.
265
+ */
266
+ setHint(offset, expected) {
267
+ if (this.hintOffset === offset) {
268
+ this.hintExpected = mergeExpected(this.hintExpected, expected);
269
+ }
270
+ else {
271
+ this.hintOffset = offset;
272
+ this.hintExpected = expected;
273
+ }
274
+ }
275
+ /** @internal */
276
+ makeFailure(offset, kind, expected) {
277
+ if (this.hintOffset === offset && this.hintExpected.length > 0) {
278
+ expected = mergeExpected(this.hintExpected, expected);
279
+ }
280
+ return new Failure(offset, kind, expected, empty, false, undefined, undefined, 0);
281
+ }
282
+ }
283
+ /** @internal */
284
+ export const mergeExpected = (a, b) => {
285
+ if (a.length === 0)
286
+ return b;
287
+ if (b.length === 0)
288
+ return a;
289
+ const out = a.slice();
290
+ for (const e of b) {
291
+ if (!out.includes(e))
292
+ out.push(e);
293
+ }
294
+ return out;
295
+ };
296
+ /**
297
+ * Combines the failures of two alternatives: the furthest failure wins, and
298
+ * failures at the same offset have their expectations merged.
299
+ *
300
+ * @internal
301
+ */
302
+ export const mergeFailures = (a, b) => {
303
+ if (a.offset > b.offset)
304
+ return a;
305
+ if (b.offset > a.offset)
306
+ return b;
307
+ const expected = mergeExpected(a.expected, b.expected);
308
+ if (expected === b.expected)
309
+ return b;
310
+ return new Failure(b.offset, b.kind, expected, b.context.length > 0 ? b.context : a.context, b.hasCause || a.hasCause, b.hasCause ? b.cause : a.cause, b.message ?? a.message, b.needed);
311
+ };
312
+ //# sourceMappingURL=Input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.js","s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