TermFormatter

A Formatter specialized in rendering Terms as Strings, implemented as a TermVisitor (each visitX method renders the corresponding sub-type). The companion offers ready-made formatters covering the usual combinations of options (canonical, default, readable, prettyVariables, prettyExpressions); of is the general entry point when a custom combination of VarFormat/OpFormat/FuncFormat is needed.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

How Struct.functors should be rendered.

Link copied to clipboard

Whether/how known it.unibo.tuprolog.core.operators.Operators should affect rendering.

Link copied to clipboard
data class TagsFormattingOptions(val showTags: Boolean = false, val delimiters: Pair<String, String> = "<" to ">", val separator: String = ", ", val showKeys: Boolean = true, val showDelimitersIfEmpty: Boolean = false, val keyFilter: (String) -> Boolean = { true }, val tagFormatter: Formatter<Any>? = null)

Options controlling whether/how a Term's tags (see it.unibo.tuprolog.utils.Taggable) are rendered alongside it.

Link copied to clipboard

How Variables should be rendered.

Functions

Link copied to clipboard
abstract fun defaultValue(term: Term): String

The value produced for any Term whose specific type has no dedicated, overridden visitX method.

Link copied to clipboard
open override fun format(value: Term): String

Converts a Term into a String

Link copied to clipboard
open fun visitAtom(term: Atom): String
Link copied to clipboard
open fun visitBlock(term: Block): String
Link copied to clipboard
open fun visitClause(term: Clause): String
Link copied to clipboard
Link copied to clipboard
open fun visitCons(term: Cons): String
Link copied to clipboard
open fun visitConstant(term: Constant): String
Link copied to clipboard
Link copied to clipboard
open fun visitEmpty(term: Empty): String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun visitFact(term: Fact): String
Link copied to clipboard
Link copied to clipboard
open fun visitInteger(term: Integer): String
Link copied to clipboard
open fun visitList(term: List): String
Link copied to clipboard
open fun visitNumeric(term: Numeric): String
Link copied to clipboard
open fun visitReal(term: Real): String
Link copied to clipboard
open fun visitRule(term: Rule): String
Link copied to clipboard
open fun visitStruct(term: Struct): String
Link copied to clipboard
open fun visitTerm(term: Term): String

Visits a generic Term, regardless of its specific sub-type. Falls back to defaultValue.

Link copied to clipboard
open fun visitTruth(term: Truth): String
Link copied to clipboard
open fun visitTuple(term: Tuple): String
Link copied to clipboard
open fun visitVar(term: Var): String