mirror of
https://github.com/Noratrieb/brainfuck.git
synced 2026-01-14 21:35:02 +01:00
works
This commit is contained in:
parent
2484fe1f44
commit
2d854539aa
8 changed files with 800 additions and 4 deletions
|
|
@ -1,8 +1,29 @@
|
|||
#![feature(allocator_api)]
|
||||
#![feature(allocator_api, let_else)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use bumpalo::Bump;
|
||||
use std::{env, fs, process};
|
||||
|
||||
mod naive_interpreter;
|
||||
mod parse;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
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 ast_alloc = Bump::new();
|
||||
|
||||
let parsed = parse::parse(&ast_alloc, file.bytes()).unwrap_or_else(|_| {
|
||||
eprintln!("Failed to parse brainfuck code.");
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
naive_interpreter::run(&parsed);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue