@optique/core 1.4.0-dev.2636 → 1.4.0-dev.2661
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 +261 -41
- package/dist/constructs.js +261 -41
- package/dist/extension.cjs +17 -0
- package/dist/extension.d.cts +13 -1
- package/dist/extension.d.ts +13 -1
- package/dist/extension.js +17 -1
- package/dist/internal/passthrough.cjs +230 -0
- package/dist/internal/passthrough.js +213 -0
- package/dist/modifiers.cjs +22 -0
- package/dist/modifiers.js +22 -0
- package/dist/primitives.cjs +45 -9
- package/dist/primitives.js +45 -9
- package/dist/suggestion.cjs +3 -1
- package/dist/suggestion.js +3 -1
- package/package.json +2 -2
package/dist/extension.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
|
3
3
|
const require_internal_parser = require('./internal/parser.cjs');
|
|
4
4
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
5
5
|
const require_short_option = require('./short-option.cjs');
|
|
6
|
+
const require_passthrough = require('./internal/passthrough.cjs');
|
|
6
7
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
7
8
|
|
|
8
9
|
//#region src/extension.ts
|
|
@@ -86,9 +87,25 @@ function delegateSuggestNodes(innerParser, outerParser, state, path, innerState,
|
|
|
86
87
|
function mapSourceMetadata(parser, mapSource) {
|
|
87
88
|
return require_internal_parser.composeWrappedSourceMetadata(parser.dependencyMetadata, mapSource);
|
|
88
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Delegates CLI option matching and capture priority through a parser wrapper.
|
|
92
|
+
* Use the same child-state projection as the wrapper's parse method. This
|
|
93
|
+
* preserves selected command options without changing public leading names.
|
|
94
|
+
*
|
|
95
|
+
* @param wrapper The parser being constructed.
|
|
96
|
+
* @param inner Its wrapped CLI parser.
|
|
97
|
+
* @param getInnerState Projects the wrapper state to the CLI parser state.
|
|
98
|
+
* @throws {TypeError} If metadata cannot be defined on the wrapper.
|
|
99
|
+
* @since 1.0.11
|
|
100
|
+
*/
|
|
101
|
+
function delegateOptionParsing(wrapper, inner, getInnerState) {
|
|
102
|
+
require_passthrough.defineOptionMatch(wrapper, (state, token) => require_passthrough.getOptionMatch(inner, getInnerState(state), token));
|
|
103
|
+
require_passthrough.definePassThroughPriority(wrapper, [inner], (state, token) => require_passthrough.getPassThroughPriority(inner, getInnerState(state), token));
|
|
104
|
+
}
|
|
89
105
|
|
|
90
106
|
//#endregion
|
|
91
107
|
exports.defineTraits = defineTraits;
|
|
108
|
+
exports.delegateOptionParsing = delegateOptionParsing;
|
|
92
109
|
exports.delegateSuggestNodes = delegateSuggestNodes;
|
|
93
110
|
exports.dispatchByMode = require_mode_dispatch.dispatchByMode;
|
|
94
111
|
exports.extractPhase2SeedKey = require_phase2_seed.extractPhase2SeedKey;
|
package/dist/extension.d.cts
CHANGED
|
@@ -105,5 +105,17 @@ declare function delegateSuggestNodes<TInnerState>(innerParser: Parser<Mode, unk
|
|
|
105
105
|
* @since 1.0.0
|
|
106
106
|
*/
|
|
107
107
|
declare function mapSourceMetadata<M extends Mode, TValue, TState>(parser: Pick<Parser<M, TValue, TState>, "dependencyMetadata">, mapSource: (source: ParserSourceMetadata<M, TValue, TState>) => ParserSourceMetadata<M, TValue, TState>): Parser<M, TValue, TState>["dependencyMetadata"] | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Delegates CLI option matching and capture priority through a parser wrapper.
|
|
110
|
+
* Use the same child-state projection as the wrapper's parse method. This
|
|
111
|
+
* preserves selected command options without changing public leading names.
|
|
112
|
+
*
|
|
113
|
+
* @param wrapper The parser being constructed.
|
|
114
|
+
* @param inner Its wrapped CLI parser.
|
|
115
|
+
* @param getInnerState Projects the wrapper state to the CLI parser state.
|
|
116
|
+
* @throws {TypeError} If metadata cannot be defined on the wrapper.
|
|
117
|
+
* @since 1.0.11
|
|
118
|
+
*/
|
|
119
|
+
declare function delegateOptionParsing<TOuterState, TInnerState>(wrapper: Parser<Mode, unknown, TOuterState>, inner: Parser<Mode, unknown, TInnerState>, getInnerState: (state: TOuterState) => TInnerState): void;
|
|
108
120
|
//#endregion
|
|
109
|
-
export { ParserSourceMetadata, ParserTraits, SuggestNode, defineTraits, delegateSuggestNodes, dispatchByMode, extractPhase2SeedKey, getTraits, inheritAnnotations, inheritOptionScope, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, unwrapInjectedAnnotationState, withAnnotationView, wrapForMode };
|
|
121
|
+
export { ParserSourceMetadata, ParserTraits, SuggestNode, defineTraits, delegateOptionParsing, delegateSuggestNodes, dispatchByMode, extractPhase2SeedKey, getTraits, inheritAnnotations, inheritOptionScope, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, unwrapInjectedAnnotationState, withAnnotationView, wrapForMode };
|
package/dist/extension.d.ts
CHANGED
|
@@ -105,5 +105,17 @@ declare function delegateSuggestNodes<TInnerState>(innerParser: Parser<Mode, unk
|
|
|
105
105
|
* @since 1.0.0
|
|
106
106
|
*/
|
|
107
107
|
declare function mapSourceMetadata<M extends Mode, TValue, TState>(parser: Pick<Parser<M, TValue, TState>, "dependencyMetadata">, mapSource: (source: ParserSourceMetadata<M, TValue, TState>) => ParserSourceMetadata<M, TValue, TState>): Parser<M, TValue, TState>["dependencyMetadata"] | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Delegates CLI option matching and capture priority through a parser wrapper.
|
|
110
|
+
* Use the same child-state projection as the wrapper's parse method. This
|
|
111
|
+
* preserves selected command options without changing public leading names.
|
|
112
|
+
*
|
|
113
|
+
* @param wrapper The parser being constructed.
|
|
114
|
+
* @param inner Its wrapped CLI parser.
|
|
115
|
+
* @param getInnerState Projects the wrapper state to the CLI parser state.
|
|
116
|
+
* @throws {TypeError} If metadata cannot be defined on the wrapper.
|
|
117
|
+
* @since 1.0.11
|
|
118
|
+
*/
|
|
119
|
+
declare function delegateOptionParsing<TOuterState, TInnerState>(wrapper: Parser<Mode, unknown, TOuterState>, inner: Parser<Mode, unknown, TInnerState>, getInnerState: (state: TOuterState) => TInnerState): void;
|
|
108
120
|
//#endregion
|
|
109
|
-
export { ParserSourceMetadata, ParserTraits, SuggestNode, defineTraits, delegateSuggestNodes, dispatchByMode, extractPhase2SeedKey, getTraits, inheritAnnotations, inheritOptionScope, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, unwrapInjectedAnnotationState, withAnnotationView, wrapForMode };
|
|
121
|
+
export { ParserSourceMetadata, ParserTraits, SuggestNode, defineTraits, delegateOptionParsing, delegateSuggestNodes, dispatchByMode, extractPhase2SeedKey, getTraits, inheritAnnotations, inheritOptionScope, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, unwrapInjectedAnnotationState, withAnnotationView, wrapForMode };
|
package/dist/extension.js
CHANGED
|
@@ -3,6 +3,7 @@ import { dispatchByMode, mapModeValue, wrapForMode } from "./internal/mode-dispa
|
|
|
3
3
|
import { annotationWrapperRequiresSourceBindingKey, composeWrappedSourceMetadata, defineInheritedAnnotationParser, getDelegatingSuggestRuntimeNodes, inheritParentAnnotationsKey, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
4
4
|
import { withAnnotationView } from "./annotation-state.js";
|
|
5
5
|
import { inheritOptionScope } from "./short-option.js";
|
|
6
|
+
import { defineOptionMatch, definePassThroughPriority, getOptionMatch, getPassThroughPriority } from "./internal/passthrough.js";
|
|
6
7
|
import { extractPhase2SeedKey } from "./phase2-seed.js";
|
|
7
8
|
|
|
8
9
|
//#region src/extension.ts
|
|
@@ -86,6 +87,21 @@ function delegateSuggestNodes(innerParser, outerParser, state, path, innerState,
|
|
|
86
87
|
function mapSourceMetadata(parser, mapSource) {
|
|
87
88
|
return composeWrappedSourceMetadata(parser.dependencyMetadata, mapSource);
|
|
88
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Delegates CLI option matching and capture priority through a parser wrapper.
|
|
92
|
+
* Use the same child-state projection as the wrapper's parse method. This
|
|
93
|
+
* preserves selected command options without changing public leading names.
|
|
94
|
+
*
|
|
95
|
+
* @param wrapper The parser being constructed.
|
|
96
|
+
* @param inner Its wrapped CLI parser.
|
|
97
|
+
* @param getInnerState Projects the wrapper state to the CLI parser state.
|
|
98
|
+
* @throws {TypeError} If metadata cannot be defined on the wrapper.
|
|
99
|
+
* @since 1.0.11
|
|
100
|
+
*/
|
|
101
|
+
function delegateOptionParsing(wrapper, inner, getInnerState) {
|
|
102
|
+
defineOptionMatch(wrapper, (state, token) => getOptionMatch(inner, getInnerState(state), token));
|
|
103
|
+
definePassThroughPriority(wrapper, [inner], (state, token) => getPassThroughPriority(inner, getInnerState(state), token));
|
|
104
|
+
}
|
|
89
105
|
|
|
90
106
|
//#endregion
|
|
91
|
-
export { defineTraits, delegateSuggestNodes, dispatchByMode, extractPhase2SeedKey, getTraits, inheritAnnotations, inheritOptionScope$1 as inheritOptionScope, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, unwrapInjectedAnnotationState, withAnnotationView, wrapForMode };
|
|
107
|
+
export { defineTraits, delegateOptionParsing, delegateSuggestNodes, dispatchByMode, extractPhase2SeedKey, getTraits, inheritAnnotations, inheritOptionScope$1 as inheritOptionScope, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, unwrapInjectedAnnotationState, withAnnotationView, wrapForMode };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/internal/passthrough.ts
|
|
3
|
+
/** Retains the deepest diagnostic and highest matching lane priority. @internal */
|
|
4
|
+
function retainConsumingFailure(current, failure, priority) {
|
|
5
|
+
return {
|
|
6
|
+
failure: current != null && current.failure.consumed >= failure.consumed ? current.failure : failure,
|
|
7
|
+
priority: Math.max(current?.priority ?? -Infinity, priority)
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const passThroughFailure = Symbol("passThroughFailure");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the sibling failure that prevents pass-through capture at this cursor.
|
|
13
|
+
* Stale hints inherited through a successful child do not block later input.
|
|
14
|
+
* @param context The pass-through parser's context.
|
|
15
|
+
* @returns The failure at this cursor, or undefined if capture is allowed.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
function getPassThroughFailure(context, capturePriority$1 = -Infinity) {
|
|
19
|
+
const hinted = context;
|
|
20
|
+
const hint = hinted[passThroughFailure];
|
|
21
|
+
return hint?.buffer === context.buffer && hint.optionsTerminated === context.optionsTerminated && hint.failure.priority >= capturePriority$1 ? hint.failure : void 0;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Carries a sibling's consuming failure into a child parse call. Only
|
|
25
|
+
* passThrough consults the hint; ordinary alternatives may still recover.
|
|
26
|
+
* @param context The child context, without modifying the parent's context.
|
|
27
|
+
* @param failure The deepest matching consuming failure at this input position.
|
|
28
|
+
* @returns A context with a hint for active option-like input, or the original.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
function withPassThroughFailure(context, failure, capturePriority$1 = -Infinity) {
|
|
32
|
+
const token = context.buffer[0];
|
|
33
|
+
const existing = getPassThroughFailure(context);
|
|
34
|
+
if (existing != null && existing.priority < capturePriority$1) {
|
|
35
|
+
const hinted$1 = context;
|
|
36
|
+
const { [passThroughFailure]: _discarded,...rest } = hinted$1;
|
|
37
|
+
context = rest;
|
|
38
|
+
}
|
|
39
|
+
if (failure == null || failure.failure.consumed < 1 || failure.priority < capturePriority$1 || context.optionsTerminated || token == null || token === "--" || !/^[-/+]/.test(token)) return context;
|
|
40
|
+
const retained = getPassThroughFailure(context);
|
|
41
|
+
const combined = retainConsumingFailure(retained, failure.failure, failure.priority);
|
|
42
|
+
const hinted = {
|
|
43
|
+
...context,
|
|
44
|
+
[passThroughFailure]: {
|
|
45
|
+
buffer: context.buffer,
|
|
46
|
+
optionsTerminated: context.optionsTerminated,
|
|
47
|
+
failure: combined
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return hinted;
|
|
51
|
+
}
|
|
52
|
+
/** Retains a child's rejected option failure only at the parent's cursor. @internal */
|
|
53
|
+
function retainConsumingFailureHint(current, context, next) {
|
|
54
|
+
if (next.buffer !== context.buffer || next.optionsTerminated !== context.optionsTerminated) return current;
|
|
55
|
+
const hint = getPassThroughFailure(next);
|
|
56
|
+
return hint == null ? current : retainConsumingFailure(current, hint.failure, hint.priority);
|
|
57
|
+
}
|
|
58
|
+
const capturePriority = Symbol("capturePriority");
|
|
59
|
+
/** Checks for capture through usage-preserving wrappers. @internal */
|
|
60
|
+
function hasPassThroughUsage(usage) {
|
|
61
|
+
return usage.some((term) => term.type === "passthrough" || (term.type === "optional" || term.type === "multiple") && hasPassThroughUsage(term.terms) || term.type === "exclusive" && term.terms.some(hasPassThroughUsage));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the priority of reachable capture, respecting an explicit override.
|
|
65
|
+
* @param parser The parser whose capture priority is needed.
|
|
66
|
+
* @param state The current parser state.
|
|
67
|
+
* @param token The current token, omitted for an unfiltered priority lookup.
|
|
68
|
+
* @returns The capture priority, or undefined when capture is absent.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
function getPassThroughPriority(parser, state = parser.initialState, token) {
|
|
72
|
+
if (!hasPassThroughUsage(parser.usage)) return void 0;
|
|
73
|
+
const annotated = parser;
|
|
74
|
+
const hint = annotated[capturePriority];
|
|
75
|
+
if (hint == null) return parser.priority;
|
|
76
|
+
const priority = hint.getPriority == null ? hint.priority : hint.getPriority(state, token);
|
|
77
|
+
return priority == null ? void 0 : hint.ownerPriority === parser.priority ? priority : parser.priority;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Records capture priority separately from unrelated children's priorities.
|
|
81
|
+
* @param parser The newly constructed parser.
|
|
82
|
+
* @param children Its transparent children.
|
|
83
|
+
* @param getPriority Optional state-aware capture priority lookup.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
function definePassThroughPriority(parser, children, getPriority) {
|
|
87
|
+
const priorities = children.filter((child) => hasPassThroughUsage(child.usage)).map((child) => getPassThroughPriority(child) ?? child.priority);
|
|
88
|
+
if (priorities.length === 0) return;
|
|
89
|
+
Object.defineProperty(parser, capturePriority, {
|
|
90
|
+
value: {
|
|
91
|
+
ownerPriority: parser.priority,
|
|
92
|
+
priority: Math.max(...priorities),
|
|
93
|
+
getPriority
|
|
94
|
+
},
|
|
95
|
+
enumerable: true
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Copies only a cursor-valid hint when rebuilding a child context.
|
|
100
|
+
* @param context The successful child's context.
|
|
101
|
+
* @returns Private hint properties, or an empty object for stale hints.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
function getPassThroughFailureHint(context) {
|
|
105
|
+
const hinted = context;
|
|
106
|
+
const hint = hinted[passThroughFailure];
|
|
107
|
+
return hint != null && getPassThroughFailure(context) != null ? { [passThroughFailure]: hint } : {};
|
|
108
|
+
}
|
|
109
|
+
/** Finds a Boolean option through usage-preserving wrappers. */
|
|
110
|
+
function hasFlagUsage(usage, name) {
|
|
111
|
+
return usage.some((term) => term.type === "option" && term.metavar == null && term.names.some((optionName) => optionName === name) || (term.type === "optional" || term.type === "multiple") && hasFlagUsage(term.terms, name) || term.type === "exclusive" && term.terms.some((terms) => hasFlagUsage(terms, name)));
|
|
112
|
+
}
|
|
113
|
+
/** Matches exact options, attached values, and leading bundled flags. */
|
|
114
|
+
function matchesOptionToken(parser, token) {
|
|
115
|
+
if (token == null || token === "--" || !/^[-/+]/.test(token)) return false;
|
|
116
|
+
if (parser.leadingNames.has(token)) return true;
|
|
117
|
+
const slashOption = token.startsWith("/");
|
|
118
|
+
const separator = slashOption ? token.indexOf(":") : token.startsWith("-") ? token.indexOf("=") : -1;
|
|
119
|
+
if (separator > (slashOption ? 0 : 2) && parser.leadingNames.has(token.slice(0, separator))) return true;
|
|
120
|
+
const shortName = token.slice(0, 2);
|
|
121
|
+
return token.length > 2 && /^-[^-]$/.test(shortName) && parser.leadingNames.has(shortName) && hasFlagUsage(parser.usage, shortName);
|
|
122
|
+
}
|
|
123
|
+
const optionMatchKey = Symbol("optionMatch");
|
|
124
|
+
/**
|
|
125
|
+
* Records state-aware option matching without changing public leading names.
|
|
126
|
+
* @param parser The newly constructed transparent parser.
|
|
127
|
+
* @param match Finds a reachable known-option lane.
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
function defineOptionMatch(parser, match) {
|
|
131
|
+
Object.defineProperty(parser, optionMatchKey, {
|
|
132
|
+
value: {
|
|
133
|
+
ownerPriority: parser.priority,
|
|
134
|
+
match
|
|
135
|
+
},
|
|
136
|
+
enumerable: true
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Finds a matching option's actual priority, including selected command children.
|
|
141
|
+
* @param parser The parser to inspect.
|
|
142
|
+
* @param state Its current state.
|
|
143
|
+
* @param token The current token.
|
|
144
|
+
* @returns A reachable option match, or undefined.
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
function getOptionMatch(parser, state, token) {
|
|
148
|
+
if (token == null || token === "--" || !/^[-/+]/.test(token)) return void 0;
|
|
149
|
+
const annotated = parser;
|
|
150
|
+
const matcher = annotated[optionMatchKey];
|
|
151
|
+
if (matcher != null) {
|
|
152
|
+
const match = matcher.match(state, token);
|
|
153
|
+
return match == null || matcher.ownerPriority === parser.priority ? match : {
|
|
154
|
+
...match,
|
|
155
|
+
priority: parser.priority
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return matchesOptionToken(parser, token) ? {
|
|
159
|
+
priority: parser.priority,
|
|
160
|
+
continuesCommand: false
|
|
161
|
+
} : void 0;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Combines option matches while retaining active command continuation.
|
|
165
|
+
* @param matches Matches from transparent children.
|
|
166
|
+
* @returns Their highest priority and whether any matching command continues.
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
function combineOptionMatches(matches) {
|
|
170
|
+
const found = matches.filter((match) => match != null);
|
|
171
|
+
return found.length === 0 ? void 0 : {
|
|
172
|
+
priority: Math.max(...found.map((match) => match.priority)),
|
|
173
|
+
continuesCommand: found.some((match) => match.continuesCommand)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const knownCompletionKey = Symbol("knownCompletion");
|
|
177
|
+
/** Marks a completion value that can be inspected without running user code. @internal */
|
|
178
|
+
function defineKnownCompletion(parser, value) {
|
|
179
|
+
defineKnownCompletionLookup(parser, (state) => ({ value: value(state) }));
|
|
180
|
+
}
|
|
181
|
+
/** Registers a known-value lookup that may decline unknown completion. @internal */
|
|
182
|
+
function defineKnownCompletionLookup(parser, value) {
|
|
183
|
+
Object.defineProperty(parser, knownCompletionKey, {
|
|
184
|
+
value: {
|
|
185
|
+
complete: parser.complete,
|
|
186
|
+
value
|
|
187
|
+
},
|
|
188
|
+
enumerable: true
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/** Looks up a known value only while the original completion is intact. @internal */
|
|
192
|
+
function getKnownCompletion(parser, state) {
|
|
193
|
+
const annotated = parser;
|
|
194
|
+
const hint = annotated[knownCompletionKey];
|
|
195
|
+
return hint != null && hint.complete === parser.complete ? hint.value(state) : void 0;
|
|
196
|
+
}
|
|
197
|
+
/** Combines the priorities of currently reachable capture lanes. @internal */
|
|
198
|
+
function combinePassThroughPriorities(priorities) {
|
|
199
|
+
const found = priorities.filter((priority) => priority != null);
|
|
200
|
+
return found.length === 0 ? void 0 : Math.max(...found);
|
|
201
|
+
}
|
|
202
|
+
/** Forwards known completion through a state-preserving wrapper. @internal */
|
|
203
|
+
function delegateKnownCompletion(wrapper, inner) {
|
|
204
|
+
Object.defineProperty(wrapper, knownCompletionKey, {
|
|
205
|
+
value: {
|
|
206
|
+
complete: wrapper.complete,
|
|
207
|
+
value: (state) => getKnownCompletion(inner, state)
|
|
208
|
+
},
|
|
209
|
+
enumerable: true
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
exports.combineOptionMatches = combineOptionMatches;
|
|
215
|
+
exports.combinePassThroughPriorities = combinePassThroughPriorities;
|
|
216
|
+
exports.defineKnownCompletion = defineKnownCompletion;
|
|
217
|
+
exports.defineKnownCompletionLookup = defineKnownCompletionLookup;
|
|
218
|
+
exports.defineOptionMatch = defineOptionMatch;
|
|
219
|
+
exports.definePassThroughPriority = definePassThroughPriority;
|
|
220
|
+
exports.delegateKnownCompletion = delegateKnownCompletion;
|
|
221
|
+
exports.getKnownCompletion = getKnownCompletion;
|
|
222
|
+
exports.getOptionMatch = getOptionMatch;
|
|
223
|
+
exports.getPassThroughFailure = getPassThroughFailure;
|
|
224
|
+
exports.getPassThroughFailureHint = getPassThroughFailureHint;
|
|
225
|
+
exports.getPassThroughPriority = getPassThroughPriority;
|
|
226
|
+
exports.hasPassThroughUsage = hasPassThroughUsage;
|
|
227
|
+
exports.matchesOptionToken = matchesOptionToken;
|
|
228
|
+
exports.retainConsumingFailure = retainConsumingFailure;
|
|
229
|
+
exports.retainConsumingFailureHint = retainConsumingFailureHint;
|
|
230
|
+
exports.withPassThroughFailure = withPassThroughFailure;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
//#region src/internal/passthrough.ts
|
|
2
|
+
/** Retains the deepest diagnostic and highest matching lane priority. @internal */
|
|
3
|
+
function retainConsumingFailure(current, failure, priority) {
|
|
4
|
+
return {
|
|
5
|
+
failure: current != null && current.failure.consumed >= failure.consumed ? current.failure : failure,
|
|
6
|
+
priority: Math.max(current?.priority ?? -Infinity, priority)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const passThroughFailure = Symbol("passThroughFailure");
|
|
10
|
+
/**
|
|
11
|
+
* Gets the sibling failure that prevents pass-through capture at this cursor.
|
|
12
|
+
* Stale hints inherited through a successful child do not block later input.
|
|
13
|
+
* @param context The pass-through parser's context.
|
|
14
|
+
* @returns The failure at this cursor, or undefined if capture is allowed.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
function getPassThroughFailure(context, capturePriority$1 = -Infinity) {
|
|
18
|
+
const hinted = context;
|
|
19
|
+
const hint = hinted[passThroughFailure];
|
|
20
|
+
return hint?.buffer === context.buffer && hint.optionsTerminated === context.optionsTerminated && hint.failure.priority >= capturePriority$1 ? hint.failure : void 0;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Carries a sibling's consuming failure into a child parse call. Only
|
|
24
|
+
* passThrough consults the hint; ordinary alternatives may still recover.
|
|
25
|
+
* @param context The child context, without modifying the parent's context.
|
|
26
|
+
* @param failure The deepest matching consuming failure at this input position.
|
|
27
|
+
* @returns A context with a hint for active option-like input, or the original.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
function withPassThroughFailure(context, failure, capturePriority$1 = -Infinity) {
|
|
31
|
+
const token = context.buffer[0];
|
|
32
|
+
const existing = getPassThroughFailure(context);
|
|
33
|
+
if (existing != null && existing.priority < capturePriority$1) {
|
|
34
|
+
const hinted$1 = context;
|
|
35
|
+
const { [passThroughFailure]: _discarded,...rest } = hinted$1;
|
|
36
|
+
context = rest;
|
|
37
|
+
}
|
|
38
|
+
if (failure == null || failure.failure.consumed < 1 || failure.priority < capturePriority$1 || context.optionsTerminated || token == null || token === "--" || !/^[-/+]/.test(token)) return context;
|
|
39
|
+
const retained = getPassThroughFailure(context);
|
|
40
|
+
const combined = retainConsumingFailure(retained, failure.failure, failure.priority);
|
|
41
|
+
const hinted = {
|
|
42
|
+
...context,
|
|
43
|
+
[passThroughFailure]: {
|
|
44
|
+
buffer: context.buffer,
|
|
45
|
+
optionsTerminated: context.optionsTerminated,
|
|
46
|
+
failure: combined
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return hinted;
|
|
50
|
+
}
|
|
51
|
+
/** Retains a child's rejected option failure only at the parent's cursor. @internal */
|
|
52
|
+
function retainConsumingFailureHint(current, context, next) {
|
|
53
|
+
if (next.buffer !== context.buffer || next.optionsTerminated !== context.optionsTerminated) return current;
|
|
54
|
+
const hint = getPassThroughFailure(next);
|
|
55
|
+
return hint == null ? current : retainConsumingFailure(current, hint.failure, hint.priority);
|
|
56
|
+
}
|
|
57
|
+
const capturePriority = Symbol("capturePriority");
|
|
58
|
+
/** Checks for capture through usage-preserving wrappers. @internal */
|
|
59
|
+
function hasPassThroughUsage(usage) {
|
|
60
|
+
return usage.some((term) => term.type === "passthrough" || (term.type === "optional" || term.type === "multiple") && hasPassThroughUsage(term.terms) || term.type === "exclusive" && term.terms.some(hasPassThroughUsage));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets the priority of reachable capture, respecting an explicit override.
|
|
64
|
+
* @param parser The parser whose capture priority is needed.
|
|
65
|
+
* @param state The current parser state.
|
|
66
|
+
* @param token The current token, omitted for an unfiltered priority lookup.
|
|
67
|
+
* @returns The capture priority, or undefined when capture is absent.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
function getPassThroughPriority(parser, state = parser.initialState, token) {
|
|
71
|
+
if (!hasPassThroughUsage(parser.usage)) return void 0;
|
|
72
|
+
const annotated = parser;
|
|
73
|
+
const hint = annotated[capturePriority];
|
|
74
|
+
if (hint == null) return parser.priority;
|
|
75
|
+
const priority = hint.getPriority == null ? hint.priority : hint.getPriority(state, token);
|
|
76
|
+
return priority == null ? void 0 : hint.ownerPriority === parser.priority ? priority : parser.priority;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Records capture priority separately from unrelated children's priorities.
|
|
80
|
+
* @param parser The newly constructed parser.
|
|
81
|
+
* @param children Its transparent children.
|
|
82
|
+
* @param getPriority Optional state-aware capture priority lookup.
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
function definePassThroughPriority(parser, children, getPriority) {
|
|
86
|
+
const priorities = children.filter((child) => hasPassThroughUsage(child.usage)).map((child) => getPassThroughPriority(child) ?? child.priority);
|
|
87
|
+
if (priorities.length === 0) return;
|
|
88
|
+
Object.defineProperty(parser, capturePriority, {
|
|
89
|
+
value: {
|
|
90
|
+
ownerPriority: parser.priority,
|
|
91
|
+
priority: Math.max(...priorities),
|
|
92
|
+
getPriority
|
|
93
|
+
},
|
|
94
|
+
enumerable: true
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Copies only a cursor-valid hint when rebuilding a child context.
|
|
99
|
+
* @param context The successful child's context.
|
|
100
|
+
* @returns Private hint properties, or an empty object for stale hints.
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
function getPassThroughFailureHint(context) {
|
|
104
|
+
const hinted = context;
|
|
105
|
+
const hint = hinted[passThroughFailure];
|
|
106
|
+
return hint != null && getPassThroughFailure(context) != null ? { [passThroughFailure]: hint } : {};
|
|
107
|
+
}
|
|
108
|
+
/** Finds a Boolean option through usage-preserving wrappers. */
|
|
109
|
+
function hasFlagUsage(usage, name) {
|
|
110
|
+
return usage.some((term) => term.type === "option" && term.metavar == null && term.names.some((optionName) => optionName === name) || (term.type === "optional" || term.type === "multiple") && hasFlagUsage(term.terms, name) || term.type === "exclusive" && term.terms.some((terms) => hasFlagUsage(terms, name)));
|
|
111
|
+
}
|
|
112
|
+
/** Matches exact options, attached values, and leading bundled flags. */
|
|
113
|
+
function matchesOptionToken(parser, token) {
|
|
114
|
+
if (token == null || token === "--" || !/^[-/+]/.test(token)) return false;
|
|
115
|
+
if (parser.leadingNames.has(token)) return true;
|
|
116
|
+
const slashOption = token.startsWith("/");
|
|
117
|
+
const separator = slashOption ? token.indexOf(":") : token.startsWith("-") ? token.indexOf("=") : -1;
|
|
118
|
+
if (separator > (slashOption ? 0 : 2) && parser.leadingNames.has(token.slice(0, separator))) return true;
|
|
119
|
+
const shortName = token.slice(0, 2);
|
|
120
|
+
return token.length > 2 && /^-[^-]$/.test(shortName) && parser.leadingNames.has(shortName) && hasFlagUsage(parser.usage, shortName);
|
|
121
|
+
}
|
|
122
|
+
const optionMatchKey = Symbol("optionMatch");
|
|
123
|
+
/**
|
|
124
|
+
* Records state-aware option matching without changing public leading names.
|
|
125
|
+
* @param parser The newly constructed transparent parser.
|
|
126
|
+
* @param match Finds a reachable known-option lane.
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
function defineOptionMatch(parser, match) {
|
|
130
|
+
Object.defineProperty(parser, optionMatchKey, {
|
|
131
|
+
value: {
|
|
132
|
+
ownerPriority: parser.priority,
|
|
133
|
+
match
|
|
134
|
+
},
|
|
135
|
+
enumerable: true
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Finds a matching option's actual priority, including selected command children.
|
|
140
|
+
* @param parser The parser to inspect.
|
|
141
|
+
* @param state Its current state.
|
|
142
|
+
* @param token The current token.
|
|
143
|
+
* @returns A reachable option match, or undefined.
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
function getOptionMatch(parser, state, token) {
|
|
147
|
+
if (token == null || token === "--" || !/^[-/+]/.test(token)) return void 0;
|
|
148
|
+
const annotated = parser;
|
|
149
|
+
const matcher = annotated[optionMatchKey];
|
|
150
|
+
if (matcher != null) {
|
|
151
|
+
const match = matcher.match(state, token);
|
|
152
|
+
return match == null || matcher.ownerPriority === parser.priority ? match : {
|
|
153
|
+
...match,
|
|
154
|
+
priority: parser.priority
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return matchesOptionToken(parser, token) ? {
|
|
158
|
+
priority: parser.priority,
|
|
159
|
+
continuesCommand: false
|
|
160
|
+
} : void 0;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Combines option matches while retaining active command continuation.
|
|
164
|
+
* @param matches Matches from transparent children.
|
|
165
|
+
* @returns Their highest priority and whether any matching command continues.
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
function combineOptionMatches(matches) {
|
|
169
|
+
const found = matches.filter((match) => match != null);
|
|
170
|
+
return found.length === 0 ? void 0 : {
|
|
171
|
+
priority: Math.max(...found.map((match) => match.priority)),
|
|
172
|
+
continuesCommand: found.some((match) => match.continuesCommand)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const knownCompletionKey = Symbol("knownCompletion");
|
|
176
|
+
/** Marks a completion value that can be inspected without running user code. @internal */
|
|
177
|
+
function defineKnownCompletion(parser, value) {
|
|
178
|
+
defineKnownCompletionLookup(parser, (state) => ({ value: value(state) }));
|
|
179
|
+
}
|
|
180
|
+
/** Registers a known-value lookup that may decline unknown completion. @internal */
|
|
181
|
+
function defineKnownCompletionLookup(parser, value) {
|
|
182
|
+
Object.defineProperty(parser, knownCompletionKey, {
|
|
183
|
+
value: {
|
|
184
|
+
complete: parser.complete,
|
|
185
|
+
value
|
|
186
|
+
},
|
|
187
|
+
enumerable: true
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/** Looks up a known value only while the original completion is intact. @internal */
|
|
191
|
+
function getKnownCompletion(parser, state) {
|
|
192
|
+
const annotated = parser;
|
|
193
|
+
const hint = annotated[knownCompletionKey];
|
|
194
|
+
return hint != null && hint.complete === parser.complete ? hint.value(state) : void 0;
|
|
195
|
+
}
|
|
196
|
+
/** Combines the priorities of currently reachable capture lanes. @internal */
|
|
197
|
+
function combinePassThroughPriorities(priorities) {
|
|
198
|
+
const found = priorities.filter((priority) => priority != null);
|
|
199
|
+
return found.length === 0 ? void 0 : Math.max(...found);
|
|
200
|
+
}
|
|
201
|
+
/** Forwards known completion through a state-preserving wrapper. @internal */
|
|
202
|
+
function delegateKnownCompletion(wrapper, inner) {
|
|
203
|
+
Object.defineProperty(wrapper, knownCompletionKey, {
|
|
204
|
+
value: {
|
|
205
|
+
complete: wrapper.complete,
|
|
206
|
+
value: (state) => getKnownCompletion(inner, state)
|
|
207
|
+
},
|
|
208
|
+
enumerable: true
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
export { combineOptionMatches, combinePassThroughPriorities, defineKnownCompletion, defineKnownCompletionLookup, defineOptionMatch, definePassThroughPriority, delegateKnownCompletion, getKnownCompletion, getOptionMatch, getPassThroughFailure, getPassThroughFailureHint, getPassThroughPriority, hasPassThroughUsage, matchesOptionToken, retainConsumingFailure, retainConsumingFailureHint, withPassThroughFailure };
|
package/dist/modifiers.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const require_internal_parser = require('./internal/parser.cjs');
|
|
|
6
6
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
7
7
|
const require_execution_context = require('./execution-context.cjs');
|
|
8
8
|
const require_short_option = require('./short-option.cjs');
|
|
9
|
+
const require_passthrough = require('./internal/passthrough.cjs');
|
|
9
10
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
10
11
|
const require_dependency_metadata = require('./dependency-metadata.cjs');
|
|
11
12
|
|
|
@@ -479,6 +480,9 @@ function optional(parser) {
|
|
|
479
480
|
require_internal_parser.defineParseLanes(optionalParser, adaptOptionalStyleParseLanes(parser));
|
|
480
481
|
require_internal_parser.defineInheritedAnnotationParser(optionalParser);
|
|
481
482
|
require_internal_parser.defineSourceBindingOnlyAnnotationCompletionParser(optionalParser);
|
|
483
|
+
require_passthrough.defineOptionMatch(optionalParser, (state, token) => require_passthrough.getOptionMatch(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
484
|
+
require_passthrough.definePassThroughPriority(optionalParser, [parser], (state, token) => require_passthrough.getPassThroughPriority(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
485
|
+
require_passthrough.defineKnownCompletionLookup(optionalParser, (state) => require_passthrough.getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
482
486
|
return fluent(require_short_option.scopeParser(optionalParser, require_short_option.combinedOptionScope([parser])));
|
|
483
487
|
}
|
|
484
488
|
/**
|
|
@@ -730,6 +734,9 @@ function withDefault(parser, defaultValue, options) {
|
|
|
730
734
|
require_internal_parser.defineParseLanes(withDefaultParser, adaptOptionalStyleParseLanes(parser));
|
|
731
735
|
require_internal_parser.defineInheritedAnnotationParser(withDefaultParser);
|
|
732
736
|
require_internal_parser.defineSourceBindingOnlyAnnotationCompletionParser(withDefaultParser);
|
|
737
|
+
require_passthrough.defineOptionMatch(withDefaultParser, (state, token) => require_passthrough.getOptionMatch(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
738
|
+
require_passthrough.definePassThroughPriority(withDefaultParser, [parser], (state, token) => require_passthrough.getPassThroughPriority(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
739
|
+
require_passthrough.defineKnownCompletionLookup(withDefaultParser, (state) => require_passthrough.getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
733
740
|
return fluent(require_short_option.scopeParser(withDefaultParser, require_short_option.combinedOptionScope([parser])));
|
|
734
741
|
}
|
|
735
742
|
/**
|
|
@@ -1715,6 +1722,19 @@ function multiple(parser, options = {}) {
|
|
|
1715
1722
|
enumerable: false
|
|
1716
1723
|
});
|
|
1717
1724
|
}
|
|
1725
|
+
const matchingItem = (state) => {
|
|
1726
|
+
const current = state.at(-1);
|
|
1727
|
+
if (current != null && !isTerminalMultipleItemState(current)) return { state: unwrapInjectedWrapper(current) };
|
|
1728
|
+
return state.length < max ? { state: parser.initialState } : void 0;
|
|
1729
|
+
};
|
|
1730
|
+
require_passthrough.defineOptionMatch(resultParser, (state, token) => {
|
|
1731
|
+
const item = matchingItem(state);
|
|
1732
|
+
return item == null ? void 0 : require_passthrough.getOptionMatch(parser, item.state, token);
|
|
1733
|
+
});
|
|
1734
|
+
require_passthrough.definePassThroughPriority(resultParser, [parser], (state, token) => {
|
|
1735
|
+
const item = matchingItem(state);
|
|
1736
|
+
return item == null ? void 0 : require_passthrough.getPassThroughPriority(parser, item.state, token);
|
|
1737
|
+
});
|
|
1718
1738
|
return fluent(require_short_option.scopeParser(resultParser, require_short_option.repeatedOptionScope(parser)));
|
|
1719
1739
|
}
|
|
1720
1740
|
/**
|
|
@@ -1851,6 +1871,8 @@ function nonEmpty(parser) {
|
|
|
1851
1871
|
enumerable: false
|
|
1852
1872
|
});
|
|
1853
1873
|
require_dependency_runtime.defineForwardedEffectfulSchedulingNodes(nonEmptyParser, parser);
|
|
1874
|
+
require_passthrough.defineOptionMatch(nonEmptyParser, (state, token) => require_passthrough.getOptionMatch(parser, state, token));
|
|
1875
|
+
require_passthrough.definePassThroughPriority(nonEmptyParser, [parser], (state, token) => require_passthrough.getPassThroughPriority(parser, state, token));
|
|
1854
1876
|
return fluent(require_short_option.scopeParser(nonEmptyParser, require_short_option.combinedOptionScope([parser])));
|
|
1855
1877
|
}
|
|
1856
1878
|
const fluentParserMarker = Symbol.for("@optique/core/fluent");
|
package/dist/modifiers.js
CHANGED
|
@@ -6,6 +6,7 @@ import { defineInheritedAnnotationParser, defineParseLanes, defineSourceBindingO
|
|
|
6
6
|
import { getDelegatedAnnotationState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeNestedDelegatedAnnotationState } from "./annotation-state.js";
|
|
7
7
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
8
8
|
import { combinedOptionScope, repeatedOptionScope, scopeParser } from "./short-option.js";
|
|
9
|
+
import { defineKnownCompletionLookup, defineOptionMatch, definePassThroughPriority, getKnownCompletion, getOptionMatch, getPassThroughPriority } from "./internal/passthrough.js";
|
|
9
10
|
import { completeOrExtractPhase2Seed, extractPhase2Seed, extractPhase2SeedKey, phase2SeedFromValueResult } from "./phase2-seed.js";
|
|
10
11
|
import { composeDependencyMetadata } from "./dependency-metadata.js";
|
|
11
12
|
|
|
@@ -479,6 +480,9 @@ function optional(parser) {
|
|
|
479
480
|
defineParseLanes(optionalParser, adaptOptionalStyleParseLanes(parser));
|
|
480
481
|
defineInheritedAnnotationParser(optionalParser);
|
|
481
482
|
defineSourceBindingOnlyAnnotationCompletionParser(optionalParser);
|
|
483
|
+
defineOptionMatch(optionalParser, (state, token) => getOptionMatch(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
484
|
+
definePassThroughPriority(optionalParser, [parser], (state, token) => getPassThroughPriority(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
485
|
+
defineKnownCompletionLookup(optionalParser, (state) => getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
482
486
|
return fluent(scopeParser(optionalParser, combinedOptionScope([parser])));
|
|
483
487
|
}
|
|
484
488
|
/**
|
|
@@ -730,6 +734,9 @@ function withDefault(parser, defaultValue, options) {
|
|
|
730
734
|
defineParseLanes(withDefaultParser, adaptOptionalStyleParseLanes(parser));
|
|
731
735
|
defineInheritedAnnotationParser(withDefaultParser);
|
|
732
736
|
defineSourceBindingOnlyAnnotationCompletionParser(withDefaultParser);
|
|
737
|
+
defineOptionMatch(withDefaultParser, (state, token) => getOptionMatch(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
738
|
+
definePassThroughPriority(withDefaultParser, [parser], (state, token) => getPassThroughPriority(parser, normalizeOptionalLikeSuggestState(state, parser.initialState, parser), token));
|
|
739
|
+
defineKnownCompletionLookup(withDefaultParser, (state) => getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
733
740
|
return fluent(scopeParser(withDefaultParser, combinedOptionScope([parser])));
|
|
734
741
|
}
|
|
735
742
|
/**
|
|
@@ -1715,6 +1722,19 @@ function multiple(parser, options = {}) {
|
|
|
1715
1722
|
enumerable: false
|
|
1716
1723
|
});
|
|
1717
1724
|
}
|
|
1725
|
+
const matchingItem = (state) => {
|
|
1726
|
+
const current = state.at(-1);
|
|
1727
|
+
if (current != null && !isTerminalMultipleItemState(current)) return { state: unwrapInjectedWrapper(current) };
|
|
1728
|
+
return state.length < max ? { state: parser.initialState } : void 0;
|
|
1729
|
+
};
|
|
1730
|
+
defineOptionMatch(resultParser, (state, token) => {
|
|
1731
|
+
const item = matchingItem(state);
|
|
1732
|
+
return item == null ? void 0 : getOptionMatch(parser, item.state, token);
|
|
1733
|
+
});
|
|
1734
|
+
definePassThroughPriority(resultParser, [parser], (state, token) => {
|
|
1735
|
+
const item = matchingItem(state);
|
|
1736
|
+
return item == null ? void 0 : getPassThroughPriority(parser, item.state, token);
|
|
1737
|
+
});
|
|
1718
1738
|
return fluent(scopeParser(resultParser, repeatedOptionScope(parser)));
|
|
1719
1739
|
}
|
|
1720
1740
|
/**
|
|
@@ -1851,6 +1871,8 @@ function nonEmpty(parser) {
|
|
|
1851
1871
|
enumerable: false
|
|
1852
1872
|
});
|
|
1853
1873
|
defineForwardedEffectfulSchedulingNodes(nonEmptyParser, parser);
|
|
1874
|
+
defineOptionMatch(nonEmptyParser, (state, token) => getOptionMatch(parser, state, token));
|
|
1875
|
+
definePassThroughPriority(nonEmptyParser, [parser], (state, token) => getPassThroughPriority(parser, state, token));
|
|
1854
1876
|
return fluent(scopeParser(nonEmptyParser, combinedOptionScope([parser])));
|
|
1855
1877
|
}
|
|
1856
1878
|
const fluentParserMarker = Symbol.for("@optique/core/fluent");
|