mirror of
https://github.com/boostorg/yap.git
synced 2026-02-22 16:02:10 +00:00
Add op_string().
This commit is contained in:
@@ -33,6 +33,59 @@ namespace boost::proto17 {
|
||||
|
||||
}
|
||||
|
||||
inline char const * op_string (expr_kind kind)
|
||||
{
|
||||
switch (kind) {
|
||||
case expr_kind::unary_plus: return "+";
|
||||
case expr_kind::negate: return "-";
|
||||
case expr_kind::dereference: return "*";
|
||||
case expr_kind::complement: return "~";
|
||||
case expr_kind::address_of: return "&";
|
||||
case expr_kind::logical_not: return "!";
|
||||
case expr_kind::pre_inc: return "++";
|
||||
case expr_kind::pre_dec: return "--";
|
||||
case expr_kind::post_inc: return "++(int)";
|
||||
case expr_kind::post_dec: return "--(int)";
|
||||
|
||||
case expr_kind::shift_left: return "<<";
|
||||
case expr_kind::shift_right: return ">>";
|
||||
case expr_kind::multiplies: return "*";
|
||||
case expr_kind::divides: return "/";
|
||||
case expr_kind::modulus: return "%";
|
||||
case expr_kind::plus: return "+";
|
||||
case expr_kind::minus: return "-";
|
||||
case expr_kind::less: return "<";
|
||||
case expr_kind::greater: return ">";
|
||||
case expr_kind::less_equal: return "<=";
|
||||
case expr_kind::greater_equal: return ">=";
|
||||
case expr_kind::equal_to: return "==";
|
||||
case expr_kind::not_equal_to: return "!=";
|
||||
case expr_kind::logical_or: return "||";
|
||||
case expr_kind::logical_and: return "&&";
|
||||
case expr_kind::bitwise_and: return "&";
|
||||
case expr_kind::bitwise_or: return "|";
|
||||
case expr_kind::bitwise_xor: return "^";
|
||||
case expr_kind::comma: return ",";
|
||||
case expr_kind::mem_ptr: return "->*";
|
||||
case expr_kind::assign: return "=";
|
||||
case expr_kind::shift_left_assign: return "<<=";
|
||||
case expr_kind::shift_right_assign: return ">>=";
|
||||
case expr_kind::multiplies_assign: return "*=";
|
||||
case expr_kind::divides_assign: return "/=";
|
||||
case expr_kind::modulus_assign: return "%=";
|
||||
case expr_kind::plus_assign: return "+=";
|
||||
case expr_kind::minus_assign: return "-=";
|
||||
case expr_kind::bitwise_and_assign: return "&=";
|
||||
case expr_kind::bitwise_or_assign: return "|=";
|
||||
case expr_kind::bitwise_xor_assign: return "^=";
|
||||
case expr_kind::subscript: return "[]";
|
||||
|
||||
case expr_kind::call: return "()";
|
||||
|
||||
default: return "** ERROR: UNKNOWN OPERATOR! **";
|
||||
}
|
||||
}
|
||||
|
||||
template <expr_kind Kind, typename Tuple>
|
||||
struct expression
|
||||
{
|
||||
|
||||
52
print.hpp
52
print.hpp
@@ -13,57 +13,7 @@ namespace boost::proto17 {
|
||||
namespace detail {
|
||||
|
||||
inline std::ostream & print_kind (std::ostream & os, expr_kind kind)
|
||||
{
|
||||
switch (kind) {
|
||||
case expr_kind::unary_plus: return os << "+";
|
||||
case expr_kind::negate: return os << "-";
|
||||
case expr_kind::dereference: return os << "*";
|
||||
case expr_kind::complement: return os << "~";
|
||||
case expr_kind::address_of: return os << "&";
|
||||
case expr_kind::logical_not: return os << "!";
|
||||
case expr_kind::pre_inc: return os << "++";
|
||||
case expr_kind::pre_dec: return os << "--";
|
||||
case expr_kind::post_inc: return os << "++(int)";
|
||||
case expr_kind::post_dec: return os << "--(int)";
|
||||
|
||||
case expr_kind::shift_left: return os << "<<";
|
||||
case expr_kind::shift_right: return os << ">>";
|
||||
case expr_kind::multiplies: return os << "*";
|
||||
case expr_kind::divides: return os << "/";
|
||||
case expr_kind::modulus: return os << "%";
|
||||
case expr_kind::plus: return os << "+";
|
||||
case expr_kind::minus: return os << "-";
|
||||
case expr_kind::less: return os << "<";
|
||||
case expr_kind::greater: return os << ">";
|
||||
case expr_kind::less_equal: return os << "<=";
|
||||
case expr_kind::greater_equal: return os << ">=";
|
||||
case expr_kind::equal_to: return os << "==";
|
||||
case expr_kind::not_equal_to: return os << "!=";
|
||||
case expr_kind::logical_or: return os << "||";
|
||||
case expr_kind::logical_and: return os << "&&";
|
||||
case expr_kind::bitwise_and: return os << "&";
|
||||
case expr_kind::bitwise_or: return os << "|";
|
||||
case expr_kind::bitwise_xor: return os << "^";
|
||||
case expr_kind::comma: return os << ",";
|
||||
case expr_kind::mem_ptr: return os << "->*";
|
||||
case expr_kind::assign: return os << "=";
|
||||
case expr_kind::shift_left_assign: return os << "<<=";
|
||||
case expr_kind::shift_right_assign: return os << ">>=";
|
||||
case expr_kind::multiplies_assign: return os << "*=";
|
||||
case expr_kind::divides_assign: return os << "/=";
|
||||
case expr_kind::modulus_assign: return os << "%=";
|
||||
case expr_kind::plus_assign: return os << "+=";
|
||||
case expr_kind::minus_assign: return os << "-=";
|
||||
case expr_kind::bitwise_and_assign: return os << "&=";
|
||||
case expr_kind::bitwise_or_assign: return os << "|=";
|
||||
case expr_kind::bitwise_xor_assign: return os << "^=";
|
||||
case expr_kind::subscript: return os << "[]";
|
||||
|
||||
case expr_kind::call: return os << "()";
|
||||
|
||||
default: return os << "** ERROR: UNKNOWN OPERATOR! **";
|
||||
}
|
||||
}
|
||||
{ return os << op_string(kind); }
|
||||
|
||||
template <typename T>
|
||||
auto print_value (std::ostream & os, T const & x) -> decltype(os << x)
|
||||
|
||||
Reference in New Issue
Block a user