]> mj.ucw.cz Git - umpf.git/blob - brum.h
use clist for headers
[umpf.git] / brum.h
1 #include "lists.h"
2
3 /* cond.h */
4 int yylex (void);
5 void yyerror (char const *);
6
7 struct tree {
8         enum {
9                 ST_IF,
10                 ST_COND,
11                 ST_BLOCK,
12                 ST_ASS,
13                 ST_LEAF,
14                 ST_EMPTY,
15                 ST_ARROW,
16                 ST_OP
17         } st;   /* subtree type */
18         union {
19                 struct {
20                         struct tree* c; /* condition */
21                         struct tree* i; /* if */
22                         struct tree* e; /* else */
23                 } tif;
24
25                 struct {
26                         int op;
27                         enum {
28                                 OP_REL,
29                                 OP_BOOL 
30                         } type;
31                         struct tree* left;
32                         struct tree* right;
33                 } cond; /* binary operator */
34
35                 struct {
36                         struct tree* head;
37                         struct tree* tail;
38                 } block;
39
40                 struct {
41                         struct tree* left;
42                         struct tree* right;
43                 } ass;
44
45                 struct {
46                         enum {
47                                 L_VAR,
48                                 L_CONST,
49                         } type;
50                         char* value;
51                 } leaf;
52
53                 struct {
54                         char* kw_left;
55                         char* kw_right; 
56                         struct tree* s;
57                 } arrow;
58
59                 struct {
60                         int op;
61                         struct tree* left;
62                         struct tree* right;
63                 } op;
64
65         } pt;
66 };
67
68 struct tree* input_tree;
69
70 /* lex.c */
71 #define CC(a,b) ((a<<8)|b)
72 void* xmalloc(size_t size);
73 char* xstrdup(char* s);
74 void __attribute__ ((noreturn)) die(char* msg, ...);
75 void read_conf(char* filename);
76 int line;
77 FILE* conf;
78
79 /* int.c */
80 struct variable {
81         char* name;
82         char* value;
83         int modified;
84         struct variable* next;
85 };
86
87 struct hlist {
88         struct node car;
89         char* name;
90         char* value;
91 };
92
93 struct email {
94         struct list* headers;
95 };
96
97 struct action {
98         char* l;
99         char* r;
100         char* s;
101         struct email e;
102 };
103
104 struct variable** var_hash;
105
106 void print_tree(struct tree* t, int ind);
107 void interp(struct tree* t, struct variable** hash);
108 struct variable** new_var_hash(void);
109 void print_vars(struct variable** hash);
110 void save_current_headers(struct variable** hash);
111
112 /* ham.c */
113 struct list* current_headers;
114 struct list* make_hlist(void);
115 void print_headers(struct list* l);
116 void do_action(struct action* a);