From: nishi Date: Wed, 12 Jun 2024 00:23:23 +0000 (+0000) Subject: Fix grammar and stuff X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0ffe811c6d0f59b0fe03a674a81f57ab3eb77223;p=dataworks.git Fix grammar and stuff git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@241 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Document/Doxyfile b/Document/Doxyfile index 862e7f3..af3c8b6 100644 --- a/Document/Doxyfile +++ b/Document/Doxyfile @@ -32,6 +32,6 @@ GENERATE_LATEX = NO HTML_EXTRA_STYLESHEET = doxygen-theme/doxygen-awesome.css HTML_COLORSTYLE = LIGHT -EXAMPLE_PATH = ../Client +EXAMPLE_PATH = ../Server ../Client EXAMPLE_RECURSIVE = YES EXAMPLE_PATTERNS = *.c diff --git a/Document/index.md b/Document/index.md index a5e62d7..e312d84 100644 --- a/Document/index.md +++ b/Document/index.md @@ -9,3 +9,4 @@ Crabware is a software-development division of Hinode Gakuen PC-Club. Contact: Nishi <nishi@nishi.boats> @example client.c +@example server.c diff --git a/Grammar/dw.l b/Grammar/dw.l index f90079f..98055cc 100644 --- a/Grammar/dw.l +++ b/Grammar/dw.l @@ -55,14 +55,22 @@ double __dw_atof(const char* str); return (STRING); } [ \t]*#.* { return (COMMENT); } -[a-zA-Z_][a-zA-Z0-9_\-]* { +[a-zA-Z_][a-zA-Z0-9_\-]+ { yylval.node.ident = strdup(yytext); yylval.node.nodes = NULL; yylval.node.string = NULL; yylval.node.type = 'I'; return (IDENTIFIER); } --?[0-9]+(\.[0-9]+)? { +[YTNF] { + yylval.node.ident = NULL; + yylval.node.nodes = NULL; + yylval.node.string = NULL; + yylval.node.logical = (yytext[0] == 'Y' || yytext[0] == 'T') ? 0xff : 0; + yylval.node.type = 'L'; + return (LOGICAL); +} +[\+-]?[0-9]+(\.[0-9]+)? { yylval.node.ident = NULL; yylval.node.nodes = NULL; yylval.node.string = NULL; diff --git a/Grammar/dw.y b/Grammar/dw.y index 35e453a..6a6e528 100644 --- a/Grammar/dw.y +++ b/Grammar/dw.y @@ -31,7 +31,7 @@ #include %} -%token IDENTIFIER STRING NUMBER SPACE COMMENT +%token IDENTIFIER STRING NUMBER SPACE COMMENT LOGICAL %start command %union { @@ -41,6 +41,7 @@ int errnum; char type; double number; + unsigned char logical; struct Node** nodes; } node; } @@ -59,7 +60,9 @@ argument $$.string = $1.string; $$.nodes = $1.nodes; $$.ident = $1.ident; + $$.number = $1.number; $$.type = $1.type; + $$.logical = $1.logical; } | NUMBER { $$.string = $1.string; @@ -67,6 +70,15 @@ argument $$.ident = $1.ident; $$.number = $1.number; $$.type = $1.type; + $$.logical = $1.logical; + } + | LOGICAL { + $$.string = $1.string; + $$.nodes = $1.nodes; + $$.ident = $1.ident; + $$.number = $1.number; + $$.type = $1.type; + $$.logical = $1.logical; } | command { $$ = $1; @@ -80,6 +92,7 @@ single_argument $$.ident = $2.ident; $$.number = $2.number; $$.type = $2.type; + $$.logical = $2.logical; } | SPACE argument { $$.string = $2.string; @@ -87,6 +100,7 @@ single_argument $$.ident = $2.ident; $$.number = $2.number; $$.type = $2.type; + $$.logical = $2.logical; } | argument SPACE { $$.string = $1.string; @@ -94,6 +108,7 @@ single_argument $$.ident = $1.ident; $$.number = $1.number; $$.type = $1.type; + $$.logical = $1.logical; } | argument { $$.string = $1.string; @@ -101,6 +116,7 @@ single_argument $$.ident = $1.ident; $$.number = $1.number; $$.type = $1.type; + $$.logical = $1.logical; } ; @@ -111,6 +127,7 @@ arguments $$.nodes[0]->nodes = NULL; $$.nodes[0]->ident = NULL; $$.nodes[0]->string = NULL; + $$.nodes[0]->logical = $1.logical; $$.nodes[0]->number = $1.number; $$.nodes[0]->type = $1.type; if($1.ident != NULL) $$.nodes[0]->ident = __dw_strdup($1.ident); @@ -128,6 +145,7 @@ arguments $$.nodes[i]->nodes = NULL; $$.nodes[i]->ident = NULL; $$.nodes[i]->string = NULL; + $$.nodes[i]->logical = $3.logical; $$.nodes[i]->number = $3.number; $$.nodes[i]->type = $3.type; if($3.ident != NULL) $$.nodes[i]->ident = __dw_strdup($3.ident); diff --git a/Library/exec.c b/Library/exec.c index 6fbc395..fa629e5 100644 --- a/Library/exec.c +++ b/Library/exec.c @@ -50,8 +50,10 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol char* fieldtypes = malloc(1); fieldtypes[0] = 0; char* name = NULL; + bool used = false; if(__dw_strcaseequ(node->ident, "version")) { newnode->string = __dw_strdup(dataworks_get_version()); + used = true; } if(node->nodes != NULL) { for(i = 0; node->nodes[i] != NULL; i++) { @@ -73,6 +75,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol printf("%s", r->string); } fflush(stdout); + used = true; } else if(__dw_strcaseequ(node->ident, "concat")) { if(r->string != NULL) { if(newnode->string == NULL) { @@ -83,6 +86,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol newnode->string = __dw_strcat(tmp, r->string); free(tmp); } + used = true; } else if(__dw_strcaseequ(node->ident, "use")) { if(name != NULL) { newnode->errnum = DW_ERR_EXEC_TOO_MANY_ARGUMENTS; @@ -97,6 +101,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol if(name == NULL) { name = __dw_strdup(r->string); } + used = true; } else if(__dw_strcaseequ(node->ident, "create_table")) { if(name == NULL) { name = __dw_strdup(r->string); @@ -139,6 +144,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol } free(val); } + used = true; } else { int j; for(i = 0; fields[i] != NULL; i++) free(fields[i]); @@ -167,7 +173,7 @@ struct Node* parser_process(struct dataworks_db* db, struct Node* node, bool dol } else { newnode->errnum = DW_ERR_EXEC_INSUFFICIENT_ARGUMENTS; } - } else { + } else if(!used) { newnode->errnum = DW_ERR_EXEC_UNKNOWN_METHOD; } if(name != NULL) free(name); diff --git a/dataworks.vim b/dataworks.vim index 4408c72..732340b 100644 --- a/dataworks.vim +++ b/dataworks.vim @@ -13,7 +13,7 @@ syn match dataworksString /\v'[^']+'/ display syn match dataworksNumber /\v[+-]?[0-9]+(\.[0-9]+)?/ display syn match dataworksComment /\v#.*$/ display syn region dataworksArgument start='(' end=')' fold transparent -syn match dataworksIdent /\v\c(create_table|use|insert|print|version|select|index)/ display +syn match dataworksIdent /\v\c(create_table|use|insert|print|version|select|index|concat)/ display hi def link dataworksString String hi def link dataworksNumber Number