|
@@ -59,7 +59,7 @@ cJSON* jroot;
|
|
|
|
|
|
%token IDENTIFIER
|
|
%token IDENTIFIER
|
|
|
|
|
|
-%token SELECT FROM WHERE INSERT INTO VALUES DELETE UPDATE SET JOIN CREATE TABLE
|
|
|
|
|
|
+%token SELECT FROM WHERE INSERT INTO VALUES DELETE UPDATE SET JOIN CREATE TABLE DROP
|
|
%token AS ON
|
|
%token AS ON
|
|
%token AND OR NOT IN
|
|
%token AND OR NOT IN
|
|
%token INT_V FLOAT_V STRING_V // 作为 value 出现的
|
|
%token INT_V FLOAT_V STRING_V // 作为 value 出现的
|
|
@@ -78,9 +78,9 @@ cJSON* jroot;
|
|
%type <jv> insert_stmt insert_list
|
|
%type <jv> insert_stmt insert_list
|
|
%type <jv> update_stmt update_list single_assign_item
|
|
%type <jv> update_stmt update_list single_assign_item
|
|
%type <jv> where_condition_item identifier identifier_or_const_value
|
|
%type <jv> where_condition_item identifier identifier_or_const_value
|
|
-%type <jv> delete_stmt select_stmt select_item select_items
|
|
|
|
|
|
+%type <jv> delete_stmt select_stmt select_item select_items drop_stmt
|
|
%type <jv> data_value_list identifier_or_const_value_or_const_value_list
|
|
%type <jv> data_value_list identifier_or_const_value_or_const_value_list
|
|
-%type <jv> search_expr compare_expr single_expr expr where_expr logical_expr negative_expr op_where_expr expr_list contains_expr
|
|
|
|
|
|
+%type <jv> compare_expr single_expr where_expr logical_expr negative_expr op_where_expr expr_list contains_expr
|
|
%type <jv> op_join table_field column_name
|
|
%type <jv> op_join table_field column_name
|
|
|
|
|
|
|
|
|
|
@@ -109,6 +109,7 @@ sql_statement: create_table_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
| update_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
| update_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
| delete_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
| delete_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
| select_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
| select_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
|
|
+ | drop_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
|
|
;
|
|
;
|
|
|
|
|
|
create_table_stmt: CREATE TABLE IDENTIFIER
|
|
create_table_stmt: CREATE TABLE IDENTIFIER
|
|
@@ -424,6 +425,14 @@ select_item: single_expr {
|
|
}
|
|
}
|
|
;
|
|
;
|
|
|
|
|
|
|
|
+drop_stmt: DROP TABLE IDENTIFIER {
|
|
|
|
+ cJSON* node = cJSON_CreateObject();
|
|
|
|
+ cJSON_AddStringToObject(node, "type", "drop_table");
|
|
|
|
+ cJSON_AddStringToObject(node, "table_name", $3);
|
|
|
|
+ $$=node;
|
|
|
|
+ }
|
|
|
|
+;
|
|
|
|
+
|
|
%%
|
|
%%
|
|
|
|
|
|
int main(int ac, char** av) {
|
|
int main(int ac, char** av) {
|