Gleam Code Generator for aleph-syntax-tree
This crate provides a code generator that transforms an abstract syntax tree (AST) from the aleph-syntax-tree crate into Gleam source code.
Features
- Converts
AlephTreenodes into Gleam source code - Supports common language constructs:
- Literals:
Int,Float,Bool,String,Bytes - Data structures:
Array,Tuple - Control flow:
If,Let,LetRec,Match - Boolean and arithmetic operations:
And,Or,Add,Sub,Mul,Div,Eq,LE,In - Pattern matching with
caseexpressions - Comments, assertions, simple imports
- Literals:
- Skips unsupported nodes like
Class,While,Put,Remove, or complex constructs
Usage
Add to your project
Ensure you depend on the aleph-syntax-tree crate.
Example
use AlephTree as at;
use generate;
Output
let answer = 42
answer
Function Signature
Returns the generated Gleam code as a String.
Limitations
- Does not support class structures,
Put,Remove, orWhileloops Letexpressions are line-based, no expression wrapping- Match and function definitions are translated using simple
caseandpub fnformats - Pattern matching does not include type destructuring