Documentation ¶
Index ¶
- Constants
- type Context
- func (c *Context) EndScope()
- func (c *Context) GetVar(n string) *Value
- func (c *Context) Peek() (*Value, error)
- func (c *Context) Pop() (*Value, error)
- func (c *Context) Pop2() (*Value, *Value, error)
- func (c *Context) Push(v *Value)
- func (c *Context) PushBool(b bool)
- func (c *Context) PushComplex(x complex128)
- func (c *Context) PushFloat(f float64)
- func (c *Context) PushInt(i int64)
- func (c *Context) PushNull()
- func (c *Context) PushString(s string)
- func (c *Context) ResetScope()
- func (c *Context) SetVar(n string, val *Value)
- func (c *Context) SetVarBool(n string, val bool)
- func (c *Context) SetVarFloat(n string, val float64)
- func (c *Context) SetVarInt(n string, val int64)
- func (c *Context) SetVarString(n string, val string)
- func (c *Context) Stack() []*Value
- func (c *Context) StartScope()
- func (c *Context) Swap() error
- func (c *Context) Vars() []map[string]*Value
- type Node
- func (n *Node) Append(a *Node) *Node
- func (n *Node) Center() *Node
- func (n *Node) ForEach(f func(*Node) error) error
- func (n *Node) ForEachAll(f func(*Node) error) error
- func (n *Node) Invoke(m *Context) error
- func (n *Node) Invoke2(m *Context) error
- func (n *Node) InvokeCenter(m *Context) error
- func (n *Node) InvokeLhs(m *Context) error
- func (n *Node) InvokeRhs(m *Context) error
- func (n *Node) IsConstant() bool
- func (n *Node) Left() *Node
- func (n *Node) Right() *Node
- func (n *Node) Token() *lex.Token
- func (n *Node) Value() *Value
- type NodeHandler
- type Value
- func (v *Value) Bool() bool
- func (v *Value) Complex() complex128
- func (a *Value) Equal(b *Value) bool
- func (v *Value) Float() float64
- func (v *Value) Imaginary() float64
- func (v *Value) Int() int64
- func (v *Value) IsComplex() bool
- func (v *Value) IsNegative() bool
- func (v *Value) IsNull() bool
- func (v *Value) IsNumeric() bool
- func (v *Value) IsZero() bool
- func (a *Value) OperationType(b *Value) int
- func (v *Value) Real() float64
- func (a *Value) Same(b *Value) bool
- func (v *Value) String() string
- func (v *Value) Type() int
Constants ¶
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) PushComplex ¶
func (c *Context) PushComplex(x complex128)
func (*Context) PushString ¶
func (*Context) ResetScope ¶
func (c *Context) ResetScope()
func (*Context) SetVarBool ¶
func (*Context) SetVarFloat ¶
func (*Context) SetVarString ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
A node in the filter tree
func NewBlock ¶
func NewBlock(f NodeHandler) *Node
func (*Node) ForEachAll ¶
ForEachAll invokes a function for the left & right hand nodes (if present) and for any node within this nodes list
func (*Node) InvokeCenter ¶
Invokes the center node or returns false if none
func (*Node) IsConstant ¶
IsConstant returns true if this node is a constant, i.e. has a Value and no Handler
type NodeHandler ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
An imutable Value of some kind.
func ComplexValue ¶
func ComplexValue(i complex128) *Value
ComplexValue returns a Value for a complex128
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) Imaginary ¶
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) IsNegative ¶
func (*Value) IsZero ¶
IsZero returns true if the Value is null, false, 0, 0.0 or "" dependent on it's type
func (*Value) OperationType ¶
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.