Expand description
Code generator for compiling Sage to Rust.
This crate transforms a type-checked Sage AST into Rust source code
that can be compiled with rustc via Cargo.
§Example
ⓘ
use sage_codegen::Codegen;
use sage_parser::Program;
let program: Program = /* parse and check */;
let rust_code = Codegen::generate(&program);Structs§
- Codegen
Config - Full configuration for code generation.
- Generated
Project - Generated Rust project files.
- Generated
Test Project - Generated test project files (RFC-0012).
- Observability
Config - Observability configuration for tracing and metrics.
Enums§
- Persistence
Backend - Persistence backend configuration for @persistent fields.
- Runtime
Dep - How to specify the sage-runtime dependency in generated Cargo.toml.
Functions§
- generate
- Generate Rust code from a Sage program (single file).
- generate_
module_ tree - Generate Rust code from a module tree (multi-file project).
- generate_
module_ tree_ with_ config - Generate Rust code from a module tree with custom runtime dependency.
- generate_
module_ tree_ with_ full_ config - Generate Rust code from a module tree with full configuration.
- generate_
test_ program - Generate a test binary from a Sage test file (RFC-0012).
- generate_
test_ program_ with_ config - Generate a test binary with custom runtime dependency.
- generate_
with_ config - Generate Rust code from a Sage program with custom runtime dependency.
- generate_
with_ full_ config - Generate Rust code from a Sage program with full configuration.