AGR: Add ()* and ()+ GroupExpr support to matcher and writer#1952
Merged
curtisman merged 2 commits intomicrosoft:mainfrom Feb 26, 2026
Merged
AGR: Add ()* and ()+ GroupExpr support to matcher and writer#1952curtisman merged 2 commits intomicrosoft:mainfrom
curtisman merged 2 commits intomicrosoft:mainfrom
Conversation
- 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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
inRepeat=true) viarepeatPartIndexstored inParentMatchState. TheinRepeatflag suppresses the duplicate optional-skip push on re-entry, so()*and()+produce exactly one result per valid repetition count.)*,)+,)?, or)) based onrepeat/optionalflags, restoring correct round-trip serialization for Kleene operators.grammarMatchertests covering zero/one/two repetitions, alternates in a repeat group, and a suffix after a repeat group; 3 newgrammarRuleWriterround-trip tests.🤖 Generated with Claude Code