a/c2iec.y | b/c2iec.y | ||
---|---|---|---|
... |
... |
||
67 | void fifo_tag(fifo_entry_t type); |
67 | void fifo_tag(fifo_entry_t type); |
68 | 68 | ||
69 | // check if fifo is empty |
69 | // check if fifo is empty |
70 | int fifo_empty(fifo_entry_t type); |
70 | int fifo_empty(fifo_entry_t type); |
71 | 71 | ||
72 | // check fill status of queue |
||
73 | int fifo_size(fifo_entry_t type); |
||
74 | |||
72 | // map c datatype to iec (standard and userdefined) |
75 | // map c datatype to iec (standard and userdefined) |
73 | char *maptype(char *ctype); |
76 | char *maptype(char *ctype); |
74 | 77 | ||
75 | // get identifier from payload data |
78 | // get identifier from payload data |
76 | // when used e.g. with the declarator of a struct, |
79 | // when used e.g. with the declarator of a struct, |
... |
... |
||
94 | // define function name of current context |
97 | // define function name of current context |
95 | static char s_szFuncName[SYM_SIZE]; |
98 | static char s_szFuncName[SYM_SIZE]; |
96 | void setFunctionName(char *szName); |
99 | void setFunctionName(char *szName); |
97 | char *getFunctionName(void); |
100 | char *getFunctionName(void); |
98 | 101 | ||
99 | |||
100 | // lex/yacc functions |
102 | // lex/yacc functions |
101 | extern int yylex (void); |
103 | extern int yylex (void); |
102 | %} |
104 | %} |
103 | 105 | ||
104 | %% |
106 | %% |
... |
... |
||
310 | strcpy($<str>$, ""); |
312 | strcpy($<str>$, ""); |
311 | } |
313 | } |
312 | | declaration_specifiers init_declarator_list ';' |
314 | | declaration_specifiers init_declarator_list ';' |
313 | { |
315 | { |
314 | char *p; |
316 | char *p; |
317 | int isFuncDecl = 0; |
||
315 | while( (p=fifo_pop(decl_func)) != NULL) |
318 | while( (p=fifo_pop(decl_func)) != NULL) |
316 | { |
319 | { |
317 | printf(p, $<str>1); |
320 | printf(p, $<str>1); |
321 | isFuncDecl = 1; |
||
318 | } |
322 | } |
319 | while( (p=fifo_pop(decl_param)) != NULL) |
323 | while( (p=fifo_pop(decl_param)) != NULL) |
320 | { |
324 | { |
321 | printf(p, $<str>1); |
325 | printf(p, $<str>1); |
326 | isFuncDecl = 0; |
||
322 | } |
327 | } |
323 | while( (p=fifo_pop(decl_all)) != NULL) |
328 | while( (p=fifo_pop(decl_all)) != NULL) |
324 | { |
329 | { |
325 | printf(p, $<str>1); |
330 | printf(p, $<str>1); |
331 | isFuncDecl = 0; |
||
326 | } |
332 | } |
327 | strcpy($<str>$, ""); |
333 | strcpy($<str>$, ""); |
334 | if (isFuncDecl) |
||
335 | printf("END_FUNCTION\n\n"); |
||
328 | } |
336 | } |
329 | ; |
337 | ; |
330 | 338 | ||
331 | declaration_specifiers |
339 | declaration_specifiers |
332 | : storage_class_specifier |
340 | : storage_class_specifier |
... |
... |
||
528 | ; |
536 | ; |
529 | 537 | ||
530 | direct_declarator |
538 | direct_declarator |
531 | : IDENTIFIER |
539 | : IDENTIFIER |
532 | | '(' declarator ')' |
540 | | '(' declarator ')' |
533 | { printf ("not supported direct_declerator\n"); } |
541 | { printf ("not supported direct_declerator\n"); exit(-1); } |
534 | | direct_declarator '[' type_qualifier_list assignment_expression ']' |
542 | | direct_declarator '[' type_qualifier_list assignment_expression ']' |
535 | { printf ("not supported direct_declerator\n"); } |
543 | { printf ("not supported direct_declerator\n"); exit(-1); } |
536 | | direct_declarator '[' type_qualifier_list ']' |
544 | | direct_declarator '[' type_qualifier_list ']' |
537 | { printf ("not supported direct_declerator\n"); } |
545 | { printf ("not supported direct_declerator\n"); exit(-1); } |
538 | | direct_declarator '[' assignment_expression ']' |
546 | | direct_declarator '[' assignment_expression ']' |
539 | { |
547 | { |
540 | if (strlen($<str>1) > 0) |
548 | if (strlen($<str>1) > 0) |
541 | { |
549 | { |
542 | sprintf($<str>$, "%s: ARRAY[0..(%s-1)] OF %%s;\n",$<str>1, $<str>3); |
550 | sprintf($<str>$, "%s: ARRAY[0..(%s-1)] OF %%s;\n",$<str>1, $<str>3); |
... |
... |
||
788 | while( (p=fifo_pop(decl_all)) != NULL) |
796 | while( (p=fifo_pop(decl_all)) != NULL) |
789 | { |
797 | { |
790 | printf(p, $<str>1); |
798 | printf(p, $<str>1); |
791 | } |
799 | } |
792 | printf("%s", $<str>3); |
800 | printf("%s", $<str>3); |
801 | printf("END_FUNCTION\n"); |
||
793 | strcpy($<str>$, ""); |
802 | strcpy($<str>$, ""); |
794 | } |
803 | } |
795 | ; |
804 | ; |
796 | 805 | ||
797 | declaration_list |
806 | declaration_list |
... |
... |
||
861 | return 1; |
870 | return 1; |
862 | } |
871 | } |
863 | return 0; |
872 | return 0; |
864 | } |
873 | } |
865 | 874 | ||
875 | int fifo_size(fifo_entry_t type) |
||
876 | { |
||
877 | return ((s_fifos[type].write + FIFO_SIZE) - s_fifos[type].read) % FIFO_SIZE; |
||
878 | } |
||
879 | |||
866 | void fifo_tag(fifo_entry_t type) |
880 | void fifo_tag(fifo_entry_t type) |
867 | { |
881 | { |
868 | char *p; |
882 | char *p; |
869 | while ((p = fifo_pop(decl_all)) != NULL) |
883 | while ((p = fifo_pop(decl_all)) != NULL) |
870 | fifo_push(type, p); |
884 | fifo_push(type, p); |