Add parsed type data structure, type application and arity.

This commit is contained in:
2020-04-13 14:20:35 -07:00
parent 682e0d3e1c
commit 379a64f379
5 changed files with 136 additions and 9 deletions

View File

@@ -38,9 +38,10 @@ struct type_var : public type {
struct type_base : public type {
std::string name;
int32_t arity;
type_base(std::string n)
: name(std::move(n)) {}
type_base(std::string n, int32_t a = 0)
: name(std::move(n)), arity(a) {}
void print(const type_mgr& mgr, std::ostream& to) const;
};
@@ -66,6 +67,16 @@ struct type_arr : public type {
void print(const type_mgr& mgr, std::ostream& to) const;
};
struct type_app : public type {
type_ptr constructor;
std::vector<type_ptr> arguments;
type_app(type_ptr c)
: constructor(std::move(c)) {}
void print(const type_mgr& mgr, std::ostream& to) const;
};
struct type_mgr {
int last_id = 0;
std::map<std::string, type_ptr> types;