Hook up parser
This commit is contained in:
parent
3efb1a26e0
commit
09f83930b4
4 changed files with 120 additions and 21 deletions
27
src/main.rs
27
src/main.rs
|
|
@ -1,7 +1,11 @@
|
|||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
|
||||
use structopt::StructOpt;
|
||||
|
||||
use crate::parser::Parser;
|
||||
use crate::source::SourceFiles;
|
||||
|
||||
mod commands;
|
||||
mod parser;
|
||||
mod source;
|
||||
|
|
@ -14,5 +18,26 @@ pub struct Opt {
|
|||
|
||||
fn main() {
|
||||
let opt = Opt::from_args();
|
||||
println!("{:#?}", opt);
|
||||
|
||||
let mut files = SourceFiles::new();
|
||||
|
||||
let (file, content) = match files.load(&opt.file) {
|
||||
Ok(result) => result,
|
||||
Err(e) => {
|
||||
eprintln!("Failed to load file: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let mut parser = Parser::new(file, content);
|
||||
|
||||
let commands = match parser.parse() {
|
||||
Ok(result) => result,
|
||||
Err(es) => {
|
||||
files.emit_all(&es);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
println!("{:#?}", commands);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue