Documentation ¶
Overview ¶
Define a new concrete type that satisfies the `Expr` interface and provides a new operation such as computing the minimum value of its operands. Since the `Parse` function does not create instances of this new type, to use it you will need to construct a syntax tree directly (or extend the parser).
Add a `String` method to `Expr` to pretty-print the syntax tree. Check that the results, when parsed again, yield an equivalent tree.
Package eval provides an expression evaluator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Expr ¶
type Expr interface { // Eval returns the value of this Expr in the environment env. Eval(env Env) float64 // Check reports errors in this Expr and adds its Vars to the set. Check(vars map[Var]bool) error // Pretty-print the syntax tree String() string // Brace() reports if this Expr has an enclosing brace Brace() bool }
An Expr is an arithmetic expression.
Click to show internal directories.
Click to hide internal directories.