simplify space parser
This commit is contained in:
parent
20093d7683
commit
a06e0a1d02
2 changed files with 8 additions and 3 deletions
|
@ -124,9 +124,10 @@ impl<'de> Deserialize<'de> for Atoms {
|
||||||
const FIELDS: &[&str] = &["notes", "sheet"];
|
const FIELDS: &[&str] = &["notes", "sheet"];
|
||||||
let NotesSheet { notes, sheet } =
|
let NotesSheet { notes, sheet } =
|
||||||
deserializer.deserialize_struct("NotesSheet", FIELDS, NotesSheetVisitor)?;
|
deserializer.deserialize_struct("NotesSheet", FIELDS, NotesSheetVisitor)?;
|
||||||
|
let maybe_yml_str_space = || many0(one_of(" \t\r"));
|
||||||
let x = all_consuming(terminated(
|
let x = all_consuming(terminated(
|
||||||
many0(preceded(many0(one_of(" \t\r")), flat_atom_parser(¬es))),
|
many0(preceded(maybe_yml_str_space(), flat_atom_parser(¬es))),
|
||||||
many0(one_of(" \t\r")),
|
maybe_yml_str_space(),
|
||||||
))(dbg!(&sheet))
|
))(dbg!(&sheet))
|
||||||
.map_err(nom_err_message)
|
.map_err(nom_err_message)
|
||||||
.map_err(AtomsSerializeError::Parsing)
|
.map_err(AtomsSerializeError::Parsing)
|
||||||
|
|
|
@ -40,7 +40,11 @@ impl Parse for Modifier {
|
||||||
|
|
||||||
pub fn flat_atom_parser(notes: &str) -> impl Parser<&str, FlatAtom, nom::error::Error<&str>> {
|
pub fn flat_atom_parser(notes: &str) -> impl Parser<&str, FlatAtom, nom::error::Error<&str>> {
|
||||||
alt((
|
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::Rest, char(Atom::REST)),
|
||||||
value(FlatAtom::StartHere, char(Atom::START_HERE)),
|
value(FlatAtom::StartHere, char(Atom::START_HERE)),
|
||||||
preceded(char(Atom::MODIFIER), Modifier::parse).map(FlatAtom::Modifier),
|
preceded(char(Atom::MODIFIER), Modifier::parse).map(FlatAtom::Modifier),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue