Documentation
¶
Index ¶
- Constants
- Variables
- type RuntimeScope
- func (scope *RuntimeScope) AssignSymbol(name string, value RuntimeValue) (RuntimeValue, bool)
- func (scope *RuntimeScope) DeclareSymbol(name string, value RuntimeValue, isConstant bool) (RuntimeValue, bool)
- func (scope *RuntimeScope) GetSymbol(name string) (RuntimeValue, bool)
- func (scope *RuntimeScope) ResolveScope(name string) *RuntimeScope
- type RuntimeValue
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
Click to show internal directories.
Click to hide internal directories.