#ifndef ERROR_HANDLER_HH #define ERROR_HANDLER_HH #include "tokenizer.hh" #include #include struct RuntimeException : public std::exception { RuntimeException(Token token, const std::string& message) : token{token}, message{message} {} const char* what() const noexcept override { return message.c_str(); } Token token; private: std::string message; }; struct ErrorHandler { ErrorHandler() : had_error{false} {}; void error(int line, const std::string &message); void error(Token token, const std::string &message); void runtime_error(const RuntimeException &exception); void report(int line, const std::string &where, const std::string &message); bool had_error; bool had_runtime_error; }; #endif