prepare for batch processing.
This commit is contained in:
@@ -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),
|
||||
|
||||
Submodule src/prolog/parser updated: e15eb2d27b...f44720afd7
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 = []"],
|
||||
|
||||
Reference in New Issue
Block a user