]> Repositorios git - scryer-prolog.git/commitdiff
edit README, ast, remove redundant modules
authorMark Thom <[email protected]>
Tue, 4 Sep 2018 04:02:15 +0000 (22:02 -0600)
committerMark Thom <[email protected]>
Tue, 4 Sep 2018 04:02:15 +0000 (22:02 -0600)
Cargo.lock
README.md
src/prolog/ast.rs
src/prolog/string_list.rs [deleted file]
src/prolog/tabled_rc.rs [deleted file]

index a33c62b14f91a3b3756debc38968bd5301f7eac7..69c93678693d397c19cbc13bf3f8175620c7cba7 100644 (file)
@@ -87,6 +87,7 @@ dependencies = [
 [[package]]
 name = "prolog_parser"
 version = "0.7.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
 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)",
@@ -112,7 +113,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",
+ "prolog_parser 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -151,6 +152,7 @@ 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.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 prolog_parser 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "21a50c17076ba5b0028835c7a2c37a2f434f53dfa4c55e51381118bb1491817b"
 "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 termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
index 8deb3ceea15d8a9c0966c92364772b05c7303770..9c808733eef76be55e378c13d55133dd09c4e863 100644 (file)
--- a/README.md
+++ b/README.md
@@ -85,18 +85,15 @@ strings.
 
 First, install the latest stable version of
 [Rust](https://www.rust-lang.org/en-US/install.html) using your
-preferred method. Then clone the rusty-wam repo and build it with
-cargo, like so:
+preferred method. Then install the latest rusty-wam with cargo,
+like so:
 
 ```
-$> git clone https://github.com/mthom/rusty-wam --recursive
-$> cd rusty-wam
-$> cargo build
+$> cargo install rusty-wam
 ```
 
 cargo will download and install the libraries rusty-wam uses
-automatically.  rusty-wam can be run with the command `cargo run`, and
-likewise tests can be run with `cargo test`.
+automatically.
 
 Note on compatibility: rusty-wam should work on Linux, Mac OS X, and
 FreeBSD. Windows support hinges on the Termion library working in
index 9a7fbf59559057db456e19ff6535af2dee412285..c3e714c9deb448019ac1ce2c819956ca6c46fc21 100644 (file)
@@ -8,7 +8,7 @@ use std::rc::Rc;
 
 #[derive(Clone, PartialEq)]
 pub enum InlinedClauseType {
-    CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),    
+    CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),
     IsAtom(RegType),
     IsAtomic(RegType),
     IsCompound(RegType),
@@ -34,7 +34,7 @@ impl InlinedClauseType {
             &InlinedClauseType::IsFloat (..) => "float",
             &InlinedClauseType::IsNonVar(..) => "nonvar",
             &InlinedClauseType::IsPartialString(..) => "partial_string",
-            &InlinedClauseType::IsVar(..) => "var",            
+            &InlinedClauseType::IsVar(..) => "var",
         }
     }
 
