correct module bugs

This commit is contained in:
Mark Thom
2018-03-04 21:35:30 -07:00
parent ba6d753a56
commit 0c66743db5
8 changed files with 203 additions and 140 deletions

View File

@@ -15,7 +15,7 @@ mod tests;
pub static LISTS: &str = include_str!("./prolog/lib/lists.pl");
pub static CONTROL: &str = include_str!("./prolog/lib/control.pl");
fn process_buffer(wam: &mut Machine, buffer: &str)
fn parse_and_compile_line(wam: &mut Machine, buffer: &str)
{
match parse_code(wam, buffer) {
Ok(packet) => {
@@ -39,20 +39,22 @@ fn prolog_repl() {
load_init_str(&mut wam, LISTS);
load_init_str(&mut wam, CONTROL);
loop {
print!("prolog> ");
let buffer = read();
match read() {
Input::Line(line) => parse_and_compile_line(&mut wam, line.as_str()),
Input::Batch(batch) => {
compile_listing(&mut wam, batch.as_str());
},
Input::Quit => break,
Input::Clear => {
wam.clear();
continue;
}
};
if buffer == "quit\n" {
break;
} else if buffer == "clear\n" {
wam.clear();
continue;
}
process_buffer(&mut wam, buffer.as_str());
wam.reset();
}
}