add eval_input

This commit is contained in:
b1ek 2023-08-22 17:37:48 +10:00
parent c547d90d0b
commit 92be2066dc
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 18 additions and 1 deletions

17
examples/eval_input.rs Normal file
View File

@ -0,0 +1,17 @@
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);
}
}

View File

@ -3,7 +3,7 @@ use brainrust::*;
fn main() {
let eval = eval(
&(
"+++++[>+++++++++<-],[[>--.++>+<<-]>+.->[<.>-]<<,]"
"+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+."
)
);
if eval.is_err() {