Clean up the output a little bit

This commit is contained in:
Emi Simpson 2022-04-26 20:04:10 -04:00
parent 780ada7034
commit 64b8d18fe8
Signed by: Emi
GPG key ID: A12F2C2FFDC3D847
2 changed files with 29 additions and 37 deletions

View file

@ -31,44 +31,37 @@ fn main() -> std::io::Result<()> {
Ok(p) => p
};
println!("Parse successful!!");
for decl in &program.0 {
println!("{decl:?}\n");
}
println!("Parse successful! Building IR...");
println!("Building IR...");
match program.gen_ir() {
Ok(program) => {
println!(
"IR built successfully!\n{}",
program.iter()
.map(|decl| format!("\n\n{decl}\n\n"))
.collect::<String>(),
);
match display_program(program) {
Ok(value) =>
println!("Evaluated successfully! Got:\n{value}"),
Err(EvaluateError::UndefinedValue(v)) =>
println!("Hit an error: {v} is undefined"),
Err(EvaluateError::EvaluatingZeroLengthExpr) =>
println!("Hit an error: Tried to evaluate a series of zero instructions"),
Err(EvaluateError::ArgumentCountMismatch(op, real, ex)) =>
println!("Problem while evaluating operation {op:?}: expected {ex} arguments, got {real}"),
Err(EvaluateError::FunctionArgumentCountMismatch(real, ex)) =>
println!("Problem while evaluating a function: expected {ex} arguments, got {real}"),
Err(EvaluateError::TypeMismatch(a, b)) =>
println!("Type mismatch between {a:?} and {b:?}!"),
Err(EvaluateError::NoMain) =>
println!("Huh, there's no main method"),
Err(EvaluateError::MainHasArgs) =>
println!("Your main method has args, but that's not allowed"),
Err(EvaluateError::IncompleteConditional) =>
println!("Uh oh, a conditional somewhere isn't complete!"),
}
let program = match program.gen_ir() {
Ok(program) => program,
Err(e) => {
println!("Oh noes! {e:?}");
exit(2);
}
Err(e) =>
println!("Oh noes! {e:?}"),
};
println!("IR built successfully! Evaluating...");
match display_program(program) {
Ok(value) =>
println!("Evaluated successfully!\n\n{value}"),
Err(EvaluateError::UndefinedValue(v)) =>
println!("Hit an error: {v} is undefined"),
Err(EvaluateError::EvaluatingZeroLengthExpr) =>
println!("Hit an error: Tried to evaluate a series of zero instructions"),
Err(EvaluateError::ArgumentCountMismatch(op, real, ex)) =>
println!("Problem while evaluating operation {op:?}: expected {ex} arguments, got {real}"),
Err(EvaluateError::FunctionArgumentCountMismatch(real, ex)) =>
println!("Problem while evaluating a function: expected {ex} arguments, got {real}"),
Err(EvaluateError::TypeMismatch(a, b)) =>
println!("Type mismatch between {a:?} and {b:?}!"),
Err(EvaluateError::NoMain) =>
println!("Huh, there's no main method"),
Err(EvaluateError::MainHasArgs) =>
println!("Your main method has args, but that's not allowed"),
Err(EvaluateError::IncompleteConditional) =>
println!("Uh oh, a conditional somewhere isn't complete!"),
}
Ok(())
}

View file

@ -40,7 +40,6 @@ impl Program {
.enumerate()
.filter_map(|(i, decl)| decl.get_identifier(&Identifier::ROOT, i as u32))
.fold(BindingScope::builtins(), |scope, ident| scope.bind_single(ident));
println!("DEBUG {root_scope:?}");
self.0.into_iter()
.enumerate()
.filter_map(|(i, decl)| decl.gen_ir(&root_scope, i as u32, Identifier::ROOT).transpose())