]> Nishi Git Mirror - dataworks.git/commitdiff
add stuff
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Tue, 4 Jun 2024 22:15:41 +0000 (22:15 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Tue, 4 Jun 2024 22:15:41 +0000 (22:15 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@148 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Library/exec.c
Library/parser.c

index 46a59ea2b522204f9896ed855a25a0da01dfd755..bd6b84e831ccf8e79022b51507437642e4f7116d 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+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;
index 31160f1310bdb3bfd4cb2fe6512e774c8626cbb4..a251f332556fd4b26f22dd97dfc85e3bee32a155 100644 (file)
@@ -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;