Erlang Code Generator for aleph-syntax-tree
This crate provides a code generator that converts an abstract syntax tree (AST) from the aleph-syntax-tree
crate into Erlang source code.
Overview
The core function generate(ast: AlephTree) -> String
takes an AlephTree
and returns equivalent Erlang code.
This generator supports:
- Basic expressions:
Add
,Sub
,Not
,Let
,If
, etc. - Data structures:
Tuple
,Array
,Bytes
- Control flow:
Match
,While
,Return
,Stmts
- Function definitions:
LetRec
,App
- COBOL-like constructs:
ProcedureDivision
,Perform
,Accept
,Display
, etc.
Output is properly indented and aims to be readable and idiomatic Erlang.
Installation
Add the dependency to your Cargo.toml
:
[]
= "0.1"
Usage
use AlephTree;
use generate;
Example
let ast = Let ;
Produces Erlang code:
X = 42,
X
Related
aleph-syntax-tree
– The AST definition cratealeph-syntax-tree
on crates.io