diff options
-rw-r--r-- | src/parser.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/parser.rs b/src/parser.rs index 8fa2d77..08f032d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -243,6 +243,11 @@ impl<'a> Parser<'a> { } } + // Match EOF + fn eof(&self) -> bool { + self.peek(0).is_none() + } + /// Executes the parser, parsing the string contained within. /// /// This function will return the `TomlTable` instance if parsing is @@ -285,7 +290,7 @@ impl<'a> Parser<'a> { }; if self.require_newline_after_table { self.ws(); - if !self.comment() && !self.newline() { + if !self.comment() && !self.newline() && !self.eof() { self.errors.push(ParserError { lo: start, hi: start, @@ -1206,6 +1211,14 @@ trimmed in raw strings. } #[test] + fn empty_table() { + let mut p = Parser::new(r#" +[foo]"#); + let table = Table(p.parse().unwrap()); + table.lookup("foo").unwrap().as_table().unwrap(); + } + + #[test] fn fruit() { let mut p = Parser::new(r#" [[fruit]] |