diff options
| author | Marius Nita <marius@cs.pdx.edu> | 2003-04-14 06:04:49 +0000 |
|---|---|---|
| committer | Marius Nita <marius@cs.pdx.edu> | 2003-04-14 06:04:49 +0000 |
| commit | 7aae14e9b83242c2778e57c069fb8f299b8172f3 (patch) | |
| tree | 80892567a99c251b0ae957c51309645b6d27dc98 /obcl/obcl.c | |
| parent | 69854023a4f36deb80c7c3dee891acc48f8ae6da (diff) | |
beginning of obcl. the parser works with semicolons after statements
for now, there is much left to change and do.
Diffstat (limited to 'obcl/obcl.c')
| -rw-r--r-- | obcl/obcl.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/obcl/obcl.c b/obcl/obcl.c index e69de29b..b4d9aeee 100644 --- a/obcl/obcl.c +++ b/obcl/obcl.c @@ -0,0 +1,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; + } + } +} |
