Skip to content

Refactoring and Code clean#35

Merged
shu-kitamura merged 4 commits into
mainfrom
develop
Feb 12, 2026
Merged

Refactoring and Code clean#35
shu-kitamura merged 4 commits into
mainfrom
develop

Conversation

@shu-kitamura

Copy link
Copy Markdown
Owner

This pull request primarily refactors the regex-core crate'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 the thiserror dependency.

Parser and AST Refactoring:

  • Moved the single-character class constructor from a free function (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]
  • Renamed function and variable names from regex to pattern in the parser to better reflect their purpose and improve code readability. [1] [2]

Dependency Update:

  • Updated the thiserror dependency from version 1.0 to 2.0.18 in regex-cli/Cargo.toml.

Code Cleanliness:

  • Removed unnecessary #![allow(dead_code)] directives from several engine modules, and moved the attribute to only where needed. [1] [2] [3] [4] [5] [6]
  • Removed the unused CharRange::new constructor, as it is no longer needed after the refactor.

- move single_char_class() to test as a helper function.
- add parse_single_char() in Parser struct.
Only ast::Predicate items are left specially.
Copilot AI review requested due to automatic review settings February 12, 2026 11:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_char and update call sites.
  • Remove crate-level #![allow(dead_code)] from several engine modules and scope it to Predicate only.
  • Update regex-cli to thiserror = "2.0.18" and remove unused CharRange::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.

Comment thread crates/regex-core/src/engine/ast.rs
Comment thread crates/regex-core/src/engine/parser.rs Outdated
replace single_char_class() with Parser::parse_single_char().
@shu-kitamura

Copy link
Copy Markdown
Owner Author

@copilot
Complete fix review

Copilot AI commented Feb 12, 2026

Copy link
Copy Markdown
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.

@shu-kitamura
shu-kitamura merged commit 066496a into main Feb 12, 2026
1 check passed
@shu-kitamura
shu-kitamura deleted the develop branch February 12, 2026 12:20
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.

3 participants