clips

package
v0.0.0-...-83c5339 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activation

type Activation struct {
	// contains filtered or unexported fields
}

Activation represents an activation from the agenda

func (*Activation) Equal

func (a *Activation) Equal(other *Activation) bool

Equal returns true if other activation represents the same CLIPS activation as this one

func (*Activation) Name

func (a *Activation) Name() string

Name returns the name of the rule of this activation

func (*Activation) Remove

func (a *Activation) Remove() error

Remove removes this activation from the agenda. Renamed from "delete" to avoid confusion with other Deletes which always only drop references to CLIPS

func (*Activation) Salience

func (a *Activation) Salience() int

Salience returns the salience value for this activation

func (*Activation) SetSalience

func (a *Activation) SetSalience(salience int)

SetSalience modifies the salience of this activation

func (*Activation) String

func (a *Activation) String() string

type Class

type Class struct {
	// contains filtered or unexported fields
}

Class is a reference to a CLIPS class

func (*Class) Abstract

func (cl *Class) Abstract() bool

Abstract returns true if the class is abstract

func (*Class) Deletable

func (cl *Class) Deletable() bool

Deletable returns true if the class is unreferenced and therefore deletable

func (*Class) Equal

func (cl *Class) Equal(other *Class) bool

Equal returns true if other class represents the same CLIPS class as this one

func (*Class) FindMessageHandler

func (cl *Class) FindMessageHandler(name string, handlerType MessageHandlerType) (*MessageHandler, error)

FindMessageHandler returns a reference to the named message handler

func (*Class) Instances

func (cl *Class) Instances() []*Instance

Instances returns the list of instances of this class

func (*Class) MessageHandlers

func (cl *Class) MessageHandlers() []*MessageHandler

MessageHandlers returns a list of all message handlers for this class

func (*Class) Module

func (cl *Class) Module() *Module

Module returns the module in which this class is defined

func (*Class) Name

func (cl *Class) Name() string

Name returns the name of this class

func (*Class) NewInstance

func (cl *Class) NewInstance(name string, skipInit bool) (*Instance, error)

NewInstance creates an instance of this class. If skipInit is true, a new, uninitialized instance of this class. Slots will be unset until the caller calls SetSlot on each one, or calls (initialize-instance [instname])

func (*Class) Reactive

func (cl *Class) Reactive() bool

Reactive returns true if the class is reactive

func (*Class) Slot

func (cl *Class) Slot(name string) (*ClassSlot, error)

Slot returns the given slot by name

func (*Class) Slots

func (cl *Class) Slots(inherited bool) []*ClassSlot

Slots returns a list of all slots for this class. inhereted determines whether inhereted slots are included

func (*Class) String

func (cl *Class) String() string

func (*Class) Subclass

func (cl *Class) Subclass(other *Class) bool

Subclass returns true if this class is a subclass of the given one

func (*Class) Subclasses

func (cl *Class) Subclasses(inherited bool) ([]*Class, error)

Subclasses returns the list of subclasses of this class

func (*Class) Superclass

func (cl *Class) Superclass(other *Class) bool

Superclass returns true if this class is a superclass of the given one

func (*Class) Superclasses

func (cl *Class) Superclasses(inherited bool) ([]*Class, error)

Superclasses returns the list of superclasses of this class

func (*Class) Undefine

func (cl *Class) Undefine() error

Undefine undefines the class within CLIPS. Equivalent to undefclass

func (*Class) WatchInstances

func (cl *Class) WatchInstances(val bool)

WatchInstances sets whether instances of this class should be watched

func (*Class) WatchSlots

func (cl *Class) WatchSlots(val bool)

WatchSlots sets whether instances of this class should be watched

func (*Class) WatchedInstances

func (cl *Class) WatchedInstances() bool

WatchedInstances returns true if the class instances are being watched

func (*Class) WatchedSlots

func (cl *Class) WatchedSlots() bool

WatchedSlots returns true if the class slots are being watched

type ClassDefaultsMode

type ClassDefaultsMode int

ClassDefaultsMode defines the mode for defaults in a class

const (
	CONVENIENCE_MODE ClassDefaultsMode = iota
	CONSERVATION_MODE
)

func (ClassDefaultsMode) CVal

func (sm ClassDefaultsMode) CVal() C.ushort

CVal returns the value as appropriate for a C call

func (ClassDefaultsMode) String

func (sm ClassDefaultsMode) String() string

type ClassSlot

type ClassSlot struct {
	// contains filtered or unexported fields
}

ClassSlot is a reference to a slot within a particular class

func (*ClassSlot) Accessible

func (cs *ClassSlot) Accessible() bool

Accessible returns true if the slot is accessible

func (*ClassSlot) AllowedClasses

func (cs *ClassSlot) AllowedClasses() (values []Symbol, ok bool)

AllowedClasses returns the names of allowed classes for this slot, if specified. Equivalent to slot-allowed-classes

func (*ClassSlot) AllowedValues

func (cs *ClassSlot) AllowedValues() (values []interface{}, ok bool)

AllowedValues returns the set of allowed values for this slot, if specified

func (*ClassSlot) Cardinality

func (cs *ClassSlot) Cardinality() (low int64, high int64, hasHigh bool)

Cardinality returns the cardinality for the slot

func (*ClassSlot) DefaultValue

func (cs *ClassSlot) DefaultValue() interface{}

DefaultValue returns a default value for the slot. (This might be a new, unique value for DYNAMIC_DEFAULT defaults)

func (*ClassSlot) Equal

func (cs *ClassSlot) Equal(other *ClassSlot) bool

Equal returns true if this slot represents the same CLIPS slot as the other slot

func (*ClassSlot) Facets

func (cs *ClassSlot) Facets() []Symbol

Facets returns a list of facets for this slot

func (*ClassSlot) FloatRange

func (cs *ClassSlot) FloatRange() (low float64, hasLow bool, high float64, hasHigh bool)

FloatRange returns the numeric range for the slot for floating point values - e.g. low, haslow, high, hashigh := ts.Range()

func (*ClassSlot) Initable

