Add chapter 8 starting code for compiler series

This commit is contained in:
2019-11-02 16:38:11 -07:00
parent 37097d3a40
commit 9531f4d8e3
28 changed files with 1612 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#pragma once
#include <exception>
#include "type.hpp"
struct type_error : std::exception {
std::string description;
type_error(std::string d)
: description(std::move(d)) {}
const char* what() const noexcept override;
};
struct unification_error : public type_error {
type_ptr left;
type_ptr right;
unification_error(type_ptr l, type_ptr r)
: left(std::move(l)), right(std::move(r)),
type_error("failed to unify types") {}
};