Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IvyEval func(context Context, s string) Value
Implemented in main, handled as a func to avoid a dependency loop.
var (
MaxBigInt63 = big.NewInt(int64(^uint64(0) >> 1))
)
Functions ¶
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf panics with the formatted string, with type Error.
func ParseString ¶
ParseString parses a string. Single quotes and double quotes are both allowed (but must be consistent.) The result must contain only valid Unicode code points.
Types ¶
type BigFloat ¶
func (BigFloat) Format ¶
func (i BigFloat) Format()
The fmt package looks for Formatter before Stringer, but we want to use Stringer only. big.Float implements Formatter, and we embed it in our BigFloat type. 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 (BigFloat) ProgString ¶
type BigInt ¶
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) ProgString ¶
type BigRat ¶
func (BigRat) ProgString ¶
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 Expr ¶
type Expr interface { // ProgString returns the unambiguous representation of the // expression to be used in program source. ProgString() string Eval(Context) Value }
Expr is the interface for a parsed expression.
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
func (Matrix) ProgString ¶
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 // contains filtered or unexported methods }