9 /* TEH MACROS FROM MOUNT DOOM */
11 #define CL_IS_NODE(X) \
12 (((CLNode*)(X))->type == CL_LIST || \
13 ((CLNode*)(X))->type == CL_BLOCK || \
14 ((CLNode*)(X))->type == CL_LISTBLOCK)
15 #define CL_NODE(X) ((CLNode*)(X))
16 #define CL_ID(X) (((CLNode*)(X))->u.lb.id)
17 #define CL_LIST(X) (((CLNode*)(X))->u.lb.list)
18 #define CL_BLOCK(X) (((CLNode*)(X))->u.lb.block)
19 #define CL_NUMVAL(X) (((CLNode*)(X))->u.num)
20 #define CL_STRVAL(X) (((CLNode*)(X))->u.str)
21 #define CL_LINE(X) (((CLNode*)(X))->lineno)
23 #define CL_ASSERT_NODE(X) \
24 g_assert(CL_IS_NODE(X))
25 #define CL_ASSERT_NUM(X) \
26 g_assert(((CLNode*)(X))->type == CL_NUM)
27 #define CL_ASSERT_STR(X) \
28 g_assert(((CLNode*)(X))->type == CL_STR)
30 #define CL_LIST_NTH(X,Y)\
31 CL_NODE(g_list_nth(CL_LIST(X),(Y))->data)
33 typedef enum CLNodeType {
42 typedef struct CLNode {
57 typedef void (*CLProcFunc)(CLNode *);
61 typedef struct CLProc {
63 struct CLProcHandler *default_h;
66 typedef enum CLProcHandlerType {
71 typedef struct CLProcHandler {
72 CLProcHandlerType type;
79 GList *cl_parse(gchar *file);
80 GList *cl_parse_fh(FILE *file);
82 void cl_tree_free(GList *tree);
83 void cl_tree_print(GList *tree, int depth);
85 CLProcHandler *cl_proc_handler_new_func(CLProcFunc f);
86 CLProcHandler *cl_proc_handler_new_proc(CLProc *cp);
87 CLProc *cl_proc_new(void);
88 void cl_proc_free(CLProc *proc);
89 void cl_proc_add_handler(CLProc *proc, gchar *str,
90 CLProcHandler *handler);
91 void cl_proc_add_handler_func(CLProc *proc, gchar *str,
93 void cl_proc_set_default(CLProc *proc, CLProcHandler *pf);
94 void cl_proc_register_keywords(CLProc *proc, ...);
95 void cl_process(GList *tree, CLProc *proc);