func (cs *ClassSlot) Initable() bool

Initable returns true if the slot is initable

func (*ClassSlot) IntRange

func (cs *ClassSlot) IntRange() (low int64, hasLow bool, high int64, hasHigh bool)

IntRange returns the numeric range for the slot for integer values - e.g. low, haslow, high, hashigh := ts.Range()

func (*ClassSlot) Name

func (cs *ClassSlot) Name() string

Name returns the name of the slot

func (*ClassSlot) Public

func (cs *ClassSlot) Public() bool

Public returns true if the slot is public

func (*ClassSlot) Sources

func (cs *ClassSlot) Sources() []Symbol

Sources returns a list of names of class sources for this slot. Equivalent to slot-sources

func (*ClassSlot) String

func (cs *ClassSlot) String() string

func (*ClassSlot) Types

func (cs *ClassSlot) Types() []Symbol

Types returns a list of value types for this slot. Equivalent to slot-types

func (*ClassSlot) Writable

func (cs *ClassSlot) Writable() bool

Writable returns true if the slot is writable

type DataObject

type DataObject struct {
	// contains filtered or unexported fields
}

DataObject wraps a CLIPS data object

func (*DataObject) Delete

func (do *DataObject) Delete()

Delete frees up associated memory

func (*DataObject) ExtractValue

func (do *DataObject) ExtractValue(retval interface{}, extractClasses bool) error

ExtractValue attempts to put the represented data value into the item provided by the user.

func (*DataObject) MustExtractValue

func (do *DataObject) MustExtractValue(retval interface{}, extractClasses bool)

MustExtractValue attempts to put the represented data value into the item provided by the user, and panics if it can't

func (*DataObject) SetValue

func (do *DataObject) SetValue(value interface{})

SetValue copies the go value into the dataobject

func (*DataObject) Value

func (do *DataObject) Value() interface{}

Value returns the Go value for this data object

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

Environment stores a CLIPS environment

func CreateEnvironment

func CreateEnvironment() *Environment

CreateEnvironment creates a new instance of a CLIPS environment

func (*Environment) Activations

func (env *Environment) Activations() []*Activation

Activations returns the list of activations in the agenda

func (*Environment) AgendaChanged

func (env *Environment) AgendaChanged() bool

AgendaChanged returns true if any rule activation changes have occurred since last call

func (*Environment) AssertString

func (env *Environment) AssertString(factstr string) (Fact, error)

AssertString asserts a fact as a string.

func (*Environment) BatchStar

func (env *Environment) BatchStar(path string) error

BatchStar executes the CLIPS code found in path. Equivalent to CLIPS (batch*)

func (*Environment) Build

func (env *Environment) Build(construct string) error

Build builds a single construct within the CLIPS environment

func (*Environment) ClassDefaultsMode

func (env *Environment) ClassDefaultsMode() ClassDefaultsMode

ClassDefaultsMode returns the current class defaults mode. Equivalent to (get-class-defaults-mode)

func (*Environment) Classes

func (env *Environment) Classes() []*Class

Classes returns the set of defined classes

func (*Environment) Clear

func (env *Environment) Clear()

Clear clears the CLIPS environment

func (*Environment) ClearAgenda

func (env *Environment) ClearAgenda() error

ClearAgenda deletes all activations in the agenda

func (*Environment) ClearFocus

func (env *Environment) ClearFocus()

ClearFocus removes all modules from the focus stack

func (*Environment) CompleteCommand

func (env *Environment) CompleteCommand(cmd string) (bool, error)

CompleteCommand checks the string to see if it is a complete command yet

func (*Environment) CurrentModule

func (env *Environment) CurrentModule() *Module

CurrentModule returns the current module of the env

func (*Environment) DefineFunction

func (env *Environment) DefineFunction(name string, callback interface{}) error

DefineFunction defines a Go function within the CLIPS environment. If the given name is "", the name of the go funciton will be used

func (*Environment) Delete

func (env *Environment) Delete()

Delete destroys the CLIPS environment

func (*Environment) Eval

func (env *Environment) Eval(construct string) (interface{}, error)

Eval evaluates an expression returning its value

func (*Environment) ExtractEval

func (env *Environment) ExtractEval(retval interface{}, construct string) error

ExtractEval evaluates an expression, storing its return value into the object passed by the user

func (*Environment) Facts

func (env *Environment) Facts() []Fact

Facts returns a slice of all facts known to CLIPS

func (*Environment) FindClass

func (env *Environment) FindClass(name string) (*Class, error)

FindClass returns a reference to the given class

func (*Environment) FindFunction

func (env *Environment) FindFunction(name string) (*Function, error)

FindFunction returns the function of the given name

func (*Environment) FindGeneric

func (env *Environment) FindGeneric(name string) (*Generic, error)

FindGeneric returns the generic identified by name

func (*Environment) FindGlobal

func (env *Environment) FindGlobal(name string) (*Global, error)

FindGlobal finds the global by name

func (*Environment) FindInstance

func (env *Environment) FindInstance(name InstanceName, module string) (*Instance, error)

FindInstance returns the instance of the given name. module may be the empty string to use the current module

func (*Environment) FindModule

func (env *Environment) FindModule(name string) (*Module, error)

FindModule returns the module with the given name

func (*Environment) FindRule

func (env *Environment) FindRule(name string) (*Rule, error)

FindRule returns the rule of the given name

func (*Environment) FindTemplate

func (env *Environment) FindTemplate(name string) (*Template, error)

FindTemplate returns an object representing the given template name

func (*Environment) Focus

func (env *Environment) Focus() *Module

Focus returns the module associated with the current focus

func (*Environment) Functions

func (env *Environment) Functions() []*Function

Functions returns the set of all functions in CLIPS

func (*Environment) Generics

func (env *Environment) Generics() []*Generic

Generics returns a list of all generics in CLIPS

func (*Environment) Globals

func (env *Environment) Globals() []*Global

Globals returns a slice containing references to all globals

func (*Environment) GlobalsChanged

func (env *Environment) GlobalsChanged() bool

