| Crates.io | erlanggen |
| lib.rs | erlanggen |
| version | 0.1.0 |
| created_at | 2025-07-27 05:33:34.629817+00 |
| updated_at | 2025-07-27 05:33:34.629817+00 |
| description | Erlang generator. |
| homepage | |
| repository | https://github.com/aleph-lang/erlanggen |
| max_upload_size | |
| id | 1769734 |
| size | 31,352 |
aleph-syntax-treeThis crate provides a code generator that converts an abstract syntax tree (AST) from the aleph-syntax-tree crate into Erlang source code.
The core function generate(ast: AlephTree) -> String takes an AlephTree and returns equivalent Erlang code.
This generator supports:
Add, Sub, Not, Let, If, etc.Tuple, Array, BytesMatch, While, Return, StmtsLetRec, AppProcedureDivision, Perform, Accept, Display, etc.Output is properly indented and aims to be readable and idiomatic Erlang.
Add the dependency to your Cargo.toml:
[dependencies]
aleph-syntax-tree = "0.1"
use aleph_syntax_tree::syntax::AlephTree;
use your_crate::generate;
fn main() {
let ast: AlephTree = /* build or parse your AST */;
let code = generate(ast);
println!("{}", code);
}
let ast = AlephTree::Let {
var: "X".into(),
is_pointer: false,
value: Box::new(AlephTree::Int { value: "42".into() }),
expr: Box::new(AlephTree::Return {
value: Box::new(AlephTree::Var {
var: "X".into(),
is_pointer: false,
}),
}),
};
Produces Erlang code:
X = 42,
X
aleph-syntax-tree – The AST definition cratealeph-syntax-tree on crates.io