]> mj.ucw.cz Git - umpf.git/blob - brum.h
639bb59676cd8822023830c4bb1e3aa623b09966
[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                         struct tree* left;
26                         struct tree* right;
27                 } cond; /* binary operator */
28
29                 struct {
30                         struct tree* head;
31                         struct tree* tail;
32                 } block;
33
34                 struct {
35                         struct tree* left;
36                         struct tree* right;
37                 } ass;
38
39                 struct {
40                         enum {
41                                 L_VAR,
42                                 L_CONST,
43                                 L_NUM
44                         } type;
45                         union {
46                                 char* s;
47                                 int n;
48                         } 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 void* xmalloc(size_t size);
70 char* xstrdup(char* s);
71 int line;
72
73 /* int.c */
74 void print_tree(struct tree* t, int ind);
75 void interp(struct tree* t);