--- a/c2iec.y +++ b/c2iec.y @@ -323,7 +323,7 @@ while( (p=fifo_pop(decl_param)) != NULL) { printf(p, $<str>1); - isFuncDecl = 0; +// isFuncDecl = 0; } while( (p=fifo_pop(decl_all)) != NULL) { @@ -516,6 +516,30 @@ { sprintf($<str>$, "%s: POINTER TO %%s;\n",$<str>2); // don't push function declarations to decl_all +// if (fifo_empty(decl_func)) + { + fifo_push(decl_all, $<str>$); + } + } + | direct_declarator + { + if (strlen($<str>1) > 0) + { + sprintf($<str>$, "%s: %%s;\n",$<str>1); + // don't push function declarations to decl_all +// if (fifo_empty(decl_func)) + { + fifo_push(decl_all, $<str>$); + } + } + } + ; + +declarator_funcdef + : pointer direct_declarator + { + sprintf($<str>$, "%s: POINTER TO %%s;\n",$<str>2); + // don't push function declarations to decl_all if (fifo_empty(decl_func)) { fifo_push(decl_all, $<str>$); @@ -778,11 +802,11 @@ ; function_definition - : declaration_specifiers declarator declaration_list compound_statement + : declaration_specifiers declarator_funcdef declaration_list compound_statement { printf("%s %s %s %s", $<str>1, $<str>2, $<str>3, $<str>4); } - | declaration_specifiers declarator compound_statement + | declaration_specifiers declarator_funcdef compound_statement { char *p; while( (p=fifo_pop(decl_func)) != NULL)