From: nishi Date: Tue, 4 Jun 2024 22:15:41 +0000 (+0000) Subject: add stuff X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=f7cd10435668bcc100db3088fd1a41d26b84d2cb;p=dataworks.git add stuff git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@148 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Library/exec.c b/Library/exec.c index 46a59ea..bd6b84e 100644 --- a/Library/exec.c +++ b/Library/exec.c @@ -35,6 +35,29 @@ #include #include +void print_node(struct Node* node, bool top) { + printf("%s(", node->ident); + if(node->nodes != NULL) { + int i; + for(i = 0; node->nodes[i] != NULL; i++) { + if(i > 0) printf(", "); + if(node->nodes[i]->ident != NULL) { + print_node(node->nodes[i], false); + } else { + printf("\"%s\"", node->nodes[i]->string); + } + } + } + printf(")"); + if(top) printf("\n"); +} + +void parser_process(struct Node* node, bool dolog) { + if(node->ident != NULL) { + if(dolog) print_node(node, true); + } +} + struct dataworks_db_result* dataworks_database_execute_code(struct dataworks_db* db, const char* code, bool dolog) { struct dataworks_db_result* r = malloc(sizeof(*r)); r->error = false; @@ -44,6 +67,8 @@ struct dataworks_db_result* dataworks_database_execute_code(struct dataworks_db* if((node = __dw_parser_parse(code, dolog)) == NULL) { r->error = true; r->errnum = DW_ERR_PARSER_FAIL; + }else{ + parser_process(node, dolog); } return r; diff --git a/Library/parser.c b/Library/parser.c index 31160f1..a251f33 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -43,30 +43,6 @@ extern int yyparse(void); extern void* yy_scan_string(const char* str); extern void yy_delete_buffer(void* buffer); -void print_node(struct Node* node, bool top) { - printf("%s(", node->ident); - if(node->nodes != NULL) { - int i; - for(i = 0; node->nodes[i] != NULL; i++) { - if(i > 0) printf(", "); - if(node->nodes[i]->ident != NULL) { - print_node(node->nodes[i], false); - } else { - printf("\"%s\"", node->nodes[i]->string); - } - } - } - printf(")"); - if(top) printf("\n"); -} - -void parser_process(struct Node* node) { - if(node->ident != NULL) { - int i; - print_node(node, true); - } -} - struct Node* __dw_parser_parse(const char* str, bool top) { extern YYSTYPE yyval; #ifdef PARSER_DEBUG @@ -78,7 +54,6 @@ struct Node* __dw_parser_parse(const char* str, bool top) { yy_delete_buffer(buf); return NULL; } - parser_process(&yyval.node); yy_delete_buffer(buf); return &yyval.node;