GlobalsChanged returns true if any global has changed since last call

func (*Environment) Insert

func (env *Environment) Insert(name string, basis interface{}, opts ...InsertClassOption) (*Instance, error)

Insert inserts the given object as a shadow instance in CLIPS. A shadow class will be created if it does not already exist

func (*Environment) InsertClass

func (env *Environment) InsertClass(basis interface{}, opts ...InsertClassOption) (*Class, error)

InsertClass creates a representation of a Go struct as a CLIPS defclass

func (*Environment) Instances

func (env *Environment) Instances() []*Instance

Instances returns all defined instances

func (*Environment) InstancesChanged

func (env *Environment) InstancesChanged() bool

InstancesChanged returns true if any instance has changed

func (*Environment) Load

func (env *Environment) Load(path string) error

Load loads a set of constructs into the CLIPS data base. Constructs can be in text or binary format. Equivalent to CLIPS (load)

func (*Environment) LoadFacts

func (env *Environment) LoadFacts(filename string) error

LoadFacts loads facts from the given file

func (*Environment) LoadFactsFromString

func (env *Environment) LoadFactsFromString(factstr string) error

LoadFactsFromString loads facts from the given string

func (*Environment) LoadInstances

func (env *Environment) LoadInstances(filename string) error

LoadInstances loads a set of instances into the CLIPS database. Equivalent to the load-instances command

func (*Environment) LoadInstancesFromString

func (env *Environment) LoadInstancesFromString(instances string) error

LoadInstancesFromString loads a set of instances into the CLIPS database. Equivalent to the load-instances command

func (*Environment) MakeInstance

func (env *Environment) MakeInstance(command string) (*Instance, error)

MakeInstance creates and initializes an instance of a user-defined class. Equivalent to make-instance Command must be a string in the form ([<instance-name>] of <class-name> <slot-override>*) <slot-override> :== (<slot-name> <constant>*)

func (*Environment) Modules

func (env *Environment) Modules() []*Module

Modules returns the list of modulesb

func (*Environment) Refresh

func (env *Environment) Refresh(module *Module)

Refresh recomputes the salience values of the Activations on the Agenda. If module is nil, the current module is used. To be called after changing the conflict resoution strategy

func (*Environment) Reorder

func (env *Environment) Reorder(module *Module)

Reorder reorders the activations in the agenda. If module is nil, the current module is used. To be called after changing the conflict resoution strategy

func (*Environment) Reset

func (env *Environment) Reset()

Reset resets the CLIPS environment

func (*Environment) RestoreInstances

func (env *Environment) RestoreInstances(filename string) error

RestoreInstances loads a set of instances into CLIPS, bypassing message handling. Intended for use with save. Equivalent to restore-isntances command

func (*Environment) RestoreInstancesFromString

func (env *Environment) RestoreInstancesFromString(instances string) error

RestoreInstancesFromString loads a set of instances into CLIPS, bypassing message handling. Intended for use with save. Equivalent to restore-isntances command

func (*Environment) Rules

func (env *Environment) Rules() []*Rule

Rules returns the list of all rules in the CLIPS environment

func (*Environment) Run

func (env *Environment) Run(limit int64) int64

Run runs the activations in the agenda. If limit is not negative, only the first activations up to the limit will be run

func (*Environment) SalienceEvaluation

func (env *Environment) SalienceEvaluation() SalienceEvaluation

SalienceEvaluation returns the salience evaulation behavior

func (*Environment) Save

func (env *Environment) Save(path string, binary bool) error

Save saves the current state of the environment

func (*Environment) SaveFacts

func (env *Environment) SaveFacts(filename string, savemode SaveMode) error

SaveFacts saves facts to the given file

func (*Environment) SaveInstances

func (env *Environment) SaveInstances(path string, binary bool, mode SaveMode) error

SaveInstances saves the instances in the system to the specified file. If binary is true, instances will be aaved in binary format. Equivalent to save-instances

func (*Environment) SendCommand

func (env *Environment) SendCommand(cmd string) error

SendCommand evaluates a command as if it were typed in the CLIPS shell

func (*Environment) SetClassDefaultsMode

func (env *Environment) SetClassDefaultsMode(mode ClassDefaultsMode)

SetClassDefaultsMode sets the class defaults mode

func (*Environment) SetFocus

func (env *Environment) SetFocus(module *Module)

SetFocus sets the current focus to the given module

func (*Environment) SetModule

func (env *Environment) SetModule(module *Module)

SetModule sets the current module for the CLIPS env

func (*Environment) SetSalienceEvaluation

func (env *Environment) SetSalienceEvaluation(val SalienceEvaluation)

SetSalienceEvaluation sets the salience evaluation behavior

func (*Environment) SetStrategy

func (env *Environment) SetStrategy(strategy Strategy)

SetStrategy sets the conflict resolution strategy

func (*Environment) Shell

func (env *Environment) Shell()

Shell sets up an interactive CLIPS shell within the given environment

func (*Environment) Strategy

func (env *Environment) Strategy() Strategy

Strategy returns the current conflict resolution strategy

func (*Environment) Templates

func (env *Environment) Templates() []*Template

Templates returns a slice of all defined templates

type Error

type Error struct {
	Err  error
	Code string
}

Error error returned from CLIPS

func EnvError

func EnvError(env *Environment, msg string, args ...interface{}) *Error

EnvError return an error that came from CLIPS

func (*Error) Error

func (e *Error) Error() string

type ErrorRouter

type ErrorRouter struct {
	// contains filtered or unexported fields
}

ErrorRouter is a router that puts messages into go logging

func CreateErrorRouter

func CreateErrorRouter(env *Environment) *ErrorRouter

CreateErrorRouter returns a new error accumulation router

func (*ErrorRouter) Activate

func (r *ErrorRouter) Activate() error

Activate activates this router with the Env

func (*ErrorRouter) Deactivate

func (r *ErrorRouter) Deactivate() error

Deactivate deactivates this router with the Env

func (*ErrorRouter) Delete

func (r *ErrorRouter) Delete() error

