Merged
Conversation
Implemented a transpiler following the REVISED_STRATEGY.md approach: - Converts W language code to idiomatic Rust source code - Leverages Rust's compilation process for safety guarantees - Maps W types directly to Rust stdlib types Key Features: - Function definitions with type annotations (Square[x: int] := x * x) - Function calls with nested composition - List support (List → Vec) - Map support (Map → HashMap) - Binary operations (arithmetic, comparison) - Proper type inference and return type generation - PascalCase → snake_case naming conversion - Debug formatting for complex types Implementation Details: - Added peek_token() to lexer for lookahead parsing - Fixed := token recognition in lexer - Unified function call/definition parser with disambiguation - Proper expression vs statement generation - Automatic main() wrapper for standalone expressions Examples: - hello_world.w: Basic Print functionality - list_example.w: Vec generation and debug printing - arithmetic.w: Binary operations - multiple_args.w: Multiple function arguments - function_def.w: Function definition transpilation See TRANSPILER_DEMO.md for complete documentation and examples.
Implements full set of Rust primitive types following Rust's defaults: - Integer literals now default to i32 (not i64) like Rust - Float literals default to f64 like Rust - Support for all Rust integer types (i8, i16, i32, i64, i128, isize) - Support for all Rust unsigned types (u8, u16, u32, u64, u128, usize) - Support for both f32 and f64 floats - Backward compatible type names (int→i32, float→f64) Changes: - Updated AST Type enum with 20+ primitive types - Enhanced parser to recognize all type keywords (Int8, UInt32, etc.) - Fixed lexer to parse identifiers with digits (UInt8, Int64, etc.) - Updated code generator to map all types correctly - Changed Expression::Number from i64 to i32 - Updated Token::Number from i64 to i32 - Enhanced documentation with complete type mapping table Examples added: - types_demo.w: UInt8 parameters - types_i64.w: Int64 usage - types_float32.w: Float32 usage - comprehensive_types.w: Working demonstration This aligns the transpiler with Rust's type system conventions and gives users fine-grained control over integer sizes.
Implements all fundamental Rust container types with generic syntax: - Array[T, N] → [T; N] (fixed-size arrays) - Slice[T] → &[T] (slice references) - HashSet[T] → HashSet<T> - BTreeMap[K, V] → BTreeMap<K, V> (sorted maps) - BTreeSet[T] → BTreeSet<T> (sorted sets) Previously only List[T] and Map[K,V] were supported. Implementation Details: - Extended AST Type enum with 5 new container variants - Enhanced parser with parse_generic_type() for generic syntax - Added expect_token() helper for cleaner parsing - Parser now handles type parameters in brackets - Array type includes size parameter (usize) - Updated code generator to map all container types to Rust Type Syntax Examples: - List[Int32] → Vec<i32> - Array[UInt8, 256] → [u8; 256] - Slice[UInt8] → &[u8] - HashSet[String] → HashSet<String> - BTreeMap[Int32, String] → BTreeMap<i32, String> - BTreeSet[Int64] → BTreeSet<i64> All type mappings verified with test examples. Documentation updated with complete container type table. Files Modified: - src/ast.rs: Added 5 new Type variants - src/parser.rs: Added generic type parsing logic - src/rust_codegen.rs: Added type mappings for all containers - TRANSPILER_DEMO.md: Updated with container type documentation Test Files Added: - examples/containers_*.w: Individual container type tests - examples/all_containers.w: Comprehensive demonstration
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.
No description provided.