initial commit

This commit is contained in:
Vinzenz Schroeter 2024-12-13 21:49:55 +01:00
commit 5ad6baa30d
35 changed files with 2877 additions and 0 deletions

8
echse_cute/Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "echse_cute"
version = "0.1.0"
edition = "2021"
[dependencies]
clap.workspace = true
echse = { path = "../echse" }

43
echse_cute/src/main.rs Normal file
View file

@ -0,0 +1,43 @@
use echse::machine::MachineBuilder;
use echse::parser::EiParser;
#[derive(clap::Parser)]
#[command(version, about, long_about = None)]
struct Cli {
ei_file: String,
#[arg(short, long, default_value_t = 2)]
registers: usize,
#[arg(short, long, default_value_t = false)]
verbose: bool,
}
fn main() {
let args: Cli = clap::Parser::parse();
let parser = EiParser::from_file(&args.ei_file).unwrap();
let instructions = match parser.parse() {
Ok(i) => i,
Err(e) => {
parser
.write_error_report(e, &mut std::io::stderr())
.expect("failed to generate error report");
return;
}
};
let mut machine = MachineBuilder::new()
.with_registers(args.registers)
.with_instructions(instructions)
.build()
.unwrap();
println!("done building machine: \n{machine}");
while machine.step() {
if args.verbose {
println!("executed instruction: {machine:?}");
}
}
println!("final state: \n{machine}");
}