Add BETWEEN operator support.

This commit is contained in:
go-jet 2022-01-04 17:58:10 +01:00
parent 3c866a0b6f
commit 001d64f1dc
14 changed files with 251 additions and 152 deletions

View file

@ -5,46 +5,29 @@ type IntegerExpression interface {
Expression
numericExpression
// Check if expression is equal to rhs
EQ(rhs IntegerExpression) BoolExpression
// Check if expression is not equal to rhs
NOT_EQ(rhs IntegerExpression) BoolExpression
// Check if expression is distinct from rhs
IS_DISTINCT_FROM(rhs IntegerExpression) BoolExpression
// Check if expression is not distinct from rhs
IS_NOT_DISTINCT_FROM(rhs IntegerExpression) BoolExpression
// Check if expression is less then rhs
LT(rhs IntegerExpression) BoolExpression
// Check if expression is less then equal rhs
LT_EQ(rhs IntegerExpression) BoolExpression
// Check if expression is greater then rhs
GT(rhs IntegerExpression) BoolExpression
// Check if expression is greater then equal rhs
GT_EQ(rhs IntegerExpression) BoolExpression
BETWEEN(min, max IntegerExpression) BoolExpression
NOT_BETWEEN(min, max IntegerExpression) BoolExpression
// expression + rhs
ADD(rhs IntegerExpression) IntegerExpression
// expression - rhs
SUB(rhs IntegerExpression) IntegerExpression
// expression * rhs
MUL(rhs IntegerExpression) IntegerExpression
// expression / rhs
DIV(rhs IntegerExpression) IntegerExpression
// expression % rhs
MOD(rhs IntegerExpression) IntegerExpression
// expression ^ rhs
POW(rhs IntegerExpression) IntegerExpression
// expression & rhs
BIT_AND(rhs IntegerExpression) IntegerExpression
// expression | rhs
BIT_OR(rhs IntegerExpression) IntegerExpression
// expression # rhs
BIT_XOR(rhs IntegerExpression) IntegerExpression
// expression << rhs
BIT_SHIFT_LEFT(shift IntegerExpression) IntegerExpression
// expression >> rhs
BIT_SHIFT_RIGHT(shift IntegerExpression) IntegerExpression
}
@ -85,6 +68,14 @@ func (i *integerInterfaceImpl) LT_EQ(rhs IntegerExpression) BoolExpression {
return LtEq(i.parent, rhs)
}
func (i *integerInterfaceImpl) BETWEEN(min, max IntegerExpression) BoolExpression {
return NewBetweenOperatorExpression(i.parent, min, max, false)
}
func (i *integerInterfaceImpl) NOT_BETWEEN(min, max IntegerExpression) BoolExpression {
return NewBetweenOperatorExpression(i.parent, min, max, true)
}
func (i *integerInterfaceImpl) ADD(rhs IntegerExpression) IntegerExpression {
return IntExp(Add(i.parent, rhs))
}