Skip to content

fix: make repl support multi-line code#47

Merged
martian56 merged 1 commit intomainfrom
13-repl-doesnt-support-multiple-lines
Apr 7, 2026
Merged

fix: make repl support multi-line code#47
martian56 merged 1 commit intomainfrom
13-repl-doesnt-support-multiple-lines

Conversation

@martian56
Copy link
Copy Markdown
Owner

This pull request introduces improvements to the Raven REPL, enabling robust multi-line input by tracking delimiter balance and providing a better user experience. The main changes include a new delimiter_depth utility, a refactored REPL input loop, and supporting code organization updates.

REPL enhancements:

  • Added a new delimiter_depth function in src/repl.rs to accurately count unclosed parentheses, braces, and brackets outside of strings and comments, supporting multi-line input in the REPL. Includes comprehensive unit tests.
  • Refactored the REPL in src/main.rs to use a new read_repl_snippet function, which reads user input until all delimiters are balanced, allowing for multi-line code entry. The prompt now changes to ...> for continued input.
  • Improved REPL command handling with a new ReplInput enum, providing clearer handling of exit, quit, help, and code input.

Code organization:

  • Added a new repl module in src/lib.rs to encapsulate REPL-related helpers.
  • Updated imports in src/main.rs to use the new delimiter_depth function from the repl module.

Other:

  • Bumped the crate version in Cargo.toml from 1.6.3 to 1.6.4 to reflect these improvements.

Closes #13

@martian56 martian56 added this to the Package Manager milestone Apr 7, 2026
@martian56 martian56 self-assigned this Apr 7, 2026
@martian56 martian56 added bug Something isn't working enhancement New feature or request labels Apr 7, 2026
@martian56 martian56 merged commit 9166772 into main Apr 7, 2026
4 checks passed
@martian56 martian56 deleted the 13-repl-doesnt-support-multiple-lines branch April 7, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REPL doesn't support multiple lines

1 participant