Merge pull request #98 from zofrex/accept-empty-table
Accept empty table
This commit is contained in:
commit
97592e120f
|
@ -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.
|
/// Executes the parser, parsing the string contained within.
|
||||||
///
|
///
|
||||||
/// This function will return the `TomlTable` instance if parsing is
|
/// This function will return the `TomlTable` instance if parsing is
|
||||||
|
@ -285,7 +290,7 @@ impl<'a> Parser<'a> {
|
||||||
};
|
};
|
||||||
if self.require_newline_after_table {
|
if self.require_newline_after_table {
|
||||||
self.ws();
|
self.ws();
|
||||||
if !self.comment() && !self.newline() {
|
if !self.comment() && !self.newline() && !self.eof() {
|
||||||
self.errors.push(ParserError {
|
self.errors.push(ParserError {
|
||||||
lo: start,
|
lo: start,
|
||||||
hi: start,
|
hi: start,
|
||||||
|
@ -1205,6 +1210,14 @@ trimmed in raw strings.
|
||||||
table.lookup("foo.1.bar").unwrap().as_table().unwrap();
|
table.lookup("foo.1.bar").unwrap().as_table().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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]
|
#[test]
|
||||||
fn fruit() {
|
fn fruit() {
|
||||||
let mut p = Parser::new(r#"
|
let mut p = Parser::new(r#"
|
||||||
|
|
Loading…
Reference in a new issue