fix function calls with no argument
This commit is contained in:
parent
ee3b53bfb5
commit
d8eef9c95b
1 changed files with 16 additions and 8 deletions
24
src/eval.rs
24
src/eval.rs
|
|
@ -46,14 +46,22 @@ pub fn eval(
|
||||||
|
|
||||||
// another check to detect if we may have a function call
|
// another check to detect if we may have a function call
|
||||||
if let Ctr::Symbol(ref tok) = car {
|
if let Ctr::Symbol(ref tok) = car {
|
||||||
if let Ctr::Seg(ast) = cdr {
|
match cdr {
|
||||||
if let Some(func) = funcs.borrow().get(tok) {
|
Ctr::Seg(ast) => {
|
||||||
return func_call(func.clone(), ast.clone(), vars.clone(), funcs.clone())
|
if let Some(func) = funcs.borrow().get(tok) {
|
||||||
} else {
|
return func_call(func.clone(), ast.clone(), vars.clone(), funcs.clone())
|
||||||
return Err(format!("Couldnt find function: {}.", tok))
|
} else {
|
||||||
}
|
return Err(format!("Couldnt find function: {}.", tok))
|
||||||
} else {
|
}
|
||||||
return Err(format!("Arguments to function not a list!"))
|
},
|
||||||
|
Ctr::None => {
|
||||||
|
if let Some(func) = funcs.borrow().get(tok) {
|
||||||
|
return func_call(func.clone(), new_ast(Ctr::None, Ctr::None), vars.clone(), funcs.clone())
|
||||||
|
} else {
|
||||||
|
return Err(format!("Couldnt find function: {}.", tok))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => return Err(format!("Arguments to function not a list!"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue