-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.c
More file actions
40 lines (35 loc) · 868 Bytes
/
main.c
File metadata and controls
40 lines (35 loc) · 868 Bytes
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
#include <stdio.h>
#include "ast_visitor.h"
#include "ir_visitor.h"
#include "mips_visitor.h"
extern FILE *yyin;
int yyparse();
static int error = 0;
#define WAIT() //({if (argc > 3) {ir_dump(argv[3]);} putchar('\n'); getchar();})
int main(int argc, char** argv) {
if (argc < 3) {
return 1;
}
if (!(yyin = fopen(argv[1], "r"))) {
perror(argv[1]);
return 1;
}
yyparse();
if (error) return 0;
ast_sem();
if (error) return 0;
ast_ir();
ir_hole_opt();
if (argc > 4) ir_dump(argv[4]);
build_program();
WAIT();
while (ir_constant() | ir_livevar(0) | ir_arthprog(0) | ir_avexpr(0)) WAIT();
while (ir_constant() | ir_arthprog(1) | ir_livevar(1)) WAIT();
while (ir_constant() | ir_avexpr(1) | ir_livevar(1)) WAIT();
if (argc > 3) ir_dump(argv[3]);
ir_mips();
return mips_dump(argv[2]);
}
void set_error() {
error = 1;
}