AST - Function calls modified to match the book's
This commit is contained in:
parent
312cdf18d5
commit
4c55e9e784
1 changed files with 6 additions and 5 deletions
11
src/ast.rs
11
src/ast.rs
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue