|
@@ -47,6 +47,7 @@ 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 where_conditions identifier identifier_or_const_value
|
|
%type <jv> where_condition_item where_conditions identifier identifier_or_const_value
|
|
|
|
+%type <jv> delete_stmt
|
|
|
|
|
|
%start statement
|
|
%start statement
|
|
|
|
|
|
@@ -60,6 +61,7 @@ statement: NEWLINE
|
|
sql_statement: create_table_stmt
|
|
sql_statement: create_table_stmt
|
|
| insert_stmt
|
|
| insert_stmt
|
|
| update_stmt
|
|
| update_stmt
|
|
|
|
+ | delete_stmt
|
|
;
|
|
;
|
|
|
|
|
|
create_table_stmt: CREATE TABLE IDENTIFIER NEWLINE
|
|
create_table_stmt: CREATE TABLE IDENTIFIER NEWLINE
|
|
@@ -231,6 +233,14 @@ bin_compare_op: '=' {$$ = "=";}
|
|
| "!=" {$$ = "!=";}
|
|
| "!=" {$$ = "!=";}
|
|
;
|
|
;
|
|
|
|
|
|
|
|
+delete_stmt: DELETE FROM IDENTIFIER WHERE where_conditions NEWLINE {
|
|
|
|
+ cJSON* node = cJSON_CreateObject();
|
|
|
|
+ cJSON_AddStringToObject(node, "type", "delete");
|
|
|
|
+ cJSON_AddStringToObject(node, "table_name", $3);
|
|
|
|
+ cJSON_AddItemToObject(node, "where", $5);
|
|
|
|
+ cJSON_AddItemToArray(jroot, node);
|
|
|
|
+ $$=node;
|
|
|
|
+};
|
|
%%
|
|
%%
|
|
|
|
|
|
int main(int ac, char** av) {
|
|
int main(int ac, char** av) {
|