interpreter

package
v0.0.0-...-de9fdfd Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownNode         = fmt.Errorf("Unknown node")
	ErrImmutableVariable   = fmt.Errorf("Variable is immutable")
	ErrExpression          = fmt.Errorf("Expression error")
	ErrImportError         = fmt.Errorf("Import error")
	ErrUndefinedVariable   = fmt.Errorf("Undefined variable")
	ErrUnsupported         = fmt.Errorf("Unsupported operation")
	ErrUndefinedFunction   = fmt.Errorf("Undefined function")
	ErrExpectedFunction    = fmt.Errorf("Expected function")
	ErrTypeMismatch        = fmt.Errorf("Type mismatch")
	ErrAst                 = fmt.Errorf("Ast error")
	ErrValueError          = fmt.Errorf("Value error")
	ErrInvalid             = fmt.Errorf("Invalid syntax")
	ErrInvalidImpl         = fmt.Errorf("Invalid implementation")
	ErrPrototype           = fmt.Errorf("Prototype error")
	ErrStructInstantiation = fmt.Errorf("Failed to instantiate a struct")
	ErrVoidAsValue         = fmt.Errorf("Cannot use void as value")
)

Functions

This section is empty.

Types

type ComplexVariable

type ComplexVariable struct {
	// Scope is the scope of the variable.
	Scope interface {
		GetObject(name string) (language.Object, bool)
		BindObject(name string, value language.Object, mutable bool) error
	}

	// Object is the object that the variable represents.
	Object language.Object
}

ComplexVariable represents a variable that is outside of the current interpreter. (For example: otherFile.otherVariable)

type Interpreter

type Interpreter struct {
	ID uint
	// contains filtered or unexported fields
}

func New

func New(currentFile string, runtime Runtime, dependent bool, wd string) *Interpreter

func NewWithParent

func NewWithParent(parent *Interpreter, scope Scope, name ...string) *Interpreter

func (*Interpreter) Assign

func (i *Interpreter) Assign(name string, value language.Object) error

func (*Interpreter) Declare

func (i *Interpreter) Declare(name string, value language.Object, typ *language.Type, mutable bool) error

func (*Interpreter) Detach

func (i *Interpreter) Detach()

func (*Interpreter) GetObject

func (i *Interpreter) GetObject(name string) (language.Object, bool)

func (*Interpreter) MustDetach

func (i *Interpreter) MustDetach()

func (*Interpreter) Run

func (i *Interpreter) Run(nodes []*astnode.Node) (language.Object, error)

type Iterator

type Iterator interface {
	// Iterator is an interface that returns a Next function which
	// returns a key, value, and ok (if ok is false, both key and value are nil and the cycle ends)
	Iterator() func() (language.Object, language.Object, bool)
}

type Runtime

type Runtime interface {
	GetBuiltin(name string) (language.Object, bool)
	GetEventProvider() events.Provider
	NewID() uint
	RemoveInterpreter(id uint)
	ImportPackage(name string, dg *debug.Debug) (language.Object, bool)
	GetPacker() (*packer.Packer, error)
	FindInterpreter(file string) (*Interpreter, bool)
	AddInterpreter(file string, interpreter *Interpreter)
}

type Scope

type Scope int
const (
	ScopeGlobal Scope = iota
	ScopeFunction
	ScopeBlock
)

Jump to

Keyboard shortcuts

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