Better error handling in REPL
We have much better spanned expression support, so now we get to show it off!
This commit is contained in:
parent
bdb32c4599
commit
39c5709db7
14
src/repl.rs
14
src/repl.rs
|
@ -15,13 +15,12 @@ pub fn repl() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let mut parser = Parser::new(&line);
|
let mut parser = Parser::new(&line);
|
||||||
let ast = parser.init();
|
let value = parser.init().and_then(|ast| {
|
||||||
match ast {
|
println!("{:?}", &ast);
|
||||||
Ok(ast) => {
|
env.eval_stmts(&ast)
|
||||||
println!("{:?}", ast);
|
});
|
||||||
println!("{:?}", env.eval_stmts(&ast));
|
|
||||||
}
|
if let Err(e) = value {
|
||||||
Err(e) => {
|
|
||||||
println!(
|
println!(
|
||||||
"Error `{:?}` occurred at span: {:?} = `{:?}`",
|
"Error `{:?}` occurred at span: {:?} = `{:?}`",
|
||||||
e.kind,
|
e.kind,
|
||||||
|
@ -37,7 +36,6 @@ pub fn repl() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Err(rustyline::error::ReadlineError::Eof) => {
|
Err(rustyline::error::ReadlineError::Eof) => {
|
||||||
println!("bye");
|
println!("bye");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue