mirror of
https://github.com/kaesaecracker/echse.git
synced 2025-09-04 15:07:16 +02:00
improve error handling
This commit is contained in:
parent
5ad6baa30d
commit
a4a027b448
24 changed files with 238 additions and 112 deletions
|
@ -1,3 +1,4 @@
|
|||
use echse::instructions::ExecuteInstructionError;
|
||||
use echse::machine::{Machine, MachineBuilder};
|
||||
use echse::parser::EiParser;
|
||||
use std::collections::HashSet;
|
||||
|
@ -129,7 +130,10 @@ impl App {
|
|||
"{:03}: {}\n",
|
||||
self.machine.ip, self.machine.instructions[self.machine.ip]
|
||||
);
|
||||
self.machine.step();
|
||||
match self.machine.step() {
|
||||
Ok(_) => {}
|
||||
Err(e) => Self::print_exec_err(e),
|
||||
}
|
||||
} else {
|
||||
println!("reached end of program\n");
|
||||
}
|
||||
|
@ -153,7 +157,12 @@ impl App {
|
|||
}
|
||||
DebugCommand::Continue => {
|
||||
let mut count = 0;
|
||||
while self.machine.step() {
|
||||
loop {
|
||||
match self.machine.step() {
|
||||
Ok(_) => {}
|
||||
Err(e) => eprintln!("{e}"),
|
||||
}
|
||||
|
||||
count += 1;
|
||||
if self.breakpoints.contains(&self.machine.ip) {
|
||||
println!(
|
||||
|
@ -163,6 +172,7 @@ impl App {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
println!(
|
||||
"stepped {count} instructions, ip now at {}\n",
|
||||
self.machine.ip
|
||||
|
@ -188,7 +198,7 @@ impl App {
|
|||
fn main() {
|
||||
let args: Cli = clap::Parser::parse();
|
||||
|
||||
let parser = EiParser::from_file(&args.ei_file).unwrap();
|
||||
let parser = EiParser::from_file(&args.ei_file).expect("failed to parse input file");
|
||||
let instructions = match parser.parse() {
|
||||
Ok(i) => i,
|
||||
Err(e) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue