blob: b4d9aeee157bbbe2f3c84633aecb2cbdbb5998a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "obcl.h"
void free_cl_tree(GList *tree)
{
}
GList *cl_parse(gchar *file)
{
FILE *fh = fopen(file, "r");
if (fh)
return cl_parse_fh(fh);
else {
printf("can't open file %s\n", file);
return 0;
}
}
void cl_print_tree(GList *tree, int depth)
{
CLNode *tmp;
int tmpd = depth;
for (; tree; tree = tree->next) {
tmp = (CLNode*)tree->data;
while (tmpd-- > 0)
printf(" ");
tmpd = depth;
switch(tmp->type) {
case CL_ID:
printf("--ID-- %s\n", tmp->u.str);
break;
case CL_STR:
printf("--STR-- %s\n", tmp->u.str);
break;
case CL_NUM:
printf("--NUM-- %.2f\n", tmp->u.num);
break;
case CL_LIST:
printf("--LIST-- %s\n", tmp->u.lb.id);
cl_print_tree(tmp->u.lb.list, depth+2);
break;
case CL_BLOCK:
printf("--BLOCK-- %s\n", tmp->u.lb.id);
cl_print_tree(tmp->u.lb.block, depth+2);
break;
case CL_LISTBLOCK:
printf("--LISTBLOCK-- %s\n", tmp->u.lb.id);
cl_print_tree(tmp->u.lb.list, depth+2);
printf("\n");
cl_print_tree(tmp->u.lb.block, depth+2);
break;
}
}
}
|