mirror of
https://github.com/Noratrieb/brainfuck.git
synced 2026-01-14 13:35:00 +01:00
27 lines
724 B
Rust
27 lines
724 B
Rust
#![feature(allocator_api, let_else)]
|
|
#![warn(rust_2018_idioms)]
|
|
|
|
use brainfuck::UseProfile;
|
|
use std::{env, fs, io, process};
|
|
|
|
fn main() {
|
|
let Some(path) = env::args().nth(1) else {
|
|
eprintln!("error: Provide a path as input.");
|
|
process::exit(1);
|
|
};
|
|
|
|
let file = fs::read_to_string(path).unwrap_or_else(|err| {
|
|
eprintln!("error: Failed to read file: {err}");
|
|
process::exit(1);
|
|
});
|
|
|
|
let stdout = io::stdout();
|
|
let stdout = stdout.lock();
|
|
let stdin = io::stdin();
|
|
let stdin = stdin.lock();
|
|
|
|
brainfuck::run(&file, stdout, stdin, UseProfile::No).unwrap_or_else(|_| {
|
|
eprintln!("error: Failed to parse brainfuck code");
|
|
process::exit(1);
|
|
});
|
|
}
|