All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.it.unibo.tuprolog.theory.parsing.ClausesParser.kt Maven / Gradle / Ivy

Go to download

Parsing facilities for knoledge bases made up of logic clauses, out of Prolog standard syntax

There is a newer version: 1.0.4
Show newest version
package it.unibo.tuprolog.theory.parsing

import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.core.operators.Operator
import it.unibo.tuprolog.core.operators.OperatorSet
import it.unibo.tuprolog.theory.Theory
import kotlin.js.JsName
import kotlin.jvm.JvmStatic

interface ClausesParser {
    @JsName("defaultOperatorSet")
    val defaultOperatorSet: OperatorSet

    @JsName("parseTheoryWithOperators")
    fun parseTheory(input: String, operators: OperatorSet): Theory =
        Theory.indexedOf(parseClausesLazily(input, operators))

    @JsName("parseTheory")
    fun parseTheory(input: String): Theory =
        parseTheory(input, defaultOperatorSet)

    @JsName("parseClausesLazilyWithOperators")
    fun parseClausesLazily(input: String, operators: OperatorSet): Sequence

    @JsName("parseClausesLazily")
    fun parseClausesLazily(input: String): Sequence =
        parseClausesLazily(input, defaultOperatorSet)

    @JsName("parseClausesWithOperators")
    fun parseClauses(input: String, operators: OperatorSet): List =
        parseClausesLazily(input, operators).toList()

    @JsName("parseClauses")
    fun parseClauses(input: String): List =
        parseClauses(input, defaultOperatorSet)

    companion object {
        @JvmStatic
        @JsName("withNoOperator")
        val withNoOperator = withOperators()

        @JvmStatic
        @JsName("withStandardOperators")
        val withStandardOperators = withOperators(OperatorSet.STANDARD)

        @JvmStatic
        @JsName("withDefaultOperators")
        val withDefaultOperators = withOperators(OperatorSet.DEFAULT)

        @JvmStatic
        @JsName("withOperatorSet")
        fun withOperators(operators: OperatorSet) = clausesParserWithOperators(operators)

        @JvmStatic
        @JsName("withOperators")
        fun withOperators(vararg operators: Operator) = withOperators(OperatorSet(*operators))
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy