Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
993cbb7
feat(unilang): Initialize crate structure and testing framework
wanguardd Jun 22, 2025
771d020
feat(unilang): Define core data structures
wanguardd Jun 22, 2025
d69e6f0
feat(unilang): Implement command registry and registration API
wanguardd Jun 22, 2025
ad5d74b
feat(unilang): Implement lexer for CLI syntax
wanguardd Jun 22, 2025
7bf21d4
feat(unilang): Implement parser and global argument extraction
wanguardd Jun 22, 2025
dec1ecb
feat(unilang): Implement semantic analysis and command binding
wanguardd Jun 22, 2025
e551cf8
feat(unilang): Implement basic interpreter and execution context
wanguardd Jun 22, 2025
fa00994
feat(unilang): Implement standard error handling
wanguardd Jun 22, 2025
8c172bc
feat(unilang): Implement basic help generation
wanguardd Jun 22, 2025
bf4e894
test(unilang): Add integration tests for Phase 1 pipeline
wanguardd Jun 22, 2025
83fe7a9
style(unilang): Clean up and document src/lib.rs
wanguardd Jun 22, 2025
16155a8
style(unilang): Clean up and document src/data.rs
wanguardd Jun 22, 2025
61bb317
style(unilang): Clean up and document src/error.rs
wanguardd Jun 22, 2025
ef95608
style(unilang): Clean up and document src/help.rs
wanguardd Jun 22, 2025
efe93aa
style(unilang): Clean up and document src/interpreter.rs
wanguardd Jun 22, 2025
8ee8044
style(unilang): Clean up and document src/parsing.rs
wanguardd Jun 22, 2025
64be7d3
style(unilang): Clean up and document src/registry.rs
wanguardd Jun 22, 2025
5aea4a6
style(unilang): Clean up and document src/semantic.rs
wanguardd Jun 22, 2025
a4137c8
style(unilang): Clean up and document src/ca/**
wanguardd Jun 22, 2025
3917d20
style(unilang): Clean up and document tests/**
wanguardd Jun 22, 2025
ba02948
chore(unilang): Final verification of codestyle changes
wanguardd Jun 22, 2025
376a05f
Merge branch 'alpha' of github.com:Wandalen/wTools into alpha
wanguardd Jun 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions module/move/unilang/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Project Plan: Unilang Codestyle and Documentation Review

### Goal
* Iterate through each file of the `unilang` crate, ensuring all code adheres to the established codestyle rules and has concise, accurate documentation.

### Progress
* ✅ Codestyle Review Complete

### Target Crate
* module/move/unilang

### Relevant Context
* Files to Include (for AI's reference, if `read_file` is planned, primarily from Target Crate):
* All `.rs` files within `module/move/unilang/src` and `module/move/unilang/tests`.

### Expected Behavior Rules / Specifications (for Target Crate)
* All files must pass `cargo clippy` with the workspace lint settings without warnings.
* All public items should have clear, concise documentation.
* Code formatting should be consistent across the entire crate.

### Target File Structure (If Applicable, within Target Crate)
* No changes to the file structure are planned.

### Increments

* ✅ Increment 1: Review `src/lib.rs`
* Detailed Plan Step 1: Read the content of `src/lib.rs`.
* Detailed Plan Step 2: Apply codestyle fixes, including adding documentation for all public modules.
* Detailed Plan Step 3: Use `mod_interface` to structure the crate's public API.
* Pre-Analysis: The `lib.rs` file is the entry point to the crate and should be well-documented and structured.
* Crucial Design Rules: [Structuring: Modules with `mod_interface`](#structuring-modules-with-mod_interface), [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile.
* Commit Message: "style(unilang): Clean up and document src/lib.rs"
* ✅ Increment 2: Review `src/data.rs`
* Detailed Plan Step 1: Read the content of `src/data.rs`.
* Detailed Plan Step 2: Apply codestyle fixes (spacing, newlines, etc.).
* Detailed Plan Step 3: Add concise documentation to all public structs and their fields.
* Detailed Plan Step 4: Re-enable the `former` crate derive macros and attributes and fix any resulting compilation errors.
* Pre-Analysis: The file contains core data structures. The `former` derive is currently commented out and needs to be re-enabled and fixed.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile without errors or warnings.
* Commit Message: "style(unilang): Clean up and document src/data.rs"
* ✅ Increment 3: Review `src/error.rs`
* Detailed Plan Step 1: Read the content of `src/error.rs`.
* Detailed Plan Step 2: Apply codestyle fixes (spacing, newlines, etc.).
* Detailed Plan Step 3: Add concise documentation to the `Error` enum and its variants.
* Pre-Analysis: The file contains the basic error enum. It needs proper documentation and formatting.
* Crucial Design Rules: [Error Handling: Use a Centralized Approach](#error-handling-use-a-centralized-approach), [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile.
* Commit Message: "style(unilang): Clean up and document src/error.rs"
* ✅ Increment 4: Review `src/help.rs`
* Detailed Plan Step 1: Read the content of `src/help.rs`.
* Detailed Plan Step 2: Apply codestyle fixes (spacing, newlines, etc.).
* Detailed Plan Step 3: Add concise documentation to the `HelpGenerator` struct and its methods.
* Pre-Analysis: The file contains the basic help generator. It needs proper documentation and formatting.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile.
* Commit Message: "style(unilang): Clean up and document src/help.rs"
* ✅ Increment 5: Review `src/interpreter.rs`
* Detailed Plan Step 1: Read the content of `src/interpreter.rs`.
* Detailed Plan Step 2: Apply codestyle fixes (spacing, newlines, etc.).
* Detailed Plan Step 3: Add concise documentation to the `Interpreter` and `ExecutionContext` structs and their methods.
* Pre-Analysis: The file contains the basic interpreter. It needs proper documentation and formatting.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile.
* Commit Message: "style(unilang): Clean up and document src/interpreter.rs"
* ✅ Increment 6: Review `src/parsing.rs`
* Detailed Plan Step 1: Read the content of `src/parsing.rs`.
* Detailed Plan Step 2: Apply codestyle fixes (spacing, newlines, etc.).
* Detailed Plan Step 3: Add concise documentation to all public items (`Token`, `Lexer`, `Parser`, `Statement`, `Program`) and their methods/variants/fields.
* Pre-Analysis: The file contains the lexer and parser. It's a large file and will require careful review to ensure all items are documented and formatted correctly.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation), [New Lines for Blocks](#new-lines-for-blocks), [Spaces Around Symbols](#spaces-around-symbols).
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile.
* Commit Message: "style(unilang): Clean up and document src/parsing.rs"
* ✅ Increment 7: Review `src/registry.rs`
* Detailed Plan Step 1: Read the content of `src/registry.rs`.
* Detailed Plan Step 2: Apply codestyle fixes (spacing, newlines, etc.).
* Detailed Plan Step 3: Add concise documentation to the `CommandRegistry` struct, `CommandRegistryBuilder` struct, and their methods.
* Pre-Analysis: The file contains the command registry. It needs proper documentation and formatting.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile.
* Commit Message: "style(unilang): Clean up and document src/registry.rs"
* ✅ Increment 8: Review `src/semantic.rs`
* Detailed Plan Step 1: Read the content of `src/semantic.rs`.
* Detailed Plan Step 2: Apply codestyle fixes (spacing, newlines, etc.).
* Detailed Plan Step 3: Add concise documentation to the `VerifiedCommand` and `SemanticAnalyzer` structs and their methods.
* Pre-Analysis: The file contains the semantic analyzer. It needs proper documentation and formatting.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` to ensure the changes compile.
* Commit Message: "style(unilang): Clean up and document src/semantic.rs"
* ✅ Increment 9: Review `src/ca/` directory
* Detailed Plan Step 1: Read all files in `src/ca/` and its subdirectories.
* Detailed Plan Step 2: Refactor `src/ca/mod.rs`.
* Detailed Plan Step 3: Refactor `src/ca/parsing/mod.rs`.
* Detailed Plan Step 4: Refactor `src/ca/parsing/engine.rs`.
* Detailed Plan Step 5: Refactor `src/ca/parsing/error.rs`.
* Detailed Plan Step 6: Refactor `src/ca/parsing/input.rs`.
* Detailed Plan Step 7: Refactor `src/ca/parsing/instruction.rs`.
* Pre-Analysis: This directory seems to contain a secondary parsing engine or a more complex command architecture (`ca`). It needs to be reviewed for consistency with the rest of the crate.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation), [New Lines for Blocks](#new-lines-for-blocks), [Spaces Around Symbols](#spaces-around-symbols).
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo build -p unilang` after refactoring all files in the directory.
* Commit Message: "style(unilang): Clean up and document src/ca/**"
* ✅ Increment 10: Review `tests/` directory
* Detailed Plan Step 1: Read all files in `tests/` and its subdirectories.
* Detailed Plan Step 2: Refactor `tests/tests.rs`.
* Detailed Plan Step 3: Refactor `tests/inc/mod.rs`.
* Detailed Plan Step 4: Refactor `tests/inc/phase1/mod.rs`.
* Detailed Plan Step 5: Refactor `tests/inc/phase1/foundational_setup.rs`.
* Detailed Plan Step 6: Refactor `tests/inc/phase1/full_pipeline_test.rs`.
* Pre-Analysis: The test files need to be reviewed for clarity, documentation, and adherence to codestyle.
* Crucial Design Rules: [Comments and Documentation](#comments-and-documentation)
* Relevant Behavior Rules: N/A
* Verification Strategy: Run `cargo test -p unilang` to ensure all tests still pass.
* Commit Message: "style(unilang): Clean up and document tests/**"
* ✅ Increment 11: Final Verification
* Detailed Plan Step 1: Run `cargo clippy -- -D warnings` to ensure there are no warnings.
* Detailed Plan Step 2: Run `cargo test` to ensure all tests pass.
* Pre-Analysis: All files have been reviewed. A final check is needed to ensure the entire crate is clean.
* Crucial Design Rules: N/A
* Relevant Behavior Rules: N/A
* Verification Strategy: All checks must pass.
* Commit Message: "chore(unilang): Final verification of codestyle changes"

### Task Requirements
* Systematically review every `.rs` file.
* Apply codestyle fixes and add documentation as needed.

### Project Requirements
* Maintain consistency with the overall workspace codestyle.

### Notes & Insights
* This is a good opportunity to improve the overall quality and maintainability of the crate.
* The `former` crate usage is still disabled and should be noted for future work.
4 changes: 3 additions & 1 deletion module/move/unilang/src/ca/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//!
//! Commands aggregator library.
//! Command aggregator library for advanced command parsing and execution.
//!

/// Contains the parsing components for the command aggregator.
pub mod parsing;

mod private {}

crate::mod_interface!
{
/// Exposes the parsing module.
exposed use parsing;
}
13 changes: 11 additions & 2 deletions module/move/unilang/src/ca/parsing/engine.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
//! Main parser logic for unilang CLI syntax.
//!
//! Main parser logic for the command aggregator.
//!

#[ allow( unused_imports ) ]
use super::input::{ InputAbstraction, InputPart, DelimiterType, Location };
use super::instruction::GenericInstruction;
use super::error::ParseError;

/// The main parser engine.
///
/// The main parser engine for the command aggregator.
///
#[ derive( Debug ) ]
pub struct Parser;

impl Parser
{
///
/// Parses the input into a sequence of generic instructions.
///
/// This is the main entry point for the parsing engine, taking an
/// `InputAbstraction` and returning a `Vec` of `GenericInstruction`s
/// or a `ParseError`.
pub fn parse< 'a >( input : InputAbstraction< 'a > ) -> Result< Vec< GenericInstruction< 'a > >, ParseError >
{
// TODO: Implement parsing logic using InputAbstraction
Expand Down
15 changes: 14 additions & 1 deletion module/move/unilang/src/ca/parsing/error.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,51 @@
//! Error types for the unilang parser.
//!
//! Error types for the command aggregator parser.
//!

use super::input::Location;

///
/// Represents an error that occurred during parsing.
///
#[ derive( Debug, Clone, PartialEq, Eq ) ]
pub enum ParseError
{
/// An unexpected character or sequence was encountered.
UnexpectedToken
{
/// The location of the unexpected token.
location : Location,
/// The unexpected token.
token : String,
},
/// An unquoted value contained internal whitespace (based on E5 decision).
UnquotedValueWithWhitespace
{
/// The location of the value.
location : Location,
/// The value containing whitespace.
value : String,
},
/// An unterminated quote was found.
UnterminatedQuote
{
/// The location of the unterminated quote.
location : Location,
/// The quote character that was not terminated.
quote_char : char,
},
/// End of input was reached unexpectedly.
UnexpectedEndOfInput
{
/// The location where the end of input was unexpected.
location : Location,
},
/// A required element was missing.
MissingElement
{
/// The location where the element was expected.
location : Location,
/// A description of the missing element.
element_description : String,
},
// Add other specific error variants as needed during parser implementation.
Expand Down
Loading
Loading