add log
This commit is contained in:
parent
7dcca519d9
commit
aeb5dc0ddc
1 changed files with 20 additions and 0 deletions
20
src/main.rs
20
src/main.rs
|
@ -570,6 +570,7 @@ fn simp(
|
||||||
for i in 0..step_limit {
|
for i in 0..step_limit {
|
||||||
expr = expr
|
expr = expr
|
||||||
.apply_special_form::<Genslop>()
|
.apply_special_form::<Genslop>()
|
||||||
|
.apply_special_form::<Log>()
|
||||||
.apply_special_form::<Let>()
|
.apply_special_form::<Let>()
|
||||||
.apply_special_form::<Eq>();
|
.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> {
|
fn make_rule(sexp: &Sexp) -> Option<Rule> {
|
||||||
match sexp {
|
match sexp {
|
||||||
Sexp::List(xs) => match &xs[..] {
|
Sexp::List(xs) => match &xs[..] {
|
||||||
|
|
Loading…
Reference in a new issue