xlang/bootstrap/error.cc
2023-01-06 03:56:33 +01:00

31 lines
990 B
C++

#include <error.hh>
#include <iostream>
namespace xlang {
ErrorListener::ErrorListener(std::string_view inputfile)
: file{inputfile}, has_error{false} {}
bool ErrorListener::hasError() {
return has_error;
}
void ErrorListener::syntaxError([[maybe_unused]] antlr4::Recognizer *recognizer,
[[maybe_unused]] antlr4::Token *offendingSymbol,
size_t line, size_t charPositionInLine,
const std::string &msg,
[[maybe_unused]] std::exception_ptr e) {
std::cerr << file << ":" << line << ":" << charPositionInLine + 1 << ": "
<< msg << std::endl;
has_error = true;
}
void ErrorListener::typeError(size_t line, size_t charPositionInLine,
std::string_view msg) {
std::cerr << file << ":" << line << ":" << charPositionInLine + 1 << ": "
<< msg << std::endl;
has_error = true;
}
} // namespace xlang