Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a new $sep pattern to allow delimiter-separated repetition in grammars.
- Implements
PatternInternal::Septo generate plus (+) and star (*) repetition rules. - Extends lexer, parser, and
PatternArgsto recognize and handle the$sep(base, delim, +|*)syntax. - Updates the AST builder, example JSON grammar, and documentation (
SYNTAX.md) to use the new$sepform.
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rusty_lr_parser/src/pattern.rs | Added handling for PatternInternal::Sep in token conversion |
| rusty_lr_parser/src/parser/parser.rs | Grammar rules to parse $sep(...) with * and + |
| rusty_lr_parser/src/parser/lexer.rs | Introduced Dollar and Comma tokens |
| rusty_lr_parser/src/parser/args.rs | Defined PatternArgs::Sep, conversion, and display |
| rusty_lr_core/src/tree.rs | Flattened sep sequences in the parse tree builder |
| example/json/src/parser.rs | Switched JSON Elements to use $sep |
| SYNTAX.md | Documented the $sep repetition syntax |
Comments suppressed due to low confidence (3)
rusty_lr_parser/src/parser/parser.rs:297
- [nitpick] Consider adding unit tests for the new
$sepsyntax (both*and+variants) to verify correct parsing and error recovery.
| dollar ident lparen base=Pattern comma del=Pattern comma? rparen {
rusty_lr_parser/src/parser/parser.rs:312
- The use of
*@$in the action is invalid Rust syntax and will not compile. You should capture the span of the entire$sep(...)rule (e.g. via an@binding in the grammar) and pass that SpanPair directly toPatternArgs::Sep.
*@$
rusty_lr_parser/src/parser/args.rs:131
- The format string uses
{base}and{del}placeholders without named arguments; this will fail to compile. Use positional formatting, for example:
write!(f, "$sep({}, {}, {})", base, del, if *one { '+' } else { '*' }) write!(f, "$sep({base}, {del}, {})", if *one { '+' } else { '*' })
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.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.
No description provided.