state

package
v0.0.0-...-943ffa6 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidVariable

func IsValidVariable(n string) bool

Types

type State

type State interface {
	Variables

	// GetFunction by name
	GetFunction(pos lexer.Position, n string) (*script.FuncDec, bool)

	// GetFunctions returns a list of declared functions
	GetFunctions() []string

	// SetFunction sets the current FuncDec in use, returning the previous one
	SetFunction(currentFunction *script.FuncDec) *script.FuncDec
}

State holds the current processing state of the Script

func New

func New(s *script.Script) (State, error)

type Variables

type Variables interface {
	// NewScope creates a new Variables scope
	NewScope() Variables
	// EndScope closes this Variables scope and returns the previous one.
	// If this is the Global scope this returns this instance.
	EndScope() Variables
	// NewRootScope is like NewScope except that variable lookups are not
	// passed to the parent if missing from the current scope.
	// This is used to isolate variables inside functions
	NewRootScope() Variables
	// GlobalScope returns the global scope, usually the one returned by NewVariables()
	GlobalScope() Variables
	// Declare a variable.
	Declare(n string)
	// Set a variable. If the variable is declared in a parent scope this
	// will set the variable there.
	// returns false if the variable is undeclared.
	Set(n string, val interface{}) bool
	// Get returns the variable, checking parent scopes until it finds it.
	Get(string) (interface{}, bool)
}

func NewVariables

func NewVariables() Variables

Jump to

Keyboard shortcuts

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