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

jvmMain.it.unibo.tuprolog.theory.parsing.ClausesReaderImpl.kt Maven / Gradle / Ivy

import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.core.operators.OperatorSet
import it.unibo.tuprolog.core.parsing.PrologExpressionVisitor
import it.unibo.tuprolog.core.parsing.PrologParserFactory
import it.unibo.tuprolog.core.parsing.toClause
import it.unibo.tuprolog.theory.parsing.ClausesReader
import java.io.InputStream
import java.io.Reader

internal class ClausesReaderImpl(override val defaultOperatorSet: OperatorSet) : ClausesReader {
    override fun readClausesLazily(inputStream: InputStream, operators: OperatorSet): Sequence =
        PrologParserFactory.parseClauses(inputStream, operators)
            .asSequence()
            .map { it.accept(PrologExpressionVisitor()) }
            .map { it.toClause() }

    override fun readClausesLazily(reader: Reader, operators: OperatorSet): Sequence =
        PrologParserFactory.parseClauses(reader, operators)
            .asSequence()
            .map { it.accept(PrologExpressionVisitor()) }
            .map { it.toClause() }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy