How terror/val works
Project type and purpose
• “val” is a multi‐target language runtime and CLI tool written in Rust. It provides:
• A command‑line REPL/file evaluator for an arbitrary‑precision calculator language
• A Rust library (core engine) exposed programmatically
• A WebAssembly target (crates/val‑wasm) to embed the engine in browsers
• A React/TypeScript web playground (www) that loads the WASM module
• Auxiliary tools include a Python example‑generator, benchmarks, tests, and CI/CD pipelines.
File structure
• Top level: Rust package (Cargo.toml), src/ (core CLI & lib), benches/, tests/, examples/, tools/, crates/val-wasm/, www/
• src/ contains modules for:
Parser (parser.rs + GRAMMAR.txt using chumsky)
AST (ast.rs + ast_node.rs)
Evaluator & environment (evaluator.rs, environment.rs)
Highlighter (highlighter.rs)
Error handling (error.rs), value types (value.rs), built‑ins, etc.
• crates/val-wasm: compiles the same engine to WebAssembly with wasm‑bindgen
• www/: Vite‐bundled React/TS app
Loads val_bg.wasm + JS glue (val.js, val.d.ts)
Editor + AST visualizer + settings dialog + example loader
• tools/example‑generator: Python CLI to sync/generate .val example files
• .github/workflows: CI for Rust build/test, WASM build, Web build, and release
README for additional insights
• Confirms architecture: CLI uses rustyline for REPL, core engine leverages chumsky & ariadne, WASM binding for web, built‑ins listed
• No external database—pure in‑memory evaluation pipeline
Detail without over‑complicating
• WASM crate as “same engine → WebAssembly”
• Flow of .val example files from disk into both frontends
• CI pipelines feeding into each build target