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