interpreter

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRootScopeName = "global"

DefaultRootScopeName is the default name of a root variable scope

Variables

View Source
var (
	ErrIsIterator        = errors.New("Function is an iterator")
	ErrEndOfIteration    = errors.New("End of iteration was reached")
	ErrContinueIteration = errors.New("End of iteration step - Continue iteration")
)

Runtime related error types - these errors are specific errors of Rumble where the code might check for object equality

Functions

func AssertListParam

func AssertListParam(val interface{}, astNode *parser.ASTNode,
	rrp *RumbleRuntimeProvider) ([]interface{}, error)

AssertListParam converts a general interface{} parameter into a list.

func AssertMapParam

func AssertMapParam(val interface{}, astNode *parser.ASTNode,
	rrp *RumbleRuntimeProvider) (map[interface{}]interface{}, error)

AssertMapParam converts a general interface{} parameter into a map.

func AssertNumParam

func AssertNumParam(val interface{}, astNode *parser.ASTNode,
	rrp *RumbleRuntimeProvider) (float64, error)

AssertNumParam converts a general interface{} parameter into a number.

func GetFuncParams

func GetFuncParams(astNode *parser.ASTNode, vs parser.VarsScope, is map[string]interface{}) ([]interface{}, error)

GetFuncParams interprets and returns the value of all parameters of a function.

func NewRootVariableScope

func NewRootVariableScope(name string) parser.VarsScope

NewRootVariableScope creates a new root variable scope.

func NewSinkVariableScope

func NewSinkVariableScope(name string, parent parser.VarsScope) parser.VarsScope

NewSinkVariableScope creates a new variable scope for a sink which knows its child scopes.

func RegisterRumbleFunc

func RegisterRumbleFunc(name string, valFunc RumbleFuncValidate, actFunc RumbleFunc) error

RegisterRumbleFunc registers a new Rumble function.

func RumbleFuncs

func RumbleFuncs() []string

RumbleFuncs returns a list of available rumble functions.

func ScopeName

func ScopeName(node *parser.ASTNode) string

ScopeName returns a scope name from a given ASTNode.

Types

type RumbleFunc

type RumbleFunc func(string, *parser.ASTNode, parser.VarsScope, map[string]interface{},
	*RumbleRuntimeProvider) (interface{}, error)

RumbleFunc represents a rumble function.

type RumbleFuncValidate

type RumbleFuncValidate func(*parser.ASTNode, *RumbleRuntimeProvider) error

RumbleFuncValidate is called to validate the number of arguments, check the environment and to execute any initialisation code which might be necessary for the function.

type RumbleRuntimeProvider

type RumbleRuntimeProvider struct {
	Name string // Name to identify the input
	// contains filtered or unexported fields
}

RumbleRuntimeProvider defines the main interpreter datastructure and all functions for general evaluation.

func NewRumbleRuntimeProvider

func NewRumbleRuntimeProvider(name string) *RumbleRuntimeProvider

NewRumbleRuntimeProvider returns a new instance of a Rumble runtime provider.

func (*RumbleRuntimeProvider) NewRuntimeError

func (rt *RumbleRuntimeProvider) NewRuntimeError(t error, d string, node *parser.ASTNode) error

NewRuntimeError creates a new RuntimeError object.

func (*RumbleRuntimeProvider) Runtime

func (rrp *RumbleRuntimeProvider) Runtime(node *parser.ASTNode) parser.Runtime

Runtime returns a runtime component for a given ASTNode.

type RuntimeError

type RuntimeError struct {
	Source string          // Name of the source which was given to the parser
	Type   error           // Error type (to be used for equal checks)
	Detail string          // Details of this error
	Node   *parser.ASTNode // AST Node where the error occurred
	Line   int             // Line of the error
	Pos    int             // Position of the error
}

RuntimeError is a runtime related error

func (*RuntimeError) Error

func (re *RuntimeError) Error() string

Error returns a human-readable string representation of this error.

Jump to

Keyboard shortcuts

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