arktype 2.0.0-dev.0 → 2.0.0-dev.10
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/__tests__/array.test.ts +270 -151
- package/__tests__/badDefinitionType.test.ts +10 -3
- package/__tests__/basis.test.ts +6 -2
- package/__tests__/bounds.test.ts +282 -352
- package/__tests__/cast.test.ts +7 -2
- package/__tests__/completions.test.ts +8 -3
- package/__tests__/config.test.ts +95 -167
- package/__tests__/dateLiteral.test.ts +8 -4
- package/__tests__/declared.test.ts +7 -6
- package/__tests__/discrimination.test.ts +1 -1
- package/__tests__/divisor.test.ts +46 -22
- package/__tests__/enclosed.test.ts +39 -25
- package/__tests__/examples.test.ts +56 -56
- package/__tests__/expressions.test.ts +184 -112
- package/__tests__/generic.test.ts +307 -288
- package/__tests__/group.test.ts +67 -54
- package/__tests__/imports.test.ts +62 -49
- package/__tests__/instanceof.test.ts +25 -23
- package/__tests__/intersection.test.ts +52 -48
- package/__tests__/keyTraversal.test.ts +77 -73
- package/__tests__/keyof.test.ts +68 -52
- package/__tests__/keywords.test.ts +164 -138
- package/__tests__/literal.test.ts +60 -21
- package/__tests__/match.bench.ts +31 -0
- package/__tests__/match.test.ts +222 -22
- package/__tests__/narrow.test.ts +52 -54
- package/__tests__/objectLiteral.test.ts +347 -205
- package/__tests__/operator.bench.ts +4 -4
- package/__tests__/pipe.test.ts +501 -0
- package/__tests__/realWorld.test.ts +63 -0
- package/__tests__/regex.test.ts +17 -7
- package/__tests__/scope.bench.ts +1 -1
- package/__tests__/scope.test.ts +257 -23
- package/__tests__/serialization.test.ts +19 -0
- package/__tests__/string.test.ts +11 -7
- package/__tests__/submodule.test.ts +26 -39
- package/__tests__/this.test.ts +83 -57
- package/__tests__/thunk.test.ts +13 -7
- package/__tests__/traverse.test.ts +76 -54
- package/__tests__/tsGenerics.test.ts +12 -12
- package/__tests__/type.test.ts +36 -0
- package/__tests__/typeReference.test.ts +7 -7
- package/__tests__/unenclosed.test.ts +116 -100
- package/__tests__/union.test.ts +171 -104
- package/ark.ts +21 -65
- package/generic.ts +69 -0
- package/main.ts +6 -18
- package/match.ts +195 -93
- package/module.ts +15 -0
- package/out/ark.d.ts +15 -39
- package/out/ark.js +9 -18
- package/out/ark.js.map +1 -1
- package/out/generic.d.ts +21 -0
- package/out/generic.js +24 -0
- package/out/generic.js.map +1 -0
- package/out/main.d.ts +6 -7
- package/out/main.js +4 -3
- package/out/main.js.map +1 -1
- package/out/match.d.ts +57 -34
- package/out/match.js +51 -17
- package/out/match.js.map +1 -1
- package/out/module.d.ts +10 -0
- package/out/module.js +3 -0
- package/out/module.js.map +1 -0
- package/out/parser/definition.d.ts +11 -13
- package/out/parser/definition.js +10 -13
- package/out/parser/definition.js.map +1 -1
- package/out/parser/generic.d.ts +5 -7
- package/out/parser/generic.js +7 -11
- package/out/parser/generic.js.map +1 -1
- package/out/parser/objectLiteral.d.ts +45 -14
- package/out/parser/objectLiteral.js +61 -52
- package/out/parser/objectLiteral.js.map +1 -1
- package/out/parser/semantic/bounds.d.ts +10 -8
- package/out/parser/semantic/bounds.js +0 -1
- package/out/parser/semantic/bounds.js.map +1 -1
- package/out/parser/semantic/divisor.d.ts +5 -7
- package/out/parser/semantic/divisor.js +0 -1
- package/out/parser/semantic/infer.d.ts +24 -0
- package/out/parser/semantic/infer.js +1 -0
- package/out/parser/semantic/infer.js.map +1 -0
- package/out/parser/semantic/utils.d.ts +3 -7
- package/out/parser/semantic/utils.js +0 -1
- package/out/parser/semantic/validate.d.ts +15 -14
- package/out/parser/semantic/validate.js +1 -1
- package/out/parser/semantic/validate.js.map +1 -1
- package/out/parser/string/reduce/dynamic.d.ts +13 -13
- package/out/parser/string/reduce/dynamic.js +31 -26
- package/out/parser/string/reduce/dynamic.js.map +1 -1
- package/out/parser/string/reduce/shared.d.ts +6 -20
- package/out/parser/string/reduce/shared.js +0 -1
- package/out/parser/string/reduce/shared.js.map +1 -1
- package/out/parser/string/reduce/static.d.ts +27 -24
- package/out/parser/string/reduce/static.js +0 -1
- package/out/parser/string/shift/operand/date.d.ts +3 -3
- package/out/parser/string/shift/operand/date.js +4 -7
- package/out/parser/string/shift/operand/date.js.map +1 -1
- package/out/parser/string/shift/operand/enclosed.d.ts +4 -19
- package/out/parser/string/shift/operand/enclosed.js +12 -13
- package/out/parser/string/shift/operand/enclosed.js.map +1 -1
- package/out/parser/string/shift/operand/genericArgs.d.ts +9 -10
- package/out/parser/string/shift/operand/genericArgs.js +6 -10
- package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
- package/out/parser/string/shift/operand/operand.d.ts +3 -4
- package/out/parser/string/shift/operand/operand.js +8 -12
- package/out/parser/string/shift/operand/operand.js.map +1 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts +15 -22
- package/out/parser/string/shift/operand/unenclosed.js +24 -36
- package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
- package/out/parser/string/shift/operator/bounds.d.ts +9 -13
- package/out/parser/string/shift/operator/bounds.js +43 -54
- package/out/parser/string/shift/operator/bounds.js.map +1 -1
- package/out/parser/string/shift/operator/divisor.d.ts +2 -4
- package/out/parser/string/shift/operator/divisor.js +1 -3
- package/out/parser/string/shift/operator/divisor.js.map +1 -1
- package/out/parser/string/shift/operator/operator.d.ts +2 -3
- package/out/parser/string/shift/operator/operator.js +12 -19
- package/out/parser/string/shift/operator/operator.js.map +1 -1
- package/out/parser/string/shift/scanner.d.ts +2 -2
- package/out/parser/string/shift/scanner.js +14 -16
- package/out/parser/string/shift/scanner.js.map +1 -1
- package/out/parser/string/string.d.ts +8 -6
- package/out/parser/string/string.js +1 -3
- package/out/parser/string/string.js.map +1 -1
- package/out/parser/tuple.d.ts +102 -43
- package/out/parser/tuple.js +119 -87
- package/out/parser/tuple.js.map +1 -1
- package/out/scope.d.ts +43 -120
- package/out/scope.js +39 -209
- package/out/scope.js.map +1 -1
- package/out/type.d.ts +43 -64
- package/out/type.js +30 -131
- package/out/type.js.map +1 -1
- package/package.json +7 -3
- package/parser/definition.ts +77 -93
- package/parser/generic.ts +38 -40
- package/parser/objectLiteral.ts +172 -136
- package/parser/semantic/bounds.ts +33 -32
- package/parser/semantic/divisor.ts +8 -10
- package/parser/semantic/infer.ts +141 -0
- package/parser/semantic/utils.ts +12 -23
- package/parser/semantic/validate.ts +81 -73
- package/parser/string/reduce/dynamic.ts +67 -55
- package/parser/string/reduce/shared.ts +1 -3
- package/parser/string/reduce/static.ts +67 -69
- package/parser/string/shift/operand/date.ts +15 -14
- package/parser/string/shift/operand/enclosed.ts +30 -25
- package/parser/string/shift/operand/genericArgs.ts +46 -45
- package/parser/string/shift/operand/operand.ts +32 -38
- package/parser/string/shift/operand/unenclosed.ts +107 -158
- package/parser/string/shift/operator/bounds.ts +118 -112
- package/parser/string/shift/operator/divisor.ts +14 -17
- package/parser/string/shift/operator/operator.ts +35 -46
- package/parser/string/shift/scanner.ts +51 -50
- package/parser/string/string.ts +30 -35
- package/parser/tuple.ts +375 -307
- package/scope.ts +170 -453
- package/type.ts +193 -274
- package/__tests__/astUtils.test.ts +0 -17
- package/__tests__/cyclic.test.ts +0 -144
- package/__tests__/jsdoc.test.ts +0 -64
- package/__tests__/morph.test.ts +0 -409
- package/__tests__/nodeDefinitions.test.ts +0 -190
- package/__tests__/typeMethods.test.ts +0 -69
- package/out/ark.d.ts.map +0 -1
- package/out/arkConfig.d.ts +0 -2
- package/out/arkConfig.d.ts.map +0 -1
- package/out/arkConfig.js +0 -10
- package/out/arkConfig.js.map +0 -1
- package/out/main.d.ts.map +0 -1
- package/out/match.d.ts.map +0 -1
- package/out/parser/definition.d.ts.map +0 -1
- package/out/parser/generic.d.ts.map +0 -1
- package/out/parser/objectLiteral.d.ts.map +0 -1
- package/out/parser/semantic/bounds.d.ts.map +0 -1
- package/out/parser/semantic/divisor.d.ts.map +0 -1
- package/out/parser/semantic/intersections.d.ts +0 -14
- package/out/parser/semantic/intersections.d.ts.map +0 -1
- package/out/parser/semantic/intersections.js +0 -2
- package/out/parser/semantic/intersections.js.map +0 -1
- package/out/parser/semantic/semantic.d.ts +0 -33
- package/out/parser/semantic/semantic.d.ts.map +0 -1
- package/out/parser/semantic/semantic.js +0 -2
- package/out/parser/semantic/semantic.js.map +0 -1
- package/out/parser/semantic/utils.d.ts.map +0 -1
- package/out/parser/semantic/validate.d.ts.map +0 -1
- package/out/parser/shared.d.ts +0 -54
- package/out/parser/shared.d.ts.map +0 -1
- package/out/parser/shared.js +0 -47
- package/out/parser/shared.js.map +0 -1
- package/out/parser/string/reduce/dynamic.d.ts.map +0 -1
- package/out/parser/string/reduce/shared.d.ts.map +0 -1
- package/out/parser/string/reduce/static.d.ts.map +0 -1
- package/out/parser/string/shift/operand/date.d.ts.map +0 -1
- package/out/parser/string/shift/operand/enclosed.d.ts.map +0 -1
- package/out/parser/string/shift/operand/genericArgs.d.ts.map +0 -1
- package/out/parser/string/shift/operand/operand.d.ts.map +0 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts.map +0 -1
- package/out/parser/string/shift/operator/bounds.d.ts.map +0 -1
- package/out/parser/string/shift/operator/divisor.d.ts.map +0 -1
- package/out/parser/string/shift/operator/operator.d.ts.map +0 -1
- package/out/parser/string/shift/scanner.d.ts.map +0 -1
- package/out/parser/string/string.d.ts.map +0 -1
- package/out/parser/tuple.d.ts.map +0 -1
- package/out/scope.d.ts.map +0 -1
- package/out/test.d.ts +0 -2
- package/out/test.d.ts.map +0 -1
- package/out/test.js +0 -7
- package/out/test.js.map +0 -1
- package/out/tsconfig.build.tsbuildinfo +0 -1
- package/out/type.d.ts.map +0 -1
- package/out/util.d.ts +0 -19
- package/out/util.d.ts.map +0 -1
- package/out/util.js +0 -7
- package/out/util.js.map +0 -1
- package/parser/semantic/intersections.ts +0 -46
- package/parser/semantic/semantic.ts +0 -144
- package/parser/shared.ts +0 -152
- package/util.ts +0 -36
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Dict, isKeyOf } from "@arktype/util"
|
|
2
2
|
import type { Comparator } from "../reduce/shared.js"
|
|
3
3
|
|
|
4
4
|
export class Scanner<Lookahead extends string = string> {
|
|
@@ -11,15 +11,15 @@ export class Scanner<Lookahead extends string = string> {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/** Get lookahead and advance scanner by one */
|
|
14
|
-
shift() {
|
|
14
|
+
shift(): Lookahead {
|
|
15
15
|
return (this.chars[this.i++] ?? "") as Lookahead
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
get lookahead() {
|
|
18
|
+
get lookahead(): Lookahead {
|
|
19
19
|
return (this.chars[this.i] ?? "") as Lookahead
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
get length() {
|
|
22
|
+
get length(): number {
|
|
23
23
|
return this.chars.length
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -27,43 +27,41 @@ export class Scanner<Lookahead extends string = string> {
|
|
|
27
27
|
let shifted = ""
|
|
28
28
|
while (this.lookahead) {
|
|
29
29
|
if (condition(this, shifted)) {
|
|
30
|
-
if (shifted[shifted.length - 1] === Scanner.escapeToken)
|
|
30
|
+
if (shifted[shifted.length - 1] === Scanner.escapeToken)
|
|
31
31
|
shifted = shifted.slice(0, -1)
|
|
32
|
-
|
|
33
|
-
break
|
|
34
|
-
}
|
|
32
|
+
else break
|
|
35
33
|
}
|
|
36
34
|
shifted += this.shift()
|
|
37
35
|
}
|
|
38
36
|
return shifted
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
shiftUntilNextTerminator() {
|
|
39
|
+
shiftUntilNextTerminator(): string {
|
|
42
40
|
this.shiftUntilNonWhitespace()
|
|
43
41
|
return this.shiftUntil(Scanner.lookaheadIsTerminator)
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
shiftUntilNonWhitespace() {
|
|
44
|
+
shiftUntilNonWhitespace(): string {
|
|
47
45
|
return this.shiftUntil(Scanner.lookaheadIsNotWhitespace)
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
jumpToIndex(i: number) {
|
|
48
|
+
jumpToIndex(i: number): void {
|
|
51
49
|
this.i = i < 0 ? this.length + i : i
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
get location() {
|
|
52
|
+
get location(): number {
|
|
55
53
|
return this.i
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
get unscanned() {
|
|
56
|
+
get unscanned(): string {
|
|
59
57
|
return this.chars.slice(this.i, this.length).join("")
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
get scanned() {
|
|
60
|
+
get scanned(): string {
|
|
63
61
|
return this.chars.slice(0, this.i).join("")
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
sliceChars(start: number, end?: number) {
|
|
64
|
+
sliceChars(start: number, end?: number): string {
|
|
67
65
|
return this.chars.slice(start, end).join("")
|
|
68
66
|
}
|
|
69
67
|
|
|
@@ -128,7 +126,8 @@ export namespace Scanner {
|
|
|
128
126
|
|
|
129
127
|
export const whiteSpaceTokens = {
|
|
130
128
|
" ": true,
|
|
131
|
-
"\n": true
|
|
129
|
+
"\n": true,
|
|
130
|
+
"\t": true
|
|
132
131
|
} as const
|
|
133
132
|
|
|
134
133
|
export type WhiteSpaceToken = keyof typeof whiteSpaceTokens
|
|
@@ -137,32 +136,32 @@ export namespace Scanner {
|
|
|
137
136
|
lookahead: string,
|
|
138
137
|
unscanned: string
|
|
139
138
|
): lookahead is ">" | "," =>
|
|
140
|
-
lookahead === ">"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
lookahead === ">" ?
|
|
140
|
+
unscanned[0] === "=" ?
|
|
141
|
+
// >== would only occur in an expression like Array<number>==5
|
|
142
|
+
// otherwise, >= would only occur as part of a bound like number>=5
|
|
143
|
+
unscanned[1] === "="
|
|
144
|
+
// if > is the end of a generic instantiation, the next token will be an operator or the end of the string
|
|
145
|
+
: unscanned.trimStart() === "" ||
|
|
146
|
+
isKeyOf(unscanned.trimStart()[0], Scanner.terminatingChars)
|
|
147
|
+
// if the lookahead is a finalizing token but not >, it's unambiguously a finalizer (currently just ",")
|
|
148
|
+
: lookahead === ","
|
|
150
149
|
|
|
151
150
|
export type lookaheadIsFinalizing<
|
|
152
151
|
lookahead extends string,
|
|
153
152
|
unscanned extends string
|
|
154
|
-
> =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
?
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
?
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
? true
|
|
153
|
+
> =
|
|
154
|
+
lookahead extends ">" ?
|
|
155
|
+
unscanned extends `=${infer nextUnscanned}` ?
|
|
156
|
+
nextUnscanned extends `=${string}` ?
|
|
157
|
+
true
|
|
158
|
+
: false
|
|
159
|
+
: Scanner.skipWhitespace<unscanned> extends (
|
|
160
|
+
"" | `${TerminatingChar}${string}`
|
|
161
|
+
) ?
|
|
162
|
+
true
|
|
163
|
+
: false
|
|
164
|
+
: lookahead extends "," ? true
|
|
166
165
|
: false
|
|
167
166
|
|
|
168
167
|
export type shift<
|
|
@@ -174,23 +173,25 @@ export namespace Scanner {
|
|
|
174
173
|
unscanned extends string,
|
|
175
174
|
terminator extends string,
|
|
176
175
|
scanned extends string = ""
|
|
177
|
-
> =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
> =
|
|
177
|
+
unscanned extends shift<infer lookahead, infer nextUnscanned> ?
|
|
178
|
+
lookahead extends terminator ?
|
|
179
|
+
scanned extends `${infer base}${EscapeToken}` ?
|
|
180
|
+
shiftUntil<nextUnscanned, terminator, `${base}${lookahead}`>
|
|
181
|
+
: [scanned, unscanned]
|
|
182
|
+
: shiftUntil<nextUnscanned, terminator, `${scanned}${lookahead}`>
|
|
183
|
+
: [scanned, ""]
|
|
184
184
|
|
|
185
185
|
export type shiftUntilNot<
|
|
186
186
|
unscanned extends string,
|
|
187
187
|
nonTerminator extends string,
|
|
188
188
|
scanned extends string = ""
|
|
189
|
-
> =
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
> =
|
|
190
|
+
unscanned extends shift<infer lookahead, infer nextUnscanned> ?
|
|
191
|
+
lookahead extends nonTerminator ?
|
|
192
|
+
shiftUntilNot<nextUnscanned, nonTerminator, `${scanned}${lookahead}`>
|
|
193
|
+
: [scanned, unscanned]
|
|
194
|
+
: [scanned, ""]
|
|
194
195
|
|
|
195
196
|
export type shiftUntilNextTerminator<unscanned extends string> = shiftUntil<
|
|
196
197
|
unscanned,
|
package/parser/string/string.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RawSchema } from "@arktype/schema"
|
|
2
2
|
import {
|
|
3
|
+
type ErrorMessage,
|
|
3
4
|
throwInternalError,
|
|
4
|
-
throwParseError
|
|
5
|
-
type ErrorMessage
|
|
5
|
+
throwParseError
|
|
6
6
|
} from "@arktype/util"
|
|
7
|
-
import type { inferAstRoot } from "../semantic/
|
|
7
|
+
import type { inferAstRoot } from "../semantic/infer.js"
|
|
8
8
|
import type { DynamicState, DynamicStateWithRoot } from "./reduce/dynamic.js"
|
|
9
9
|
import type { StringifiablePrefixOperator } from "./reduce/shared.js"
|
|
10
10
|
import type { StaticState, state } from "./reduce/static.js"
|
|
11
11
|
import type { parseOperand } from "./shift/operand/operand.js"
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
type parseOperator,
|
|
14
|
+
writeUnexpectedCharacterMessage
|
|
15
15
|
} from "./shift/operator/operator.js"
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Try to parse the definition from right to left using the most common syntax.
|
|
19
19
|
* This can be much more efficient for simple definitions.
|
|
20
20
|
*/
|
|
21
|
-
export type parseString<def extends string, $, args> =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
export type parseString<def extends string, $, args> =
|
|
22
|
+
def extends keyof $ ?
|
|
23
|
+
// def could also be a generic reference here, in which case it will
|
|
24
|
+
// fail semantic validation because it has no args
|
|
25
|
+
def
|
|
26
|
+
: def extends `${infer child}[]` ?
|
|
27
|
+
child extends keyof $ ?
|
|
28
|
+
[child, "[]"]
|
|
29
|
+
: fullStringParse<state.initialize<def>, $, args>
|
|
30
|
+
: fullStringParse<state.initialize<def>, $, args>
|
|
30
31
|
|
|
31
32
|
export type inferString<def extends string, $, args> = inferAstRoot<
|
|
32
33
|
parseString<def, $, args>,
|
|
@@ -40,7 +41,7 @@ export type BaseCompletions<$, args, otherSuggestions extends string = never> =
|
|
|
40
41
|
| StringifiablePrefixOperator
|
|
41
42
|
| otherSuggestions
|
|
42
43
|
|
|
43
|
-
export const fullStringParse = (s: DynamicState):
|
|
44
|
+
export const fullStringParse = (s: DynamicState): RawSchema => {
|
|
44
45
|
s.parseOperand()
|
|
45
46
|
const result = parseUntilFinalizer(s).root
|
|
46
47
|
if (!result) {
|
|
@@ -60,31 +61,25 @@ type fullStringParse<s extends StaticState, $, args> = extractFinalizedResult<
|
|
|
60
61
|
parseUntilFinalizer<s, $, args>
|
|
61
62
|
>
|
|
62
63
|
|
|
63
|
-
export const parseUntilFinalizer = (s: DynamicState) => {
|
|
64
|
-
while (s.finalizer === undefined)
|
|
65
|
-
|
|
66
|
-
}
|
|
64
|
+
export const parseUntilFinalizer = (s: DynamicState): DynamicStateWithRoot => {
|
|
65
|
+
while (s.finalizer === undefined) next(s)
|
|
66
|
+
|
|
67
67
|
return s as DynamicStateWithRoot
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export type parseUntilFinalizer<
|
|
71
|
-
s extends
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
> = s["finalizer"] extends undefined
|
|
75
|
-
? parseUntilFinalizer<next<s, $, args>, $, args>
|
|
76
|
-
: s
|
|
70
|
+
export type parseUntilFinalizer<s extends StaticState, $, args> =
|
|
71
|
+
s["finalizer"] extends undefined ?
|
|
72
|
+
parseUntilFinalizer<next<s, $, args>, $, args>
|
|
73
|
+
: s
|
|
77
74
|
|
|
78
75
|
const next = (s: DynamicState) =>
|
|
79
76
|
s.hasRoot() ? s.parseOperator() : s.parseOperand()
|
|
80
77
|
|
|
81
|
-
type next<s extends StaticState, $, args> =
|
|
82
|
-
? parseOperand<s, $, args>
|
|
83
|
-
:
|
|
78
|
+
type next<s extends StaticState, $, args> =
|
|
79
|
+
s["root"] extends undefined ? parseOperand<s, $, args>
|
|
80
|
+
: parseOperator<s, $, args>
|
|
84
81
|
|
|
85
82
|
export type extractFinalizedResult<s extends StaticState> =
|
|
86
|
-
s["finalizer"] extends ErrorMessage
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
? s["root"]
|
|
90
|
-
: state.error<writeUnexpectedCharacterMessage<`${s["finalizer"]}`>>
|
|
83
|
+
s["finalizer"] extends ErrorMessage ? s["finalizer"]
|
|
84
|
+
: s["finalizer"] extends "" ? s["root"]
|
|
85
|
+
: state.error<writeUnexpectedCharacterMessage<`${s["finalizer"]}`>>
|