ErrorReporting.h 923 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef QLOW_ERROR_REPORTING
  2. #define QLOW_ERROR_REPORTING
  3. #include "Logging.h"
  4. namespace qlow
  5. {
  6. struct CodePosition;
  7. class CompileError;
  8. class SyntaxError;
  9. }
  10. /*!
  11. * \brief bison-compatible location struct
  12. */
  13. struct qlow::CodePosition
  14. {
  15. const char* filename = "";
  16. int first_line;
  17. int last_line;
  18. int first_column;
  19. int last_column;
  20. };
  21. class qlow::CompileError
  22. {
  23. protected:
  24. CodePosition where;
  25. public:
  26. inline CompileError(const CodePosition& where) :
  27. where{ where }
  28. {
  29. }
  30. virtual ~CompileError(void);
  31. virtual void print(Logger& logger) const = 0;
  32. void underlineError(Logger& logger) const;
  33. };
  34. class qlow::SyntaxError : public CompileError
  35. {
  36. public:
  37. inline SyntaxError(const CodePosition& where) :
  38. CompileError{ where }
  39. {
  40. }
  41. virtual void print(Logger&) const override;
  42. };
  43. #endif // QLOW_ERROR_REPORTING