diff --git a/src/main.rs b/src/main.rs index 21d1e37..24d9e75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -570,6 +570,7 @@ fn simp( for i in 0..step_limit { expr = expr .apply_special_form::() + .apply_special_form::() .apply_special_form::() .apply_special_form::(); @@ -704,6 +705,25 @@ impl SpecialForm<'_> for Genslop { } } +static LOG: Lazy = Lazy::new(|| TABLE.lock().unwrap().intern("log").unwrap()); + +#[derive(Debug, Clone)] +struct Log<'src>(&'src Sexp); + +impl<'src> SpecialForm<'src> for Log<'src> { + fn from_sexp(sexp: &'src Sexp) -> Option { + match sexp { + Sexp::List(xs) if xs.len() == 2 && *xs[0].atom()? == *LOG => Some(Self(&xs[1])), + _ => None, + } + } + + fn eval(self) -> Sexp { + eprintln!("LOG: {}", self.0); + self.0.clone() + } +} + fn make_rule(sexp: &Sexp) -> Option { match sexp { Sexp::List(xs) => match &xs[..] {