Interpreter - Lambda support
This commit is contained in:
parent
0ef1318a35
commit
f1145bfbdf
1 changed files with 4 additions and 1 deletions
|
@ -160,7 +160,7 @@ impl ast::StmtNode {
|
||||||
params: &Vec<Token>,
|
params: &Vec<Token>,
|
||||||
body: &Vec<ast::StmtNode>,
|
body: &Vec<ast::StmtNode>,
|
||||||
) -> InterpreterResult {
|
) -> InterpreterResult {
|
||||||
let fun = Function::new(name, params, body);
|
let fun = Function::new(Some(name), params, body);
|
||||||
environment
|
environment
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.define(name, Some(Value::Callable(fun)))?;
|
.define(name, Some(Value::Callable(fun)))?;
|
||||||
|
@ -286,6 +286,9 @@ impl Interpretable for ast::ExprNode {
|
||||||
right_paren,
|
right_paren,
|
||||||
arguments,
|
arguments,
|
||||||
} => self.on_call(environment, callee, right_paren, arguments),
|
} => self.on_call(environment, callee, right_paren, arguments),
|
||||||
|
ast::ExprNode::Lambda { params, body } => {
|
||||||
|
Ok(Value::Callable(Function::new(None, params, body)).into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue