macroctx: pass ctx JSON (caps) to user macros; add demo macro; docs: MacroCtx section and sandbox Box API; golden for for/foreach normalized AST

This commit is contained in:
Selfhosting Dev
2025-09-20 09:11:52 +09:00
parent daa5309ea9
commit 497da75f90
14 changed files with 188 additions and 506 deletions

View File

@ -1,73 +1,11 @@
/*!
* Nyash Rust Implementation - Everything is Box in Memory Safe Rust
*
* This is the main entry point for the Rust implementation of Nyash,
* demonstrating the "Everything is Box" philosophy with Rust's ownership system.
*
* The main function serves as a thin entry point that delegates to the CLI
* and runner modules for actual processing.
*/
// Core modules
pub mod ast;
pub mod box_arithmetic; // 🚀 Moved from box_trait.rs for better organization
pub mod box_factory; // 🏭 Unified Box Factory Architecture (Phase 9.78)
pub mod box_trait;
pub mod boxes;
pub mod channel_box;
pub mod core; // core::model (shared models)
pub mod environment;
pub mod exception_box;
pub mod finalization;
pub mod instance_v2; // 🎯 Phase 9.78d: Simplified InstanceBox implementation
// Legacy interpreter module is not included by default; when disabled, re-export lib's stub
#[cfg(feature = "interpreter-legacy")]
pub mod interpreter;
#[cfg(not(feature = "interpreter-legacy"))]
pub mod interpreter { pub use nyash_rust::interpreter::*; }
pub mod messaging; // 🌐 P2P Communication Infrastructure
pub mod method_box;
pub mod operator_traits;
pub mod parser;
pub mod scope_tracker; // VM scope lifecycle
pub mod stdlib;
pub mod tokenizer;
pub mod transport;
pub mod type_box; // 🌟 TypeBox revolutionary system
pub mod value; // 🔥 NyashValue Revolutionary System // 🌐 P2P Communication Infrastructure
// 🚀 MIR Infrastructure
pub mod mir;
// 🚀 Backend Infrastructure
pub mod backend;
// JIT subsystem (Phase 10)
pub mod jit;
pub mod semantics; // mirror library semantics module for crate path consistency in bin
// 📊 Performance Benchmarks (lib provides; bin does not re-declare)
// 🚀 Refactored modules for better organization
pub mod cli;
pub mod runner;
pub mod r#macro;
// BID-FFI / Plugin System (prototype)
pub mod bid;
// Configuration system
pub mod config;
// Runtime system (plugins, registry, etc.)
pub mod debug;
pub mod grammar; // Phase 11.9 unified grammar scaffolding
pub mod runner_plugin_init;
pub mod runtime;
pub mod syntax; // Phase 12.7: syntax sugar config and helpers (mirror lib layout)
Minimal CLI entry point for Nyash.
Delegates to the library crate (`nyash_rust`) for all functionality.
*/
use nyash_rust::cli::CliConfig;
use nyash_rust::config::env as env_config;
use runner::NyashRunner;
use nyash_rust::runner::NyashRunner;
/// Thin entry point - delegates to CLI parsing and runner execution
fn main() {
@ -84,12 +22,13 @@ fn main() {
#[cfg(test)]
mod tests {
use super::*;
use box_trait::{BoxCore, NyashBox, StringBox};
use nyash_rust::box_trait::{BoxCore, NyashBox, StringBox};
#[test]
fn test_main_functionality() {
// This test ensures the module structure is correct
// Smoke: library module path wiring works
let string_box = StringBox::new("test".to_string());
assert_eq!(string_box.to_string_box().value, "test");
let _ = (); // CLI wiring exists via nyash_rust::cli
}
}