provisional changes #2
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -86,8 +86,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "prolog_parser"
|
name = "prolog_parser"
|
||||||
version = "0.7.11"
|
version = "0.7.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -108,12 +107,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusty-wam"
|
name = "rusty-wam"
|
||||||
version = "0.7.9"
|
version = "0.7.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"downcast 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"downcast 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"prolog_parser 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"prolog_parser 0.7.12",
|
||||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -152,7 +151,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
|
"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
|
||||||
"checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe"
|
"checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe"
|
||||||
"checksum ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58d25b6c0e47b20d05226d288ff434940296e7e2f8b877975da32f862152241f"
|
"checksum ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58d25b6c0e47b20d05226d288ff434940296e7e2f8b877975da32f862152241f"
|
||||||
"checksum prolog_parser 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "608b6d0e85a6ea8d4fda3679fc314a8b08efdb07f896438342a9d727b04b72d7"
|
|
||||||
"checksum redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ab105df655884ede59d45b7070c8a65002d921461ee813a024558ca16030eea0"
|
"checksum redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ab105df655884ede59d45b7070c8a65002d921461ee813a024558ca16030eea0"
|
||||||
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
|
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
|
||||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rusty-wam"
|
name = "rusty-wam"
|
||||||
version = "0.7.9"
|
version = "0.7.10"
|
||||||
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
||||||
repository = "https://github.com/mthom/rusty-wam"
|
repository = "https://github.com/mthom/rusty-wam"
|
||||||
description = "The Warren Abstract Machine in Rust."
|
description = "The Warren Abstract Machine in Rust."
|
||||||
@@ -10,7 +10,7 @@ license = "BSD-3-Clause"
|
|||||||
downcast = "0.9.1"
|
downcast = "0.9.1"
|
||||||
num = "0.2"
|
num = "0.2"
|
||||||
ordered-float = "0.5.0"
|
ordered-float = "0.5.0"
|
||||||
prolog_parser = "0.7.11"
|
prolog_parser = { path = "../prolog_parser", version = "0.7.12" }
|
||||||
|
|
||||||
[dependencies.termion]
|
[dependencies.termion]
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@@ -134,8 +134,8 @@ impl ListingCompiler {
|
|||||||
ListingCompiler { module: None, non_counted_bt_preds: HashSet::new() }
|
ListingCompiler { module: None, non_counted_bt_preds: HashSet::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_module(&mut self, submodule: Module, wam: &mut Machine,
|
fn use_module(&mut self, submodule: Module, wam: &mut Machine, indices: &mut MachineCodeIndices)
|
||||||
indices: &mut MachineCodeIndices) -> Result<(), SessionError>
|
-> Result<(), SessionError>
|
||||||
{
|
{
|
||||||
let mod_name = self.get_module_name();
|
let mod_name = self.get_module_name();
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ pub fn compile_listing<'a, R>(wam: &mut Machine, src: R, mut indices: MachineCod
|
|||||||
let mut compiler = ListingCompiler::new();
|
let mut compiler = ListingCompiler::new();
|
||||||
let mut toplevel_results = vec![];
|
let mut toplevel_results = vec![];
|
||||||
|
|
||||||
while let Some(decl) = try_eval_session!(worker.consume(&mut indices)) {
|
while let Some(decl) = try_eval_session!(worker.consume(&wam.op_dir, &mut indices)) {
|
||||||
if decl.is_module_decl() {
|
if decl.is_module_decl() {
|
||||||
toplevel_indices.copy_and_swap(&mut indices);
|
toplevel_indices.copy_and_swap(&mut indices);
|
||||||
mem::swap(&mut worker.results, &mut toplevel_results);
|
mem::swap(&mut worker.results, &mut toplevel_results);
|
||||||
|
|||||||
@@ -176,10 +176,6 @@ impl Machine {
|
|||||||
self.ms.atom_tbl.clone()
|
self.ms.atom_tbl.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_module(&self, name: ClauseName) -> Option<&Module> {
|
|
||||||
self.modules.get(&name)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_batched_code(&mut self, code: Code, code_dir: CodeDir) -> Result<(), SessionError>
|
pub fn add_batched_code(&mut self, code: Code, code_dir: CodeDir) -> Result<(), SessionError>
|
||||||
{
|
{
|
||||||
for (ref key, ref idx) in code_dir.iter() {
|
for (ref key, ref idx) in code_dir.iter() {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ pub fn read_toplevel(wam: &Machine) -> Result<Input, ParserError> {
|
|||||||
let mut parser = Parser::new(stdin.lock(), wam.atom_tbl(), wam.machine_flags());
|
let mut parser = Parser::new(stdin.lock(), wam.atom_tbl(), wam.machine_flags());
|
||||||
|
|
||||||
parser.add_to_top(buffer.as_str());
|
parser.add_to_top(buffer.as_str());
|
||||||
Ok(Input::Term(parser.read_term(&wam.op_dir)?))
|
Ok(Input::Term(parser.read_term(composite_op!(&wam.op_dir))?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ impl MachineState {
|
|||||||
pub fn read<R: Read>(&mut self, inner: R, op_dir: &OpDir) -> Result<usize, ParserError>
|
pub fn read<R: Read>(&mut self, inner: R, op_dir: &OpDir) -> Result<usize, ParserError>
|
||||||
{
|
{
|
||||||
let mut parser = Parser::new(inner, self.atom_tbl.clone(), self.flags);
|
let mut parser = Parser::new(inner, self.atom_tbl.clone(), self.flags);
|
||||||
let term = parser.read_term(op_dir)?;
|
let term = parser.read_term(composite_op!(op_dir))?;
|
||||||
|
|
||||||
Ok(write_term_to_heap(term, self))
|
Ok(write_term_to_heap(term, self))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -627,7 +627,8 @@ pub fn parse_term(term: Term, mut indices: MachineCodeIndices) -> Result<TopLeve
|
|||||||
pub struct TopLevelBatchWorker<R: Read> {
|
pub struct TopLevelBatchWorker<R: Read> {
|
||||||
parser: Parser<R>,
|
parser: Parser<R>,
|
||||||
rel_worker: RelationWorker,
|
rel_worker: RelationWorker,
|
||||||
pub results: Vec<(Predicate, VecDeque<TopLevel>)>
|
pub results: Vec<(Predicate, VecDeque<TopLevel>)>,
|
||||||
|
pub in_module: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Read> TopLevelBatchWorker<R> {
|
impl<R: Read> TopLevelBatchWorker<R> {
|
||||||
@@ -635,11 +636,19 @@ impl<R: Read> TopLevelBatchWorker<R> {
|
|||||||
{
|
{
|
||||||
TopLevelBatchWorker { parser: Parser::new(inner, atom_tbl, flags),
|
TopLevelBatchWorker { parser: Parser::new(inner, atom_tbl, flags),
|
||||||
rel_worker: RelationWorker::new(),
|
rel_worker: RelationWorker::new(),
|
||||||
results: vec![] }
|
results: vec![],
|
||||||
|
in_module: false }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn read_term(&mut self, static_op_dir: &OpDir, op_dir: &OpDir) -> Result<Term, ParserError> {
|
||||||
|
let composite_op = composite_op!(self.in_module, op_dir, static_op_dir);
|
||||||
|
self.parser.read_term(composite_op)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub
|
pub
|
||||||
fn consume(&mut self, indices: &mut MachineCodeIndices) -> Result<Option<Declaration>, SessionError>
|
fn consume(&mut self, op_dir: &OpDir, indices: &mut MachineCodeIndices)
|
||||||
|
-> Result<Option<Declaration>, SessionError>
|
||||||
{
|
{
|
||||||
let mut preds = vec![];
|
let mut preds = vec![];
|
||||||
|
|
||||||
@@ -647,7 +656,7 @@ impl<R: Read> TopLevelBatchWorker<R> {
|
|||||||
self.parser.reset(); // empty the parser stack of token descriptions.
|
self.parser.reset(); // empty the parser stack of token descriptions.
|
||||||
|
|
||||||
let mut new_rel_worker = RelationWorker::new();
|
let mut new_rel_worker = RelationWorker::new();
|
||||||
let term = self.parser.read_term(&indices.op_dir)?;
|
let term = self.read_term(op_dir, &indices.op_dir)?;
|
||||||
let tl = new_rel_worker.try_term_to_tl(indices, term, true)?;
|
let tl = new_rel_worker.try_term_to_tl(indices, term, true)?;
|
||||||
|
|
||||||
if !is_consistent(&tl, &preds) { // if is_consistent returns false, preds is non-empty.
|
if !is_consistent(&tl, &preds) { // if is_consistent returns false, preds is non-empty.
|
||||||
|
|||||||
Reference in New Issue
Block a user