]> mj.ucw.cz Git - umpf.git/blob - brum.h
f5e2372ed77092d8d3041501515cbc287a53943c
[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 void* xrealloc(void* buf, size_t size);
74 char* xstrdup(char* s);
75 void __attribute__ ((noreturn)) die(char* msg, ...);
76 void read_conf(char* filename);
77 int line;
78 FILE* conf;
79
80 /* int.c */
81 struct variable {
82         struct node car;
83         char* name;
84         char* value;
85         int modified;
86 };
87
88 struct hlist {
89         struct node car;
90         char* name;
91         char* value;
92 };
93
94 struct email {
95         struct list* headers;
96         char* body;
97 };
98
99 struct action {
100         char* l;
101         char* r;
102         char* s;
103         struct email e;
104 };
105
106 struct list* var_hash;
107
108 void print_tree(struct tree* t, int ind);
109 void interp(struct tree* t, struct list* hash);
110 struct list* new_var_hash(void);
111 void print_vars(struct list* hash);
112 void save_current_headers(struct list* hash);
113
114 /* ham.c */
115 struct list* current_headers;
116 char* current_body;
117 struct list* make_hlist(void);
118 void print_headers(struct list* l);
119 void do_action(struct action* a);
120 char* get_body(void);