Skip to content

Commit

Permalink
Solve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Jan 22, 2025
2 parents 1c3d632 + 7daf2d4 commit 38d2154
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
15 changes: 2 additions & 13 deletions src/elements/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,12 @@ impl Script {

match ans.check_nest(feeder){
Status::NormalEnd => return Ok(Some(ans)),
Status::NeedMoreLine => feeder.feed_additional_line(core)?,
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);
},
Status::NeedMoreLine => {
if ! feeder.feed_additional_line(core).is_ok() {
break;
}
return Err(ParseError::UnexpectedSymbol(s.clone()));
},
}
}

feeder.consume(feeder.len());
Ok(None)
}
}
13 changes: 11 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,18 @@ 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) => {
feeder.consume(feeder.len());
e.print(core);
break;
}
}
core.sigint.store(false, Relaxed);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/exit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-FileCopyrightText: 2024 Ryuichi Ueda [email protected]
//PDX-License-Identifier: BSD-3-Clause
//SPDX-License-Identifier: BSD-3-Clause

use crate::ShellCore;
use std::process;
Expand Down

0 comments on commit 38d2154

Please sign in to comment.