Plug new bitcode generator in main.
This commit is contained in:
parent
a8fa0a1bff
commit
becafb4cd5
|
@ -65,7 +65,7 @@ elseif(BISON_VERSION VERSION_LESS 3.0)
|
|||
endif()
|
||||
|
||||
## 3. External components
|
||||
find_package(Boost 1.54 REQUIRED)
|
||||
find_package(Boost 1.48 REQUIRED regex)
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
|
||||
add_definitions(
|
||||
|
|
44
main.cpp
44
main.cpp
|
@ -20,26 +20,52 @@
|
|||
#include "Scanner.hpp"
|
||||
#include "Parser.hpp"
|
||||
#include "CppEmitter.hpp"
|
||||
#include "BitcodeEmitter.hpp"
|
||||
|
||||
#include <llvm/Bitcode/ReaderWriter.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/raw_os_ostream.h>
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
using namespace monicelli;
|
||||
|
||||
int main() {
|
||||
Program program;
|
||||
Scanner scanner(&std::cin);
|
||||
Parser parser(scanner, program);
|
||||
|
||||
#if YYDEBUG
|
||||
int main(int argc, char **argv) {
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string inputname(argv[i]);
|
||||
std::ifstream instream(inputname);
|
||||
|
||||
Program program;
|
||||
Scanner scanner(&instream);
|
||||
Parser parser(scanner, program);
|
||||
BitcodeEmitter emitter;
|
||||
|
||||
# if YYDEBUG
|
||||
parser.set_debug_level(1);
|
||||
#endif
|
||||
# endif
|
||||
|
||||
parser.parse();
|
||||
CppEmitter emitter(&std::cout);
|
||||
|
||||
program.emit(&emitter);
|
||||
boost::regex namere("^(.+)\\.mc$");
|
||||
std::string outputname;
|
||||
|
||||
return 0;
|
||||
if (boost::regex_match(inputname, namere)) {
|
||||
outputname = boost::regex_replace(inputname, namere, "$1.bc");
|
||||
} else {
|
||||
outputname = inputname + ".bc";
|
||||
}
|
||||
|
||||
if (!program.emit(&emitter)) return 1;
|
||||
|
||||
std::ofstream outstream(outputname);
|
||||
llvm::raw_os_ostream stream(outstream);
|
||||
llvm::WriteBitcodeToFile(&emitter.getModule(), stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue
Block a user