-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.h
More file actions
38 lines (29 loc) · 689 Bytes
/
node.h
File metadata and controls
38 lines (29 loc) · 689 Bytes
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
#ifndef NODE_H
#define NODE_H
#include <boost/variant.hpp>
struct binary_op;
struct unary_op;
namespace impl
{
typedef double (*unaryFunc)(double);
typedef double (*binaryFunc)(double, double);
}
typedef boost::variant<double, char,
boost::recursive_wrapper<binary_op>,
boost::recursive_wrapper<unary_op>
> ast_node;
struct binary_op
{
binary_op(ast_node const& left, ast_node const& right,
impl::binaryFunc op): left(left), right(right), op(op) {}
ast_node left;
ast_node right;
impl::binaryFunc op;
};
struct unary_op
{
unary_op(ast_node const& subj, impl::unaryFunc op): subj(subj), op(op){}
ast_node subj;
impl::unaryFunc op;
};
#endif // NODE_H