forked from lsegal/my_toy_compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (28 loc) · 697 Bytes
/
main.cpp
File metadata and controls
35 lines (28 loc) · 697 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
#include <iostream>
#include "codegen.h"
#include "node.h"
using namespace std;
extern int yyparse();
extern NBlock* programBlock;
void open_file(const char* filename) {
// openfile
freopen(filename, "r", stdin);
}
void createCoreFunctions(CodeGenContext& context);
int main(int argc, char **argv)
{
if (argc > 1) {
open_file(argv[1]);
}
yyparse();
cout << programBlock << endl;
// see http://comments.gmane.org/gmane.comp.compilers.llvm.devel/33877
InitializeNativeTarget();
InitializeNativeTargetAsmPrinter();
InitializeNativeTargetAsmParser();
CodeGenContext context;
createCoreFunctions(context);
context.generateCode(*programBlock);
context.runCode();
return 0;
}