REPL checkpoint

This commit is contained in:
Tibo De Peuter 2025-04-18 20:36:11 +02:00
parent 69c156024a
commit 1b3280a947
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
21 changed files with 503 additions and 34 deletions

View file

@ -18,7 +18,7 @@ import prolog.logic.unifyLazy
* @see [prolog.ast.terms.Variable]
* @see [Predicate]
*/
abstract class Clause(private val head: Head, private val body: Body) : Resolvent {
abstract class Clause(val head: Head, val body: Body) : Resolvent {
val functor: Functor = head.functor
override fun solve (goal: Goal, subs: Substitutions): Answers = sequence {

View file

@ -39,6 +39,11 @@ class Predicate : Resolvent {
*/
fun add(clause: Clause) {
require(clause.functor == functor) { "Clause functor does not match predicate functor" }
if (Debug.on) {
println("Adding clause $clause to predicate $functor")
}
clauses.add(clause)
}