-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
executable file
·55 lines (46 loc) · 1.12 KB
/
main.c
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
#include "list.h"
#include "pretty_print.h"
#include "semant.h"
#include "cgen.h"
#include <stdlib.h>
extern int yyparse();
list* program = 0;
#if 0
#include "ast_cons.h"
#include "symtab.h"
#include "utils.h"
void test_scope()
{
struct symtab* stab = NULL;
stab = enter_scope(stab);
stab = add_symbol(stab, variable("a"));
stab = add_symbol(stab, variable("b"));
// new scope
stab = enter_scope(stab);
stab = add_symbol(stab, variable("a"));
stab = add_symbol(stab, variable("b"));
stab = add_symbol(stab, variable("c"));
dump_symtab(stab);
stab = enter_scope(stab);
stab = add_symbol(stab, variable("x"));
stab = add_symbol(stab, variable("y"));
stab = add_symbol(stab, variable("z"));
dump_symtab(stab);
stab = exit_scope(stab);
stab = exit_scope(stab);
stab = exit_scope(stab);
dump_symtab(stab);
}
#endif
int main()
{
#if 1
yyparse();
/*for (struct node* tmp = program->head; tmp != NULL; tmp = tmp->next)
pretty_print(tmp->data);
*/
analyze(program);
codegen(program);
#endif
//test_scope();
}