TermVisitor

interface TermVisitor<T>

The Visitor-pattern counterpart of the Term hierarchy (see Term.accept). Each visitX method has a default implementation delegating to the visitY method of its immediate supertype Y in the hierarchy (e.g. visitAtom delegates to visitStruct, which delegates to visitTerm, which delegates to defaultValue), so implementers only need to override the methods for the specific sub-types they care about, letting everything else fall back sensibly. defaultValue is the only method that must be implemented.

Overriding visitTerm intercepts every kind of term uniformly (unless a more specific override exists); this is how, e.g., ListIterator and TupleIterator are implemented, by overriding only the couple of visitX methods relevant to unfolding one step of a list/tuple, and letting defaultValue signal "end of sequence" for everything else.

Type Parameters

T

the type of the value produced by visiting a Term

See also

Inheritors

Functions

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

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

Link copied to clipboard
open fun visitAtom(term: Atom): T
Link copied to clipboard
open fun visitBlock(term: Block): T
Link copied to clipboard
open fun visitClause(term: Clause): T
Link copied to clipboard
open fun visitCollection(term: Recursive): T
Link copied to clipboard
open fun visitCons(term: Cons): T
Link copied to clipboard
open fun visitConstant(term: Constant): T
Link copied to clipboard
open fun visitDirective(term: Directive): T
Link copied to clipboard
open fun visitEmpty(term: Empty): T
Link copied to clipboard
open fun visitEmptyBlock(term: EmptyBlock): T
Link copied to clipboard
open fun visitEmptyList(term: EmptyList): T
Link copied to clipboard
open fun visitFact(term: Fact): T
Link copied to clipboard
open fun visitIndicator(term: Indicator): T
Link copied to clipboard
open fun visitInteger(term: Integer): T
Link copied to clipboard
open fun visitList(term: List): T
Link copied to clipboard
open fun visitNumeric(term: Numeric): T
Link copied to clipboard
open fun visitReal(term: Real): T
Link copied to clipboard
open fun visitRule(term: Rule): T
Link copied to clipboard
open fun visitStruct(term: Struct): T
Link copied to clipboard
open fun visitTerm(term: Term): T

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

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