@optique/core 1.0.0-dev.1724 → 1.0.0-dev.1726
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/constructs.cjs +43 -42
- package/dist/constructs.js +43 -42
- package/dist/parser.d.cts +17 -5
- package/dist/parser.d.ts +17 -5
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -872,27 +872,27 @@ function or(...args) {
|
|
|
872
872
|
dependencyRegistry: replayExec.dependencyRegistry
|
|
873
873
|
} : {}
|
|
874
874
|
}, provisionalConsuming.index, checkResult.next.state, provisionalConsuming.parser));
|
|
875
|
-
if (replayedResult.success)
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
875
|
+
if (!replayedResult.success) return replayedResult;
|
|
876
|
+
const mergedExec = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
877
|
+
return {
|
|
878
|
+
success: true,
|
|
879
|
+
provisional: true,
|
|
880
|
+
next: {
|
|
881
|
+
...context,
|
|
882
|
+
buffer: replayedResult.next.buffer,
|
|
883
|
+
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
884
|
+
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, {
|
|
885
|
+
...replayedResult,
|
|
886
|
+
provisional: true,
|
|
887
|
+
consumed: [...previouslyConsumed, ...replayedResult.consumed]
|
|
888
|
+
}),
|
|
889
|
+
...mergedExec != null ? {
|
|
890
|
+
exec: mergedExec,
|
|
891
|
+
dependencyRegistry: mergedExec.dependencyRegistry
|
|
892
|
+
} : {}
|
|
893
|
+
},
|
|
894
|
+
consumed: replayedResult.consumed
|
|
895
|
+
};
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
898
|
}
|
|
@@ -1071,27 +1071,27 @@ function or(...args) {
|
|
|
1071
1071
|
dependencyRegistry: replayExec.dependencyRegistry
|
|
1072
1072
|
} : {}
|
|
1073
1073
|
}, provisionalConsuming.index, checkResult.next.state, provisionalConsuming.parser));
|
|
1074
|
-
if (replayedResult.success)
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1074
|
+
if (!replayedResult.success) return replayedResult;
|
|
1075
|
+
const mergedExec = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
1076
|
+
return {
|
|
1077
|
+
success: true,
|
|
1078
|
+
provisional: true,
|
|
1079
|
+
next: {
|
|
1080
|
+
...context,
|
|
1081
|
+
buffer: replayedResult.next.buffer,
|
|
1082
|
+
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
1083
|
+
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, {
|
|
1084
|
+
...replayedResult,
|
|
1085
|
+
provisional: true,
|
|
1086
|
+
consumed: [...previouslyConsumed, ...replayedResult.consumed]
|
|
1087
|
+
}),
|
|
1088
|
+
...mergedExec != null ? {
|
|
1089
|
+
exec: mergedExec,
|
|
1090
|
+
dependencyRegistry: mergedExec.dependencyRegistry
|
|
1091
|
+
} : {}
|
|
1092
|
+
},
|
|
1093
|
+
consumed: replayedResult.consumed
|
|
1094
|
+
};
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
@@ -4044,6 +4044,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4044
4044
|
const mergedExec = mergeChildExec(context.exec, branchResult.next.exec);
|
|
4045
4045
|
return {
|
|
4046
4046
|
success: true,
|
|
4047
|
+
...state.speculative || branchResult.provisional ? { provisional: true } : {},
|
|
4047
4048
|
next: {
|
|
4048
4049
|
...branchResult.next,
|
|
4049
4050
|
state: {
|
package/dist/constructs.js
CHANGED
|
@@ -872,27 +872,27 @@ function or(...args) {
|
|
|
872
872
|
dependencyRegistry: replayExec.dependencyRegistry
|
|
873
873
|
} : {}
|
|
874
874
|
}, provisionalConsuming.index, checkResult.next.state, provisionalConsuming.parser));
|
|
875
|
-
if (replayedResult.success)
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
875
|
+
if (!replayedResult.success) return replayedResult;
|
|
876
|
+
const mergedExec = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
877
|
+
return {
|
|
878
|
+
success: true,
|
|
879
|
+
provisional: true,
|
|
880
|
+
next: {
|
|
881
|
+
...context,
|
|
882
|
+
buffer: replayedResult.next.buffer,
|
|
883
|
+
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
884
|
+
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, {
|
|
885
|
+
...replayedResult,
|
|
886
|
+
provisional: true,
|
|
887
|
+
consumed: [...previouslyConsumed, ...replayedResult.consumed]
|
|
888
|
+
}),
|
|
889
|
+
...mergedExec != null ? {
|
|
890
|
+
exec: mergedExec,
|
|
891
|
+
dependencyRegistry: mergedExec.dependencyRegistry
|
|
892
|
+
} : {}
|
|
893
|
+
},
|
|
894
|
+
consumed: replayedResult.consumed
|
|
895
|
+
};
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
898
|
}
|
|
@@ -1071,27 +1071,27 @@ function or(...args) {
|
|
|
1071
1071
|
dependencyRegistry: replayExec.dependencyRegistry
|
|
1072
1072
|
} : {}
|
|
1073
1073
|
}, provisionalConsuming.index, checkResult.next.state, provisionalConsuming.parser));
|
|
1074
|
-
if (replayedResult.success)
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1074
|
+
if (!replayedResult.success) return replayedResult;
|
|
1075
|
+
const mergedExec = mergeChildExec(replayExec, replayedResult.next.exec);
|
|
1076
|
+
return {
|
|
1077
|
+
success: true,
|
|
1078
|
+
provisional: true,
|
|
1079
|
+
next: {
|
|
1080
|
+
...context,
|
|
1081
|
+
buffer: replayedResult.next.buffer,
|
|
1082
|
+
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
1083
|
+
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, {
|
|
1084
|
+
...replayedResult,
|
|
1085
|
+
provisional: true,
|
|
1086
|
+
consumed: [...previouslyConsumed, ...replayedResult.consumed]
|
|
1087
|
+
}),
|
|
1088
|
+
...mergedExec != null ? {
|
|
1089
|
+
exec: mergedExec,
|
|
1090
|
+
dependencyRegistry: mergedExec.dependencyRegistry
|
|
1091
|
+
} : {}
|
|
1092
|
+
},
|
|
1093
|
+
consumed: replayedResult.consumed
|
|
1094
|
+
};
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
@@ -4044,6 +4044,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4044
4044
|
const mergedExec = mergeChildExec(context.exec, branchResult.next.exec);
|
|
4045
4045
|
return {
|
|
4046
4046
|
success: true,
|
|
4047
|
+
...state.speculative || branchResult.provisional ? { provisional: true } : {},
|
|
4047
4048
|
next: {
|
|
4048
4049
|
...branchResult.next,
|
|
4049
4050
|
state: {
|
package/dist/parser.d.cts
CHANGED
|
@@ -559,11 +559,23 @@ type ParserResult<TState> = {
|
|
|
559
559
|
*/
|
|
560
560
|
readonly consumed: readonly string[];
|
|
561
561
|
/**
|
|
562
|
-
* When `true`, indicates that this success is tentative
|
|
563
|
-
* matched something
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
562
|
+
* When `true`, indicates that this success is tentative or
|
|
563
|
+
* speculative: the parser matched something but the match has not
|
|
564
|
+
* been confirmed yet. This covers two cases:
|
|
565
|
+
*
|
|
566
|
+
* - A zero-consuming discriminator resolved to a branch key, but
|
|
567
|
+
* the selected sub-parser has not consumed any input yet.
|
|
568
|
+
* - A {@link conditional} parser speculatively committed to a
|
|
569
|
+
* named branch that consumed tokens, before the discriminator
|
|
570
|
+
* has had a chance to confirm the choice. In this case the
|
|
571
|
+
* marker stays set across subsequent parse calls until
|
|
572
|
+
* `complete()` verifies the speculative selection.
|
|
573
|
+
*
|
|
574
|
+
* Outer combinators like {@link or} and {@link longestMatch} should
|
|
575
|
+
* not treat provisional successes as definitive — a definitive
|
|
576
|
+
* branch must be allowed to take priority, and a definitive
|
|
577
|
+
* zero-consuming fallback must not be displaced by a provisional
|
|
578
|
+
* consuming hit.
|
|
567
579
|
*
|
|
568
580
|
* @since 1.0.0
|
|
569
581
|
*/
|
package/dist/parser.d.ts
CHANGED
|
@@ -559,11 +559,23 @@ type ParserResult<TState> = {
|
|
|
559
559
|
*/
|
|
560
560
|
readonly consumed: readonly string[];
|
|
561
561
|
/**
|
|
562
|
-
* When `true`, indicates that this success is tentative
|
|
563
|
-
* matched something
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
562
|
+
* When `true`, indicates that this success is tentative or
|
|
563
|
+
* speculative: the parser matched something but the match has not
|
|
564
|
+
* been confirmed yet. This covers two cases:
|
|
565
|
+
*
|
|
566
|
+
* - A zero-consuming discriminator resolved to a branch key, but
|
|
567
|
+
* the selected sub-parser has not consumed any input yet.
|
|
568
|
+
* - A {@link conditional} parser speculatively committed to a
|
|
569
|
+
* named branch that consumed tokens, before the discriminator
|
|
570
|
+
* has had a chance to confirm the choice. In this case the
|
|
571
|
+
* marker stays set across subsequent parse calls until
|
|
572
|
+
* `complete()` verifies the speculative selection.
|
|
573
|
+
*
|
|
574
|
+
* Outer combinators like {@link or} and {@link longestMatch} should
|
|
575
|
+
* not treat provisional successes as definitive — a definitive
|
|
576
|
+
* branch must be allowed to take priority, and a definitive
|
|
577
|
+
* zero-consuming fallback must not be displaced by a provisional
|
|
578
|
+
* consuming hit.
|
|
567
579
|
*
|
|
568
580
|
* @since 1.0.0
|
|
569
581
|
*/
|