diff options
| author | Teddy Wing | 2018-11-03 18:04:56 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-11-03 18:07:37 +0100 |
| commit | e3e0b70d1c7195b460784a333e07019c6b3a19c9 (patch) | |
| tree | 3b04679e681d1d2844cf4aed7639e143a9222bbf /src | |
| parent | 34a5f3749e7d60855ff907ffa7f66a323454c526 (diff) | |
| download | dome-key-map-e3e0b70d1c7195b460784a333e07019c6b3a19c9.tar.bz2 | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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<Item = char>, I::Error: ParseError<I::Item, I::Range, I::Position>, { - string("map").map(|_| MapKind::Map) + try(string("map")).map(|_| MapKind::Map) } fn map_kind_cmd<I>() -> impl Parser<Input = I, Output = MapKind> @@ -234,7 +234,7 @@ where I: Stream<Item = char>, I::Error: ParseError<I::Item, I::Range, I::Position>, { - string("cmd").map(|_| MapKind::Command) + try(string("cmd")).map(|_| MapKind::Command) } fn headphone_button<I>() -> impl Parser<Input = I, Output = HeadphoneButton> @@ -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) |
