Skip to content

AGR: Add ()* and ()+ GroupExpr support to matcher and writer#1952

Merged
curtisman merged 2 commits intomicrosoft:mainfrom
curtisman:agr-kleene-groupexpr-matcher
Feb 26, 2026
Merged

AGR: Add ()* and ()+ GroupExpr support to matcher and writer#1952
curtisman merged 2 commits intomicrosoft:mainfrom
curtisman:agr-kleene-groupexpr-matcher

Conversation

@curtisman
Copy link
Member

@curtisman curtisman commented Feb 26, 2026

Summary

  • grammarMatcher: Implement repeat iteration in the interpreter-based matcher. After each successful group match, a retry state is queued (with inRepeat=true) via repeatPartIndex stored in ParentMatchState. The inRepeat flag suppresses the duplicate optional-skip push on re-entry, so ()* and ()+ produce exactly one result per valid repetition count.
  • grammarRuleWriter: Emit the correct closing suffix ()*, )+, )?, or )) based on repeat/optional flags, restoring correct round-trip serialization for Kleene operators.
  • Tests: 8 new grammarMatcher tests covering zero/one/two repetitions, alternates in a repeat group, and a suffix after a repeat group; 3 new grammarRuleWriter round-trip tests.

🤖 Generated with Claude Code

- grammarMatcher: implement repeat iteration in the interpreter-based
  matcher by tracking repeatPartIndex in ParentMatchState and pushing a
  retry state (with inRepeat flag) after each successful group match,
  preventing duplicate optional-skip states on re-entry
- grammarRuleWriter: emit correct )* / )+ suffix when repeat=true,
  preserving round-trip fidelity for all four GroupExpr closing tokens
- Tests: 8 new matcher tests and 3 new writer round-trip tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@curtisman curtisman added this pull request to the merge queue Feb 26, 2026
Merged via the queue into microsoft:main with commit d44f9e4 Feb 26, 2026
13 of 15 checks passed
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.

1 participant