ExpressionContainer.hh 2.07 KB
#ifndef EXPRESSIONCONTAINER_HH_
#define EXPRESSIONCONTAINER_HH_

namespace AMDA {
namespace parser {

struct op_not {};
struct op_or {};
struct op_greater{};
struct op_greaterOrEqual{};
struct op_lowerOrEqual{};
struct op_lower{};
struct op_and {};
struct op_xor {};
struct op_equal {};
struct op_unequal {};
struct op_sum {};
struct op_difference {};
struct op_factor {};
struct op_division {};
struct op_power{};
struct op_powerTen{};
struct op_plusSign {};
struct op_minusSign {};

namespace Expression{

typedef std::string var;
template <typename tag> struct binop;
template <typename tag> struct unop;
template <typename tag> struct comop;

typedef boost::variant<var,
	boost::recursive_wrapper<unop <op_not> >,
	boost::recursive_wrapper<binop<op_equal> >,
	boost::recursive_wrapper<comop<op_greater> >,
	boost::recursive_wrapper<binop<op_greaterOrEqual> >,
	boost::recursive_wrapper<binop<op_lowerOrEqual> >,
	boost::recursive_wrapper<comop<op_lower> >,
	boost::recursive_wrapper<binop<op_unequal> >,
	boost::recursive_wrapper<binop<op_and> >,
	boost::recursive_wrapper<binop<op_xor> >,
	boost::recursive_wrapper<binop<op_or> >,
	boost::recursive_wrapper<binop<op_difference> >,
	boost::recursive_wrapper<binop<op_sum> >,
	boost::recursive_wrapper<binop<op_factor> >,
	boost::recursive_wrapper<binop<op_division> >,
	boost::recursive_wrapper<binop<op_power> >, 
	boost::recursive_wrapper<binop<op_powerTen> >,
	boost::recursive_wrapper<unop<op_minusSign> >,
	boost::recursive_wrapper<unop<op_plusSign> >
> ExpressionContainer;


template <typename tag> struct binop
{
	explicit binop(const ExpressionContainer& l, const ExpressionContainer& r) : oper1(l), oper2(r) { }
	ExpressionContainer oper1, oper2;
};

template <typename tag> struct comop
{
    explicit comop(const ExpressionContainer& l, const ExpressionContainer& r) : oper1(l), oper2(r) { }
    ExpressionContainer oper1, oper2;
};

template <typename tag> struct unop
{
    explicit unop(const ExpressionContainer& o) : oper1(o) { }
    ExpressionContainer oper1;
};

} /* namespace Expression */

} /* namespace parser */
} /* namespace AMDA */

#endif