value

package
v0.0.0-...-04de46c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2014 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, args ...interface{})

Errorf panics with the formatted string, with type Error.

func SetConfig

func SetConfig(c *config.Config)

Types

type BigInt

type BigInt struct {
	*big.Int
}

func (BigInt) Eval

func (i BigInt) Eval(Context) Value

func (BigInt) Format

func (i BigInt) Format()

The fmt package looks for Formatter before Stringer, but we want to use Stringer only. big.Int and big.Rat implement Formatter, and we embed them in our BigInt and BigRat types. To make sure that our String gets called rather than the inner Format, we put a non-matching stub Format method into this interface. This is ugly but very simple and cheap.

func (BigInt) String

func (i BigInt) String() string

type BigRat

type BigRat struct {
	*big.Rat
}

func (BigRat) Eval

func (r BigRat) Eval(Context) Value

func (BigRat) String

func (r BigRat) String() string

type Context

type Context interface {
	// Lookup returns the value of a symbol.
	Lookup(name string) Value

	// AssignLocal binds a value to the name in the current function.
	AssignLocal(name string, value Value)

	// Assign assigns the variable the value. The variable must
	// be defined either in the current function or globally.
	// Inside a function, new variables become locals.
	Assign(name string, value Value)

	// Push pushes a new frame onto the context stack.
	Push()

	// Pop pops the top frame from the stack.
	Pop()

	// Eval evaluates a list of expressions.
	Eval(exprs []Expr) []Value
}

Context is the execution context for evaluation.

type Error

type Error string

Error is the type we recognize as a recoverable run-time error.

func (Error) Error

func (err Error) Error() string

type Expr

type Expr interface {
	String() string

	Eval(Context) Value
}

Expr is the interface for a parsed expression.

type Int

type Int int64

func (Int) Eval

func (i Int) Eval(Context) Value

func (Int) String

func (i Int) String() string

func (Int) ToBool

func (i Int) ToBool() bool

type Matrix

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

func (Matrix) Eval

func (m Matrix) Eval(Context) Value

func (Matrix) Shape

func (m Matrix) Shape() Vector

func (Matrix) String

func (m Matrix) String() string

type Value

type Value interface {
	String() string
	Eval(Context) Value
	// contains filtered or unexported methods
}

func Binary

func Binary(u Value, opName string, v Value) Value

func Parse

func Parse(s string) (Value, error)

func Unary

func Unary(opName string, v Value) Value

type Vector

type Vector []Value

func NewVector

func NewVector(elem []Value) Vector

func (Vector) Eval

func (v Vector) Eval(Context) Value

func (Vector) String

func (v Vector) String() string

Jump to

Keyboard shortcuts

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