| Crates.io | cral |
| lib.rs | cral |
| version | 0.2.0 |
| created_at | 2026-01-24 08:25:18.088269+00 |
| updated_at | 2026-01-24 09:55:59.480136+00 |
| description | C code gen. |
| homepage | |
| repository | https://github.com/ZJZCORE/cral/ |
| max_upload_size | |
| id | 2066399 |
| size | 19,748 |
This crate can generate c code from ASTs.
This crate's design and functionality inspired by the crustal crate.
This crate is publish to crates.io.
Add this crate to your project using Cargo:
cargo add cral
Alternatively, add the following to your Cargo.toml dependencies section:
[dependencies]
cral = "0.0.0" # Replace with actual version
use cral::prelude::*;
let f = File::new([
Decl::include("stdio.h", true),
Decl::fn_decl(Type::void(), "main", [], Block::new([
Stmt::Expr(Expr::call(
Expr::name("printf"),
[Expr::literal_str("HelloWorld")],
))
]))
]);
f.save("main.c").unwrap();
Generated main.c file content:
#include<stdio.h>
void main() {
printf("HelloWorld");
}