Delete removes this router from the Env

func (*ErrorRouter) Exit

func (r *ErrorRouter) Exit(exitcode int)

Exit is called by CLIPS before CLIPS itself exits

func (*ErrorRouter) Getc

func (r *ErrorRouter) Getc(name string) byte

Getc is called by CLIPS to obtain a character from input

func (*ErrorRouter) LastMessage

func (r *ErrorRouter) LastMessage() string

LastMessage returns the accumulated error message and resets it

func (*ErrorRouter) Name

func (r *ErrorRouter) Name() string

Name of this router

func (*ErrorRouter) Print

func (r *ErrorRouter) Print(name string, message string)

Print is called with a message if Query has returned true

func (*ErrorRouter) Query

func (r *ErrorRouter) Query(name string) bool

Query should return true if the router handles the given logical IO name

func (*ErrorRouter) Ungetc

func (r *ErrorRouter) Ungetc(name string, ch byte) error

Ungetc is called by CLIPS to push a character back into the input queue

type Fact

type Fact interface {
	// Index returns the index number of this fact within CLIPS
	Index() int

	// Asserted returns true if the fact has been asserted.
	Asserted() bool

	// Assert asserts the fact
	Assert() error

	// Retract retracts the fact from CLIPS
	Retract() error

	// Template returns the template defining this fact
	Template() *Template

	// String returns a string representation of the fact
	String() string

	// Drop drops the reference to the fact in CLIPS. should be called when done with the fact
	Drop()

	// Equal returns true if this fact equal the given fact
	Equal(Fact) bool

	// Slots returns a *copy* of slot values for each slot in this fact
	Slots() (map[string]interface{}, error)

	// Slot returns the value of a given slot. For Implied Facts, "" is the only valid slot name
	Slot(slotname string) (interface{}, error)

	// ExtractSlot unmarshals the given slot into the user provided object
	ExtractSlot(retval interface{}, slotname string) error

	// Extract unmarshals the full fact into the user provided object
	Extract(retval interface{}) error
}

Fact represents a fact within CLIPS

type Function

type Function struct {
	// contains filtered or unexported fields
}

Function references a CLIPS function

func (*Function) Call

func (f *Function) Call(arguments string) (interface{}, error)

Call calls the CLIPS function with the given arguments (must be a space-delimited string)

func (*Function) Deletable

func (f *Function) Deletable() bool

Deletable returns true if function is unreferenced and deletable

func (*Function) Equal

func (f *Function) Equal(other *Function) bool

Equal returns true if the other function represents the same CLIPS function as this one

func (*Function) Module

func (f *Function) Module() *Module

Module returns the module in which this function is defined

func (*Function) Name

func (f *Function) Name() string

Name returns the name of this function

func (*Function) String

func (f *Function) String() string

func (*Function) Undefine

func (f *Function) Undefine() error

Undefine undefines the function within CLIPS

func (*Function) Watch

func (f *Function) Watch(val bool)

Watch sets whether the function is being watched

func (*Function) Watched

func (f *Function) Watched() bool

Watched returns true if function is being watched

type Generic

type Generic struct {
	// contains filtered or unexported fields
}

Generic represents a CLIPS genneric

func (*Generic) Call

func (g *Generic) Call(arguments string) (interface{}, error)

Call calls the CLIPS generic function. Arguments must be passed as a string

func (*Generic) Deletable

func (g *Generic) Deletable() bool

Deletable returns true if the generic is unreferenced and can be deleted

func (*Generic) Equal

func (g *Generic) Equal(other *Generic) bool

Equal returns true if the other generic represents the same CLIPS generic

func (*Generic) Methods

func (g *Generic) Methods() []*Method

Methods returns a list of all methods for this generic

func (*Generic) Module

func (g *Generic) Module() *Module

Module returns a reference to the module of this generic

func (*Generic) Name

func (g *Generic) Name() string

Name returns the name of this generic

func (*Generic) String

func (g *Generic) String() string

func (*Generic) Undefine

func (g *Generic) Undefine() error

Undefine undefines the Generic

func (*Generic) Watch

func (g *Generic) Watch(val bool)

Watch sets whether this generic is watched

func (*Generic) Watched

func (g *Generic) Watched() bool

Watched returns true if the generic is watched

type Global

type Global struct {
	// contains filtered or unexported fields
}

Global represents a global variable within CLIPS

func (*Global) Deletable

func (g *Global) Deletable() bool

Deletable returns true if the global can be deleted

func (*Global) Equal

func (g *Global) Equal(other *Global) bool

Equal returns true if the other object represents the same global in CLIPS

func (*Global) Module

func (g *Global) Module() *Module

Module returns a referece to the module of this global

func (*Global) Name

func (g *Global) Name() string

Name returns the name of this global

func (*Global) SetValue

func (g *Global) SetValue(value interface{}) error

SetValue sets the value of this global

func (*Global) String

func (g *Global) String() string

func (*Global) Undefine

func (g *Global) Undefine() error

Undefine undefines the global

func (*Global) Value

func (g *Global) Value() (interface{}, error)

Value returns the value of this global

func (*Global) Watch

func (g *Global) Watch(val bool)

Watch sets whether the global is watched

func (*Global) Watched

func (g *Global) Watched() bool

Watched returns true if the global can be deleted

type HighlightedWriter

type HighlightedWriter struct {
	// contains filtered or unexported fields
}

HighlightedWriter tries to catch selected writes and use the syntax highlighting on them

func (*HighlightedWriter) AskForCPR

func (hw *HighlightedWriter) AskForCPR()

AskForCPR asks for a cursor position report (CPR).

func (*HighlightedWriter) ClearTitle

func (hw *HighlightedWriter) ClearTitle()

ClearTitle clears a title of terminal window.

func (*HighlightedWriter) CursorBackward

func (hw *HighlightedWriter) CursorBackward(n int)

CursorBackward moves the cursor backward by 'n' columns; the default count is 1.

func (*HighlightedWriter) CursorDown

func (hw *HighlightedWriter) CursorDown(n int)

