| Crates.io | gleamgen |
| lib.rs | gleamgen |
| version | 0.1.0 |
| created_at | 2025-07-27 05:32:30.585769+00 |
| updated_at | 2025-07-27 05:32:30.585769+00 |
| description | Gleam generator. |
| homepage | |
| repository | https://github.com/aleph-lang/gleamgen |
| max_upload_size | |
| id | 1769732 |
| size | 16,983 |
aleph-syntax-treeThis crate provides a code generator that transforms an abstract syntax tree (AST) from the aleph-syntax-tree crate into Gleam source code.
AlephTree nodes into Gleam source codeInt, Float, Bool, String, BytesArray, TupleIf, Let, LetRec, MatchAnd, Or, Add, Sub, Mul, Div, Eq, LE, Incase expressionsClass, While, Put, Remove, or complex constructsEnsure you depend on the aleph-syntax-tree crate.
use aleph_syntax_tree::syntax::AlephTree as at;
use your_crate::generate;
fn main() {
let ast = at::Let {
var: "answer".into(),
is_pointer: false,
value: Box::new(at::Int { value: "42".into() }),
expr: Box::new(at::Return {
value: Box::new(at::Var { var: "answer".into(), is_pointer: false }),
}),
};
let gleam_code = generate(ast);
println!("{}", gleam_code);
}
let answer = 42
answer
pub fn generate(ast: AlephTree) -> String
Returns the generated Gleam code as a String.
Put, Remove, or While loopsLet expressions are line-based, no expression wrappingcase and pub fn formats