From d759a2473ff59a767639327cc53d9462aa9e87aa Mon Sep 17 00:00:00 2001 From: nishi Date: Wed, 22 May 2024 06:13:26 +0000 Subject: [PATCH] parse git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@79 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Client/main.c | 2 +- Library/dw_parser.h | 2 +- Library/parser.c | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Client/main.c b/Client/main.c index 6b6c476..c17e593 100644 --- a/Client/main.c +++ b/Client/main.c @@ -179,7 +179,7 @@ int main(int argc, char** argv) { printf("Unknown dot-command.\n"); } } else if(strlen(buf) > 0) { - struct __dw_token* token = __dw_parser_parse(buf); + struct __dw_token* token = __dw_parser_parse(NULL, buf); if(token != NULL) { if(token->error) { printf("%s\n", dataworks_database_strerror(token->errnum)); diff --git a/Library/dw_parser.h b/Library/dw_parser.h index 0ebfdca..cab2316 100644 --- a/Library/dw_parser.h +++ b/Library/dw_parser.h @@ -52,7 +52,7 @@ struct __dw_token { struct __dw_token* token; }; -struct __dw_token* __dw_parser_parse(const char* str); +struct __dw_token* __dw_parser_parse(const char* name, const char* str); #ifdef __cplusplus } diff --git a/Library/parser.c b/Library/parser.c index 0a70a9b..6ef9929 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -35,7 +35,7 @@ #include #include -struct __dw_token* __dw_parser_parse(const char* str) { +struct __dw_token* __dw_parser_parse(const char* name, const char* str) { struct __dw_token* token = malloc(sizeof(*token)); token->error = false; token->errnum = DW_ERR_SUCCESS; @@ -59,18 +59,14 @@ struct __dw_token* __dw_parser_parse(const char* str) { br = __dw_strcat(tmp, cbuf); free(tmp); } else { - printf("%s\n", br); - __dw_parser_parse(br); + printf("%s:%s\n", buf, br); + __dw_parser_parse(buf, br); } } else if(dq) { char* tmp = buf; buf = __dw_strcat(tmp, cbuf); free(tmp); } else if(str[i] == '(') { - printf("%s\n", buf); - free(buf); - buf = malloc(1); - buf[0] = 0; brace++; } else if(str[i] == ')') { brace--; -- 2.43.0