From: nishi Date: Tue, 4 Jun 2024 03:29:52 +0000 (+0000) Subject: use floating not double X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=22145560c02ac4d7532083a0ab36dc30fe51f1cf;p=dataworks.git use floating not double git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@143 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Grammar/dw.y b/Grammar/dw.y index 16785fe..b68dd1e 100644 --- a/Grammar/dw.y +++ b/Grammar/dw.y @@ -38,7 +38,7 @@ struct Node { char* string; char* ident; - struct Node* nodes; + struct Node** nodes; } node; } @@ -66,18 +66,31 @@ single_argument ; arguments - : single_argument - | arguments ',' single_argument + : single_argument { + $$.nodes = malloc(sizeof(*$$.nodes) * 2); + $$.nodes[0] = &$1; + $$.nodes[1] = NULL; + } + | arguments ',' single_argument { + struct Node** old_nodes = $$.nodes; + int i; + for(i = 0; old_nodes[i] != NULL; i++); + $$.nodes = malloc(sizeof(*$$.nodes) * (i + 2)); + for(i = 0; old_nodes[i] != NULL; i++) $$.nodes[i] = old_nodes[i]; + $$.nodes[i] = &$3; + $$.nodes[i + 1] = NULL; + free(old_nodes); + } | SPACE | ; ; command : IDENTIFIER SPACE '(' arguments ')' { - printf("%s\n", $1.ident); + printf("%s %p\n", $1.ident, $1.nodes); } | IDENTIFIER '(' arguments ')' { - printf("%s\n", $1.ident); + printf("%s %p\n", $1.ident, $1.nodes); } ; diff --git a/Library/parser.c b/Library/parser.c index 20d7701..99f6f70 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -42,6 +42,10 @@ extern void* yy_scan_string(const char* str); extern void yy_delete_buffer(void* buffer); int __dw_parser_parse(const char* str, bool top) { +#ifdef PARSER_DEBUG + yydebug = 1; +#endif + void* buf = yy_scan_string(str); if(yyparse() != 0){ yy_delete_buffer(buf); diff --git a/common-decl.mk b/common-decl.mk index 723aa2b..73166eb 100644 --- a/common-decl.mk +++ b/common-decl.mk @@ -8,7 +8,7 @@ LEX = lex AR_ARGS = rcs \$$@ RANLIB = ranlib WINDRES = windres -CFLAGS = -g -std=c99 -D_DEFAULT_SOURCE +CFLAGS = -g -std=c99 -D_DEFAULT_SOURCE $(DEBUGFLAGS) LDFLAGS = -L`pwd`/Library YFLAGS = -d -t LFLAGS = diff --git a/common.mk b/common.mk index fd0c45c..93bb05e 100644 --- a/common.mk +++ b/common.mk @@ -72,7 +72,7 @@ archive: $(MAKE) archive-cleanup prepare-dosbox: no-doc - echo 'create_table("test", "string:key", "double:value");' > op.txt + echo 'create_table("test", "string:key", "floating:value");' > op.txt echo '.tables' >> op.txt echo "[cpu]" > dosbox.conf echo "cycles=12000" >> dosbox.conf