Skip to content

Commit

Permalink
Add Machine::run_input_once() which reads one goal from user input an…
Browse files Browse the repository at this point in the history
…d runs it
  • Loading branch information
lucksus committed Jul 11, 2023
1 parent 95b3114 commit 112d398
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ impl Machine {
self.run_module_predicate(atom!("$toplevel"), (atom!("$repl"), 1));
}

pub fn run_input_once(&mut self) {
self.run_module_predicate(atom!("$toplevel"), (atom!("run_input_once"), 0));
}

pub fn set_user_input(&mut self, input: String) {
self.user_input = Stream::from_owned_string(input, &mut self.machine_st.arena);
}
Expand Down
3 changes: 3 additions & 0 deletions src/toplevel.pl
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,6 @@
% is expected to be printed instead.
; print_exception(E)
).

run_input_once :-
catch(read_and_match, E, print_exception(E)).

0 comments on commit 112d398

Please sign in to comment.