Function pancakestack::interpret::run_program
source · pub fn run_program(
program: &[Command<'_>],
input: impl Read,
output: impl Write
) -> Result<(), Error>
Expand description
Runs the given slice of commands using the provided input and output.
// load program from file
let mut file = File::open("example.pancake").unwrap();
let mut program_str = String::new();
file.read_to_string(&mut program_str).unwrap();
// parse the program
let program = pancakestack::parse_program_str(&program_str);
// run the program
pancakestack::run_program(&program, std::io::stdin(), std::io::stdout()).unwrap();
Errors
Will return Err
if the given program performs an illegal operation or an io error occurs. See Error
.