use nested_parser instead

pull/5/head
azur 2023-03-04 19:57:35 +07:00
parent 74f0e86b93
commit 6b95e74420
2 changed files with 10 additions and 7 deletions

2
a.hlm
View File

@ -1,4 +1,4 @@
func add (x: num) num = x + 1;
func add (x: num) num = (\a: num -> a + 1)(x);
println(
{

View File

@ -445,14 +445,17 @@ pub fn exprs_parser() -> impl P<Vec<Spanned<PExpr>>> {
pub fn stmt_parser() -> impl P<Spanned<PStmt>> {
let func = just(Token::Func)
.ignore_then(symbol_parser())
.then_ignore(just(Token::Open(Delim::Paren)))
.then(
symbol_parser()
.then_ignore(just(Token::Colon))
.then(type_parser())
.separated_by(just(Token::Comma))
nested_parser(
symbol_parser()
.then_ignore(just(Token::Colon))
.then(type_parser())
.separated_by(just(Token::Comma))
.allow_trailing(),
Delim::Paren,
|_| Vec::new(),
)
)
.then_ignore(just(Token::Close(Delim::Paren)))
.then(type_parser())
.then_ignore(just(Token::Assign))
.then(expr_parser().map(Box::new))