Documentation
¶
Overview ¶
Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the GO_LICENSE file.
This parser is based on go's parser package, but has been customized to parse expressions suitable for dexpr.
The parser accepts a larger language than is syntactically permitted by the Go spec, for simplicity, and for improved robustness in the presence of syntax errors. For instance, in method declarations, the receiver is treated like an ordinary parameter list and thus may contain multiple entries where the spec permits exactly one. Consequently, the corresponding field in the AST (ast.FuncDecl.Recv) field is not restricted to one entry.
Index ¶
- Variables
- func Eval(expr string, callFuncs map[string]CallFun, vars map[string]*dlit.Literal) *dlit.Literal
- func EvalBool(expr string, callFuncs map[string]CallFun, vars map[string]*dlit.Literal) (bool, error)
- type CallFun
- type Expr
- type FunctionError
- type FunctionNotExistError
- type InvalidExprError
- type InvalidOpError
- type VarNotExistError
Constants ¶
This section is empty.
Variables ¶
var ErrDivByZero = errors.New("divide by zero")
var ErrIncompatibleTypes = errors.New("incompatible types")
var ErrInvalidCompositeType = errors.New("invalid composite type")
var ErrInvalidIndex = errors.New("index out of range")
var ErrSyntax = errors.New("syntax error")
var ErrTypeNotIndexable = errors.New("type does not support indexing")
var ErrUnderflowOverflow = errors.New("underflow/overflow")
Functions ¶
Types ¶
type FunctionError ¶
func (FunctionError) Error ¶
func (e FunctionError) Error() string
type FunctionNotExistError ¶
type FunctionNotExistError string
func (FunctionNotExistError) Error ¶
func (e FunctionNotExistError) Error() string
type InvalidExprError ¶
func (InvalidExprError) Error ¶
func (e InvalidExprError) Error() string
type InvalidOpError ¶
func (InvalidOpError) Error ¶
func (e InvalidOpError) Error() string
type VarNotExistError ¶
type VarNotExistError string
func (VarNotExistError) Error ¶
func (e VarNotExistError) Error() string