-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (31 loc) · 760 Bytes
/
main.cpp
File metadata and controls
35 lines (31 loc) · 760 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
#include <cstdio>
#include <iostream>
#include "AST.h"
#include "CodeGenVisitor.h"
#include "Visitor.h"
extern "C" FILE *yyin;
extern "C" int yyparse();
ASTProgram * start;
int main (const int argc, const char ** argv) {
if (argc < 2) {
yyin = NULL;
std::cerr <<"fatal error: no input files" << std::endl;
return -1;
} else {
FILE * infile = fopen(argv[1], "r");
if (!infile) {
std::cerr <<"Error reading file " << argv[1] << std::endl;
return -1;
}
yyin = infile;
}
#ifdef DEBUG
extern int yydebug;
yydebug = 1;
#endif
if (!yyparse()) {
CodeGenVisitor * visitor = new CodeGenVisitor(start);
visitor->codeGen();
}
return 0;
}