]> mj.ucw.cz Git - umpf.git/blob - brum.h
16e4b9e5acb8acb50c30eb74b9f9191b4d5f408e
[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 int line;
74
75 /* int.c */
76 struct variable {
77         char* name;
78         char* value;
79         struct variable* next;
80 };
81
82 struct variable** var_hash;
83
84 void print_tree(struct tree* t, int ind);
85 void interp(struct tree* t, struct variable** hash);
86 struct variable** new_var_hash(void);
87 void print_vars(struct variable** hash);