commonMain.it.unibo.tuprolog.solve.function.ExpressionEvaluator.kt Maven / Gradle / Ivy
package it.unibo.tuprolog.solve.function
import it.unibo.tuprolog.core.Struct
import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.solve.ExecutionContext
import it.unibo.tuprolog.solve.exception.error.TypeError
import it.unibo.tuprolog.solve.primitive.Solve
/**
* Evaluates a [Term] as an expression, w.r.t. the loaded functions provided through [request].
* Throws a [TypeError] in case a non-evaluable sub-term is met.
*
* @param request the request of the primitive in which the evaluation should happen
* @param index the index of the argument being evalued in the aforementioned primitive
*/
class ExpressionEvaluator(
request: Solve.Request,
index: Int? = null
) : AbstractEvaluator(request, index) {
override fun unevaluable(struct: Struct): Term =
throw TypeError.forArgument(request.context, request.signature, TypeError.Expected.EVALUABLE, struct, index)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy