runtime

package
v0.0.0-...-cca31bf Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoneValue = iota
	NumberValue
	BooleanValue
)

Variables

View Source
var ValueNames = map[int]string{
	NoneValue:    "None",
	NumberValue:  "Number",
	BooleanValue: "Boolean",
}

Functions

This section is empty.

Types

type RuntimeScope

type RuntimeScope struct {
	Parent    *RuntimeScope           `json:"parent"`
	Symbols   map[string]RuntimeValue `json:"symbols"`
	Constants map[string]bool         `json:"constants"`
}

func (*RuntimeScope) AssignSymbol

func (scope *RuntimeScope) AssignSymbol(name string, value RuntimeValue) (RuntimeValue, bool)

AssignSymbol assigns a value to a symbol in the current scope If the symbol does not exist, it will check the parent scope If the symbol is a constant, it will panic

func (*RuntimeScope) DeclareSymbol

func (scope *RuntimeScope) DeclareSymbol(name string, value RuntimeValue, isConstant bool) (RuntimeValue, bool)

DeclareSymbol declares a symbol in the current scope and returns the value

func (*RuntimeScope) GetSymbol

func (scope *RuntimeScope) GetSymbol(name string) (RuntimeValue, bool)

GetSymbol returns the value of a symbol in the current scope If the symbol does not exist, it will check the parent scope

func (*RuntimeScope) ResolveScope

func (scope *RuntimeScope) ResolveScope(name string) *RuntimeScope

type RuntimeValue

type RuntimeValue struct {
	Type  int         `json:"type"`
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

func EvaluateAst

func EvaluateAst(tree interface{}, scope RuntimeScope) RuntimeValue

Jump to

Keyboard shortcuts

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