a/c2iec.y | b/c2iec.y | ||
---|---|---|---|
... |
... |
||
29 | #define FIFO_SIZE 200 |
29 | #define FIFO_SIZE 200 |
30 | 30 | ||
31 | typedef enum |
31 | typedef enum |
32 | { |
32 | { |
33 | decl_all, |
33 | decl_all, |
34 | decl_inout, |
34 | decl_func, |
35 | decl_var, |
||
36 | fifo_entry_num /* reflects the number of enum entries */ |
35 | fifo_entry_num /* reflects the number of enum entries */ |
37 | } fifo_entry_t; |
36 | } fifo_entry_t; |
38 | 37 | ||
39 | typedef struct |
38 | typedef struct |
40 | { |
39 | { |
... |
... |
||
283 | strcpy($<str>$, ""); |
282 | strcpy($<str>$, ""); |
284 | } |
283 | } |
285 | | declaration_specifiers init_declarator_list ';' |
284 | | declaration_specifiers init_declarator_list ';' |
286 | { |
285 | { |
287 | char *p; |
286 | char *p; |
288 | while( (p=fifo_pop(decl_all)) != NULL) |
287 | while( (p=fifo_pop(decl_func)) != NULL) |
289 | { |
288 | { |
290 | // sprintf(TAIL($<str>$), p, $<str>1); |
289 | printf(p, $<str>1); |
290 | strcpy($<str>$, ""); |
||
291 | } |
||
292 | while( (p=fifo_pop(decl_all)) != NULL) |
||
293 | { |
||
291 | printf(p, $<str>1); |
294 | printf(p, $<str>1); |
292 | strcpy($<str>$, ""); |
295 | strcpy($<str>$, ""); |
293 | } |
296 | } |
294 | } |
297 | } |
295 | ; |
298 | ; |
... |
... |
||
396 | char *p; |
399 | char *p; |
397 | while( (p=fifo_pop(decl_all)) != NULL) |
400 | while( (p=fifo_pop(decl_all)) != NULL) |
398 | { |
401 | { |
399 | strcpy($<str>$, ""); |
402 | strcpy($<str>$, ""); |
400 | sprintf(TAIL($<str>$), p, $<str>1); |
403 | sprintf(TAIL($<str>$), p, $<str>1); |
401 | // printf(p, $<str>1); |
||
402 | // strcpy($<str>$, ""); |
||
403 | } |
404 | } |
404 | } |
405 | } |
405 | | unnamed_struct_or_union_specifier ';' |
406 | | unnamed_struct_or_union_specifier ';' |
406 | ; |
407 | ; |
407 | 408 | ||
... |
... |
||
515 | | direct_declarator '[' '*' ']' |
516 | | direct_declarator '[' '*' ']' |
516 | | direct_declarator '[' ']' |
517 | | direct_declarator '[' ']' |
517 | | direct_declarator '(' parameter_type_list ')' |
518 | | direct_declarator '(' parameter_type_list ')' |
518 | { |
519 | { |
519 | sprintf($<str>$, "FUNCTION %s:%%s;\n",$<str>1); |
520 | sprintf($<str>$, "FUNCTION %s:%%s;\n",$<str>1); |
520 | fifo_push(decl_all, $<str>$); |
521 | fifo_push(decl_func, $<str>$); |
521 | strcpy($<str>$, $<str>1); |
522 | strcpy($<str>$, $<str>1); |
522 | strcpy($<str>$, ""); |
523 | strcpy($<str>$, ""); |
523 | } |
524 | } |
524 | | direct_declarator '(' identifier_list ')' |
525 | | direct_declarator '(' identifier_list ')' |
525 | { |
526 | { |
526 | sprintf($<str>$, "FUNCTION %s:%%s;\n",$<str>1); |
527 | sprintf($<str>$, "FUNCTION %s:%%s;\n",$<str>1); |
527 | fifo_push(decl_all, $<str>$); |
528 | fifo_push(decl_func, $<str>$); |
528 | strcpy($<str>$, $<str>1); |
529 | strcpy($<str>$, $<str>1); |
529 | strcpy($<str>$, ""); |
530 | strcpy($<str>$, ""); |
530 | } |
531 | } |
531 | | direct_declarator '(' ')' |
532 | | direct_declarator '(' ')' |
532 | { |
533 | { |
533 | sprintf($<str>$, "FUNCTION %s:%%s;\n",$<str>1); |
534 | sprintf($<str>$, "FUNCTION %s:%%s;\n",$<str>1); |
534 | fifo_push(decl_all, $<str>$); |
535 | fifo_push(decl_func, $<str>$); |
535 | strcpy($<str>$, ""); |
536 | strcpy($<str>$, ""); |
536 | strcpy($<str>$, ""); |
537 | strcpy($<str>$, ""); |
537 | } |
538 | } |
538 | ; |
539 | ; |
539 | 540 | ||
... |
... |
||
711 | printf("%s %s %s %s", $<str>1, $<str>2, $<str>3, $<str>4); |
712 | printf("%s %s %s %s", $<str>1, $<str>2, $<str>3, $<str>4); |
712 | } |
713 | } |
713 | | declaration_specifiers declarator compound_statement |
714 | | declaration_specifiers declarator compound_statement |
714 | { |
715 | { |
715 | char *p; |
716 | char *p; |
717 | while( (p=fifo_pop(decl_func)) != NULL) |
||
718 | { |
||
719 | printf(p, $<str>1); |
||
720 | } |
||
716 | while( (p=fifo_pop(decl_all)) != NULL) |
721 | while( (p=fifo_pop(decl_all)) != NULL) |
717 | { |
722 | { |
718 | printf(p, $<str>1); |
723 | printf(p, $<str>1); |
719 | } |
724 | } |
720 | printf("%s", $<str>3); |
725 | printf("%s", $<str>3); |