Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Move bms part in a folder like bmson #107

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/bms.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//! The parser module of BMS(.bms/.bme/.bml/.pms) file.

pub mod lex;
pub mod parse;
pub mod time;

use thiserror::Error;

use self::{lex::LexError, parse::ParseError};

/// An error occurred when parsing the BMS format file.
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Error)]
pub enum BmsError {
/// An error comes from lexical analyzer.
#[error("lex error: {0}")]
LexError(LexError),
/// An error comes from syntax parser.
#[error("parse error: {0}")]
ParseError(ParseError),
}

impl From<LexError> for BmsError {
fn from(e: LexError) -> Self {
Self::LexError(e)
}
}
impl From<ParseError> for BmsError {
fn from(e: ParseError) -> Self {
Self::ParseError(e)
}
}

/// A custom result type for bms-rs.
pub type Result<T> = std::result::Result<T, BmsError>;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/parse/notes.rs → src/bms/parse/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,12 @@ impl Notes {

/// Removes the latest note from the notes.
pub fn remove_latest_note(&mut self, id: ObjId) -> Option<Obj> {
self.objs.entry(id).or_default().pop().map(|removed| {
self.objs.entry(id).or_default().pop().inspect(|removed| {
self.ids_by_key
.get_mut(&removed.key)
.unwrap()
.remove(&removed.offset)
.unwrap();
removed
})
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 2 additions & 32 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,8 @@
#![deny(rustdoc::broken_intra_doc_links)]
#![cfg_attr(feature = "nightly", feature(doc_cfg))]

pub mod bms;
#[cfg(feature = "bmson")]
pub mod bmson;
pub mod lex;
pub mod parse;
pub mod time;

use thiserror::Error;

use self::{lex::LexError, parse::ParseError};

/// An error occurred when parsing the BMS format file.
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Error)]
pub enum BmsError {
/// An error comes from lexical analyzer.
#[error("lex error: {0}")]
LexError(LexError),
/// An error comes from syntax parser.
#[error("parse error: {0}")]
ParseError(ParseError),
}

impl From<LexError> for BmsError {
fn from(e: LexError) -> Self {
Self::LexError(e)
}
}
impl From<ParseError> for BmsError {
fn from(e: ParseError) -> Self {
Self::ParseError(e)
}
}

/// A custom result type for bms-rs.
pub type Result<T> = std::result::Result<T, BmsError>;
pub use bms::{lex, parse, time};
Loading