value

package
v0.0.0-...-3042a1c Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

COPIED FROM robpike.io/ivy/value/value.go

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.

Types

type Char

type Char rune

func (Char) Eval

func (c Char) Eval(Context) Value

func (Char) ProgString

func (c Char) ProgString() string

func (Char) Sprint

func (c Char) Sprint(conf *config.Config) string

func (Char) String

func (c Char) String() string

type Context

type Context interface {

	// Lookup returns the configuration state for evaluation.
	Config() *config.Config

	// Lookup returns the value of a symbol.
	Lookup(name string) 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)

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

	// EvalUnaryFn evaluates a unary operator.
	EvalUnary(op string, right Value) Value

	// EvalBinary evaluates a binary operator.
	EvalBinary(left Value, op string, right Value) Value

	// UserDefined reports whether the specified op is user-defined.
	UserDefined(op string, isBinary bool) bool
}

Context is the execution context for evaluation. The only implementation is ../exec/Context, but the interface is defined separately, here, because of the dependence on Expr and the import cycle that would otherwise result.

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 {
	// ProgString returns the unambiguous representation of the
	// expression to be used in program source.
	ProgString() string
}

Expr is the interface for a parsed expression.

type Int

type Int int64

func (Int) Eval

func (i Int) Eval(Context) Value

func (Int) ProgString

func (i Int) ProgString() string

func (Int) Sprint

func (i Int) Sprint(conf *config.Config) string

func (Int) String

func (i Int) String() string

type Value

type Value interface {
	// String is for internal debugging only. It uses default configuration
	// and puts parentheses around every value so it's clear when it is used.
	// All user output should call Sprint instead.
	String() string
	Sprint(*config.Config) string
	Eval(Context) Value

	// ProgString is like String, but suitable for program listing.
	// For instance, it ignores the user format for numbers and
	// puts quotes on chars, guaranteeing a correct representation.
	ProgString() string
}

func Parse

func Parse(conf *config.Config, s string) (Value, error)

Jump to

Keyboard shortcuts

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