CursorDown moves the cursor down by 'n' rows; the default count is 1.

func (*HighlightedWriter) CursorForward

func (hw *HighlightedWriter) CursorForward(n int)

CursorForward moves the cursor forward by 'n' columns; the default count is 1.

func (*HighlightedWriter) CursorGoTo

func (hw *HighlightedWriter) CursorGoTo(row, col int)

CursorGoTo sets the cursor position where subsequent text will begin.

func (*HighlightedWriter) CursorUp

func (hw *HighlightedWriter) CursorUp(n int)

CursorUp moves the cursor up by 'n' rows; the default count is 1.

func (*HighlightedWriter) EraseDown

func (hw *HighlightedWriter) EraseDown()

EraseDown erases the screen from the current line down to the bottom of the screen.

func (*HighlightedWriter) EraseEndOfLine

func (hw *HighlightedWriter) EraseEndOfLine()

EraseEndOfLine erases from the current cursor position to the end of the current line.

func (*HighlightedWriter) EraseLine

func (hw *HighlightedWriter) EraseLine()

EraseLine erases the entire current line.

func (*HighlightedWriter) EraseScreen

func (hw *HighlightedWriter) EraseScreen()

EraseScreen erases the screen with the background colour and moves the cursor to home.

func (*HighlightedWriter) EraseStartOfLine

func (hw *HighlightedWriter) EraseStartOfLine()

EraseStartOfLine erases from the current cursor position to the start of the current line.

func (*HighlightedWriter) EraseUp

func (hw *HighlightedWriter) EraseUp()

EraseUp erases the screen from the current line up to the top of the screen.

func (*HighlightedWriter) Flush

func (hw *HighlightedWriter) Flush() error

Flush to flush buffer.

func (*HighlightedWriter) HideCursor

func (hw *HighlightedWriter) HideCursor()

HideCursor hides cursor.

func (*HighlightedWriter) SaveCursor

func (hw *HighlightedWriter) SaveCursor()

SaveCursor saves current cursor position.

func (*HighlightedWriter) ScrollDown

func (hw *HighlightedWriter) ScrollDown()

ScrollDown scrolls display down one line.

func (*HighlightedWriter) ScrollUp

func (hw *HighlightedWriter) ScrollUp()

ScrollUp scroll display up one line.

func (*HighlightedWriter) SetColor

func (hw *HighlightedWriter) SetColor(fg, bg prompt.Color, bold bool)

SetColor sets text and background colors. and specify whether text is bold.

func (*HighlightedWriter) SetTitle

func (hw *HighlightedWriter) SetTitle(title string)

SetTitle sets a title of terminal window.

func (*HighlightedWriter) ShowCursor

func (hw *HighlightedWriter) ShowCursor()

ShowCursor stops blinking cursor and show.

func (*HighlightedWriter) UnSaveCursor

func (hw *HighlightedWriter) UnSaveCursor()

UnSaveCursor restores cursor position after a Save Cursor.

func (*HighlightedWriter) Write

func (hw *HighlightedWriter) Write(data []byte)

Write to write safety byte array by removing control sequences.

func (*HighlightedWriter) WriteRaw

func (hw *HighlightedWriter) WriteRaw(data []byte)

WriteRaw to write raw byte array.

func (*HighlightedWriter) WriteRawStr

func (hw *HighlightedWriter) WriteRawStr(data string)

WriteRawStr to write raw string.

func (*HighlightedWriter) WriteStr

func (hw *HighlightedWriter) WriteStr(data string)

WriteStr to write safety string by removing control sequences.

type ImpliedFact

type ImpliedFact struct {
	// contains filtered or unexported fields
}

ImpliedFact is an ordered fact having an implied definition

func (*ImpliedFact) Append

func (f *ImpliedFact) Append(value interface{}) error

Append an element to the fact

func (*ImpliedFact) Assert

func (f *ImpliedFact) Assert() error

Assert asserts the fact

func (*ImpliedFact) Asserted

func (f *ImpliedFact) Asserted() bool

Asserted returns true if the fact has been asserted.

func (*ImpliedFact) Drop

func (f *ImpliedFact) Drop()

Drop drops the reference to the fact in CLIPS. should be called when done with the fact

func (*ImpliedFact) Equal

func (f *ImpliedFact) Equal(otherfact Fact) bool

Equal returns true if this fact equal the given fact

func (*ImpliedFact) Extend

func (f *ImpliedFact) Extend(values []interface{}) error

Extend Appends the contents of a slice to the fact

func (*ImpliedFact) Extract

func (f *ImpliedFact) Extract(retval interface{}) error

Extract unmarshals this fact into the user provided object

func (*ImpliedFact) ExtractSlot

func (f *ImpliedFact) ExtractSlot(retval interface{}, slotname string) error

ExtractSlot unmarshals the value of the given slot into the user provided object. For Implied Facts, the only valid slot name is ""

func (*ImpliedFact) Index

func (f *ImpliedFact) Index() int

Index returns the index number of this fact within CLIPS

func (*ImpliedFact) Retract

func (f *ImpliedFact) Retract() error

Retract retracts the fact from CLIPS

func (*ImpliedFact) Set

func (f *ImpliedFact) Set(index int, value interface{}) error

Set alters the item at a specific in the multifield

func (*ImpliedFact) Slot

func (f *ImpliedFact) Slot(slotname string) (interface{}, error)

Slot returns the value of the given slot. For Implied Facts, the only valid slot name is ""

func (*ImpliedFact) Slots

func (f *ImpliedFact) Slots() (map[string]interface{}, error)

Slots returns a function that can be called to get the next slot for this fact. Will return nil when no more slots remain

func (*ImpliedFact) String

func (f *ImpliedFact) String() string

String returns a string representation of the fact

func (*ImpliedFact) Template

func (f *ImpliedFact) Template() *Template

Template returns the template defining this fact

type ImpliedFactSlot

type ImpliedFactSlot struct {
	// contains filtered or unexported fields
}

ImpliedFactSlot is a hook to the value of a particular slot

type InsertClassOption

type InsertClassOption string

