Skip to content

add function call and $sep syntax#14

Merged
ehwan merged 12 commits intomainfrom
function
Jul 15, 2025
Merged

add function call and $sep syntax#14
ehwan merged 12 commits intomainfrom
function

Conversation

@ehwan
Copy link
Owner

@ehwan ehwan commented Jul 15, 2025

No description provided.

@ehwan ehwan requested a review from Copilot July 15, 2025 05:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new $sep pattern to allow delimiter-separated repetition in grammars.

  • Implements PatternInternal::Sep to generate plus (+) and star (*) repetition rules.
  • Extends lexer, parser, and PatternArgs to recognize and handle the $sep(base, delim, +|*) syntax.
  • Updates the AST builder, example JSON grammar, and documentation (SYNTAX.md) to use the new $sep form.

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 $sep syntax (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 to PatternArgs::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>
@ehwan ehwan marked this pull request as ready for review July 15, 2025 05:11
@ehwan ehwan merged commit 8c18296 into main Jul 15, 2025
1 check passed
@ehwan ehwan deleted the function branch July 15, 2025 05:11
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