From d0acc35dbeb476e54f02b74534547999475bb990 Mon Sep 17 00:00:00 2001 From: nishi Date: Tue, 25 Jun 2024 04:53:30 +0000 Subject: [PATCH] fix grammar, and add result git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@432 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Grammar/dw.y | 1 + Library/dw_database.h | 3 +-- Library/exec.c | 6 ++++++ Library/parser.c | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Grammar/dw.y b/Grammar/dw.y index b75f5f8..ed674f9 100644 --- a/Grammar/dw.y +++ b/Grammar/dw.y @@ -46,6 +46,7 @@ double number; unsigned char logical; struct Node** nodes; + void* result; } node; } diff --git a/Library/dw_database.h b/Library/dw_database.h index 24de8ca..6dba8d8 100644 --- a/Library/dw_database.h +++ b/Library/dw_database.h @@ -607,14 +607,13 @@ void dataworks_database_free_result(struct dataworks_db_result* result); * @brief Inserts the record. * @param db Database * @param records Records - * @param fields Fields in binary * @param prop List which contains character `U` or `S` * - `U` indicates the field is unset * - `S` indicates the field is set * @return Result * */ -struct dataworks_db_result* dataworks_database_insert_record(struct dataworks_db* db, void** fields, const char* prop); +struct dataworks_db_result* dataworks_database_insert_record(struct dataworks_db* db, void** records, const char* prop); /** * @~english diff --git a/Library/exec.c b/Library/exec.c index 5b00a12..ae44b87 100644 --- a/Library/exec.c +++ b/Library/exec.c @@ -47,6 +47,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol newnode->string = NULL; newnode->nodes = NULL; newnode->type = 0; + newnode->result = NULL; newnode->errnum = DW_ERR_SUCCESS; char** fields = malloc(sizeof(*fields)); fields[0] = NULL; @@ -74,6 +75,8 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol if(__dw_strcaseequ(node->ident, "print")) { if(r->type == 'N') { printf("%f", r->number); + } else if(r->type == 'L') { + printf("%c", r->logical ? 'T' : 'F'); } else if(r->string != NULL) { printf("%s", r->string); } @@ -148,6 +151,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol free(val); } used = true; + } else if(__dw_strcaseequ(node->ident, "insert")) { } else { int j; for(i = 0; fields[i] != NULL; i++) free(fields[i]); @@ -176,6 +180,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol } else { newnode->errnum = DW_ERR_EXEC_INSUFFICIENT_ARGUMENTS; } + } else if(__dw_strcaseequ(node->ident, "insert")) { } else if(!used) { newnode->errnum = DW_ERR_EXEC_UNKNOWN_METHOD; } @@ -187,6 +192,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol } else { struct Node* n = __dw_duplicate_node(node); n->errnum = DW_ERR_SUCCESS; + n->result = NULL; return n; } } diff --git a/Library/parser.c b/Library/parser.c index 44ef2bb..1b9bfc6 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -71,6 +71,7 @@ struct Node* __dw_duplicate_node(struct Node* node) { r->string = NULL; r->nodes = NULL; r->number = node->number; + r->logical = node->logical; r->type = node->type; if(node->ident != NULL) r->ident = __dw_strdup(node->ident); if(node->string != NULL) r->string = __dw_strdup(node->string); @@ -106,6 +107,10 @@ bool __dw_print_node(struct Node* node, bool top) { printf("%f", node->number); fflush(stdout); return true; + } else if(node->type == 'L') { + printf("%c", node->logical ? 'T' : 'F'); + fflush(stdout); + return true; } else if(node->string != NULL) { printf("\""); fflush(stdout); -- 2.43.0