Handle nested function calls
This commit is contained in:
parent
c6b4ed7ee4
commit
f4f89b39b6
@ -586,13 +586,13 @@ impl Parser {
|
|||||||
|
|
||||||
#[recursive_descent_method]
|
#[recursive_descent_method]
|
||||||
fn call_expr(&mut self) -> ParseResult<Expression> {
|
fn call_expr(&mut self) -> ParseResult<Expression> {
|
||||||
let index = self.index_expr()?;
|
let mut expr = self.index_expr()?;
|
||||||
Ok(if let LParen = self.peek() {
|
while let LParen = self.peek() {
|
||||||
let arguments = delimited!(self, LParen, expression, Comma, RParen);
|
let arguments = delimited!(self, LParen, expression, Comma, RParen);
|
||||||
Expression(ExpressionType::Call { f: bx!(index), arguments }, None) //TODO fix this none
|
expr = Expression(ExpressionType::Call { f: bx!(expr), arguments }, None); //TODO none is incorrect
|
||||||
} else {
|
}
|
||||||
index
|
|
||||||
})
|
Ok(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[recursive_descent_method]
|
#[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]
|
#[test]
|
||||||
fn list_literals() {
|
fn list_literals() {
|
||||||
parse_test! {
|
parse_test! {
|
||||||
|
Loading…
Reference in New Issue
Block a user