-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgiko.cpp
More file actions
52 lines (38 loc) · 1.13 KB
/
Copy pathgiko.cpp
File metadata and controls
52 lines (38 loc) · 1.13 KB
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
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <string>
#include <vector>
#include <llvm/Bitcode/ReaderWriter.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/raw_ostream.h>
#include "parser.hpp"
#include "generator.hpp"
int main(int argc, char *argv[])
{
using namespace giko;
using namespace boost::spirit;
std::string temp;
std::string input;
while (std::getline(std::cin, temp)) {
input += temp;
input += '\n';
}
std::cout << "Input:" << std::endl;
std::cout << input << std::endl;
parser::giko_grammar<std::string::iterator, qi::standard_wide::space_type> g;
ast::ModuleAST *result = nullptr;
auto it = input.begin();
bool success = qi::phrase_parse(it, input.end(), g, qi::standard_wide::space, result);
if (success && it == input.end()) {
std::cout << "OK" << std::endl;
using namespace llvm;
generator::generator gen;
std::string error;
raw_fd_ostream raw_stream("out.bc", error, sys::fs::OpenFlags::F_RW);
WriteBitcodeToFile(gen.generateModule(result), raw_stream);
raw_stream.close();
delete result;
}else{
std::cout << "ERROR" << std::endl;
}
return 0;
}