From 6b95e74420e006e3aafc1edf8e7f8a485288962f Mon Sep 17 00:00:00 2001 From: azur Date: Sat, 4 Mar 2023 19:57:35 +0700 Subject: [PATCH] use nested_parser instead --- a.hlm | 2 +- src/read/parse.rs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/a.hlm b/a.hlm index 522d747..f46b3ec 100644 --- a/a.hlm +++ b/a.hlm @@ -1,4 +1,4 @@ -func add (x: num) num = x + 1; +func add (x: num) num = (\a: num -> a + 1)(x); println( { diff --git a/src/read/parse.rs b/src/read/parse.rs index 20167ad..4e83033 100644 --- a/src/read/parse.rs +++ b/src/read/parse.rs @@ -445,14 +445,17 @@ pub fn exprs_parser() -> impl P>> { pub fn stmt_parser() -> impl P> { 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))