Documentation ¶
Index ¶
- Constants
- func ConvertToBool(v reflect.Value) bool
- func ConvertToFloat(v reflect.Value) float64
- func ConvertToInt(v reflect.Value) int64
- func ConvertToUint(v reflect.Value) uint64
- func EvalBool(expr Expr, env Env) (value bool, err error)
- func EvalInt(expr Expr, env Env) (value int64, err error)
- type Env
- type Expr
- type ExpressionParser
- type Var
Constants ¶
View Source
const ( TokenEOF = -(iota + 1) TokenIdent TokenInt TokenFloat TokenString TokenOperator )
Variables ¶
This section is empty.
Functions ¶
func ConvertToBool ¶
func ConvertToFloat ¶
func ConvertToInt ¶
func ConvertToUint ¶
Types ¶
type Expr ¶
type Expr interface { // Eval returns the value of this Expr in the environment env. Eval(env Env) reflect.Value // Check reports errors in this Expr and adds its Vars to the set. Check(vars map[Var]interface{}) error }
An Expr is an arithmetic expression.
type ExpressionParser ¶
type ExpressionParser struct {
// contains filtered or unexported fields
}
---- parser ----
func NewExpressionParser ¶
func NewExpressionParser() *ExpressionParser
func (*ExpressionParser) GetExpr ¶
func (parser *ExpressionParser) GetExpr() Expr
func (*ExpressionParser) GetVariable ¶
func (parser *ExpressionParser) GetVariable() []string
func (*ExpressionParser) Parse ¶
func (parser *ExpressionParser) Parse(input string) (err error)
Parse parses the input string as an arithmetic expression.
expr = num a literal number, e.g., 3.14159 | id a variable name, e.g., x | id '(' expr ',' ... ')' a function call | '-' expr a unary operator ( + - ! ) | expr '+' expr a binary operator ( + - * / && & || | == )
Click to show internal directories.
Click to hide internal directories.