From 7aae14e9b83242c2778e57c069fb8f299b8172f3 Mon Sep 17 00:00:00 2001 From: Marius Nita Date: Mon, 14 Apr 2003 06:04:49 +0000 Subject: beginning of obcl. the parser works with semicolons after statements for now, there is much left to change and do. --- obcl/obcl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'obcl/obcl.c') 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; + } + } +} -- cgit v1.2.3