@thomasfosterau/effect-parse 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -230
- package/dist/Ascii.d.ts +32 -53
- package/dist/Ascii.d.ts.map +1 -1
- package/dist/Ascii.js +576 -571
- package/dist/Ascii.js.map +1 -1
- package/dist/Binary.d.ts +6 -29
- package/dist/Binary.d.ts.map +1 -1
- package/dist/Binary.js +129 -116
- package/dist/Binary.js.map +1 -1
- package/dist/Bits.d.ts +4 -2
- package/dist/Bits.d.ts.map +1 -1
- package/dist/Bits.js +121 -123
- package/dist/Bits.js.map +1 -1
- package/dist/Compiler.d.ts +39 -0
- package/dist/Compiler.d.ts.map +1 -0
- package/dist/Compiler.js +48 -0
- package/dist/Compiler.js.map +1 -0
- package/dist/Encoding.d.ts +29 -46
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +76 -75
- package/dist/Encoding.js.map +1 -1
- package/dist/Expression.d.ts +15 -49
- package/dist/Expression.d.ts.map +1 -1
- package/dist/Expression.js +143 -131
- package/dist/Expression.js.map +1 -1
- package/dist/Input.d.ts +206 -177
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +317 -299
- package/dist/Input.js.map +1 -1
- package/dist/Nom.d.ts +44 -84
- package/dist/Nom.d.ts.map +1 -1
- package/dist/Nom.js +423 -453
- package/dist/Nom.js.map +1 -1
- package/dist/ParseError.d.ts +54 -49
- package/dist/ParseError.d.ts.map +1 -1
- package/dist/ParseError.js +233 -275
- package/dist/ParseError.js.map +1 -1
- package/dist/Parser.d.ts +345 -313
- package/dist/Parser.d.ts.map +1 -1
- package/dist/Parser.js +2010 -1802
- package/dist/Parser.js.map +1 -1
- package/dist/ParserSchema.d.ts +8 -7
- package/dist/ParserSchema.d.ts.map +1 -1
- package/dist/ParserSchema.js +49 -49
- package/dist/ParserSchema.js.map +1 -1
- package/dist/ParserStream.d.ts +26 -20
- package/dist/ParserStream.d.ts.map +1 -1
- package/dist/ParserStream.js +267 -255
- package/dist/ParserStream.js.map +1 -1
- package/dist/Syntax.d.ts +401 -0
- package/dist/Syntax.d.ts.map +1 -0
- package/dist/Syntax.js +717 -0
- package/dist/Syntax.js.map +1 -0
- package/dist/Text.d.ts +98 -134
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +534 -496
- package/dist/Text.js.map +1 -1
- package/dist/Token.d.ts +60 -42
- package/dist/Token.d.ts.map +1 -1
- package/dist/Token.js +331 -265
- package/dist/Token.js.map +1 -1
- package/dist/index.d.ts +16 -17
- package/dist/index.js +16 -17
- package/dist/internal/compiler/closure.d.ts +14 -16
- package/dist/internal/compiler/closure.d.ts.map +1 -1
- package/dist/internal/compiler/closure.js +1458 -1637
- package/dist/internal/compiler/closure.js.map +1 -1
- package/dist/internal/compiler/entries.d.ts +11 -11
- package/dist/internal/compiler/entries.d.ts.map +1 -1
- package/dist/internal/compiler/entries.js +36 -26
- package/dist/internal/compiler/entries.js.map +1 -1
- package/dist/internal/compiler/first.d.ts +19 -19
- package/dist/internal/compiler/first.d.ts.map +1 -1
- package/dist/internal/compiler/first.js +251 -227
- package/dist/internal/compiler/first.js.map +1 -1
- package/dist/internal/compiler/jit.d.ts +6 -17
- package/dist/internal/compiler/jit.d.ts.map +1 -1
- package/dist/internal/compiler/jit.js +860 -988
- package/dist/internal/compiler/jit.js.map +1 -1
- package/dist/internal/compiler/registry.d.ts +20 -21
- package/dist/internal/compiler/registry.d.ts.map +1 -1
- package/dist/internal/compiler/registry.js +21 -41
- package/dist/internal/compiler/registry.js.map +1 -1
- package/dist/internal/compiler/sets.d.ts +9 -13
- package/dist/internal/compiler/sets.d.ts.map +1 -1
- package/dist/internal/compiler/sets.js +76 -73
- package/dist/internal/compiler/sets.js.map +1 -1
- package/dist/internal/entries.d.ts +3 -3
- package/dist/internal/entries.d.ts.map +1 -1
- package/dist/internal/entries.js +38 -30
- package/dist/internal/entries.js.map +1 -1
- package/dist/internal/node.d.ts +177 -173
- package/dist/internal/node.d.ts.map +1 -1
- package/dist/internal/node.js +77 -66
- package/dist/internal/node.js.map +1 -1
- package/dist/internal/numbers.d.ts +7 -8
- package/dist/internal/numbers.d.ts.map +1 -1
- package/dist/internal/numbers.js +246 -276
- package/dist/internal/numbers.js.map +1 -1
- package/dist/internal/resume.d.ts +6 -24
- package/dist/internal/resume.d.ts.map +1 -1
- package/dist/internal/resume.js +30 -29
- package/dist/internal/resume.js.map +1 -1
- package/dist/internal/run.d.ts +15 -0
- package/dist/internal/run.d.ts.map +1 -0
- package/dist/internal/run.js +36 -0
- package/dist/internal/run.js.map +1 -0
- package/dist/internal/stack.d.ts +16 -0
- package/dist/internal/stack.d.ts.map +1 -0
- package/dist/internal/stack.js +26 -0
- package/dist/internal/stack.js.map +1 -0
- package/dist/internal/syntax.d.ts +146 -0
- package/dist/internal/syntax.d.ts.map +1 -0
- package/dist/internal/syntax.js +305 -0
- package/dist/internal/syntax.js.map +1 -0
- package/dist/internal/text.d.ts +10 -2
- package/dist/internal/text.d.ts.map +1 -1
- package/dist/internal/text.js +295 -345
- package/dist/internal/text.js.map +1 -1
- package/dist/internal/tokens.d.ts +25 -30
- package/dist/internal/tokens.d.ts.map +1 -1
- package/dist/internal/tokens.js +369 -363
- package/dist/internal/tokens.js.map +1 -1
- package/package.json +42 -28
- package/src/Ascii.ts +278 -187
- package/src/Binary.ts +150 -44
- package/src/Bits.ts +6 -3
- package/src/Compiler.ts +98 -0
- package/src/Expression.ts +10 -5
- package/src/Input.ts +106 -28
- package/src/Nom.ts +4 -3
- package/src/ParseError.ts +48 -51
- package/src/Parser.ts +1163 -795
- package/src/ParserStream.ts +104 -80
- package/src/Syntax.ts +900 -0
- package/src/Text.ts +272 -187
- package/src/Token.ts +180 -87
- package/src/index.ts +2 -0
- package/src/internal/compiler/closure.ts +121 -88
- package/src/internal/compiler/entries.ts +21 -8
- package/src/internal/compiler/first.ts +17 -15
- package/src/internal/compiler/jit.ts +360 -157
- package/src/internal/compiler/registry.ts +12 -33
- package/src/internal/compiler/sets.ts +17 -11
- package/src/internal/entries.ts +4 -2
- package/src/internal/node.ts +51 -37
- package/src/internal/numbers.ts +22 -20
- package/src/internal/resume.ts +8 -4
- package/src/internal/run.ts +41 -0
- package/src/internal/stack.ts +36 -0
- package/src/internal/syntax.ts +421 -0
- package/src/internal/text.ts +32 -25
- package/src/internal/tokens.ts +96 -51
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/Input.d.ts
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
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
1
|
import * as Context from "effect/Context";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
2
|
+
import { ErrorKind } from "./ParseError.js";
|
|
3
|
+
import { Builder } from "./internal/syntax.js";
|
|
4
|
+
import { Encoding } from "./Encoding.js";
|
|
5
|
+
//#region src/Input.d.ts
|
|
18
6
|
/**
|
|
19
7
|
* The kinds of input a parser can consume.
|
|
20
8
|
*
|
|
@@ -63,8 +51,8 @@ export type Source<I> = I | ([I] extends [Uint8Array] ? BinaryInput : never);
|
|
|
63
51
|
* @category constructors
|
|
64
52
|
*/
|
|
65
53
|
export declare const fromSource: {
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
(source: BinaryInput): Uint8Array;
|
|
55
|
+
<I extends Input>(source: Source<I>): I;
|
|
68
56
|
};
|
|
69
57
|
/**
|
|
70
58
|
* The type of a single token of an input.
|
|
@@ -111,39 +99,39 @@ export type ErrMode = "Backtrack" | "Cut" | "Incomplete";
|
|
|
111
99
|
* @category failure
|
|
112
100
|
*/
|
|
113
101
|
export declare class Failure {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
102
|
+
/** Offset into the input where the failure occurred. */
|
|
103
|
+
readonly offset: number;
|
|
104
|
+
/** The kind of parser that failed. */
|
|
105
|
+
readonly kind: ErrorKind;
|
|
106
|
+
/** Rendered descriptions of what was expected at `offset`. */
|
|
107
|
+
readonly expected: ReadonlyArray<string>;
|
|
108
|
+
/** Context labels added by `Parser.context`, innermost first. */
|
|
109
|
+
readonly context: ReadonlyArray<string>;
|
|
110
|
+
/** Whether a user supplied cause is present. */
|
|
111
|
+
readonly hasCause: boolean;
|
|
112
|
+
/** A user supplied (typed) cause. */
|
|
113
|
+
readonly cause: unknown;
|
|
114
|
+
/** An optional free-form message. */
|
|
115
|
+
readonly message: string | undefined;
|
|
116
|
+
/** For `Incomplete` failures, how many more tokens are needed (0 if unknown). */
|
|
117
|
+
readonly needed: number;
|
|
118
|
+
constructor(
|
|
119
|
+
/** Offset into the input where the failure occurred. */
|
|
120
|
+
offset: number,
|
|
121
|
+
/** The kind of parser that failed. */
|
|
122
|
+
kind: ErrorKind,
|
|
123
|
+
/** Rendered descriptions of what was expected at `offset`. */
|
|
124
|
+
expected: ReadonlyArray<string>,
|
|
125
|
+
/** Context labels added by `Parser.context`, innermost first. */
|
|
126
|
+
context: ReadonlyArray<string>,
|
|
127
|
+
/** Whether a user supplied cause is present. */
|
|
128
|
+
hasCause: boolean,
|
|
129
|
+
/** A user supplied (typed) cause. */
|
|
130
|
+
cause: unknown,
|
|
131
|
+
/** An optional free-form message. */
|
|
132
|
+
message: string | undefined,
|
|
133
|
+
/** For `Incomplete` failures, how many more tokens are needed (0 if unknown). */
|
|
134
|
+
needed: number);
|
|
147
135
|
}
|
|
148
136
|
/** @internal */
|
|
149
137
|
export declare const emptyStrings: readonly string[];
|
|
@@ -154,15 +142,15 @@ export declare const emptyStrings: readonly string[];
|
|
|
154
142
|
* @category tracing
|
|
155
143
|
*/
|
|
156
144
|
export interface TraceEvent {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
145
|
+
readonly _tag: "Enter" | "Exit";
|
|
146
|
+
readonly name: string;
|
|
147
|
+
readonly depth: number;
|
|
148
|
+
readonly offset: number;
|
|
149
|
+
/** For `Exit` events: the outcome. */
|
|
150
|
+
readonly result?: "Ok" | ErrMode;
|
|
151
|
+
/** For `Exit` events: the offset reached. */
|
|
152
|
+
readonly endOffset?: number;
|
|
153
|
+
readonly state: State;
|
|
166
154
|
}
|
|
167
155
|
/**
|
|
168
156
|
* The mutable parsing cursor.
|
|
@@ -171,123 +159,163 @@ export interface TraceEvent {
|
|
|
171
159
|
* @category models
|
|
172
160
|
*/
|
|
173
161
|
export declare class State<I extends Input = Input> {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
162
|
+
/** The full input being parsed. */
|
|
163
|
+
readonly input: I;
|
|
164
|
+
/** The current offset. Advanced by parsers, rewound on backtracking. */
|
|
165
|
+
pos: number;
|
|
166
|
+
/** The end offset (the input's length; in bits inside `Bits.bits`). */
|
|
167
|
+
end: number;
|
|
168
|
+
/** 0 = string, 1 = Uint8Array, 2 = array. */
|
|
169
|
+
readonly inputKind: 0 | 1 | 2;
|
|
170
|
+
/** Whether the input is partial (streaming): running out yields `Incomplete`. */
|
|
171
|
+
partial: boolean;
|
|
172
|
+
/** Services available to `Parser.service`. */
|
|
173
|
+
context: Context.Context<never>;
|
|
174
|
+
/** Mode of the latest failure. Only meaningful after a step returned {@link Fail}. */
|
|
175
|
+
mode: ErrMode;
|
|
176
|
+
/** Details of the latest failure. Only meaningful after a step returned {@link Fail}. */
|
|
177
|
+
failure: Failure;
|
|
178
|
+
/**
|
|
179
|
+
* The offset of a recoverable failure that occurred without consuming
|
|
180
|
+
* input (for example the last attempt of a `repeat`). Its
|
|
181
|
+
* expectations are merged into new failures at the same offset, producing
|
|
182
|
+
* messages like `expected digit or ")"`.
|
|
183
|
+
*/
|
|
184
|
+
hintOffset: number;
|
|
185
|
+
/** The expectations of the hint at {@link hintOffset}. */
|
|
186
|
+
hintExpected: ReadonlyArray<string>;
|
|
187
|
+
/**
|
|
188
|
+
* The furthest recoverable failure seen so far, including failures that
|
|
189
|
+
* were later swallowed by backtracking (for example a trailing separator
|
|
190
|
+
* followed by an invalid element). It is reported instead of the final
|
|
191
|
+
* failure when it lies further into the input. This is the classic PEG
|
|
192
|
+
* "farthest failure" heuristic. `Parser.cut` keeps only the failures
|
|
193
|
+
* recorded inside it when it commits, and `Parser.peek` and `Parser.not`
|
|
194
|
+
* forget the failures of a lookahead that succeeded.
|
|
195
|
+
*/
|
|
196
|
+
deepest: Failure | undefined;
|
|
197
|
+
/** When defined, `Parser.resumeAfter`/`retryAfter` record failures here. */
|
|
198
|
+
recovered: Array<Failure> | undefined;
|
|
199
|
+
/** When defined, `Parser.trace` reports events here. */
|
|
200
|
+
tracer: ((event: TraceEvent) => void) | undefined;
|
|
201
|
+
/** Current tracing depth. */
|
|
202
|
+
depth: number;
|
|
203
|
+
/**
|
|
204
|
+
* The text encoding of a byte input, recorded by `Text` parsers when they
|
|
205
|
+
* fail so that errors can show the input as text.
|
|
206
|
+
*/
|
|
207
|
+
encoding: Encoding<any> | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* The checkpoints of a resumable streaming parse (see
|
|
210
|
+
* `ParserStream.parseAll`); `undefined` otherwise.
|
|
211
|
+
*
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
resume: Map<object, Map<number, unknown>> | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* The tree builder of a `Syntax` parse; `undefined` otherwise.
|
|
217
|
+
*
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
syntax: Builder | undefined;
|
|
221
|
+
constructor(source: I | Source<I>, options?: {
|
|
222
|
+
readonly partial?: boolean | undefined;
|
|
223
|
+
readonly context?: Context.Context<never> | undefined;
|
|
224
|
+
readonly offset?: number | undefined;
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* Prepares the state for another run over the same input, starting at
|
|
228
|
+
* `offset`: afterwards it behaves exactly like
|
|
229
|
+
* `new State(state.input, { ...options, offset })`, without allocating a
|
|
230
|
+
* new state.
|
|
231
|
+
*
|
|
232
|
+
* Every per-run field is reset: the cursor and end, the latest failure,
|
|
233
|
+
* hints and furthest failure, recorded recoveries, the tracer and tracing
|
|
234
|
+
* depth, the recorded encoding and streaming checkpoints. Like the
|
|
235
|
+
* constructor, `partial` defaults to `false` and `context` to the empty
|
|
236
|
+
* context, so pass them again on every reset.
|
|
237
|
+
*
|
|
238
|
+
* Use it to run many small parses over one buffer, for example one per
|
|
239
|
+
* token, with `parser.step`. A state can be reused after any run,
|
|
240
|
+
* including one that failed, returned `Incomplete` or threw.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* import { Ascii, Input } from "@thomasfosterau/effect-parse"
|
|
245
|
+
*
|
|
246
|
+
* const state = new Input.State("12 34")
|
|
247
|
+
* Ascii.decUint.step(state) // 12
|
|
248
|
+
* state.reset(3)
|
|
249
|
+
* Ascii.decUint.step(state) // 34
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* @since 0.2.0
|
|
253
|
+
*/
|
|
254
|
+
reset(offset?: number, options?: {
|
|
255
|
+
readonly partial?: boolean | undefined;
|
|
256
|
+
readonly context?: Context.Context<never> | undefined;
|
|
257
|
+
}): this;
|
|
258
|
+
/**
|
|
259
|
+
* The number of input units (code units, bytes or elements) remaining.
|
|
260
|
+
*/
|
|
261
|
+
remaining(): number;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the cursor is at the end of the input.
|
|
264
|
+
*/
|
|
265
|
+
atEnd(): boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Extracts the slice `[start, end)` of the input.
|
|
268
|
+
*/
|
|
269
|
+
slice(start: number, end: number): Slice<I>;
|
|
270
|
+
/**
|
|
271
|
+
* Records a recoverable failure at the current offset and returns {@link Fail}.
|
|
272
|
+
*/
|
|
273
|
+
backtrack(kind: ErrorKind, expected?: ReadonlyArray<string>, offset?: number): Fail;
|
|
274
|
+
/**
|
|
275
|
+
* Records an unrecoverable failure at the current offset and returns {@link Fail}.
|
|
276
|
+
*/
|
|
277
|
+
cut(kind: ErrorKind, expected?: ReadonlyArray<string>, offset?: number): Fail;
|
|
278
|
+
/**
|
|
279
|
+
* Records an `Incomplete` failure (only meaningful for partial input) and
|
|
280
|
+
* returns {@link Fail}.
|
|
281
|
+
*/
|
|
282
|
+
incomplete(needed: number, expected?: ReadonlyArray<string>): Fail;
|
|
283
|
+
/**
|
|
284
|
+
* Fails because the input ended: `Incomplete` for partial input, otherwise
|
|
285
|
+
* a `Backtrack` failure of the given kind.
|
|
286
|
+
*/
|
|
287
|
+
eoi(kind: ErrorKind, expected: ReadonlyArray<string>, needed: number): Fail;
|
|
288
|
+
/**
|
|
289
|
+
* Records a failure carrying a user supplied cause.
|
|
290
|
+
*/
|
|
291
|
+
failCause(mode: ErrMode, kind: ErrorKind, cause: unknown, offset?: number): Fail;
|
|
292
|
+
/**
|
|
293
|
+
* Records a failure carrying a message.
|
|
294
|
+
*/
|
|
295
|
+
failMessage(mode: ErrMode, kind: ErrorKind, message: string, offset?: number): Fail;
|
|
296
|
+
/**
|
|
297
|
+
* Records the given failure and returns {@link Fail}.
|
|
298
|
+
*/
|
|
299
|
+
failWith(mode: ErrMode, failure: Failure): Fail;
|
|
300
|
+
/**
|
|
301
|
+
* Replaces the details of the current failure (for example to add context),
|
|
302
|
+
* keeping the record of the furthest failure consistent.
|
|
303
|
+
*/
|
|
304
|
+
replaceFailure(failure: Failure): void;
|
|
305
|
+
/**
|
|
306
|
+
* The failure to report to the user: the current failure, or the furthest
|
|
307
|
+
* failure if it lies beyond the current one and the current failure is a
|
|
308
|
+
* plain syntax error (no user cause or message).
|
|
309
|
+
*/
|
|
310
|
+
reportedFailure(): Failure;
|
|
311
|
+
/**
|
|
312
|
+
* Records that, at `offset`, any of `expected` could also have been
|
|
313
|
+
* accepted. Used by parsers that stop without failing, such as `opt`,
|
|
314
|
+
* `repeat` and `Ascii.digit1`.
|
|
315
|
+
*/
|
|
316
|
+
setHint(offset: number, expected: ReadonlyArray<string>): void;
|
|
317
|
+
/** @internal */
|
|
318
|
+
makeFailure(offset: number, kind: ErrorKind, expected: ReadonlyArray<string>): Failure;
|
|
291
319
|
}
|
|
292
320
|
/** @internal */
|
|
293
321
|
export declare const mergeExpected: (a: ReadonlyArray<string>, b: ReadonlyArray<string>) => ReadonlyArray<string>;
|
|
@@ -298,4 +326,5 @@ export declare const mergeExpected: (a: ReadonlyArray<string>, b: ReadonlyArray<
|
|
|
298
326
|
* @internal
|
|
299
327
|
*/
|
|
300
328
|
export declare const mergeFailures: (a: Failure, b: Failure) => Failure;
|
|
329
|
+
//#endregion
|
|
301
330
|
//# sourceMappingURL=Input.d.ts.map
|
package/dist/Input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","
|
|
1
|
+
{"version":3,"file":"Input.d.ts","names":["SyntaxBuilder"],"sources":["../src/Input.ts"],"mappings":";;;;;;;;;;;;;;;;YAgCY,iBAAiB,aAAa;;;;;;;;;;;;;YAc9B,cAAc,kBAAkB;;;;;;;;YAShC,OAAO,KAAK,MAAM,YAAY,cAAc;;;;;;;;;;;;;;;qBAgB3C;GACV,QAAQ,cAAc;GACtB,UAAU,OAAO,QAAQ,OAAO,KAAK;;;;;;;;YAkB5B,MAAM,KAAK,4BAEnB,UAAU,sBAER,UAAU,oBAAoB,KAC5B;;;;;;;YASI,MAAM,KAAK,4BAEnB,UAAU,aACR,aACA,UAAU,oBAAoB,KAC5B,cAAc;;;;;;;;qBAUT;;;;;YAMD,cAAc;;;;;;;;;;;YAYd;;;;;;;qBAQC;;WAGA;;WAEA,MAAM;;WAEN,UAAU;;WAEV,SAAS;;WAET;;WAEA;;WAEA;;WAEA;;;EAdA;;EAEA,MAAM;;EAEN,UAAU;;EAEV,SAAS;;EAET;;EAEA;;EAEA;;EAEA;;;qBAUA;;;;;;;iBAQI;WACN;WACA;WACA;WACA;;WAEA,gBAAgB;;WAEhB;WACA,OAAO;;;;;;;;qBASL,MAAM,UAAU,QAAQ;;WAE1B,OAAO;;EAGR;;EAER;;WAES;;EAET;;EAEA,SAAS,QAAQ;;EAEjB,MAAM;;EAEN,SAAS;;;;;;;EAOT;;EAEA,cAAc;;;;;;;;;;EAUd,SAAS;;EAET,WAAW,MAAM;;EAEjB,UAAU,OAAO;;EAEjB;;;;;EAKA,UAAU;;;;;;;EAOV,QAAQ,YAAY;;;;;;EAMpB,QAAQA;EAGN,YAAA,QAAQ,IAAI,OAAO,IACnB;aACW;aACA,UAAU,QAAQ;aAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCb,MACE,iBACA;aACW;aACA,UAAU,QAAQ;;;;;EAuB/B;;;;EAOA;;;;EAOA,MAAM,eAAe,cAAc,MAAM;;;;EAezC,UAAU,MAAM,WAAW,WAAU,uBAA+B,kBAA4B;;;;EAOhG,IAAI,MAAM,WAAW,WAAU,uBAA+B,kBAA4B;;;;;EAQ1F,WAAW,gBAAgB,WAAU,wBAAgC;;;;;EAWrE,IAAI,MAAM,WAAW,UAAU,uBAAuB,iBAAiB;;;;EAOvE,UAAU,MAAM,SAAS,MAAM,WAAW,gBAAgB,kBAA4B;;;;EAOtF,YAAY,MAAM,SAAS,MAAM,WAAW,iBAAiB,kBAA4B;;;;EAOzF,SAAS,MAAM,SAAS,SAAS,UAAU;;;;;EAa3C,eAAe,SAAS;;;;;;EAUxB,mBAAmB;;;;;;EAuBnB,QAAQ,gBAAgB,UAAU;;EAUlC,YAAY,gBAAgB,MAAM,WAAW,UAAU,wBAAwB;;;qBASpE,gBAAiB,GAAG,uBAAuB,GAAG,0BAAwB;;;;;;;qBAgBtE,gBAAiB,GAAG,SAAS,GAAG,YAAU"}
|