10 #ifndef CHAISCRIPT_ALGEBRAIC_HPP_ 11 #define CHAISCRIPT_ALGEBRAIC_HPP_ 13 #include "../utility/hash.hpp" 56 constexpr
static std::string_view to_string(Opers t_oper) noexcept {
57 constexpr
const std::array opers
58 = {
"",
"==",
"<",
">",
"<=",
">=",
"!=",
"",
"=",
"++",
"--",
"*=",
"+=",
"/=",
"-=",
"",
"&=",
"|=",
"<<=",
">>=",
"%=",
"^=",
"",
"<<",
">>",
"%",
"&",
"|",
"^",
"~",
"",
"+",
"/",
"*",
"-",
"+",
"-",
""};
59 return opers[
static_cast<std::size_t
>(t_oper)];
62 constexpr
static Opers to_operator(std::string_view t_str,
bool t_is_unary =
false) noexcept {
63 #ifdef CHAISCRIPT_MSVC 65 #pragma warning(disable : 4307) 68 const auto op_hash = utility::hash(t_str);
70 case utility::hash(
"=="): {
73 case utility::hash(
"<"): {
74 return Opers::less_than;
76 case utility::hash(
">"): {
77 return Opers::greater_than;
79 case utility::hash(
"<="): {
80 return Opers::less_than_equal;
82 case utility::hash(
">="): {
83 return Opers::greater_than_equal;
85 case utility::hash(
"!="): {
86 return Opers::not_equal;
88 case utility::hash(
"="): {
91 case utility::hash(
"++"): {
92 return Opers::pre_increment;
94 case utility::hash(
"--"): {
95 return Opers::pre_decrement;
97 case utility::hash(
"*="): {
98 return Opers::assign_product;
100 case utility::hash(
"+="): {
101 return Opers::assign_sum;
103 case utility::hash(
"-="): {
104 return Opers::assign_difference;
106 case utility::hash(
"&="): {
107 return Opers::assign_bitwise_and;
109 case utility::hash(
"|="): {
110 return Opers::assign_bitwise_or;
112 case utility::hash(
"<<="): {
113 return Opers::assign_shift_left;
115 case utility::hash(
">>="): {
116 return Opers::assign_shift_right;
118 case utility::hash(
"%="): {
119 return Opers::assign_remainder;
121 case utility::hash(
"^="): {
122 return Opers::assign_bitwise_xor;
124 case utility::hash(
"<<"): {
125 return Opers::shift_left;
127 case utility::hash(
">>"): {
128 return Opers::shift_right;
130 case utility::hash(
"%"): {
131 return Opers::remainder;
133 case utility::hash(
"&"): {
134 return Opers::bitwise_and;
136 case utility::hash(
"|"): {
137 return Opers::bitwise_or;
139 case utility::hash(
"^"): {
140 return Opers::bitwise_xor;
142 case utility::hash(
"~"): {
143 return Opers::bitwise_complement;
145 case utility::hash(
"+"): {
146 return t_is_unary ? Opers::unary_plus : Opers::sum;
148 case utility::hash(
"-"): {
149 return t_is_unary ? Opers::unary_minus : Opers::difference;
151 case utility::hash(
"/"): {
152 return Opers::quotient;
154 case utility::hash(
"*"): {
155 return Opers::product;
158 return Opers::invalid;
161 #ifdef CHAISCRIPT_MSVC Namespace chaiscript contains every API call that the average user will be concerned with...
Definition: chaiscript_algebraic.hpp:19