add some boolean operations, tests for

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-03-02 09:43:12 -08:00
parent c1d83a6285
commit 28e158f110
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
5 changed files with 292 additions and 4 deletions

View file

@ -23,6 +23,7 @@ use std::rc::Rc;
pub mod append;
pub mod control;
pub mod boolean;
//pub mod str;
/// static_stdlib
@ -79,6 +80,66 @@ pub fn static_stdlib(syms: &mut SymTable) -> Result<(), String> {
},
);
syms.insert(
"and".to_string(),
Symbol {
name: String::from("and"),
args: Args::Infinite,
conditional_branches: false,
value: ValueType::Internal(Rc::new(boolean::bool_and_callback)),
}
);
syms.insert(
"or".to_string(),
Symbol {
name: String::from("or"),
args: Args::Infinite,
conditional_branches: false,
value: ValueType::Internal(Rc::new(boolean::bool_or_callback)),
}
);
syms.insert(
"xor".to_string(),
Symbol {
name: String::from("xor"),
args: Args::Infinite,
conditional_branches: false,
value: ValueType::Internal(Rc::new(boolean::bool_xor_callback)),
}
);
syms.insert(
"not".to_string(),
Symbol {
name: String::from("not"),
args: Args::Strict(vec![Type::Bool]),
conditional_branches: false,
value: ValueType::Internal(Rc::new(boolean::bool_not_callback)),
}
);
syms.insert(
"eq?".to_string(),
Symbol {
name: String::from("eq?"),
args: Args::Infinite,
conditional_branches: false,
value: ValueType::Internal(Rc::new(boolean::bool_iseq_callback)),
}
);
syms.insert(
"toggle".to_string(),
Symbol {
name: String::from("toggle"),
args: Args::Lazy(1),
conditional_branches: true,
value: ValueType::Internal(Rc::new(boolean::bool_toggle_callback)),
}
);
Ok(())
}