Expand description
AOT Bop → Rust transpiler.
transpile takes a Bop source string, parses it with bop-lang,
and emits Rust source that links against bop-lang (for
Value, operators, and language-level
builtins) and optionally bop-sys (for the standard host).
The emitted code is intentionally human-readable: user-defined
Bop functions become top-level Rust fns, the top-level program
becomes run_program, and the main entry point drives it
against [bop_sys::StandardHost]. Run the output with rustc or
cargo build to produce a native binary.
§Scope (v1 starter)
Supported today:
- All literals (numbers, strings, bools,
none, arrays, dicts) - Binary / unary operators, including short-circuit
&&/|| let, assign, compound assign on plain variablesif/else(both as statement and expression)while,repeat,for x in ...(over arrays, ranges, or strings)break,continue- Built-in function calls (
print,range,str,int,type,abs,min,max,rand,len,inspect) - User-defined functions with recursion
- Indexed reads (
arr[i],dict[k],"str"[i])
Not yet emitted (tracked for follow-ups — the transpiler returns an error naming the missing feature):
- Method calls (e.g.
arr.push(1)) - String interpolation (
"hi {name}") - Indexed writes (
arr[i] = val,arr[i] += 1) BopLimitssandbox mode (step / memory enforcement in the emitted code)
Structs§
- Options
- Options that control the shape of the emitted Rust.
Functions§
- modules_
from_ map - Build a
ModuleResolverfrom an in-memory name→source map. Convenience for tests and simple embedders. - transpile
- Parse Bop source and emit the equivalent Rust source.
- transpile_
ast - Lower-level entry point: emit Rust from an already-parsed AST.
Type Aliases§
- Module
Resolver - A compile-time module resolver. The AOT runs this eagerly for
every
useit encounters, threading the entire module graph into the generated Rust. Same contract asbop::BopHost::resolve_module:None= not handled,Some(Ok(source))= module source text,Some(Err(_))= resolver failure.