@thomasfosterau/effect-parse 0.1.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/internal/node.d.ts
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Nodes refer to their child parsers rather than to child nodes, so a
|
|
6
|
-
* child's own step is always at hand for fallback, and recursion through
|
|
7
|
-
* `Suspend` is just a reference.
|
|
8
|
-
*/
|
|
9
|
-
import type { Encoding } from "../Encoding.js";
|
|
10
|
-
import type { ErrMode, Input, State } from "../Input.js";
|
|
1
|
+
import { ErrMode, Input, State } from "../Input.js";
|
|
2
|
+
import { Encoding } from "../Encoding.js";
|
|
3
|
+
//#region src/internal/node.d.ts
|
|
11
4
|
/** The parts of a parser the compiler needs. */
|
|
12
5
|
export interface ParserLike {
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
readonly step: (state: State<any>) => unknown;
|
|
7
|
+
readonly name: string | undefined;
|
|
15
8
|
}
|
|
16
9
|
type P = ParserLike;
|
|
17
10
|
type Step = (state: State<any>) => unknown;
|
|
18
11
|
/** A repetition range, normalized: `max` may be `Infinity`. */
|
|
19
12
|
interface Bounds {
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
readonly min: number;
|
|
14
|
+
readonly max: number;
|
|
22
15
|
}
|
|
23
16
|
/**
|
|
24
17
|
* For token nodes: `undefined` for the `Token`/`Ascii` parsers (code points
|
|
@@ -27,214 +20,224 @@ interface Bounds {
|
|
|
27
20
|
*/
|
|
28
21
|
type Enc = Encoding<any> | undefined;
|
|
29
22
|
export type Node = {
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
readonly _tag: "Opaque";
|
|
24
|
+
readonly step: Step;
|
|
32
25
|
} | {
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
readonly _tag: "Succeed";
|
|
27
|
+
readonly value: unknown;
|
|
35
28
|
} | {
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
readonly _tag: "Sync";
|
|
30
|
+
readonly evaluate: () => unknown;
|
|
38
31
|
} | {
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
readonly _tag: "Fail";
|
|
33
|
+
readonly mode: ErrMode;
|
|
41
34
|
} | {
|
|
42
|
-
|
|
35
|
+
readonly _tag: "Eof";
|
|
43
36
|
} | {
|
|
44
|
-
|
|
37
|
+
readonly _tag: "Location";
|
|
45
38
|
} | {
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
readonly _tag: "Suspend";
|
|
40
|
+
readonly resolve: () => P;
|
|
48
41
|
} | {
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
readonly _tag: "Any";
|
|
43
|
+
readonly encoding: Enc;
|
|
51
44
|
} | {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
readonly _tag: "Literal";
|
|
46
|
+
readonly literal: Input;
|
|
47
|
+
readonly caseless: boolean;
|
|
48
|
+
readonly encoding: Enc;
|
|
56
49
|
} | {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
readonly _tag: "OneOf";
|
|
51
|
+
readonly set: unknown;
|
|
52
|
+
readonly negate: boolean;
|
|
53
|
+
readonly encoding: Enc;
|
|
61
54
|
} | {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
readonly _tag: "Take";
|
|
56
|
+
readonly count: number;
|
|
57
|
+
readonly encoding: Enc;
|
|
65
58
|
} | ({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
readonly _tag: "TakeWhile";
|
|
60
|
+
readonly set: unknown;
|
|
61
|
+
readonly negate: boolean;
|
|
62
|
+
readonly encoding: Enc;
|
|
70
63
|
} & Bounds) | ({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
readonly _tag: "TakeUntil";
|
|
65
|
+
readonly literal: Input;
|
|
66
|
+
readonly encoding: Enc;
|
|
74
67
|
} & Bounds) | {
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
readonly _tag: "Rest";
|
|
69
|
+
readonly encoding: Enc;
|
|
77
70
|
} | {
|
|
78
|
-
|
|
71
|
+
readonly _tag: "RestLen";
|
|
79
72
|
} | {
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
readonly _tag: "TillLineEnding";
|
|
74
|
+
readonly encoding: Enc;
|
|
82
75
|
} | {
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
readonly _tag: "Identifier";
|
|
77
|
+
readonly encoding: Enc;
|
|
85
78
|
} | {
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
readonly _tag: "Bom";
|
|
80
|
+
readonly encoding: Enc;
|
|
88
81
|
} | {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
readonly _tag: "Escaped";
|
|
83
|
+
readonly normal: P;
|
|
84
|
+
/** The control character, as a code point (or a byte / unit for `Ascii`). */
|
|
85
|
+
readonly control: number;
|
|
86
|
+
readonly escape: P;
|
|
87
|
+
/** `takeEscaped`: return the raw slice instead of the unescaped text. */
|
|
88
|
+
readonly raw: boolean;
|
|
89
|
+
readonly encoding: Enc;
|
|
97
90
|
} | {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
readonly _tag: "Map";
|
|
92
|
+
readonly self: P;
|
|
93
|
+
readonly f: (a: any) => unknown;
|
|
101
94
|
} | {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
readonly _tag: "As";
|
|
96
|
+
readonly self: P;
|
|
97
|
+
readonly value: unknown;
|
|
105
98
|
} | {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
readonly _tag: "Tap";
|
|
100
|
+
readonly self: P;
|
|
101
|
+
readonly f: (a: any) => void;
|
|
109
102
|
} | {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
readonly _tag: "TryMap";
|
|
104
|
+
readonly self: P;
|
|
105
|
+
readonly f: (a: any) => unknown;
|
|
113
106
|
} | {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
readonly _tag: "FilterMap";
|
|
108
|
+
readonly self: P;
|
|
109
|
+
readonly f: (a: any) => unknown;
|
|
117
110
|
} | {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
readonly _tag: "Filter";
|
|
112
|
+
readonly self: P;
|
|
113
|
+
readonly predicate: (a: any) => boolean;
|
|
121
114
|
} | {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
readonly _tag: "FlatMap";
|
|
116
|
+
readonly self: P;
|
|
117
|
+
readonly f: (a: any) => P;
|
|
125
118
|
} | {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
readonly _tag: "Taken";
|
|
120
|
+
readonly self: P;
|
|
121
|
+
readonly encoding: Enc;
|
|
129
122
|
} | {
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
readonly _tag: "WithTaken";
|
|
124
|
+
readonly self: P;
|
|
132
125
|
} | {
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
readonly _tag: "Span";
|
|
127
|
+
readonly self: P;
|
|
135
128
|
} | {
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
readonly _tag: "WithSpan";
|
|
130
|
+
readonly self: P;
|
|
138
131
|
} | {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
readonly _tag: "Mode";
|
|
133
|
+
readonly self: P;
|
|
134
|
+
readonly from: ErrMode;
|
|
135
|
+
readonly to: ErrMode;
|
|
143
136
|
} | {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
readonly _tag: "Context";
|
|
138
|
+
readonly self: P;
|
|
139
|
+
readonly label: string;
|
|
147
140
|
} | {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
141
|
+
readonly _tag: "Expected";
|
|
142
|
+
readonly self: P;
|
|
143
|
+
readonly description: string;
|
|
151
144
|
} | {
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
readonly _tag: "MapError";
|
|
146
|
+
readonly self: P;
|
|
154
147
|
} | {
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
readonly _tag: "OrFail";
|
|
149
|
+
readonly self: P;
|
|
157
150
|
} | {
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
readonly _tag: "Opt";
|
|
152
|
+
readonly self: P;
|
|
160
153
|
} | {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
readonly _tag: "OrElseSucceed";
|
|
155
|
+
readonly self: P;
|
|
156
|
+
readonly value: () => unknown;
|
|
164
157
|
} | {
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
readonly _tag: "Peek";
|
|
159
|
+
readonly self: P;
|
|
167
160
|
} | {
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
readonly _tag: "Not";
|
|
162
|
+
readonly self: P;
|
|
170
163
|
} | {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
readonly _tag: "Seq";
|
|
165
|
+
readonly parsers: ReadonlyArray<P>;
|
|
166
|
+
/** Which outputs are kept: all (a tuple), one index, or a pair of indices. */
|
|
167
|
+
readonly output: "tuple" | number | readonly [number, number];
|
|
175
168
|
} | {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
readonly _tag: "Struct";
|
|
170
|
+
readonly keys: ReadonlyArray<string>;
|
|
171
|
+
readonly parsers: ReadonlyArray<P>;
|
|
179
172
|
} | {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
173
|
+
readonly _tag: "ZipWith";
|
|
174
|
+
readonly self: P;
|
|
175
|
+
readonly that: P;
|
|
176
|
+
readonly f: (a: any, b: any) => unknown;
|
|
184
177
|
} | {
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
readonly _tag: "Alt";
|
|
179
|
+
readonly parsers: ReadonlyArray<P>;
|
|
187
180
|
} | {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
readonly _tag: "Dispatch";
|
|
182
|
+
readonly selector: P;
|
|
183
|
+
/** A record of cases, when `dispatch` was given one. */
|
|
184
|
+
readonly cases: Readonly<Record<PropertyKey, P>> | undefined;
|
|
185
|
+
readonly otherwise: P | undefined;
|
|
186
|
+
readonly choose: (key: any) => P | undefined;
|
|
194
187
|
} | ({
|
|
195
|
-
|
|
196
|
-
|
|
188
|
+
readonly _tag: "Repeat";
|
|
189
|
+
readonly self: P;
|
|
197
190
|
} & Bounds) | ({
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
191
|
+
readonly _tag: "Fold";
|
|
192
|
+
readonly self: P;
|
|
193
|
+
readonly init: () => unknown;
|
|
194
|
+
readonly f: (acc: any, a: any) => unknown;
|
|
195
|
+
/** Stops the repetition once false of the accumulator (after `min` elements). */
|
|
196
|
+
readonly while: ((acc: any) => boolean) | undefined;
|
|
197
|
+
readonly name: string;
|
|
203
198
|
} & Bounds) | ({
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
199
|
+
readonly _tag: "RepeatTill";
|
|
200
|
+
readonly self: P;
|
|
201
|
+
readonly end: P;
|
|
207
202
|
} & Bounds) | ({
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
readonly _tag: "Separated";
|
|
204
|
+
readonly self: P;
|
|
205
|
+
readonly separator: P;
|
|
211
206
|
} & Bounds) | {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
} | {
|
|
218
|
-
|
|
219
|
-
} | {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
} | {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
} | {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
} | {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
207
|
+
readonly _tag: "SeparatedFold";
|
|
208
|
+
readonly self: P;
|
|
209
|
+
readonly separator: P;
|
|
210
|
+
readonly op: (l: any, s: any, r: any) => unknown;
|
|
211
|
+
readonly right: boolean;
|
|
212
|
+
} | {
|
|
213
|
+
readonly _tag: "Service";
|
|
214
|
+
} | {
|
|
215
|
+
readonly _tag: "Provide";
|
|
216
|
+
readonly self: P;
|
|
217
|
+
} | {
|
|
218
|
+
readonly _tag: "ResumeAfter";
|
|
219
|
+
readonly self: P;
|
|
220
|
+
readonly recover: P;
|
|
221
|
+
} | {
|
|
222
|
+
readonly _tag: "RetryAfter";
|
|
223
|
+
readonly self: P;
|
|
224
|
+
readonly recover: P;
|
|
225
|
+
} | {
|
|
226
|
+
readonly _tag: "Trace";
|
|
227
|
+
readonly self: P;
|
|
228
|
+
readonly name: string;
|
|
229
|
+
} |
|
|
230
|
+
/** `Syntax.node`, `Syntax.token` and `Syntax.field`: identities outside `Syntax` parses. */
|
|
231
|
+
{
|
|
232
|
+
readonly _tag: "Syntax";
|
|
233
|
+
readonly self: P;
|
|
234
|
+
/** The node kind, or `undefined` for a field. */
|
|
235
|
+
readonly kind: string | undefined;
|
|
236
|
+
readonly named: boolean;
|
|
234
237
|
};
|
|
235
238
|
export type Tag = Node["_tag"];
|
|
236
239
|
export type NodeOf<T extends Tag> = Extract<Node, {
|
|
237
|
-
|
|
240
|
+
readonly _tag: T;
|
|
238
241
|
}>;
|
|
239
242
|
/** Where a parser's description is stored. */
|
|
240
243
|
export declare const NodeId: unique symbol;
|
|
@@ -242,10 +245,11 @@ export declare const NodeId: unique symbol;
|
|
|
242
245
|
export declare const nodeOf: (p: ParserLike) => Node;
|
|
243
246
|
/** Normalizes a range, as `repeat`, `takeWhile`, ... do. */
|
|
244
247
|
export declare const bounds: (range: number | {
|
|
245
|
-
|
|
246
|
-
|
|
248
|
+
readonly min?: number | undefined;
|
|
249
|
+
readonly max?: number | undefined;
|
|
247
250
|
} | undefined) => Bounds;
|
|
248
251
|
/** The child parsers of a node, in evaluation order. */
|
|
249
252
|
export declare const children: (node: Node) => ReadonlyArray<P>;
|
|
253
|
+
//#endregion
|
|
250
254
|
export {};
|
|
251
255
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","
|
|
1
|
+
{"version":3,"file":"node.d.ts","names":[],"sources":["../../src/internal/node.ts"],"mappings":";;;;iBAaiB;WACN,OAAO,OAAO;WACd;;KAGN,IAAI;KACJ,QAAQ,OAAO;;UAGV;WACC;WACA;;;;;;;KAQN,MAAM;YAEC;WAEG;WAAyB,MAAM;;WAC/B;WAA0B;;WAC1B;WAAuB;;WACvB;WAAuB,MAAM;;WAC7B;;WACA;;WACA;WAA0B,eAAe;;WAEzC;WAAsB,UAAU;;WAChC;WAA0B,SAAS;WAAgB;WAA4B,UAAU;;WACzF;WAAwB;WAAuB;WAA0B,UAAU;;WACnF;WAAuB;WAAwB,UAAU;;WACxD;WAA4B;WAAuB;WAA0B,UAAU;IAAQ;WAC/F;WAA4B,SAAS;WAAgB,UAAU;IAAQ;WACxE;WAAuB,UAAU;;WACjC;;WACA;WAAiC,UAAU;;WAC3C;WAA6B,UAAU;;WACvC;WAAsB,UAAU;;WAEhC;WACA,QAAQ;;WAER;WACA,QAAQ;;WAER;WACA,UAAU;;WAGV;WAAsB,MAAM;WAAY,IAAI;;WAC5C;WAA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SACX;WAA2B;WAAmC;kBAC7D;;qBAOU,WAAY,MAAM,SAAO,cAAc"}
|
package/dist/internal/node.js
CHANGED
|
@@ -1,73 +1,84 @@
|
|
|
1
|
+
import * as Predicate from "effect/Predicate";
|
|
2
|
+
//#region src/internal/node.ts
|
|
3
|
+
/**
|
|
4
|
+
* Descriptions of parsers, recorded next to their steps so that parsers can
|
|
5
|
+
* be compiled (see `docs/DESIGN.md`, "Compiled parsers").
|
|
6
|
+
*
|
|
7
|
+
* Nodes refer to their child parsers rather than to child nodes, so a
|
|
8
|
+
* child's own step is always at hand for fallback, and recursion through
|
|
9
|
+
* `Suspend` is just a reference.
|
|
10
|
+
*/
|
|
1
11
|
/** Where a parser's description is stored. */
|
|
2
|
-
|
|
12
|
+
const NodeId = /*#__PURE__*/ Symbol.for("effect-parse/Parser/node");
|
|
3
13
|
/** The description of a parser: `Opaque` when it has none. */
|
|
4
|
-
|
|
14
|
+
const nodeOf = (p) => p[NodeId] ?? {
|
|
15
|
+
_tag: "Opaque",
|
|
16
|
+
step: p.step
|
|
17
|
+
};
|
|
5
18
|
/** Normalizes a range, as `repeat`, `takeWhile`, ... do. */
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
const bounds = (range) => {
|
|
20
|
+
if (range === void 0) return {
|
|
21
|
+
min: 0,
|
|
22
|
+
max: Infinity
|
|
23
|
+
};
|
|
24
|
+
if (Predicate.isNumber(range)) return {
|
|
25
|
+
min: range,
|
|
26
|
+
max: range
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
min: range.min ?? 0,
|
|
30
|
+
max: range.max ?? Infinity
|
|
31
|
+
};
|
|
12
32
|
};
|
|
13
33
|
/** The child parsers of a node, in evaluation order. */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return out;
|
|
61
|
-
}
|
|
62
|
-
case "RepeatTill":
|
|
63
|
-
return [node.self, node.end];
|
|
64
|
-
case "Separated":
|
|
65
|
-
case "SeparatedFold":
|
|
66
|
-
return [node.self, node.separator];
|
|
67
|
-
case "Suspend":
|
|
68
|
-
return [node.resolve()];
|
|
69
|
-
default:
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
34
|
+
const children = (node) => {
|
|
35
|
+
switch (node._tag) {
|
|
36
|
+
case "Escaped": return [node.normal, node.escape];
|
|
37
|
+
case "Map":
|
|
38
|
+
case "As":
|
|
39
|
+
case "Tap":
|
|
40
|
+
case "TryMap":
|
|
41
|
+
case "FilterMap":
|
|
42
|
+
case "Filter":
|
|
43
|
+
case "FlatMap":
|
|
44
|
+
case "Taken":
|
|
45
|
+
case "WithTaken":
|
|
46
|
+
case "Span":
|
|
47
|
+
case "WithSpan":
|
|
48
|
+
case "Mode":
|
|
49
|
+
case "Context":
|
|
50
|
+
case "Expected":
|
|
51
|
+
case "MapError":
|
|
52
|
+
case "OrFail":
|
|
53
|
+
case "Opt":
|
|
54
|
+
case "OrElseSucceed":
|
|
55
|
+
case "Peek":
|
|
56
|
+
case "Not":
|
|
57
|
+
case "Repeat":
|
|
58
|
+
case "Fold":
|
|
59
|
+
case "Provide":
|
|
60
|
+
case "Trace":
|
|
61
|
+
case "Syntax": return [node.self];
|
|
62
|
+
case "ResumeAfter":
|
|
63
|
+
case "RetryAfter": return [node.self, node.recover];
|
|
64
|
+
case "Seq":
|
|
65
|
+
case "Struct":
|
|
66
|
+
case "Alt": return node.parsers;
|
|
67
|
+
case "ZipWith": return [node.self, node.that];
|
|
68
|
+
case "Dispatch": {
|
|
69
|
+
const out = [node.selector];
|
|
70
|
+
if (node.cases !== void 0) for (const key of Reflect.ownKeys(node.cases)) out.push(node.cases[key]);
|
|
71
|
+
if (node.otherwise !== void 0) out.push(node.otherwise);
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
case "RepeatTill": return [node.self, node.end];
|
|
75
|
+
case "Separated":
|
|
76
|
+
case "SeparatedFold": return [node.self, node.separator];
|
|
77
|
+
case "Suspend": return [node.resolve()];
|
|
78
|
+
default: return [];
|
|
79
|
+
}
|
|
72
80
|
};
|
|
81
|
+
//#endregion
|
|
82
|
+
export { NodeId, bounds, children, nodeOf };
|
|
83
|
+
|
|
73
84
|
//# sourceMappingURL=node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/internal/node.ts"],"names":[],"mappings":"AAwIA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;AAE3E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAa,EAAQ,EAAE,CAAE,CAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;AAErG,4DAA4D;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAoG,EAAU,EAAE;IACrI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EA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KAAK,QAAQ,CAAC;QACd,KAAK,KAAK;YACR,OAAO,IAAI,CAAC,OAAO,CAAA;QACrB,KAAK,SAAS;YACZ,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/B,KAAK,UAAU,EAAE,CAAC;YAChB,MAAM,GAAG,GAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACrC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC7B,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;oBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAU,CAAE,CAAC,CAAA;YAClF,CAAC;YACD,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;gBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC1D,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,KAAK,YAAY;YACf,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;QAC9B,KAAK,WAAW,CAAC;QACjB,KAAK,eAAe;YAClB,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QACpC,KAAK,SAAS;YACZ,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QACzB;YACE,OAAO,EAAE,CAAA;IACb,CAAC;AACH,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../../src/internal/node.ts"],"sourcesContent":["/**\n * Descriptions of parsers, recorded next to their steps so that parsers can\n * be compiled (see `docs/DESIGN.md`, \"Compiled parsers\").\n *\n * Nodes refer to their child parsers rather than to child nodes, so a\n * child's own step is always at hand for fallback, and recursion through\n * `Suspend` is just a reference.\n */\nimport * as Predicate from \"effect/Predicate\"\nimport type { Encoding } from \"../Encoding.js\"\nimport type { ErrMode, Input, State } from \"../Input.js\"\n\n/** The parts of a parser the compiler needs. */\nexport interface ParserLike {\n readonly step: (state: State<any>) => unknown\n readonly name: string | undefined\n}\n\ntype P = ParserLike\ntype Step = (state: State<any>) => unknown\n\n/** A repetition range, normalized: `max` may be `Infinity`. */\ninterface Bounds {\n readonly min: number\n readonly max: number\n}\n\n/**\n * For token nodes: `undefined` for the `Token`/`Ascii` parsers (code points\n * of strings with lenient surrogates, bytes, or array elements), or the\n * encoding of a `Text` parser.\n */\ntype Enc = Encoding<any> | undefined\n\nexport type Node =\n // Constants\n | { readonly _tag: \"Opaque\"; readonly step: Step }\n | { readonly _tag: \"Succeed\"; readonly value: unknown }\n | { readonly _tag: \"Sync\"; readonly evaluate: () => unknown }\n | { readonly _tag: \"Fail\"; readonly mode: ErrMode }\n | { readonly _tag: \"Eof\" }\n | { readonly _tag: \"Location\" }\n | { readonly _tag: \"Suspend\"; readonly resolve: () => P }\n // Tokens\n | { readonly _tag: \"Any\"; readonly encoding: Enc }\n | { readonly _tag: \"Literal\"; readonly literal: Input; readonly caseless: boolean; readonly encoding: Enc }\n | { readonly _tag: \"OneOf\"; readonly set: unknown; readonly negate: boolean; readonly encoding: Enc }\n | { readonly _tag: \"Take\"; readonly count: number; readonly encoding: Enc }\n | ({ readonly _tag: \"TakeWhile\"; readonly set: unknown; readonly negate: boolean; readonly encoding: Enc } & Bounds)\n | ({ readonly _tag: \"TakeUntil\"; readonly literal: Input; readonly encoding: Enc } & Bounds)\n | { readonly _tag: \"Rest\"; readonly encoding: Enc }\n | { readonly _tag: \"RestLen\" }\n | { readonly _tag: \"TillLineEnding\"; readonly encoding: Enc }\n | { readonly _tag: \"Identifier\"; readonly encoding: Enc }\n | { readonly _tag: \"Bom\"; readonly encoding: Enc }\n | {\n readonly _tag: \"Escaped\"\n readonly normal: P\n /** The control character, as a code point (or a byte / unit for `Ascii`). */\n readonly control: number\n readonly escape: P\n /** `takeEscaped`: return the raw slice instead of the unescaped text. */\n readonly raw: boolean\n readonly encoding: Enc\n }\n // Mapping\n | { readonly _tag: \"Map\"; readonly self: P; readonly f: (a: any) => unknown }\n | { readonly _tag: \"As\"; readonly self: P; readonly value: unknown }\n | { readonly _tag: \"Tap\"; readonly self: P; readonly f: (a: any) => void }\n | { readonly _tag: \"TryMap\"; readonly self: P; readonly f: (a: any) => unknown }\n | { readonly _tag: \"FilterMap\"; readonly self: P; readonly f: (a: any) => unknown }\n | { readonly _tag: \"Filter\"; readonly self: P; readonly predicate: (a: any) => boolean }\n | { readonly _tag: \"FlatMap\"; readonly self: P; readonly f: (a: any) => P }\n // Consumed input\n | { readonly _tag: \"Taken\"; readonly self: P; readonly encoding: Enc }\n | { readonly _tag: \"WithTaken\"; readonly self: P }\n | { readonly _tag: \"Span\"; readonly self: P }\n | { readonly _tag: \"WithSpan\"; readonly self: P }\n // Errors\n | { readonly _tag: \"Mode\"; readonly self: P; readonly from: ErrMode; readonly to: ErrMode }\n | { readonly _tag: \"Context\"; readonly self: P; readonly label: string }\n | { readonly _tag: \"Expected\"; readonly self: P; readonly description: string }\n | { readonly _tag: \"MapError\"; readonly self: P }\n | { readonly _tag: \"OrFail\"; readonly self: P }\n // Control\n | { readonly _tag: \"Opt\"; readonly self: P }\n | { readonly _tag: \"OrElseSucceed\"; readonly self: P; readonly value: () => unknown }\n | { readonly _tag: \"Peek\"; readonly self: P }\n | { readonly _tag: \"Not\"; readonly self: P }\n // Sequencing\n | {\n readonly _tag: \"Seq\"\n readonly parsers: ReadonlyArray<P>\n /** Which outputs are kept: all (a tuple), one index, or a pair of indices. */\n readonly output: \"tuple\" | number | readonly [number, number]\n }\n | { readonly _tag: \"Struct\"; readonly keys: ReadonlyArray<string>; readonly parsers: ReadonlyArray<P> }\n | { readonly _tag: \"ZipWith\"; readonly self: P; readonly that: P; readonly f: (a: any, b: any) => unknown }\n // Choice\n | { readonly _tag: \"Alt\"; readonly parsers: ReadonlyArray<P> }\n | {\n readonly _tag: \"Dispatch\"\n readonly selector: P\n /** A record of cases, when `dispatch` was given one. */\n readonly cases: Readonly<Record<PropertyKey, P>> | undefined\n readonly otherwise: P | undefined\n readonly choose: (key: any) => P | undefined\n }\n // Repetition\n | ({ readonly _tag: \"Repeat\"; readonly self: P } & Bounds)\n | ({\n readonly _tag: \"Fold\"\n readonly self: P\n readonly init: () => unknown\n readonly f: (acc: any, a: any) => unknown\n /** Stops the repetition once false of the accumulator (after `min` elements). */\n readonly while: ((acc: any) => boolean) | undefined\n readonly name: string\n } & Bounds)\n | ({ readonly _tag: \"RepeatTill\"; readonly self: P; readonly end: P } & Bounds)\n | ({ readonly _tag: \"Separated\"; readonly self: P; readonly separator: P } & Bounds)\n | {\n readonly _tag: \"SeparatedFold\"\n readonly self: P\n readonly separator: P\n readonly op: (l: any, s: any, r: any) => unknown\n readonly right: boolean\n }\n // Services, recovery, debugging\n | { readonly _tag: \"Service\" }\n | { readonly _tag: \"Provide\"; readonly self: P }\n | { readonly _tag: \"ResumeAfter\"; readonly self: P; readonly recover: P }\n | { readonly _tag: \"RetryAfter\"; readonly self: P; readonly recover: P }\n | { readonly _tag: \"Trace\"; readonly self: P; readonly name: string }\n /** `Syntax.node`, `Syntax.token` and `Syntax.field`: identities outside `Syntax` parses. */\n | {\n readonly _tag: \"Syntax\"\n readonly self: P\n /** The node kind, or `undefined` for a field. */\n readonly kind: string | undefined\n readonly named: boolean\n }\n\nexport type Tag = Node[\"_tag\"]\n\nexport type NodeOf<T extends Tag> = Extract<Node, { readonly _tag: T }>\n\n/** Where a parser's description is stored. */\nexport const NodeId: unique symbol = /*#__PURE__*/ Symbol.for(\"effect-parse/Parser/node\")\n\n/** The description of a parser: `Opaque` when it has none. */\nexport const nodeOf = (p: ParserLike): Node => (p as any)[NodeId] ?? { _tag: \"Opaque\", step: p.step }\n\n/** Normalizes a range, as `repeat`, `takeWhile`, ... do. */\nexport const bounds = (\n range: number | { readonly min?: number | undefined; readonly max?: number | undefined } | undefined\n): Bounds => {\n if (range === undefined) return { min: 0, max: Infinity }\n if (Predicate.isNumber(range)) return { min: range, max: range }\n return { min: range.min ?? 0, max: range.max ?? Infinity }\n}\n\n/** The child parsers of a node, in evaluation order. */\nexport const children = (node: Node): ReadonlyArray<P> => {\n switch (node._tag) {\n case \"Escaped\":\n return [node.normal, node.escape]\n case \"Map\":\n case \"As\":\n case \"Tap\":\n case \"TryMap\":\n case \"FilterMap\":\n case \"Filter\":\n case \"FlatMap\":\n case \"Taken\":\n case \"WithTaken\":\n case \"Span\":\n case \"WithSpan\":\n case \"Mode\":\n case \"Context\":\n case \"Expected\":\n case \"MapError\":\n case \"OrFail\":\n case \"Opt\":\n case \"OrElseSucceed\":\n case \"Peek\":\n case \"Not\":\n case \"Repeat\":\n case \"Fold\":\n case \"Provide\":\n case \"Trace\":\n case \"Syntax\":\n return [node.self]\n case \"ResumeAfter\":\n case \"RetryAfter\":\n return [node.self, node.recover]\n case \"Seq\":\n case \"Struct\":\n case \"Alt\":\n return node.parsers\n case \"ZipWith\":\n return [node.self, node.that]\n case \"Dispatch\": {\n const out: Array<P> = [node.selector]\n if (node.cases !== undefined) {\n for (const key of Reflect.ownKeys(node.cases)) out.push(node.cases[key as any])\n }\n if (node.otherwise !== undefined) out.push(node.otherwise)\n return out\n }\n case \"RepeatTill\":\n return [node.self, node.end]\n case \"Separated\":\n case \"SeparatedFold\":\n return [node.self, node.separator]\n case \"Suspend\":\n return [node.resolve()]\n default:\n return []\n }\n}\n"],"mappings":";;;;;;;;;;;AAoJA,MAAa,SAAsC,qBAAO,IAAI,0BAA0B;;AAGxF,MAAa,UAAU,MAAyB,EAAU,WAAW;CAAE,MAAM;CAAU,MAAM,EAAE;AAAK;;AAGpG,MAAa,UACX,UACW;CACX,IAAI,UAAU,KAAA,GAAW,OAAO;EAAE,KAAK;EAAG,KAAK;CAAS;CACxD,IAAI,UAAU,SAAS,KAAK,GAAG,OAAO;EAAE,KAAK;EAAO,KAAK;CAAM;CAC/D,OAAO;EAAE,KAAK,MAAM,OAA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