How takashiidobe/slate works
Slate is a C23-to-Rust transpiler. Its principal workflow takes compiler arguments and a C translation unit, preprocesses and parses the source, produces typed IR, lowers that representation to Rust, then applies Rust refinement passes and emits formatted output. Separate capabilities include target sysroot management and project translation from compilation databases. The README documents the end-to-end workflow; source excerpts are partial, so internal links not directly established by those excerpts are marked unverified or omitted.
Main entry points: main.rs Slate CLI · mod.rs Preprocessor · lib.rs Sysroot Manager · compiler_args.rs Compiler Arguments
Components 25
C Frontend
- Compiler Arguments
crates/slate-parser/src/compiler_args.rs - C Dialect
crates/slate-parser/src/dialect.rs - C Lexer
crates/slate-parser/src/lexer.rs - Preprocessor
crates/slate-parser/src/pp/mod.rs - C Syntax Tree
crates/slate-parser/src/ast.rs - Constant Expressions
crates/slate-parser/src/const_expr.rs - Typed Parser IR
crates/slate-parser/src/ir/mod.rs - Semantic Analysis
crates/slate-parser/src/sema/ctype/mod.rs
Targets And Headers
- Target Configuration
crates/slate-parser/src/target_info.rs - ISA Support
crates/slate-parser/src/target/x86_isa.rs - Sysroot Commands
crates/slate/src/sysroot.rs - Sysroot Manager
crates/slate-sysroots/src/lib.rs - Compiler Headers
crates/slate-sysroots/src/compiler_headers.rs - Header Downloads
crates/slate-sysroots/src/download.rs
Rust Translation
- Slate CLI
crates/slate/src/main.rs - Project Commands
crates/slate/src/compile_commands.rs - Rust Lowering
crates/slate/src/frontend/lowerer.rs - Rust AST
crates/slate/src/backend/rust_ast.rs - Rust Code Generation
crates/slate/src/backend/codegen.rs - Rust Output
crates/slate/src/backend/format.rs
Rust Refinement
- Rewrite Passes
crates/slate/src/backend/engine/mod.rs - Interprocedural Analysis
crates/slate/src/backend/interproc/length_lattice.rs
Other components
- C Project Developer
- Compilation Database
- Header Sources
Connections 25
- C Project Developer → Slate CLI: runs translation
README.md - Compilation Database → Slate CLI: provides commands
README.md - Slate CLI → Project Commands: translates project
- Slate CLI → Compiler Arguments: passes compiler args
- Compiler Arguments → C Dialect: configures language
crates/slate-parser/src/dialect.rs - Compiler Arguments → Target Configuration: configures target
crates/slate-parser/src/compiler_args.rs - Slate CLI → Preprocessor: uses built-in frontend
README.md - Preprocessor → C Lexer: expands tokens
crates/slate-parser/src/pp/mod.rs - Preprocessor → C Syntax Tree: prepares C input
crates/slate-parser/src/pp/mod.rs - C Syntax Tree → Constant Expressions: uses expressions
crates/slate-parser/src/ast.rs - C Syntax Tree → Typed Parser IR: lowers to IR
crates/slate-parser/src/ir/mod.rs - Typed Parser IR → Semantic Analysis: analyzes types
- Target Configuration → ISA Support: selects ISA
- Sysroot Commands → Sysroot Manager: installs target
- Sysroot Manager → Compiler Headers: resolves headers
crates/slate-sysroots/src/lib.rs - Sysroot Manager → Header Downloads: uses downloads
crates/slate-sysroots/src/lib.rs - Header Sources → Header Downloads: supplies headers
- Preprocessor → Sysroot Manager: reads include paths
- Typed Parser IR → Rust Lowering: lowers to Rust
README.md - Rust Lowering → Rust AST: builds Rust AST
- Rust AST → Rust Code Generation: generates Rust
crates/slate/src/backend/rust_ast.rs - Rust Code Generation → Rewrite Passes: refines output
- Rewrite Passes → Interprocedural Analysis: runs analyses
- Rewrite Passes → Rust Output: formats Rust
README.md - Rust Code Generation → Rust Output: emits Rust