Clean up the output a little bit
This commit is contained in:
parent
780ada7034
commit
64b8d18fe8
65
src/main.rs
65
src/main.rs
|
@ -31,44 +31,37 @@ fn main() -> std::io::Result<()> {
|
||||||
Ok(p) => p
|
Ok(p) => p
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("Parse successful!!");
|
println!("Parse successful! Building IR...");
|
||||||
for decl in &program.0 {
|
|
||||||
println!("{decl:?}\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("Building IR...");
|
let program = match program.gen_ir() {
|
||||||
match program.gen_ir() {
|
Ok(program) => program,
|
||||||
Ok(program) => {
|
Err(e) => {
|
||||||
println!(
|
println!("Oh noes! {e:?}");
|
||||||
"IR built successfully!\n{}",
|
exit(2);
|
||||||
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!"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ impl Program {
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(i, decl)| decl.get_identifier(&Identifier::ROOT, i as u32))
|
.filter_map(|(i, decl)| decl.get_identifier(&Identifier::ROOT, i as u32))
|
||||||
.fold(BindingScope::builtins(), |scope, ident| scope.bind_single(ident));
|
.fold(BindingScope::builtins(), |scope, ident| scope.bind_single(ident));
|
||||||
println!("DEBUG {root_scope:?}");
|
|
||||||
self.0.into_iter()
|
self.0.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(i, decl)| decl.gen_ir(&root_scope, i as u32, Identifier::ROOT).transpose())
|
.filter_map(|(i, decl)| decl.gen_ir(&root_scope, i as u32, Identifier::ROOT).transpose())
|
||||||
|
|
Loading…
Reference in a new issue