34 lines
939 B
Rust
34 lines
939 B
Rust
extern crate clap;
|
|
extern crate huia_parser;
|
|
|
|
use clap::{App, Arg};
|
|
use std::fs;
|
|
use std::process;
|
|
|
|
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
|
|
|
fn main() {
|
|
let matches = App::new("huiac")
|
|
.version(VERSION)
|
|
.author("James Harton <james@automat.nz>")
|
|
.about("The compiler for the Huia programming language.")
|
|
.arg(
|
|
Arg::with_name("INPUT")
|
|
.help("The source file to compile")
|
|
.required(true)
|
|
.index(1),
|
|
)
|
|
.get_matches();
|
|
|
|
let source_path = matches.value_of("INPUT").unwrap();
|
|
let source_file = fs::read_to_string(source_path).expect("Unable to read input file");
|
|
let result = huia_parser::parse_file(&source_file);
|
|
|
|
if result.is_ok() {
|
|
println!("{:#?}", result.unwrap());
|
|
process::exit(0);
|
|
} else {
|
|
println!("{}", result.err().unwrap());
|
|
process::exit(1);
|
|
}
|
|
}
|