aleph_syntax_tree/
lib.rs

1use crate::syntax::AlephTree as at;
2
3pub mod syntax;
4
5pub fn gen_list_expr_sep(ast_list: Vec<Box<at>>, f: fn(at, i64) -> String, sep: &str) -> String {
6    format!("{}", ast_list.into_iter().map(|e| f(*e, 0)).collect::<Vec<String>>().join(sep))
7}
8
9pub fn gen_list_expr(ast_list: Vec<Box<at>>, f: fn(at, i64) -> String) -> String {
10    gen_list_expr_sep(ast_list, f, " ")
11}
12
13// indentation for generators
14pub fn comp_indent_sep(indent: i64, sep: String) -> String {
15    let mut res = "".to_string();
16    for _ in 0..indent {
17        res.push_str(&sep);
18    }
19    res
20}
21
22// use comp_indent_sep with tab
23pub fn comp_indent(indent: i64) -> String {
24    comp_indent_sep(indent, String::from("    "))
25}