Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
glyh committed Sep 16, 2024
1 parent d10dfb6 commit 1760eef
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/parser/interface.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions src/parser/parser.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) }),
)
}
9 changes: 9 additions & 0 deletions test/test_src/comments.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// wowowowo
fn main
// hell yes
{
( //hell yes

)

};
Empty file removed test/test_src/dummy.mbt
Empty file.
9 changes: 9 additions & 0 deletions test/test_src/ids.mbt
Original file line number Diff line number Diff line change
@@ -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
};

0 comments on commit 1760eef

Please sign in to comment.