From 7282e9f05e60c624bf14cea285c356c49f8036a8 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 24 Mar 2020 03:00:10 -0700 Subject: [PATCH] Fix blocks --- schala-lang/language/src/parser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schala-lang/language/src/parser.rs b/schala-lang/language/src/parser.rs index 2a2bb62..3febe98 100644 --- a/schala-lang/language/src/parser.rs +++ b/schala-lang/language/src/parser.rs @@ -386,7 +386,7 @@ fn block(text: &str) -> ParseResult { let make_expr = |e| Statement { id: ItemId::new(0), kind: StatementKind::Expression(e) }; delimited(ws(tag("{")), delimited(opt(many0(statement_sep)), - separated_nonempty_list(many1(statement_sep), + separated_list(many1(statement_sep), map(expression, make_expr) ), opt(many0(statement_sep)) @@ -498,7 +498,7 @@ fn declaration(text: &str) -> ParseResult { fn func_declaration(text: &str) -> ParseResult { use Declaration::*; - let p = tuple((func_signature, opt(block))); + let p = tuple((func_signature, ws(opt(block)))); map(p, |(signature, maybe_block)| match maybe_block { Some(block) => FuncDecl(signature, block), None => FuncSig(signature),