interpreter

package
v11.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegistryNames = func() []string {
	names := make([]string, 0, registry.Len())

	for name := registry.Oldest(); name != nil; name = name.Next() {
		names = append(names, name.Key)
	}
	return names
}()

RegistryNames is the list of the predicate names in the Registry.

Functions

func IsRegistered

func IsRegistered(name string) bool

IsRegistered returns true if the predicate with the given name is registered in the interpreter. Registered predicates are built-in predicates that are available in the interpreter.

func New

func New(
	opts ...Option,
) (*prolog.Interpreter, error)

New creates a new prolog.Interpreter with the specified options.

func Register

func Register(i *prolog.Interpreter, name string) error

Register registers a well-known predicate in the interpreter.

Types

type Option

type Option func(*prolog.Interpreter) error

Option is a function that configures an Interpreter.

func WithBootstrap

func WithBootstrap(ctx goctx.Context, bootstrap string) Option

WithBootstrap configures the interpreter to compile the specified bootstrap script to serve as setup context. If compilation of the bootstrap script fails, the function will return an error.

func WithFS

func WithFS(fs fs.FS) Option

WithFS configures the interpreter to use the specified file system.

func WithHooks

func WithHooks(hooks ...engine.HookFunc) Option

WithHooks configures the interpreter to use the specified hooks.

func WithMaxVariables

func WithMaxVariables(maxVariables uint64) Option

WithMaxVariables configures the interpreter to use the specified maximum number of variables.

func WithPredicate

func WithPredicate(_ goctx.Context, predicate string) Option

WithPredicate configures the interpreter to register the specified predicate.

The predicates names must be present in the registry, otherwise the function will return an error.

func WithPredicates

func WithPredicates(ctx goctx.Context, predicates []string) Option

WithPredicates configures the interpreter to register the specified predicates. See WithPredicate for more details.

func WithUserOutputWriter

func WithUserOutputWriter(w io.Writer) Option

WithUserOutputWriter configures the interpreter to use the specified writer for user output.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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