Documentation
¶
Index ¶
- Constants
- Variables
- func Error(err error, debug *models.Debug, customText ...any) error
- type Executer
- func (e *Executer) AssignVariable(name string, object lang.Object) error
- func (e *Executer) BindMethod(name string, fn lang.Method)
- func (e *Executer) BindObject(name string, object lang.Object)
- func (e *Executer) Copy() lang.Executer
- func (e *Executer) Execute(nodes []*models.Node) (lang.Object, error)
- func (e *Executer) GetMethod(name string) (lang.Method, error)
- func (e *Executer) GetNamespaceExecuter(namespace string) (*Executer, error)
- func (e *Executer) GetNew() lang.Executer
- func (e *Executer) GetVariable(name string) (lang.Object, error)
- func (e *Executer) LoadFile(path string) error
- func (e *Executer) Variables() []string
- func (e *Executer) WithName(name string) *Executer
- type ExecuterScope
- type Namespace
- type Runtime
- func (r *Runtime) BindModule(module lang.Module)
- func (r *Runtime) Exec(scope ExecuterScope, parent *Executer, namespace string, nodes []*models.Node) (lang.Object, error)
- func (r *Runtime) Execute(nodes []*models.Node) (lang.Object, error)
- func (r *Runtime) GetNamespace(nodes []*models.Node) (string, []*models.Node, error)
- func (r *Runtime) GetNamespaceExecuter(namespace string) (*Executer, error)
- func (r *Runtime) LoadSourceNamespaces() error
- func (r *Runtime) UseModule(module lang.Module) *Executer
Constants ¶
View Source
const PackageDirectory = ".flmod"
Variables ¶
View Source
var ( ErrInvalidValue = fmt.Errorf("invalid value") ErrVariableRedeclared = fmt.Errorf("variable already declared") ErrVariableNotDeclared = fmt.Errorf("variable not declared") ErrConstantReassignment = fmt.Errorf("cannot reassign constant") ErrVariableNotFound = fmt.Errorf("variable not found") ErrFunctionRedeclared = fmt.Errorf("function already declared") ErrNamespaceInUse = fmt.Errorf("namespace already in use") ErrNamespaceNotFound = fmt.Errorf("namespace not found") ErrFunctionNotFound = fmt.Errorf("function not found") ErrInvalidArguments = fmt.Errorf("invalid arguments") ErrIndexOutOfBounds = fmt.Errorf("index out of bounds") ErrDefinitionReassignment = fmt.Errorf("cannot reassign this definition") ErrThisOutsideMethod = fmt.Errorf("'this' cannot be used outside of a method") ErrUnhandledNodeType = fmt.Errorf("unhandled node type") ErrInvalidIncrementTarget = fmt.Errorf("cannot increment this value") ErrEmptyErrorBlock = fmt.Errorf("error block has no child nodes") ErrNamedInlineFunction = fmt.Errorf("inline function cannot have a name") ErrExpectedExpression = fmt.Errorf("expected expression") ErrExpectedBoolean = fmt.Errorf("%w: expected boolean", ErrInvalidValue) ErrExpectedIterable = fmt.Errorf("%w: expected an iterable value (e.g. array, list, or string)", ErrInvalidValue) ErrInvalidIndexAccess = fmt.Errorf("%w: cannot access value: invalid index or not indexable", ErrInvalidValue) ErrKeyNotFound = fmt.Errorf("key not found in array") ErrInvalidObject = fmt.Errorf("invalid object") ErrInvalidObjectAccess = fmt.Errorf("invalid object member access") )
Functions ¶
Types ¶
type Executer ¶
type Executer struct {
// contains filtered or unexported fields
}
Executer represents a node executer in the runtime
func NewExecuter ¶
func NewExecuter(scope ExecuterScope, r *Runtime, parent *Executer) *Executer
NewExecuter creates a new runtime executer
func (*Executer) AssignVariable ¶
func (*Executer) BindMethod ¶
BindMethod binds a method to the executer
func (*Executer) BindObject ¶
BindObject binds an object to the executer
func (*Executer) GetNamespaceExecuter ¶
func (*Executer) GetVariable ¶
GetVariable gets a variable by name
type ExecuterScope ¶
type ExecuterScope int
ExecuterScope is the scope of the executer
const ( // ExecuterScopeGlobal is the global scope ExecuterScopeGlobal ExecuterScope = iota // ExecuterScopeBlock is the block scope (if, else, for, etc.) ExecuterScopeBlock // ExecuterScopeFunction is the function scope ExecuterScopeFunction // ExecuterScopeDefinition is the definition scope ExecuterScopeDefinition )
func (ExecuterScope) String ¶
func (e ExecuterScope) String() string
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
RuntimeMode is the runtime mode
func (*Runtime) BindModule ¶
BindModule binds the given module to the runtime
func (*Runtime) Exec ¶
func (r *Runtime) Exec(scope ExecuterScope, parent *Executer, namespace string, nodes []*models.Node) (lang.Object, error)
Exec executes the given nodes in the given namespace
func (*Runtime) GetNamespace ¶
func (*Runtime) GetNamespaceExecuter ¶
GetNamespaceExecuter gets the executer for the given namespace
func (*Runtime) LoadSourceNamespaces ¶
Click to show internal directories.
Click to hide internal directories.