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