Handle nested function calls
This commit is contained in:
parent
c6b4ed7ee4
commit
f4f89b39b6
@ -586,13 +586,13 @@ impl Parser {
|
||||
|
||||
#[recursive_descent_method]
|
||||
fn call_expr(&mut self) -> ParseResult<Expression> {
|
||||
let index = self.index_expr()?;
|
||||
Ok(if let LParen = self.peek() {
|
||||
let mut expr = self.index_expr()?;
|
||||
while let LParen = self.peek() {
|
||||
let arguments = delimited!(self, LParen, expression, Comma, RParen);
|
||||
Expression(ExpressionType::Call { f: bx!(index), arguments }, None) //TODO fix this none
|
||||
} else {
|
||||
index
|
||||
})
|
||||
expr = Expression(ExpressionType::Call { f: bx!(expr), arguments }, None); //TODO none is incorrect
|
||||
}
|
||||
|
||||
Ok(expr)
|
||||
}
|
||||
|
||||
#[recursive_descent_method]
|
||||
@ -1511,6 +1511,22 @@ fn a(x) {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn more_advanced_lambdas() {
|
||||
parse_test! {
|
||||
r#"fn wahoo() { let a = 10; \(x) { x + a } };
|
||||
wahoo()(3) "#, AST(vec![
|
||||
exst!(s r"fn wahoo() { let a = 10; \(x) { x + a } }"),
|
||||
exst! {
|
||||
Call {
|
||||
f: bx!(ex!(Call { f: bx!(ex!(val!("wahoo"))), arguments: vec![] })),
|
||||
arguments: vec![ex!(s "3")],
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_literals() {
|
||||
parse_test! {
|
||||
|
Loading…
Reference in New Issue
Block a user