]> mj.ucw.cz Git - umpf.git/blob - umpf.h
a2d45766a4b514c74a93b03d7e13bfb88e4511b3
[umpf.git] / umpf.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 hlist {
82         struct node car;
83         char* name;
84         char* value;
85 };
86
87 struct email {
88         struct list* headers;
89         char* body;
90         int body_len;
91 };
92
93 struct action {
94         char* l;
95         char* r;
96         char* s;
97         struct email e;
98 };
99
100 /* ham.c */
101 char* default_mailbox;
102
103 struct list* current_headers;
104 struct email* current_body;
105 struct list* make_hlist(void);
106 void print_headers(struct list* l);
107 void do_action(struct action* a);
108 struct email* get_body(void);
109
110 /* lock.c */
111 void save_gids(void);
112 void close_mailbox(int fd, char* path, int is_default_mailbox);
113 int open_mailbox(char* path, int is_default_mailbox);
114 char* cat(char* l, char* r);
115
116 /* code.c */
117
118 struct code {
119         struct node car;
120         enum {
121                 SET,
122                 JUMP,
123                 JUMP_IF,
124                 JUMP_UNLESS,
125                 DELIVER,
126                 CALL_EXT,
127                 NOP
128         } opcode;
129
130         union {
131                 struct {
132                         int l;
133                         int r;
134                 } set;
135         } u;
136 };
137
138 struct variable {
139         struct node car;
140         char* name;
141         int varcode;    
142 };
143
144 struct list input_code;
145 struct list* var_hash;
146 int current_varcode;
147 char** var_tab; 
148 char** const_tab;
149 int cur_const_n, cur_const_s;
150
151 void init(void);
152 void compile(struct tree* t);
153 void print_code(struct tree* t);