forked from tmsm1999/Rust-Compiler-Project-Compilers-Course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler.c
More file actions
37 lines (30 loc) · 690 Bytes
/
compiler.c
File metadata and controls
37 lines (30 loc) · 690 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
#include <stdio.h>
#include "parser.h"
#include "printAbsTree.h"
#include "code.h"
#include "mips_code.h"
int main(int argc, char** argv)
{
variables = init_table();
--argc; ++argv;
if (argc != 0)
{
yyin = fopen(*argv, "r");
if (!yyin)
{
printf("'%s': could not open file\n", *argv);
return 1;
}
} // yyin = stdin
if (yyparse() == 0)
{
if(root != NULL) // If the program is not empty
{
//printCmd(root, 0); // AST printing
InstrList* code = compileCmd(root); // Intermediate code generation
//printInstrList(code); // Intermediate code printing
printMIPS(code); // MIPS code printing
}
}
return 0;
}