Explorar el Código

同时解析多条sql

myuan hace 2 años
padre
commit
3a4991ce35
Se han modificado 1 ficheros con 6 adiciones y 3 borrados
  1. 6 3
      src/calc.y

+ 6 - 3
src/calc.y

@@ -91,17 +91,20 @@ cJSON* jroot;
 // %left '+' '-'
 // %left '+' '-'
 // %left '*' '/'
 // %left '*' '/'
 
 
-%start statement
+%start statements
 
 
 %%
 %%
 
 
+statements: statement
+	| statements statement
+;
+
 statement: NEWLINE
 statement: NEWLINE
 	| QUIT {printf("bye!\n"); exit(0); }
 	| QUIT {printf("bye!\n"); exit(0); }
 	| sql_statement 
 	| sql_statement 
 ;
 ;
 
 
-sql_statement: 
-create_table_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
+sql_statement: create_table_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
 	| insert_stmt NEWLINE {cJSON_AddItemToArray(jroot, $1);}
 	| insert_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);}