-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.h
More file actions
43 lines (37 loc) · 1.17 KB
/
tree.h
File metadata and controls
43 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef TREE_H
#define TREE_H
#include "node.h"
typedef struct tree_s {
int type; /* INUM, RNUM, ID, ADDOP, MULOP, RELOP, ASSIGNOP, IF, WHILE, FOR */
int effective_type; /* INUM, RNUM */
int left_leaf;
int label;
char *asm_label;
union {
int ival; /* INUM */
float rval; /* RNUM */
node_t *sval; /* ID FUNCTION */
int opval; /* ADDOP, MULOP, RELOP, ASSIGNOP*/
void *noval; /* IF, WHILE, FOR, PROCEDURE */
} attribute;
struct tree_s *left;
struct tree_s *right;
}
tree_t;
/* constructor */
tree_t *make_tree(int type, int effective_type, tree_t *left, tree_t *right);
tree_t *make_op(int type, int attribute, tree_t *left, tree_t *right);
tree_t *make_id(node_t *node);
tree_t *make_func(node_t *node);
tree_t *make_proc(node_t *node, tree_t *left);
tree_t *make_loop(int type, tree_t *left, tree_t *right);
tree_t *make_if(int type, tree_t *left, tree_t *right);
tree_t *make_else(int type, tree_t *left, tree_t *right);
tree_t *make_inum(int ival);
tree_t *make_rnum(float rval);
tree_t *make_bool(int val);
tree_t *make_link(int type, tree_t *left, tree_t *right);
int same_types(tree_t *head);
void print_tree(tree_t *t, int spaces);
void free_tree(tree_t *t);
#endif