InsertClassOption tweaks how the inserted class is instructed

const (
	// DoNotRestrictAllowedClasses prevents the class insertion from using an allowed-class constraint for instance-name slots. Primarily useful if [nil] must be allowed
	DoNotRestrictAllowedClasses InsertClassOption = "DoNotRestrictAllowedClasses"
)

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance represents an instance of a class from CLIPS

func (*Instance) Class

func (inst *Instance) Class() *Class

Class returns a reference to the class of this instance

func (*Instance) Delete

func (inst *Instance) Delete() error

Delete unmakes the instance within CLIPS, bypassing message passing

func (*Instance) Drop

func (inst *Instance) Drop()

Drop drops the reference to the instance in CLIPS. should be called when done with the instance

func (*Instance) Equal

func (inst *Instance) Equal(other *Instance) bool

Equal returns true if the other instance represents the same CLIPS inst as this one

func (*Instance) Extract

func (inst *Instance) Extract(retval interface{}) error

Extract attempts to marshall the CLIPS instance data into the user-provided or pointer The return value can be a struct or a map of string to another datatype. If retval points to a valid object, that object will be populated. If it is not, one will be created

func (*Instance) ExtractSlot

func (inst *Instance) ExtractSlot(retval interface{}, name string) error

ExtractSlot obtains the given slot value into the user-provided object

func (*Instance) Name

func (inst *Instance) Name() InstanceName

Name returns the name of this instance

func (*Instance) Send

func (inst *Instance) Send(message string, arguments string) interface{}

Send sends a message tot his instance. Message arguments must be provided as a string

func (*Instance) SetSlot

func (inst *Instance) SetSlot(name string, value interface{}) error

SetSlot sets the slot to the given value. Warning, this function bypasses message-passing

func (*Instance) Slot

func (inst *Instance) Slot(name string) (interface{}, error)

Slot returns the value of the given slot. Warning, this function bypasses message-passing

func (*Instance) Slots

func (inst *Instance) Slots(inherited bool) map[string]interface{}

Slots returns a map of values for each slot by name

func (*Instance) String

func (inst *Instance) String() string

func (*Instance) Unmake

func (inst *Instance) Unmake() error

Unmake unmakes the instance within CLIPS, using message passing

type InstanceName

type InstanceName Symbol

InstanceName represents a CLIPS INSTANCE_NAME value

type LoggingRouter

type LoggingRouter struct {
	// contains filtered or unexported fields
}

LoggingRouter is a router that puts messages into go logging

func CreateLoggingRouter

func CreateLoggingRouter(env *Environment, logger *log.Logger) *LoggingRouter

CreateLoggingRouter returns a new logging router

func (*LoggingRouter) Activate

func (r *LoggingRouter) Activate() error

Activate activates this router with the Env

func (*LoggingRouter) Deactivate

func (r *LoggingRouter) Deactivate() error

Deactivate deactivates this router with the Env

func (*LoggingRouter) Delete

func (r *LoggingRouter) Delete() error

Delete removes this router from the Env

func (*LoggingRouter) Exit

func (r *LoggingRouter) Exit(exitcode int)

Exit is called by CLIPS before CLIPS itself exits

func (*LoggingRouter) Getc

func (r *LoggingRouter) Getc(name string) byte

Getc is called by CLIPS to obtain a character from input

func (*LoggingRouter) Name

func (r *LoggingRouter) Name() string

Name of this router

func (*LoggingRouter) Print

func (r *LoggingRouter) Print(name string, message string)

Print is called with a message if Query has returned true

func (*LoggingRouter) Query

func (r *LoggingRouter) Query(name string) bool

Query should return true if the router handles the given logical IO name

func (*LoggingRouter) Ungetc

func (r *LoggingRouter) Ungetc(name string, ch byte) error

Ungetc is called by CLIPS to push a character back into the input queue

type MessageHandler

type MessageHandler struct {
	// contains filtered or unexported fields
}

MessageHandler is a reference to a messagehandler for a particular class

func (*MessageHandler) Deletable

func (mh *MessageHandler) Deletable() bool

Deletable returns true if this messagehandler can be deleted

func (*MessageHandler) Equal

func (mh *MessageHandler) Equal(other *MessageHandler) bool

Equal returns true if this messagehandler represents the same CLIPS handler as the other one

func (*MessageHandler) Name

func (mh *MessageHandler) Name() string

Name returns the name of this message handler

func (*MessageHandler) String

func (mh *MessageHandler) String() string

func (*MessageHandler) Type

Type returns the messagehandler type

func (*MessageHandler) Undefine

func (mh *MessageHandler) Undefine() error

Undefine undefines the message handler. Equivalent to undefmessage-handler

func (*MessageHandler) Watch

func (mh *MessageHandler) Watch(val bool)

Watch sets whether this messagehandler should be watched

func (*MessageHandler) Watched

func (mh *MessageHandler) Watched() bool

Watched returns true if this messagehandler is being watched

type MessageHandlerType

type MessageHandlerType Symbol
const (
	AROUND  MessageHandlerType = "around"
	BEFORE  MessageHandlerType = "before"
	PRIMARY MessageHandlerType = "primary"
	AFTER   MessageHandlerType = "after"
)

type Method

type Method struct {
	// contains filtered or unexported fields
}

Method represents one method of a CLIPS generic

func (*Method) Deletable

func (m *Method) Deletable() bool

Deletable returns true if this method is unreferenced and deletable

func (*Method) Description

func (m *Method) Description() string

Description returns the description of this method

func (*Method) Equal

func (m *Method) Equal(other *Method) bool

Equal returns true of other represents the same CLIPS method as this

func (*Method) Restrictions

func (m *Method) Restrictions() interface{}

Restrictions returns the method restrictions for this method

func (*Method) String

func (m *Method) String() string

func (*Method) Undefine

func (m *Method) Undefine() error

Undefine undefines the method

func (*Method) Watch

func (m *Method) Watch(val bool)

Watch sets whether this method is watched

func (*Method) Watched

func (m *Method) Watched() bool

