refactor: introduce utils crate and remove external regex dependency #266
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 PR introduces a new internal
utilscrate to centralize shared utility logic and replaces the heavyregexdependency with a lightweight, custom implementation. These changes significantly reduce compilation times and the final binary size by eliminating the overhead of the regex engine for simple string operations.Key Changes
1. New
utilsCrateCreated a dedicated workspace member for project-wide utilities:
utils/src/colorex.rs: Centralized terminal color formatting logic, moving it into a controlled internal module.utils/src/formatx.rs: Implemented a lightweightcount_placeholdersfunction to handle Wave's format string validation logic ({}counting).Cargo.tomlto includeutilsand configured dependencies across all crates.2. Dependency Optimization
regexcrate fromfront/parser/Cargo.toml.regex::Regexbased placeholder counting infront/parser/src/parser/io.rswith the more efficientutils::formatx::count_placeholders. This eliminates the need to compile the entire regex engine just for bracket counting.3. Project-Wide Integration
front/errorto useutils::colorexfor colored diagnostic output.src/main.rsandsrc/lib.rsto consume color utilities from the newutilscrate, ensuring a consistent UI across the compiler.Benefits
regexmacro and engine reduces total build time significantly.front/error,front/parser, and the main CLI.