Prettier error handling

This commit is contained in:
Alex Bethel 2021-06-04 18:56:26 -05:00
parent 5d230431e0
commit 6c2d5cc84a

View file

@ -20,13 +20,20 @@ pub fn repl() {
Ok(ast) => {
println!("{:?}", ast);
println!("{:?}", env.eval_items(&ast));
},
}
Err(e) => {
println!(
"Error `{:?}` occured at span: {:?} = `{:?}`",
e.kind,
e.position.clone(),
line.slice(e.position)
line.slice(e.position.clone())
);
println!(" | {}", line);
println!(
" {}{}-- Here",
" ".repeat(e.position.start),
"^".repeat((e.position.end - e.position.start).max(1))
);
}
}