A Hugo incarnation of the blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 773B

123456789101112131415161718192021222324252627
  1. #include "ast.hpp"
  2. #include <iostream>
  3. #include "parser.hpp"
  4. #include "compiler.hpp"
  5. #include "error.hpp"
  6. void yy::parser::error(const yy::location& loc, const std::string& msg) {
  7. std::cerr << "An error occured: " << msg << std::endl;
  8. }
  9. int main(int argc, char** argv) {
  10. if(argc != 2) {
  11. std::cerr << "please enter a file to compile." << std::endl;
  12. exit(1);
  13. }
  14. compiler cmp(argv[1]);
  15. try {
  16. cmp("program.o");
  17. } catch(unification_error& err) {
  18. err.pretty_print(std::cerr, cmp.get_file_manager(), cmp.get_type_manager());
  19. } catch(type_error& err) {
  20. err.pretty_print(std::cerr, cmp.get_file_manager());
  21. } catch (compiler_error& err) {
  22. err.pretty_print(std::cerr, cmp.get_file_manager());
  23. }
  24. }