a/c2iec.y | b/c2iec.y | ||
---|---|---|---|
... |
... |
||
321 | isFuncDecl = 1; |
321 | isFuncDecl = 1; |
322 | } |
322 | } |
323 | while( (p=fifo_pop(decl_param)) != NULL) |
323 | while( (p=fifo_pop(decl_param)) != NULL) |
324 | { |
324 | { |
325 | printf(p, $<str>1); |
325 | printf(p, $<str>1); |
326 | isFuncDecl = 0; |
326 | // isFuncDecl = 0; |
327 | } |
327 | } |
328 | while( (p=fifo_pop(decl_all)) != NULL) |
328 | while( (p=fifo_pop(decl_all)) != NULL) |
329 | { |
329 | { |
330 | printf(p, $<str>1); |
330 | printf(p, $<str>1); |
331 | isFuncDecl = 0; |
331 | isFuncDecl = 0; |
... |
... |
||
514 | declarator |
514 | declarator |
515 | : pointer direct_declarator |
515 | : pointer direct_declarator |
516 | { |
516 | { |
517 | sprintf($<str>$, "%s: POINTER TO %%s;\n",$<str>2); |
517 | sprintf($<str>$, "%s: POINTER TO %%s;\n",$<str>2); |
518 | // don't push function declarations to decl_all |
518 | // don't push function declarations to decl_all |
519 | // if (fifo_empty(decl_func)) |
||
520 | { |
||
521 | fifo_push(decl_all, $<str>$); |
||
522 | } |
||
523 | } |
||
524 | | direct_declarator |
||
525 | { |
||
526 | if (strlen($<str>1) > 0) |
||
527 | { |
||
528 | sprintf($<str>$, "%s: %%s;\n",$<str>1); |
||
529 | // don't push function declarations to decl_all |
||
530 | // if (fifo_empty(decl_func)) |
||
531 | { |
||
532 | fifo_push(decl_all, $<str>$); |
||
533 | } |
||
534 | } |
||
535 | } |
||
536 | ; |
||
537 | |||
538 | declarator_funcdef |
||
539 | : pointer direct_declarator |
||
540 | { |
||
541 | sprintf($<str>$, "%s: POINTER TO %%s;\n",$<str>2); |
||
542 | // don't push function declarations to decl_all |
||
519 | if (fifo_empty(decl_func)) |
543 | if (fifo_empty(decl_func)) |
520 | { |
544 | { |
521 | fifo_push(decl_all, $<str>$); |
545 | fifo_push(decl_all, $<str>$); |
522 | } |
546 | } |
523 | } |
547 | } |
... |
... |
||
776 | : function_definition |
800 | : function_definition |
777 | | declaration |
801 | | declaration |
778 | ; |
802 | ; |
779 | 803 | ||
780 | function_definition |
804 | function_definition |
781 | : declaration_specifiers declarator declaration_list compound_statement |
805 | : declaration_specifiers declarator_funcdef declaration_list compound_statement |
782 | { |
806 | { |
783 | printf("%s %s %s %s", $<str>1, $<str>2, $<str>3, $<str>4); |
807 | printf("%s %s %s %s", $<str>1, $<str>2, $<str>3, $<str>4); |
784 | } |
808 | } |
785 | | declaration_specifiers declarator compound_statement |
809 | | declaration_specifiers declarator_funcdef compound_statement |
786 | { |
810 | { |
787 | char *p; |
811 | char *p; |
788 | while( (p=fifo_pop(decl_func)) != NULL) |
812 | while( (p=fifo_pop(decl_func)) != NULL) |
789 | { |
813 | { |
790 | printf(p, $<str>1); |
814 | printf(p, $<str>1); |