AST - Function calls modified to match the book's

This commit is contained in:
Emmanuel BENOîT 2023-01-02 15:23:33 +01:00
parent 312cdf18d5
commit 4c55e9e784

View file

@ -76,8 +76,8 @@ pub enum ExprNode {
/// A function call. /// A function call.
Call { Call {
/// Token that contains the name of the function. /// Expression that corresponds to the callable.
name: Token, callee: Box<ExprNode>,
/// Right parenthesis that closes the list of arguments. Used to /// Right parenthesis that closes the list of arguments. Used to
/// report errors. /// report errors.
right_paren: Token, right_paren: Token,
@ -201,14 +201,15 @@ impl AstDumper for ExprNode {
} }
} }
ExprNode::Call { ExprNode::Call {
name, callee,
right_paren: _, right_paren: _,
arguments, arguments,
} => { } => {
let callee = callee.dump();
if arguments.len() > 0 { if arguments.len() > 0 {
format!( format!(
"( call {} {} )", "( call {} {} )",
name.lexeme, callee,
arguments arguments
.iter() .iter()
.map(|arg| arg.dump()) .map(|arg| arg.dump())
@ -216,7 +217,7 @@ impl AstDumper for ExprNode {
.join(" ") .join(" ")
) )
} else { } else {
format!("( call {} )", name.lexeme) format!("( call {} )", callee)
} }
} }
} }