Documentation ¶
Overview ¶
Package actr implements our internal, parsed version of the amod file which is passed to a Framework to generate their code.
Index ¶
- Variables
- func IsInternalChunkName(name string) bool
- func ValidLogLevel(e string) bool
- type ACTRLogLevel
- type Chunk
- type ClearStatement
- type Comparison
- type Constraint
- type Initializer
- type Match
- type Model
- func (model Model) BufferNames() (list []string)
- func (model *Model) CreateExtraBuffers() *modules.ExtraBuffers
- func (model *Model) CreateImaginal() *modules.Imaginal
- func (model Model) HasPrintStatement() bool
- func (model Model) ImaginalModule() *modules.Imaginal
- func (model *Model) Initialize()
- func (model Model) LookupBuffer(bufferName string) buffer.BufferInterface
- func (model Model) LookupChunk(chunkName string) *Chunk
- func (model Model) LookupInitializer(buffer string) *Initializer
- func (model Model) LookupModule(moduleName string) modules.ModuleInterface
- func (model *Model) SetParam(param *params.Param) (err error)
- type Pattern
- type PatternSlot
- type PatternVar
- type PrintStatement
- type Production
- type RecallStatement
- type SetSlot
- type SetStatement
- type Statement
- type StopStatement
- type Value
- type VarIndex
Constants ¶
This section is empty.
Variables ¶
var ACTRLoggingLevels = []string{
"min",
"info",
"detail",
}
Functions ¶
func IsInternalChunkName ¶
func ValidLogLevel ¶
Types ¶
type ACTRLogLevel ¶
type ACTRLogLevel string
type Chunk ¶
type Chunk struct { Name string SlotNames []string NumSlots int AMODLineNumber int // line number in the amod file of the this chunk declaration }
func (Chunk) IsInternal ¶
type ClearStatement ¶
type ClearStatement struct {
BufferNames []string
}
ClearStatement clears a list of buffers.
type Comparison ¶ added in v0.8.0
type Comparison int
const ( Equal Comparison = iota NotEqual )
func (Comparison) String ¶ added in v0.8.0
func (c Comparison) String() string
type Constraint ¶ added in v0.8.0
type Constraint struct { LHS *string Comparison Comparison RHS *Value }
func (Constraint) String ¶ added in v0.8.0
func (c Constraint) String() string
type Initializer ¶
type Initializer struct { Module modules.ModuleInterface Buffer buffer.BufferInterface Pattern *Pattern AMODLineNumber int // line number in the amod file of this initialization }
type Match ¶
type Match struct { Buffer buffer.BufferInterface Pattern *Pattern }
type Model ¶
type Model struct { Name string Description string Authors []string Examples []*Pattern Modules []modules.ModuleInterface Memory *modules.DeclarativeMemory // memory is always present Goal *modules.Goal // goal is always present Procedural *modules.Procedural // procedural is always present Chunks []*Chunk Initializers []*Initializer Productions []*Production // contains filtered or unexported fields }
Model represents a basic ACT-R model. This is used as input to a Framework where it can be run or output to a file. (This is incomplete w.r.t. all of ACT-R's capabilities.)
func (Model) BufferNames ¶ added in v0.6.0
BufferNames returns a slice of valid buffers.
func (*Model) CreateExtraBuffers ¶ added in v0.9.0
func (model *Model) CreateExtraBuffers() *modules.ExtraBuffers
CreateExtraBuffers creates the "extra_buffers" module and adds it to the list.
func (*Model) CreateImaginal ¶
CreateImaginal creates the imaginal module and adds it to the list.
func (Model) HasPrintStatement ¶
HasPrintStatement checks if this model uses the print statement. This is used to include extra code to handle printing in some frameworks.
func (Model) ImaginalModule ¶ added in v0.7.0
ImaginalModule gets the imaginal module (or returns nil if it does not exist).
func (*Model) Initialize ¶
func (model *Model) Initialize()
func (Model) LookupBuffer ¶
func (model Model) LookupBuffer(bufferName string) buffer.BufferInterface
LookupBuffer looks up the named buffer in the model and returns it (or nil if it does not exist).
func (Model) LookupChunk ¶
LookupChunk looks up the named chunk in the model and returns it (or nil if it does not exist).
func (Model) LookupInitializer ¶ added in v0.6.0
func (model Model) LookupInitializer(buffer string) *Initializer
LookupInitializer returns an initializer or nil if the buffer does not have one.
func (Model) LookupModule ¶ added in v0.2.0
func (model Model) LookupModule(moduleName string) modules.ModuleInterface
LookupModule looks up the named module in the model and returns it (or nil if it does not exist).
type Pattern ¶
type Pattern struct { Chunk *Chunk Slots []*PatternSlot }
func (*Pattern) AddSlot ¶
func (p *Pattern) AddSlot(slot *PatternSlot)
func (Pattern) LookupVariable ¶
func (p Pattern) LookupVariable(varName string) *PatternVar
type PatternSlot ¶
type PatternSlot struct { // The item is one of the following: Nil bool Wildcard bool ID *string Var *PatternVar Num *string // we don't need to treat this as a number anywhere, so keep as a string Negated bool // this item is negated }
func (PatternSlot) String ¶
func (p PatternSlot) String() (str string)
type PatternVar ¶ added in v0.8.0
type PatternVar struct { Name *string Constraints []*Constraint // any constraints on this var }
type PrintStatement ¶
type PrintStatement struct {
Values *[]*Value
}
PrintStatement outputs the string, id, or number to stdout.
type Production ¶
type Production struct { Name string Description *string // optional description to output as a comment in the generated code VarIndexMap map[string]VarIndex // track the buffer and slot name each variable refers to Matches []*Match DoStatements []*Statement AMODLineNumber int // line number in the amod file of the this production }
Production stores information on how to match buffers and perform some operations. It uses a small language to modify states upon successful matches.
func (Production) LookupMatchByBuffer ¶
func (p Production) LookupMatchByBuffer(bufferName string) *Match
func (Production) LookupMatchByVariable ¶
func (p Production) LookupMatchByVariable(varName string) *Match
LookupMatchByVariable checks all matches for a variable by name. This is pretty inefficient, but given the small number of matches in a production, it's probably not worth doing anything more complicated. We could store all the vars used in all the matches on the Match itself and look it up there.
func (Production) LookupSetStatementByBuffer ¶
func (p Production) LookupSetStatementByBuffer(bufferName string) *SetStatement
LookupSetStatementByBuffer is used when combining several set consecutive statements on one buffer. So this:
set goal.foo to 1 set goal.bar to 10
is treated like this:
set foo, bar on goal to 1, 10
type RecallStatement ¶
RecallStatement is used to pull information from memory.
type SetStatement ¶
type SetStatement struct { Slots *[]SetSlot // (1) set this slot (optional) Chunk *Chunk // (1) if we are setting slots, point at the chunk they reference for easy lookup Buffer buffer.BufferInterface // (1 & 2) buffer we are manipulating Pattern *Pattern // (2) pattern if we are setting the whole buffer }
SetStatement will set a slot or the entire contents of the named buffer to a string or a pattern. There are two forms:
(1) set (SetSlot) of (Buffer) to (SetValue) (2) set (Buffer) to (Pattern)
func (*SetStatement) AddSlot ¶
func (s *SetStatement) AddSlot(slot *SetSlot)
type Statement ¶
type Statement struct { Clear *ClearStatement Print *PrintStatement Recall *RecallStatement Set *SetStatement Stop *StopStatement }
type StopStatement ¶ added in v0.8.0
type StopStatement struct { }
StopStatement outputs a stop command. There are no parameters.
type Value ¶
type Value struct { Nil *bool // set this to nil Var *string ID *string Str *string Number *string }
Value holds something that may be printed.
type VarIndex ¶ added in v0.2.0
type VarIndex struct { Var *PatternVar Buffer buffer.BufferInterface SlotName string }
VarIndex is used to track which buffer slot a variable refers to