|
@@ -240,12 +240,13 @@ single_expr: identifier {$$=$1;}
|
|
|
$$=node;
|
|
|
}
|
|
|
| data_value {$$=$1;}
|
|
|
- | '(' single_expr ')' {$$=$2;}
|
|
|
+ // | '(' single_expr ')' {$$=$2;}
|
|
|
;
|
|
|
where_expr: logical_expr {
|
|
|
- MEET(logical_expr from where_expr);
|
|
|
+ MEET_JSON(logical_expr from where_expr, $1);
|
|
|
$$=$1;
|
|
|
}
|
|
|
+ | '(' where_expr ')' {$$=$2;}
|
|
|
;
|
|
|
op_where_expr: {$$=cJSON_CreateObject();}
|
|
|
| WHERE where_expr {$$=$2;}
|
|
@@ -253,57 +254,53 @@ op_where_expr: {$$=cJSON_CreateObject();}
|
|
|
compare_expr: compare_expr bin_cmp_op compare_expr {
|
|
|
fprintf(stderr, "compare_expr %s\n", $2);
|
|
|
SIMPLE_OP_NODE($$, $2, $1, $3);}
|
|
|
- | single_expr {MEET_JSON(single_expr from cmp, $1); $$=$1;}
|
|
|
- | where_expr {MEET(where_expr from cmp) $$=$1;}
|
|
|
+ | single_expr {MEET_JSON(single_expr from compare_expr, $1); $$=$1;}
|
|
|
+ | where_expr {MEET_JSON(where_expr from compare_expr, $1) $$=$1;}
|
|
|
|
|
|
;
|
|
|
negative_expr: NOT negative_expr {
|
|
|
fprintf(stderr, "negative_expr\n");
|
|
|
SIMPLE_OP_NODE_ONLY_LEFT($$, "非", $2);}
|
|
|
- | compare_expr {MEET(compare_expr from neg) $$=$1;}
|
|
|
- | where_expr {MEET(where_expr from neg) $$=$1;}
|
|
|
+ | compare_expr {MEET_JSON(compare_expr from negative_expr, $1) $$=$1;}
|
|
|
+ | where_expr {MEET(where_expr from negative_expr) $$=$1;}
|
|
|
;
|
|
|
logical_expr: logical_expr bin_logical_op negative_expr {
|
|
|
fprintf(stderr, "logical_expr %s\n", $2);
|
|
|
SIMPLE_OP_NODE($$, $2, $1, $3);}
|
|
|
- | negative_expr {MEET(negative_expr from log) $$=$1;}
|
|
|
- | single_expr {MEET(single_expr from log) $$=$1;}
|
|
|
- | '(' logical_expr ')' {$$=$2;}
|
|
|
+ | negative_expr {MEET_JSON(negative_expr from logical_expr, $1); $$=$1;}
|
|
|
+ | single_expr {MEET_JSON(single_expr from logical_expr, $1) $$=$1;}
|
|
|
+ // | '(' logical_expr ')' {$$=$2;}
|
|
|
;
|
|
|
|
|
|
-// expr: compare_expr
|
|
|
-// | negative_expr
|
|
|
-// | logical_expr
|
|
|
-// ;
|
|
|
|
|
|
-// compare_expr: expr bin_cmp_op single_expr
|
|
|
-
|
|
|
-// expr: expr bin_cmp_op expr {SIMPLE_OP_NODE($$, $2, $1, $3)}
|
|
|
-// | expr bin_cmp_op '(' expr ')' {SIMPLE_OP_NODE($$, $2, $1, $4)}
|
|
|
-// // | '(' expr ')' {$$=$2;}
|
|
|
-// // | NOT expr {SIMPLE_OP_NODE_ONLY_LEFT($$, "非", $2);
|
|
|
-// // fprintf(stderr, "非asd %s\n", cJSON_Print($2));
|
|
|
-// // }
|
|
|
-// ;
|
|
|
-// // expr: expr bin_logical_op expr {SIMPLE_OP_NODE($$, $2, $1, $3)}
|
|
|
-
|
|
|
-
|
|
|
-expr_list: where_expr {
|
|
|
- MEET(where_expr from expr_list);
|
|
|
+expr_list: {
|
|
|
+ MEET(empty expr_list);
|
|
|
+ cJSON* node = cJSON_CreateArray();
|
|
|
+ $$=node;
|
|
|
+ }
|
|
|
+ | logical_expr {
|
|
|
+ MEET_JSON(where_expr from expr_list, $1);
|
|
|
|
|
|
cJSON* node = cJSON_CreateArray();
|
|
|
cJSON_AddItemToArray(node, $1);
|
|
|
$$=node;
|
|
|
}
|
|
|
- | expr_list ',' where_expr {
|
|
|
- fprintf(stderr, "迭代 expr_list\n %s", cJSON_Print($1));
|
|
|
- cJSON_AddItemToArray($1, $3);
|
|
|
- $$=$1;
|
|
|
- }
|
|
|
-
|
|
|
-where_expr: where_expr bin_contains_op '(' expr_list ')' {SIMPLE_OP_NODE($$, $2, $1, $4)}
|
|
|
- | where_expr bin_contains_op '(' select_stmt ')' {SIMPLE_OP_NODE($$, $2, $1, $4)}
|
|
|
+ // | expr_list ',' logical_expr {
|
|
|
+ // fprintf(stderr, "迭代 expr_list\n %s", cJSON_Print($1));
|
|
|
+ // cJSON_AddItemToArray($1, $3);
|
|
|
+ // $$=$1;
|
|
|
+ // }
|
|
|
+;
|
|
|
|
|
|
+where_expr: logical_expr bin_contains_op '(' expr_list ')' {
|
|
|
+ MEET_JSON(logical_expr bin_contains_op expr_list, $2);
|
|
|
+ SIMPLE_OP_NODE($$, $2, $1, $4)
|
|
|
+ }
|
|
|
+ // | logical_expr bin_contains_op '(' select_stmt ')' {
|
|
|
+ // MEET_JSON(logical_expr bin_contains_op select_stmt, $2);
|
|
|
+ // SIMPLE_OP_NODE($$, $2, $1, $4)
|
|
|
+ // }
|
|
|
+;
|
|
|
|
|
|
identifier: IDENTIFIER {
|
|
|
cJSON* node = cJSON_CreateObject();
|
|
@@ -311,6 +308,8 @@ identifier: IDENTIFIER {
|
|
|
cJSON_AddStringToObject(node, "value", $1);
|
|
|
$$=node;
|
|
|
}
|
|
|
+;
|
|
|
+
|
|
|
identifier_or_const_value: identifier {$$=$1;}
|
|
|
| data_value {$$=$1;}
|
|
|
;
|
|
@@ -326,7 +325,7 @@ data_value_list: data_value {
|
|
|
;
|
|
|
identifier_or_const_value_or_const_value_list: identifier_or_const_value{$$=$1;}
|
|
|
| data_value_list {$$=$1;}
|
|
|
-
|
|
|
+;
|
|
|
where_condition_item: identifier_or_const_value bin_cmp_op identifier_or_const_value {
|
|
|
cJSON* node = cJSON_CreateObject();
|
|
|
cJSON_AddStringToObject(node, "type", $2);
|
|
@@ -350,10 +349,10 @@ bin_cmp_op: '=' {$$ = "相等";}
|
|
|
| ">=" {$$ = "大等";}
|
|
|
| "<=" {$$ = "小等";}
|
|
|
| "!=" {$$ = "不等";}
|
|
|
- | IN {$$ = "包含于";}
|
|
|
;
|
|
|
|
|
|
-unary_compare_op: NOT {$$ = "非";};
|
|
|
+unary_compare_op: NOT {$$ = "非";}
|
|
|
+;
|
|
|
|
|
|
bin_logical_op: AND {MEET(and from bin_log) $$ = "且";}
|
|
|
| OR {MEET(or from bin_log) $$ = "或";}
|
|
@@ -388,6 +387,7 @@ select_items: select_item {
|
|
|
cJSON_AddItemToArray($1, $3);
|
|
|
$$=$1;
|
|
|
}
|
|
|
+;
|
|
|
select_item: identifier_or_const_value {
|
|
|
cJSON* node = cJSON_CreateObject();
|
|
|
cJSON_AddStringToObject(node, "type", "select_column");
|
|
@@ -406,7 +406,6 @@ select_item: identifier_or_const_value {
|
|
|
cJSON_AddStringToObject(node, "type", "select_all_column");
|
|
|
$$=node;
|
|
|
}
|
|
|
- |
|
|
|
;
|
|
|
%%
|
|
|
|