From 1760eef3bbabc22703ac5fde9c7df9bd7a849ba6 Mon Sep 17 00:00:00 2001 From: glyh Date: Mon, 16 Sep 2024 22:50:16 +0800 Subject: [PATCH] checkpoint --- src/parser/interface.mbt | 3 ++- src/parser/parser.mbt | 8 ++------ test/test_src/comments.mbt | 9 +++++++++ test/test_src/dummy.mbt | 0 test/test_src/ids.mbt | 9 +++++++++ 5 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 test/test_src/comments.mbt delete mode 100644 test/test_src/dummy.mbt create mode 100644 test/test_src/ids.mbt diff --git a/src/parser/interface.mbt b/src/parser/interface.mbt index 0fb71cf..95da0c9 100644 --- a/src/parser/interface.mbt +++ b/src/parser/interface.mbt @@ -32,7 +32,8 @@ pub fn parse_program(intput : String) -> S { } let parsed = match parser().parse(lex_stream[:]) { (Some(parsed), []) => parsed - _ => @util.die("parse error") + _ => Unit + //@util.die("Parser Error") } ensure_top_level_type_sig(parsed) parsed diff --git a/src/parser/parser.mbt b/src/parser/parser.mbt index 53c0030..1ac7cee 100644 --- a/src/parser/parser.mbt +++ b/src/parser/parser.mbt @@ -227,9 +227,7 @@ fn parser() -> PS { stmt_ref.val = fold_right( ref(expr_ref), stmt_head, - tok(@lex.SEMICOL).replace(fn(u, v) { u(v) }) + - // HACK: Allow omitting semicolon between statements - epsilon().replace(fn(u, v) { u(v) }), + tok(@lex.SEMICOL).replace(fn(u, v) { u(v) }), ) let top_head = lift2( fn(id : String, body : S) { @@ -252,8 +250,6 @@ fn parser() -> PS { tok(@lex.EOF).replace(S::Unit), // NOTE: top level definitions must start at the beginning of line line_start >> top_head, - tok(@lex.SEMICOL).replace(fn(u, v) { u(v) }) + - // HACK: Allow omitting semicolon at top level - epsilon().replace(fn(u, v) { u(v) }), + tok(@lex.SEMICOL).replace(fn(u, v) { u(v) }), ) } diff --git a/test/test_src/comments.mbt b/test/test_src/comments.mbt new file mode 100644 index 0000000..0801d48 --- /dev/null +++ b/test/test_src/comments.mbt @@ -0,0 +1,9 @@ +// wowowowo +fn main +// hell yes +{ + ( //hell yes + + ) + +}; diff --git a/test/test_src/dummy.mbt b/test/test_src/dummy.mbt deleted file mode 100644 index e69de29..0000000 diff --git a/test/test_src/ids.mbt b/test/test_src/ids.mbt new file mode 100644 index 0000000..90d4f53 --- /dev/null +++ b/test/test_src/ids.mbt @@ -0,0 +1,9 @@ +fn main { + let _ = 1; + let _1 = 2; + let _1 = 9; + let _1 = 8; + let __ = 3; + let _hey__1_what_132 = 4; + 5 +};