use ::mice::backend_support::TyTarget::Mir::Stack as MirStack;
use ::clap::{Parser, Subcommand};
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
#[clap(infer_subcommands = true)]
struct Cli {
#[clap(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Repl,
#[clap(hide = true)]
Mdb,
}
fn main() {
let cli = Cli::parse();
match cli.command {
Commands::Repl => {
use ::std::io::BufRead;
let stdin = ::std::io::stdin();
for line in stdin.lock().lines() {
let line = line.unwrap();
let program = match ::mice::parse::parse_expression::<MirStack>(line.as_bytes()) {
Ok((_input, (_tokens, proggy))) => proggy,
Err(_) => {
if line.len() > 0 {
println!("That's an invalid dice expression.");
}
continue
}
};
let result = ::mice::mir::stack::interpret(&program, u64::MAX, &mut ::rand::thread_rng());
match result {
Ok(output) => println!("{}", ::mice::mir::fmt::mbot_format_default(&output.output, output.total)),
Err(e) => eprintln!("{:?}", e),
}
}
},
Commands::Mdb => {
todo!("implement the debugger REPL, but better this time");
}
}
}