From 486fb2a3a3573905b758a99755c59ede831ad6de Mon Sep 17 00:00:00 2001 From: glyh Date: Tue, 17 Sep 2024 01:23:59 +0800 Subject: [PATCH] format --- src/parser/parser.mbt | 11 ++--------- test/test_src/bad.mbt | 3 +++ 2 files changed, 5 insertions(+), 9 deletions(-) create mode 100644 test/test_src/bad.mbt diff --git a/src/parser/parser.mbt b/src/parser/parser.mbt index f0c9d76..58b48e2 100644 --- a/src/parser/parser.mbt +++ b/src/parser/parser.mbt @@ -17,6 +17,7 @@ fn parser() -> PS { let expr_ref : Ref[PS] = { val: empty() } let stmt_ref : Ref[PS] = { val: empty() } let block_expr = tok(@lex.LBRACE) >> + // HACK: there's test case that uses `{}` (ref(stmt_ref) + epsilon().replace(S::Unit)) << tok(@lex.RBRACE) @@ -211,7 +212,6 @@ fn parser() -> PS { let_tup_head(false) + lift2_maybe( fn(get_expr, rhs) { - // HACK: comment below to relax enforcement match get_expr { S::Get(_, _) => () _ => return None @@ -221,11 +221,6 @@ fn parser() -> PS { get_or_apply, tok(@lex.ASSIGN) >> ref(expr_ref), ) - // HACK: To support sequencing exps: - //+ - //ref(expr_ref).map( - // fn { exp => fn(rest) { S::Let(("_", fix_type(None)), exp, rest) } }, - //) stmt_ref.val = fold_right( ref(expr_ref), stmt_head, @@ -245,9 +240,7 @@ fn parser() -> PS { _ => true }, ) + - let_head(true) + - // HACK: relax to accept tuple let at top level - let_tup_head(true) + let_head(true) fold_right( tok(@lex.EOF).replace(S::Unit), // NOTE: top level definitions must start at the beginning of line diff --git a/test/test_src/bad.mbt b/test/test_src/bad.mbt new file mode 100644 index 0000000..f089bee --- /dev/null +++ b/test/test_src/bad.mbt @@ -0,0 +1,3 @@ +fn main { + +};