-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
38 lines (32 loc) · 804 Bytes
/
main.cpp
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 <iostream>
#include <cstdio>
#include "codegen.h"
#include "node.h"
using namespace std;
extern int yylex();
extern int yyparse();
extern FILE* yyin;
extern NBlock* programBlock;
void createCoreFunctions(CodeGenContext& context);
int main(int argc, char **argv)
{
if (argc != 2) {
cout << "Wrong num of args" << endl;
return -1;
}
FILE *myfile = fopen(argv[1], "r");
if (!myfile) {
cout << "I can't open: " << argv[1] << endl;
return -1;
}
yyin = myfile;
yyparse();
std::cout << programBlock << endl;
// see http://comments.gmane.org/gmane.comp.compilers.llvm.devel/33877
InitializeNativeTarget();
CodeGenContext context;
createCoreFunctions(context);
context.generateCode(*programBlock);
context.runCode();
return 0;
}