evaluator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package evaluator defines logic to evaluate an AST.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constant

type Constant struct {
	Value datavalue.Value
	Type  string
}

Constant defines a constant struct.

func (*Constant) GetType

func (c *Constant) GetType() string

GetType returns the constant's type.

func (*Constant) GetValue

func (c *Constant) GetValue() datavalue.Value

GetValue returns the value of the constant.

func (*Constant) IsConstant

func (c *Constant) IsConstant() bool

IsConstant just returns true.

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

Evaluator defines the actual evaluator struct.

func NewEvaluator

func NewEvaluator(outFile io.Writer) *Evaluator

NewEvaluator creates a new evaluator.

func (*Evaluator) Evaluate

func (e *Evaluator) Evaluate(currentAst ast.ExprNode) (*controlflow.EvaluationResult, error)

Evaluate runs the evaluation logic.

func (*Evaluator) Output

func (e *Evaluator) Output() string

Output returns the current output buffer contents.

type ScopedValue

type ScopedValue interface {
	GetValue() datavalue.Value
	GetType() string
	IsConstant() bool
}

ScopedValue defines an interface for scoped values.

type Variable

type Variable struct {
	Value datavalue.Value
	Type  string
}

Variable defines a variable struct.

func (*Variable) GetType

func (v *Variable) GetType() string

GetType returns the variable's type.

func (*Variable) GetValue

func (v *Variable) GetValue() datavalue.Value

GetValue returns the value of the variable.

func (*Variable) IsConstant

func (v *Variable) IsConstant() bool

IsConstant just returns false.

Jump to

Keyboard shortcuts

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