-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.h
59 lines (48 loc) · 1.06 KB
/
ast.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef AST_H
#define AST_H
#include <stdbool.h>
#include <stddef.h>
//#define RDEBUG
#ifdef RDEBUG
#define dbg_info printf
#else
#define dbg_info
#endif
enum ff_node_type {
node_op = 1,
node_id,
node_list,
node_bool
};
enum ff_op_type {
op_quote = 1,
op_atom,
op_eq,
op_car,
op_cdr,
op_cons,
op_cond
};
typedef struct FfNode {
bool is_empty;
enum ff_node_type type;
union {
enum ff_op_type op_type;
char *id_name;
struct FfNode *list;
bool is_true;
} node_val;
struct FfNode* next;
} FfNode;
#define node_val_id node_val.id_name
#define node_val_op node_val.op_type
#define node_val_list node_val.list
#define node_val_bool node_val.is_true
FfNode* ff_create_op_node(enum ff_op_type type);
FfNode* ff_create_id_node(char *id_name);
FfNode* ff_create_list_node(FfNode *list);
FfNode* ff_create_empty_node();
FfNode* ff_link_node(FfNode *left, FfNode *right);
FfNode* ff_copy_node(FfNode *src);
FfNode* ff_create_bool_node(bool is_true);
#endif