add support for embedded calls (syntax)
This commit is contained in:
@@ -638,6 +638,15 @@ mod tests {
|
||||
assert_eq!(submit(&mut wam, "?- call(david_lynch, X)."), true);
|
||||
assert_eq!(submit(&mut wam, "?- call(david_lynch, kyle(Film))."), true);
|
||||
assert_eq!(submit(&mut wam, "?- call(david_lynch, kyle(Film), _)."), false);
|
||||
|
||||
submit(&mut wam, "call_mult(P, X) :- call(call(P), X).");
|
||||
|
||||
assert_eq!(submit(&mut wam, "?- call_mult(p(X), Y)."), true);
|
||||
assert_eq!(submit(&mut wam, "?- call_mult(p(X), X)."), true);
|
||||
assert_eq!(submit(&mut wam, "?- call_mult(p(one), X)."), true);
|
||||
assert_eq!(submit(&mut wam, "?- call_mult(p(X), one)."), true);
|
||||
assert_eq!(submit(&mut wam, "?- call_mult(p(two), one)."), false);
|
||||
assert_eq!(submit(&mut wam, "?- call_mult(p(two), two)."), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,25 @@ BoxedTerm : Box<Term> = {
|
||||
};
|
||||
|
||||
Call : QueryTerm = {
|
||||
"call" "(" <c:Call> <ts: ("," <BoxedTerm>)*> ")" => {
|
||||
match c {
|
||||
QueryTerm::CallN(mut terms) => {
|
||||
let vt = terms.pop().unwrap();
|
||||
let mut ts = ts;
|
||||
|
||||
terms.append(&mut ts);
|
||||
terms.push(vt);
|
||||
|
||||
QueryTerm::CallN(terms)
|
||||
},
|
||||
QueryTerm::Term(Term::Clause(cell, atom, mut terms)) => {
|
||||
let mut ts = ts;
|
||||
terms.append(&mut ts);
|
||||
QueryTerm::Term(Term::Clause(cell, atom, terms))
|
||||
},
|
||||
_ => c
|
||||
}
|
||||
},
|
||||
"call" "(" <a:Atom> "(" <ts: (<BoxedTerm> ",")*> <t:BoxedTerm> ")"
|
||||
<tss: ("," <BoxedTerm>)*> ")" => {
|
||||
let mut ts = ts;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user