2019-06-04 18:13:39 -07:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace lily {
|
2019-06-09 21:25:02 -07:00
|
|
|
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;
|
2019-06-09 21:25:02 -07:00
|
|
|
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;
|
2019-06-09 21:25:02 -07:00
|
|
|
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;
|
2019-06-09 21:25:02 -07:00
|
|
|
type* check_modifying(type_manager& mgr, std::shared_ptr<type_env> env);
|
2019-06-04 18:13:39 -07:00
|
|
|
};
|
|
|
|
}
|