parse an adjacent ? after a named rule reference as an optional suffix
preserve required references and literal question marks when ? is separated or escaped
carry optionality through local, imported, and built-in phrase-set references
keep formatter round-trips, source metadata, spacing modes, and grammar docs in sync
Why
<Owner>? was previously compiled as a required <Owner> followed by a literal ? token. That made the optional reference fail to match even though the equivalent inline group worked. The same suffix form is already used by grammars such as <TimeSpec>? and <PanelRef>?.
The suffix is intentionally adjacency-only, matching $(...)? and (...)?, so <Rule> ? remains a required reference followed by literal punctuation.
Validation
action grammar build
76 action grammar test suites: 16,188 passed, 2 skipped
parser/writer round-trip, NFA/DFA, AST evaluation, and completion regressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
<Owner>? was previously compiled as a required <Owner> followed by a literal ? token. That made the optional reference fail to match even though the equivalent inline group worked. The same suffix form is already used by grammars such as <TimeSpec>? and <PanelRef>?.
The suffix is intentionally adjacency-only, matching $(...)? and (...)?, so <Rule> ? remains a required reference followed by literal punctuation.
Validation
Fixes #2461