diff options
author | James Sanderson <zofrex@gmail.com> | 2016-04-17 22:51:43 +0100 |
---|---|---|
committer | James Sanderson <zofrex@gmail.com> | 2016-04-17 22:51:43 +0100 |
commit | 848227c6053019918b726fa7356f5dfb87861420 (patch) | |
tree | ef364868ff5502e6636dd627a0b668f733d442e3 /src | |
parent | 2cd1116e062f9af389f97044360a9cfbdb127c82 (diff) | |
download | milf-rs-848227c6053019918b726fa7356f5dfb87861420.tar.gz milf-rs-848227c6053019918b726fa7356f5dfb87861420.zip |
Require a newline after table definition
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/parser.rs | 10 |
2 files changed, 11 insertions, 1 deletions
@@ -447,7 +447,7 @@ mod tests { #[test] fn lookup_advanced_table() { - let value: Value = r#"[table."name.other"] value = "my value""#.parse().unwrap(); + let value: Value = "[table.\"name.other\"]\nvalue = \"my value\"".parse().unwrap(); let looked = value.lookup(r#"table."name.other".value"#).unwrap(); assert_eq!(*looked, Value::String(String::from("my value"))); } diff --git a/src/parser.rs b/src/parser.rs index 2a156e3..8c689f8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -271,6 +271,16 @@ impl<'a> Parser<'a> { values: BTreeMap::new(), defined: true, }; + self.ws(); + self.comment(); + if !self.newline() { + self.errors.push(ParserError { + lo: start, + hi: start, + desc: format!("expected a newline after table definition"), + }); + return None + } if !self.values(&mut table) { return None } if array { self.insert_array(&mut ret, &keys, Value::Table(table), |