bf_rust/examples/eval_input.rs

17 lines
389 B
Rust
Raw Normal View History

2023-08-22 09:37:48 +02:00
use std::{io::{Read, stdin}, process::exit};
use brainrust::*;
fn main() {
let mut str = String::new();
stdin().read_to_string(&mut str).unwrap();
let eval_res = eval(&str.as_str());
if eval_res.is_err() {
let err = eval_res.unwrap_err();
if err == "Stdin closed" {
exit(0);
}
eprintln!("Program failed: {}", err);
}
}