Add CMake file and code for post 4

This commit is contained in:
2019-08-26 18:52:25 -07:00
parent 7e98477450
commit 7e40af4830
16 changed files with 698 additions and 0 deletions

16
04/env.cpp Normal file
View File

@@ -0,0 +1,16 @@
#include "env.hpp"
type_ptr type_env::lookup(const std::string& name) const {
auto it = names.find(name);
if(it != names.end()) return it->second;
if(parent) return parent->lookup(name);
return nullptr;
}
void type_env::bind(const std::string& name, type_ptr t) {
names[name] = t;
}
type_env type_env::scope() const {
return type_env(this);
}