Add return code to parse_sv

This commit is contained in:
dalance 2019-10-07 17:46:42 +09:00
parent 5ebaa7017c
commit ba89870178

View File

@ -1,5 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
use std::process;
use structopt::StructOpt; use structopt::StructOpt;
use sv_parser::parse_sv; use sv_parser::parse_sv;
@ -23,6 +24,7 @@ struct Opt {
fn main() { fn main() {
let opt = Opt::from_args(); let opt = Opt::from_args();
let mut defines = HashMap::new(); let mut defines = HashMap::new();
let mut exit = 0;
for path in &opt.files { for path in &opt.files {
match parse_sv(&path, &defines, &opt.includes) { match parse_sv(&path, &defines, &opt.includes) {
Ok((syntax_tree, new_defines)) => { Ok((syntax_tree, new_defines)) => {
@ -36,7 +38,9 @@ fn main() {
} }
Err(x) => { Err(x) => {
println!("parse failed: {:?} ({})", path, x); println!("parse failed: {:?} ({})", path, x);
exit = 1;
} }
} }
} }
process::exit(exit);
} }