-
Notifications
You must be signed in to change notification settings - Fork 25
/
pseudo_code.h
60 lines (50 loc) · 1.04 KB
/
pseudo_code.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
60
typedef struct VarNode{
char *name;
int index;
int len;
} VarNode;
typedef struct ConstNode{
int value;
} ConstNode;
typedef struct OpNode{
int type;
int n;
struct Node **operands;
} OpNode;
typedef struct BlockNode{
int n;
struct Node **statements;
} BlockNode;
typedef struct StringNode{
char *s;
} StringNode;
typedef struct ParamNode{
int n;
struct Node **params;
} ParamNode;
typedef enum { tConst, tVar, tOp, tBlock, tString, tParam, tFnCall} NodeType;
typedef struct Node{
NodeType type;
union {
VarNode *var; // reference to variable or function name
ConstNode con;
OpNode op;
BlockNode block;
StringNode str;
ParamNode par;
};
} Node;
typedef struct Function{
char *name;
int param_count;
int var_count;
VarNode **variables; //return value, params, internal variables
Node *body;
} Function;
typedef struct FnList{
int fn_count;
Function **functions;
} FnList;
VarNode *StrToVar(char *name);
FnList *ReadFunctions(char *file_name, FnList *x);
void FreeFunctions(FnList *x);