about summary refs log tree commit diff
path: root/src/parser/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/mod.rs')
-rw-r--r--src/parser/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 9ac590cee86c..9c4598732247 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -1,6 +1,6 @@
 use nom::character::complete::{multispace0, multispace1};
 use nom::error::{ErrorKind, ParseError};
-use nom::{alt, char, complete, do_parse, many0, named, separated_list0, tag};
+use nom::{alt, char, complete, do_parse, many0, named, separated_list0, tag, terminated};
 
 #[macro_use]
 mod macros;
@@ -81,7 +81,7 @@ named!(pub decl(&str) -> Decl, alt!(
     fun_decl
 ));
 
-named!(pub toplevel(&str) -> Vec<Decl>, many0!(decl));
+named!(pub toplevel(&str) -> Vec<Decl>, terminated!(many0!(decl), multispace0));
 
 #[cfg(test)]
 mod tests {
@@ -114,5 +114,10 @@ mod tests {
              fn main = plus (id 2) 7"
         );
         assert_eq!(res.len(), 3);
+        let res = test_parse!(
+            toplevel,
+            "fn id x = x\nfn plus x y = x + y\nfn main = plus (id 2) 7\n"
+        );
+        assert_eq!(res.len(), 3);
     }
 }