refactor: organize parser into modular components#263
Merged
LunaStev merged 1 commit intowavefnd:masterfrom Jan 4, 2026
Merged
Conversation
Split the large `parser.rs` file into logical submodules within `front/parser/src/parser/` to improve code structure and maintainability. Changes: - **New Module Structure**: - `asm.rs`: `parse_asm_block` - `control.rs`: `parse_if`, `parse_while`, `parse_for` - `decl.rs`: `parse_variable_decl`, `parse_const`, `parse_let`, `parse_var` - `expr.rs`: `parse_function_call`, `parse_parentheses` - `functions.rs`: `parse_function`, `parse_parameters`, `extract_body` - `io.rs`: `parse_println`, `parse_print`, `parse_input` - `items.rs`: `parse_import`, `parse_proto`, `parse_struct` - `stmt.rs`: `parse_assignment`, `parse_block`, `parse_statement` - `types.rs`: Type parsing logic moved from `type_system.rs` (`parse_type`, `parse_type_from_token`, etc.) - `parse.rs`: Main `parse()` entry point and module declarations. - **Cleanup**: - Removed `type_system.rs` (logic moved to `types.rs`). - Updated `mod.rs` to expose the new structure. - Fixed imports across the crate to point to new module locations. - Resolved unused import warnings in `main.rs` and `runner.rs`. This refactoring decouples parser components, making it easier to navigate and extend individual language features. Signed-off-by: LunaStev <luna@lunastev.org>
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 PR performs a major refactoring of the parsing logic by decomposing the monolithic
parser.rsand the auxiliarytype_system.rsinto a well-structured directory of specialized submodules. This change significantly improves the maintainability and navigability of the frontend logic.Key Changes
1. Parser Modularization
The parser has been split into the following submodules within
front/parser/src/parser/:asm.rs: Logic for parsing inline assembly blocks (asm { ... }).control.rs: Handles control flow structures includingif,while, andforloops.decl.rs: Consolidates variable and constant declarations (const,let,mut,var).expr.rs: Manages expression-related parsing such as function calls and grouped parentheses.functions.rs: Handles function definitions, parameter lists, and body extraction.io.rs: Logic for I/O statements includingprint,println, andinput.items.rs: Parsing for top-level items such asimport,proto, andstruct.stmt.rs: Generic statement handling, including assignments and block parsing ({ ... }).types.rs: Consolidated type parsing logic (moved from the now-deletedtype_system.rs).parse.rs: The primary entry point containing the mainparse()function.2. Cleanup & Integration
front/parser/src/parser/type_system.rsand integrated its logic intoparser/types.rsto keep type-related parsing logic in one place.mod.rsto export the new module structure and refactored imports across thewaveccrate (specifically inmain.rsandrunner.rs) to resolve warnings and ensure compatibility with the new structure.Impact
parser.rs.