Documentation ¶
Index ¶
- Variables
- func Between(a Expr) func(x, b Expr) Expr
- func Equal(a, b Expr) bool
- func IsArithmeticOperator(op Operator) bool
- func IsComparisonOperator(op Operator) bool
- func Walk(e Expr, fn func(Expr) bool) bool
- type Aggregator
- type AggregatorBuilder
- type AndOp
- func (op *AndOp) Eval(env *environment.Environment) (types.Value, error)
- func (op AndOp) IsEqual(other Expr) bool
- func (op AndOp) LeftHand() Expr
- func (op AndOp) Precedence() int
- func (op AndOp) RightHand() Expr
- func (op AndOp) SetLeftHandExpr(a Expr)
- func (op AndOp) SetRightHandExpr(b Expr)
- func (op AndOp) String() string
- func (op AndOp) Token() scanner.Token
- type BetweenOperator
- func (op *BetweenOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op BetweenOperator) IsEqual(other Expr) bool
- func (op BetweenOperator) LeftHand() Expr
- func (op BetweenOperator) Precedence() int
- func (op BetweenOperator) RightHand() Expr
- func (op BetweenOperator) SetLeftHandExpr(a Expr)
- func (op BetweenOperator) SetRightHandExpr(b Expr)
- func (op *BetweenOperator) String() string
- func (op BetweenOperator) Token() scanner.Token
- type Cast
- type ConcatOperator
- func (op *ConcatOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op ConcatOperator) IsEqual(other Expr) bool
- func (op ConcatOperator) LeftHand() Expr
- func (op ConcatOperator) Precedence() int
- func (op ConcatOperator) RightHand() Expr
- func (op ConcatOperator) SetLeftHandExpr(a Expr)
- func (op ConcatOperator) SetRightHandExpr(b Expr)
- func (op ConcatOperator) String() string
- func (op ConcatOperator) Token() scanner.Token
- type ConstraintExpr
- type Expr
- func Add(a, b Expr) Expr
- func And(a, b Expr) Expr
- func BitwiseAnd(a, b Expr) Expr
- func BitwiseOr(a, b Expr) Expr
- func BitwiseXor(a, b Expr) Expr
- func Concat(a, b Expr) Expr
- func Div(a, b Expr) Expr
- func Eq(a, b Expr) Expr
- func Gt(a, b Expr) Expr
- func Gte(a, b Expr) Expr
- func In(a, b Expr) Expr
- func Is(a, b Expr) Expr
- func IsNot(a, b Expr) Expr
- func Like(a, b Expr) Expr
- func Lt(a, b Expr) Expr
- func Lte(a, b Expr) Expr
- func Mod(a, b Expr) Expr
- func Mul(a, b Expr) Expr
- func Neq(a, b Expr) Expr
- func Not(e Expr) Expr
- func NotIn(a, b Expr) Expr
- func NotLike(a, b Expr) Expr
- func Or(a, b Expr) Expr
- func Sub(a, b Expr) Expr
- type Function
- type InOperator
- func (op *InOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op InOperator) IsEqual(other Expr) bool
- func (op InOperator) LeftHand() Expr
- func (op InOperator) Precedence() int
- func (op InOperator) RightHand() Expr
- func (op InOperator) SetLeftHandExpr(a Expr)
- func (op InOperator) SetRightHandExpr(b Expr)
- func (op InOperator) String() string
- func (op InOperator) Token() scanner.Token
- type IsNotOperator
- func (op *IsNotOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op IsNotOperator) IsEqual(other Expr) bool
- func (op IsNotOperator) LeftHand() Expr
- func (op IsNotOperator) Precedence() int
- func (op IsNotOperator) RightHand() Expr
- func (op IsNotOperator) SetLeftHandExpr(a Expr)
- func (op IsNotOperator) SetRightHandExpr(b Expr)
- func (op *IsNotOperator) String() string
- func (op IsNotOperator) Token() scanner.Token
- type IsOperator
- func (op *IsOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op IsOperator) IsEqual(other Expr) bool
- func (op IsOperator) LeftHand() Expr
- func (op IsOperator) Precedence() int
- func (op IsOperator) RightHand() Expr
- func (op IsOperator) SetLeftHandExpr(a Expr)
- func (op IsOperator) SetRightHandExpr(b Expr)
- func (op IsOperator) String() string
- func (op IsOperator) Token() scanner.Token
- type KVPair
- type KVPairs
- type LikeOperator
- func (op *LikeOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op LikeOperator) IsEqual(other Expr) bool
- func (op LikeOperator) LeftHand() Expr
- func (op LikeOperator) Precedence() int
- func (op LikeOperator) RightHand() Expr
- func (op LikeOperator) SetLeftHandExpr(a Expr)
- func (op LikeOperator) SetRightHandExpr(b Expr)
- func (op LikeOperator) String() string
- func (op LikeOperator) Token() scanner.Token
- type LiteralExprList
- type LiteralValue
- type NamedExpr
- type NamedParam
- type NextValueFor
- type NotInOperator
- func (op *NotInOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op NotInOperator) IsEqual(other Expr) bool
- func (op NotInOperator) LeftHand() Expr
- func (op NotInOperator) Precedence() int
- func (op NotInOperator) RightHand() Expr
- func (op NotInOperator) SetLeftHandExpr(a Expr)
- func (op NotInOperator) SetRightHandExpr(b Expr)
- func (op *NotInOperator) String() string
- func (op NotInOperator) Token() scanner.Token
- type NotLikeOperator
- func (op *NotLikeOperator) Eval(env *environment.Environment) (types.Value, error)
- func (op NotLikeOperator) IsEqual(other Expr) bool
- func (op NotLikeOperator) LeftHand() Expr
- func (op NotLikeOperator) Precedence() int
- func (op NotLikeOperator) RightHand() Expr
- func (op NotLikeOperator) SetLeftHandExpr(a Expr)
- func (op NotLikeOperator) SetRightHandExpr(b Expr)
- func (op *NotLikeOperator) String() string
- func (op NotLikeOperator) Token() scanner.Token
- type NotOp
- func (op *NotOp) Eval(env *environment.Environment) (types.Value, error)
- func (op NotOp) IsEqual(other Expr) bool
- func (op NotOp) LeftHand() Expr
- func (op NotOp) Precedence() int
- func (op NotOp) RightHand() Expr
- func (op NotOp) SetLeftHandExpr(a Expr)
- func (op NotOp) SetRightHandExpr(b Expr)
- func (op *NotOp) String() string
- func (op NotOp) Token() scanner.Token
- type Operator
- type OrOp
- func (op *OrOp) Eval(env *environment.Environment) (types.Value, error)
- func (op OrOp) IsEqual(other Expr) bool
- func (op OrOp) LeftHand() Expr
- func (op OrOp) Precedence() int
- func (op OrOp) RightHand() Expr
- func (op OrOp) SetLeftHandExpr(a Expr)
- func (op OrOp) SetRightHandExpr(b Expr)
- func (op OrOp) String() string
- func (op OrOp) Token() scanner.Token
- type Parentheses
- type Path
- type PositionalParam
- type Wildcard
Constants ¶
This section is empty.
Variables ¶
var ( TrueLiteral = types.NewBoolValue(true) FalseLiteral = types.NewBoolValue(false) NullLiteral = types.NewNullValue() )
Functions ¶
func Between ¶
Between returns a function that creates a BETWEEN operator that returns true if x is between a and b.
func Equal ¶
Equal reports whether a and b are equal by first calling IsEqual if they have an IsEqual method with this signature:
IsEqual(Expr) bool
If not, it returns whether a and b values are equal.
func IsArithmeticOperator ¶
IsArithmeticOperator returns true if e is one of +, -, *, /, %, &, |, or ^ operators.
func IsComparisonOperator ¶
IsComparisonOperator returns true if e is one of =, !=, >, >=, <, <=, IS, IS NOT, IN, or NOT IN operators.
Types ¶
type Aggregator ¶
type Aggregator interface { Expr Aggregate(env *environment.Environment) error }
An Aggregator is an expression that aggregates objects into one result.
type AggregatorBuilder ¶
type AggregatorBuilder interface { Expr Aggregator() Aggregator }
An AggregatorBuilder is a type that can create aggregators.
type AndOp ¶
type AndOp struct {
// contains filtered or unexported fields
}
AndOp is the And operator.
func (*AndOp) Eval ¶
func (op *AndOp) Eval(env *environment.Environment) (types.Value, error)
Eval implements the Expr interface. It evaluates a and b and returns true if both evaluate to true.
func (AndOp) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (AndOp) Precedence ¶
func (op AndOp) Precedence() int
func (AndOp) SetLeftHandExpr ¶
func (op AndOp) SetLeftHandExpr(a Expr)
func (AndOp) SetRightHandExpr ¶
func (op AndOp) SetRightHandExpr(b Expr)
type BetweenOperator ¶
type BetweenOperator struct { X Expr // contains filtered or unexported fields }
func (*BetweenOperator) Eval ¶
func (op *BetweenOperator) Eval(env *environment.Environment) (types.Value, error)
func (BetweenOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (BetweenOperator) Precedence ¶
func (op BetweenOperator) Precedence() int
func (BetweenOperator) SetLeftHandExpr ¶
func (op BetweenOperator) SetLeftHandExpr(a Expr)
func (BetweenOperator) SetRightHandExpr ¶
func (op BetweenOperator) SetRightHandExpr(b Expr)
func (*BetweenOperator) String ¶
func (op *BetweenOperator) String() string
type Cast ¶
Cast represents the CAST expression.
func (Cast) Eval ¶
func (c Cast) Eval(env *environment.Environment) (types.Value, error)
Eval returns the primary key of the current object.
type ConcatOperator ¶
type ConcatOperator struct {
// contains filtered or unexported fields
}
func (*ConcatOperator) Eval ¶
func (op *ConcatOperator) Eval(env *environment.Environment) (types.Value, error)
func (ConcatOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (ConcatOperator) Precedence ¶
func (op ConcatOperator) Precedence() int
func (ConcatOperator) SetLeftHandExpr ¶
func (op ConcatOperator) SetLeftHandExpr(a Expr)
func (ConcatOperator) SetRightHandExpr ¶
func (op ConcatOperator) SetRightHandExpr(b Expr)
type ConstraintExpr ¶
type ConstraintExpr struct {
Expr Expr
}
func Constraint ¶
func Constraint(e Expr) *ConstraintExpr
func (*ConstraintExpr) Eval ¶
func (t *ConstraintExpr) Eval(tx *database.Transaction, o types.Object) (types.Value, error)
func (*ConstraintExpr) String ¶
func (t *ConstraintExpr) String() string
type Expr ¶
type Expr interface { Eval(*environment.Environment) (types.Value, error) String() string }
An Expr evaluates to a value.
func BitwiseAnd ¶
BitwiseAnd creates an expression thats evaluates to the result of a & b.
func BitwiseXor ¶
BitwiseXor creates an expression thats evaluates to the result of a ^ b.
func Concat ¶
Concat creates an expression that concatenates two text values together. It returns null if one of the values is not a text.
type Function ¶
type Function interface { Expr // Params returns the list of parameters this function has received. Params() []Expr }
A Function is an expression whose evaluation calls a function previously defined.
type InOperator ¶
type InOperator struct {
// contains filtered or unexported fields
}
func (*InOperator) Eval ¶
func (op *InOperator) Eval(env *environment.Environment) (types.Value, error)
func (InOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (InOperator) Precedence ¶
func (op InOperator) Precedence() int
func (InOperator) SetLeftHandExpr ¶
func (op InOperator) SetLeftHandExpr(a Expr)
func (InOperator) SetRightHandExpr ¶
func (op InOperator) SetRightHandExpr(b Expr)
type IsNotOperator ¶
type IsNotOperator struct {
// contains filtered or unexported fields
}
func (*IsNotOperator) Eval ¶
func (op *IsNotOperator) Eval(env *environment.Environment) (types.Value, error)
func (IsNotOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (IsNotOperator) Precedence ¶
func (op IsNotOperator) Precedence() int
func (IsNotOperator) SetLeftHandExpr ¶
func (op IsNotOperator) SetLeftHandExpr(a Expr)
func (IsNotOperator) SetRightHandExpr ¶
func (op IsNotOperator) SetRightHandExpr(b Expr)
func (*IsNotOperator) String ¶
func (op *IsNotOperator) String() string
type IsOperator ¶
type IsOperator struct {
// contains filtered or unexported fields
}
func (*IsOperator) Eval ¶
func (op *IsOperator) Eval(env *environment.Environment) (types.Value, error)
func (IsOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (IsOperator) Precedence ¶
func (op IsOperator) Precedence() int
func (IsOperator) SetLeftHandExpr ¶
func (op IsOperator) SetLeftHandExpr(a Expr)
func (IsOperator) SetRightHandExpr ¶
func (op IsOperator) SetRightHandExpr(b Expr)
type KVPairs ¶
KVPairs is a list of KVPair.
func (*KVPairs) Eval ¶
func (kvp *KVPairs) Eval(env *environment.Environment) (types.Value, error)
Eval turns a list of KVPairs into an object.
type LikeOperator ¶
type LikeOperator struct {
// contains filtered or unexported fields
}
func (*LikeOperator) Eval ¶
func (op *LikeOperator) Eval(env *environment.Environment) (types.Value, error)
func (LikeOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (LikeOperator) Precedence ¶
func (op LikeOperator) Precedence() int
func (LikeOperator) SetLeftHandExpr ¶
func (op LikeOperator) SetLeftHandExpr(a Expr)
func (LikeOperator) SetRightHandExpr ¶
func (op LikeOperator) SetRightHandExpr(b Expr)
type LiteralExprList ¶
type LiteralExprList []Expr
LiteralExprList is a list of expressions.
func (LiteralExprList) Eval ¶
func (l LiteralExprList) Eval(env *environment.Environment) (types.Value, error)
Eval evaluates all the expressions and returns a literalValueList. It implements the Expr interface.
func (LiteralExprList) IsEqual ¶
func (l LiteralExprList) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (LiteralExprList) String ¶
func (l LiteralExprList) String() string
String implements the fmt.Stringer interface.
type LiteralValue ¶
A LiteralValue represents a literal value of any type defined by the value package.
func (LiteralValue) Eval ¶
func (v LiteralValue) Eval(*environment.Environment) (types.Value, error)
Eval returns l. It implements the Expr interface.
func (LiteralValue) IsEqual ¶
func (v LiteralValue) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (LiteralValue) String ¶
func (v LiteralValue) String() string
String implements the fmt.Stringer interface.
type NamedParam ¶
type NamedParam string
NamedParam is an expression which represents the name of a parameter.
func (NamedParam) Eval ¶
func (p NamedParam) Eval(env *environment.Environment) (types.Value, error)
Eval looks up for the parameters in the env for the one that has the same name as p and returns the value.
func (NamedParam) IsEqual ¶
func (p NamedParam) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (NamedParam) String ¶
func (p NamedParam) String() string
String implements the fmt.Stringer interface.
type NextValueFor ¶
type NextValueFor struct {
SeqName string
}
func (NextValueFor) Eval ¶
func (n NextValueFor) Eval(env *environment.Environment) (types.Value, error)
Eval calls the underlying expression Eval method.
func (NextValueFor) IsEqual ¶
func (n NextValueFor) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (NextValueFor) String ¶
func (n NextValueFor) String() string
type NotInOperator ¶
type NotInOperator struct {
InOperator
}
func (*NotInOperator) Eval ¶
func (op *NotInOperator) Eval(env *environment.Environment) (types.Value, error)
func (NotInOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (NotInOperator) Precedence ¶
func (op NotInOperator) Precedence() int
func (NotInOperator) SetLeftHandExpr ¶
func (op NotInOperator) SetLeftHandExpr(a Expr)
func (NotInOperator) SetRightHandExpr ¶
func (op NotInOperator) SetRightHandExpr(b Expr)
func (*NotInOperator) String ¶
func (op *NotInOperator) String() string
type NotLikeOperator ¶
type NotLikeOperator struct {
*LikeOperator
}
func (*NotLikeOperator) Eval ¶
func (op *NotLikeOperator) Eval(env *environment.Environment) (types.Value, error)
func (NotLikeOperator) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (NotLikeOperator) Precedence ¶
func (op NotLikeOperator) Precedence() int
func (NotLikeOperator) SetLeftHandExpr ¶
func (op NotLikeOperator) SetLeftHandExpr(a Expr)
func (NotLikeOperator) SetRightHandExpr ¶
func (op NotLikeOperator) SetRightHandExpr(b Expr)
func (*NotLikeOperator) String ¶
func (op *NotLikeOperator) String() string
type NotOp ¶
type NotOp struct {
// contains filtered or unexported fields
}
NotOp is the NOT unary operator.
func (*NotOp) Eval ¶
func (op *NotOp) Eval(env *environment.Environment) (types.Value, error)
Eval implements the Expr interface. It evaluates e and returns true if b is falsy
func (NotOp) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (NotOp) Precedence ¶
func (op NotOp) Precedence() int
func (NotOp) SetLeftHandExpr ¶
func (op NotOp) SetLeftHandExpr(a Expr)
func (NotOp) SetRightHandExpr ¶
func (op NotOp) SetRightHandExpr(b Expr)
type Operator ¶
type Operator interface { Expr Precedence() int LeftHand() Expr RightHand() Expr SetLeftHandExpr(Expr) SetRightHandExpr(Expr) Token() scanner.Token }
An Operator is a binary expression that takes two operands and executes an operation on them.
type OrOp ¶
type OrOp struct {
// contains filtered or unexported fields
}
OrOp is the Or operator.
func (*OrOp) Eval ¶
func (op *OrOp) Eval(env *environment.Environment) (types.Value, error)
Eval implements the Expr interface. It evaluates a and b and returns true if a or b evalutate to true.
func (OrOp) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (OrOp) Precedence ¶
func (op OrOp) Precedence() int
func (OrOp) SetLeftHandExpr ¶
func (op OrOp) SetLeftHandExpr(a Expr)
func (OrOp) SetRightHandExpr ¶
func (op OrOp) SetRightHandExpr(b Expr)
type Parentheses ¶
type Parentheses struct {
E Expr
}
Parentheses is a special expression which turns any sub-expression as unary. It hides the underlying operator, if any, from the parser so that it doesn't get reordered by precedence.
func (Parentheses) Eval ¶
func (p Parentheses) Eval(env *environment.Environment) (types.Value, error)
Eval calls the underlying expression Eval method.
func (Parentheses) IsEqual ¶
func (p Parentheses) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (Parentheses) String ¶
func (p Parentheses) String() string
type Path ¶
A Path is an expression that extracts a value from a object at a given path.
func (Path) Eval ¶
func (p Path) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the current value from the environment and returns the value stored at p. It implements the Expr interface.
type PositionalParam ¶
type PositionalParam int
PositionalParam is an expression which represents the position of a parameter.
func (PositionalParam) Eval ¶
func (p PositionalParam) Eval(env *environment.Environment) (types.Value, error)
Eval looks up for the parameters in the env for the one that is has the same position as p and returns the value.
func (PositionalParam) IsEqual ¶
func (p PositionalParam) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (PositionalParam) String ¶
func (p PositionalParam) String() string
String implements the fmt.Stringer interface.
type Wildcard ¶
type Wildcard struct{}
A Wildcard is an expression that iterates over all the fields of a object.
func (Wildcard) Eval ¶
func (w Wildcard) Eval(env *environment.Environment) (types.Value, error)
func (Wildcard) Iterate ¶
func (w Wildcard) Iterate(env environment.Environment, fn func(field string, value types.Value) error) error
Iterate call the object iterate method.