]> Repositorios git - scryer-prolog.git/commitdiff
prepare for batch processing.
authorMark Thom <[email protected]>
Mon, 29 Jan 2018 06:25:39 +0000 (23:25 -0700)
committerMark Thom <[email protected]>
Mon, 29 Jan 2018 06:25:39 +0000 (23:25 -0700)
src/prolog/ast.rs
src/prolog/parser
src/prolog/tabled_rc.rs
src/tests.rs

index 0bed72e0c18c1ec98ed4a38c43283e5eb87e67f1..91232738234b6b2c685a8ead0c8eabf7c60e4e1c 100644 (file)
@@ -35,6 +35,8 @@ impl GenContext {
     }
 }
 
+pub type Predicate = Vec<PredicateClause>;
+
 pub enum PredicateClause {
     Fact(Term),
     Rule(Rule)
@@ -80,7 +82,7 @@ pub enum Declaration {
 pub enum TopLevel {
     Declaration(Declaration),
     Fact(Term),
-    Predicate(Vec<PredicateClause>),
+    Predicate(Predicate),
     Query(Vec<QueryTerm>),
     Rule(Rule)
 }
@@ -264,8 +266,8 @@ pub enum ParserError
     InadmissibleFact,
     InadmissibleQueryTerm,
     IncompleteReduction,
-    InconsistentDeclaration,
-    InconsistentPredicate,
+    InconsistentEntry, // was InconsistentDeclaration.
+//    InconsistentPredicate, //TODO: admit this is not needed.
     InvalidRuleHead,
     ParseBigInt,
     ParseFloat(ParseFloatError),
index e15eb2d27bb866d7a94fe47a829f5c51893bede3..f44720afd708c8778e0eeafc0a34121299d0ac86 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e15eb2d27bb866d7a94fe47a829f5c51893bede3
+Subproject commit f44720afd708c8778e0eeafc0a34121299d0ac86
index 70bebcb20e1655b7387895ff50c49af54084243a..dc8f719463e5a8dbebb625ec16deb1f41bd56642 100644 (file)
@@ -7,12 +7,21 @@ use std::rc::Rc;
 
 pub type TabledData<T> = Rc<RefCell<HashSet<Rc<T>>>>;
     
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone)]
 pub struct TabledRc<T: Hash + Eq> {
     atom: Rc<T>,
     table: TabledData<T>
 }
 
+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)
     {
index b2e80bec8bce24bf844532b7a427d98e6f9bf854..0c715e3e282fb6f8fc67fb446a23e1dff20638e3 100644 (file)
@@ -1262,6 +1262,8 @@ fn test_queries_on_builtins()
     assert_prolog_success!(&mut wam, "?- f(1,2,3) =.. [f,1,2,3].");
     assert_prolog_failure!(&mut wam, "?- f(1,2,3) =.. [f,1].");
     assert_prolog_failure!(&mut wam, "?- f(1,2,3) =.. [g,1,2,3].");
+    assert_prolog_success!(&mut wam, "?- f(1,2,3) =.. [f,X,Y,Z].",
+                           [["X = 1", "Y = 2", "Z = 3"]]);
 
     assert_prolog_success_with_limit!(&mut wam, "?- length(Xs, N).",
                                       [["N = 0", "Xs = []"],