Move stuff around to prep for future crates

Eventually, I want to take the code for working with the official binary
formats and split it out into a standalone library. The code for parsing
my unofficial text formats would then use that library as a dependency.

I might also spin off the text format code into its own library someday.
It might be useful to have a common text format.

This commit is just anticipatory prep work; I'm definitely not ready to
split this into a bunch of different crates today! I want to firm up the
data structures and the text format first.
This commit is contained in:
2026-01-28 14:20:51 -08:00
parent 6899e11aad
commit dc349e8b95
3 changed files with 6 additions and 1214 deletions
+5 -11
View File
@@ -21,23 +21,17 @@ pub enum ParseError {
#[error("board data too large")] #[error("board data too large")]
BoardTooLarge, BoardTooLarge,
#[error("parse error: {0}")] #[error("nom error: {0}")]
ParseError(String), NomError(String),
#[error("text parse error: {message}")]
TextParseError { message: String },
#[error("invalid hex in terrain: {0}")]
InvalidHex(String),
} }
impl<I> NomParseError<I> for ParseError { impl<I> NomParseError<I> for ParseError {
fn from_error_kind(_input: I, kind: ErrorKind) -> Self { fn from_error_kind(_input: I, kind: ErrorKind) -> Self {
Self::ParseError(kind.description().to_string()) Self::NomError(kind.description().to_string())
} }
fn append(_input: I, kind: ErrorKind, other: Self) -> Self { fn append(_input: I, kind: ErrorKind, other: Self) -> Self {
Self::ParseError(format!("{}: {:?}", other, kind)) Self::NomError(format!("{}: {:?}", other, kind))
} }
} }
@@ -45,7 +39,7 @@ impl From<nom::Err<ParseError>> for ParseError {
fn from(value: nom::Err<ParseError>) -> Self { fn from(value: nom::Err<ParseError>) -> Self {
match value { match value {
nom::Err::Error(e) | nom::Err::Failure(e) => e, nom::Err::Error(e) | nom::Err::Failure(e) => e,
nom::Err::Incomplete(needed) => Self::ParseError(format!("incomplete: {:?}", needed)), nom::Err::Incomplete(needed) => Self::NomError(format!("incomplete: {:?}", needed)),
} }
} }
} }
+1 -2
View File
@@ -2,9 +2,8 @@ mod elements;
mod encoding; mod encoding;
mod error; mod error;
mod parse; mod parse;
mod text;
pub use elements::{Element, element_id_from_name, element_name, resolve_alias};
pub use encoding::{decode_multiline, decode_oneline, encode_multiline, encode_oneline}; pub use encoding::{decode_multiline, decode_oneline, encode_multiline, encode_oneline};
pub use error::ParseError; pub use error::ParseError;
pub use parse::{Board, Program, Stat, Tile, World}; pub use parse::{Board, Program, Stat, Tile, World};
pub use text::{board_to_text, text_to_board, text_to_world, world_to_text};
-1201
View File
File diff suppressed because it is too large Load Diff