Skip to content

Commit 15fab78

Browse files
committed
fix exec_all for compiled code disjunction
test8 :- ((fail ; fail ; X = ok)), show(test8, X).
1 parent 0f0871b commit 15fab78

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

builtin.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,29 @@ int exec_all(int goals, int bindings, int th)
371371
unbind(bindings,th);
372372
return (NO);
373373
}
374+
// (D1,D2)
375+
else if(structurep(goals) && car(goals) == OR){
376+
if (exec_all(cadr(goals), bindings, th) == YES)
377+
return(YES);
378+
unbind(bindings,th);
379+
if (exec_all(caddr(goals), bindings, th) == YES)
380+
return(YES);
381+
unbind(bindings,th);
382+
return (NO);
383+
}
374384
// ((D1,D2),Xs)
375385
else if (structurep(goals) && car(goals) == AND
376386
&& car(cadr(goals)) == AND) {
377387
if (exec_all(cadr(goals), bindings, th) == YES)
378388
return (exec_all(caddr(goals), bindings, th));
379389
else
380390
return (NO);
381-
} else if ((structurep(goals) && car(goals) != AND) || atomp(goals))
391+
}
392+
// predicate P
393+
else if ((structurep(goals) && car(goals) != AND) || atomp(goals))
382394
return (exec(goals, bindings, NIL, th));
383-
else {
395+
// (P1,P2,...)
396+
else {
384397
return (exec(cadr(goals), bindings, caddr(goals), th));
385398
}
386399

0 commit comments

Comments
 (0)