eval

package module
v0.0.0-...-9d89a60 Latest Latest
Warning

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

Go to latest
Published: May 3, 2015 License: MIT Imports: 8 Imported by: 5

README

eval

simple expression evaluation

Documentation

Index

Constants

View Source
const (
	EOE token = iota
	BAD
	IDENT
	STRING
	NUMBER
	BOOL
	COMMA
	LPAREN
	RPAREN
	NOT
	ADD
	SUB
	MUL
	DIV
	EQ
	NEQ
	LT
	LTE
	GT
	GTE
	AND
	OR
)
View Source
const (
	ISO8601 string = "2006-01-02T15:04:05.999Z0700"
)

Variables

This section is empty.

Functions

func GetNumber

func GetNumber(args []interface{}, index int) *big.Rat

func GetNumberAsInt

func GetNumberAsInt(args []interface{}, index int) int

func MinNumOfParams

func MinNumOfParams(args []interface{}, expected int)

func MustBeBool

func MustBeBool(args []interface{}, index int) bool

func MustBeDate

func MustBeDate(args []interface{}, index int) time.Time

func MustBeNumber

func MustBeNumber(args []interface{}, index int) *big.Rat

func MustBeNumberAsInt

func MustBeNumberAsInt(args []interface{}, index int) int

func MustBeString

func MustBeString(args []interface{}, index int) string

func NewContext

func NewContext() *context

func NumOfParams

func NumOfParams(args []interface{}, expected int)

Types

type Context

type Context interface {
	AddFunctions(Functions) Context
	AddValues(Values) Context
	SetTimeZone(*time.Location) Context
	ParseDate(format, value string) (time.Time, error)
	// contains filtered or unexported methods
}

type Expr

type Expr interface {
	Eval(Context) (interface{}, error)
	String() string
}

func Parse

func Parse(src []byte) (expr Expr, err error)

func ParseIdent

func ParseIdent(name string) Expr

ParseIdent is shortcut function to get value from context

func ParseString

func ParseString(src string) (expr Expr, err error)

ParseString parses string and returns expression or error

type Functions

type Functions func(string, []interface{}) (interface{}, error)

type NOFUNC

type NOFUNC struct{}

func (NOFUNC) Error

func (e NOFUNC) Error() string

type Values

type Values func(string) (interface{}, bool)

Jump to

Keyboard shortcuts

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