-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathast.html
More file actions
executable file
·134 lines (123 loc) · 1.67 KB
/
ast.html
File metadata and controls
executable file
·134 lines (123 loc) · 1.67 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<style>
table tr td {
margin: 20px;
padding: 5px;
}
td.head {
background: #dddddd;
border: 1px solid black;
margin: 5px;
padding: 0px;
font-size: 75%;
font-weight: bold;
}
</style>
<center>
<h2>B-Minor Abstract Syntax Tree</h2>
<table>
<tr>
<td class=head>decl.h
<td class=head>param_list.h
<tr valign=top>
<td>
<pre>
struct decl {
char *name;
struct type *type;
struct expr *value;
struct stmt *code;
struct symbol *symbol;
struct decl *next;
};
</pre>
<td>
<pre>
struct param_list {
char *name;
struct type *type;
struct symbol *symbol;
struct param_list *next;
};
</pre>
<td>
<tr>
<td colspan=2 class=head>stmt.h
<tr valign=top>
<td>
<pre>
struct stmt {
stmt_t kind;
struct decl *decl;
struct expr *init_expr;
struct expr *expr;
struct expr *next_expr;
struct stmt *body;
struct stmt *else_body;
struct stmt *next;
};
</pre>
<td>
<pre>
typedef enum {
STMT_DECL,
STMT_EXPR,
STMT_IF_ELSE,
STMT_FOR,
STMT_PRINT,
STMT_RETURN,
STMT_BLOCK
} stmt_t;
</pre>
<tr>
<td colspan=2 class=head>expr.h
<tr valign=top>
<td>
<pre>
struct expr {
expr_t kind;
struct expr *left;
struct expr *right;
const char *name;
struct symbol *symbol;
int literal_value;
const char * string_literal;
};
</pre>
<td>
<pre>
typedef enum {
EXPR_ADD,
EXPR_SUB,
EXPR_MUL,
EXPR_DIV,
...
EXPR_INTEGER_LITERAL,
EXPR_STRING_LITERAL
} expr_t;
</pre>
<tr valign=top>
<td colspan=2 class=head>type.h
<tr valign=top>
<td>
<pre>
struct type {
type_t kind;
struct type *subtype;
struct param_list *params;
};
</pre>
<td>
<pre>
typedef enum {
TYPE_BOOLEAN,
TYPE_CHARACTER,
TYPE_INTEGER,
TYPE_STRING,
TYPE_ARRAY,
TYPE_FUNCTION,
TYPE_VOID
} type_t;
</pre>
<tr valign=top>
</table>
</center>