context

package
v0.0.0-...-0feb360 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VAR_NULL
	VAR_BOOL
	VAR_INT
	VAR_FLOAT
	VAR_COMPLEX
	VAR_STRING
)

The types of a Value returned by Type()

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

The runtime context used when performing processing

func (*Context) EndScope

func (c *Context) EndScope()

Ends the current variable scope. Note this will not remove the first scope if present

func (*Context) GetVar

func (c *Context) GetVar(n string) *Value

func (*Context) Peek

func (c *Context) Peek() (*Value, error)

func (*Context) Pop

func (c *Context) Pop() (*Value, error)

Pop a value from the stack. Returns error if the stack is empty

func (*Context) Pop2

func (c *Context) Pop2() (*Value, *Value, error)

Pops 2 values from the stack. Returns error if the stack is empty

func (*Context) Push

func (c *Context) Push(v *Value)

Push a value onto the stack

func (*Context) PushBool

func (c *Context) PushBool(b bool)

func (*Context) PushComplex

func (c *Context) PushComplex(x complex128)

func (*Context) PushFloat

func (c *Context) PushFloat(f float64)

func (*Context) PushInt

func (c *Context) PushInt(i int64)

func (*Context) PushNull

func (c *Context) PushNull()

func (*Context) PushString

func (c *Context) PushString(s string)

func (*Context) ResetScope

func (c *Context) ResetScope()

func (*Context) SetVar

func (c *Context) SetVar(n string, val *Value)

func (*Context) SetVarBool

func (c *Context) SetVarBool(n string, val bool)

func (*Context) SetVarFloat

func (c *Context) SetVarFloat(n string, val float64)

func (*Context) SetVarInt

func (c *Context) SetVarInt(n string, val int64)

func (*Context) SetVarString

func (c *Context) SetVarString(n string, val string)

func (*Context) Stack

func (c *Context) Stack() []*Value

Stack returns a copy of the current stack

func (*Context) StartScope

func (c *Context) StartScope()

Starts a variable scope

func (*Context) Swap

func (c *Context) Swap() error

Swap swaps the top 2 values on the stack. Returns error if the stack doesn't have 2 items to swap.

func (*Context) Vars

func (c *Context) Vars() []map[string]*Value

Vars returns a copy of the context's variables

type Node

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

A node in the filter tree

func NewBlock

func NewBlock(f NodeHandler) *Node

func NewConstant

func NewConstant(t *lex.Token, val *Value) *Node

func NewNode

func NewNode(t *lex.Token, f NodeHandler, left *Node, right *Node) *Node

func NewNode3

func NewNode3(t *lex.Token, f NodeHandler, left *Node, center *Node, right *Node) *Node

func (*Node) Append

func (n *Node) Append(a *Node) *Node

Append appends a Node to this nodes list

func (*Node) Center

func (n *Node) Center() *Node

Right returns the right hand node or nil

func (*Node) ForEach

func (n *Node) ForEach(f func(*Node) error) error

ForEach invokes a function for each node in this nodes list

func (*Node) ForEachAll

func (n *Node) ForEachAll(f func(*Node) error) error

ForEachAll invokes a function for the left & right hand nodes (if present) and for any node within this nodes list

func (*Node) Invoke

func (n *Node) Invoke(m *Context) error

Invoke the handler of this node

func (*Node) Invoke2

func (n *Node) Invoke2(m *Context) error

Invoke2 is for use by handlers. It will invoke both left & right in one go

func (*Node) InvokeCenter

func (n *Node) InvokeCenter(m *Context) error

Invokes the center node or returns false if none

func (*Node) InvokeLhs

func (n *Node) InvokeLhs(m *Context) error

Invokes the left hand side node or returns false if none

func (*Node) InvokeRhs

func (n *Node) InvokeRhs(m *Context) error

Invokes the right hand side node or returns false if none

func (*Node) IsConstant

func (n *Node) IsConstant() bool

IsConstant returns true if this node is a constant, i.e. has a Value and no Handler

func (*Node) Left

func (n *Node) Left() *Node

Left returns the left hand node or nil

func (*Node) Right

func (n *Node) Right() *Node

Right returns the right hand node or nil

func (*Node) Token

func (n *Node) Token() *lex.Token

Token returns this nodes lex.Token

func (*Node) Value

func (n *Node) Value() *Value

Value returns this nodes value or nil

type NodeHandler

type NodeHandler func(*Context, *Node) error

type Value

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

An imutable Value of some kind.

func BoolValue

func BoolValue(i bool) *Value

BoolValue returns a Value for a bool

func ComplexValue

func ComplexValue(i complex128) *Value

ComplexValue returns a Value for a complex128

func FloatValue

func FloatValue(i float64) *Value

FloatValue returns a Value for an float64

func IntValue

func IntValue(i int64) *Value

IntValue returns a Value for an int64

func NullValue

func NullValue() *Value

NullValue returns the Value for Null/nil

func StringValue

func StringValue(i string) *Value

StringValue returns a Value for an string

func (*Value) Bool

func (v *Value) Bool() bool

Bool returns the value as a bool

func (*Value) Complex

func (v *Value) Complex() complex128

Return the number as a Complex number. For real numbers this will return the complex value with 0 for the imaginary component.

func (*Value) Equal

func (a *Value) Equal(b *Value) bool

func (*Value) Float

func (v *Value) Float() float64

Float returns the value as a float64

func (*Value) Imaginary

func (v *Value) Imaginary() float64

Imaginary returns the imaginary value of this Value. For real numbers this returns 0.0 but for complex numbers this returns the imaginary component.

func (*Value) Int

func (v *Value) Int() int64

Int returns the value as an int64

func (*Value) IsComplex

func (v *Value) IsComplex() bool

func (*Value) IsNegative

func (v *Value) IsNegative() bool

func (*Value) IsNull

func (v *Value) IsNull() bool

IsNull returns true if the Value is null

func (*Value) IsNumeric

func (v *Value) IsNumeric() bool

IsNumeric returns true if the Value is a number, i.e. int64 or float64

func (*Value) IsZero

func (v *Value) IsZero() bool

IsZero returns true if the Value is null, false, 0, 0.0 or "" dependent on it's type

func (*Value) OperationType

func (a *Value) OperationType(b *Value) int

OperationType returns the type of the suggested value when performing some operation like addition or multiplication to keep the precision of the result. For example, if a Value is an Integer but the passed value is Float then we should use float.

func (*Value) Real

func (v *Value) Real() float64

Real returns the real value of this Value. For real numbers this is the same as Float() but for complex numbers this returns the real component.

func (*Value) Same

func (a *Value) Same(b *Value) bool

func (*Value) String

func (v *Value) String() string

String returns the value as a string

func (*Value) Type

func (v *Value) Type() int

The type of this value

Jump to

Keyboard shortcuts

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