update readline.rs version

This commit is contained in:
Mark Thom
2019-03-17 15:22:31 -06:00
parent 2927387a66
commit 840b98dcf3
6 changed files with 16 additions and 14 deletions

View File

@@ -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)
};

View File

@@ -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<TopLevelPacket, SessionError>
fn string_to_toplevel<R: Read>(buffer: R, wam: &mut Machine) -> Result<TopLevelPacket, SessionError>
{
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);

View File

@@ -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<String, SessionError> {
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)
}
}

View File

@@ -147,7 +147,7 @@ pub fn submit_query(wam: &mut Machine, buffer: &str, result: Vec<HashSet<String>
{
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) =>