@@ -317,7 +317,7 @@ impl SystemClauseType {
 #[derive(Clone, PartialEq)]
 pub enum BuiltInClauseType {
     AcyclicTerm,
-    Arg,    
+    Arg,
     Compare,
     CompareTerm(CompareTermQT),
     CyclicTerm,
@@ -417,7 +417,7 @@ impl BuiltInClauseType {
             ("keysort", 2) => Some(BuiltInClauseType::KeySort),
             ("\\==", 2) => Some(BuiltInClauseType::NotEq),
             ("sort", 2) => Some(BuiltInClauseType::Sort),
-            ("read", 1) => Some(BuiltInClauseType::Read),            
+            ("read", 1) => Some(BuiltInClauseType::Read),
             _ => None
         }
     }
diff --git a/src/prolog/string_list.rs b/src/prolog/string_list.rs
deleted file mode 100644 (file)
index dd021a7..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-use std::cell::{Cell, Ref, RefCell};
-use std::cmp::Ordering;
-use std::hash::{Hash, Hasher};
-use std::rc::Rc;
-
-#[derive(PartialOrd, PartialEq, Ord, Eq)]
-pub struct StringListWrapper(RefCell<String>);
-
-impl Hash for StringListWrapper {
-    fn hash<H: Hasher>(&self, state: &mut H) {
-        self.0.borrow().hash(state)
-    }
-}
-
-// cursor is ignored if the double_quotes flag is set to atom
-#[derive(Clone)]
-pub struct StringList {
-    body: Rc<StringListWrapper>,
-    cursor: usize, // use this to generate a chars() iterator on the fly,
-                   // and skip over the first cursor chars.
-    expandable: Rc<Cell<bool>>
-}
-
-impl Hash for StringList {
-    #[inline]    
-    fn hash<H: Hasher>(&self, state: &mut H) {
-        (self.borrow().as_str(), self.cursor, self.expandable.get()).hash(state);
-    }
-}
-
-impl PartialOrd for StringList {
-    #[inline]    
-    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
-        Some(self.body.cmp(&other.body))
-    }
-}
-
-impl Ord for StringList {
-    #[inline]
-    fn cmp(&self, other: &Self) -> Ordering {
-        if self.expandable.get() && !self.expandable.get() {
-            Ordering::Greater
-        } else if !self.expandable.get() && self.expandable.get() {
-            Ordering::Less
-        } else {
-            self.borrow()[self.cursor ..].cmp(&other.borrow()[other.cursor ..])
-        }
-    }
-}
-
-impl PartialEq for StringList {
-    #[inline]
-    fn eq(&self, other: &Self) -> bool {
-        Rc::ptr_eq(&self.body, &other.body)
-    }
-}
-
-impl Eq for StringList {}
-
-impl StringList {
-    #[inline]
-    pub fn new(s: String, expandable: bool) -> Self {
-        let body = Rc::new(StringListWrapper(RefCell::new(s)));
-
-        StringList {
-            cursor: 0,
-            body,
-            expandable: Rc::new(Cell::new(expandable))
-        }
-    }
-
-    #[inline]
-    pub fn is_expandable(&self) -> bool {
-        self.expandable.get()
-    }
-
-    #[inline]
-    pub fn set_expandable(&self) {
-        self.expandable.set(true);
-    }
-
-    #[inline]
-    pub fn set_non_expandable(&self) {
-        self.expandable.set(false);
-    }
-
-    #[inline]
-    pub fn push_char(&mut self, c: char) -> Self {
-        if self.expandable.get() {
-            self.body.0.borrow_mut().push(c);
-
-            let mut new_string_list = self.clone();
-            new_string_list.cursor += c.len_utf8();
-
-            new_string_list
-        } else {
-            self.clone()
-        }
-    }
-
-    #[inline]
-    pub fn append(&mut self, s: &StringList) {
-        self.body.0.borrow_mut().extend(s.borrow()[s.cursor ..].chars());
-        self.expandable.set(s.expandable.get());
-    }
-
-    #[inline]
-    pub fn cursor(&self) -> usize {
-        self.cursor
-    }
-
-    #[inline]
-    pub fn head(&self) -> Option<char> {
-        self.borrow()[self.cursor ..].chars().next()
-    }
-
-    #[inline]
-    pub fn tail(&self) -> Self {
-        let mut new_string_list = self.clone();
-
-        if let Some(c) = self.head() {
-            new_string_list.cursor += c.len_utf8();
-        }
-
-        new_string_list
-    }
-
-    #[inline]
-    pub fn is_empty(&self) -> bool {
-        self.borrow().len() == self.cursor
-    }
-
-    #[inline]
-    pub fn borrow(&self) -> Ref<String> {
-        self.body.0.borrow()
-    }
-}
diff --git a/src/prolog/tabled_rc.rs b/src/prolog/tabled_rc.rs
deleted file mode 100644 (file)
index a7a093f..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-use std::cell::RefCell;
-use std::cmp::Ordering;
-use std::collections::HashSet;
-use std::fmt;
-use std::hash::{Hash, Hasher};
-use std::ops::Deref;
-use std::rc::Rc;
-
-pub type TabledData<T> = Rc<RefCell<HashSet<Rc<T>>>>;
-
-pub struct TabledRc<T: Hash + Eq> {
-    atom: Rc<T>,
-    table: TabledData<T>
-}
-
-// this Clone instance is manually defined to prevent the compiler
-// from complaining when deriving Clone for StringList.
-impl<T: Hash + Eq> Clone for TabledRc<T> {
-    fn clone(&self) -> Self {
-        TabledRc { atom: self.atom.clone(), table: self.table().clone() }
-    }
-}
-
-impl<T: Ord + Hash + Eq> PartialOrd for TabledRc<T> {
-    fn partial_cmp(&self, other: &Self) -> Option<Ordering>
-    {
-        Some(self.atom.cmp(&other.atom))
-    }
-}
-
-impl<T: Ord + Hash + Eq> Ord for TabledRc<T> {
-    fn cmp(&self, other: &Self) -> Ordering
-    {
-        self.atom.cmp(&other.atom)
-    }
-}
-
-impl<T: Hash + Eq> PartialEq for TabledRc<T> {
-    fn eq(&self, other: &TabledRc<T>) -> bool
-    {
-        self.atom == other.atom
-    }
-}
-
-impl<T: Hash + Eq> Eq for TabledRc<T> {}
-
-impl<T: Hash + Eq> Hash for TabledRc<T> {
-    fn hash<H: Hasher>(&self, state: &mut H) {
-        self.atom.hash(state)
-    }
-}
-
-impl<T: Hash + Eq> TabledRc<T> {
-    pub fn new(atom: T, table: TabledData<T>) -> Self {
-        let atom = match table.borrow_mut().take(&atom) {
-            Some(atom) => atom.clone(),
-            None => Rc::new(atom)
-        };
-
-        table.borrow_mut().insert(atom.clone());
-
-        TabledRc { atom, table }
-    }
-
-    pub fn table(&self) -> TabledData<T> {
-        self.table.clone()
-    }
-}
-
-impl<T: Hash + Eq> Drop for TabledRc<T> {
-    fn drop(&mut self) {
-        if Rc::strong_count(&self.atom) == 2 {
-            self.table.borrow_mut().remove(&self.atom);
-        }
-    }
-}
-
-impl<T: Hash + Eq> Deref for TabledRc<T> {
-    type Target = T;
-
-    fn deref(&self) -> &Self::Target {
-        &*self.atom
-    }
-}
-
-impl<T: Hash + Eq + fmt::Display> fmt::Display for TabledRc<T> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", &*self.atom)
-    }
-}