summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index 6fec2b6..f957553 100644
--- a/eval.c
+++ b/eval.c
@@ -40,8 +40,32 @@ evalquery(Term *query)
}else{
Predicate *pred = findpredicate(module->predicates, goal);
if(pred == nil){
- print("No predicate matches: %S:%S\n", module->name, prettyprint(goal, 0, 0, 0, nil));
- goto Backtrack;
+ Rune *name;
+ int arity;
+ Term *replacement = nil;
+ Term *procedure;
+ Term *pi;
+ if(goal->tag == CompoundTerm){
+ name = goal->text;
+ arity = goal->arity;
+ }else{
+ name = prettyprint(goal, 0, 0, 0, nil);
+ arity = 0;
+ }
+ switch(flagunknown){
+ case UnknownError:
+ procedure = mkatom(name);
+ procedure->next = mkinteger(arity);
+ pi = mkcompound(L"/", 2, procedure);
+ replacement = existenceerror(L"procedure", pi);
+ break;
+ case UnknownWarning:
+ print("Warning: no such predicate in module %S: %S/%d\n", module->name, name, arity);
+ case UnknownFail:
+ replacement = mkatom(L"fail");
+ }
+ goalstack = addgoals(goalstack, replacement, module);
+ continue;
}
/* Find a clause where the head unifies with the goal */