struct Node {
char* string;
char* ident;
- struct Node* nodes;
+ struct Node** nodes;
} node;
}
;
arguments
- : single_argument
- | arguments ',' single_argument
+ : single_argument {
+ $<node>$.nodes = malloc(sizeof(*$<node>$.nodes) * 2);
+ $<node>$.nodes[0] = &$<node>1;
+ $<node>$.nodes[1] = NULL;
+ }
+ | arguments ',' single_argument {
+ struct Node** old_nodes = $<node>$.nodes;
+ int i;
+ for(i = 0; old_nodes[i] != NULL; i++);
+ $<node>$.nodes = malloc(sizeof(*$<node>$.nodes) * (i + 2));
+ for(i = 0; old_nodes[i] != NULL; i++) $<node>$.nodes[i] = old_nodes[i];
+ $<node>$.nodes[i] = &$<node>3;
+ $<node>$.nodes[i + 1] = NULL;
+ free(old_nodes);
+ }
| SPACE
| ;
;
command
: IDENTIFIER SPACE '(' arguments ')' {
- printf("%s\n", $<node>1.ident);
+ printf("%s %p\n", $<node>1.ident, $<node>1.nodes);
}
| IDENTIFIER '(' arguments ')' {
- printf("%s\n", $<node>1.ident);
+ printf("%s %p\n", $<node>1.ident, $<node>1.nodes);
}
;
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);
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 =
$(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