From 187d992ef43af0a357267676186b328a2c1d8a4f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 23 Aug 2024 10:49:33 -0500 Subject: [PATCH] refactor(varcon): Pull out note parser --- crates/varcon-core/src/parser.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/varcon-core/src/parser.rs b/crates/varcon-core/src/parser.rs index 1a7ae6f..82c203e 100644 --- a/crates/varcon-core/src/parser.rs +++ b/crates/varcon-core/src/parser.rs @@ -997,12 +997,12 @@ impl Entry { let pos = opt((space1, delimited('<', cut_err(Pos::parse_), cut_err('>')))) .parse_next(input)?; let archaic = opt((space1, archaic)).parse_next(input)?; - let note = opt((space1, NOTE_PREFIX, space1, description)).parse_next(input)?; + let note = opt((space1, note)).parse_next(input)?; let description = opt((space1, description)).parse_next(input)?; entry.pos = pos.map(|(_, p)| p); entry.archaic = archaic.is_some(); - entry.note = note.map(|(_, _, _, d)| d.to_owned()); + entry.note = note.map(|(_, d)| d.to_owned()); entry.description = description.map(|(_, d)| d.to_owned()); } Ok(entry) @@ -1011,6 +1011,11 @@ impl Entry { } } +fn note(input: &mut &str) -> PResult { + let (_, _, note) = (NOTE_PREFIX, space1, description).parse_next(input)?; + Ok(note.to_owned()) +} + const NOTE_PREFIX: &str = "--"; fn archaic(input: &mut &str) -> PResult<(), ()> {