2021-06-10 07:43:49 +08:00
|
|
|
|
```haskell
|
|
|
|
|
Expr :=
|
|
|
|
|
LogicalExpr | NIL
|
|
|
|
|
|
|
|
|
|
LogicalExpr :=
|
|
|
|
|
LogicalExpr BinaryLogicalOp LogicalExpr
|
|
|
|
|
| UnaryLogicalOp LogicalExpr
|
|
|
|
|
| "(" LogicalExpr ")"
|
|
|
|
|
| SingleExpr
|
|
|
|
|
|
|
|
|
|
BinaryLogicalOp :=
|
|
|
|
|
"&&" | "and"
|
|
|
|
|
| "||" | "or"
|
|
|
|
|
|
|
|
|
|
UnaryLogicalOp :=
|
|
|
|
|
"not"
|
|
|
|
|
|
|
|
|
|
SingleExpr :=
|
|
|
|
|
TermExpr
|
|
|
|
|
| CompareExpr
|
|
|
|
|
|
|
|
|
|
TermExpr :=
|
|
|
|
|
IDENTIFIER "in" ConstantArray
|
|
|
|
|
|
|
|
|
|
ConstantArray :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
"[" ConstantExpr { "," ConstantExpr } "]"
|
|
|
|
|
|
|
|
|
|
ConstantExpr :=
|
|
|
|
|
Constant
|
|
|
|
|
| ConstantExpr BinaryArithOp ConstantExpr
|
|
|
|
|
| UnaryArithOp ConstantExpr
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
|
|
|
|
Constant :=
|
|
|
|
|
INTERGER
|
2021-07-15 11:25:54 +08:00
|
|
|
|
| FLOAT_NUMBER
|
|
|
|
|
|
|
|
|
|
UnaryArithOp :=
|
|
|
|
|
"+"
|
|
|
|
|
| "-"
|
|
|
|
|
|
|
|
|
|
BinaryArithOp :=
|
|
|
|
|
"+"
|
|
|
|
|
| "-"
|
|
|
|
|
| "*"
|
|
|
|
|
| "/"
|
|
|
|
|
| "%"
|
|
|
|
|
| "**"
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
|
|
|
|
CompareExpr :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
IDENTIFIER CmpOp IDENTIFIER
|
|
|
|
|
| IDENTIFIER CmpOp ConstantExpr
|
|
|
|
|
| ConstantExpr CmpOp IDENTIFIER
|
|
|
|
|
| ConstantExpr CmpOpRestricted IDENTIFIER CmpOpRestricted ConstantExpr
|
|
|
|
|
|
|
|
|
|
CmpOpRestricted :=
|
|
|
|
|
"<"
|
|
|
|
|
| "<="
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
|
|
|
|
CmpOp :=
|
|
|
|
|
">"
|
|
|
|
|
| ">="
|
|
|
|
|
| "<"
|
|
|
|
|
| "<="
|
|
|
|
|
| "=="
|
|
|
|
|
| "!="
|
|
|
|
|
|
|
|
|
|
INTERGER := 整数
|
|
|
|
|
FLOAT_NUM := 浮点数
|
|
|
|
|
IDENTIFIER := 列名
|
|
|
|
|
```
|
|
|
|
|
|
2021-07-15 11:25:54 +08:00
|
|
|
|
Tips:
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-07-15 11:25:54 +08:00
|
|
|
|
1. NIL represent a empty string, which means there is no Predicate for Expr.
|
|
|
|
|
2. Gramma is described by EBNF syntax,expressions that may be omitted or repeated are represented through curly braces `{...}`.
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-07-15 11:25:54 +08:00
|
|
|
|
After syntax analysis, following rules will be applied:
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-07-15 11:25:54 +08:00
|
|
|
|
1. non-vector column must exist in Schema.
|
|
|
|
|
2. CompareExpr/TermExpr requires operand type matching.
|
|
|
|
|
3. CompareExpr between non-vector columns of different types is available
|
|
|
|
|
4. The modulo operation requires all operands to be integers.
|
|
|
|
|
5. Integer columns can only match integer operands. But float columns can match both integer and float operands.
|
|
|
|
|
6. In BinaryOp, the `and`/`&&` operator has higher priority than the `or`/`||` operator
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-07-15 11:25:54 +08:00
|
|
|
|
example:
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
A > 3 && A < 4 && (C > 5 || D < 6)
|
2021-07-15 11:25:54 +08:00
|
|
|
|
1 < A <= 2.0 + 3 - 4 * 5 / 6 % 7 ** 8
|
|
|
|
|
A == B
|
2021-06-10 07:43:49 +08:00
|
|
|
|
FloatCol in [1.0, 2, 3.0]
|
|
|
|
|
Int64Col in [1, 2, 3] or C != 6
|
|
|
|
|
```
|