Skip to content

Commit eda9737

Browse files
committed
Auto merge of #751 - Dirbaio:solver-flag, r=jackh726
repl: add --solver flag. Useful to try out the recursive solver in the REPL. Accepts `--solver recursive` or `--solver slg`, default is SLG.
2 parents b32c563 + 29a39af commit eda9737

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ Options:
3131
--goal=GOAL Specifies a goal to evaluate (may be given more than once).
3232
--overflow-depth=N Specifies the overflow depth [default: 10].
3333
--multiple Output multiple answers instead of ambiguous solution.
34+
--solver=S Specifies the solver to use. `slg` or `recursive`. Default is SLG.
3435
";
3536

3637
/// This struct represents the various command line options available.
3738
#[derive(Debug, Deserialize)]
3839
struct Args {
3940
flag_program: Option<String>,
41+
flag_solver: Option<String>,
4042
flag_goal: Vec<String>,
4143
flag_overflow_depth: usize,
4244
flag_multiple: bool,
@@ -288,9 +290,17 @@ fn read_program(rl: &mut rustyline::Editor<()>) -> Result<String> {
288290

289291
impl Args {
290292
fn solver_choice(&self) -> SolverChoice {
291-
SolverChoice::SLG {
292-
max_size: self.flag_overflow_depth,
293-
expected_answers: None,
293+
match self.flag_solver.as_ref().map(String::as_str) {
294+
None | Some("slg") => SolverChoice::SLG {
295+
max_size: self.flag_overflow_depth,
296+
expected_answers: None,
297+
},
298+
Some("recursive") => SolverChoice::Recursive {
299+
overflow_depth: 100,
300+
caching_enabled: true,
301+
max_size: 30,
302+
},
303+
Some(s) => panic!("invalid solver {}", s),
294304
}
295305
}
296306
}

0 commit comments

Comments
 (0)