correct ordinary input

This commit is contained in:
Mark Thom
2018-09-17 20:24:58 -06:00
parent 8eb327c735
commit 43ba8f23dc
2 changed files with 6 additions and 9 deletions

View File

@@ -5,7 +5,6 @@ use prolog::instructions::*;
use prolog::iterators::*; use prolog::iterators::*;
use prolog::machine::*; use prolog::machine::*;
use prolog::machine::machine_state::MachineState; use prolog::machine::machine_state::MachineState;
use prolog::toplevel::*;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::io::{Read, stdin}; use std::io::{Read, stdin};
@@ -43,7 +42,12 @@ pub fn read_toplevel(wam: &Machine) -> Result<Input, ParserError> {
println!("(type Enter + Ctrl-D to terminate the stream when finished)"); println!("(type Enter + Ctrl-D to terminate the stream when finished)");
Ok(Input::Batch) Ok(Input::Batch)
}, },
_ => Ok(Input::Term(parse_term(wam, buffer.as_bytes())?)) _ => {
let mut parser = Parser::new(stdin.lock(), wam.atom_tbl(), wam.machine_flags());
parser.add_to_top(buffer.as_str());
Ok(Input::Term(parser.read_term(composite_op!(&wam.op_dir))?))
}
} }
} }

View File

@@ -669,13 +669,6 @@ impl RelationWorker {
} }
} }
// used to parse queries. mostly.
pub fn parse_term<R: Read>(wam: &Machine, buf: R) -> Result<Term, ParserError>
{
let mut parser = Parser::new(buf, wam.atom_tbl(), wam.machine_flags());
parser.read_term(composite_op!(&wam.op_dir))
}
pub pub
fn consume_term<'a>(static_code_dir: Rc<RefCell<CodeDir>>, term: Term, fn consume_term<'a>(static_code_dir: Rc<RefCell<CodeDir>>, term: Term,
mut indices: MachineCodeIndices<'a>) mut indices: MachineCodeIndices<'a>)