xlang/bootstrap/error.hh
2023-01-07 09:56:27 +01:00

36 lines
1.2 KiB
C++

#pragma once
#include <BaseErrorListener.h>
#include <string_view>
#include <typecheck.hh>
namespace xlang {
class ErrorListener : public antlr4::BaseErrorListener {
std::string_view file;
bool has_error;
void printError(size_t line, size_t charPositionInLine, std::string_view msg);
public:
ErrorListener(std::string_view inputfile);
bool hasError();
[[noreturn]] void compilerError(const std::string &file, size_t line);
void duplicateFunction(antlr4::Token *token, const std::string &name);
void loopControlWithoutLoop(antlr4::Token *token);
void shadowedVariable(antlr4::Token *token, const std::string &name);
void syntaxError(antlr4::Recognizer *recognizer,
antlr4::Token *offendingSymbol, size_t line,
size_t charPositionInLine, const std::string &msg,
std::exception_ptr e) override;
void typeMismatch(antlr4::Token *token, Type expected, Type actual);
void unknownFunction(antlr4::Token *token, const std::string &name);
void unknownVariable(antlr4::Token *token, const std::string &name);
void wrongArgumentNumber(antlr4::Token *token, const std::string &name,
size_t expected, size_t actual);
};
} // namespace xlang