rustfmt
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
ecbc47d4fe
commit
bc09cb07b1
17 changed files with 236 additions and 217 deletions
|
|
@ -17,7 +17,7 @@
|
|||
use crate::segment::{Ctr, Seg};
|
||||
use crate::sym::SymTable;
|
||||
|
||||
pub fn append_callback (ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
pub fn append_callback(ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
if let Ctr::Seg(ref s) = *ast.car {
|
||||
let mut temp = s.clone();
|
||||
if let Ctr::Seg(ref list) = *ast.cdr {
|
||||
|
|
@ -47,7 +47,7 @@ pub fn append_callback (ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String>
|
|||
}
|
||||
}
|
||||
|
||||
pub fn expand_callback (ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
pub fn expand_callback(ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
if let Ctr::Seg(_) = *ast.car {
|
||||
Ok(*ast.car.clone())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -15,32 +15,30 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::segment::{Ctr, Seg};
|
||||
use crate::eval::eval;
|
||||
use crate::segment::{Ctr, Seg};
|
||||
use crate::sym::SymTable;
|
||||
|
||||
pub fn if_callback (ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
pub fn if_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
let cond: bool;
|
||||
match *ast.car {
|
||||
Ctr::Seg(ref cond_form) => {
|
||||
if let Ctr::Bool(cond_from_eval) = *eval(cond_form, syms)? {
|
||||
cond = cond_from_eval;
|
||||
} else {
|
||||
return Err("first argument to if must evaluate to be a boolean".to_string())
|
||||
return Err("first argument to if must evaluate to be a boolean".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Ctr::Bool(cond_from_car) => cond = cond_from_car,
|
||||
_ => {
|
||||
return Err("first argument to if must evaluate to be a boolean".to_string())
|
||||
}
|
||||
_ => return Err("first argument to if must evaluate to be a boolean".to_string()),
|
||||
}
|
||||
|
||||
let then_form: &Seg;
|
||||
if let Ctr::Seg(ref s) = *ast.cdr {
|
||||
then_form = s;
|
||||
} else {
|
||||
return Err("impossible condition: not enough args to if".to_string())
|
||||
return Err("impossible condition: not enough args to if".to_string());
|
||||
}
|
||||
|
||||
if cond {
|
||||
|
|
@ -56,9 +54,8 @@ pub fn if_callback (ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
} else {
|
||||
Err("impossible condition: list evals to non list".to_string())
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// else
|
||||
if let Ctr::Seg(ref else_form) = *then_form.cdr {
|
||||
|
|
@ -73,7 +70,7 @@ pub fn if_callback (ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
} else {
|
||||
Err("impossible condition: list evals to non list".to_string())
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Err("impossible condition: args not in standard form".to_string())
|
||||
|
|
@ -81,18 +78,18 @@ pub fn if_callback (ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn let_callback (_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
pub fn let_callback(_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn while_callback (_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
pub fn while_callback(_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn map_callback (_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
pub fn map_callback(_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn circuit_callback (_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
pub fn circuit_callback(_ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue