1 /*============================================================================= 2 Copyright (c) 2001-2011 Joel de Guzman 3 Copyright (c) 2001-2011 Hartmut Kaiser 4 5 Distributed under the Boost Software License, Version 1.0. (See accompanying 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 =============================================================================*/ 8 #if !defined(BOOST_SPIRIT_CONJURE_IDS_HPP) 9 #define BOOST_SPIRIT_CONJURE_IDS_HPP 10 11 namespace client 12 { 13 struct op_type 14 { 15 enum type 16 { 17 binary = 0x20000, 18 unary = 0x40000, 19 assign = 0x80000 20 }; 21 }; 22 23 struct op 24 { 25 enum type 26 { 27 // binary 28 comma, 29 assign, 30 plus_assign, 31 minus_assign, 32 times_assign, 33 divide_assign, 34 mod_assign, 35 bit_and_assign, 36 bit_xor_assign, 37 bit_or_assign, 38 shift_left_assign, 39 shift_right_assign, 40 logical_or, 41 logical_and, 42 bit_or, 43 bit_xor, 44 bit_and, 45 equal, 46 not_equal, 47 less, 48 less_equal, 49 greater, 50 greater_equal, 51 shift_left, 52 shift_right, 53 plus, 54 minus, 55 times, 56 divide, 57 mod, 58 59 // unary 60 plus_plus, 61 minus_minus, 62 compl_, 63 not_, 64 }; 65 }; 66 67 template <int type, int op> 68 struct make_op 69 { 70 static int const value = type + op; 71 }; 72 73 template <op::type op> 74 struct unary_op : make_op<op_type::unary, op> {}; 75 76 template <op::type op> 77 struct binary_op 78 : make_op<op_type::binary, op> {}; 79 80 template <op::type op> 81 struct assign_op 82 : make_op<op_type::assign, op> {}; 83 84 template <op::type op> 85 struct binary_or_unary_op 86 : make_op<op_type::unary | op_type::binary, op> {}; 87 88 struct token_ids 89 { 90 enum type 91 { 92 // pseudo tags 93 invalid = -1, 94 op_binary = op_type::binary, 95 op_unary = op_type::unary, 96 op_assign = op_type::assign, 97 98 // binary / unary operators with common tokens 99 // '+' and '-' can be binary or unary 100 // (the lexer cannot distinguish which) 101 plus = binary_or_unary_op<op::plus>::value, 102 minus = binary_or_unary_op<op::minus>::value, 103 104 // binary operators 105 comma = binary_op<op::comma>::value, 106 assign = assign_op<op::assign>::value, 107 plus_assign = assign_op<op::plus_assign>::value, 108 minus_assign = assign_op<op::minus_assign>::value, 109 times_assign = assign_op<op::times_assign>::value, 110 divide_assign = assign_op<op::divide_assign>::value, 111 mod_assign = assign_op<op::mod_assign>::value, 112 bit_and_assign = assign_op<op::bit_and_assign>::value, 113 bit_xor_assign = assign_op<op::bit_xor_assign>::value, 114 bit_or_assign = assign_op<op::bit_or_assign>::value, 115 shift_left_assign = assign_op<op::shift_left_assign>::value, 116 shift_right_assign = assign_op<op::shift_right_assign>::value, 117 logical_or = binary_op<op::logical_or>::value, 118 logical_and = binary_op<op::logical_and>::value, 119 bit_or = binary_op<op::bit_or>::value, 120 bit_xor = binary_op<op::bit_xor>::value, 121 bit_and = binary_op<op::bit_and>::value, 122 equal = binary_op<op::equal>::value, 123 not_equal = binary_op<op::not_equal>::value, 124 less = binary_op<op::less>::value, 125 less_equal = binary_op<op::less_equal>::value, 126 greater = binary_op<op::greater>::value, 127 greater_equal = binary_op<op::greater_equal>::value, 128 shift_left = binary_op<op::shift_left>::value, 129 shift_right = binary_op<op::shift_right>::value, 130 times = binary_op<op::times>::value, 131 divide = binary_op<op::divide>::value, 132 mod = binary_op<op::mod>::value, 133 134 // unary operators with overlaps 135 // '++' and '--' can be prefix or postfix 136 // (the lexer cannot distinguish which) 137 plus_plus = unary_op<op::plus_plus>::value, 138 minus_minus = unary_op<op::minus_minus>::value, 139 140 // unary operators 141 compl_ = unary_op<op::compl_>::value, 142 not_ = unary_op<op::not_>::value, 143 144 // misc tags 145 identifier = op::not_ + 1, 146 comment, 147 whitespace, 148 lit_uint, 149 true_or_false 150 }; 151 }; 152 } 153 154 #endif 155