Changed main function back to using anyhow::Result<T> cause i dont get backtraces without it
This commit is contained in:
parent
d2b0e57ce6
commit
b8728b8f8d
21
src/main.rs
21
src/main.rs
|
@ -7,7 +7,7 @@ mod logger;
|
|||
|
||||
|
||||
|
||||
fn main() -> ExitCode {
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let cli = mclangc::cli::CliArgs::parse();
|
||||
cli.set_log_level();
|
||||
cli.validate();
|
||||
|
@ -15,25 +15,16 @@ fn main() -> ExitCode {
|
|||
let fp = PathBuf::from(file);
|
||||
if !fp.exists() {
|
||||
error!("File {fp:?} doesnt exits, exiting");
|
||||
return ExitCode::FAILURE;
|
||||
anyhow::bail!("")
|
||||
}
|
||||
|
||||
let data = std::fs::read_to_string(fp).unwrap();
|
||||
info!("Tokenising {file}");
|
||||
let Ok(tokens) = mclangc::tokeniser::tokenise(&data, &file) else {
|
||||
error!("Failed to tokenise file, exiting");
|
||||
return ExitCode::FAILURE;
|
||||
};
|
||||
let tokens = mclangc::tokeniser::tokenise(&data, &file)?;
|
||||
info!("Parsing {file}");
|
||||
let Ok(prog) = mclangc::parser::parse_program(tokens) else {
|
||||
error!("Failed to parse file, exiting");
|
||||
return ExitCode::FAILURE;
|
||||
};
|
||||
let mut prog = mclangc::parser::parse_program(tokens)?;
|
||||
info!("Validating {file}");
|
||||
let Ok(validated) = mclangc::validator::validate_code(&prog) else {
|
||||
error!("Failed to validate file, exiting");
|
||||
return ExitCode::FAILURE;
|
||||
};
|
||||
let validated = mclangc::validator::validate_code(&mut prog)?;
|
||||
}
|
||||
ExitCode::SUCCESS
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user