DirectiveSelector

The concrete DirectiveListener recognizing every directive pattern 2P-Kt gives special treatment to when loading a knowledge base: dynamic/1, static/1 (declaring a predicate's storage), initialization/1/solve/1 (a goal to run at load time), include/1/load/1 (another theory to load), op/3 (operator declaration), and set_flag/2/set_prolog_flag/2 (flag assignment). Each recognized pattern is routed to the corresponding on* callback (onDynamic, onStatic, onSolve, onLoad, onOperator, onSetFlag); anything else falls back to ClauseListener.onDirective.

Implemented by ClausePartitioner, which is what actually collects the callbacks' arguments into a ClausePartition.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val patterns: List<Term>

The directive-body patterns recognized by this listener, tried in order.

Link copied to clipboard
abstract val unificator: Unificator

The Unificator used to match a directive's body against patterns.

Functions

Link copied to clipboard
open override fun listen(clause: Clause)

Dispatches clause to onDirective/onFact/onRule/onClause, depending on its concrete kind.

Link copied to clipboard
open fun listenDirective(directive: Directive)

Tries to unify directive's body against each of patterns, in order; on the first match, delegates to listenDirectiveMatchingPattern, otherwise falls back to ClauseListener.onDirective.

Link copied to clipboard
open override fun listenDirectiveMatchingPattern(directive: Directive, pattern: Term, unifier: Substitution.Unifier)

Invoked by listenDirective on a match; by default just forwards to onDirectiveMatchingPattern.

Link copied to clipboard
abstract fun onClause(clause: Clause)

Invoked when listening any Clause that is neither a Directive, Fact, nor Rule.

Link copied to clipboard
abstract fun onDirective(directive: Directive)

Invoked when listening a Directive (a :- Goal clause).

Link copied to clipboard
abstract fun onDirectiveMatchingPattern(directive: Directive, pattern: Term, unifier: Substitution.Unifier)

Invoked when a directive's body unifies with one of patterns, via unifier.

Link copied to clipboard
abstract fun onDynamic(directive: Directive, indicator: Indicator)

Invoked on a dynamic(indicator) directive.

Link copied to clipboard
abstract fun onFact(fact: Fact)

Invoked when listening a Fact (a clause with an empty body).

Link copied to clipboard
abstract fun onLoad(directive: Directive, goal: Term)

Invoked on an include(goal)/load(goal) directive.

Link copied to clipboard
abstract fun onOperator(directive: Directive, priority: Term, specifier: Term, name: Term)

Invoked on an op(priority, specifier, name) directive.

Link copied to clipboard
abstract fun onRule(rule: Rule)

Invoked when listening a Rule (a clause with a non-empty body, other than a Directive).

Link copied to clipboard
abstract fun onSetFlag(directive: Directive, name: Term, value: Term)

Invoked on a set_flag(name, value)/set_prolog_flag(name, value) directive.

Link copied to clipboard
abstract fun onSolve(directive: Directive, goal: Term)

Invoked on an initialization(goal)/solve(goal) directive.

Link copied to clipboard
abstract fun onStatic(directive: Directive, indicator: Indicator)

Invoked on a static(indicator) directive.