@optique/core 1.0.0-dev.1903 → 1.0.0-dev.1970
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/dist/annotation-state.cjs +66 -31
- package/dist/annotation-state.d.cts +24 -0
- package/dist/annotation-state.d.ts +24 -0
- package/dist/annotation-state.js +65 -31
- package/dist/annotations.cjs +2 -267
- package/dist/annotations.d.cts +2 -152
- package/dist/annotations.d.ts +2 -152
- package/dist/annotations.js +2 -256
- package/dist/completion.d.cts +1 -1
- package/dist/completion.d.ts +1 -1
- package/dist/constructs.cjs +206 -238
- package/dist/constructs.d.cts +1 -1
- package/dist/constructs.d.ts +1 -1
- package/dist/constructs.js +96 -128
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/dependency-metadata.cjs +1 -1
- package/dist/dependency-metadata.d.cts +1 -1
- package/dist/dependency-metadata.d.ts +1 -1
- package/dist/dependency-metadata.js +1 -1
- package/dist/dependency-runtime.cjs +2 -2
- package/dist/dependency-runtime.js +2 -2
- package/dist/dependency.cjs +7 -1111
- package/dist/dependency.d.cts +2 -838
- package/dist/dependency.d.ts +2 -838
- package/dist/dependency.js +2 -1078
- package/dist/execution-context.cjs +56 -0
- package/dist/execution-context.js +53 -0
- package/dist/extension.cjs +87 -0
- package/dist/extension.d.cts +97 -0
- package/dist/extension.d.ts +97 -0
- package/dist/extension.js +76 -0
- package/dist/facade.cjs +19 -19
- package/dist/facade.d.cts +1 -1
- package/dist/facade.d.ts +1 -1
- package/dist/facade.js +19 -19
- package/dist/index.cjs +4 -41
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/internal/annotations.cjs +316 -0
- package/dist/internal/annotations.d.cts +140 -0
- package/dist/internal/annotations.d.ts +140 -0
- package/dist/internal/annotations.js +306 -0
- package/dist/internal/dependency.cjs +984 -0
- package/dist/internal/dependency.d.cts +539 -0
- package/dist/internal/dependency.d.ts +539 -0
- package/dist/internal/dependency.js +964 -0
- package/dist/{mode-dispatch.cjs → internal/mode-dispatch.cjs} +1 -3
- package/dist/{mode-dispatch.d.cts → internal/mode-dispatch.d.cts} +3 -7
- package/dist/{mode-dispatch.d.ts → internal/mode-dispatch.d.ts} +3 -7
- package/dist/{mode-dispatch.js → internal/mode-dispatch.js} +1 -3
- package/dist/internal/parser.cjs +728 -0
- package/dist/internal/parser.d.cts +947 -0
- package/dist/internal/parser.d.ts +947 -0
- package/dist/internal/parser.js +711 -0
- package/dist/modifiers.cjs +67 -95
- package/dist/modifiers.d.cts +1 -1
- package/dist/modifiers.d.ts +1 -1
- package/dist/modifiers.js +51 -79
- package/dist/parser.cjs +11 -743
- package/dist/parser.d.cts +3 -991
- package/dist/parser.d.ts +3 -991
- package/dist/parser.js +2 -704
- package/dist/phase2-seed.cjs +4 -4
- package/dist/phase2-seed.js +4 -4
- package/dist/primitives.cjs +39 -74
- package/dist/primitives.d.cts +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/primitives.js +26 -61
- package/dist/program.d.cts +1 -1
- package/dist/program.d.ts +1 -1
- package/dist/valueparser.cjs +23 -23
- package/dist/valueparser.d.cts +3 -3
- package/dist/valueparser.d.ts +3 -3
- package/dist/valueparser.js +23 -23
- package/package.json +9 -9
package/dist/constructs.cjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
const require_annotations = require('./annotations.cjs');
|
|
1
|
+
const require_annotations = require('./internal/annotations.cjs');
|
|
2
2
|
const require_message = require('./message.cjs');
|
|
3
3
|
const require_validate = require('./validate.cjs');
|
|
4
4
|
const require_usage = require('./usage.cjs');
|
|
5
5
|
const require_doc = require('./doc.cjs');
|
|
6
|
-
const require_mode_dispatch = require('./mode-dispatch.cjs');
|
|
7
|
-
const require_dependency = require('./dependency.cjs');
|
|
6
|
+
const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
7
|
+
const require_dependency = require('./internal/dependency.cjs');
|
|
8
8
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
9
|
+
const require_parser = require('./internal/parser.cjs');
|
|
10
|
+
const require_annotation_state = require('./annotation-state.cjs');
|
|
11
|
+
const require_execution_context = require('./execution-context.cjs');
|
|
9
12
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
10
13
|
const require_suggestion = require('./suggestion.cjs');
|
|
11
14
|
const require_usage_internals = require('./usage-internals.cjs');
|
|
12
|
-
const require_parser = require('./parser.cjs');
|
|
13
|
-
const require_annotation_state = require('./annotation-state.cjs');
|
|
14
15
|
|
|
15
16
|
//#region src/constructs.ts
|
|
16
17
|
/**
|
|
@@ -21,13 +22,6 @@ const EMPTY_LEADING_NAMES = /* @__PURE__ */ new Set();
|
|
|
21
22
|
function isNonCliBoundSourceState(state, parser) {
|
|
22
23
|
return parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object" && Object.hasOwn(state, "hasCliValue") && state.hasCliValue === false;
|
|
23
24
|
}
|
|
24
|
-
function withChildExecPath(exec, segment) {
|
|
25
|
-
if (exec == null) return void 0;
|
|
26
|
-
return {
|
|
27
|
-
...exec,
|
|
28
|
-
path: [...exec.path ?? [], segment]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
25
|
function withDependencyRuntimeExec(usage, exec, runtime) {
|
|
32
26
|
if (exec == null) return {
|
|
33
27
|
usage,
|
|
@@ -43,35 +37,9 @@ function withDependencyRuntimeExec(usage, exec, runtime) {
|
|
|
43
37
|
dependencyRegistry: runtime.registry
|
|
44
38
|
};
|
|
45
39
|
}
|
|
46
|
-
function
|
|
47
|
-
if (parent == null) return child;
|
|
48
|
-
if (child == null) return parent;
|
|
49
|
-
return {
|
|
50
|
-
...parent,
|
|
51
|
-
trace: child.trace ?? parent.trace,
|
|
52
|
-
dependencyRuntime: child.dependencyRuntime ?? parent.dependencyRuntime,
|
|
53
|
-
dependencyRegistry: child.dependencyRegistry ?? parent.dependencyRegistry,
|
|
54
|
-
commandPath: child.commandPath ?? parent.commandPath,
|
|
55
|
-
preCompletedByParser: child.preCompletedByParser ?? parent.preCompletedByParser,
|
|
56
|
-
excludedSourceFields: child.excludedSourceFields ?? parent.excludedSourceFields
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function withChildContext(context, segment, state, parser, usage) {
|
|
60
|
-
const exec = withChildExecPath(context.exec, segment);
|
|
61
|
-
const dependencyRegistry = context.dependencyRegistry ?? exec?.dependencyRegistry;
|
|
40
|
+
function withChildContext$1(context, segment, state, parser, usage) {
|
|
62
41
|
const childState = parser == null ? state : require_annotation_state.getWrappedChildParseState(context.state, state, parser);
|
|
63
|
-
return
|
|
64
|
-
...context,
|
|
65
|
-
state: childState,
|
|
66
|
-
...usage != null ? { usage } : {},
|
|
67
|
-
...exec != null ? {
|
|
68
|
-
exec: dependencyRegistry === exec.dependencyRegistry ? exec : {
|
|
69
|
-
...exec,
|
|
70
|
-
dependencyRegistry
|
|
71
|
-
},
|
|
72
|
-
dependencyRegistry
|
|
73
|
-
} : {}
|
|
74
|
-
};
|
|
42
|
+
return require_execution_context.withChildContext(context, segment, childState, usage);
|
|
75
43
|
}
|
|
76
44
|
function isUnmatchedDependencyState(state, parser) {
|
|
77
45
|
if (state === void 0) return true;
|
|
@@ -451,7 +419,7 @@ function assertParsers(parsers, callerName) {
|
|
|
451
419
|
for (let i = 0; i < parsers.length; i++) {
|
|
452
420
|
const p = parsers[i];
|
|
453
421
|
const r = p;
|
|
454
|
-
if (p == null || typeof p !== "object" && typeof p !== "function" || !(r
|
|
422
|
+
if (p == null || typeof p !== "object" && typeof p !== "function" || !(r.mode === "sync" || r.mode === "async") || !Array.isArray(r.usage) || typeof r.priority !== "number" || Number.isNaN(r.priority) || !("initialState" in p) || typeof r.parse !== "function" || typeof r.complete !== "function" || typeof r.suggest !== "function" || typeof r.getDocFragments !== "function") throw new TypeError(`${callerName} argument at index ${i} is not a valid Parser.`);
|
|
455
423
|
}
|
|
456
424
|
}
|
|
457
425
|
/**
|
|
@@ -560,7 +528,7 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
560
528
|
if (candidate != null) {
|
|
561
529
|
const p = syncParsers[candidate.index];
|
|
562
530
|
const annotatedState = require_annotation_state.getWrappedChildState(state, candidate.parseResult.next.state, p);
|
|
563
|
-
return p.complete(annotatedState, withChildExecPath(exec, candidate.index));
|
|
531
|
+
return p.complete(annotatedState, require_execution_context.withChildExecPath(exec, candidate.index));
|
|
564
532
|
}
|
|
565
533
|
return {
|
|
566
534
|
success: false,
|
|
@@ -568,10 +536,10 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
568
536
|
};
|
|
569
537
|
}, async () => {
|
|
570
538
|
const candidate = await findExclusiveZeroInputCandidateAsync(parsers, state, exec);
|
|
571
|
-
if (candidate != null && (parsers[candidate.index]
|
|
539
|
+
if (candidate != null && (parsers[candidate.index].mode === "sync" || exec?.phase !== "parse" && exec?.phase !== "suggest")) {
|
|
572
540
|
const p = parsers[candidate.index];
|
|
573
541
|
const annotatedState = require_annotation_state.getWrappedChildState(state, candidate.parseResult.next.state, p);
|
|
574
|
-
return await p.complete(annotatedState, withChildExecPath(exec, candidate.index));
|
|
542
|
+
return await p.complete(annotatedState, require_execution_context.withChildExecPath(exec, candidate.index));
|
|
575
543
|
}
|
|
576
544
|
return {
|
|
577
545
|
success: false,
|
|
@@ -583,8 +551,8 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
583
551
|
success: false,
|
|
584
552
|
error: result.error
|
|
585
553
|
};
|
|
586
|
-
return require_mode_dispatch.dispatchByMode(mode, () => syncParsers[i].complete(result.next.state, withChildExecPath(exec, i)), async () => {
|
|
587
|
-
const completeResult = await parsers[i].complete(result.next.state, withChildExecPath(exec, i));
|
|
554
|
+
return require_mode_dispatch.dispatchByMode(mode, () => syncParsers[i].complete(result.next.state, require_execution_context.withChildExecPath(exec, i)), async () => {
|
|
555
|
+
const completeResult = await parsers[i].complete(result.next.state, require_execution_context.withChildExecPath(exec, i));
|
|
588
556
|
return completeResult;
|
|
589
557
|
});
|
|
590
558
|
};
|
|
@@ -601,14 +569,14 @@ function createExclusiveSuggest(parsers, mode) {
|
|
|
601
569
|
const activeState = normalizeExclusiveState(context.state);
|
|
602
570
|
if (activeState == null || activeState[1].success && activeState[1].consumed.length === 0) for (let i = 0; i < syncParsers.length; i++) {
|
|
603
571
|
const parser = syncParsers[i];
|
|
604
|
-
const parserSuggestions = parser.suggest(withChildContext(context, i, parser.initialState, parser), prefix);
|
|
572
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, i, parser.initialState, parser), prefix);
|
|
605
573
|
suggestions.push(...parserSuggestions);
|
|
606
574
|
}
|
|
607
575
|
else {
|
|
608
576
|
const [index, parserResult] = activeState;
|
|
609
577
|
if (parserResult.success) {
|
|
610
578
|
const parser = syncParsers[index];
|
|
611
|
-
const parserSuggestions = parser.suggest(withChildContext(context, index, parserResult.next.state, parser), prefix);
|
|
579
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, index, parserResult.next.state, parser), prefix);
|
|
612
580
|
suggestions.push(...parserSuggestions);
|
|
613
581
|
}
|
|
614
582
|
}
|
|
@@ -618,16 +586,16 @@ function createExclusiveSuggest(parsers, mode) {
|
|
|
618
586
|
const activeState = normalizeExclusiveState(context.state);
|
|
619
587
|
if (activeState == null || activeState[1].success && activeState[1].consumed.length === 0) for (let i = 0; i < parsers.length; i++) {
|
|
620
588
|
const parser = parsers[i];
|
|
621
|
-
const parserSuggestions = parser.suggest(withChildContext(context, i, parser.initialState, parser), prefix);
|
|
622
|
-
if (parser
|
|
589
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, i, parser.initialState, parser), prefix);
|
|
590
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
623
591
|
else suggestions.push(...parserSuggestions);
|
|
624
592
|
}
|
|
625
593
|
else {
|
|
626
594
|
const [index, parserResult] = activeState;
|
|
627
595
|
if (parserResult.success) {
|
|
628
596
|
const parser = parsers[index];
|
|
629
|
-
const parserSuggestions = parser.suggest(withChildContext(context, index, parserResult.next.state, parser), prefix);
|
|
630
|
-
if (parser
|
|
597
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, index, parserResult.next.state, parser), prefix);
|
|
598
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
631
599
|
else suggestions.push(...parserSuggestions);
|
|
632
600
|
}
|
|
633
601
|
}
|
|
@@ -710,15 +678,15 @@ function extractExclusivePhase2Seed(parsers, state, exec, mode) {
|
|
|
710
678
|
if (activeState == null) return require_mode_dispatch.dispatchByMode(mode, () => {
|
|
711
679
|
const candidate = findExclusiveZeroInputCandidateSync(parsers, state, exec);
|
|
712
680
|
if (candidate == null) return null;
|
|
713
|
-
return extractOrCompletePhase2SeedSync(parsers[candidate.index], candidate.parseResult.next.state, withChildExecPath(exec, candidate.index));
|
|
681
|
+
return extractOrCompletePhase2SeedSync(parsers[candidate.index], candidate.parseResult.next.state, require_execution_context.withChildExecPath(exec, candidate.index));
|
|
714
682
|
}, async () => {
|
|
715
683
|
const candidate = await findExclusiveZeroInputCandidateAsync(parsers, state, exec);
|
|
716
684
|
if (candidate == null) return null;
|
|
717
|
-
return await extractOrCompletePhase2SeedAsync(parsers[candidate.index], candidate.parseResult.next.state, withChildExecPath(exec, candidate.index));
|
|
685
|
+
return await extractOrCompletePhase2SeedAsync(parsers[candidate.index], candidate.parseResult.next.state, require_execution_context.withChildExecPath(exec, candidate.index));
|
|
718
686
|
});
|
|
719
687
|
if (!activeState[1].success) return require_mode_dispatch.dispatchByMode(mode, () => null, () => Promise.resolve(null));
|
|
720
688
|
const [index, parserResult] = activeState;
|
|
721
|
-
return require_phase2_seed.completeOrExtractPhase2Seed(parsers[index], parserResult.next.state, withChildExecPath(exec, index));
|
|
689
|
+
return require_phase2_seed.completeOrExtractPhase2Seed(parsers[index], parserResult.next.state, require_execution_context.withChildExecPath(exec, index));
|
|
722
690
|
}
|
|
723
691
|
/**
|
|
724
692
|
* Gets the no-match error, either from custom options or default.
|
|
@@ -765,7 +733,7 @@ function or(...args) {
|
|
|
765
733
|
if (parsers.length < 1) throw new TypeError("or() requires at least one parser argument.");
|
|
766
734
|
assertParsers(parsers, "or()");
|
|
767
735
|
const noMatchContext = analyzeNoMatchContext(parsers);
|
|
768
|
-
const combinedMode = parsers.some((p) => p
|
|
736
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
769
737
|
const syncParsers = parsers;
|
|
770
738
|
const getInitialError = (context) => ({
|
|
771
739
|
consumed: 0,
|
|
@@ -786,7 +754,7 @@ function or(...args) {
|
|
|
786
754
|
let provisionalConsuming = null;
|
|
787
755
|
let provisionalAmbiguous = false;
|
|
788
756
|
for (const [parser, i] of orderedParsers) {
|
|
789
|
-
const result = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
757
|
+
const result = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
790
758
|
if (result.success && result.consumed.length > 0) {
|
|
791
759
|
if (result.provisional) {
|
|
792
760
|
const activeBranchLocked = activeState != null && activeState[1].success && activeState[1].consumed.length > 0;
|
|
@@ -812,7 +780,7 @@ function or(...args) {
|
|
|
812
780
|
}
|
|
813
781
|
if (activeState?.[0] !== i && activeState?.[1].success) {
|
|
814
782
|
if (activeState[1].consumed.length === 0) {
|
|
815
|
-
const mergedExec$2 = mergeChildExec(context.exec, result.next.exec);
|
|
783
|
+
const mergedExec$2 = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
816
784
|
return {
|
|
817
785
|
success: true,
|
|
818
786
|
next: {
|
|
@@ -830,7 +798,7 @@ function or(...args) {
|
|
|
830
798
|
}
|
|
831
799
|
const previouslyConsumed = activeState[1].consumed;
|
|
832
800
|
const checkResult = parser.parse({
|
|
833
|
-
...withChildContext(context, i, parser.initialState, parser),
|
|
801
|
+
...withChildContext$1(context, i, parser.initialState, parser),
|
|
834
802
|
buffer: previouslyConsumed
|
|
835
803
|
});
|
|
836
804
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
@@ -839,8 +807,8 @@ function or(...args) {
|
|
|
839
807
|
consumed: context.buffer.length - result.next.buffer.length,
|
|
840
808
|
error: require_message.message`${require_message.values(activeState[1].consumed)} and ${require_message.values(result.consumed)} cannot be used together.`
|
|
841
809
|
};
|
|
842
|
-
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
843
|
-
const replayedResult = parser.parse(withChildContext({
|
|
810
|
+
const replayExec = require_execution_context.mergeChildExec(context.exec, checkResult.next.exec);
|
|
811
|
+
const replayedResult = parser.parse(withChildContext$1({
|
|
844
812
|
...context,
|
|
845
813
|
...replayExec != null ? {
|
|
846
814
|
exec: replayExec,
|
|
@@ -848,7 +816,7 @@ function or(...args) {
|
|
|
848
816
|
} : {}
|
|
849
817
|
}, i, checkResult.next.state, parser));
|
|
850
818
|
if (!replayedResult.success) return replayedResult;
|
|
851
|
-
const mergedExec$1 = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
819
|
+
const mergedExec$1 = require_execution_context.mergeChildExec(replayExec, replayedResult.next.exec);
|
|
852
820
|
return {
|
|
853
821
|
success: true,
|
|
854
822
|
next: {
|
|
@@ -867,7 +835,7 @@ function or(...args) {
|
|
|
867
835
|
consumed: replayedResult.consumed
|
|
868
836
|
};
|
|
869
837
|
}
|
|
870
|
-
const mergedExec = mergeChildExec(context.exec, result.next.exec);
|
|
838
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
871
839
|
return {
|
|
872
840
|
success: true,
|
|
873
841
|
next: {
|
|
@@ -892,7 +860,7 @@ function or(...args) {
|
|
|
892
860
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
893
861
|
}
|
|
894
862
|
if (zeroConsumedBranch !== null && zeroConsumedCount === 1 && error.consumed === 0 && context.buffer.length === 0) {
|
|
895
|
-
const mergedExec = mergeChildExec(context.exec, zeroConsumedBranch.result.next.exec);
|
|
863
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, zeroConsumedBranch.result.next.exec);
|
|
896
864
|
return {
|
|
897
865
|
success: true,
|
|
898
866
|
...zeroConsumedBranch.result.provisional ? { provisional: true } : {},
|
|
@@ -910,7 +878,7 @@ function or(...args) {
|
|
|
910
878
|
if (provisionalConsuming !== null) {
|
|
911
879
|
const activeIsLockedDifferent = activeState != null && activeState[1].success && activeState[1].consumed.length > 0 && activeState[0] !== provisionalConsuming.index;
|
|
912
880
|
if (!activeIsLockedDifferent) {
|
|
913
|
-
const mergedExec = mergeChildExec(context.exec, provisionalConsuming.result.next.exec);
|
|
881
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, provisionalConsuming.result.next.exec);
|
|
914
882
|
return {
|
|
915
883
|
success: true,
|
|
916
884
|
provisional: true,
|
|
@@ -930,13 +898,13 @@ function or(...args) {
|
|
|
930
898
|
if (activeState != null && activeState[1].success) {
|
|
931
899
|
const previouslyConsumed = activeState[1].consumed;
|
|
932
900
|
const checkResult = provisionalConsuming.parser.parse({
|
|
933
|
-
...withChildContext(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
901
|
+
...withChildContext$1(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
934
902
|
buffer: previouslyConsumed
|
|
935
903
|
});
|
|
936
904
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
937
905
|
if (canConsumeShared && checkResult.success) {
|
|
938
|
-
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
939
|
-
const replayedResult = provisionalConsuming.parser.parse(withChildContext({
|
|
906
|
+
const replayExec = require_execution_context.mergeChildExec(context.exec, checkResult.next.exec);
|
|
907
|
+
const replayedResult = provisionalConsuming.parser.parse(withChildContext$1({
|
|
940
908
|
...context,
|
|
941
909
|
...replayExec != null ? {
|
|
942
910
|
exec: replayExec,
|
|
@@ -944,7 +912,7 @@ function or(...args) {
|
|
|
944
912
|
} : {}
|
|
945
913
|
}, provisionalConsuming.index, checkResult.next.state, provisionalConsuming.parser));
|
|
946
914
|
if (!replayedResult.success) return replayedResult;
|
|
947
|
-
const mergedExec = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
915
|
+
const mergedExec = require_execution_context.mergeChildExec(replayExec, replayedResult.next.exec);
|
|
948
916
|
return {
|
|
949
917
|
success: true,
|
|
950
918
|
provisional: true,
|
|
@@ -982,7 +950,7 @@ function or(...args) {
|
|
|
982
950
|
let provisionalConsuming = null;
|
|
983
951
|
let provisionalAmbiguous = false;
|
|
984
952
|
for (const [parser, i] of orderedParsers) {
|
|
985
|
-
const resultOrPromise = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
953
|
+
const resultOrPromise = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
986
954
|
const result = await resultOrPromise;
|
|
987
955
|
if (result.success && result.consumed.length > 0) {
|
|
988
956
|
if (result.provisional) {
|
|
@@ -1009,7 +977,7 @@ function or(...args) {
|
|
|
1009
977
|
}
|
|
1010
978
|
if (activeState?.[0] !== i && activeState?.[1].success) {
|
|
1011
979
|
if (activeState[1].consumed.length === 0) {
|
|
1012
|
-
const mergedExec$2 = mergeChildExec(context.exec, result.next.exec);
|
|
980
|
+
const mergedExec$2 = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
1013
981
|
return {
|
|
1014
982
|
success: true,
|
|
1015
983
|
next: {
|
|
@@ -1027,7 +995,7 @@ function or(...args) {
|
|
|
1027
995
|
}
|
|
1028
996
|
const previouslyConsumed = activeState[1].consumed;
|
|
1029
997
|
const checkResultOrPromise = parser.parse({
|
|
1030
|
-
...withChildContext(context, i, parser.initialState, parser),
|
|
998
|
+
...withChildContext$1(context, i, parser.initialState, parser),
|
|
1031
999
|
buffer: previouslyConsumed
|
|
1032
1000
|
});
|
|
1033
1001
|
const checkResult = await checkResultOrPromise;
|
|
@@ -1037,8 +1005,8 @@ function or(...args) {
|
|
|
1037
1005
|
consumed: context.buffer.length - result.next.buffer.length,
|
|
1038
1006
|
error: require_message.message`${require_message.values(activeState[1].consumed)} and ${require_message.values(result.consumed)} cannot be used together.`
|
|
1039
1007
|
};
|
|
1040
|
-
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
1041
|
-
const replayedResultOrPromise = parser.parse(withChildContext({
|
|
1008
|
+
const replayExec = require_execution_context.mergeChildExec(context.exec, checkResult.next.exec);
|
|
1009
|
+
const replayedResultOrPromise = parser.parse(withChildContext$1({
|
|
1042
1010
|
...context,
|
|
1043
1011
|
...replayExec != null ? {
|
|
1044
1012
|
exec: replayExec,
|
|
@@ -1047,7 +1015,7 @@ function or(...args) {
|
|
|
1047
1015
|
}, i, checkResult.next.state, parser));
|
|
1048
1016
|
const replayedResult = await replayedResultOrPromise;
|
|
1049
1017
|
if (!replayedResult.success) return replayedResult;
|
|
1050
|
-
const mergedExec$1 = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
1018
|
+
const mergedExec$1 = require_execution_context.mergeChildExec(replayExec, replayedResult.next.exec);
|
|
1051
1019
|
return {
|
|
1052
1020
|
success: true,
|
|
1053
1021
|
next: {
|
|
@@ -1066,7 +1034,7 @@ function or(...args) {
|
|
|
1066
1034
|
consumed: replayedResult.consumed
|
|
1067
1035
|
};
|
|
1068
1036
|
}
|
|
1069
|
-
const mergedExec = mergeChildExec(context.exec, result.next.exec);
|
|
1037
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
1070
1038
|
return {
|
|
1071
1039
|
success: true,
|
|
1072
1040
|
next: {
|
|
@@ -1091,7 +1059,7 @@ function or(...args) {
|
|
|
1091
1059
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
1092
1060
|
}
|
|
1093
1061
|
if (zeroConsumedBranch !== null && zeroConsumedCount === 1 && error.consumed === 0 && context.buffer.length === 0) {
|
|
1094
|
-
const mergedExec = mergeChildExec(context.exec, zeroConsumedBranch.result.next.exec);
|
|
1062
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, zeroConsumedBranch.result.next.exec);
|
|
1095
1063
|
return {
|
|
1096
1064
|
success: true,
|
|
1097
1065
|
...zeroConsumedBranch.result.provisional ? { provisional: true } : {},
|
|
@@ -1109,7 +1077,7 @@ function or(...args) {
|
|
|
1109
1077
|
if (provisionalConsuming !== null) {
|
|
1110
1078
|
const activeIsLockedDifferent = activeState != null && activeState[1].success && activeState[1].consumed.length > 0 && activeState[0] !== provisionalConsuming.index;
|
|
1111
1079
|
if (!activeIsLockedDifferent) {
|
|
1112
|
-
const mergedExec = mergeChildExec(context.exec, provisionalConsuming.result.next.exec);
|
|
1080
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, provisionalConsuming.result.next.exec);
|
|
1113
1081
|
return {
|
|
1114
1082
|
success: true,
|
|
1115
1083
|
provisional: true,
|
|
@@ -1129,13 +1097,13 @@ function or(...args) {
|
|
|
1129
1097
|
if (activeState != null && activeState[1].success) {
|
|
1130
1098
|
const previouslyConsumed = activeState[1].consumed;
|
|
1131
1099
|
const checkResult = await provisionalConsuming.parser.parse({
|
|
1132
|
-
...withChildContext(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1100
|
+
...withChildContext$1(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1133
1101
|
buffer: previouslyConsumed
|
|
1134
1102
|
});
|
|
1135
1103
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
1136
1104
|
if (canConsumeShared && checkResult.success) {
|
|
1137
|
-
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
1138
|
-
const replayedResult = await provisionalConsuming.parser.parse(withChildContext({
|
|
1105
|
+
const replayExec = require_execution_context.mergeChildExec(context.exec, checkResult.next.exec);
|
|
1106
|
+
const replayedResult = await provisionalConsuming.parser.parse(withChildContext$1({
|
|
1139
1107
|
...context,
|
|
1140
1108
|
...replayExec != null ? {
|
|
1141
1109
|
exec: replayExec,
|
|
@@ -1143,7 +1111,7 @@ function or(...args) {
|
|
|
1143
1111
|
} : {}
|
|
1144
1112
|
}, provisionalConsuming.index, checkResult.next.state, provisionalConsuming.parser));
|
|
1145
1113
|
if (!replayedResult.success) return replayedResult;
|
|
1146
|
-
const mergedExec = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
1114
|
+
const mergedExec = require_execution_context.mergeChildExec(replayExec, replayedResult.next.exec);
|
|
1147
1115
|
return {
|
|
1148
1116
|
success: true,
|
|
1149
1117
|
provisional: true,
|
|
@@ -1172,7 +1140,7 @@ function or(...args) {
|
|
|
1172
1140
|
};
|
|
1173
1141
|
};
|
|
1174
1142
|
const singleResult = {
|
|
1175
|
-
|
|
1143
|
+
mode: combinedMode,
|
|
1176
1144
|
$valueType: [],
|
|
1177
1145
|
$stateType: [],
|
|
1178
1146
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
@@ -1242,7 +1210,7 @@ function longestMatch(...args) {
|
|
|
1242
1210
|
if (parsers.length < 1) throw new TypeError("longestMatch() requires at least one parser argument.");
|
|
1243
1211
|
assertParsers(parsers, "longestMatch()");
|
|
1244
1212
|
const noMatchContext = analyzeNoMatchContext(parsers);
|
|
1245
|
-
const combinedMode = parsers.some((p) => p
|
|
1213
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
1246
1214
|
const syncParsers = parsers;
|
|
1247
1215
|
const getInitialError = (context) => ({
|
|
1248
1216
|
consumed: 0,
|
|
@@ -1259,7 +1227,7 @@ function longestMatch(...args) {
|
|
|
1259
1227
|
const activeState = normalizeExclusiveState(context.state);
|
|
1260
1228
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
1261
1229
|
const parser = syncParsers[i];
|
|
1262
|
-
const result = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1230
|
+
const result = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1263
1231
|
if (result.success) {
|
|
1264
1232
|
const consumed = context.buffer.length - result.next.buffer.length;
|
|
1265
1233
|
const bestIsProvisional = bestMatch != null && bestMatch.result.success && !!bestMatch.result.provisional;
|
|
@@ -1272,7 +1240,7 @@ function longestMatch(...args) {
|
|
|
1272
1240
|
} else if (error.consumed < result.consumed) error = result;
|
|
1273
1241
|
}
|
|
1274
1242
|
if (bestMatch && bestMatch.result.success) {
|
|
1275
|
-
const mergedExec = mergeChildExec(context.exec, bestMatch.result.next.exec);
|
|
1243
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, bestMatch.result.next.exec);
|
|
1276
1244
|
return {
|
|
1277
1245
|
success: true,
|
|
1278
1246
|
next: {
|
|
@@ -1299,7 +1267,7 @@ function longestMatch(...args) {
|
|
|
1299
1267
|
const activeState = normalizeExclusiveState(context.state);
|
|
1300
1268
|
for (let i = 0; i < parsers.length; i++) {
|
|
1301
1269
|
const parser = parsers[i];
|
|
1302
|
-
const resultOrPromise = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1270
|
+
const resultOrPromise = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1303
1271
|
const result = await resultOrPromise;
|
|
1304
1272
|
if (result.success) {
|
|
1305
1273
|
const consumed = context.buffer.length - result.next.buffer.length;
|
|
@@ -1313,7 +1281,7 @@ function longestMatch(...args) {
|
|
|
1313
1281
|
} else if (error.consumed < result.consumed) error = result;
|
|
1314
1282
|
}
|
|
1315
1283
|
if (bestMatch && bestMatch.result.success) {
|
|
1316
|
-
const mergedExec = mergeChildExec(context.exec, bestMatch.result.next.exec);
|
|
1284
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, bestMatch.result.next.exec);
|
|
1317
1285
|
return {
|
|
1318
1286
|
success: true,
|
|
1319
1287
|
next: {
|
|
@@ -1335,7 +1303,7 @@ function longestMatch(...args) {
|
|
|
1335
1303
|
};
|
|
1336
1304
|
};
|
|
1337
1305
|
const multiResult = {
|
|
1338
|
-
|
|
1306
|
+
mode: combinedMode,
|
|
1339
1307
|
$valueType: [],
|
|
1340
1308
|
$stateType: [],
|
|
1341
1309
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
@@ -1420,14 +1388,14 @@ function* suggestObjectSync(context, prefix, parserPairs) {
|
|
|
1420
1388
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
1421
1389
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
1422
1390
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1423
|
-
yield* parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1391
|
+
yield* parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1424
1392
|
return;
|
|
1425
1393
|
}
|
|
1426
1394
|
}
|
|
1427
1395
|
const suggestions = [];
|
|
1428
1396
|
for (const [field, parser] of parserPairs) {
|
|
1429
1397
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1430
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1398
|
+
const fieldSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1431
1399
|
suggestions.push(...fieldSuggestions);
|
|
1432
1400
|
}
|
|
1433
1401
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -1456,7 +1424,7 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1456
1424
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
1457
1425
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
1458
1426
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1459
|
-
const suggestions$1 = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1427
|
+
const suggestions$1 = parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1460
1428
|
for await (const s of suggestions$1) yield s;
|
|
1461
1429
|
return;
|
|
1462
1430
|
}
|
|
@@ -1464,7 +1432,7 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1464
1432
|
const suggestions = [];
|
|
1465
1433
|
for (const [field, parser] of parserPairs) {
|
|
1466
1434
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1467
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1435
|
+
const fieldSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1468
1436
|
for await (const s of fieldSuggestions) suggestions.push(s);
|
|
1469
1437
|
}
|
|
1470
1438
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -1653,35 +1621,35 @@ function preCompleteAndRegisterDependencies(state, fieldParserPairs, registry, e
|
|
|
1653
1621
|
const fieldState = state[field];
|
|
1654
1622
|
const annotatedFieldState = getAnnotatedFieldState(state, field, fieldParser);
|
|
1655
1623
|
if (fieldParser.dependencyMetadata?.source?.getMissingSourceValue != null && isUnmatchedDependencyState(fieldState, fieldParser)) {
|
|
1656
|
-
const completed = fieldParser.complete(annotatedFieldState, withChildExecPath(exec, field));
|
|
1624
|
+
const completed = fieldParser.complete(annotatedFieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1657
1625
|
preCompleted.set(field, completed);
|
|
1658
1626
|
const depState = wrapAsDependencySourceState(completed, fieldParser);
|
|
1659
1627
|
if (depState) registerCompletedDependency(depState, registry);
|
|
1660
1628
|
continue;
|
|
1661
1629
|
}
|
|
1662
1630
|
if (fieldParser.dependencyMetadata?.source != null && isUnmatchedDependencyState(fieldState, fieldParser) && (annotatedFieldState !== fieldState || isNonCliBoundSourceState(fieldState, fieldParser))) {
|
|
1663
|
-
const completed = fieldParser.complete(annotatedFieldState, withChildExecPath(exec, field));
|
|
1631
|
+
const completed = fieldParser.complete(annotatedFieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1664
1632
|
preCompleted.set(field, completed);
|
|
1665
1633
|
const depState = wrapAsDependencySourceState(completed, fieldParser);
|
|
1666
1634
|
if (depState) registerCompletedDependency(depState, registry);
|
|
1667
1635
|
continue;
|
|
1668
1636
|
}
|
|
1669
1637
|
if (Array.isArray(fieldState) && fieldState.length === 1 && require_dependency.isPendingDependencySourceState(fieldState[0])) {
|
|
1670
|
-
const completed = fieldParser.complete(fieldState, withChildExecPath(exec, field));
|
|
1638
|
+
const completed = fieldParser.complete(fieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1671
1639
|
preCompleted.set(field, completed);
|
|
1672
1640
|
if (require_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1673
1641
|
} else if (fieldState === void 0 && require_dependency.isPendingDependencySourceState(fieldParser.initialState)) {
|
|
1674
|
-
const completed = fieldParser.complete([fieldParser.initialState], withChildExecPath(exec, field));
|
|
1642
|
+
const completed = fieldParser.complete([fieldParser.initialState], require_execution_context.withChildExecPath(exec, field));
|
|
1675
1643
|
preCompleted.set(field, completed);
|
|
1676
1644
|
if (require_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1677
1645
|
} else if (fieldState === void 0 && require_dependency.isWrappedDependencySource(fieldParser)) {
|
|
1678
1646
|
const pendingState = fieldParser[require_dependency.wrappedDependencySourceMarker];
|
|
1679
|
-
const completed = fieldParser.complete([pendingState], withChildExecPath(exec, field));
|
|
1647
|
+
const completed = fieldParser.complete([pendingState], require_execution_context.withChildExecPath(exec, field));
|
|
1680
1648
|
preCompleted.set(field, completed);
|
|
1681
1649
|
if (require_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1682
1650
|
} else if (fieldState != null && !Array.isArray(fieldState) && !require_dependency.isDependencySourceState(fieldState) && (require_dependency.isWrappedDependencySource(fieldParser) || require_dependency.isPendingDependencySourceState(fieldParser.initialState))) {
|
|
1683
1651
|
const annotatedFieldState$1 = getAnnotatedFieldState(state, field, fieldParser);
|
|
1684
|
-
const completed = fieldParser.complete(annotatedFieldState$1, withChildExecPath(exec, field));
|
|
1652
|
+
const completed = fieldParser.complete(annotatedFieldState$1, require_execution_context.withChildExecPath(exec, field));
|
|
1685
1653
|
preCompleted.set(field, completed);
|
|
1686
1654
|
const depState = wrapAsDependencySourceState(completed, fieldParser);
|
|
1687
1655
|
if (depState) registerCompletedDependency(depState, registry);
|
|
@@ -1706,35 +1674,35 @@ async function preCompleteAndRegisterDependenciesAsync(state, fieldParserPairs,
|
|
|
1706
1674
|
const fieldState = state[field];
|
|
1707
1675
|
const annotatedFieldState = getAnnotatedFieldState(state, field, fieldParser);
|
|
1708
1676
|
if (fieldParser.dependencyMetadata?.source?.getMissingSourceValue != null && isUnmatchedDependencyState(fieldState, fieldParser)) {
|
|
1709
|
-
const completed = await fieldParser.complete(annotatedFieldState, withChildExecPath(exec, field));
|
|
1677
|
+
const completed = await fieldParser.complete(annotatedFieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1710
1678
|
preCompleted.set(field, completed);
|
|
1711
1679
|
const depState = wrapAsDependencySourceState(completed, fieldParser);
|
|
1712
1680
|
if (depState) registerCompletedDependency(depState, registry);
|
|
1713
1681
|
continue;
|
|
1714
1682
|
}
|
|
1715
1683
|
if (fieldParser.dependencyMetadata?.source != null && isUnmatchedDependencyState(fieldState, fieldParser) && (annotatedFieldState !== fieldState || isNonCliBoundSourceState(fieldState, fieldParser))) {
|
|
1716
|
-
const completed = await fieldParser.complete(annotatedFieldState, withChildExecPath(exec, field));
|
|
1684
|
+
const completed = await fieldParser.complete(annotatedFieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1717
1685
|
preCompleted.set(field, completed);
|
|
1718
1686
|
const depState = wrapAsDependencySourceState(completed, fieldParser);
|
|
1719
1687
|
if (depState) registerCompletedDependency(depState, registry);
|
|
1720
1688
|
continue;
|
|
1721
1689
|
}
|
|
1722
1690
|
if (Array.isArray(fieldState) && fieldState.length === 1 && require_dependency.isPendingDependencySourceState(fieldState[0])) {
|
|
1723
|
-
const completed = await fieldParser.complete(fieldState, withChildExecPath(exec, field));
|
|
1691
|
+
const completed = await fieldParser.complete(fieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1724
1692
|
preCompleted.set(field, completed);
|
|
1725
1693
|
if (require_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1726
1694
|
} else if (fieldState === void 0 && require_dependency.isPendingDependencySourceState(fieldParser.initialState)) {
|
|
1727
|
-
const completed = await fieldParser.complete([fieldParser.initialState], withChildExecPath(exec, field));
|
|
1695
|
+
const completed = await fieldParser.complete([fieldParser.initialState], require_execution_context.withChildExecPath(exec, field));
|
|
1728
1696
|
preCompleted.set(field, completed);
|
|
1729
1697
|
if (require_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1730
1698
|
} else if (fieldState === void 0 && require_dependency.isWrappedDependencySource(fieldParser)) {
|
|
1731
1699
|
const pendingState = fieldParser[require_dependency.wrappedDependencySourceMarker];
|
|
1732
|
-
const completed = await fieldParser.complete([pendingState], withChildExecPath(exec, field));
|
|
1700
|
+
const completed = await fieldParser.complete([pendingState], require_execution_context.withChildExecPath(exec, field));
|
|
1733
1701
|
preCompleted.set(field, completed);
|
|
1734
1702
|
if (require_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1735
1703
|
} else if (fieldState != null && !Array.isArray(fieldState) && !require_dependency.isDependencySourceState(fieldState) && (require_dependency.isWrappedDependencySource(fieldParser) || require_dependency.isPendingDependencySourceState(fieldParser.initialState))) {
|
|
1736
1704
|
const annotatedFieldState$1 = getAnnotatedFieldState(state, field, fieldParser);
|
|
1737
|
-
const completed = await fieldParser.complete(annotatedFieldState$1, withChildExecPath(exec, field));
|
|
1705
|
+
const completed = await fieldParser.complete(annotatedFieldState$1, require_execution_context.withChildExecPath(exec, field));
|
|
1738
1706
|
preCompleted.set(field, completed);
|
|
1739
1707
|
const depState = wrapAsDependencySourceState(completed, fieldParser);
|
|
1740
1708
|
if (depState) registerCompletedDependency(depState, registry);
|
|
@@ -1787,7 +1755,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1787
1755
|
};
|
|
1788
1756
|
if (!options.allowDuplicates) checkDuplicateOptionNames(parserPairs.map(([field, parser]) => [field, parser.usage]));
|
|
1789
1757
|
const noMatchContext = analyzeNoMatchContext(parserKeys.map((k) => parsers[k]));
|
|
1790
|
-
const combinedMode = parserKeys.some((k) => parsers[k]
|
|
1758
|
+
const combinedMode = parserKeys.some((k) => parsers[k].mode === "async") ? "async" : "sync";
|
|
1791
1759
|
const getInitialError = (context) => ({
|
|
1792
1760
|
consumed: 0,
|
|
1793
1761
|
error: context.buffer.length > 0 ? (() => {
|
|
@@ -1812,9 +1780,9 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1812
1780
|
madeProgress = false;
|
|
1813
1781
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
1814
1782
|
for (const [field, parser] of parserPairs) {
|
|
1815
|
-
const result = parser.parse(withChildContext(currentContext, field, getFieldState(field, parser), parser));
|
|
1783
|
+
const result = parser.parse(withChildContext$1(currentContext, field, getFieldState(field, parser), parser));
|
|
1816
1784
|
if (result.success && result.consumed.length > 0) {
|
|
1817
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
1785
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
1818
1786
|
currentContext = {
|
|
1819
1787
|
...currentContext,
|
|
1820
1788
|
buffer: result.next.buffer,
|
|
@@ -1844,9 +1812,9 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1844
1812
|
const typedParser = parser;
|
|
1845
1813
|
if (parser.leadingNames.size > 0 || typedParser.acceptingAnyToken) continue;
|
|
1846
1814
|
const fieldState = getFieldState(field, parser);
|
|
1847
|
-
const result = typedParser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1815
|
+
const result = typedParser.parse(withChildContext$1(currentContext, field, fieldState, parser));
|
|
1848
1816
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
1849
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
1817
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
1850
1818
|
currentContext = {
|
|
1851
1819
|
...currentContext,
|
|
1852
1820
|
state: {
|
|
@@ -1881,7 +1849,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1881
1849
|
};
|
|
1882
1850
|
for (const [field, parser] of parserPairs) {
|
|
1883
1851
|
const fieldState = getFieldState(field, parser);
|
|
1884
|
-
const completeResult = parser.complete(fieldState, withChildExecPath(probeExec, field));
|
|
1852
|
+
const completeResult = parser.complete(fieldState, require_execution_context.withChildExecPath(probeExec, field));
|
|
1885
1853
|
if (!completeResult.success) {
|
|
1886
1854
|
allCanComplete = false;
|
|
1887
1855
|
break;
|
|
@@ -1909,10 +1877,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1909
1877
|
madeProgress = false;
|
|
1910
1878
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
1911
1879
|
for (const [field, parser] of parserPairs) {
|
|
1912
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, field, getFieldState(field, parser), parser));
|
|
1880
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, field, getFieldState(field, parser), parser));
|
|
1913
1881
|
const result = await resultOrPromise;
|
|
1914
1882
|
if (result.success && result.consumed.length > 0) {
|
|
1915
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
1883
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
1916
1884
|
currentContext = {
|
|
1917
1885
|
...currentContext,
|
|
1918
1886
|
buffer: result.next.buffer,
|
|
@@ -1941,10 +1909,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1941
1909
|
if (consumedFields.has(field)) continue;
|
|
1942
1910
|
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken) continue;
|
|
1943
1911
|
const fieldState = getFieldState(field, parser);
|
|
1944
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1912
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, field, fieldState, parser));
|
|
1945
1913
|
const result = await resultOrPromise;
|
|
1946
1914
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
1947
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
1915
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
1948
1916
|
currentContext = {
|
|
1949
1917
|
...currentContext,
|
|
1950
1918
|
state: {
|
|
@@ -1979,7 +1947,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1979
1947
|
};
|
|
1980
1948
|
for (const [field, parser] of parserPairs) {
|
|
1981
1949
|
const fieldState = getFieldState(field, parser);
|
|
1982
|
-
const completeResult = await parser.complete(fieldState, withChildExecPath(probeExec, field));
|
|
1950
|
+
const completeResult = await parser.complete(fieldState, require_execution_context.withChildExecPath(probeExec, field));
|
|
1983
1951
|
if (!completeResult.success) {
|
|
1984
1952
|
allCanComplete = false;
|
|
1985
1953
|
break;
|
|
@@ -1997,7 +1965,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1997
1965
|
};
|
|
1998
1966
|
};
|
|
1999
1967
|
const objectParser = {
|
|
2000
|
-
|
|
1968
|
+
mode: combinedMode,
|
|
2001
1969
|
$valueType: [],
|
|
2002
1970
|
$stateType: [],
|
|
2003
1971
|
[fieldParsersKey]: parserPairs,
|
|
@@ -2048,7 +2016,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2048
2016
|
if (preCompletedResult !== void 0) valueResult = unwrapCompleteResult(preCompletedResult);
|
|
2049
2017
|
else {
|
|
2050
2018
|
const fieldState = resolvedFieldStates[fieldKey];
|
|
2051
|
-
valueResult = unwrapCompleteResult(fieldParser.complete(fieldState, withChildExecPath(phase3Exec, fieldKey)));
|
|
2019
|
+
valueResult = unwrapCompleteResult(fieldParser.complete(fieldState, require_execution_context.withChildExecPath(phase3Exec, fieldKey)));
|
|
2052
2020
|
}
|
|
2053
2021
|
if (valueResult.success) {
|
|
2054
2022
|
result[fieldKey] = valueResult.value;
|
|
@@ -2116,13 +2084,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2116
2084
|
if (failure != null) return failure;
|
|
2117
2085
|
continue;
|
|
2118
2086
|
}
|
|
2119
|
-
if (typeof fieldParser.shouldDeferCompletion === "function" && fieldParser.shouldDeferCompletion(resolvedFieldStates[fieldKey], withChildExecPath(phase3Exec, fieldKey)) === true) deferredFields.push(field);
|
|
2087
|
+
if (typeof fieldParser.shouldDeferCompletion === "function" && fieldParser.shouldDeferCompletion(resolvedFieldStates[fieldKey], require_execution_context.withChildExecPath(phase3Exec, fieldKey)) === true) deferredFields.push(field);
|
|
2120
2088
|
else concurrentFields.push(field);
|
|
2121
2089
|
}
|
|
2122
2090
|
const concurrentResults = await Promise.all(concurrentFields.map(async (field) => {
|
|
2123
2091
|
const fieldKey = field;
|
|
2124
2092
|
const fieldParser = parsers[field];
|
|
2125
|
-
const valueResult = unwrapCompleteResult(await fieldParser.complete(resolvedFieldStates[fieldKey], withChildExecPath(phase3Exec, fieldKey)));
|
|
2093
|
+
const valueResult = unwrapCompleteResult(await fieldParser.complete(resolvedFieldStates[fieldKey], require_execution_context.withChildExecPath(phase3Exec, fieldKey)));
|
|
2126
2094
|
return {
|
|
2127
2095
|
fieldKey,
|
|
2128
2096
|
valueResult
|
|
@@ -2135,7 +2103,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2135
2103
|
for (const field of deferredFields) {
|
|
2136
2104
|
const fieldKey = field;
|
|
2137
2105
|
const fieldParser = parsers[field];
|
|
2138
|
-
const valueResult = unwrapCompleteResult(await fieldParser.complete(resolvedFieldStates[fieldKey], withChildExecPath(phase3Exec, fieldKey)));
|
|
2106
|
+
const valueResult = unwrapCompleteResult(await fieldParser.complete(resolvedFieldStates[fieldKey], require_execution_context.withChildExecPath(phase3Exec, fieldKey)));
|
|
2139
2107
|
const failure = applyValueResult(fieldKey, valueResult);
|
|
2140
2108
|
if (failure != null) return failure;
|
|
2141
2109
|
}
|
|
@@ -2176,7 +2144,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2176
2144
|
for (const field of parserKeys) {
|
|
2177
2145
|
const fieldKey = field;
|
|
2178
2146
|
const fieldParser = parsers[field];
|
|
2179
|
-
const childExec$1 = withChildExecPath(phase3Exec, fieldKey);
|
|
2147
|
+
const childExec$1 = require_execution_context.withChildExecPath(phase3Exec, fieldKey);
|
|
2180
2148
|
const preCompletedResult = preCompleted.get(fieldKey);
|
|
2181
2149
|
const seed = preCompletedResult !== void 0 ? reusePreCompletedPhase2Seed(fieldParser, resolvedFieldStates[fieldKey], preCompletedResult, childExec$1) : require_phase2_seed.completeOrExtractPhase2Seed(fieldParser, resolvedFieldStates[fieldKey], childExec$1);
|
|
2182
2150
|
if (seed == null) continue;
|
|
@@ -2219,7 +2187,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2219
2187
|
for (const field of parserKeys) {
|
|
2220
2188
|
const fieldKey = field;
|
|
2221
2189
|
const fieldParser = parsers[field];
|
|
2222
|
-
const childExec$1 = withChildExecPath(phase3Exec, fieldKey);
|
|
2190
|
+
const childExec$1 = require_execution_context.withChildExecPath(phase3Exec, fieldKey);
|
|
2223
2191
|
const preCompletedResult = preCompleted.get(fieldKey);
|
|
2224
2192
|
const seed = preCompletedResult !== void 0 ? await reusePreCompletedPhase2SeedAsync(fieldParser, resolvedFieldStates[fieldKey], preCompletedResult, childExec$1) : await require_phase2_seed.completeOrExtractPhase2Seed(fieldParser, resolvedFieldStates[fieldKey], childExec$1);
|
|
2225
2193
|
if (seed == null) continue;
|
|
@@ -2326,7 +2294,7 @@ function suggestTupleSync(context, prefix, parsers) {
|
|
|
2326
2294
|
for (let i = 0; i < parsers.length; i++) {
|
|
2327
2295
|
const parser = parsers[i];
|
|
2328
2296
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[i] : parser.initialState;
|
|
2329
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry, i, parserState, parser), prefix);
|
|
2297
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, i, parserState, parser), prefix);
|
|
2330
2298
|
suggestions.push(...parserSuggestions);
|
|
2331
2299
|
}
|
|
2332
2300
|
return require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -2360,8 +2328,8 @@ async function* suggestTupleAsync(context, prefix, parsers) {
|
|
|
2360
2328
|
for (let i = 0; i < parsers.length; i++) {
|
|
2361
2329
|
const parser = parsers[i];
|
|
2362
2330
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[i] : parser.initialState;
|
|
2363
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry, i, parserState, parser), prefix);
|
|
2364
|
-
if (parser
|
|
2331
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, i, parserState, parser), prefix);
|
|
2332
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
2365
2333
|
else suggestions.push(...parserSuggestions);
|
|
2366
2334
|
}
|
|
2367
2335
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -2376,10 +2344,10 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2376
2344
|
const stateArray = Array.isArray(currentContext.state) ? [...currentContext.state] : parsers.map((parser) => parser.initialState);
|
|
2377
2345
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2378
2346
|
for (const [parser, index] of remainingParsers) {
|
|
2379
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2347
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2380
2348
|
if (result.success && result.consumed.length > 0) {
|
|
2381
2349
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2382
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2350
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2383
2351
|
currentContext = {
|
|
2384
2352
|
...currentContext,
|
|
2385
2353
|
buffer: result.next.buffer,
|
|
@@ -2401,10 +2369,10 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2401
2369
|
}
|
|
2402
2370
|
}
|
|
2403
2371
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2404
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2372
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2405
2373
|
if (result.success && result.consumed.length < 1) {
|
|
2406
2374
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2407
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2375
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2408
2376
|
currentContext = {
|
|
2409
2377
|
...currentContext,
|
|
2410
2378
|
state: newStateArray,
|
|
@@ -2442,10 +2410,10 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2442
2410
|
const stateArray = Array.isArray(currentContext.state) ? [...currentContext.state] : parsers.map((parser) => parser.initialState);
|
|
2443
2411
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2444
2412
|
for (const [parser, index] of remainingParsers) {
|
|
2445
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2413
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2446
2414
|
if (result.success && result.consumed.length > 0) {
|
|
2447
2415
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2448
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2416
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2449
2417
|
currentContext = {
|
|
2450
2418
|
...currentContext,
|
|
2451
2419
|
buffer: result.next.buffer,
|
|
@@ -2467,10 +2435,10 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2467
2435
|
}
|
|
2468
2436
|
}
|
|
2469
2437
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2470
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2438
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2471
2439
|
if (result.success && result.consumed.length < 1) {
|
|
2472
2440
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2473
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2441
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2474
2442
|
currentContext = {
|
|
2475
2443
|
...currentContext,
|
|
2476
2444
|
state: newStateArray,
|
|
@@ -2544,7 +2512,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2544
2512
|
parsers = labelOrParsers;
|
|
2545
2513
|
options = maybeParsersOrOptions ?? {};
|
|
2546
2514
|
}
|
|
2547
|
-
const combinedMode = parsers.some((p) => p
|
|
2515
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
2548
2516
|
const syncParsers = parsers;
|
|
2549
2517
|
if (!options.allowDuplicates) checkDuplicateOptionNames(parsers.map((parser, index) => [String(index), parser.usage]));
|
|
2550
2518
|
const parseSync = (context) => {
|
|
@@ -2560,10 +2528,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2560
2528
|
const stateArray = currentContext.state;
|
|
2561
2529
|
const remainingParsers = syncParsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2562
2530
|
for (const [parser, index] of remainingParsers) {
|
|
2563
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2531
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2564
2532
|
if (result.success && result.consumed.length > 0) {
|
|
2565
2533
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2566
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2534
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2567
2535
|
currentContext = {
|
|
2568
2536
|
...currentContext,
|
|
2569
2537
|
buffer: result.next.buffer,
|
|
@@ -2581,10 +2549,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2581
2549
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
2582
2550
|
}
|
|
2583
2551
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2584
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2552
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2585
2553
|
if (result.success && result.consumed.length < 1) {
|
|
2586
2554
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2587
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2555
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2588
2556
|
currentContext = {
|
|
2589
2557
|
...currentContext,
|
|
2590
2558
|
state: newStateArray,
|
|
@@ -2626,11 +2594,11 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2626
2594
|
const stateArray = currentContext.state;
|
|
2627
2595
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2628
2596
|
for (const [parser, index] of remainingParsers) {
|
|
2629
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2597
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2630
2598
|
const result = await resultOrPromise;
|
|
2631
2599
|
if (result.success && result.consumed.length > 0) {
|
|
2632
2600
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2633
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2601
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2634
2602
|
currentContext = {
|
|
2635
2603
|
...currentContext,
|
|
2636
2604
|
buffer: result.next.buffer,
|
|
@@ -2648,11 +2616,11 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2648
2616
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
2649
2617
|
}
|
|
2650
2618
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2651
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2619
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2652
2620
|
const result = await resultOrPromise;
|
|
2653
2621
|
if (result.success && result.consumed.length < 1) {
|
|
2654
2622
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2655
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2623
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2656
2624
|
currentContext = {
|
|
2657
2625
|
...currentContext,
|
|
2658
2626
|
state: newStateArray,
|
|
@@ -2682,7 +2650,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2682
2650
|
};
|
|
2683
2651
|
};
|
|
2684
2652
|
const tupleParser = {
|
|
2685
|
-
|
|
2653
|
+
mode: combinedMode,
|
|
2686
2654
|
$valueType: [],
|
|
2687
2655
|
$stateType: [],
|
|
2688
2656
|
[fieldParsersKey]: parsers.map((parser, index) => [String(index), parser]),
|
|
@@ -2721,7 +2689,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2721
2689
|
if (preCompletedResult !== void 0) valueResult = unwrapCompleteResult(preCompletedResult);
|
|
2722
2690
|
else {
|
|
2723
2691
|
const elementState = prepareStateForCompletion(resolvedArray[i], elementParser);
|
|
2724
|
-
valueResult = unwrapCompleteResult(elementParser.complete(elementState, withChildExecPath(phase3Exec, i)));
|
|
2692
|
+
valueResult = unwrapCompleteResult(elementParser.complete(elementState, require_execution_context.withChildExecPath(phase3Exec, i)));
|
|
2725
2693
|
}
|
|
2726
2694
|
if (valueResult.success) {
|
|
2727
2695
|
result[i] = valueResult.value;
|
|
@@ -2768,7 +2736,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2768
2736
|
if (preCompletedResult !== void 0) valueResult = unwrapCompleteResult(preCompletedResult);
|
|
2769
2737
|
else {
|
|
2770
2738
|
const elementState = prepareStateForCompletion(resolvedArray[i], elementParser);
|
|
2771
|
-
valueResult = unwrapCompleteResult(await elementParser.complete(elementState, withChildExecPath(phase3Exec, i)));
|
|
2739
|
+
valueResult = unwrapCompleteResult(await elementParser.complete(elementState, require_execution_context.withChildExecPath(phase3Exec, i)));
|
|
2772
2740
|
}
|
|
2773
2741
|
if (valueResult.success) {
|
|
2774
2742
|
result[i] = valueResult.value;
|
|
@@ -2811,7 +2779,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2811
2779
|
let hasAnySeed = false;
|
|
2812
2780
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
2813
2781
|
const elementParser = syncParsers[i];
|
|
2814
|
-
const childExec$1 = withChildExecPath(phase3Exec, i);
|
|
2782
|
+
const childExec$1 = require_execution_context.withChildExecPath(phase3Exec, i);
|
|
2815
2783
|
const preCompletedResult = preCompleted.get(String(i));
|
|
2816
2784
|
const seed = preCompletedResult !== void 0 ? reusePreCompletedPhase2Seed(elementParser, prepareStateForCompletion(resolvedArray[i], elementParser), preCompletedResult, childExec$1) : require_phase2_seed.completeOrExtractPhase2Seed(elementParser, prepareStateForCompletion(resolvedArray[i], elementParser), childExec$1);
|
|
2817
2785
|
if (seed == null) continue;
|
|
@@ -2848,7 +2816,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2848
2816
|
let hasAnySeed = false;
|
|
2849
2817
|
for (let i = 0; i < parsers.length; i++) {
|
|
2850
2818
|
const elementParser = parsers[i];
|
|
2851
|
-
const childExec$1 = withChildExecPath(phase3Exec, i);
|
|
2819
|
+
const childExec$1 = require_execution_context.withChildExecPath(phase3Exec, i);
|
|
2852
2820
|
const preCompletedResult = preCompleted.get(String(i));
|
|
2853
2821
|
const seed = preCompletedResult !== void 0 ? await reusePreCompletedPhase2SeedAsync(elementParser, prepareStateForCompletion(resolvedArray[i], elementParser), preCompletedResult, childExec$1) : await require_phase2_seed.completeOrExtractPhase2Seed(elementParser, prepareStateForCompletion(resolvedArray[i], elementParser), childExec$1);
|
|
2854
2822
|
if (seed == null) continue;
|
|
@@ -2939,7 +2907,7 @@ function merge(...args) {
|
|
|
2939
2907
|
const rawParsers = args.slice(startIndex, endIndex);
|
|
2940
2908
|
if (rawParsers.length < 1) throw new TypeError("merge() requires at least one parser argument.");
|
|
2941
2909
|
assertParsers(rawParsers, "merge()");
|
|
2942
|
-
const combinedMode = rawParsers.some((p) => p
|
|
2910
|
+
const combinedMode = rawParsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
2943
2911
|
const isAsync = combinedMode === "async";
|
|
2944
2912
|
const syncRawParsers = rawParsers;
|
|
2945
2913
|
const withIndex = rawParsers.map((p, i) => [p, i]);
|
|
@@ -3006,9 +2974,9 @@ function merge(...args) {
|
|
|
3006
2974
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
3007
2975
|
const parser = syncParsers[i];
|
|
3008
2976
|
const parserState = extractParserState(parser, currentContext, i);
|
|
3009
|
-
const result = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
2977
|
+
const result = parser.parse(withChildContext$1(currentContext, i, parserState, parser));
|
|
3010
2978
|
if (result.success) {
|
|
3011
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2979
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3012
2980
|
const newState = mergeResultState(parser, currentContext, parserState, result, i);
|
|
3013
2981
|
const newContext = {
|
|
3014
2982
|
...currentContext,
|
|
@@ -3051,10 +3019,10 @@ function merge(...args) {
|
|
|
3051
3019
|
for (let i = 0; i < parsers.length; i++) {
|
|
3052
3020
|
const parser = parsers[i];
|
|
3053
3021
|
const parserState = extractParserState(parser, currentContext, i);
|
|
3054
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
3022
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, i, parserState, parser));
|
|
3055
3023
|
const result = await resultOrPromise;
|
|
3056
3024
|
if (result.success) {
|
|
3057
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3025
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3058
3026
|
const newState = mergeResultState(parser, currentContext, parserState, result, i);
|
|
3059
3027
|
const newContext = {
|
|
3060
3028
|
...currentContext,
|
|
@@ -3092,7 +3060,7 @@ function merge(...args) {
|
|
|
3092
3060
|
};
|
|
3093
3061
|
};
|
|
3094
3062
|
const mergeParser = {
|
|
3095
|
-
|
|
3063
|
+
mode: combinedMode,
|
|
3096
3064
|
$valueType: [],
|
|
3097
3065
|
$stateType: [],
|
|
3098
3066
|
[fieldParsersKey]: mergedFieldParsers,
|
|
@@ -3138,7 +3106,7 @@ function merge(...args) {
|
|
|
3138
3106
|
const pairs = parser[fieldParsersKey];
|
|
3139
3107
|
const excludedSourceFields = new Set(pairs.map(([field]) => field).filter((field) => duplicateFieldNames.has(field)));
|
|
3140
3108
|
const phase1Pairs = filterExcludedFieldParsers(pairs, excludedSourceFields);
|
|
3141
|
-
const preCompleted = preCompleteAndRegisterDependencies(state, phase1Pairs, runtime.registry, withChildExecPath(childExec, i));
|
|
3109
|
+
const preCompleted = preCompleteAndRegisterDependencies(state, phase1Pairs, runtime.registry, require_execution_context.withChildExecPath(childExec, i));
|
|
3142
3110
|
return {
|
|
3143
3111
|
cache: filterDuplicateKeys(preCompleted, phase1Pairs),
|
|
3144
3112
|
excludedSourceFields: excludedSourceFields.size > 0 ? excludedSourceFields : void 0
|
|
@@ -3158,7 +3126,7 @@ function merge(...args) {
|
|
|
3158
3126
|
const parser = syncParsers[i];
|
|
3159
3127
|
const parserState = extractCompleteState(parser, resolvedState, i);
|
|
3160
3128
|
const { cache, excludedSourceFields } = perChildPhase1[i];
|
|
3161
|
-
const childCompleteExec = withChildExecPath(childExec, i);
|
|
3129
|
+
const childCompleteExec = require_execution_context.withChildExecPath(childExec, i);
|
|
3162
3130
|
const completeExec = excludedSourceFields == null ? {
|
|
3163
3131
|
...childCompleteExec,
|
|
3164
3132
|
preCompletedByParser: cache
|
|
@@ -3206,7 +3174,7 @@ function merge(...args) {
|
|
|
3206
3174
|
const pairs = parser[fieldParsersKey];
|
|
3207
3175
|
const excludedSourceFields = new Set(pairs.map(([field]) => field).filter((field) => duplicateFieldNames.has(field)));
|
|
3208
3176
|
const phase1Pairs = filterExcludedFieldParsers(pairs, excludedSourceFields);
|
|
3209
|
-
const preCompleted = await preCompleteAndRegisterDependenciesAsync(state, phase1Pairs, runtime.registry, withChildExecPath(childExec, i));
|
|
3177
|
+
const preCompleted = await preCompleteAndRegisterDependenciesAsync(state, phase1Pairs, runtime.registry, require_execution_context.withChildExecPath(childExec, i));
|
|
3210
3178
|
perChildPhase1.push({
|
|
3211
3179
|
cache: filterDuplicateKeys(preCompleted, phase1Pairs),
|
|
3212
3180
|
excludedSourceFields: excludedSourceFields.size > 0 ? excludedSourceFields : void 0
|
|
@@ -3225,7 +3193,7 @@ function merge(...args) {
|
|
|
3225
3193
|
const parser = parsers[i];
|
|
3226
3194
|
const parserState = extractCompleteState(parser, resolvedState, i);
|
|
3227
3195
|
const { cache: asyncCache, excludedSourceFields } = perChildPhase1[i];
|
|
3228
|
-
const childCompleteExec = withChildExecPath(childExec, i);
|
|
3196
|
+
const childCompleteExec = require_execution_context.withChildExecPath(childExec, i);
|
|
3229
3197
|
const completeExec = excludedSourceFields == null ? {
|
|
3230
3198
|
...childCompleteExec,
|
|
3231
3199
|
preCompletedByParser: asyncCache
|
|
@@ -3287,7 +3255,7 @@ function merge(...args) {
|
|
|
3287
3255
|
const pairs = parser[fieldParsersKey];
|
|
3288
3256
|
const excludedSourceFields = new Set(pairs.map(([field]) => field).filter((field) => duplicateFieldNames.has(field)));
|
|
3289
3257
|
const phase1Pairs = filterExcludedFieldParsers(pairs, excludedSourceFields);
|
|
3290
|
-
const preCompleted = preCompleteAndRegisterDependencies(state, phase1Pairs, runtime.registry, withChildExecPath(childExec, i));
|
|
3258
|
+
const preCompleted = preCompleteAndRegisterDependencies(state, phase1Pairs, runtime.registry, require_execution_context.withChildExecPath(childExec, i));
|
|
3291
3259
|
return {
|
|
3292
3260
|
cache: filterDuplicateKeys(preCompleted, phase1Pairs),
|
|
3293
3261
|
excludedSourceFields: excludedSourceFields.size > 0 ? excludedSourceFields : void 0
|
|
@@ -3308,7 +3276,7 @@ function merge(...args) {
|
|
|
3308
3276
|
const parser = syncParsers[i];
|
|
3309
3277
|
const parserState = extractMergeCompleteState(parser, resolvedState, i);
|
|
3310
3278
|
const { cache, excludedSourceFields } = perChildPhase1[i];
|
|
3311
|
-
const childCompleteExec = withChildExecPath(childExec, i);
|
|
3279
|
+
const childCompleteExec = require_execution_context.withChildExecPath(childExec, i);
|
|
3312
3280
|
const completeExec = excludedSourceFields == null ? {
|
|
3313
3281
|
...childCompleteExec,
|
|
3314
3282
|
preCompletedByParser: cache
|
|
@@ -3352,7 +3320,7 @@ function merge(...args) {
|
|
|
3352
3320
|
const pairs = parser[fieldParsersKey];
|
|
3353
3321
|
const excludedSourceFields = new Set(pairs.map(([field]) => field).filter((field) => duplicateFieldNames.has(field)));
|
|
3354
3322
|
const phase1Pairs = filterExcludedFieldParsers(pairs, excludedSourceFields);
|
|
3355
|
-
const preCompleted = await preCompleteAndRegisterDependenciesAsync(state, phase1Pairs, runtime.registry, withChildExecPath(childExec, i));
|
|
3323
|
+
const preCompleted = await preCompleteAndRegisterDependenciesAsync(state, phase1Pairs, runtime.registry, require_execution_context.withChildExecPath(childExec, i));
|
|
3356
3324
|
perChildPhase1.push({
|
|
3357
3325
|
cache: filterDuplicateKeys(preCompleted, phase1Pairs),
|
|
3358
3326
|
excludedSourceFields: excludedSourceFields.size > 0 ? excludedSourceFields : void 0
|
|
@@ -3372,7 +3340,7 @@ function merge(...args) {
|
|
|
3372
3340
|
const parser = parsers[i];
|
|
3373
3341
|
const parserState = extractMergeCompleteState(parser, resolvedState, i);
|
|
3374
3342
|
const { cache: asyncCache, excludedSourceFields } = perChildPhase1[i];
|
|
3375
|
-
const childCompleteExec = withChildExecPath(childExec, i);
|
|
3343
|
+
const childCompleteExec = require_execution_context.withChildExecPath(childExec, i);
|
|
3376
3344
|
const completeExec = excludedSourceFields == null ? {
|
|
3377
3345
|
...childCompleteExec,
|
|
3378
3346
|
preCompletedByParser: asyncCache
|
|
@@ -3447,7 +3415,7 @@ function merge(...args) {
|
|
|
3447
3415
|
for (let i = 0; i < parsers.length; i++) {
|
|
3448
3416
|
const parser = parsers[i];
|
|
3449
3417
|
const parserState = extractState(parser, i);
|
|
3450
|
-
const childContext = withChildContext(contextWithRegistry$1, i, parserState, parser);
|
|
3418
|
+
const childContext = withChildContext$1(contextWithRegistry$1, i, parserState, parser);
|
|
3451
3419
|
const excludedSourceFields = perChildExcludedSourceFields$1[i];
|
|
3452
3420
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
3453
3421
|
const childRuntime = require_dependency_runtime.createDependencyRuntimeContext(runtime$1.registry.clone());
|
|
@@ -3461,7 +3429,7 @@ function merge(...args) {
|
|
|
3461
3429
|
};
|
|
3462
3430
|
})();
|
|
3463
3431
|
const parserSuggestions = parser.suggest(contextForChild, prefix);
|
|
3464
|
-
if (parser
|
|
3432
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
3465
3433
|
else suggestions.push(...parserSuggestions);
|
|
3466
3434
|
}
|
|
3467
3435
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -3488,7 +3456,7 @@ function merge(...args) {
|
|
|
3488
3456
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
3489
3457
|
const parser = syncParsers[i];
|
|
3490
3458
|
const parserState = extractState(parser, i);
|
|
3491
|
-
const childContext = withChildContext(contextWithRegistry, i, parserState, parser);
|
|
3459
|
+
const childContext = withChildContext$1(contextWithRegistry, i, parserState, parser);
|
|
3492
3460
|
const excludedSourceFields = perChildExcludedSourceFields[i];
|
|
3493
3461
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
3494
3462
|
const childRuntime = require_dependency_runtime.createDependencyRuntimeContext(runtime.registry.clone());
|
|
@@ -3749,14 +3717,14 @@ function tryParseSuggestList(context, stateArray, parsers, matchedParsers, remai
|
|
|
3749
3717
|
for (let ri = 0; ri < remaining.length; ri++) {
|
|
3750
3718
|
const [parser, index] = remaining[ri];
|
|
3751
3719
|
const parserState = index < stateArray.length ? stateArray[index] : parser.initialState;
|
|
3752
|
-
const resultOrPromise = parser.parse(withChildContext(context, index, parserState, parser));
|
|
3720
|
+
const resultOrPromise = parser.parse(withChildContext$1(context, index, parserState, parser));
|
|
3753
3721
|
if (resultOrPromise != null && typeof resultOrPromise === "object" && "then" in resultOrPromise && typeof resultOrPromise.then === "function") {
|
|
3754
3722
|
const tail = remaining.slice(ri + 1);
|
|
3755
3723
|
return resultOrPromise.then((result$1) => {
|
|
3756
3724
|
if (result$1.success && result$1.consumed.length > 0) {
|
|
3757
3725
|
stateArray[index] = require_annotation_state.getWrappedChildState(context.state, result$1.next.state, parser);
|
|
3758
3726
|
matchedParsers.add(index);
|
|
3759
|
-
const mergedExec = mergeChildExec(context.exec, result$1.next.exec);
|
|
3727
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, result$1.next.exec);
|
|
3760
3728
|
return preParseSuggestLoop({
|
|
3761
3729
|
...context,
|
|
3762
3730
|
buffer: result$1.next.buffer,
|
|
@@ -3783,7 +3751,7 @@ function tryParseSuggestList(context, stateArray, parsers, matchedParsers, remai
|
|
|
3783
3751
|
if (result.success && result.consumed.length > 0) {
|
|
3784
3752
|
stateArray[index] = require_annotation_state.getWrappedChildState(context.state, result.next.state, parser);
|
|
3785
3753
|
matchedParsers.add(index);
|
|
3786
|
-
const mergedExec = mergeChildExec(context.exec, result.next.exec);
|
|
3754
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
3787
3755
|
return {
|
|
3788
3756
|
...context,
|
|
3789
3757
|
buffer: result.next.buffer,
|
|
@@ -3801,7 +3769,7 @@ function tryParseSuggestList(context, stateArray, parsers, matchedParsers, remai
|
|
|
3801
3769
|
function concat(...parsers) {
|
|
3802
3770
|
if (parsers.length < 1) throw new TypeError("concat() requires at least one parser argument.");
|
|
3803
3771
|
assertParsers(parsers, "concat()");
|
|
3804
|
-
const combinedMode = parsers.some((p) => p
|
|
3772
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
3805
3773
|
const isAsync = combinedMode === "async";
|
|
3806
3774
|
const syncParsers = parsers;
|
|
3807
3775
|
const initialState = parsers.map((parser) => parser.initialState);
|
|
@@ -3818,10 +3786,10 @@ function concat(...parsers) {
|
|
|
3818
3786
|
const stateArray = currentContext.state;
|
|
3819
3787
|
const remainingParsers = syncParsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
3820
3788
|
for (const [parser, index] of remainingParsers) {
|
|
3821
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3789
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3822
3790
|
if (result.success && result.consumed.length > 0) {
|
|
3823
3791
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3824
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3792
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3825
3793
|
currentContext = {
|
|
3826
3794
|
...currentContext,
|
|
3827
3795
|
buffer: result.next.buffer,
|
|
@@ -3839,10 +3807,10 @@ function concat(...parsers) {
|
|
|
3839
3807
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
3840
3808
|
}
|
|
3841
3809
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
3842
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3810
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3843
3811
|
if (result.success && result.consumed.length < 1) {
|
|
3844
3812
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3845
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3813
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3846
3814
|
currentContext = {
|
|
3847
3815
|
...currentContext,
|
|
3848
3816
|
state: newStateArray,
|
|
@@ -3884,10 +3852,10 @@ function concat(...parsers) {
|
|
|
3884
3852
|
const stateArray = currentContext.state;
|
|
3885
3853
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
3886
3854
|
for (const [parser, index] of remainingParsers) {
|
|
3887
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3855
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3888
3856
|
if (result.success && result.consumed.length > 0) {
|
|
3889
3857
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3890
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3858
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3891
3859
|
currentContext = {
|
|
3892
3860
|
...currentContext,
|
|
3893
3861
|
buffer: result.next.buffer,
|
|
@@ -3905,10 +3873,10 @@ function concat(...parsers) {
|
|
|
3905
3873
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
3906
3874
|
}
|
|
3907
3875
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
3908
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3876
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3909
3877
|
if (result.success && result.consumed.length < 1) {
|
|
3910
3878
|
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3911
|
-
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3879
|
+
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3912
3880
|
currentContext = {
|
|
3913
3881
|
...currentContext,
|
|
3914
3882
|
state: newStateArray,
|
|
@@ -3959,7 +3927,7 @@ function concat(...parsers) {
|
|
|
3959
3927
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
3960
3928
|
const parser = syncParsers[i];
|
|
3961
3929
|
const preCompletedResult = preCompleted.get(String(i));
|
|
3962
|
-
const result = preCompletedResult !== void 0 ? unwrapCompleteResult(preCompletedResult) : unwrapCompleteResult(parser.complete(prepareStateForCompletion(resolvedArray[i], parser), withChildExecPath(phase3Exec, i)));
|
|
3930
|
+
const result = preCompletedResult !== void 0 ? unwrapCompleteResult(preCompletedResult) : unwrapCompleteResult(parser.complete(prepareStateForCompletion(resolvedArray[i], parser), require_execution_context.withChildExecPath(phase3Exec, i)));
|
|
3963
3931
|
if (!result.success) return result;
|
|
3964
3932
|
const baseIndex = results.length;
|
|
3965
3933
|
if (Array.isArray(result.value)) {
|
|
@@ -4009,7 +3977,7 @@ function concat(...parsers) {
|
|
|
4009
3977
|
for (let i = 0; i < parsers.length; i++) {
|
|
4010
3978
|
const parser = parsers[i];
|
|
4011
3979
|
const preCompletedResult = preCompleted.get(String(i));
|
|
4012
|
-
const result = preCompletedResult !== void 0 ? unwrapCompleteResult(preCompletedResult) : unwrapCompleteResult(await parser.complete(prepareStateForCompletion(resolvedArray[i], parser), withChildExecPath(phase3Exec, i)));
|
|
3980
|
+
const result = preCompletedResult !== void 0 ? unwrapCompleteResult(preCompletedResult) : unwrapCompleteResult(await parser.complete(prepareStateForCompletion(resolvedArray[i], parser), require_execution_context.withChildExecPath(phase3Exec, i)));
|
|
4013
3981
|
if (!result.success) return result;
|
|
4014
3982
|
const baseIndex = results.length;
|
|
4015
3983
|
if (Array.isArray(result.value)) {
|
|
@@ -4038,7 +4006,7 @@ function concat(...parsers) {
|
|
|
4038
4006
|
};
|
|
4039
4007
|
};
|
|
4040
4008
|
const concatParser = {
|
|
4041
|
-
|
|
4009
|
+
mode: combinedMode,
|
|
4042
4010
|
$valueType: [],
|
|
4043
4011
|
$stateType: [],
|
|
4044
4012
|
priority: parsers.length > 0 ? Math.max(...parsers.map((p) => p.priority)) : 0,
|
|
@@ -4074,7 +4042,7 @@ function concat(...parsers) {
|
|
|
4074
4042
|
let hasAnySeed = false;
|
|
4075
4043
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
4076
4044
|
const parser = syncParsers[i];
|
|
4077
|
-
const childExec$1 = withChildExecPath(phase3Exec, i);
|
|
4045
|
+
const childExec$1 = require_execution_context.withChildExecPath(phase3Exec, i);
|
|
4078
4046
|
const preCompletedResult = preCompleted.get(String(i));
|
|
4079
4047
|
const seed = preCompletedResult !== void 0 ? reusePreCompletedPhase2Seed(parser, prepareStateForCompletion(resolvedArray[i], parser), preCompletedResult, childExec$1) : require_phase2_seed.completeOrExtractPhase2Seed(parser, prepareStateForCompletion(resolvedArray[i], parser), childExec$1);
|
|
4080
4048
|
if (seed == null) continue;
|
|
@@ -4108,7 +4076,7 @@ function concat(...parsers) {
|
|
|
4108
4076
|
let hasAnySeed = false;
|
|
4109
4077
|
for (let i = 0; i < parsers.length; i++) {
|
|
4110
4078
|
const parser = parsers[i];
|
|
4111
|
-
const childExec$1 = withChildExecPath(phase3Exec, i);
|
|
4079
|
+
const childExec$1 = require_execution_context.withChildExecPath(phase3Exec, i);
|
|
4112
4080
|
const preCompletedResult = preCompleted.get(String(i));
|
|
4113
4081
|
const seed = preCompletedResult !== void 0 ? await reusePreCompletedPhase2SeedAsync(parser, prepareStateForCompletion(resolvedArray[i], parser), preCompletedResult, childExec$1) : await require_phase2_seed.completeOrExtractPhase2Seed(parser, prepareStateForCompletion(resolvedArray[i], parser), childExec$1);
|
|
4114
4082
|
if (seed == null) continue;
|
|
@@ -4133,8 +4101,8 @@ function concat(...parsers) {
|
|
|
4133
4101
|
for (let i = 0; i < parsers.length; i++) {
|
|
4134
4102
|
const parser = parsers[i];
|
|
4135
4103
|
const parserState = stateArray$1 && Array.isArray(stateArray$1) ? stateArray$1[i] : parser.initialState;
|
|
4136
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry$1, i, parserState, parser), prefix);
|
|
4137
|
-
if (parser
|
|
4104
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry$1, i, parserState, parser), prefix);
|
|
4105
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
4138
4106
|
else suggestions.push(...parserSuggestions);
|
|
4139
4107
|
}
|
|
4140
4108
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -4146,7 +4114,7 @@ function concat(...parsers) {
|
|
|
4146
4114
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
4147
4115
|
const parser = syncParsers[i];
|
|
4148
4116
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[i] : parser.initialState;
|
|
4149
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry, i, parserState, parser), prefix);
|
|
4117
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, i, parserState, parser), prefix);
|
|
4150
4118
|
suggestions.push(...parserSuggestions);
|
|
4151
4119
|
}
|
|
4152
4120
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -4184,7 +4152,7 @@ function concat(...parsers) {
|
|
|
4184
4152
|
function group(label, parser, options = {}) {
|
|
4185
4153
|
require_validate.validateLabel(label);
|
|
4186
4154
|
const groupParser = {
|
|
4187
|
-
|
|
4155
|
+
mode: parser.mode,
|
|
4188
4156
|
$valueType: parser.$valueType,
|
|
4189
4157
|
$stateType: parser.$stateType,
|
|
4190
4158
|
priority: parser.priority,
|
|
@@ -4204,7 +4172,7 @@ function group(label, parser, options = {}) {
|
|
|
4204
4172
|
parse: (context) => parser.parse(context),
|
|
4205
4173
|
complete: (state, exec) => parser.complete(state, exec),
|
|
4206
4174
|
suggest: (context, prefix) => {
|
|
4207
|
-
if (options.hidden === true) return require_mode_dispatch.dispatchIterableByMode(parser
|
|
4175
|
+
if (options.hidden === true) return require_mode_dispatch.dispatchIterableByMode(parser.mode, function* () {}, async function* () {});
|
|
4208
4176
|
return parser.suggest(context, prefix);
|
|
4209
4177
|
},
|
|
4210
4178
|
getDocFragments: (state, defaultValue) => {
|
|
@@ -4330,7 +4298,7 @@ function group(label, parser, options = {}) {
|
|
|
4330
4298
|
function conditional(discriminator, branches, defaultBranch, options) {
|
|
4331
4299
|
const branchParsers = Object.entries(branches);
|
|
4332
4300
|
const allBranchParsers = defaultBranch ? [...branchParsers.map(([_, p]) => p), defaultBranch] : branchParsers.map(([_, p]) => p);
|
|
4333
|
-
const combinedMode = discriminator
|
|
4301
|
+
const combinedMode = discriminator.mode === "async" || allBranchParsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
4334
4302
|
const isAsync = combinedMode === "async";
|
|
4335
4303
|
const maxPriority = Math.max(discriminator.priority, ...allBranchParsers.map((p) => p.priority));
|
|
4336
4304
|
function appendLiteralToUsage(usage$1, literalValue) {
|
|
@@ -4381,9 +4349,9 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4381
4349
|
const syncDefaultBranch = defaultBranch;
|
|
4382
4350
|
if (state.selectedBranch !== void 0) {
|
|
4383
4351
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
4384
|
-
const branchResult = branchParser.parse(withChildContext(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4352
|
+
const branchResult = branchParser.parse(withChildContext$1(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4385
4353
|
if (branchResult.success) {
|
|
4386
|
-
const mergedExec = mergeChildExec(context.exec, branchResult.next.exec);
|
|
4354
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, branchResult.next.exec);
|
|
4387
4355
|
return {
|
|
4388
4356
|
success: true,
|
|
4389
4357
|
next: {
|
|
@@ -4402,17 +4370,17 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4402
4370
|
}
|
|
4403
4371
|
return branchResult;
|
|
4404
4372
|
}
|
|
4405
|
-
const discriminatorResult = syncDiscriminator.parse({ ...withChildContext(context, "_discriminator", state.discriminatorState, syncDiscriminator) });
|
|
4373
|
+
const discriminatorResult = syncDiscriminator.parse({ ...withChildContext$1(context, "_discriminator", state.discriminatorState, syncDiscriminator) });
|
|
4406
4374
|
if (discriminatorResult.success) {
|
|
4407
4375
|
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, syncDiscriminator);
|
|
4408
|
-
const completionResult = syncDiscriminator.complete(annotatedDiscriminatorState, withChildExecPath(context.exec, "_discriminator"));
|
|
4376
|
+
const completionResult = syncDiscriminator.complete(annotatedDiscriminatorState, require_execution_context.withChildExecPath(context.exec, "_discriminator"));
|
|
4409
4377
|
if (completionResult.success) {
|
|
4410
4378
|
const value = completionResult.value;
|
|
4411
4379
|
const branchParser = syncBranches[value];
|
|
4412
4380
|
if (branchParser) {
|
|
4413
|
-
const discriminatorExec = mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4381
|
+
const discriminatorExec = require_execution_context.mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4414
4382
|
const branchParseResult = branchParser.parse({
|
|
4415
|
-
...withChildContext({
|
|
4383
|
+
...withChildContext$1({
|
|
4416
4384
|
...context,
|
|
4417
4385
|
...discriminatorExec != null ? {
|
|
4418
4386
|
exec: discriminatorExec,
|
|
@@ -4423,7 +4391,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4423
4391
|
optionsTerminated: discriminatorResult.next.optionsTerminated
|
|
4424
4392
|
});
|
|
4425
4393
|
if (branchParseResult.success) {
|
|
4426
|
-
const mergedExec = mergeChildExec(discriminatorExec, branchParseResult.next.exec);
|
|
4394
|
+
const mergedExec = require_execution_context.mergeChildExec(discriminatorExec, branchParseResult.next.exec);
|
|
4427
4395
|
const isProvisional = branchParseResult.provisional || discriminatorResult.consumed.length === 0 && branchParseResult.consumed.length === 0 && (branchParser.leadingNames.size > 0 || branchParser.acceptingAnyToken);
|
|
4428
4396
|
return {
|
|
4429
4397
|
success: true,
|
|
@@ -4478,9 +4446,9 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4478
4446
|
}
|
|
4479
4447
|
const discriminatorConsumed = discriminatorResult.success ? discriminatorResult.consumed.length : discriminatorResult.consumed;
|
|
4480
4448
|
if (syncDefaultBranch !== void 0) {
|
|
4481
|
-
const defaultResult = syncDefaultBranch.parse(withChildContext(context, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch, syncDefaultBranch.usage));
|
|
4449
|
+
const defaultResult = syncDefaultBranch.parse(withChildContext$1(context, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch, syncDefaultBranch.usage));
|
|
4482
4450
|
if (defaultResult.success && (defaultResult.consumed.length > 0 || discriminatorConsumed === 0 && context.buffer.length === 0)) {
|
|
4483
|
-
const mergedExec = mergeChildExec(context.exec, defaultResult.next.exec);
|
|
4451
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, defaultResult.next.exec);
|
|
4484
4452
|
const commitDefault = defaultResult.consumed.length > 0 || context.buffer.length === 0;
|
|
4485
4453
|
return {
|
|
4486
4454
|
success: true,
|
|
@@ -4512,9 +4480,9 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4512
4480
|
const state = context.state ?? initialState;
|
|
4513
4481
|
if (state.selectedBranch !== void 0) {
|
|
4514
4482
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
4515
|
-
const branchResult = await branchParser.parse(withChildContext(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4483
|
+
const branchResult = await branchParser.parse(withChildContext$1(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4516
4484
|
if (branchResult.success) {
|
|
4517
|
-
const mergedExec = mergeChildExec(context.exec, branchResult.next.exec);
|
|
4485
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, branchResult.next.exec);
|
|
4518
4486
|
return {
|
|
4519
4487
|
success: true,
|
|
4520
4488
|
...state.speculative || branchResult.provisional ? { provisional: true } : {},
|
|
@@ -4534,10 +4502,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4534
4502
|
}
|
|
4535
4503
|
return branchResult;
|
|
4536
4504
|
}
|
|
4537
|
-
const discriminatorResult = await discriminator.parse({ ...withChildContext(context, "_discriminator", state.discriminatorState, discriminator) });
|
|
4505
|
+
const discriminatorResult = await discriminator.parse({ ...withChildContext$1(context, "_discriminator", state.discriminatorState, discriminator) });
|
|
4538
4506
|
if (discriminatorResult.success) {
|
|
4539
|
-
if (discriminatorResult.consumed.length === 0 && discriminator
|
|
4540
|
-
const discriminatorExec = mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4507
|
+
if (discriminatorResult.consumed.length === 0 && discriminator.mode === "async") {
|
|
4508
|
+
const discriminatorExec = require_execution_context.mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4541
4509
|
const speculationContext = {
|
|
4542
4510
|
...context,
|
|
4543
4511
|
buffer: discriminatorResult.next.buffer,
|
|
@@ -4553,7 +4521,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4553
4521
|
let speculativeError;
|
|
4554
4522
|
let ambiguous = false;
|
|
4555
4523
|
for (const [key, bp] of branchParsers) {
|
|
4556
|
-
const branchResult = await bp.parse(withChildContext(speculationContext, "_branch", bp.initialState, bp, bp.usage));
|
|
4524
|
+
const branchResult = await bp.parse(withChildContext$1(speculationContext, "_branch", bp.initialState, bp, bp.usage));
|
|
4557
4525
|
if (branchResult.success && branchResult.consumed.length > 0) {
|
|
4558
4526
|
if (branchResult.provisional) {
|
|
4559
4527
|
if (provisionalHit == null && !provisionalAmbiguous) provisionalHit = {
|
|
@@ -4585,7 +4553,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4585
4553
|
const { key, bp, result: branchResult } = speculativeHit;
|
|
4586
4554
|
if (branchResult.success) {
|
|
4587
4555
|
const annotatedDiscriminatorState$2 = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, discriminator);
|
|
4588
|
-
const mergedExec = mergeChildExec(discriminatorExec, branchResult.next.exec);
|
|
4556
|
+
const mergedExec = require_execution_context.mergeChildExec(discriminatorExec, branchResult.next.exec);
|
|
4589
4557
|
return {
|
|
4590
4558
|
success: true,
|
|
4591
4559
|
provisional: true,
|
|
@@ -4612,9 +4580,9 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4612
4580
|
}
|
|
4613
4581
|
let deferredBranchState = state.branchState;
|
|
4614
4582
|
if (defaultBranch !== void 0 && !ambiguous && !provisionalAmbiguous) {
|
|
4615
|
-
const defaultResult = await defaultBranch.parse(withChildContext(speculationContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4583
|
+
const defaultResult = await defaultBranch.parse(withChildContext$1(speculationContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4616
4584
|
if (defaultResult.success && defaultResult.consumed.length > 0) {
|
|
4617
|
-
const defaultExec = mergeChildExec(discriminatorExec ?? context.exec, defaultResult.next.exec);
|
|
4585
|
+
const defaultExec = require_execution_context.mergeChildExec(discriminatorExec ?? context.exec, defaultResult.next.exec);
|
|
4618
4586
|
return {
|
|
4619
4587
|
success: true,
|
|
4620
4588
|
...defaultResult.provisional ? { provisional: true } : {},
|
|
@@ -4653,14 +4621,14 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4653
4621
|
};
|
|
4654
4622
|
}
|
|
4655
4623
|
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, discriminator);
|
|
4656
|
-
const completionResult = await discriminator.complete(annotatedDiscriminatorState, withChildExecPath(context.exec, "_discriminator"));
|
|
4624
|
+
const completionResult = await discriminator.complete(annotatedDiscriminatorState, require_execution_context.withChildExecPath(context.exec, "_discriminator"));
|
|
4657
4625
|
if (completionResult.success) {
|
|
4658
4626
|
const value = completionResult.value;
|
|
4659
4627
|
const branchParser = branches[value];
|
|
4660
4628
|
if (branchParser) {
|
|
4661
|
-
const discriminatorExec = mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4629
|
+
const discriminatorExec = require_execution_context.mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4662
4630
|
const branchParseResult = await branchParser.parse({
|
|
4663
|
-
...withChildContext({
|
|
4631
|
+
...withChildContext$1({
|
|
4664
4632
|
...context,
|
|
4665
4633
|
...discriminatorExec != null ? {
|
|
4666
4634
|
exec: discriminatorExec,
|
|
@@ -4671,7 +4639,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4671
4639
|
optionsTerminated: discriminatorResult.next.optionsTerminated
|
|
4672
4640
|
});
|
|
4673
4641
|
if (branchParseResult.success) {
|
|
4674
|
-
const mergedExec = mergeChildExec(discriminatorExec, branchParseResult.next.exec);
|
|
4642
|
+
const mergedExec = require_execution_context.mergeChildExec(discriminatorExec, branchParseResult.next.exec);
|
|
4675
4643
|
return {
|
|
4676
4644
|
success: true,
|
|
4677
4645
|
...branchParseResult.provisional || discriminatorResult.consumed.length === 0 && branchParseResult.consumed.length === 0 && (branchParser.leadingNames.size > 0 || branchParser.acceptingAnyToken) ? { provisional: true } : {},
|
|
@@ -4725,9 +4693,9 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4725
4693
|
}
|
|
4726
4694
|
const discriminatorConsumed = discriminatorResult.success ? discriminatorResult.consumed.length : discriminatorResult.consumed;
|
|
4727
4695
|
if (defaultBranch !== void 0) {
|
|
4728
|
-
const defaultResult = await defaultBranch.parse(withChildContext(context, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4696
|
+
const defaultResult = await defaultBranch.parse(withChildContext$1(context, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4729
4697
|
if (defaultResult.success && (defaultResult.consumed.length > 0 || discriminatorConsumed === 0 && context.buffer.length === 0)) {
|
|
4730
|
-
const mergedExec = mergeChildExec(context.exec, defaultResult.next.exec);
|
|
4698
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, defaultResult.next.exec);
|
|
4731
4699
|
const commitDefault = defaultResult.consumed.length > 0 || context.buffer.length === 0;
|
|
4732
4700
|
return {
|
|
4733
4701
|
success: true,
|
|
@@ -4762,12 +4730,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4762
4730
|
if (state.selectedBranch === void 0) {
|
|
4763
4731
|
{
|
|
4764
4732
|
const annotatedDiscriminatorStateForDeferred = require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
4765
|
-
const deferredDiscriminatorResult = unwrapCompleteResult(syncDiscriminator.complete(annotatedDiscriminatorStateForDeferred, withChildExecPath(exec, "_discriminator")));
|
|
4733
|
+
const deferredDiscriminatorResult = unwrapCompleteResult(syncDiscriminator.complete(annotatedDiscriminatorStateForDeferred, require_execution_context.withChildExecPath(exec, "_discriminator")));
|
|
4766
4734
|
if (deferredDiscriminatorResult.success) {
|
|
4767
4735
|
const deferredValue = deferredDiscriminatorResult.value;
|
|
4768
4736
|
const deferredBranch = syncBranches[deferredValue];
|
|
4769
4737
|
if (deferredBranch) {
|
|
4770
|
-
const branchExec = withChildExecPath(exec, "_branch");
|
|
4738
|
+
const branchExec = require_execution_context.withChildExecPath(exec, "_branch");
|
|
4771
4739
|
const emptyCtx = {
|
|
4772
4740
|
buffer: [],
|
|
4773
4741
|
optionsTerminated: false,
|
|
@@ -4805,7 +4773,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4805
4773
|
}
|
|
4806
4774
|
if (syncDefaultBranch !== void 0) {
|
|
4807
4775
|
const branchState = require_annotation_state.getWrappedChildState(state, state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch);
|
|
4808
|
-
const defaultResult = unwrapCompleteResult(syncDefaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
4776
|
+
const defaultResult = unwrapCompleteResult(syncDefaultBranch.complete(branchState, require_execution_context.withChildExecPath(exec, "_branch")));
|
|
4809
4777
|
if (!defaultResult.success) return defaultResult;
|
|
4810
4778
|
return {
|
|
4811
4779
|
success: true,
|
|
@@ -4842,8 +4810,8 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4842
4810
|
dependencyRegistry: runtime.registry
|
|
4843
4811
|
};
|
|
4844
4812
|
const needsDiscriminatorCompletion = state.selectedBranch.kind !== "default" && !(state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key);
|
|
4845
|
-
const discriminatorCompleteResult = needsDiscriminatorCompletion ? syncDiscriminator.complete(annotatedDiscriminatorState, withChildExecPath(completionExec, "_discriminator")) : void 0;
|
|
4846
|
-
const branchResult = unwrapCompleteResult(branchParser.complete(resolvedBranchState, withChildExecPath(completionExec, "_branch")));
|
|
4813
|
+
const discriminatorCompleteResult = needsDiscriminatorCompletion ? syncDiscriminator.complete(annotatedDiscriminatorState, require_execution_context.withChildExecPath(completionExec, "_discriminator")) : void 0;
|
|
4814
|
+
const branchResult = unwrapCompleteResult(branchParser.complete(resolvedBranchState, require_execution_context.withChildExecPath(completionExec, "_branch")));
|
|
4847
4815
|
if (!branchResult.success) {
|
|
4848
4816
|
if (state.discriminatorValue !== void 0 && options?.errors?.branchError) return {
|
|
4849
4817
|
success: false,
|
|
@@ -4882,12 +4850,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4882
4850
|
if (state.selectedBranch === void 0) {
|
|
4883
4851
|
if (exec?.phase !== "parse" && exec?.phase !== "suggest") {
|
|
4884
4852
|
const annotatedDiscriminatorStateForDeferred = require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
4885
|
-
const deferredDiscriminatorResult = unwrapCompleteResult(await discriminator.complete(annotatedDiscriminatorStateForDeferred, withChildExecPath(exec, "_discriminator")));
|
|
4853
|
+
const deferredDiscriminatorResult = unwrapCompleteResult(await discriminator.complete(annotatedDiscriminatorStateForDeferred, require_execution_context.withChildExecPath(exec, "_discriminator")));
|
|
4886
4854
|
if (deferredDiscriminatorResult.success) {
|
|
4887
4855
|
const deferredValue = deferredDiscriminatorResult.value;
|
|
4888
4856
|
const deferredBranch = branches[deferredValue];
|
|
4889
4857
|
if (deferredBranch) {
|
|
4890
|
-
const branchExec = withChildExecPath(exec, "_branch");
|
|
4858
|
+
const branchExec = require_execution_context.withChildExecPath(exec, "_branch");
|
|
4891
4859
|
const emptyCtx = {
|
|
4892
4860
|
buffer: [],
|
|
4893
4861
|
optionsTerminated: false,
|
|
@@ -4929,7 +4897,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4929
4897
|
};
|
|
4930
4898
|
if (defaultBranch !== void 0) {
|
|
4931
4899
|
const branchState = require_annotation_state.getWrappedChildState(state, state.branchState ?? defaultBranch.initialState, defaultBranch);
|
|
4932
|
-
const defaultResult = unwrapCompleteResult(await defaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
4900
|
+
const defaultResult = unwrapCompleteResult(await defaultBranch.complete(branchState, require_execution_context.withChildExecPath(exec, "_branch")));
|
|
4933
4901
|
if (!defaultResult.success) return defaultResult;
|
|
4934
4902
|
return {
|
|
4935
4903
|
success: true,
|
|
@@ -4977,7 +4945,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4977
4945
|
dependencyRegistry: discOnlyRuntime.registry
|
|
4978
4946
|
};
|
|
4979
4947
|
}
|
|
4980
|
-
const discriminatorCompleteResult = needsDiscriminatorCompletion ? await discriminator.complete(annotatedDiscriminatorState, withChildExecPath(discriminatorCompletionExec, "_discriminator")) : void 0;
|
|
4948
|
+
const discriminatorCompleteResult = needsDiscriminatorCompletion ? await discriminator.complete(annotatedDiscriminatorState, require_execution_context.withChildExecPath(discriminatorCompletionExec, "_discriminator")) : void 0;
|
|
4981
4949
|
let discriminatorValue;
|
|
4982
4950
|
if (state.selectedBranch.kind === "default") discriminatorValue = void 0;
|
|
4983
4951
|
else if (state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key) discriminatorValue = state.discriminatorValue;
|
|
@@ -4996,7 +4964,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4996
4964
|
};
|
|
4997
4965
|
}
|
|
4998
4966
|
const resolvedBranchState = require_annotation_state.getWrappedChildState(state, await require_dependency_runtime.resolveStateWithRuntimeAsync(state.branchState, runtime), branchParser);
|
|
4999
|
-
const branchResult = unwrapCompleteResult(await branchParser.complete(resolvedBranchState, withChildExecPath(completionExec, "_branch")));
|
|
4967
|
+
const branchResult = unwrapCompleteResult(await branchParser.complete(resolvedBranchState, require_execution_context.withChildExecPath(completionExec, "_branch")));
|
|
5000
4968
|
if (!branchResult.success) {
|
|
5001
4969
|
if (discriminatorValue !== void 0 && options?.errors?.branchError) return {
|
|
5002
4970
|
success: false,
|
|
@@ -5014,12 +4982,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5014
4982
|
};
|
|
5015
4983
|
};
|
|
5016
4984
|
const getConditionalBranchSeedSync = (currentState, branchParser, branchState, exec) => {
|
|
5017
|
-
const branchExec = withChildExecPath(exec, "_branch");
|
|
4985
|
+
const branchExec = require_execution_context.withChildExecPath(exec, "_branch");
|
|
5018
4986
|
const annotatedState = require_annotation_state.getWrappedChildState(currentState, branchState, branchParser);
|
|
5019
4987
|
return extractOrCompletePhase2SeedSync(branchParser, annotatedState, branchExec);
|
|
5020
4988
|
};
|
|
5021
4989
|
const getConditionalBranchSeedAsync = async (currentState, branchParser, branchState, exec) => {
|
|
5022
|
-
const branchExec = withChildExecPath(exec, "_branch");
|
|
4990
|
+
const branchExec = require_execution_context.withChildExecPath(exec, "_branch");
|
|
5023
4991
|
const annotatedState = require_annotation_state.getWrappedChildState(currentState, branchState, branchParser);
|
|
5024
4992
|
return await extractOrCompletePhase2SeedAsync(branchParser, annotatedState, branchExec);
|
|
5025
4993
|
};
|
|
@@ -5046,16 +5014,16 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5046
5014
|
dependencyRegistry: runtime.registry
|
|
5047
5015
|
} } : {}
|
|
5048
5016
|
};
|
|
5049
|
-
yield* syncDiscriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState, syncDiscriminator), prefix);
|
|
5017
|
+
yield* syncDiscriminator.suggest(withChildContext$1(suggestContext, "_discriminator", state.discriminatorState, syncDiscriminator), prefix);
|
|
5050
5018
|
const annotatedDiscState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
5051
|
-
const discComplete = syncDiscriminator.complete(annotatedDiscState, withChildExecPath(suggestContext.exec ? {
|
|
5019
|
+
const discComplete = syncDiscriminator.complete(annotatedDiscState, require_execution_context.withChildExecPath(suggestContext.exec ? {
|
|
5052
5020
|
...suggestContext.exec,
|
|
5053
5021
|
phase: "suggest"
|
|
5054
5022
|
} : void 0, "_discriminator"));
|
|
5055
5023
|
if (discComplete.success && syncBranches[discComplete.value] !== void 0) {
|
|
5056
5024
|
const resolvedBranch = syncBranches[discComplete.value];
|
|
5057
|
-
yield* resolvedBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5058
|
-
} else if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch), prefix);
|
|
5025
|
+
yield* resolvedBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5026
|
+
} else if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch), prefix);
|
|
5059
5027
|
} else {
|
|
5060
5028
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
5061
5029
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
@@ -5075,7 +5043,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5075
5043
|
dependencyRegistry: runtime.registry
|
|
5076
5044
|
} } : {}
|
|
5077
5045
|
};
|
|
5078
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5046
|
+
yield* branchParser.suggest(withChildContext$1(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5079
5047
|
}
|
|
5080
5048
|
}
|
|
5081
5049
|
async function* suggestAsync(context, prefix) {
|
|
@@ -5098,22 +5066,22 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5098
5066
|
dependencyRegistry: runtime.registry
|
|
5099
5067
|
} } : {}
|
|
5100
5068
|
};
|
|
5101
|
-
yield* discriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState, discriminator), prefix);
|
|
5069
|
+
yield* discriminator.suggest(withChildContext$1(suggestContext, "_discriminator", state.discriminatorState, discriminator), prefix);
|
|
5102
5070
|
let discResolved = false;
|
|
5103
|
-
if (discriminator
|
|
5071
|
+
if (discriminator.mode === "sync") {
|
|
5104
5072
|
const annotatedDiscState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
5105
|
-
const discComplete = discriminator.complete(annotatedDiscState, withChildExecPath(suggestContext.exec ? {
|
|
5073
|
+
const discComplete = discriminator.complete(annotatedDiscState, require_execution_context.withChildExecPath(suggestContext.exec ? {
|
|
5106
5074
|
...suggestContext.exec,
|
|
5107
5075
|
phase: "suggest"
|
|
5108
5076
|
} : void 0, "_discriminator"));
|
|
5109
5077
|
if (discComplete.success && branches[discComplete.value] !== void 0) {
|
|
5110
5078
|
const resolvedBranch = branches[discComplete.value];
|
|
5111
|
-
yield* resolvedBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5079
|
+
yield* resolvedBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5112
5080
|
discResolved = true;
|
|
5113
5081
|
}
|
|
5114
5082
|
}
|
|
5115
5083
|
if (!discResolved) {
|
|
5116
|
-
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch), prefix);
|
|
5084
|
+
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch), prefix);
|
|
5117
5085
|
}
|
|
5118
5086
|
} else {
|
|
5119
5087
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
@@ -5134,11 +5102,11 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5134
5102
|
dependencyRegistry: runtime.registry
|
|
5135
5103
|
} } : {}
|
|
5136
5104
|
};
|
|
5137
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5105
|
+
yield* branchParser.suggest(withChildContext$1(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5138
5106
|
}
|
|
5139
5107
|
}
|
|
5140
5108
|
const conditionalParser = {
|
|
5141
|
-
|
|
5109
|
+
mode: combinedMode,
|
|
5142
5110
|
$valueType: [],
|
|
5143
5111
|
$stateType: [],
|
|
5144
5112
|
priority: maxPriority,
|
|
@@ -5159,7 +5127,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5159
5127
|
const syncDiscriminator = discriminator;
|
|
5160
5128
|
const syncDefaultBranch = defaultBranch;
|
|
5161
5129
|
const syncBranches = branches;
|
|
5162
|
-
const discriminatorExec = withChildExecPath(exec, "_discriminator");
|
|
5130
|
+
const discriminatorExec = require_execution_context.withChildExecPath(exec, "_discriminator");
|
|
5163
5131
|
if (state.selectedBranch === void 0) {
|
|
5164
5132
|
const discriminatorSeed$1 = require_phase2_seed.completeOrExtractPhase2Seed(syncDiscriminator, require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator), discriminatorExec);
|
|
5165
5133
|
if (typeof discriminatorSeed$1?.value === "string") {
|
|
@@ -5180,7 +5148,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5180
5148
|
const discriminatorSeed = state.selectedBranch.kind === "default" ? null : state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key ? { value: state.discriminatorValue } : require_phase2_seed.completeOrExtractPhase2Seed(syncDiscriminator, require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator), discriminatorExec) ?? { value: state.selectedBranch.key };
|
|
5181
5149
|
return combineTuplePhase2Seeds(discriminatorSeed, branchSeed);
|
|
5182
5150
|
}, async () => {
|
|
5183
|
-
const discriminatorExec = withChildExecPath(exec, "_discriminator");
|
|
5151
|
+
const discriminatorExec = require_execution_context.withChildExecPath(exec, "_discriminator");
|
|
5184
5152
|
if (state.selectedBranch === void 0) {
|
|
5185
5153
|
const discriminatorSeed$1 = await require_phase2_seed.completeOrExtractPhase2Seed(discriminator, require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator), discriminatorExec);
|
|
5186
5154
|
if (typeof discriminatorSeed$1?.value === "string") {
|