28 lines
682 B
Rust
28 lines
682 B
Rust
#![feature(let_chains)]
|
|
|
|
use std::{env, fs, path::PathBuf};
|
|
|
|
mod asm_gen;
|
|
mod compiler;
|
|
mod interpreter;
|
|
mod tokenizer;
|
|
|
|
fn main() {
|
|
let args: Vec<String> = env::args().collect();
|
|
let input = args.get(1).expect("malformed arguments");
|
|
let program: Vec<u8> = load_program(input);
|
|
let name = args
|
|
.get(2)
|
|
.map(|s| s.to_string())
|
|
.unwrap_or_else(|| "program".to_string());
|
|
|
|
compiler::compile(program, name);
|
|
// interpreter::run(program);
|
|
}
|
|
|
|
fn load_program(input: &str) -> Vec<u8> {
|
|
let path: PathBuf = input.into();
|
|
let input = fs::read_to_string(path).expect("failed to read the program file");
|
|
input.as_bytes().to_vec()
|
|
}
|