1 # dump the current parse tree
4 function element_string
(elnum
,
7 elem = elements
[elnum
, "elem"];
8 if (elements
[elnum
, "ptr"]==
"1") elem=
"*"elem
;
9 if (elements
[elnum
, "array_len"]!="")
10 elem=elem
"["elements
[elnum
, "array_len"]"]";
11 if (elements
[elnum
, "switch"]!="")
12 elem=elem
"["elements
[elnum
, "switch"]"]";
16 function dump_element
(f
, elnum
,
19 type = elements
[elnum
, "type"];
20 case = elements
[elnum
, "case"];
21 elem = element_string
(elnum
);
23 xprintf
(f
,"\t\tcase %d %s %s;\n", case
, type
, elem
);
25 xprintf
(f
,"\t%s %s;\n", type
, elem
);
29 function dump_union
(f
, elnum
,
32 xprintf
(f
,"\tunion %s {\n", element_string
(elnum
));
33 for (i=
0;i
<unions
[elnum
, "num_elems"];i
++) {
34 dump_element
(f
, unions
[elnum
, i
]);
39 function dump_elem
(f
, struct_num
, elem_num
,
42 elnum = structs
[struct_num
, elem_num
];
44 if (elements
[elnum
, "type"] ==
"union") {
47 dump_element
(f
, elnum
);
51 function dump_structs
(f
, NIL
,
54 xprintf
(f
,"/* dump of parsed structures */\n\n\n");
56 for (i=
0;i
< num_options
;i
++) {
57 xprintf
(f
,"option %s %s\n", options
[i
, "name"], options
[i
, "value"]);
61 for (i=
0;i
< num_structs
;i
++) {
62 xprintf
(f
,"/* structure %d */\n", i
);
63 xprintf
(f
,"struct %s {\n", structs
[i
, "name"]);
64 for (j=
0;j
<structs
[i
, "num_elems"];j
++) {
69 xprintf
(f
,"/* end dump */\n\n");