parsing seems to be working fine

This commit is contained in:
Henrik Boeving
2020-11-28 17:44:06 +01:00
parent 111ca93a31
commit 2348f7889b
13 changed files with 478 additions and 1 deletions

32
src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
use std::fs;
use std::env;
#[macro_use]
extern crate pest_derive;
use pest::Parser;
mod asm;
mod parse;
mod generate;
use parse::{parse_asm, AsmParser};
fn main() {
let file_name = env::args().nth(1);
let file_content = match file_name {
Some(file_name) => {
fs::read_to_string(file_name).expect("Could not read the provided asm file")
}
None => {
println!("No input file was provided");
return;
}
};
let instructions = parse_asm(AsmParser::parse(parse::Rule::program, &file_content).unwrap_or_else(|e| panic!("{}", e)));
println!("{:#?}", instructions);
}