farm parser out to a crate, remove it as a git submodule.
This commit is contained in:
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,4 +0,0 @@
|
||||
[submodule "src/prolog/parser"]
|
||||
path = src/prolog/parser
|
||||
url = http://github.com/mthom/prolog-parser
|
||||
branch = rusty-wam_branch
|
||||
|
||||
9
Cargo.lock
generated
9
Cargo.lock
generated
@@ -84,6 +84,14 @@ dependencies = [
|
||||
"unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prolog_parser"
|
||||
version = "0.7.9"
|
||||
dependencies = [
|
||||
"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)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.32"
|
||||
@@ -104,6 +112,7 @@ dependencies = [
|
||||
"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)",
|
||||
"ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"prolog_parser 0.7.9",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
[package]
|
||||
name = "rusty-wam"
|
||||
version = "0.7.9"
|
||||
authors = ["Mark Thom"]
|
||||
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
||||
repository = "https://github.com/mthom/rusty-wam"
|
||||
description = "The Warren Abstract Machine in Rust."
|
||||
license = "BSD-3-Clause"
|
||||
|
||||
[dependencies]
|
||||
downcast = "0.9.1"
|
||||
num = "0.2"
|
||||
ordered-float = "0.5.0"
|
||||
prolog_parser = "0.7.9"
|
||||
|
||||
[dependencies.termion]
|
||||
version = "1.4.0"
|
||||
@@ -1,10 +1,11 @@
|
||||
#[macro_use] extern crate downcast;
|
||||
#[macro_use] extern crate prolog_parser;
|
||||
extern crate termion;
|
||||
|
||||
#[macro_use]
|
||||
use prolog::ast::*;
|
||||
|
||||
mod prolog;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::compile::*;
|
||||
use prolog::io::*;
|
||||
use prolog::machine::*;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::fixtures::*;
|
||||
use prolog::targets::*;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use prolog::ast::*;
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use std::cell::Cell;
|
||||
use std::cmp::{min, max};
|
||||
use std::rc::Rc;
|
||||
|
||||
1413
src/prolog/ast.rs
1413
src/prolog/ast.rs
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,11 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::allocator::*;
|
||||
use prolog::arithmetic::*;
|
||||
use prolog::ast::*;
|
||||
use prolog::fixtures::*;
|
||||
use prolog::indexing::*;
|
||||
use prolog::iterators::*;
|
||||
use prolog::machine::machine_state::MachineFlags;
|
||||
use prolog::targets::*;
|
||||
|
||||
use std::cell::Cell;
|
||||
@@ -596,10 +597,10 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<TermMarker>
|
||||
|
||||
pub fn compile_fact<'b: 'a>(&mut self, term: &'b Term) -> Code
|
||||
{
|
||||
self.update_var_count(term.post_order_iter());
|
||||
self.update_var_count(post_order_iter(term));
|
||||
|
||||
let mut vs = VariableFixtures::new();
|
||||
vs.mark_vars_in_chunk(term.post_order_iter(), term.arity(), GenContext::Head);
|
||||
vs.mark_vars_in_chunk(post_order_iter(term), term.arity(), GenContext::Head);
|
||||
|
||||
vs.populate_restricting_sets();
|
||||
self.marker.drain_var_data(vs);
|
||||
@@ -628,7 +629,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<TermMarker>
|
||||
{
|
||||
self.marker.reset_arg(term.arity());
|
||||
|
||||
let iter = term.post_order_iter();
|
||||
let iter = query_term_post_order_iter(term);
|
||||
let query = self.compile_target(iter, term_loc, is_exposed);
|
||||
|
||||
if !query.is_empty() {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::debray_allocator::*;
|
||||
use prolog::codegen::*;
|
||||
use prolog::machine::*;
|
||||
use prolog::machine::machine_state::MachineFlags;
|
||||
use prolog::toplevel::*;
|
||||
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use prolog::and_stack::*;
|
||||
use prolog::ast::*;
|
||||
use prolog::and_stack::*;
|
||||
|
||||
use std::ops::IndexMut;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use prolog::allocator::*;
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::allocator::*;
|
||||
use prolog::targets::*;
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
@@ -1,56 +1,15 @@
|
||||
use prolog::ast::*;
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::iterators::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use std::cell::Cell;
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::btree_map::{IntoIter, IterMut, Values};
|
||||
use std::mem::swap;
|
||||
use std::rc::Rc;
|
||||
use std::vec::Vec;
|
||||
|
||||
impl VarData {
|
||||
pub fn as_reg_type(&self) -> RegType {
|
||||
match self {
|
||||
&VarData::Temp(_, r, _) => RegType::Temp(r),
|
||||
&VarData::Perm(r) => RegType::Perm(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TempVarData {
|
||||
fn new(last_term_arity: usize) -> Self {
|
||||
TempVarData {
|
||||
last_term_arity: last_term_arity,
|
||||
use_set: BTreeSet::new(),
|
||||
no_use_set: BTreeSet::new(),
|
||||
conflict_set: BTreeSet::new()
|
||||
}
|
||||
}
|
||||
|
||||
fn uses_reg(&self, reg: usize) -> bool {
|
||||
for &(_, nreg) in self.use_set.iter() {
|
||||
if reg == nreg {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
fn populate_conflict_set(&mut self) {
|
||||
if self.last_term_arity > 0 {
|
||||
let arity = self.last_term_arity;
|
||||
let mut conflict_set : BTreeSet<usize> = (1..arity).collect();
|
||||
|
||||
for &(_, reg) in self.use_set.iter() {
|
||||
conflict_set.remove(®);
|
||||
}
|
||||
|
||||
self.conflict_set = conflict_set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type VariableFixture<'a> = (VarStatus, Vec<&'a Cell<VarReg>>);
|
||||
pub struct VariableFixtures<'a>(BTreeMap<Rc<Var>, VariableFixture<'a>>);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::machine::machine_state::MachineState;
|
||||
use prolog::machine::machine_state::*;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::vec::Vec;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::machine::machine_state::*;
|
||||
use prolog::num::*;
|
||||
use prolog::heap_iter::*;
|
||||
use prolog::machine::machine_state::MachineState;
|
||||
use prolog::ordered_float::OrderedFloat;
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use prolog::ast::*;
|
||||
use prolog::machine::machine_state::MachineFlags;
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::hash::Hash;
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -9,6 +9,10 @@ use termion::event::Key;
|
||||
use std::io::{Write, stdin, stdout};
|
||||
use std::fmt;
|
||||
|
||||
fn error_string(e: &String) -> String {
|
||||
format!("error: exception thrown: {}", e)
|
||||
}
|
||||
|
||||
impl fmt::Display for IndexPtr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
@@ -22,35 +26,6 @@ impl fmt::Display for IndexPtr {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ClauseName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Constant {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
&Constant::Atom(ref atom) =>
|
||||
if atom.as_str().chars().any(|c| "`.$'\" ".contains(c)) {
|
||||
write!(f, "'{}'", atom.as_str())
|
||||
} else {
|
||||
write!(f, "{}", atom.as_str())
|
||||
},
|
||||
&Constant::Char(c) =>
|
||||
write!(f, "'{}'", c as u8),
|
||||
&Constant::EmptyList =>
|
||||
write!(f, "[]"),
|
||||
&Constant::Number(ref n) =>
|
||||
write!(f, "{}", n),
|
||||
&Constant::String(ref s) =>
|
||||
write!(f, "\"{}\"", s.borrow()),
|
||||
&Constant::Usize(integer) =>
|
||||
write!(f, "u{}", integer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for FactInstruction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
@@ -306,28 +281,6 @@ impl fmt::Display for Level {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for VarReg {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
&VarReg::Norm(RegType::Perm(reg)) => write!(f, "Y{}", reg),
|
||||
&VarReg::Norm(RegType::Temp(reg)) => write!(f, "X{}", reg),
|
||||
&VarReg::ArgAndNorm(RegType::Perm(reg), arg) =>
|
||||
write!(f, "Y{} A{}", reg, arg),
|
||||
&VarReg::ArgAndNorm(RegType::Temp(reg), arg) =>
|
||||
write!(f, "X{} A{}", reg, arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for RegType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
&RegType::Perm(val) => write!(f, "Y{}", val),
|
||||
&RegType::Temp(val) => write!(f, "X{}", val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Input {
|
||||
Quit,
|
||||
Clear,
|
||||
@@ -367,10 +320,6 @@ pub fn read() -> Input {
|
||||
}
|
||||
}
|
||||
|
||||
fn error_string(e: &String) -> String {
|
||||
format!("error: exception thrown: {}", e)
|
||||
}
|
||||
|
||||
pub fn print(wam: &mut Machine, result: EvalSession) {
|
||||
match result {
|
||||
EvalSession::InitialQuerySuccess(alloc_locs, mut heap_locs) => {
|
||||
|
||||
@@ -1,10 +1,33 @@
|
||||
use prolog::ast::*;
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
use std::iter::*;
|
||||
use std::rc::Rc;
|
||||
use std::vec::Vec;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum TermRef<'a> {
|
||||
AnonVar(Level),
|
||||
Cons(Level, &'a Cell<RegType>, &'a Term, &'a Term),
|
||||
Constant(Level, &'a Cell<RegType>, &'a Constant),
|
||||
Clause(Level, &'a Cell<RegType>, ClauseType, &'a Vec<Box<Term>>),
|
||||
Var(Level, &'a Cell<VarReg>, Rc<Var>)
|
||||
}
|
||||
|
||||
impl<'a> TermRef<'a> {
|
||||
pub fn level(self) -> Level {
|
||||
match self {
|
||||
TermRef::AnonVar(lvl)
|
||||
| TermRef::Cons(lvl, ..)
|
||||
| TermRef::Constant(lvl, ..)
|
||||
| TermRef::Var(lvl, ..)
|
||||
| TermRef::Clause(lvl, ..) => lvl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct QueryIterator<'a> {
|
||||
state_stack: Vec<TermIterState<'a>>,
|
||||
}
|
||||
@@ -192,14 +215,12 @@ impl<'a> Iterator for FactIterator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Term {
|
||||
pub fn post_order_iter(&self) -> QueryIterator {
|
||||
QueryIterator::from_term(self)
|
||||
}
|
||||
pub fn post_order_iter(term: &Term) -> QueryIterator {
|
||||
QueryIterator::from_term(term)
|
||||
}
|
||||
|
||||
pub fn breadth_first_iter(&self, iterable_root: bool) -> FactIterator {
|
||||
FactIterator::new(self, iterable_root)
|
||||
}
|
||||
pub fn breadth_first_iter(term: &Term, iterable_root: bool) -> FactIterator {
|
||||
FactIterator::new(term, iterable_root)
|
||||
}
|
||||
|
||||
pub enum ChunkedTerm<'a> {
|
||||
@@ -207,10 +228,8 @@ pub enum ChunkedTerm<'a> {
|
||||
BodyTerm(&'a QueryTerm)
|
||||
}
|
||||
|
||||
impl QueryTerm {
|
||||
pub fn post_order_iter<'a>(&'a self) -> QueryIterator<'a> {
|
||||
QueryIterator::new(self)
|
||||
}
|
||||
pub fn query_term_post_order_iter<'a>(query_term: &'a QueryTerm) -> QueryIterator<'a> {
|
||||
QueryIterator::new(query_term)
|
||||
}
|
||||
|
||||
impl<'a> ChunkedTerm<'a> {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::machine::machine_state::*;
|
||||
use prolog::num::bigint::BigInt;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
use prolog::and_stack::*;
|
||||
use prolog_parser::ast::*;
|
||||
use prolog_parser::tabled_rc::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::and_stack::*;
|
||||
use prolog::copier::*;
|
||||
use prolog::heap_print::*;
|
||||
use prolog::machine::machine_errors::*;
|
||||
use prolog::num::{BigInt, BigUint, Zero, One};
|
||||
use prolog::or_stack::*;
|
||||
use prolog::read::*;
|
||||
use prolog::tabled_rc::*;
|
||||
|
||||
use downcast::Any;
|
||||
|
||||
@@ -264,38 +266,6 @@ pub(super) enum MachineMode {
|
||||
Write
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum DoubleQuotes {
|
||||
Atom, Chars, // Codes
|
||||
}
|
||||
|
||||
impl DoubleQuotes {
|
||||
pub fn is_chars(self) -> bool {
|
||||
if let DoubleQuotes::Chars = self {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DoubleQuotes {
|
||||
fn default() -> Self {
|
||||
DoubleQuotes::Chars
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct MachineFlags {
|
||||
pub double_quotes: DoubleQuotes
|
||||
}
|
||||
|
||||
impl Default for MachineFlags {
|
||||
fn default() -> Self {
|
||||
MachineFlags { double_quotes: DoubleQuotes::default() }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MachineState {
|
||||
pub(crate) atom_tbl: TabledData<Atom>,
|
||||
pub(super) s: usize,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use prolog::and_stack::*;
|
||||
use prolog_parser::ast::*;
|
||||
use prolog_parser::string_list::StringList;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::and_stack::*;
|
||||
use prolog::copier::*;
|
||||
use prolog::heap_iter::*;
|
||||
use prolog::heap_print::*;
|
||||
@@ -9,7 +12,6 @@ use prolog::num::{Integer, Signed, ToPrimitive, Zero};
|
||||
use prolog::num::bigint::{BigInt, BigUint};
|
||||
use prolog::num::rational::Ratio;
|
||||
use prolog::or_stack::*;
|
||||
use prolog::string_list::StringList;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{max, Ordering};
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
use prolog_parser::ast::*;
|
||||
use prolog_parser::tabled_rc::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::compile::*;
|
||||
use prolog::heap_print::*;
|
||||
use prolog::tabled_rc::*;
|
||||
|
||||
mod machine_errors;
|
||||
pub(super) mod machine_state;
|
||||
#[macro_use]
|
||||
mod machine_state_impl;
|
||||
|
||||
#[macro_use] mod machine_state_impl;
|
||||
mod system_calls;
|
||||
|
||||
use prolog::machine::machine_state::*;
|
||||
@@ -16,6 +18,8 @@ use std::mem::swap;
|
||||
use std::ops::Index;
|
||||
use std::rc::Rc;
|
||||
|
||||
static BUILTINS: &str = include_str!("../lib/builtins.pl");
|
||||
|
||||
pub struct MachineCodeIndices<'a> {
|
||||
pub(super) code_dir: &'a mut CodeDir,
|
||||
pub(super) op_dir: &'a mut OpDir,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::machine::machine_errors::*;
|
||||
use prolog::machine::machine_state::*;
|
||||
|
||||
@@ -1,27 +1,3 @@
|
||||
macro_rules! clause_name {
|
||||
($name: expr, $tbl: expr) => (
|
||||
ClauseName::User(TabledRc::new($name, $tbl.clone()))
|
||||
) ;
|
||||
($name: expr) => (
|
||||
ClauseName::BuiltIn($name)
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! tabled_rc {
|
||||
($e:expr, $tbl:expr) => (
|
||||
TabledRc::new(String::from($e), $tbl.clone())
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! atom {
|
||||
($e:expr, $tbl:expr) => (
|
||||
Constant::Atom(ClauseName::User(tabled_rc!($e, $tbl)))
|
||||
);
|
||||
($e:expr) => (
|
||||
Constant::Atom(clause_name!($e))
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! interm {
|
||||
($n: expr) => (
|
||||
ArithmeticTerm::Interm($n)
|
||||
@@ -76,18 +52,6 @@ macro_rules! functor {
|
||||
);
|
||||
}
|
||||
|
||||
macro_rules! temp_v {
|
||||
($x:expr) => (
|
||||
RegType::Temp($x)
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! perm_v {
|
||||
($x:expr) => (
|
||||
RegType::Perm($x)
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! is_atom {
|
||||
($r:expr) => (
|
||||
call_clause!(ClauseType::Inlined(InlinedClauseType::IsAtom($r)), 1, 0)
|
||||
@@ -191,18 +155,6 @@ macro_rules! set_cp {
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! integer {
|
||||
($i:expr) => (
|
||||
Constant::Number(Number::Integer(Rc::new(BigInt::from($i))))
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! rc_atom {
|
||||
($e:expr) => (
|
||||
Rc::new(String::from($e))
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! succeed {
|
||||
() => (
|
||||
call_clause!(ClauseType::System(SystemClauseType::Succeed), 0, 0)
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
extern crate num;
|
||||
extern crate ordered_float;
|
||||
extern crate prolog_parser;
|
||||
|
||||
#[macro_use] pub mod ast;
|
||||
pub mod and_stack;
|
||||
#[macro_use]
|
||||
pub mod macros;
|
||||
#[macro_use]
|
||||
pub mod ast;
|
||||
#[macro_use]
|
||||
pub mod allocator;
|
||||
#[macro_use] pub mod macros;
|
||||
#[macro_use] pub mod allocator;
|
||||
pub mod toplevel;
|
||||
pub mod machine;
|
||||
pub mod compile;
|
||||
@@ -21,10 +19,6 @@ pub mod indexing;
|
||||
pub mod io;
|
||||
pub mod iterators;
|
||||
pub mod or_stack;
|
||||
#[macro_use]
|
||||
pub mod parser;
|
||||
pub mod heap_print;
|
||||
pub mod targets;
|
||||
pub mod tabled_rc;
|
||||
pub mod read;
|
||||
pub mod string_list;
|
||||
|
||||
Submodule src/prolog/parser deleted from 48814651b8
@@ -1,6 +1,9 @@
|
||||
use prolog_parser::ast::*;
|
||||
use prolog_parser::parser::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::iterators::*;
|
||||
use prolog::machine::machine_state::*;
|
||||
use prolog::parser::parser::*;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::io::stdin;
|
||||
@@ -70,7 +73,7 @@ impl<'a> Reader<'a> {
|
||||
let mut queue = SubtermDeque::new();
|
||||
let mut var_dict = HeapVarDict::new();
|
||||
|
||||
for term in term.breadth_first_iter(true) {
|
||||
for term in breadth_first_iter(&term, true) {
|
||||
let h = self.machine_st.heap.h;
|
||||
|
||||
match &term {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::iterators::*;
|
||||
|
||||
@@ -32,7 +34,7 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
|
||||
type Iterator = FactIterator<'a>;
|
||||
|
||||
fn iter(term: &'a Term) -> Self::Iterator {
|
||||
term.breadth_first_iter(false) // do not iterate over the root clause if one exists.
|
||||
breadth_first_iter(term, false) // do not iterate over the root clause if one exists.
|
||||
}
|
||||
|
||||
fn to_constant(lvl: Level, constant: Constant, reg: RegType) -> Self {
|
||||
@@ -99,7 +101,7 @@ impl<'a> CompilationTarget<'a> for QueryInstruction {
|
||||
type Iterator = QueryIterator<'a>;
|
||||
|
||||
fn iter(term: &'a Term) -> Self::Iterator {
|
||||
term.post_order_iter()
|
||||
post_order_iter(term)
|
||||
}
|
||||
|
||||
fn to_structure(ct: ClauseType, arity: usize, r: RegType) -> Self
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use prolog_parser::ast::*;
|
||||
use prolog_parser::parser::*;
|
||||
use prolog_parser::tabled_rc::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::iterators::*;
|
||||
use prolog::machine::*;
|
||||
use prolog::machine::machine_state::MachineFlags;
|
||||
use prolog::num::*;
|
||||
use prolog::parser::parser::*;
|
||||
use prolog::tabled_rc::*;
|
||||
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
use std::cell::{Cell, RefCell};
|
||||
@@ -322,7 +324,7 @@ impl RelationWorker {
|
||||
{
|
||||
let mut vars = HashSet::new();
|
||||
|
||||
for term in term.post_order_iter() {
|
||||
for term in post_order_iter(term) {
|
||||
if let TermRef::Var(_, _, v) = term {
|
||||
vars.insert(v.clone());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use prolog_parser::ast::*;
|
||||
|
||||
use prolog::ast::*;
|
||||
use prolog::heap_print::*;
|
||||
use prolog::compile::*;
|
||||
|
||||
Reference in New Issue
Block a user