Make a few more things classes.
This commit is contained in:
@@ -7,38 +7,43 @@
|
||||
|
||||
using maybe_location = std::optional<yy::location>;
|
||||
|
||||
struct compiler_error : std::exception {
|
||||
std::string description;
|
||||
maybe_location loc;
|
||||
class compiler_error : std::exception {
|
||||
private:
|
||||
std::string description;
|
||||
maybe_location loc;
|
||||
|
||||
compiler_error(std::string d, maybe_location l = std::nullopt)
|
||||
: description(std::move(d)), loc(std::move(l)) {}
|
||||
public:
|
||||
compiler_error(std::string d, maybe_location l = std::nullopt)
|
||||
: description(std::move(d)), loc(std::move(l)) {}
|
||||
|
||||
const char* what() const noexcept override;
|
||||
const char* what() const noexcept override;
|
||||
|
||||
void print_about(std::ostream& to);
|
||||
void print_location(std::ostream& to, file_mgr& fm, bool highlight = false);
|
||||
void print_about(std::ostream& to);
|
||||
void print_location(std::ostream& to, file_mgr& fm, bool highlight = false);
|
||||
|
||||
void pretty_print(std::ostream& to, file_mgr& fm);
|
||||
void pretty_print(std::ostream& to, file_mgr& fm);
|
||||
};
|
||||
|
||||
struct type_error : compiler_error {
|
||||
std::optional<yy::location> loc;
|
||||
class type_error : compiler_error {
|
||||
private:
|
||||
|
||||
type_error(std::string d, maybe_location l = std::nullopt)
|
||||
: compiler_error(std::move(d), std::move(l)) {}
|
||||
public:
|
||||
type_error(std::string d, maybe_location l = std::nullopt)
|
||||
: compiler_error(std::move(d), std::move(l)) {}
|
||||
|
||||
const char* what() const noexcept override;
|
||||
void pretty_print(std::ostream& to, file_mgr& fm);
|
||||
const char* what() const noexcept override;
|
||||
void pretty_print(std::ostream& to, file_mgr& fm);
|
||||
};
|
||||
|
||||
struct unification_error : public type_error {
|
||||
type_ptr left;
|
||||
type_ptr right;
|
||||
class unification_error : public type_error {
|
||||
private:
|
||||
type_ptr left;
|
||||
type_ptr right;
|
||||
|
||||
unification_error(type_ptr l, type_ptr r, maybe_location loc = std::nullopt)
|
||||
: left(std::move(l)), right(std::move(r)),
|
||||
public:
|
||||
unification_error(type_ptr l, type_ptr r, maybe_location loc = std::nullopt)
|
||||
: left(std::move(l)), right(std::move(r)),
|
||||
type_error("failed to unify types", std::move(loc)) {}
|
||||
|
||||
void pretty_print(std::ostream& to, file_mgr& fm, type_mgr& mgr);
|
||||
void pretty_print(std::ostream& to, file_mgr& fm, type_mgr& mgr);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user