use ngr::backend::BackendError; use rustyline::error::ReadlineError; use rustyline::DefaultEditor; fn main() -> Result<(), BackendError> { let mut editor = DefaultEditor::new().expect("rustyline works"); let mut line_no = 0; let mut state = ngr::REPL::default(); println!("No Good Reason, the Interpreter!"); loop { line_no += 1; match editor.readline("> ") { Ok(command) => match command.trim() { "" => continue, ":quit" => break, _ => state.process_input(line_no, command), }, Err(ReadlineError::Io(e)) => { eprintln!("IO error: {}", e); break; } Err(ReadlineError::Eof) => break, Err(ReadlineError::Interrupted) => break, #[cfg(not(windows))] Err(ReadlineError::Errno(e)) => { eprintln!("Unknown syscall error: {}", e); break; } Err(ReadlineError::WindowResized) => continue, Err(e) => { eprintln!("Unknown internal error: {}", e); break; } } } Ok(()) }