xlang/bootstrap/error.hh

35 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();
void compilerError(const std::string &file, size_t line);
void duplicateFunction(antlr4::Token *token, const std::string &name);
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