Compare commits

...

2 commits

Author SHA1 Message Date
a06e0a1d02
simplify space parser 2024-11-04 18:06:18 -05:00
20093d7683
simplify space parser 2024-11-04 18:01:56 -05:00
2 changed files with 9 additions and 4 deletions

View file

@ -124,10 +124,11 @@ impl<'de> Deserialize<'de> for Atoms {
const FIELDS: &[&str] = &["notes", "sheet"];
let NotesSheet { notes, sheet } =
deserializer.deserialize_struct("NotesSheet", FIELDS, NotesSheetVisitor)?;
let maybe_yml_str_space = || many0(one_of(" \t\r"));
let x = all_consuming(terminated(
many0(preceded(many0(one_of(" \t\r")), flat_atom_parser(&notes))),
many0(alt((char('\t'), char(' '), char('\n'), char('\r')))),
))(&sheet)
many0(preceded(maybe_yml_str_space(), flat_atom_parser(&notes))),
maybe_yml_str_space(),
))(dbg!(&sheet))
.map_err(nom_err_message)
.map_err(AtomsSerializeError::Parsing)
.map_err(de::Error::custom)

View file

@ -40,7 +40,11 @@ impl Parse for Modifier {
pub fn flat_atom_parser(notes: &str) -> impl Parser<&str, FlatAtom, nom::error::Error<&str>> {
alt((
map_res(map_opt(one_of(notes), |c| notes.find(c)), u8::try_from).map(FlatAtom::Note),
map_res(
map_opt(one_of(notes), |c| notes.find(dbg!(c))),
u8::try_from,
)
.map(FlatAtom::Note),
value(FlatAtom::Rest, char(Atom::REST)),
value(FlatAtom::StartHere, char(Atom::START_HERE)),
preceded(char(Atom::MODIFIER), Modifier::parse).map(FlatAtom::Modifier),