#[cfg(feature = "iac-forge")]
mod iac_forge_impl {
use crate::ast::{Atom, Sexp};
use iac_forge::sexpr::SExpr;
impl From<&Sexp> for SExpr {
fn from(s: &Sexp) -> Self {
match s {
Sexp::Nil => SExpr::Nil,
Sexp::Atom(a) => match a {
Atom::Symbol(s) => SExpr::Symbol(s.clone()),
Atom::Keyword(s) => SExpr::Symbol(format!(":{s}")),
Atom::Str(s) => SExpr::String(s.clone()),
Atom::Int(n) => SExpr::Integer(*n),
Atom::Float(n) => SExpr::Float(*n),
Atom::Bool(b) => SExpr::Bool(*b),
},
Sexp::List(xs) => SExpr::List(xs.iter().map(Self::from).collect()),
Sexp::Quote(inner) => tagged("quote", inner),
Sexp::Quasiquote(inner) => tagged("quasiquote", inner),
Sexp::Unquote(inner) => tagged("unquote", inner),
Sexp::UnquoteSplice(inner) => tagged("unquote-splicing", inner),
}
}
}
impl From<Sexp> for SExpr {
fn from(s: Sexp) -> Self {
(&s).into()
}
}
fn tagged(tag: &str, inner: &Sexp) -> SExpr {
SExpr::List(vec![SExpr::Symbol(tag.to_string()), inner.as_ref().into()])
}
}