builtin

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncsInit deprecated

func FuncsInit(out io.Writer)

Deprecated: Use builtin.SystemInit instead. builtin.SystemInit provides greater portability.

func GetConstant added in v1.1.0

func GetConstant(name string) (val interface{}, found bool)

Get constant by name from the builtin constant map.

func HasConstant added in v1.1.0

func HasConstant(name string) bool

Is constant with name presented in the builtin constant map.

func HasFunction added in v1.1.0

func HasFunction(name string) bool

Is function with name presented in the builtin function map.

func ListConstants added in v1.1.0

func ListConstants() map[string]interface{}

Return the builtin constant map.

func Predict added in v1.4.0

func Predict(word string) string

func RegisterConstant added in v1.2.2

func RegisterConstant[T string | bool | uint64 | int64 | float64](name string, value T)

Register a new constant and add it to the builtin constant map.

func RegisterFunction added in v1.2.2

func RegisterFunction(name string, function Func)

Register a new function and add it to the builtin function map.

func SystemInit added in v1.4.0

func SystemInit(sys System)

Provide your own system description.

Use this function to implement native integration into your application.

Types

type Environment added in v1.4.0

type Environment struct {
	Description string
	UserVars    map[string]interface{}
	UserFuncs   map[string]user.Func
}

type Func

type Func struct {
	// Arguments description.
	Args string
	// Function description.
	Desc string
	// Function that will be executed.
	Exec func(args ...interface{}) (interface{}, error)
}

func GetFunction added in v1.1.0

func GetFunction(name string) (function Func, found bool)

Get function by name from the builtin function map.

type FuncMap

type FuncMap map[string]Func

func ListFunctions added in v1.1.0

func ListFunctions() FuncMap

Return the builtin function map.

type System added in v1.4.0

type System struct {
	// Is syntax highlighting enabled for built-in functions output.
	HighlightEnabled bool

	// Writer for additional output.
	Stdout io.Writer
	// Callback that should clears screen.
	ClearScreen func()

	// Random seed that sets on SystemInit.
	RandomSeed int64

	// Callback that should return list of available environment file names.
	ListEnvironments func() ([]string, error)
	// Callback that should open environment file with provided name for write and return it as io.WriteCloser.
	WriteEnvironment func(name string) (io.WriteCloser, error)
	// Callback that should open environment file with provided name for read and return it as io.ReadCloser.
	ReadEnvironment func(name string) (io.ReadCloser, error)

	// Callback that should terminate the program and perform any necessary cleanup.
	Exit func(errCode int)
}

Jump to

Keyboard shortcuts

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