glisp/ast
// Represents an expression in a Lisp-like language. // Converts an expression to its string representation.
Types
The expression can be one of:
Atom: A symbolic name or identifier (e.g.,+,define, variable names)Number: An integer valueList: A list of expressions, typically representing function calls or special formsBuiltin: A built-in function that can evaluate lists of expressions
pub type Expr {
Atom(String)
Number(Int)
List(List(Expr))
Builtin(fn(List(Expr)) -> Result(Expr, String))
}
Constructors
-
Atom(String) -
Number(Int) -
List(List(Expr)) -
Builtin(fn(List(Expr)) -> Result(Expr, String))
Values
pub fn expr_to_string(expr: Expr) -> String
This function returns a human-readable string that represents the given expression:
- Atoms are converted to their name
- Numbers are converted to their string representation
- Lists are converted recursively with elements joined by spaces and enclosed in parentheses
- Builtin functions are represented as “#
”