use the readline library at toplevel

This commit is contained in:
Mark Thom
2019-03-16 19:12:06 -06:00
parent bc0f0719fb
commit 2fad1c724c
8 changed files with 132 additions and 39 deletions

View File

@@ -149,11 +149,6 @@ impl<'a, R: Read> TermStream<'a, R> {
self.parser.set_atom_tbl(atom_tbl);
}
#[inline]
pub fn add_to_top(&mut self, buf: &str) {
self.parser.add_to_top(buf);
}
#[inline]
pub fn eof(&mut self) -> Result<bool, ParserError> {
Ok(self.stack.is_empty() && self.parser.eof()?)

View File

@@ -761,15 +761,12 @@ fn term_to_toplevel<'a, R>(term_stream: &mut TermStream<'a, R>, code_dir: &mut C
}
pub
fn string_to_toplevel<R: Read>(src: R, buffer: String, wam: &mut Machine)
-> Result<TopLevelPacket, SessionError>
fn string_to_toplevel(buffer: String, wam: &mut Machine) -> Result<TopLevelPacket, SessionError>
{
let mut term_stream = TermStream::new(src, wam.indices.atom_tbl(),
let mut term_stream = TermStream::new(buffer.as_bytes(), wam.indices.atom_tbl(),
wam.machine_flags(), &mut wam.indices,
&mut wam.policies, &mut wam.code_repo);
term_stream.add_to_top(buffer.as_str());
let term = term_stream.read_term(&OpDir::new())?;
let mut code_dir = CodeDir::new();