15 char *loop [] = {"","n","m","/*BAD*/"};
16 char *names[] = {" ","[n]","[n][m]"};
17 char *pnames[]= {"","*","**"};
27 %token '(' ')' '[' ']'
30 %token <i> NUMBER UNIT
32 %type <s> attr_desc attr_id attr_type
39 printf("#ifdef SYSROFF_SWAP_IN\n");
42 printf("#ifdef SYSROFF_p\n");
47 printf("#ifdef SYSROFF_SWAP_OUT\n");
50 printf("#ifdef SYSROFF_PRINT\n");
51 printf("#include <stdio.h>\n");
52 printf("#include <stdlib.h>\n");
83 printf("\n\n\n#define IT_%s_CODE 0x%x\n", it,code);
84 printf("struct IT_%s { \n", it);
87 printf("void sysroff_swap_%s_in(ptr)\n",$2);
88 printf("struct IT_%s *ptr;\n", it);
90 printf("char raw[255];\n");
91 printf("\tint idx = 0 ;\n");
92 printf("\tint size;\n");
93 printf("memset(raw,0,255);\n");
94 printf("memset(ptr,0,sizeof(*ptr));\n");
95 printf("size = fillup(raw);\n");
98 printf("void sysroff_swap_%s_out(file,ptr,last)\n",$2);
99 printf("FILE * file;\n");
100 printf("struct IT_%s *ptr;\n", it);
101 printf("int last;\n");
103 printf("\tchar raw[255];\n");
104 printf("\tint idx = 16 ;\n");
105 printf("\tmemset (raw, 0, 255);\n");
106 printf("\tcode = IT_%s_CODE;\n", it);
109 printf("void sysroff_swap_%s_out(abfd,ptr)\n",$2);
110 printf("bfd * abfd;\n");
111 printf("struct IT_%s *ptr;\n",it);
113 printf("int idx = 0 ;\n");
116 printf("void sysroff_print_%s_out(ptr)\n",$2);
117 printf("struct IT_%s *ptr;\n", it);
119 printf("itheader(\"%s\", IT_%s_CODE);\n",$2,$2);
135 printf("\tchecksum(file,raw, idx, IT_%s_CODE, last);\n", it);
149 it_field it_field_list
150 | cond_it_field it_field_list
151 | repeat_it_field it_field_list
155 repeat_it_field: '(' REPEAT NAME
162 printf("\tprintf(\"repeat %%d\\n\", %s);\n",$3);
164 printf("\tprintf(\"repeat %%d\\n\", %s[n]);\n",$3);
171 printf("\t{ int n; for (n = 0; n < %s; n++) {\n", $3);
174 printf("\t{ int m; for (m = 0; m < %s[n]; m++) {\n", $3);
202 cond_it_field: '(' COND NAME
210 printf("\tif (%s) {\n", $3);
229 '(' attr_desc '(' attr_type attr_size ')' attr_id
237 char *p = names[rdepth];
238 char *ptr = pnames[rdepth];
245 printf("\twriteBITS(ptr->%s%s,raw,&idx,%d);\n",
247 names[rdepth], size);
251 printf("\twrite%s(ptr->%s%s,raw,&idx,%d,file);\n",
254 names[rdepth],size/8);
263 printf("if (!ptr->%s) ptr->%s = (%s*)xcalloc(%s, sizeof(ptr->%s[0]));\n",
273 printf("if (!ptr->%s[n]) ptr->%s[n] = (%s**)calloc(%s[n], sizeof(ptr->%s[n][0]));\n",
285 printf("\tptr->%s%s = getBITS(raw,&idx, %d,size);\n",
291 printf("\tptr->%s%s = get%s(raw,&idx, %d,size);\n",
299 printf("\tput%s(raw,%d,%d,&idx,ptr->%s%s);\n", type,size/8,size%8,id,names[rdepth]);
303 printf("\t/* repeat %s */\n", repeat);
305 if (type[0] == 'I') {
306 printf("\tint %s%s; \t/* %s */\n",ptr,id, desc);
308 else if (type[0] =='C') {
309 printf("\tchar %s*%s;\t /* %s */\n",ptr,id, desc);
312 printf("\tbarray %s%s;\t /* %s */\n",ptr,id, desc);
316 printf("tabout();\n");
317 printf("\tprintf(\"/*%-30s*/ ptr->%s = \");\n", desc, id);
320 printf("\tprintf(\"%%d\\n\",ptr->%s%s);\n", id,p);
321 else if (type[0] == 'C')
322 printf("\tprintf(\"%%s\\n\",ptr->%s%s);\n", id,p);
324 else if (type[0] == 'B')
326 printf("\tpbarray(&ptr->%s%s);\n", id,p);
353 '(' NAME ')' { $$ = $2; }
358 | '(' enum_list ')' ;
362 enum_list '(' NAME NAME ')' {
366 printf("#define %s %s\n", $3,$4);
369 printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],$4,$3);
381 printf("Got %s\n", word);
394 -d write structure defintions for sysroff in host format
395 -i write functions to swap into sysroff format in
396 -o write functions to swap into sysroff format out
397 -c write code to print info in human form */
411 writecode = av[1][1];
412 if (writecode == 'd')
414 printf("typedef struct { unsigned char *data; int len; } barray; \n");
415 printf("typedef int INT;\n");
416 printf("typedef char * CHARS;\n");
425 printf("Error twathead\n");