From 840b98dcf31b906c4cc62aa6a102b5ed8bd16d07 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sun, 17 Mar 2019 15:22:31 -0600 Subject: [PATCH] update readline.rs version --- Cargo.lock | 8 +++++--- Cargo.toml | 4 ++-- src/main.rs | 2 +- src/prolog/machine/toplevel.rs | 4 ++-- src/prolog/read.rs | 6 +++--- src/tests.rs | 6 +++--- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b9198dd..d2740a48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,8 @@ dependencies = [ [[package]] name = "readline-rs" -version = "0.1.0" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "redox_syscall" @@ -115,13 +116,13 @@ dependencies = [ [[package]] name = "scryer-prolog" -version = "0.8.4" +version = "0.8.5" dependencies = [ "downcast 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "prolog_parser 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "readline-rs 0.1.0", + "readline-rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -161,6 +162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7eb5259643245d3f292c7a146b2df53bba24d7eab159410e648eb73dc164669d" "checksum prolog_parser 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6da85e0cfa5a604edf65f753e629db37bfd04af93a09a1df5576d2197a2f7af3" +"checksum readline-rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f35410ab92501753b66a269387df7a8162daeaf816f6528ba8b07b34f0d80c99" "checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" diff --git a/Cargo.toml b/Cargo.toml index 572996ce..707e7dcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scryer-prolog" -version = "0.8.5" +version = "0.8.6" authors = ["Mark Thom "] repository = "https://github.com/mthom/scryer-prolog" description = "A modern Prolog implementation written mostly in Rust." @@ -11,7 +11,7 @@ downcast = "0.9.1" num = "0.2" ordered-float = "0.5.0" prolog_parser = "0.8.1" -readline_rs = { package = "readline-rs", version = "0.1.0" } +readline_rs = { package = "readline-rs", version = "0.1.2" } [dependencies.termion] version = "1.4.0" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ca214421..e1e9a4c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ fn prolog_repl() { match toplevel_read_line() { Ok(Input::TermString(buffer)) => { - let result = match string_to_toplevel(buffer, &mut wam) { + let result = match string_to_toplevel(buffer.as_bytes(), &mut wam) { Ok(packet) => compile_term(&mut wam, packet), Err(e) => EvalSession::from(e) }; diff --git a/src/prolog/machine/toplevel.rs b/src/prolog/machine/toplevel.rs index c3656eba..bd569265 100644 --- a/src/prolog/machine/toplevel.rs +++ b/src/prolog/machine/toplevel.rs @@ -761,9 +761,9 @@ fn term_to_toplevel<'a, R>(term_stream: &mut TermStream<'a, R>, code_dir: &mut C } pub -fn string_to_toplevel(buffer: String, wam: &mut Machine) -> Result +fn string_to_toplevel(buffer: R, wam: &mut Machine) -> Result { - let mut term_stream = TermStream::new(buffer.as_bytes(), wam.indices.atom_tbl(), + let mut term_stream = TermStream::new(buffer, wam.indices.atom_tbl(), wam.machine_flags(), &mut wam.indices, &mut wam.policies, &mut wam.code_repo); diff --git a/src/prolog/read.rs b/src/prolog/read.rs index da7254f9..a36c9f13 100644 --- a/src/prolog/read.rs +++ b/src/prolog/read.rs @@ -30,7 +30,7 @@ pub enum Input { Quit, Clear, Batch, - TermString(String) + TermString(&'static str) } #[derive(Clone, Copy)] @@ -107,9 +107,9 @@ pub fn readline_initialize() { bind_keyseq_rl("\\C-d", bind_end_chord); } -pub fn read_line(prompt: &str) -> Result { +pub fn read_line(prompt: &str) -> Result<&'static str, SessionError> { match readline_rl(prompt) { - Some(input) => Ok(input.to_string()), + Some(input) => Ok(input), None => Err(SessionError::UserPrompt) } } diff --git a/src/tests.rs b/src/tests.rs index 71e19a80..8b6c8407 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -147,7 +147,7 @@ pub fn submit_query(wam: &mut Machine, buffer: &str, result: Vec { wam.reset(); - match string_to_toplevel(String::from(buffer), wam) { + match string_to_toplevel(buffer.as_bytes(), wam) { Ok(term) => match compile_term(wam, term) { EvalSession::InitialQuerySuccess(alloc_locs, heap_locs) => @@ -164,7 +164,7 @@ pub fn submit_query_without_results(wam: &mut Machine, buffer: &str) -> bool { wam.reset(); - match string_to_toplevel(String::from(buffer), wam) { + match string_to_toplevel(buffer.as_bytes(), wam) { Ok(term) => match compile_term(wam, term) { EvalSession::InitialQuerySuccess(..) @@ -182,7 +182,7 @@ pub fn submit_query_with_limit(wam: &mut Machine, buffer: &str, { wam.reset(); - match string_to_toplevel(String::from(buffer), wam) { + match string_to_toplevel(buffer.as_bytes(), wam) { Ok(term) => match compile_term(wam, term) { EvalSession::InitialQuerySuccess(alloc_locs, heap_locs) => -- 2.54.0