use crate::error::Position;
use crate::sexp::{Keyword, List, Number, SExp, StringLit, Symbol};
pub fn sym(name: impl Into<String>) -> SExp {
SExp::Symbol(Symbol::new(name, Position::new(0, 1, 1)))
}
pub fn kw(name: impl Into<String>) -> SExp {
SExp::Keyword(Keyword::new(name, Position::new(0, 1, 1)))
}
pub fn string(value: impl Into<String>) -> SExp {
SExp::String(StringLit::new(value, Position::new(0, 1, 1)))
}
pub fn num(value: impl ToString) -> SExp {
SExp::Number(Number::new(value.to_string(), Position::new(0, 1, 1)))
}
pub fn list(elements: Vec<SExp>) -> SExp {
SExp::List(List::new(elements, Position::new(0, 1, 1)))
}
pub fn empty_list() -> SExp {
list(vec![])
}
pub fn kwarg(key: &str, value: SExp) -> Vec<SExp> {
vec![kw(key), value]
}
pub fn typed_node(type_name: &str, fields: Vec<SExp>) -> SExp {
let mut elements = vec![sym(type_name)];
elements.extend(fields);
list(elements)
}
pub fn kwargs(pairs: Vec<Vec<SExp>>) -> Vec<SExp> {
pairs.into_iter().flatten().collect()
}