eval

package
v0.0.0-...-82282fc Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRegistery

func DefaultRegistery()

Register Default Rocky Function

func Eval

func Eval(tokenMap map[int]*tokenizer.Token)

func NewActionList

func NewActionList(acts ...*Action) *map[string]*Action

func NewArgs

func NewArgs(args ...string) map[string]VTYPE

Structure the arg like this: name-VTYPE

func NewRockyFunction

func NewRockyFunction()

func NewVariableList

func NewVariableList(vars ...*Variable) *map[string]*Variable

func RegisterFunction

func RegisterFunction(function *Function)

Register New Function

func TestEval

func TestEval(tokenMap map[int]*tokenizer.Token)

Types

type Action

type Action struct {
	Name              string
	RequestedID       string
	RequiredVariables map[int]*Variable
}

type Class

type Class struct {
	FunctionList map[int]Function
	Variables    map[int]Variable
}

type Function

type Function struct {
	Name         string
	Args         map[string]VTYPE
	VariableList map[string]*Variable
	ActionList   map[string]*Action
	Executable   func(function *Function) bool
}

func GetFunction

func GetFunction(name string) *Function

Get Function

func NewFunction

func NewFunction(Name string, VariableList map[string]*Variable,
	ActionList map[string]*Action, ArgList map[string]VTYPE, function func(function *Function) bool) *Function

func (*Function) Execute

func (function *Function) Execute()

func (*Function) SetVariableList

func (function *Function) SetVariableList(varList map[string]*Variable)

type Mathematical

type Mathematical struct {
	Equation string
	Output   float64
}

func NewMathematical

func NewMathematical(equation string) *Mathematical

func (*Mathematical) GetOutput

func (math *Mathematical) GetOutput() float64

Token Type Getter

type VTYPE

type VTYPE int

TOKEN - Custom type to hold value for token type

const (
	STRING VTYPE = iota + 1 // EnumIndex = 1
	INT                     // EnumIndex = 2
	CLASS                   // EnumIndex = 3
	DOUBLE                  // EnumIndex = 4
	NONE                    // EnumIndex = 3
)

Declare related constants for each Token type starting with index 1

func NewVType

func NewVType(Type string) VTYPE

func VTypeFromString

func VTypeFromString(tk string) VTYPE

func (VTYPE) ToString

func (vtype VTYPE) ToString() string

Converting Enum to string

type Variable

type Variable struct {
	Name string
	Type VTYPE
	Data string
}

func NewVariable

func NewVariable(Name string, Type VTYPE, Data string) *Variable

type VariableRegistrar

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

func NewVariableRegistrar

func NewVariableRegistrar() *VariableRegistrar

func (*VariableRegistrar) GetVariable

func (varR *VariableRegistrar) GetVariable(name string) *Variable

Get a Variable

func (*VariableRegistrar) RegisterVariable

func (varR *VariableRegistrar) RegisterVariable(variable *Variable)

Function to register new variable

Jump to

Keyboard shortcuts

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