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
|
@ -14,7 +14,7 @@ struct Cli {
|
|||
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) => {
|
||||
|
@ -33,11 +33,19 @@ fn main() {
|
|||
|
||||
println!("done building machine: \n{machine}");
|
||||
|
||||
while machine.step() {
|
||||
if args.verbose {
|
||||
println!("executed instruction: {machine:?}");
|
||||
loop {
|
||||
match machine.step() {
|
||||
Ok(_) => {
|
||||
if args.verbose {
|
||||
println!("executed instruction: {machine:?}");
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("{e}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println!("final state: \n{machine}");
|
||||
println!("final state: \n{}", machine.registers);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue