slight polishing up, bug fixes
This commit is contained in:
24
src/main.rs
24
src/main.rs
@@ -27,29 +27,23 @@ fn l1_repl() {
|
||||
|
||||
match result {
|
||||
Ok(TopLevel::Fact(fact)) => {
|
||||
let mut compiled_fact = compile_fact(&fact);
|
||||
let index = ms.code.len();
|
||||
let name = fact.name().to_owned();
|
||||
let arity = fact.arity();
|
||||
let fact = compile_fact(&fact);
|
||||
|
||||
ms.code.append(&mut compiled_fact);
|
||||
ms.code_dir.insert((fact.name().clone(), fact.arity()), index);
|
||||
ms.add_fact(fact, name, arity);
|
||||
},
|
||||
Ok(TopLevel::Query(query)) => {
|
||||
let compiled_query = compile_query(&query);
|
||||
|
||||
for instruction in &compiled_query {
|
||||
ms.execute_query_instr(instruction);
|
||||
|
||||
if ms.fail {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ms.fail {
|
||||
ms.execute_query(&compiled_query);
|
||||
|
||||
if ms.failed() {
|
||||
println!("no");
|
||||
} else {
|
||||
println!("yes");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ms.reset_machine_state();
|
||||
},
|
||||
Err(_) => println!("Grammatical error of some kind!"),
|
||||
|
||||
Reference in New Issue
Block a user