-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.h
48 lines (37 loc) · 917 Bytes
/
ast.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef AST_H
#define AST_H
#include "node.h"
#include <boost/phoenix/phoenix.hpp>
namespace phx = boost::phoenix;
struct UnaryFuncWrap
{
template <class T>
struct result;
template <class This, class Arg1, class Arg2>
struct result <This(Arg1, Arg2)>
{
typedef ast_node type;
};
ast_node operator() (ast_node const & node, impl::unaryFunc op) const
{
return unary_op(node, op);
}
};
phx::function<UnaryFuncWrap> const unaryFunc = UnaryFuncWrap();
struct BinaryFuncWrap
{
template <class T>
struct result;
template <class This, class Arg1, class Arg2, class Arg3>
struct result <This(Arg1, Arg2, Arg3)>
{
typedef ast_node type;
};
ast_node operator()( ast_node const& left, ast_node const& right,
impl::binaryFunc op) const
{
return binary_op(left, right, op);
}
};
phx::function<BinaryFuncWrap> const binaryFunc = BinaryFuncWrap();
#endif // AST_H