-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (34 loc) · 965 Bytes
/
main.cpp
File metadata and controls
43 lines (34 loc) · 965 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
41
42
43
#include <iostream>
#include "IncludeList.h"
#include "bison.tab.h"
#include "GraphvizPrinter.h"
#include "SymbolTableMaker.h"
#include "TypeChecker.h"
extern CProgram* goal;
extern "C" FILE *yyin;
int main(int argc, char* argv[]) {
if (argc != 2) {
std::cout << "usage: ./compiler <your file>\n";
return -1;
}
FILE * pt = fopen(argv[1], "r");
if (!pt) {
std::cout << "Bad Input " << argv[1] << std::endl;
return -1;
}
yyin = pt;
do {
yyparse();
} while (!feof(yyin));
Visitor::Printer* printer = new Visitor::Printer("output/tree.dot");
printer->Visit(goal);
delete printer;
//std::cout << "Successfully built AST (file tree.dot)\n";
Table table;
Visitor::TableMaker table_filler(&table);
table_filler.Visit(goal);
table.print("output/symbols.txt");
//std::cout << "Successfully built table (log saved as symbols.txt)\n";
Visitor::TypeChecker checker(&table);
checker.Visit(goal);
}