forked from AbleScript/ablescript
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
a0c1f93392
commit
dc5ef63fef
14
src/repl.rs
14
src/repl.rs
|
@ -15,13 +15,12 @@ pub fn repl() {
|
|||
break;
|
||||
}
|
||||
let mut parser = Parser::new(&line);
|
||||
let ast = parser.init();
|
||||
match ast {
|
||||
Ok(ast) => {
|
||||
println!("{:?}", ast);
|
||||
println!("{:?}", env.eval_stmts(&ast));
|
||||
}
|
||||
Err(e) => {
|
||||
let value = parser.init().and_then(|ast| {
|
||||
println!("{:?}", &ast);
|
||||
env.eval_stmts(&ast)
|
||||
});
|
||||
|
||||
if let Err(e) = value {
|
||||
println!(
|
||||
"Error `{:?}` occurred at span: {:?} = `{:?}`",
|
||||
e.kind,
|
||||
|
@ -37,7 +36,6 @@ pub fn repl() {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(rustyline::error::ReadlineError::Eof) => {
|
||||
println!("bye");
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue