diff --git a/crates/varcon-core/src/parser.rs b/crates/varcon-core/src/parser.rs index d576bc0..2ca0814 100644 --- a/crates/varcon-core/src/parser.rs +++ b/crates/varcon-core/src/parser.rs @@ -1001,13 +1001,11 @@ impl Entry { )) .parse_next(input)?; let archaic = - winnow::combinator::opt((winnow::ascii::space1, "(-)")).parse_next(input)?; - let note = winnow::combinator::opt((winnow::ascii::space1, "--")).parse_next(input)?; - let description = winnow::combinator::opt(( - winnow::ascii::space1, - winnow::token::take_till(0.., ('\n', '\r', '#')), - )) - .parse_next(input)?; + winnow::combinator::opt((winnow::ascii::space1, archaic)).parse_next(input)?; + let note = + winnow::combinator::opt((winnow::ascii::space1, NOTE_PREFIX)).parse_next(input)?; + let description = + winnow::combinator::opt((winnow::ascii::space1, description)).parse_next(input)?; let variants = Vec::new(); let pos = pos.map(|(_, p)| p); @@ -1028,6 +1026,17 @@ impl Entry { } } +const NOTE_PREFIX: &str = "--"; + +fn archaic(input: &mut &str) -> PResult<(), ()> { + "(-)".void().parse_next(input) +} + +fn description(input: &mut &str) -> PResult { + let description = winnow::token::take_till(0.., ('\n', '\r', '#')).parse_next(input)?; + Ok(description.to_owned()) +} + #[cfg(test)] mod test_entry { #![allow(clippy::bool_assert_comparison)]