Add function expr parsing
* Introduce new `fn` keyword * Function example is added to examples/expr.not Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -48,5 +48,8 @@ impl Visit for CollectLocals<'_> {
|
||||
fn visit_call_expr(&mut self, expr: &CallExpr) -> Self::Out { DefaultAccept::default_accept(expr, self); }
|
||||
fn visit_index_expr(&mut self, expr: &IndexExpr) -> Self::Out { DefaultAccept::default_accept(expr, self); }
|
||||
fn visit_access_expr(&mut self, expr: &AccessExpr) -> Self::Out { DefaultAccept::default_accept(expr, self); }
|
||||
fn visit_fun_expr(&mut self, _expr: &FunExpr) -> Self::Out {
|
||||
// Do not collect names for function expressions, since they have their own scope.
|
||||
}
|
||||
fn visit_atom(&mut self, atom: &Atom) -> Self::Out { DefaultAccept::default_accept(atom, self); }
|
||||
}
|
||||
|
||||
@@ -345,6 +345,11 @@ impl Visit for CompileBody<'_> {
|
||||
Ok(thunk)
|
||||
}
|
||||
|
||||
fn visit_fun_expr(&mut self, _expr: &FunExpr) -> Self::Out {
|
||||
// TODO : fun exprs should be compiled as constants and put into the constant pool
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn visit_atom(&mut self, atom: &Atom) -> Self::Out {
|
||||
let thunk = match atom {
|
||||
Atom::Ident(ident) => {
|
||||
|
||||
Reference in New Issue
Block a user