lily/src/pattern.hpp

37 lines
915 B
C++

#pragma once
#include <string>
#include <memory>
#include <vector>
namespace lily {
class type_manager;
class type_env;
struct type;
struct pattern {
virtual ~pattern() = default;
virtual type* check_modifying(type_manager& mgr, std::shared_ptr<type_env> env) = 0;
};
typedef std::unique_ptr<pattern> pattern_ptr;
struct pattern_var : pattern {
std::string name;
pattern_var(std::string n) :
name(std::move(n)) {}
~pattern_var() = default;
type* check_modifying(type_manager& mgr, std::shared_ptr<type_env> env);
};
struct pattern_cons : pattern {
std::string name;
std::vector<std::string> vnames;
pattern_cons(std::string n) :
name(std::move(n)) {}
~pattern_cons() = default;
type* check_modifying(type_manager& mgr, std::shared_ptr<type_env> env);
};
}