Skip to content

fix(action-grammar): support optional rule references - #2941

Open
Rio Yu (rioyu123) wants to merge 1 commit into
microsoft:mainfrom
rioyu123:codex/fix-optional-rule-reference
Open

fix(action-grammar): support optional rule references#2941
Rio Yu (rioyu123) wants to merge 1 commit into
microsoft:mainfrom
rioyu123:codex/fix-optional-rule-reference

Conversation

@rioyu123

Copy link
Copy Markdown

Summary

  • 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
  • Prettier and git diff --check
  • repository policy checks: 9,532 passed
  • code-lint ratchet: no new violations

Fixes #2461

@rioyu123
Rio Yu (rioyu123) force-pushed the codex/fix-optional-rule-reference branch from d8720ee to 3ed2154 Compare August 27, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

actionGrammar: optional rule-reference <Rule>? silently fails to match (inline optional group works)

1 participant