allow toplevel answers to be passed back as queries
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "scryer-prolog"
|
name = "scryer-prolog"
|
||||||
version = "0.8.12"
|
version = "0.8.13"
|
||||||
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
||||||
repository = "https://github.com/mthom/scryer-prolog"
|
repository = "https://github.com/mthom/scryer-prolog"
|
||||||
description = "A modern Prolog implementation written mostly in Rust."
|
description = "A modern Prolog implementation written mostly in Rust."
|
||||||
|
|||||||
@@ -372,29 +372,23 @@ fn next_step(mut stdout: RawTerminal<std::io::Stdout>) -> ContinueResult
|
|||||||
pub fn print(wam: &mut Machine, result: EvalSession) {
|
pub fn print(wam: &mut Machine, result: EvalSession) {
|
||||||
match result {
|
match result {
|
||||||
EvalSession::InitialQuerySuccess(alloc_locs, mut heap_locs) => {
|
EvalSession::InitialQuerySuccess(alloc_locs, mut heap_locs) => {
|
||||||
|
loop {
|
||||||
if wam.or_stack_is_empty() {
|
if wam.or_stack_is_empty() {
|
||||||
println!("true.");
|
|
||||||
|
|
||||||
if heap_locs.is_empty() {
|
if heap_locs.is_empty() {
|
||||||
|
println!("true.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if heap_locs.is_empty() {
|
||||||
|
print!("true");
|
||||||
|
stdout().flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !wam.or_stack_is_empty() {
|
|
||||||
print!("true .");
|
|
||||||
|
|
||||||
if !heap_locs.is_empty() {
|
|
||||||
println!("\r");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let mut output = PrinterOutputter::new();
|
|
||||||
|
|
||||||
let bindings = wam.heap_view(&heap_locs, output).result();
|
|
||||||
let mut raw_stdout = stdout().into_raw_mode().unwrap();
|
let mut raw_stdout = stdout().into_raw_mode().unwrap();
|
||||||
|
|
||||||
if !heap_locs.is_empty() {
|
if !heap_locs.is_empty() {
|
||||||
|
let mut output = PrinterOutputter::new();
|
||||||
|
let bindings = wam.heap_view(&heap_locs, output).result();
|
||||||
|
|
||||||
write!(raw_stdout, "{}", bindings).unwrap();
|
write!(raw_stdout, "{}", bindings).unwrap();
|
||||||
raw_stdout.flush().unwrap();
|
raw_stdout.flush().unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user