summaryrefslogtreecommitdiff
path: root/sugar.h
blob: 1140ef32d866f6655230bc363e20fee7e94bf2eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include "ast.h"
#include "environment.h"

using namespace std;


using Hook2 = function<AST(Environment&,const AST&,const AST&)>;
using Hook3 = function<AST(Environment&,const AST&,const AST&,const AST&)>;


extern const unordered_map<AST::Type,string> typeName;

ostream& operator<<(ostream &os,AST::Type t);

template <typename T>
string stringify(const vector<T> &v,const string &join=", ");


Hook checkedHook(const Name &name,
                 const vector<AST::Type> &types,
                 const Hook &func);

Hook checkedHook(const Name &name,
                 const vector<AST::Type> &types1,const vector<AST::Type> &types2,
                 const Hook2 &func);

Hook checkedHook(const Name &name,
                 const vector<AST::Type> &types1,const vector<AST::Type> &types2,const vector<AST::Type> &types3,
                 const Hook3 &func);