lily/src/pattern.hpp

37 lines
915 B
C++
Raw Normal View History

2019-06-04 18:13:39 -07:00
#pragma once
#include <string>
#include <memory>
#include <vector>
namespace lily {
class type_manager;
class type_env;
struct type;
2019-06-04 18:13:39 -07:00
struct pattern {
2019-06-04 20:45:06 -07:00
virtual ~pattern() = default;
virtual type* check_modifying(type_manager& mgr, std::shared_ptr<type_env> env) = 0;
2019-06-04 18:13:39 -07:00
};
typedef std::unique_ptr<pattern> pattern_ptr;
2019-06-04 20:45:06 -07:00
struct pattern_var : pattern {
2019-06-04 18:13:39 -07:00
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);
2019-06-04 18:13:39 -07:00
};
2019-06-04 20:45:06 -07:00
struct pattern_cons : pattern {
2019-06-04 18:13:39 -07:00
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);
2019-06-04 18:13:39 -07:00
};
}