evaluator

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// null can be referenced instead of allocating a new object each time we evaluate a node.
	NULL = &object.Null{}
	// there will only ever be two variations of object.Booleans,
	// it is more beneficial to reference them instead of allocating new ones.
	TRUE  = &object.Boolean{Value: true}
	FALSE = &object.Boolean{Value: false}
)

Functions

func Eval

func Eval(node ast.Node, env *object.Environment) object.Object

Eval accepts an AST Node and determines the best way to evaluate it. We store the evaluated value in an Object, which can be later referenced. Eval is expected to run recursively, following the "tree-walking pattern". It should traverse the tree (AST), starting with the top-level *ast.Program, going into all its statements and evaluating each one. It traverses each Statement, evaluating its own nodes. This will lead to evaluating the actual Expression Nodes, where the Value of the node can be consumed and stored in an Object.

Types

This section is empty.

Jump to

Keyboard shortcuts

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