1: #include <stdio.h>
2: #include "def.h"
3:
4: #define TABOVER(n) tabover(n,stderr)
5: prgraph()
6: {
7: VERT v;
8: int i;
9: if (progress) fprintf(stderr,"prgraph():\n");
10: for (v = 0; v < nodenum; ++v)
11: {
12: fprintf(stderr,"%d %s:",v, typename[NTYPE(v)]);
13: for (i = 0; i < ARCNUM(v); ++i)
14: {
15: fprintf(stderr,"%d ",ARC(v,i));
16: ASSERT(UNDEFINED <= ARC(v,i) && ARC(v,i) < nodenum, prgraph);
17: }
18: fprintf(stderr,"\n");
19: }
20: fprintf(stderr,"\n\n");
21: }
22:
23: prtree()
24: {
25: prtr(START,1);
26: }
27:
28: prtr(v,tab) /* print tree in form of program indenting by tab */
29: VERT v;
30: int tab;
31: {
32: int i;
33: TABOVER(tab);
34: fprintf(stderr,"%d %s:",v,typename[NTYPE(v)]);
35: for (i = 0; i < ARCNUM(v); ++i)
36: fprintf(stderr," %d",ARC(v,i));
37: fprintf(stderr,"\n");
38: for (i = 0; i < CHILDNUM(v); ++i)
39: {
40: TABOVER(tab+1);
41: fprintf(stderr,"{\n");
42: if (DEFINED(LCHILD(v,i)))
43: prtr(LCHILD(v,i),tab+1);
44: TABOVER(tab+1);
45: fprintf(stderr,"}\n");
46: }
47: if (DEFINED(RSIB(v)))
48: prtr(RSIB(v),tab);
49: }
50:
51:
52: tabover(n,fd) /* tab n times */
53: int n;
54: FILE *fd;
55: {
56: int i;
57: for (i = 0; i < n; ++i)
58: putc('\t',fd);
59: }
Defined functions
prtr
defined in line
28; used 3 times
Defined macros