Main.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "llvm/ADT/STLExtras.h"
  2. #include "llvm/IR/IRBuilder.h"
  3. #include "llvm/IR/LLVMContext.h"
  4. #include "llvm/IR/Module.h"
  5. #include "llvm/IR/Verifier.h"
  6. #include <cctype>
  7. #include <cstdio>
  8. #include <map>
  9. #include <string>
  10. #include <vector>
  11. #include "Ast.h"
  12. #include "Lexer.h"
  13. #include "Parser.h"
  14. using namespace llvm;
  15. using namespace ast;
  16. using namespace lexer;
  17. using namespace parser;
  18. namespace helper {
  19. // Cloning make_unique here until it's standard in C++14.
  20. // Using a namespace to avoid conflicting with MSVC's std::make_unique (which
  21. // ADL can sometimes find in unqualified calls).
  22. template <class T, class... Args>
  23. static
  24. typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
  25. make_unique(Args &&... args) {
  26. return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
  27. }
  28. }
  29. //===----------------------------------------------------------------------===//
  30. // Main driver code.
  31. //===----------------------------------------------------------------------===//
  32. int main() {
  33. // Prime the first token.
  34. fprintf(stderr, "ready> ");
  35. getNextToken();
  36. // Run the main "interpreter loop" now.
  37. parser::MainLoop();
  38. AstTree::TheModule->dump();
  39. return 0;
  40. }