Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Jan 20, 2025
1 parent 7a73031 commit 554f295
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
12 changes: 2 additions & 10 deletions src/elements/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,11 @@ impl Script {
match ans.check_nest(feeder){
Status::NormalEnd => return Ok(Some(ans)),
Status::UnexpectedSymbol(s) => {
eprintln!("Unexpected token: {}", s);
let e = ParseError::UnexpectedSymbol(s.clone());
e.print(core);
core.db.set_param("?", "2").unwrap();
feeder.consume(feeder.len());
return Err(e);
return Err(ParseError::UnexpectedSymbol(s.clone()));
},
Status::NeedMoreLine => {
let res = feeder.feed_additional_line(core);
if let Err(e) = res {
feeder.consume(feeder.len());
return Err(e);
}
feeder.feed_additional_line(core)?;
},
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ fn main_loop(core: &mut ShellCore) {
_ => break,
}

if let Ok(Some(mut s)) = Script::parse(&mut feeder, core){
if let Err(e) = s.exec(core) {
match Script::parse(&mut feeder, core){
Ok(Some(mut s)) => {
if let Err(e) = s.exec(core) {
e.print(core);
break;
}
}
Ok(None) => {},
Err(e) => {
dbg!("!!");
feeder.consume(feeder.len());
e.print(core);
break;
}
}
core.sigint.store(false, Relaxed);
Expand Down

0 comments on commit 554f295

Please sign in to comment.