Watched returns true if watch is enabled on this method

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module represents a CLIPS module

func (*Module) Equal

func (m *Module) Equal(other *Module) bool

Equal returns true if the other module references the same CLIPS module

func (*Module) Name

func (m *Module) Name() string

Name returns the name of this module

func (*Module) String

func (m *Module) String() string

type NotFoundError

type NotFoundError error

NotFoundError is returned when an item does not exist in CLIPS

type Router

type Router interface {
	// Name returns a name for this router
	Name() string

	// Query should return true if the router handles the given logical IO name
	Query(name string) bool

	// Print is called with a message if Query has returned true
	Print(name string, message string)

	// Getc is called by CLIPS to obtain a character from input
	Getc(name string) byte

	// Ungetc is called by CLIPS to push a character back into the input queue
	Ungetc(name string, ch byte) error

	// Exit is called by CLIPS before CLIPS itself exits
	Exit(exitcode int)

	// Activate activates this router with the Env
	Activate() error

	// Deactivate deactivates this router with the Env
	Deactivate() error

	// Delete removes this router from the Env
	Delete() error
}

Router defines an object responsible for handling IO with CLIPS

type RouterCore

type RouterCore struct {
	// contains filtered or unexported fields
}

RouterCore is an implementation of common Router guts which can be used inside other Router implementations

func CreateRouterCore

func CreateRouterCore(env *Environment, routerimpl Router, name string, handled []string, priority int) *RouterCore

CreateRouterCore creates an instance of the RouterCore which can be used to easily create a full Router

func (*RouterCore) Activate

func (r *RouterCore) Activate() error

Activate activates the router in the Environment

func (*RouterCore) Deactivate

func (r *RouterCore) Deactivate() error

Deactivate deactives the router in the environment

func (*RouterCore) Delete

func (r *RouterCore) Delete() error

Delete deletes the router from the environment

func (*RouterCore) Name

func (r *RouterCore) Name() string

Name returns the name of the router

func (*RouterCore) Print

func (r *RouterCore) Print(name string, message string)

Print outputs message

func (*RouterCore) Query

func (r *RouterCore) Query(name string) bool

Query returns true for handled logical io types

type Rule

type Rule struct {
	// contains filtered or unexported fields
}

Rule represents a rule within CLIPS

func (*Rule) AddBreakpoint

func (r *Rule) AddBreakpoint()

AddBreakpoint adds a breakpoint for the rule

func (*Rule) Deletable

func (r *Rule) Deletable() bool

Deletable returns true if the rule is unreferenced and can be deleted

func (*Rule) Equal

func (r *Rule) Equal(other *Rule) bool

Equal returns true if the other rule represents the same CLIPS rule as this one

func (*Rule) Matches

func (r *Rule) Matches(verbosity Verbosity) ([]interface{}, error)

Matches shows partial matches and activations for the rule. Returns a list containing the combined sum of the matches, the combined sum of partial matches, then the total activations. Verbosity determines how much to output to stdout

func (*Rule) Module

func (r *Rule) Module() *Module

Module returns the module in which the rule is defined

func (*Rule) Name

func (r *Rule) Name() string

Name returns the name of this rule

func (*Rule) Refresh

func (r *Rule) Refresh() error

Refresh refreshes the rule

func (*Rule) RemoveBreakpoint

func (r *Rule) RemoveBreakpoint() error

RemoveBreakpoint removes a breakpoint for the rule

func (*Rule) String

func (r *Rule) String() string

func (*Rule) Undefine

func (r *Rule) Undefine() error

Undefine undefines a rule

func (*Rule) WatchActivations

func (r *Rule) WatchActivations(val bool)

WatchActivations sets whether rule activations should be watched

func (*Rule) WatchFirings

func (r *Rule) WatchFirings(val bool)

WatchFirings sets whether rule firigns are watched

func (*Rule) WatchedActivations

func (r *Rule) WatchedActivations() bool

WatchedActivations returns true if rule activations are being watched

func (*Rule) WatchedFirings

func (r *Rule) WatchedFirings() bool

WatchedFirings returns true if rule firings are being watched

type SalienceEvaluation

type SalienceEvaluation int

SalienceEvaluation is used to specify the salience evaluation behavior

const (
	WHEN_DEFINED SalienceEvaluation = iota
	WHEN_ACTIVATED
	EVERY_CYCLE
)

func (SalienceEvaluation) CVal

func (sm SalienceEvaluation) CVal() C.int

CVal returns the value as appropriate for a C call

func (SalienceEvaluation) String

func (sm SalienceEvaluation) String() string

type SaveMode

type SaveMode C.short

SaveMode is used to specify the type of save when saving objects to a file

const (
	LOCAL_SAVE SaveMode = iota
	VISIBLE_SAVE
)

func (SaveMode) CVal

func (sm SaveMode) CVal() C.int

CVal returns the value as appropriate for a C call

func (SaveMode) String

func (sm SaveMode) String() string

type ShellContext

type ShellContext struct {
	// contains filtered or unexported fields
}

ShellContext stores the context of the shell environment

type Strategy

type Strategy int

Strategy is used to specify the conflict resolution strategy

const (
	DEPTH Strategy = iota
	BREADTH
	LEX
	MEA
	COMPLEXITY
	RANDOM
)

func (Strategy) CVal

func (sm Strategy) CVal() C.int

CVal returns the value as appropriate for a C call

func (Strategy) String

func (sm Strategy) String() string

type Symbol

type Symbol string

Symbol represents a CLIPS SYMBOL value

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template is a formal representation of the fact data structure, defined by deftemplate in CLIPS

func (*Template) Deletable

func (t *Template) Deletable() bool

Deletable returns true if the Template can be deleted from CLIPS

func (*Template) Equal

func (t *Template) Equal(other *Template) bool

Equal returns true if this template represents the same template as the given one

func (*Template) Implied

func (t *Template) Implied() bool

Implied returns whether the template is implied

func (*Template) Module

func (t *Template) Module() *Module

Module returns the module in which the template is defined. Equivalent to (deftempalte-module)

