This commit is contained in:
mehbark 2023-06-13 14:34:43 -04:00
parent 7dcca519d9
commit aeb5dc0ddc

View file

@ -570,6 +570,7 @@ fn simp(
for i in 0..step_limit {
expr = expr
.apply_special_form::<Genslop>()
.apply_special_form::<Log>()
.apply_special_form::<Let>()
.apply_special_form::<Eq>();
@ -704,6 +705,25 @@ impl SpecialForm<'_> for Genslop {
}
}
static LOG: Lazy<Symbol> = 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<Self> {
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<Rule> {
match sexp {
Sexp::List(xs) => match &xs[..] {