25 lines
593 B
Rust
25 lines
593 B
Rust
mod machine;
|
|
mod tape;
|
|
|
|
use std::fmt::Display;
|
|
|
|
pub use machine::NextState;
|
|
pub use machine::StateId;
|
|
pub use machine::TuringMachine;
|
|
|
|
#[derive(Debug)]
|
|
pub enum TuringMachineError {
|
|
DuplicateStateEntryKey(String),
|
|
StateEntryParsing(String),
|
|
}
|
|
|
|
impl Display for TuringMachineError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
use TuringMachineError::*;
|
|
match self {
|
|
DuplicateStateEntryKey(key) => write!(f, "duplicate key in state table: {}", key),
|
|
StateEntryParsing(entry) => write!(f, "could not parse state entry: {}", entry),
|
|
}
|
|
}
|
|
}
|