func (*Template) Name

func (t *Template) Name() string

Name returns the name of this template

func (*Template) NewFact

func (t *Template) NewFact() (Fact, error)

NewFact creates a new fact from this template

func (*Template) Slots

func (t *Template) Slots() map[string]*TemplateSlot

Slots returns the slot definitions contained in this template

func (*Template) String

func (t *Template) String() string

String returns a string representation of the template

func (*Template) Undefine

func (t *Template) Undefine() error

Undefine the template. Equivalent to (undeftemplate). This object is unusable after this call

func (*Template) Watch

func (t *Template) Watch(val bool)

Watch sets whether or not the template should be watched

func (*Template) Watched

func (t *Template) Watched() bool

Watched returns whether or not the template is being watched

type TemplateFact

type TemplateFact struct {
	// contains filtered or unexported fields
}

TemplateFact is an unordered fact

func (*TemplateFact) Assert

func (f *TemplateFact) Assert() error

Assert asserts the fact

func (*TemplateFact) Asserted

func (f *TemplateFact) Asserted() bool

Asserted returns true if the fact has been asserted.

func (*TemplateFact) Drop

func (f *TemplateFact) Drop()

Drop drops the reference to the fact in CLIPS. should be called when done with the fact

func (*TemplateFact) Equal

func (f *TemplateFact) Equal(otherfact Fact) bool

Equal returns true if this fact equal the given fact

func (*TemplateFact) Extract

func (f *TemplateFact) Extract(retval interface{}) error

Extract unmarshals this fact into the user provided object

func (*TemplateFact) ExtractSlot

func (f *TemplateFact) ExtractSlot(retval interface{}, name string) error

ExtractSlot unmarshals the given slot value into the object provided by the user

func (*TemplateFact) Index

func (f *TemplateFact) Index() int

Index returns the index number of this fact within CLIPS

func (*TemplateFact) Retract

func (f *TemplateFact) Retract() error

Retract retracts the fact from CLIPS

func (*TemplateFact) Set

func (f *TemplateFact) Set(slot string, value interface{}) error

Set alters the item at a specific in the multifield

func (*TemplateFact) Slot

func (f *TemplateFact) Slot(name string) (interface{}, error)

Slot returns the value stored in the given slot

func (*TemplateFact) Slots

func (f *TemplateFact) Slots() (map[string]interface{}, error)

Slots returns a function that can be called to get the next slot for this fact. Will return nil when no more slots remain

func (*TemplateFact) String

func (f *TemplateFact) String() string

String returns a string representation of the fact

func (*TemplateFact) Template

func (f *TemplateFact) Template() *Template

Template returns the template defining this fact

type TemplateSlot

type TemplateSlot struct {
	// contains filtered or unexported fields
}

TemplateSlot defines one slot within a template

func (*TemplateSlot) AllowedValues

func (ts *TemplateSlot) AllowedValues() (values []interface{}, ok bool)

AllowedValues returns the set of allowed values for this slot, if specified

func (*TemplateSlot) Cardinality

func (ts *TemplateSlot) Cardinality() (low int64, high int64, hasHigh bool)

Cardinality returns the cardinality for the slot

func (*TemplateSlot) DefaultType

func (ts *TemplateSlot) DefaultType() TemplateSlotDefaultType

DefaultType returns the type of default value for this slot

func (*TemplateSlot) DefaultValue

func (ts *TemplateSlot) DefaultValue() interface{}

DefaultValue returns a default value for the slot. (This might be a new, unique value for DYNAMIC_DEFAULT defaults)

func (*TemplateSlot) Equal

func (ts *TemplateSlot) Equal(other *TemplateSlot) bool

Equal checks if the other templateslot represents the same slot

func (*TemplateSlot) FloatRange

func (ts *TemplateSlot) FloatRange() (low float64, hasLow bool, high float64, hasHigh bool)

FloatRange returns the numeric range for the slot for floating point values - e.g. low, haslow, high, hashigh := ts.Range()

func (*TemplateSlot) IntRange

func (ts *TemplateSlot) IntRange() (low int64, hasLow bool, high int64, hasHigh bool)

IntRange returns the numeric range for the slot for integer values - e.g. low, haslow, high, hashigh := ts.Range()

func (*TemplateSlot) Multifield

func (ts *TemplateSlot) Multifield() bool

Multifield returns true if the slot is a multifield slot

func (*TemplateSlot) Name

func (ts *TemplateSlot) Name() string

Name returns the name of this slot

func (*TemplateSlot) String

func (ts *TemplateSlot) String() string

func (*TemplateSlot) Types

func (ts *TemplateSlot) Types() []Symbol

Types returns the set of value types for this slot

type TemplateSlotDefaultType

type TemplateSlotDefaultType int

TemplateSlotDefaultType is used to specify how default is specifified for a slot within a template

const (
	NO_DEFAULT TemplateSlotDefaultType = iota
	STATIC_DEFAULT
	DYNAMIC_DEFAULT
)

func (TemplateSlotDefaultType) CVal

func (tsdt TemplateSlotDefaultType) CVal() C.int

CVal returns the value as appropriate for a C call

func (TemplateSlotDefaultType) String

func (tsdt TemplateSlotDefaultType) String() string

type Type

type Type C.int

Type is an enumeration CLIPS uses to describe data types

const (
	FLOAT Type = iota
	INTEGER
	SYMBOL
	STRING
	MULTIFIELD
	EXTERNAL_ADDRESS
	FACT_ADDRESS
	INSTANCE_ADDRESS
	INSTANCE_NAME
)

func (Type) CVal

func (typ Type) CVal() C.int

CVal returns the value as appropriate for a C call

func (Type) String

func (typ Type) String() string

type Verbosity

type Verbosity int

Verbosity controls how much is output to stdout for rule matches

const (
	VERBOSE Verbosity = iota
	SUCCINCT
	TERSE
)

func (Verbosity) CVal

func (sm Verbosity) CVal() C.int

CVal returns the value as appropriate for a C call

func (Verbosity) String

func (sm Verbosity) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL