From e148152eef545c68302a054a449ee0f184bab700 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sun, 28 Jan 2018 23:25:39 -0700 Subject: [PATCH] prepare for batch processing. --- src/prolog/ast.rs | 8 +++++--- src/prolog/parser | 2 +- src/prolog/tabled_rc.rs | 11 ++++++++++- src/tests.rs | 2 ++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/prolog/ast.rs b/src/prolog/ast.rs index 0bed72e0..91232738 100644 --- a/src/prolog/ast.rs +++ b/src/prolog/ast.rs @@ -35,6 +35,8 @@ impl GenContext { } } +pub type Predicate = Vec; + pub enum PredicateClause { Fact(Term), Rule(Rule) @@ -80,7 +82,7 @@ pub enum Declaration { pub enum TopLevel { Declaration(Declaration), Fact(Term), - Predicate(Vec), + Predicate(Predicate), Query(Vec), 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), diff --git a/src/prolog/parser b/src/prolog/parser index e15eb2d2..f44720af 160000 --- a/src/prolog/parser +++ b/src/prolog/parser @@ -1 +1 @@ -Subproject commit e15eb2d27bb866d7a94fe47a829f5c51893bede3 +Subproject commit f44720afd708c8778e0eeafc0a34121299d0ac86 diff --git a/src/prolog/tabled_rc.rs b/src/prolog/tabled_rc.rs index 70bebcb2..dc8f7194 100644 --- a/src/prolog/tabled_rc.rs +++ b/src/prolog/tabled_rc.rs @@ -7,12 +7,21 @@ use std::rc::Rc; pub type TabledData = Rc>>>; -#[derive(Clone, PartialEq, Eq)] +#[derive(Clone)] pub struct TabledRc { atom: Rc, table: TabledData } +impl PartialEq for TabledRc { + fn eq(&self, other: &TabledRc) -> bool + { + self.atom == other.atom + } +} + +impl Eq for TabledRc {} + impl Hash for TabledRc { fn hash(&self, state: &mut H) { diff --git a/src/tests.rs b/src/tests.rs index b2e80bec..0c715e3e 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -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 = []"], -- 2.54.0