Skip to content

Commit

Permalink
Update main.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
crnvl committed Jul 16, 2023
1 parent 002c669 commit c37fe75
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,29 @@ use crate::logic::{ast::parse, interpeter::interpret};
mod logic;

fn main() {
let script = std::fs::read_to_string("./examples/spec_test.nl").unwrap();
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
println!("Error: No file path provided");
return;
}

let tokens = logic::tokenizer::tokenize(&script);

let parsed = parse(tokens).unwrap();
let path = &args[1];

println!("{:#?}", parsed);
let script = match std::fs::read_to_string(path) {
Ok(script) => script,
Err(e) => {
println!("Error: {}", e);
return;
}
};

let tokens = logic::tokenizer::tokenize(&script);
let parsed = match parse(tokens) {
Ok(parsed) => parsed,
Err(e) => {
println!("Error: {}", e);
return;
}
};
interpret(parsed);
}

0 comments on commit c37fe75

Please sign in to comment.