Add Function to AST

This commit is contained in:
numzero 2025-04-19 11:03:50 +03:00
parent fe0d46ecf3
commit 528545f71d
2 changed files with 7 additions and 0 deletions

View File

@ -31,6 +31,12 @@ pub enum Expression {
callee: Ident, callee: Ident,
args: Vec<Expression>, args: Vec<Expression>,
}, },
Function {
name: Option<Ident>,
args: Vec<Ident>,
body: Vec<Statement>,
ret: Option<Box<Expression>>,
},
} }
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]

View File

@ -103,6 +103,7 @@ impl Eval for Expression {
let args = args.iter().map(|arg| arg.eval(scope)).collect(); let args = args.iter().map(|arg| arg.eval(scope)).collect();
(function.inner)(scope, args) (function.inner)(scope, args)
} }
Expression::Function { .. } => todo!(),
} }
} }
} }