diff --git a/src/bin.rs b/src/bin.rs index 40145f7..3c41caa 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -123,6 +123,7 @@ fn main() -> Result<()> { if args.is_step_by_step { while { + term.clear_line()?; print!("Press Enter to continue..."); stdout().flush()?; let key = term.read_key()?; @@ -193,7 +194,27 @@ fn turing_machine_from_config(config: &Config, tape: String) -> Result>(); + if accept_states.iter().any(|s| s.is_none()) { + return Err(anyhow!( + "Invalid accept state: {}. Accept state must be one of {}.", + config + .accept_states + .iter() + .map(|s| format!("\"{}\"", s)) + .collect::>() + .join(", "), + state_names + .iter() + .map(|s| format!("\"{}\"", s)) + .collect::>() + .join(", ") + )); + } + let accept_states = accept_states + .into_iter() + .map(|s| s.unwrap().clone()) .collect::>(); let mut alphabet = config