Refactoring and Code clean#35
Merged
Merged
Conversation
- move single_char_class() to test as a helper function. - add parse_single_char() in Parser struct.
Only ast::Predicate items are left specially.
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors regex-core’s parser/AST internals to improve encapsulation and reduce broad dead_code allowances, plus aligns regex-cli’s thiserror dependency version with regex-core.
Changes:
- Move single-literal character class construction into
Parser::parse_single_charand update call sites. - Remove crate-level
#![allow(dead_code)]from several engine modules and scope it toPredicateonly. - Update
regex-clitothiserror = "2.0.18"and remove unusedCharRange::new.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/regex-core/src/engine/parser.rs | Encapsulates single-char class creation in the parser and updates tests accordingly. |
| crates/regex-core/src/engine/ast.rs | Removes broad dead-code allowance, removes CharRange::new, and scopes allow(dead_code) to Predicate. |
| crates/regex-core/src/engine/compiler.rs | Removes module-level #![allow(dead_code)]. |
| crates/regex-core/src/engine/evaluator.rs | Removes module-level #![allow(dead_code)]. |
| crates/regex-core/src/engine/instruction.rs | Removes module-level #![allow(dead_code)]. |
| crates/regex-cli/Cargo.toml | Bumps thiserror to 2.0.18. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
replace single_char_class() with Parser::parse_single_char().
Owner
Author
|
@copilot |
Contributor
|
@shu-kitamura I've opened a new pull request, #36, to work on those changes. Once the pull request is ready, I'll request review from you. |
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.
This pull request primarily refactors the
regex-corecrate's parser and AST engine to improve code clarity and maintainability, while also updating a dependency. The most significant changes include refactoring the single-character class construction logic, renaming variables for clarity, and updating thethiserrordependency.Parser and AST Refactoring:
single_char_class) to a private parser method (parse_single_char), and refactored all relevant code paths to use this method for consistency and encapsulation. [1] [2] [3]regextopatternin the parser to better reflect their purpose and improve code readability. [1] [2]Dependency Update:
thiserrordependency from version1.0to2.0.18inregex-cli/Cargo.toml.Code Cleanliness:
#![allow(dead_code)]directives from several engine modules, and moved the attribute to only where needed. [1] [2] [3] [4] [5] [6]CharRange::newconstructor, as it is no longer needed after the refactor.