From 9b2ad49f3b8bc788c8858db2c413288d4ed19cff Mon Sep 17 00:00:00 2001 From: p6nj Date: Thu, 7 Nov 2024 20:19:14 -0500 Subject: [PATCH 1/2] rename serialization file (conflicts with serde) --- src/bng/score.rs | 4 ++-- src/bng/score/lex/lexer.rs | 6 +----- src/bng/score/{ser.rs => serialize.rs} | 0 3 files changed, 3 insertions(+), 7 deletions(-) rename src/bng/score/{ser.rs => serialize.rs} (100%) diff --git a/src/bng/score.rs b/src/bng/score.rs index 0595765..3e1f302 100644 --- a/src/bng/score.rs +++ b/src/bng/score.rs @@ -27,9 +27,9 @@ use thiserror::Error; use utils::{inflate, InflateError}; mod lex; -mod ser; +mod serialize; mod utils; -pub use ser::*; +pub use serialize::*; use super::Expression as Instruction; diff --git a/src/bng/score/lex/lexer.rs b/src/bng/score/lex/lexer.rs index 1933b43..762100e 100644 --- a/src/bng/score/lex/lexer.rs +++ b/src/bng/score/lex/lexer.rs @@ -40,11 +40,7 @@ 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(dbg!(c))), - u8::try_from, - ) - .map(FlatAtom::Note), + map_res(map_opt(one_of(notes), |c| notes.find(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), diff --git a/src/bng/score/ser.rs b/src/bng/score/serialize.rs similarity index 100% rename from src/bng/score/ser.rs rename to src/bng/score/serialize.rs From 2176f5dd8949232bc44cd5fa09a75394832cc055 Mon Sep 17 00:00:00 2001 From: p6nj Date: Thu, 7 Nov 2024 20:24:00 -0500 Subject: [PATCH 2/2] rename serde de (conflicts with local) --- src/bng/score.rs | 6 +++--- src/bng/score/{serialize.rs => de.rs} | 22 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) rename src/bng/score/{serialize.rs => de.rs} (91%) diff --git a/src/bng/score.rs b/src/bng/score.rs index 3e1f302..4aadc1e 100644 --- a/src/bng/score.rs +++ b/src/bng/score.rs @@ -19,17 +19,17 @@ use nom::{ #[cfg(debug_assertions)] use serde::Serialize; use serde::{ - de::{self, Visitor}, + de::{self as serde_de, Visitor}, Deserialize, }; use strum::EnumDiscriminants; use thiserror::Error; use utils::{inflate, InflateError}; +mod de; mod lex; -mod serialize; mod utils; -pub use serialize::*; +pub use de::*; use super::Expression as Instruction; diff --git a/src/bng/score/serialize.rs b/src/bng/score/de.rs similarity index 91% rename from src/bng/score/serialize.rs rename to src/bng/score/de.rs index ef8b300..1745d76 100644 --- a/src/bng/score/serialize.rs +++ b/src/bng/score/de.rs @@ -1,7 +1,23 @@ -use de::Deserializer; -use nom::Parser; +use derive_new::new; +use nom::{ + character::complete::one_of, + combinator::all_consuming, + multi::many0, + sequence::{preceded, terminated}, + Parser, +}; +use serde::{ + de::{self, Deserializer, Visitor}, + Deserialize, +}; +use thiserror::Error; -use super::*; +use crate::bng::score::lex::lexer::flat_atom_parser; + +use super::{ + utils::{inflate, InflateError}, + Atoms, FlatAtom, +}; #[derive(Debug, Error)] enum AtomsSerializeError {