Skip to content

Initialize ZenoRust project for Rust migration#11

Open
nextcore wants to merge 17 commits intomainfrom
feat/init-zeno-rust-11922689703418189888
Open

Initialize ZenoRust project for Rust migration#11
nextcore wants to merge 17 commits intomainfrom
feat/init-zeno-rust-11922689703418189888

Conversation

@nextcore
Copy link
Owner

@nextcore nextcore commented Feb 6, 2026

This PR initializes the ZenoRust project to begin the migration of ZenoEngine to Rust. It sets up the directory structure with source/ for scripts and src/ for Rust code, uses Rust edition 2024, and includes a basic "Hello World" proof of concept.


PR created automatically by Jules for task 11922689703418189888 started by @nextcore

- Created `ZenoRust` directory for the Rust rewrite.
- Initialized Rust project with `edition = "2024"`.
- Created `source/` directory for ZenoLang scripts as requested.
- Added `ZenoRust/source/test.zl` sample script.
- Added `.gitignore` to exclude build artifacts.
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Added `logos` dependency for high-performance lexing.
- Implemented `lexer.rs` to tokenize ZenoLang syntax (keywords, strings, symbols).
- Implemented `parser.rs` (recursive descent) to parse `print` statements.
- Implemented `evaluator.rs` to execute the AST.
- Updated `main.rs` to run scripts from `source/` directory.
- Added unit tests for the interpreter logic.
- Updated `lexer.rs` to support `let`, `=`, `+`, `-`, `*`, `/`, and integers.
- Updated `parser.rs` with a Pratt parser to handle expression precedence.
- Updated `evaluator.rs` with an `Environment` (HashMap) for variable storage and arithmetic logic.
- Updated `main.rs` to use a mutable evaluator (for state persistence).
- Expanded `source/test.zl` with comprehensive test cases for variables and math.
- Added unit tests for variable assignment and mathematical operations.
- Updated `lexer.rs` with tokens for `if`, `else`, booleans, blocks (`{`, `}`), and comparisons.
- Updated `parser.rs` to handle `If` statements, `Block` scopes, and boolean/comparison expressions.
- Updated `evaluator.rs` with a scoped environment stack (`envs`) to handle variable shadowing.
- Implemented execution logic for `if/else` and boolean operations.
- Expanded `source/test.zl` with tests for control flow, scoping, and comparisons.
- Added comprehensive unit tests for these new features.
- Updated `lexer.rs` with `fn`, `return`, and `,` tokens.
- Updated `parser.rs` to handle function definitions, `return` statements, and function calls with arguments.
- Refactored `evaluator.rs` to use `Rc<RefCell<HashMap>>` for shared environments.
- Implemented function execution logic, including parameter binding and closure environment capturing.
- Expanded `source/test.zl` with tests for basic functions, closures, and nested calls.
- Added unit tests for function logic.
- Updated `evaluator.rs` with `Value::Builtin` variant to support native Rust functions.
- Implemented `len`, `upper`, and `str` built-in functions.
- Added `register_builtins` method to the Evaluator to inject default functions.
- Fixed `PartialEq` implementation for `Value` to safely handle function pointers.
- Expanded `source/test.zl` with tests for built-in functions.
- Added unit tests for built-in function execution.
- Updated `lexer.rs` with `[` and `]` tokens.
- Updated `parser.rs` to handle Array Literals and Indexing Expressions.
- Updated `evaluator.rs` with `Value::Array` using `Rc<RefCell<Vec<Value>>>` for mutable shared arrays.
- Implemented `push` built-in function for appending to arrays.
- Updated `len` built-in to support arrays.
- Added array tests to `source/test.zl` covering creation, indexing, mutation, and iteration.
- Added unit tests for array functionality.
- Updated `lexer.rs` to support Map syntax (`:`) and safely skip comments (`//`).
- Updated `parser.rs` to handle Map Literals (`{"key": val}`) and Assignment Statements (`lhs = rhs`).
- Updated `evaluator.rs` with `Value::Map` using `Rc<RefCell<HashMap>>` for mutable shared objects.
- Implemented evaluation logic for Map creation, string-key indexing (`obj["key"]`), and assignment to variables, arrays, and maps.
- Expanded `source/test.zl` with tests for Maps, assignments, and verified comment handling.
- Added comprehensive unit tests for Maps.
- Added `axum`, `tokio`, `serde`, and `serde_json` dependencies to `Cargo.toml`.
- Refactored `main.rs` to support both CLI (default) and Server modes (`cargo run -- server`).
- Implemented `POST /execute` endpoint that runs ZenoLang scripts and returns JSON output.
- Updated `Evaluator` to capture `print` output into a buffer for HTTP responses instead of just printing to stdout.
- Finalized Lexer to safely handle comments.
- Polished codebase by removing TODOs and ensuring compatibility with latest Rust environment.
- Added `reqwest` (blocking) dependency for HTTP client support.
- Implemented `http_get` and `http_post` built-in functions in `Evaluator`.
- Refactored `main.rs` to remove `#[tokio::main]` macro. Now `main` is synchronous by default (for CLI) and manually builds a Tokio runtime only for Server mode.
- Wrapped server handler execution in `tokio::task::spawn_blocking` to safely run the synchronous interpreter and blocking HTTP calls within the async server context.
- Fixed panic issues where blocking calls were made inside an async runtime context.
- Updated `test.zl` to verify HTTP functionality.
- Refactored `Evaluator` to be fully asynchronous using `async fn` and `async_recursion`.
- Replaced `Rc<RefCell<T>>` with `Arc<Mutex<T>>` for `Value::Array`, `Value::Map`, and `Env` to ensure thread safety (`Send` trait compliance).
- Updated built-in functions (`http_get`, `http_post`) to use asynchronous `reqwest::Client`.
- Restored `#[tokio::main]` in `main.rs` as the entire application stack is now async-compatible.
- Updated unit tests to run with `#[tokio::test]`.
- Resolved all compilation errors related to `Send` trait bounds and `PartialEq` implementation.
- Added `sqlx` dependency with `runtime-tokio` and `sqlite` features.
- Initialized `SqlitePool` (in-memory) in `main.rs` and passed it to the `Evaluator`.
- Implemented `db_execute(sql, params)` and `db_query(sql, params)` built-in functions.
- Updated `Evaluator` struct to hold the DB pool reference.
- Updated CLI and Server modes to propagate the DB pool correctly.
- Added comprehensive tests for table creation, insertion, and querying in `test.zl`.
- Finalized async architecture to support database operations alongside HTTP client.
- Added `sqlx` dependency with `mysql`, `postgres`, `sqlite`, and `any` features.
- Refactored `Evaluator` and `main.rs` to use `sqlx::AnyPool` for database abstraction.
- Updated `main.rs` to default to a file-based SQLite database (`zeno.db`) or use `DATABASE_URL` env var.
- Updated `db_execute` and `db_query` built-ins to support parameterized queries and generic result mapping.
- Ensured thread safety with `Arc<Mutex>` and async execution.
- Verified functionality with `test.zl` performing CREATE, INSERT, and SELECT operations.
- Implemented `ZenoBladeParser` (AST-based) for template parsing (`template.rs`).
- Added `BladeNode` types for Text, Interpolation (`{{ }}`), and Control Flow (`@if`, `@else`, `@endif`).
- Added `view(template, data)` built-in function to `Evaluator` that renders templates asynchronously.
- Updated `parser.rs` to expose `parse_expression_entry` for template logic parsing.
- Made `Evaluator.env` public to allow variable injection during rendering.
- Updated `test.zl` with comprehensive ZenoBlade test cases.
- Finalized feature parity with ZenoGo core features (Interpreter, DB, HTTP, Templating).
- Added `tracing` and `tracing-subscriber` for structured logging.
- Added `dotenvy` for configuration management (`DATABASE_URL`, `PORT`).
- Added `tower-http` middleware for request tracing and CORS.
- Updated `main.rs` to implement graceful shutdown handling (Ctrl+C).
- Restored `evaluator.rs` with full async capabilities and public `env` access.
- Fixed dependency imports and `env-filter` feature flags.
- Validated server behavior and shutdown logic.
- Implemented `/{*path}` wildcard routing in `main.rs` to handle dynamic API endpoints.
- Added Request Context injection (`path`, `method`, `body`, `query`) into the Evaluator environment.
- Implemented `response_json(obj)` and `response_status(code)` built-ins for structured API responses.
- Updated `Evaluator` to manage response state (`_response_body`, `_response_status`) across scopes using `env.update`.
- Updated `source/index.zl` to act as a central router for the application.
- Fixed scoping issues in built-ins to ensure response variables are set globally.
- Validated full request/response cycle with `curl` tests.
- Implemented robust `fetch(url, options)` built-in with full HTTP method and header support.
- Refactored `Evaluator` to pass `Env` to built-ins, enabling state modification from native functions.
- Implemented `response_json(obj)` and `response_status(code)` for full-stack API capabilities.
- Updated `main.rs` to handle wildcard routing (`/{*path}`) and serve structured JSON responses.
- Fixed `PartialEq` implementation for `Value` to support String equality (resolving critical logic bugs).
- Verified full request/response cycle with `curl` tests against a mock router in `source/index.zl`.
- Ensured thread safety with `Arc<Mutex>` and async execution throughout the stack.
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.

1 participant