framework

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package framework implements the abstract framework used by the concrete implementations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ValidFrameworks lists the valid options for choosing frameworks on the command line and in the
	// interactive case. Make sure "all" is the first entry as we use [1:] to get the rest.
	ValidFrameworks = []string{"all", "ccm", "pyactr", "vanilla"}

	// GactarVersion stores the current build version. It is a var so we can replace it in testing.
	GactarVersion = version.BuildVersion

	// TimeNow stores the time.Now function so we can replace it in testing.
	TimeNow = time.Now
)
View Source
var (
	ErrModelMissingName = errors.New("model missing name")
)

Functions

func GenerateCodeFromFile added in v0.8.0

func GenerateCodeFromFile(fw Framework, inputFile string, initialBuffers InitialBuffers) (code []byte, err error)

Reads a file, generates a model, validates it, and generates code from it for a given framework. This is useful for testing.

func IsValidFramework

func IsValidFramework(frameworkName string) bool

IsValidFramework returns if the framework name is in our list of valid ones or not.

func Setup added in v0.5.0

func Setup(info *Info) (err error)

Setup will check that the executable exists and then use it to identify itself.

func ValidNamedFrameworks added in v0.5.0

func ValidNamedFrameworks() []string

ValidNamedFrameworks returns the list of all valid framework names without "all".

func WriteSupportFile added in v0.12.0

func WriteSupportFile(path, supportFileName, contents string) (err error)

WriteSupportFile will write out a file to add extra support for a framework.

Types

type ErrBufferNotFound added in v0.9.0

type ErrBufferNotFound struct {
	BufferName string
	ModelName  string
}

func (ErrBufferNotFound) Error added in v0.9.0

func (e ErrBufferNotFound) Error() string

type ErrExecutableNotSet added in v0.9.0

type ErrExecutableNotSet struct {
	Name string
}

func (ErrExecutableNotSet) Error added in v0.9.0

func (e ErrExecutableNotSet) Error() string

type ErrModelGenerationFailed added in v0.9.0

type ErrModelGenerationFailed struct {
	Log *issues.Log
}

func (ErrModelGenerationFailed) Error added in v0.9.0

func (e ErrModelGenerationFailed) Error() string

type ErrModelValidationFailed added in v0.9.0

type ErrModelValidationFailed struct {
	Log *issues.Log
}

func (ErrModelValidationFailed) Error added in v0.9.0

func (e ErrModelValidationFailed) Error() string

type Framework

type Framework interface {
	Info() *Info

	ValidateModel(model *actr.Model) (log *issues.Log)
	SetModel(model *actr.Model) (err error)
	Model() (model *actr.Model)

	Run(initialBuffers InitialBuffers) (result *RunResult, err error)
	WriteModel(path string, initialBuffers InitialBuffers) (outputFileName string, err error)
	GenerateCode(initialBuffers InitialBuffers) (code []byte, err error)
}

type Info added in v0.5.0

type Info struct {
	Name     string `json:"name"`     // name of the framework
	Language string `json:"language"` // language the framework uses

	FileExtension string `json:"fileExtension"` // file extension of the intermediate file

	ExecutableName string `json:"executableName"` // name of the executable to run

	PythonRequiredPackages []string `json:"pythonRequiredPackages,omitempty"` // (Python only) List of packages this framework requires
}

Info provides basic info to set up a framework.

type InfoList added in v0.5.0

type InfoList = []Info

type InitialBuffers added in v0.2.0

type InitialBuffers map[string]string

InitialBuffers is a map of buffer names to initial contents of the buffer. This is used when passing in user-defined initial contents e.g. through a web API.

type KeyValueList

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

KeyValueList is used to format output nicely with tabs using tabwriter.

func (*KeyValueList) Add

func (l *KeyValueList) Add(key, value string)

type List

type List map[string]Framework

func (List) Exists

func (l List) Exists(framework string) bool

Exists checks if the framework is in the list.

func (List) Names

func (l List) Names() (names []string)

Names returns all the names of the frameworks in the list.

type ParsedInitialBuffers added in v0.2.0

type ParsedInitialBuffers map[string]*actr.Pattern

ParsedInitialBuffers is a map of buffer name to a parsed version of the initial contents. This is used when passing in user-defined initial contents e.g. through a web API.

func ParseInitialBuffers added in v0.2.0

func ParseInitialBuffers(model *actr.Model, initialBuffers InitialBuffers) (parsed ParsedInitialBuffers, err error)

type RunResult added in v0.5.0

type RunResult struct {
	FileName      string // full path to the intermediate file
	GeneratedCode []byte // code which was run
	Output        []byte // resulting output (stdout + stderr)
}

RunResult is the result of a Run() call which runs the code using the framework's executable.

type WriterHelper

type WriterHelper struct {
	Contents  *bytes.Buffer
	TabWriter *tabwriter.Writer
	// contains filtered or unexported fields
}

func (WriterHelper) GetContents

func (w WriterHelper) GetContents() []byte

func (*WriterHelper) InitWriterHelper

func (w *WriterHelper) InitWriterHelper() (err error)

func (*WriterHelper) ResetLineLen added in v0.10.0

func (w *WriterHelper) ResetLineLen()

ResetLineLen will reset the line length capability.

func (*WriterHelper) SetLineLen added in v0.10.0

func (w *WriterHelper) SetLineLen(lineLength int)

SetLineLen will cause newlines to be inserted at the line length. Note that this can be problematic for some things like comments or strings, so be careful how you use it.

func (WriterHelper) TabWrite

func (w WriterHelper) TabWrite(level int, list KeyValueList)

func (*WriterHelper) Write

func (w *WriterHelper) Write(e string, a ...interface{})

func (*WriterHelper) WriteFile added in v0.8.0

func (w *WriterHelper) WriteFile(outputFileName string) (err error)

func (WriterHelper) Writeln

func (w WriterHelper) Writeln(e string, a ...interface{})

Directories

Path Synopsis
Package ccm_pyactr provides functions to output the internal actr data structures in Python suitable for running using CCM's python_actr package, and to run those models using Python.
Package ccm_pyactr provides functions to output the internal actr data structures in Python suitable for running using CCM's python_actr package, and to run those models using Python.
Package pyactr provides functions to output the internal actr data structures in Python suitable for running using the pyactr package, and to run those models using Python.
Package pyactr provides functions to output the internal actr data structures in Python suitable for running using the pyactr package, and to run those models using Python.
Package vanilla_actr provides functions to output the internal actr data structures in Lisp suitable for running using the ACT-R code, and to run those models on the Clozure Common Lisp compiler.
Package vanilla_actr provides functions to output the internal actr data structures in Lisp suitable for running using the ACT-R code, and to run those models on the Clozure Common Lisp compiler.

Jump to

Keyboard shortcuts

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