diff options
-rw-r--r-- | eval.c | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -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 */ |