From e3e0b70d1c7195b460784a333e07019c6b3a19c9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Nov 2018 18:04:56 +0100 Subject: parser::definitions(): Move `try()` calls to map_kind parsers This seems to fix the problem of errors in the middle of definitions not being surfaced (what the test in 3091ebe0deb1ba832b4a5925263409ec5b651c62 is for). Need to write some more tests for other error cases. The reason why this happens is because `try()` causes the parser to not consume the input. Since the input isn't consumed, I guess the error messages from within never get surfaced. Moving the `try()` further down the parser tree appears to fix things. --- src/parser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/parser.rs b/src/parser.rs index 85a7ed2..97fbcf0 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -226,7 +226,7 @@ where I: Stream, I::Error: ParseError, { - string("map").map(|_| MapKind::Map) + try(string("map")).map(|_| MapKind::Map) } fn map_kind_cmd() -> impl Parser @@ -234,7 +234,7 @@ where I: Stream, I::Error: ParseError, { - string("cmd").map(|_| MapKind::Command) + try(string("cmd")).map(|_| MapKind::Command) } fn headphone_button() -> impl Parser @@ -617,8 +617,8 @@ where blank(), many1( choice!( - try(map()).map(|map| Definition::Map(map)), - try(mode()).map(|mode| Definition::Mode(mode)) + map().map(|map| Definition::Map(map)), + mode().map(|mode| Definition::Mode(mode)) ).skip(blank()) ) ).map(|(_, definitions)| definitions) -- cgit v1.2.3