From d92e6b97e5341794d9f74c44b5603662c4e13c7e Mon Sep 17 00:00:00 2001 From: Tim Quatmann Date: Mon, 2 Mar 2020 08:53:58 +0100 Subject: [PATCH] updated exprtk --- resources/3rdparty/exprtk/exprtk.hpp | 7567 ++++++++++------- .../exprtk.h => adapters/ExprttkAdapter.h} | 3 + .../expressions/ExprtkCompiledExpression.h | 2 +- .../expressions/ExprtkExpressionEvaluator.h | 2 +- 4 files changed, 4564 insertions(+), 3010 deletions(-) mode change 100755 => 100644 resources/3rdparty/exprtk/exprtk.hpp rename src/storm/{utility/exprtk.h => adapters/ExprttkAdapter.h} (69%) diff --git a/resources/3rdparty/exprtk/exprtk.hpp b/resources/3rdparty/exprtk/exprtk.hpp old mode 100755 new mode 100644 index e8c156596..68afc0d46 --- a/resources/3rdparty/exprtk/exprtk.hpp +++ b/resources/3rdparty/exprtk/exprtk.hpp @@ -2,7 +2,7 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2020) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -66,10 +66,31 @@ namespace exprtk #define exprtk_debug(params) (void)0 #endif + #define exprtk_error_location \ + "exprtk.hpp:" + details::to_str(__LINE__) \ + + #if defined(__GNUC__) && (__GNUC__ >= 7) + + #define exprtk_disable_fallthrough_begin \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") \ + + #define exprtk_disable_fallthrough_end \ + _Pragma ("GCC diagnostic pop") \ + + #else + #define exprtk_disable_fallthrough_begin (void)0; + #define exprtk_disable_fallthrough_end (void)0; + #endif + namespace details { - typedef unsigned char uchar_t; - typedef char char_t; + typedef unsigned char uchar_t; + typedef char char_t; + typedef uchar_t* uchar_ptr; + typedef char_t* char_ptr; + typedef uchar_t const* uchar_cptr; + typedef char_t const* char_cptr; inline bool is_whitespace(const char_t c) { @@ -143,13 +164,18 @@ namespace exprtk ('\'' != c); } + #ifndef exprtk_disable_caseinsensitivity + inline void case_normalise(std::string& s) + { + for (std::size_t i = 0; i < s.size(); ++i) + { + s[i] = static_cast(std::tolower(s[i])); + } + } + inline bool imatch(const char_t c1, const char_t c2) { - #ifdef MODIFICATION - return c1 == c2; - #else return std::tolower(c1) == std::tolower(c2); - #endif } inline bool imatch(const std::string& s1, const std::string& s2) @@ -158,11 +184,7 @@ namespace exprtk { for (std::size_t i = 0; i < s1.size(); ++i) { - #ifdef MODIFICATION - if (s1[i] != s2[i]) - #else if (std::tolower(s1[i]) != std::tolower(s2[i])) - #endif { return false; } @@ -174,6 +196,50 @@ namespace exprtk return false; } + struct ilesscompare + { + inline bool operator() (const std::string& s1, const std::string& s2) const + { + const std::size_t length = std::min(s1.size(),s2.size()); + + for (std::size_t i = 0; i < length; ++i) + { + const char_t c1 = static_cast(std::tolower(s1[i])); + const char_t c2 = static_cast(std::tolower(s2[i])); + + if (c1 > c2) + return false; + else if (c1 < c2) + return true; + } + + return s1.size() < s2.size(); + } + }; + + #else + inline void case_normalise(std::string&) + {} + + inline bool imatch(const char_t c1, const char_t c2) + { + return c1 == c2; + } + + inline bool imatch(const std::string& s1, const std::string& s2) + { + return s1 == s2; + } + + struct ilesscompare + { + inline bool operator() (const std::string& s1, const std::string& s2) const + { + return s1 < s2; + } + }; + #endif + inline bool is_valid_sf_symbol(const std::string& symbol) { // Special function: $f12 or $F34 @@ -184,12 +250,12 @@ namespace exprtk is_digit(symbol[3]); } - inline const char& front(const std::string& s) + inline const char_t& front(const std::string& s) { return s[0]; } - inline const char& back(const std::string& s) + inline const char_t& back(const std::string& s) { return s[s.size() - 1]; } @@ -223,6 +289,11 @@ namespace exprtk return result; } + inline std::string to_str(std::size_t i) + { + return to_str(static_cast(i)); + } + inline bool is_hex_digit(const std::string::value_type digit) { return (('0' <= digit) && (digit <= '9')) || @@ -255,7 +326,8 @@ namespace exprtk (is_hex_digit(*(itr + 3))) ) { - result = hex_to_bin(*(itr + 2)) << 4 | hex_to_bin(*(itr + 3)); + result = hex_to_bin(static_cast(*(itr + 2))) << 4 | + hex_to_bin(static_cast(*(itr + 3))) ; itr += 3; } else @@ -323,7 +395,7 @@ namespace exprtk return (*this); } - inline build_string& operator << (const char* s) + inline build_string& operator << (char_cptr s) { data_ += std::string(s); return (*this); @@ -344,32 +416,6 @@ namespace exprtk std::string data_; }; - struct ilesscompare - { - inline bool operator()(const std::string& s1, const std::string& s2) const - { - const std::size_t length = std::min(s1.size(),s2.size()); - - for (std::size_t i = 0; i < length; ++i) - { - #ifdef MODIFICATION - const char_t c1 = static_cast(s1[i]); - const char_t c2 = static_cast(s2[i]); - #else - const char_t c1 = static_cast(std::tolower(s1[i])); - const char_t c2 = static_cast(std::tolower(s2[i])); - #endif - - if (c1 > c2) - return false; - else if (c1 < c2) - return true; - } - - return s1.size() < s2.size(); - } - }; - static const std::string reserved_words[] = { "break", "case", "continue", "default", "false", "for", @@ -457,7 +503,7 @@ namespace exprtk { for (std::size_t i = 0; i < reserved_words_size; ++i) { - if (imatch(symbol,reserved_words[i])) + if (imatch(symbol, reserved_words[i])) { return true; } @@ -470,7 +516,7 @@ namespace exprtk { for (std::size_t i = 0; i < reserved_symbols_size; ++i) { - if (imatch(symbol,reserved_symbols[i])) + if (imatch(symbol, reserved_symbols[i])) { return true; } @@ -483,7 +529,7 @@ namespace exprtk { for (std::size_t i = 0; i < base_function_list_size; ++i) { - if (imatch(function_name,base_function_list[i])) + if (imatch(function_name, base_function_list[i])) { return true; } @@ -496,7 +542,7 @@ namespace exprtk { for (std::size_t i = 0; i < cntrl_struct_list_size; ++i) { - if (imatch(cntrl_strct,cntrl_struct_list[i])) + if (imatch(cntrl_strct, cntrl_struct_list[i])) { return true; } @@ -509,7 +555,7 @@ namespace exprtk { for (std::size_t i = 0; i < logic_ops_list_size; ++i) { - if (imatch(lgc_opr,logic_ops_list[i])) + if (imatch(lgc_opr, logic_ops_list[i])) { return true; } @@ -522,11 +568,7 @@ namespace exprtk { static inline bool cmp(const char_t c0, const char_t c1) { - #ifdef MODIFICATION return (c0 == c1); - #else - return (std::tolower(c0) == std::tolower(c1)); - #endif } }; @@ -540,89 +582,92 @@ namespace exprtk template inline bool match_impl(const Iterator pattern_begin, - const Iterator pattern_end, - const Iterator data_begin, - const Iterator data_end, + const Iterator pattern_end , + const Iterator data_begin , + const Iterator data_end , const typename std::iterator_traits::value_type& zero_or_more, - const typename std::iterator_traits::value_type& zero_or_one) + const typename std::iterator_traits::value_type& zero_or_one ) { - if (0 == std::distance(data_begin,data_end)) - { - return false; - } + const Iterator null_itr(0); - Iterator d_itr = data_begin; - Iterator p_itr = pattern_begin; - Iterator c_itr = data_begin; - Iterator m_itr = data_begin; + Iterator d_itr = data_begin; + Iterator p_itr = pattern_begin; + Iterator tb_p_itr = null_itr; + Iterator tb_d_itr = null_itr; - while ((data_end != d_itr) && (zero_or_more != (*p_itr))) + while (d_itr != data_end) { - if ((!Compare::cmp((*p_itr),(*d_itr))) && (zero_or_one != (*p_itr))) + if (zero_or_more == *p_itr) { - return false; - } + while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) + { + ++p_itr; + } - ++p_itr; - ++d_itr; - } + if (pattern_end == p_itr) + return true; - while (data_end != d_itr) - { - if (zero_or_more == (*p_itr)) - { - if (pattern_end == (++p_itr)) + const typename std::iterator_traits::value_type c = *(p_itr); + + while ((data_end != d_itr) && !Compare::cmp(c,*d_itr)) { - return true; + ++d_itr; } - m_itr = p_itr; - c_itr = d_itr; - ++c_itr; - } - else if ((Compare::cmp((*p_itr),(*d_itr))) || (zero_or_one == (*p_itr))) - { - ++p_itr; - ++d_itr; + tb_p_itr = p_itr; + tb_d_itr = d_itr; + + continue; } - else + else if (!Compare::cmp(*p_itr, *d_itr) && (zero_or_one != *p_itr)) { - p_itr = m_itr; - d_itr = c_itr++; + if (null_itr == tb_d_itr) + return false; + + d_itr = tb_d_itr++; + p_itr = tb_p_itr; + + continue; } + + ++p_itr; + ++d_itr; } - while ((p_itr != pattern_end) && (zero_or_more == (*p_itr))) { ++p_itr; } + while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) + { + ++p_itr; + } - return (p_itr == pattern_end); + return (pattern_end == p_itr); } inline bool wc_match(const std::string& wild_card, const std::string& str) { - return match_impl(wild_card.data(), - wild_card.data() + wild_card.size(), - str.data(), - str.data() + str.size(), - '*', - '?'); + return match_impl(wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), + '*', + '?'); } inline bool wc_imatch(const std::string& wild_card, const std::string& str) { - return match_impl(wild_card.data(), - wild_card.data() + wild_card.size(), - str.data(), - str.data() + str.size(), - '*', - '?'); + return match_impl(wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), + '*', + '?'); } inline bool sequence_match(const std::string& pattern, const std::string& str, std::size_t& diff_index, - char& diff_value) + char_t& diff_value) { if (str.empty()) { @@ -647,7 +692,7 @@ namespace exprtk if ('*' == target) { - diff_index = std::distance(str.begin(),s_itr); + diff_index = static_cast(std::distance(str.begin(),s_itr)); diff_value = static_cast(std::toupper(*p_itr)); return false; @@ -670,7 +715,7 @@ namespace exprtk std::toupper(*p_itr) != std::toupper(*s_itr) ) { - diff_index = std::distance(str.begin(),s_itr); + diff_index = static_cast(std::distance(str.begin(),s_itr)); diff_value = static_cast(std::toupper(*p_itr)); return false; @@ -697,7 +742,7 @@ namespace exprtk 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016 }; - static const std::size_t pow10_size = sizeof(pow10) / sizeof(double); + static const std::size_t pow10_size = sizeof(pow10) / sizeof(double); namespace numeric { @@ -717,23 +762,29 @@ namespace exprtk namespace details { - struct unknown_type_tag {}; - struct real_type_tag {}; - struct complex_type_tag {}; - struct int_type_tag {}; + struct unknown_type_tag { unknown_type_tag() {} }; + struct real_type_tag { real_type_tag () {} }; + struct complex_type_tag { complex_type_tag() {} }; + struct int_type_tag { int_type_tag () {} }; template - struct number_type { typedef unknown_type_tag type; }; + struct number_type + { + typedef unknown_type_tag type; + number_type() {} + }; - #define exprtk_register_real_type_tag(T) \ - template<> struct number_type { typedef real_type_tag type; }; \ + #define exprtk_register_real_type_tag(T) \ + template<> struct number_type \ + { typedef real_type_tag type; number_type() {} }; \ - #define exprtk_register_complex_type_tag(T) \ - template<> struct number_type > \ - { typedef complex_type_tag type; }; \ + #define exprtk_register_complex_type_tag(T) \ + template<> struct number_type > \ + { typedef complex_type_tag type; number_type() {} }; \ - #define exprtk_register_int_type_tag(T) \ - template<> struct number_type { typedef int_type_tag type; }; \ + #define exprtk_register_int_type_tag(T) \ + template<> struct number_type \ + { typedef int_type_tag type; number_type() {} }; \ exprtk_register_real_type_tag(double ) exprtk_register_real_type_tag(long double) @@ -953,7 +1004,15 @@ namespace exprtk template inline T root_impl(const T v0, const T v1, real_type_tag) { - return std::pow(v0,T(1) / v1); + if (v1 < T(0)) + return std::numeric_limits::quiet_NaN(); + + const std::size_t n = static_cast(v1); + + if ((v0 < T(0)) && (0 == (n % 2))) + return std::numeric_limits::quiet_NaN(); + + return std::pow(v0, T(1) / n); } template @@ -1266,6 +1325,9 @@ namespace exprtk template inline T frac_impl(const T v, real_type_tag) { return (v - static_cast(v)); } template inline T trunc_impl(const T v, real_type_tag) { return T(static_cast(v)); } + template inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } + template inline T const_e_impl (real_type_tag) { return T(numeric::constant::e); } + template inline T abs_impl(const T v, int_type_tag) { return ((v >= T(0)) ? v : -v); } template inline T exp_impl(const T v, int_type_tag) { return std::exp (v); } template inline T log_impl(const T v, int_type_tag) { return std::log (v); } @@ -1320,162 +1382,162 @@ namespace exprtk template inline int to_int32(const T v) { - typename details::number_type::type num_type; - return to_int32_impl(v,num_type); + const typename details::number_type::type num_type; + return to_int32_impl(v, num_type); } template inline long long int to_int64(const T v) { - typename details::number_type::type num_type; - return to_int64_impl(v,num_type); + const typename details::number_type::type num_type; + return to_int64_impl(v, num_type); } template inline bool is_nan(const T v) { - typename details::number_type::type num_type; - return is_nan_impl(v,num_type); + const typename details::number_type::type num_type; + return is_nan_impl(v, num_type); } template inline T min(const T v0, const T v1) { - typename details::number_type::type num_type; - return min_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return min_impl(v0, v1, num_type); } template inline T max(const T v0, const T v1) { - typename details::number_type::type num_type; - return max_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return max_impl(v0, v1, num_type); } template inline T equal(const T v0, const T v1) { - typename details::number_type::type num_type; - return equal_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return equal_impl(v0, v1, num_type); } template inline T nequal(const T v0, const T v1) { - typename details::number_type::type num_type; - return nequal_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return nequal_impl(v0, v1, num_type); } template inline T modulus(const T v0, const T v1) { - typename details::number_type::type num_type; - return modulus_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return modulus_impl(v0, v1, num_type); } template inline T pow(const T v0, const T v1) { - typename details::number_type::type num_type; - return pow_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return pow_impl(v0, v1, num_type); } template inline T logn(const T v0, const T v1) { - typename details::number_type::type num_type; - return logn_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return logn_impl(v0, v1, num_type); } template inline T root(const T v0, const T v1) { - typename details::number_type::type num_type; - return root_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return root_impl(v0, v1, num_type); } template inline T roundn(const T v0, const T v1) { - typename details::number_type::type num_type; - return roundn_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return roundn_impl(v0, v1, num_type); } template inline T hypot(const T v0, const T v1) { - typename details::number_type::type num_type; - return hypot_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return hypot_impl(v0, v1, num_type); } template inline T atan2(const T v0, const T v1) { - typename details::number_type::type num_type; - return atan2_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return atan2_impl(v0, v1, num_type); } template inline T shr(const T v0, const T v1) { - typename details::number_type::type num_type; - return shr_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return shr_impl(v0, v1, num_type); } template inline T shl(const T v0, const T v1) { - typename details::number_type::type num_type; - return shl_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return shl_impl(v0, v1, num_type); } template inline T and_opr(const T v0, const T v1) { - typename details::number_type::type num_type; - return and_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return and_impl(v0, v1, num_type); } template inline T nand_opr(const T v0, const T v1) { - typename details::number_type::type num_type; - return nand_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return nand_impl(v0, v1, num_type); } template inline T or_opr(const T v0, const T v1) { - typename details::number_type::type num_type; - return or_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return or_impl(v0, v1, num_type); } template inline T nor_opr(const T v0, const T v1) { - typename details::number_type::type num_type; - return nor_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return nor_impl(v0, v1, num_type); } template inline T xor_opr(const T v0, const T v1) { - typename details::number_type::type num_type; - return xor_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return xor_impl(v0, v1, num_type); } template inline T xnor_opr(const T v0, const T v1) { - typename details::number_type::type num_type; - return xnor_impl(v0,v1,num_type); + const typename details::number_type::type num_type; + return xnor_impl(v0, v1, num_type); } template inline bool is_integer(const T v) { - typename details::number_type::type num_type; - return is_integer_impl(v,num_type); + const typename details::number_type::type num_type; + return is_integer_impl(v, num_type); } template @@ -1514,13 +1576,13 @@ namespace exprtk template struct fast_exp { static inline T result(T v) { return v; } }; template struct fast_exp { static inline T result(T ) { return T(1); } }; - #define exprtk_define_unary_function(FunctionName) \ - template \ - inline T FunctionName (const T v) \ - { \ - typename details::number_type::type num_type; \ - return FunctionName##_impl(v,num_type); \ - } \ + #define exprtk_define_unary_function(FunctionName) \ + template \ + inline T FunctionName (const T v) \ + { \ + const typename details::number_type::type num_type; \ + return FunctionName##_impl(v,num_type); \ + } \ exprtk_define_unary_function(abs ) exprtk_define_unary_function(acos ) @@ -1633,7 +1695,7 @@ namespace exprtk if (itr == end) return false; - bool negative = ('-' == (*itr)); + const bool negative = ('-' == (*itr)); if (negative || ('+' == (*itr))) { @@ -1641,34 +1703,51 @@ namespace exprtk return false; } - while ((end != itr) && ('0' == (*itr))) ++itr; + static const uchar_t zero = static_cast('0'); + + while ((end != itr) && (zero == (*itr))) ++itr; bool return_result = true; unsigned int digit = 0; - const std::size_t length = std::distance(itr,end); + const std::size_t length = static_cast(std::distance(itr,end)); if (length <= 4) { + exprtk_disable_fallthrough_begin switch (length) { #ifdef exprtk_use_lut - #define exprtk_process_digit \ - if ((digit = details::digit_table[(int)*itr++]) < 10) result = result * 10 + (digit); else { return_result = false; break; } + #define exprtk_process_digit \ + if ((digit = details::digit_table[(int)*itr++]) < 10) \ + result = result * 10 + (digit); \ + else \ + { \ + return_result = false; \ + break; \ + } \ #else - #define exprtk_process_digit \ - if ((digit = (*itr++ - '0')) < 10) result = result * 10 + (digit); else { return_result = false; break; } + + #define exprtk_process_digit \ + if ((digit = (*itr++ - zero)) < 10) \ + result = result * T(10) + digit; \ + else \ + { \ + return_result = false; \ + break; \ + } \ #endif case 4 : exprtk_process_digit case 3 : exprtk_process_digit case 2 : exprtk_process_digit - case 1 : if ((digit = (*itr - '0'))>= 10) { digit = 0; return_result = false; } + case 1 : if ((digit = (*itr - zero))>= 10) { digit = 0; return_result = false; } #undef exprtk_process_digit } + exprtk_disable_fallthrough_end } else return_result = false; @@ -1723,12 +1802,12 @@ namespace exprtk static const char_t inf_lc[] = "infinity"; static const std::size_t inf_length = 8; - const std::size_t length = std::distance(itr,end); + const std::size_t length = static_cast(std::distance(itr,end)); if ((3 != length) && (inf_length != length)) return false; - const char* inf_itr = ('i' == (*itr)) ? inf_lc : inf_uc; + char_cptr inf_itr = ('i' == (*itr)) ? inf_lc : inf_uc; while (end != itr) { @@ -1759,7 +1838,7 @@ namespace exprtk T d = T(0); - bool negative = ('-' == (*itr)); + const bool negative = ('-' == (*itr)); if (negative || '+' == (*itr)) { @@ -1769,23 +1848,27 @@ namespace exprtk bool instate = false; - #define parse_digit_1(d) \ - if ((digit = (*itr - '0')) < 10) \ - { d = d * T(10) + digit; } \ - else \ - { break; } \ - if (end == ++itr) break; \ + static const char_t zero = static_cast('0'); - #define parse_digit_2(d) \ - if ((digit = (*itr - '0')) < 10) \ - { d = d * T(10) + digit; } \ - else { break; } \ - ++itr; \ + #define parse_digit_1(d) \ + if ((digit = (*itr - zero)) < 10) \ + { d = d * T(10) + digit; } \ + else \ + { break; } \ + if (end == ++itr) break; \ + + #define parse_digit_2(d) \ + if ((digit = (*itr - zero)) < 10) \ + { d = d * T(10) + digit; } \ + else { break; } \ + ++itr; \ if ('.' != (*itr)) { const Iterator curr = itr; - while ((end != itr) && ('0' == (*itr))) ++itr; + + while ((end != itr) && (zero == (*itr))) ++itr; + unsigned int digit; while (end != itr) @@ -1844,7 +1927,7 @@ namespace exprtk { int exp = 0; - if (!details::string_to_type_converter_impl_ref(++itr,end,exp)) + if (!details::string_to_type_converter_impl_ref(++itr, end, exp)) { if (end == itr) return false; @@ -1867,11 +1950,11 @@ namespace exprtk { if (('i' == (*itr)) || ('I' == (*itr))) { - return parse_inf(itr,end,t,negative); + return parse_inf(itr, end, t, negative); } else if (('n' == (*itr)) || ('N' == (*itr))) { - return parse_nan(itr,end,t); + return parse_nan(itr, end, t); } else return false; @@ -1883,11 +1966,11 @@ namespace exprtk { if (('i' == (*itr)) || ('I' == (*itr))) { - return parse_inf(itr,end,t,negative); + return parse_inf(itr, end, t, negative); } else if (('n' == (*itr)) || ('N' == (*itr))) { - return parse_nan(itr,end,t); + return parse_nan(itr, end, t); } else return false; @@ -1910,10 +1993,12 @@ namespace exprtk template inline bool string_to_real(const std::string& s, T& t) { - const char* begin = s.data(); - const char* end = s.data() + s.size(); - typename numeric::details::number_type::type num_type; - return string_to_real(begin,end,t,num_type); + const typename numeric::details::number_type::type num_type; + + char_cptr begin = s.data(); + char_cptr end = s.data() + s.size(); + + return string_to_real(begin, end, t, num_type); } template @@ -1972,13 +2057,15 @@ namespace exprtk } template - inline token& set_operator(const token_type tt, const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) + inline token& set_operator(const token_type tt, + const Iterator begin, const Iterator end, + const Iterator base_begin = Iterator(0)) { type = tt; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); - return *this; + position = static_cast(std::distance(base_begin,begin)); + return (*this); } template @@ -1987,8 +2074,8 @@ namespace exprtk type = e_symbol; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); - return *this; + position = static_cast(std::distance(base_begin,begin)); + return (*this); } template @@ -1997,8 +2084,8 @@ namespace exprtk type = e_number; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); - return *this; + position = static_cast(std::distance(base_begin,begin)); + return (*this); } template @@ -2007,8 +2094,8 @@ namespace exprtk type = e_string; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); - return *this; + position = static_cast(std::distance(base_begin,begin)); + return (*this); } inline token& set_string(const std::string& s, const std::size_t p) @@ -2016,11 +2103,13 @@ namespace exprtk type = e_string; value = s; position = p; - return *this; + return (*this); } template - inline token& set_error(const token_type et, const Iterator begin, const Iterator end, const Iterator base_begin = Iterator(0)) + inline token& set_error(const token_type et, + const Iterator begin, const Iterator end, + const Iterator base_begin = Iterator(0)) { if ( (e_error == et) || @@ -2038,9 +2127,9 @@ namespace exprtk value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); + position = static_cast(std::distance(base_begin,begin)); - return *this; + return (*this); } static inline std::string to_str(token_type t) @@ -2146,9 +2235,7 @@ namespace exprtk { scan_token(); - if (token_list_.empty()) - return true; - else if (token_list_.back().is_error()) + if (!token_list_.empty() && token_list_.back().is_error()) return false; } @@ -2238,8 +2325,8 @@ namespace exprtk inline std::string substr(const std::size_t& begin, const std::size_t& end) { - const char* begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_; - const char* end_itr = ((base_itr_ + end) < s_end_) ? (base_itr_ + end) : s_end_; + const details::char_cptr begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_; + const details::char_cptr end_itr = ((base_itr_ + end) < s_end_) ? (base_itr_ + end) : s_end_; return std::string(begin_itr,end_itr); } @@ -2256,11 +2343,28 @@ namespace exprtk private: - inline bool is_end(const char* itr) + inline bool is_end(details::char_cptr itr) { return (s_end_ == itr); } + inline bool is_comment_start(details::char_cptr itr) + { + #ifndef exprtk_disable_comments + const char_t c0 = *(itr + 0); + const char_t c1 = *(itr + 1); + + if ('#' == c0) + return true; + else if (!is_end(itr + 1)) + { + if (('/' == c0) && ('/' == c1)) return true; + if (('/' == c0) && ('*' == c1)) return true; + } + #endif + return false; + } + inline void skip_whitespace() { while (!is_end(s_itr_) && details::is_whitespace(*s_itr_)) @@ -2290,47 +2394,72 @@ namespace exprtk return (0 != mode); } - static inline bool comment_end(const char_t c0, const char_t c1, const int mode) + static inline bool comment_end(const char_t c0, const char_t c1, int& mode) { - return ( - ((1 == mode) && ('\n' == c0)) || - ((2 == mode) && ( '*' == c0) && ('/' == c1)) - ); + if ( + ((1 == mode) && ('\n' == c0)) || + ((2 == mode) && ( '*' == c0) && ('/' == c1)) + ) + { + mode = 0; + return true; + } + else + return false; } }; int mode = 0; int increment = 0; - if (is_end(s_itr_) || is_end((s_itr_ + 1))) + if (is_end(s_itr_)) return; - else if (!test::comment_start(*s_itr_,*(s_itr_ + 1),mode,increment)) + else if (!test::comment_start(*s_itr_, *(s_itr_ + 1), mode, increment)) return; + details::char_cptr cmt_start = s_itr_; + s_itr_ += increment; - while (!is_end(s_itr_) && !test::comment_end(*s_itr_,*(s_itr_ + 1),mode)) + while (!is_end(s_itr_)) { - ++s_itr_; + if ((1 == mode) && test::comment_end(*s_itr_, 0, mode)) + { + ++s_itr_; + return; + } + + if ((2 == mode)) + { + if (!is_end((s_itr_ + 1)) && test::comment_end(*s_itr_, *(s_itr_ + 1), mode)) + { + s_itr_ += 2; + return; + } + } + + ++s_itr_; } - if (!is_end(s_itr_)) + if (2 == mode) { - s_itr_ += mode; - skip_whitespace(); - skip_comments(); + token_t t; + t.set_error(token::e_error, cmt_start, cmt_start + mode, base_itr_); + token_list_.push_back(t); } #endif } inline void scan_token() { - skip_whitespace(); - - skip_comments(); - - if (is_end(s_itr_)) + if (details::is_whitespace(*s_itr_)) { + skip_whitespace(); + return; + } + else if (is_comment_start(s_itr_)) + { + skip_comments(); return; } else if (details::is_operator_char(*s_itr_)) @@ -2426,11 +2555,11 @@ namespace exprtk } if ('<' == c0) - t.set_operator(token_t::e_lt ,s_itr_, s_itr_ + 1, base_itr_); + t.set_operator(token_t::e_lt , s_itr_, s_itr_ + 1, base_itr_); else if ('>' == c0) - t.set_operator(token_t::e_gt ,s_itr_, s_itr_ + 1, base_itr_); + t.set_operator(token_t::e_gt , s_itr_, s_itr_ + 1, base_itr_); else if (';' == c0) - t.set_operator(token_t::e_eof,s_itr_, s_itr_ + 1, base_itr_); + t.set_operator(token_t::e_eof, s_itr_, s_itr_ + 1, base_itr_); else if ('&' == c0) t.set_symbol(s_itr_, s_itr_ + 1, base_itr_); else if ('|' == c0) @@ -2444,7 +2573,7 @@ namespace exprtk inline void scan_symbol() { - const char* initial_itr = s_itr_; + details::char_cptr initial_itr = s_itr_; while (!is_end(s_itr_)) { @@ -2495,11 +2624,11 @@ namespace exprtk (15) .1234e-3 */ - const char* initial_itr = s_itr_; - bool dot_found = false; - bool e_found = false; - bool post_e_sign_found = false; - bool post_e_digit_found = false; + details::char_cptr initial_itr = s_itr_; + bool dot_found = false; + bool e_found = false; + bool post_e_sign_found = false; + bool post_e_digit_found = false; token_t t; while (!is_end(s_itr_)) @@ -2518,9 +2647,9 @@ namespace exprtk continue; } - else if (details::imatch('e',(*s_itr_))) + else if ('e' == std::tolower(*s_itr_)) { - const char& c = *(s_itr_ + 1); + const char_t& c = *(s_itr_ + 1); if (is_end(s_itr_ + 1)) { @@ -2582,7 +2711,7 @@ namespace exprtk inline void scan_special_function() { - const char* initial_itr = s_itr_; + details::char_cptr initial_itr = s_itr_; token_t t; // $fdd(x,x,x) = at least 11 chars @@ -2618,7 +2747,7 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities inline void scan_string() { - const char* initial_itr = s_itr_ + 1; + details::char_cptr initial_itr = s_itr_ + 1; token_t t; if (std::distance(s_itr_,s_end_) < 2) @@ -2656,7 +2785,7 @@ namespace exprtk Note: The following 'awkward' conditional is due to various broken msvc compilers. */ - #if _MSC_VER == 1600 + #if defined(_MSC_VER) && (_MSC_VER == 1600) const bool within_range = !is_end(s_itr_ + 2) && !is_end(s_itr_ + 3) ; #else @@ -2701,8 +2830,12 @@ namespace exprtk else { std::string parsed_string(initial_itr,s_itr_); + details::cleanup_escapes(parsed_string); - t.set_string(parsed_string, std::distance(base_itr_,initial_itr)); + + t.set_string( + parsed_string, + static_cast(std::distance(base_itr_,initial_itr))); } token_list_.push_back(t); @@ -2718,9 +2851,9 @@ namespace exprtk token_list_itr_t token_itr_; token_list_itr_t store_token_itr_; token_t eof_token_; - const char* base_itr_; - const char* s_itr_; - const char* s_end_; + details::char_cptr base_itr_; + details::char_cptr s_itr_; + details::char_cptr s_end_; friend class token_scanner; friend class token_modifier; @@ -2781,7 +2914,7 @@ namespace exprtk const token& t0 = g.token_list_[i ]; const token& t1 = g.token_list_[i + 1]; - if (!operator()(t0,t1)) + if (!operator()(t0, t1)) { return i; } @@ -2794,7 +2927,7 @@ namespace exprtk const token& t1 = g.token_list_[i + 1]; const token& t2 = g.token_list_[i + 2]; - if (!operator()(t0,t1,t2)) + if (!operator()(t0, t1, t2)) { return i; } @@ -2808,7 +2941,7 @@ namespace exprtk const token& t2 = g.token_list_[i + 2]; const token& t3 = g.token_list_[i + 3]; - if (!operator()(t0,t1,t2,t3)) + if (!operator()(t0, t1, t2, t3)) { return i; } @@ -2821,29 +2954,29 @@ namespace exprtk return (g.token_list_.size() - stride_ + 1); } - virtual bool operator()(const token&) + virtual bool operator() (const token&) { return false; } - virtual bool operator()(const token&, const token&) + virtual bool operator() (const token&, const token&) { return false; } - virtual bool operator()(const token&, const token&, const token&) + virtual bool operator() (const token&, const token&, const token&) { return false; } - virtual bool operator()(const token&, const token&, const token&, const token&) + virtual bool operator() (const token&, const token&, const token&, const token&) { return false; } private: - std::size_t stride_; + const std::size_t stride_; }; class token_modifier : public helper_interface @@ -2910,9 +3043,13 @@ namespace exprtk break; } + typedef std::iterator_traits::difference_type diff_t; + if ((insert_index >= 0) && (insert_index <= (static_cast(stride_) + 1))) { - g.token_list_.insert(g.token_list_.begin() + (i + insert_index),t); + g.token_list_.insert( + g.token_list_.begin() + static_cast(i + static_cast(insert_index)), t); + changes++; } } @@ -2944,14 +3081,14 @@ namespace exprtk private: - std::size_t stride_; + const std::size_t stride_; }; class token_joiner : public helper_interface { public: - token_joiner(const std::size_t& stride) + explicit token_joiner(const std::size_t& stride) : stride_(stride) {} @@ -2968,29 +3105,34 @@ namespace exprtk } } - virtual bool join(const token&, const token&, token&) { return false; } + virtual bool join(const token&, const token&, token&) { return false; } virtual bool join(const token&, const token&, const token&, token&) { return false; } private: inline std::size_t process_stride_2(generator& g) { + typedef std::iterator_traits::difference_type diff_t; + if (g.token_list_.size() < 2) return 0; std::size_t changes = 0; - for (std::size_t i = 0; i < (g.token_list_.size() - 1); ++i) + for (int i = 0; i < static_cast(g.token_list_.size() - 1); ++i) { token t; - while (join(g[i],g[i + 1],t)) + while (join(g[i], g[i + 1], t)) { g.token_list_[i] = t; - g.token_list_.erase(g.token_list_.begin() + (i + 1)); + g.token_list_.erase(g.token_list_.begin() + static_cast(i + 1)); ++changes; + + if (static_cast(i + 1) >= g.token_list_.size()) + break; } } @@ -2999,29 +3141,34 @@ namespace exprtk inline std::size_t process_stride_3(generator& g) { + typedef std::iterator_traits::difference_type diff_t; + if (g.token_list_.size() < 3) return 0; std::size_t changes = 0; - for (std::size_t i = 0; i < (g.token_list_.size() - 2); ++i) + for (int i = 0; i < static_cast(g.token_list_.size() - 2); ++i) { token t; - while (join(g[i],g[i + 1],g[i + 2],t)) + while (join(g[i], g[i + 1], g[i + 2], t)) { g.token_list_[i] = t; - g.token_list_.erase(g.token_list_.begin() + (i + 1), - g.token_list_.begin() + (i + 3)); + g.token_list_.erase(g.token_list_.begin() + static_cast(i + 1), + g.token_list_.begin() + static_cast(i + 3)); ++changes; + + if (static_cast(i + 2) >= g.token_list_.size()) + break; } } return changes; } - std::size_t stride_; + const std::size_t stride_; }; namespace helper @@ -3092,6 +3239,7 @@ namespace exprtk else if ((t0.type == lexer::token::e_rbracket ) && (t1.type == lexer::token::e_symbol )) match = true; else if ((t0.type == lexer::token::e_rcrlbracket) && (t1.type == lexer::token::e_symbol )) match = true; else if ((t0.type == lexer::token::e_rsqrbracket) && (t1.type == lexer::token::e_symbol )) match = true; + else if ((t0.type == lexer::token::e_symbol ) && (t1.type == lexer::token::e_symbol )) match = true; return (match) ? 1 : -1; } @@ -3105,7 +3253,7 @@ namespace exprtk { public: - operator_joiner(const std::size_t& stride) + explicit operator_joiner(const std::size_t& stride) : token_joiner(stride) {} @@ -3237,7 +3385,7 @@ namespace exprtk return true; } - // '- -' --> '-' + // '- -' --> '+' else if ((t0.type == lexer::token::e_sub) && (t1.type == lexer::token::e_sub)) { /* @@ -3314,7 +3462,7 @@ namespace exprtk error_token_.clear(); } - bool operator()(const lexer::token& t) + bool operator() (const lexer::token& t) { if ( !t.value.empty() && @@ -3325,7 +3473,7 @@ namespace exprtk { details::char_t c = t.value[0]; - if (t.type == lexer::token::e_lbracket) stack_.push(std::make_pair(')',t.position)); + if (t.type == lexer::token::e_lbracket ) stack_.push(std::make_pair(')',t.position)); else if (t.type == lexer::token::e_lcrlbracket) stack_.push(std::make_pair('}',t.position)); else if (t.type == lexer::token::e_lsqrbracket) stack_.push(std::make_pair(']',t.position)); else if (exprtk::details::is_right_bracket(c)) @@ -3381,7 +3529,7 @@ namespace exprtk current_index_ = 0; } - bool operator()(const lexer::token& t) + bool operator() (const lexer::token& t) { if (token::e_number == t.type) { @@ -3432,7 +3580,7 @@ namespace exprtk bool remove(const std::string& target_symbol) { - replace_map_t::iterator itr = replace_map_.find(target_symbol); + const replace_map_t::iterator itr = replace_map_.find(target_symbol); if (replace_map_.end() == itr) return false; @@ -3446,7 +3594,7 @@ namespace exprtk const std::string& replace_symbol, const lexer::token::token_type token_type = lexer::token::e_symbol) { - replace_map_t::iterator itr = replace_map_.find(target_symbol); + const replace_map_t::iterator itr = replace_map_.find(target_symbol); if (replace_map_.end() != itr) { @@ -3472,7 +3620,7 @@ namespace exprtk if (replace_map_.empty()) return false; - replace_map_t::iterator itr = replace_map_.find(t.value); + const replace_map_t::iterator itr = replace_map_.find(t.value); if (replace_map_.end() != itr) { @@ -3503,11 +3651,11 @@ namespace exprtk sequence_validator() : lexer::token_scanner(2) { - add_invalid(lexer::token::e_number ,lexer::token::e_number ); - add_invalid(lexer::token::e_string ,lexer::token::e_string ); - add_invalid(lexer::token::e_number ,lexer::token::e_string ); - add_invalid(lexer::token::e_string ,lexer::token::e_number ); - add_invalid(lexer::token::e_string ,lexer::token::e_ternary); + add_invalid(lexer::token::e_number, lexer::token::e_number); + add_invalid(lexer::token::e_string, lexer::token::e_string); + add_invalid(lexer::token::e_number, lexer::token::e_string); + add_invalid(lexer::token::e_string, lexer::token::e_number); + add_invalid_set1(lexer::token::e_assign ); add_invalid_set1(lexer::token::e_shr ); add_invalid_set1(lexer::token::e_shl ); @@ -3533,9 +3681,9 @@ namespace exprtk return error_list_.empty(); } - bool operator()(const lexer::token& t0, const lexer::token& t1) + bool operator() (const lexer::token& t0, const lexer::token& t1) { - set_t::value_type p = std::make_pair(t0.type,t1.type); + const set_t::value_type p = std::make_pair(t0.type,t1.type); if (invalid_bracket_check(t0.type,t1.type)) { @@ -3549,7 +3697,7 @@ namespace exprtk return true; } - std::size_t error_count() + std::size_t error_count() const { return error_list_.size(); } @@ -3581,21 +3729,21 @@ namespace exprtk void add_invalid_set1(lexer::token::token_type t) { - add_invalid(t,lexer::token::e_assign); - add_invalid(t,lexer::token::e_shr ); - add_invalid(t,lexer::token::e_shl ); - add_invalid(t,lexer::token::e_lte ); - add_invalid(t,lexer::token::e_ne ); - add_invalid(t,lexer::token::e_gte ); - add_invalid(t,lexer::token::e_lt ); - add_invalid(t,lexer::token::e_gt ); - add_invalid(t,lexer::token::e_eq ); - add_invalid(t,lexer::token::e_comma ); - add_invalid(t,lexer::token::e_div ); - add_invalid(t,lexer::token::e_mul ); - add_invalid(t,lexer::token::e_mod ); - add_invalid(t,lexer::token::e_pow ); - add_invalid(t,lexer::token::e_colon ); + add_invalid(t, lexer::token::e_assign); + add_invalid(t, lexer::token::e_shr ); + add_invalid(t, lexer::token::e_shl ); + add_invalid(t, lexer::token::e_lte ); + add_invalid(t, lexer::token::e_ne ); + add_invalid(t, lexer::token::e_gte ); + add_invalid(t, lexer::token::e_lt ); + add_invalid(t, lexer::token::e_gt ); + add_invalid(t, lexer::token::e_eq ); + add_invalid(t, lexer::token::e_comma ); + add_invalid(t, lexer::token::e_div ); + add_invalid(t, lexer::token::e_mul ); + add_invalid(t, lexer::token::e_mod ); + add_invalid(t, lexer::token::e_pow ); + add_invalid(t, lexer::token::e_colon ); } bool invalid_bracket_check(lexer::token::token_type base, lexer::token::token_type t) @@ -3605,7 +3753,7 @@ namespace exprtk switch (t) { case lexer::token::e_assign : return (']' != base); - case lexer::token::e_string : return true; + case lexer::token::e_string : return (')' != base); default : return false; } } @@ -3626,7 +3774,7 @@ namespace exprtk case lexer::token::e_sub : return false; case lexer::token::e_colon : return false; case lexer::token::e_ternary : return false; - default : return true; + default : return true ; } } } @@ -3640,7 +3788,7 @@ namespace exprtk case lexer::token::e_eof : return false; case lexer::token::e_colon : return false; case lexer::token::e_ternary : return false; - default : return true; + default : return true ; } } else if (details::is_left_bracket(static_cast(t))) @@ -3661,12 +3809,97 @@ namespace exprtk std::vector > error_list_; }; + class sequence_validator_3tokens : public lexer::token_scanner + { + private: + + typedef lexer::token::token_type token_t; + typedef std::pair > token_triplet_t; + typedef std::set set_t; + + public: + + using lexer::token_scanner::operator(); + + sequence_validator_3tokens() + : lexer::token_scanner(3) + { + add_invalid(lexer::token::e_number, lexer::token::e_number, lexer::token::e_number); + add_invalid(lexer::token::e_string, lexer::token::e_string, lexer::token::e_string); + add_invalid(lexer::token::e_comma , lexer::token::e_comma , lexer::token::e_comma ); + + add_invalid(lexer::token::e_add , lexer::token::e_add , lexer::token::e_add ); + add_invalid(lexer::token::e_sub , lexer::token::e_sub , lexer::token::e_sub ); + add_invalid(lexer::token::e_div , lexer::token::e_div , lexer::token::e_div ); + add_invalid(lexer::token::e_mul , lexer::token::e_mul , lexer::token::e_mul ); + add_invalid(lexer::token::e_mod , lexer::token::e_mod , lexer::token::e_mod ); + add_invalid(lexer::token::e_pow , lexer::token::e_pow , lexer::token::e_pow ); + + add_invalid(lexer::token::e_add , lexer::token::e_sub , lexer::token::e_add ); + add_invalid(lexer::token::e_sub , lexer::token::e_add , lexer::token::e_sub ); + add_invalid(lexer::token::e_div , lexer::token::e_mul , lexer::token::e_div ); + add_invalid(lexer::token::e_mul , lexer::token::e_div , lexer::token::e_mul ); + add_invalid(lexer::token::e_mod , lexer::token::e_pow , lexer::token::e_mod ); + add_invalid(lexer::token::e_pow , lexer::token::e_mod , lexer::token::e_pow ); + } + + bool result() + { + return error_list_.empty(); + } + + bool operator() (const lexer::token& t0, const lexer::token& t1, const lexer::token& t2) + { + const set_t::value_type p = std::make_pair(t0.type,std::make_pair(t1.type,t2.type)); + + if (invalid_comb_.find(p) != invalid_comb_.end()) + { + error_list_.push_back(std::make_pair(t0,t1)); + } + + return true; + } + + std::size_t error_count() const + { + return error_list_.size(); + } + + std::pair error(const std::size_t index) + { + if (index < error_list_.size()) + { + return error_list_[index]; + } + else + { + static const lexer::token error_token; + return std::make_pair(error_token,error_token); + } + } + + void clear_errors() + { + error_list_.clear(); + } + + private: + + void add_invalid(token_t t0, token_t t1, token_t t2) + { + invalid_comb_.insert(std::make_pair(t0,std::make_pair(t1,t2))); + } + + set_t invalid_comb_; + std::vector > error_list_; + }; + struct helper_assembly { inline bool register_scanner(lexer::token_scanner* scanner) { if (token_scanner_list.end() != std::find(token_scanner_list.begin(), - token_scanner_list.end(), + token_scanner_list.end (), scanner)) { return false; @@ -3680,7 +3913,7 @@ namespace exprtk inline bool register_modifier(lexer::token_modifier* modifier) { if (token_modifier_list.end() != std::find(token_modifier_list.begin(), - token_modifier_list.end(), + token_modifier_list.end (), modifier)) { return false; @@ -3694,7 +3927,7 @@ namespace exprtk inline bool register_joiner(lexer::token_joiner* joiner) { if (token_joiner_list.end() != std::find(token_joiner_list.begin(), - token_joiner_list.end(), + token_joiner_list.end (), joiner)) { return false; @@ -3708,7 +3941,7 @@ namespace exprtk inline bool register_inserter(lexer::token_inserter* inserter) { if (token_inserter_list.end() != std::find(token_inserter_list.begin(), - token_inserter_list.end(), + token_inserter_list.end (), inserter)) { return false; @@ -3915,40 +4148,6 @@ namespace exprtk return true; } - inline bool token_is_then_assign(const token_t::token_type& ttype, - std::string& token, - const token_advance_mode mode = e_advance) - { - if (current_token_.type != ttype) - { - return false; - } - - token = current_token_.value; - - advance_token(mode); - - return true; - } - - template class Container> - inline bool token_is_then_assign(const token_t::token_type& ttype, - Container& token_list, - const token_advance_mode mode = e_advance) - { - if (current_token_.type != ttype) - { - return false; - } - - token_list.push_back(current_token_.value); - - advance_token(mode); - - return true; - } - inline bool peek_token_is(const token_t::token_type& ttype) { return (lexer_.peek_next_token().type == ttype); @@ -4026,7 +4225,7 @@ namespace exprtk private: - std::size_t size_; + const std::size_t size_; data_ptr_t data_; std::vector data_ref_; }; @@ -4053,19 +4252,24 @@ namespace exprtk enum store_type { e_unknown, - e_scalar, - e_vector, + e_scalar , + e_vector , e_string }; type_store() - : size(0), - data(0), + : data(0), + size(0), type(e_unknown) {} + union + { + void* data; + T* vec_data; + }; + std::size_t size; - void* data; store_type type; class parameter_list @@ -4134,6 +4338,11 @@ namespace exprtk data_(reinterpret_cast(ts_.data)) {} + type_view(const type_store_t& ts) + : ts_(const_cast(ts)), + data_(reinterpret_cast(ts_.data)) + {} + inline std::size_t size() const { return ts_.size; @@ -4182,12 +4391,12 @@ namespace exprtk : v_(*reinterpret_cast(const_cast(ts).data)) {} - inline value_t& operator()() + inline value_t& operator() () { return v_; } - inline const value_t& operator()() const + inline const value_t& operator() () const { return v_; } @@ -4413,12 +4622,12 @@ namespace exprtk { details(const std::size_t& vsize, const unsigned int loop_batch_size = global_loop_batch_size) - : batch_size(loop_batch_size), + : batch_size(loop_batch_size ), remainder (vsize % batch_size), - upper_bound(static_cast(vsize) - (remainder ? loop_batch_size : 0)) + upper_bound(static_cast(vsize - (remainder ? loop_batch_size : 0))) {} - int batch_size; + unsigned int batch_size; int remainder; int upper_bound; }; @@ -4460,16 +4669,16 @@ namespace exprtk {} control_block(const std::size_t& dsize) - : ref_count(1), + : ref_count(1 ), size (dsize), - data (0), - destruct (true) + data (0 ), + destruct (true ) { create_data(); } control_block(const std::size_t& dsize, data_t dptr, bool dstrct = false) - : ref_count(1), - size (dsize), - data (dptr ), + : ref_count(1 ), + size (dsize ), + data (dptr ), destruct (dstrct) {} @@ -4479,7 +4688,7 @@ namespace exprtk { dump_ptr("~control_block() data",data); delete[] data; - data = 0; + data = reinterpret_cast(0); } } @@ -4488,12 +4697,12 @@ namespace exprtk if (dsize) { if (0 == data_ptr) - return new control_block(dsize); + return (new control_block(dsize)); else - return new control_block(dsize, data_ptr, dstrct); + return (new control_block(dsize, data_ptr, dstrct)); } else - return new control_block; + return (new control_block); } static inline void destroy(control_block*& cntrl_blck) @@ -4574,7 +4783,7 @@ namespace exprtk } } - return *this; + return (*this); } inline data_t data() @@ -4632,8 +4841,8 @@ namespace exprtk static inline std::size_t min_size(control_block* cb0, control_block* cb1) { - std::size_t size0 = cb0->size; - std::size_t size1 = cb1->size; + const std::size_t size0 = cb0->size; + const std::size_t size1 = cb1->size; if (size0 && size1) return std::min(size0,size1); @@ -4720,19 +4929,19 @@ namespace exprtk case e_ne : return std::not_equal_to()(arg0,arg1) ? T(1) : T(0); case e_gte : return (arg0 >= arg1) ? T(1) : T(0); case e_gt : return (arg0 > arg1) ? T(1) : T(0); - case e_and : return and_opr (arg0,arg1); + case e_and : return and_opr (arg0,arg1); case e_nand : return nand_opr(arg0,arg1); - case e_or : return or_opr (arg0,arg1); - case e_nor : return nor_opr (arg0,arg1); - case e_xor : return xor_opr (arg0,arg1); + case e_or : return or_opr (arg0,arg1); + case e_nor : return nor_opr (arg0,arg1); + case e_xor : return xor_opr (arg0,arg1); case e_xnor : return xnor_opr(arg0,arg1); - case e_root : return root (arg0,arg1); - case e_roundn : return roundn (arg0,arg1); - case e_equal : return equal (arg0,arg1); - case e_nequal : return nequal (arg0,arg1); - case e_hypot : return hypot (arg0,arg1); - case e_shr : return shr (arg0,arg1); - case e_shl : return shl (arg0,arg1); + case e_root : return root (arg0,arg1); + case e_roundn : return roundn (arg0,arg1); + case e_equal : return equal (arg0,arg1); + case e_nequal : return nequal (arg0,arg1); + case e_hypot : return hypot (arg0,arg1); + case e_shr : return shr (arg0,arg1); + case e_shl : return shl (arg0,arg1); default : exprtk_debug(("numeric::details::process_impl - Invalid binary operation.\n")); return std::numeric_limits::quiet_NaN(); @@ -4787,7 +4996,7 @@ namespace exprtk template inline T process(const operator_type operation, const T arg0, const T arg1) { - return exprtk::details::numeric::details::process_impl(operation,arg0,arg1); + return exprtk::details::numeric::details::process_impl(operation, arg0, arg1); } } @@ -4798,42 +5007,42 @@ namespace exprtk enum node_type { - e_none , e_null , e_constant , e_unary , - e_binary , e_binary_ext , e_trinary , e_quaternary , - e_vararg , e_conditional , e_while , e_repeat , - e_for , e_switch , e_mswitch , e_return , - e_retenv , e_variable , e_stringvar , e_stringconst , - e_stringvarrng , e_cstringvarrng, e_strgenrange , e_strconcat , - e_stringvarsize, e_strswap , e_stringsize , e_stringvararg , - e_function , e_vafunction , e_genfunction , e_strfunction , - e_strcondition , e_strccondition, e_add , e_sub , - e_mul , e_div , e_mod , e_pow , - e_lt , e_lte , e_gt , e_gte , - e_eq , e_ne , e_and , e_nand , - e_or , e_nor , e_xor , e_xnor , - e_in , e_like , e_ilike , e_inranges , - e_ipow , e_ipowinv , e_abs , e_acos , - e_acosh , e_asin , e_asinh , e_atan , - e_atanh , e_ceil , e_cos , e_cosh , - e_exp , e_expm1 , e_floor , e_log , - e_log10 , e_log2 , e_log1p , e_neg , - e_pos , e_round , e_sin , e_sinc , - e_sinh , e_sqrt , e_tan , e_tanh , - e_cot , e_sec , e_csc , e_r2d , - e_d2r , e_d2g , e_g2d , e_notl , - e_sgn , e_erf , e_erfc , e_ncdf , - e_frac , e_trunc , e_uvouv , e_vov , - e_cov , e_voc , e_vob , e_bov , - e_cob , e_boc , e_vovov , e_vovoc , - e_vocov , e_covov , e_covoc , e_vovovov , - e_vovovoc , e_vovocov , e_vocovov , e_covovov , - e_covocov , e_vocovoc , e_covovoc , e_vococov , - e_sf3ext , e_sf4ext , e_nulleq , e_strass , - e_vector , e_vecelem , e_rbvecelem , e_rbveccelem , - e_vecdefass , e_vecvalass , e_vecvecass , e_vecopvalass , - e_vecopvecass , e_vecfunc , e_vecvecswap , e_vecvecineq , - e_vecvalineq , e_valvecineq , e_vecvecarith , e_vecvalarith , - e_valvecarith , e_vecunaryop , e_break , e_continue , + e_none , e_null , e_constant , e_unary , + e_binary , e_binary_ext , e_trinary , e_quaternary , + e_vararg , e_conditional , e_while , e_repeat , + e_for , e_switch , e_mswitch , e_return , + e_retenv , e_variable , e_stringvar , e_stringconst , + e_stringvarrng , e_cstringvarrng , e_strgenrange , e_strconcat , + e_stringvarsize , e_strswap , e_stringsize , e_stringvararg , + e_function , e_vafunction , e_genfunction , e_strfunction , + e_strcondition , e_strccondition , e_add , e_sub , + e_mul , e_div , e_mod , e_pow , + e_lt , e_lte , e_gt , e_gte , + e_eq , e_ne , e_and , e_nand , + e_or , e_nor , e_xor , e_xnor , + e_in , e_like , e_ilike , e_inranges , + e_ipow , e_ipowinv , e_abs , e_acos , + e_acosh , e_asin , e_asinh , e_atan , + e_atanh , e_ceil , e_cos , e_cosh , + e_exp , e_expm1 , e_floor , e_log , + e_log10 , e_log2 , e_log1p , e_neg , + e_pos , e_round , e_sin , e_sinc , + e_sinh , e_sqrt , e_tan , e_tanh , + e_cot , e_sec , e_csc , e_r2d , + e_d2r , e_d2g , e_g2d , e_notl , + e_sgn , e_erf , e_erfc , e_ncdf , + e_frac , e_trunc , e_uvouv , e_vov , + e_cov , e_voc , e_vob , e_bov , + e_cob , e_boc , e_vovov , e_vovoc , + e_vocov , e_covov , e_covoc , e_vovovov , + e_vovovoc , e_vovocov , e_vocovov , e_covovov , + e_covocov , e_vocovoc , e_covovoc , e_vococov , + e_sf3ext , e_sf4ext , e_nulleq , e_strass , + e_vector , e_vecelem , e_rbvecelem , e_rbveccelem , + e_vecdefass , e_vecvalass , e_vecvecass , e_vecopvalass , + e_vecopvecass , e_vecfunc , e_vecvecswap , e_vecvecineq , + e_vecvalineq , e_valvecineq , e_vecvecarith , e_vecvalarith , + e_valvecarith , e_vecunaryop , e_break , e_continue , e_swap }; @@ -5054,7 +5263,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline bool all_nodes_valid(const Sequence*,Allocator>& b) { for (std::size_t i = 0; i < b.size(); ++i) @@ -5081,7 +5290,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline bool all_nodes_variables(Sequence*,Allocator>& b) { for (std::size_t i = 0; i < b.size(); ++i) @@ -5107,7 +5316,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline void free_all_nodes(NodeAllocator& node_allocator, Sequence*,Allocator>& b) { for (std::size_t i = 0; i < b.size(); ++i) @@ -5130,10 +5339,17 @@ namespace exprtk return; node_allocator.free(node); - node = 0; + node = reinterpret_cast*>(0); } } + template + inline void destroy_node(expression_node*& node) + { + delete node; + node = reinterpret_cast*>(0); + } + template class vector_holder { @@ -5147,7 +5363,7 @@ namespace exprtk { public: - virtual ~vector_holder_base(){} + virtual ~vector_holder_base() {} inline value_ptr operator[](const std::size_t& index) const { @@ -5210,7 +5426,7 @@ namespace exprtk }; template class Sequence> + template class Sequence> class sequence_vector_impl : public vector_holder_base { public: @@ -5317,7 +5533,7 @@ namespace exprtk void set_ref(value_ptr* ref) { - return vector_holder_base_->set_ref(ref); + vector_holder_base_->set_ref(ref); } bool rebaseable() const @@ -5364,8 +5580,7 @@ namespace exprtk { if (branch_ && branch_deletable_) { - delete branch_; - branch_ = 0; + destroy_node(branch_); } } @@ -5398,7 +5613,7 @@ namespace exprtk private: expression_ptr branch_; - bool branch_deletable_; + const bool branch_deletable_; bool equality_; }; @@ -5429,7 +5644,7 @@ namespace exprtk private: literal_node(literal_node&) {} - literal_node& operator=(literal_node&) { return *this; } + literal_node& operator=(literal_node&) { return (*this); } const T value_; }; @@ -5468,7 +5683,7 @@ namespace exprtk virtual std::string str () const = 0; - virtual const char* base() const = 0; + virtual char_cptr base() const = 0; virtual std::size_t size() const = 0; }; @@ -5511,7 +5726,7 @@ namespace exprtk return value_; } - const char* base() const + char_cptr base() const { return value_.data(); } @@ -5559,8 +5774,7 @@ namespace exprtk { if (branch_ && branch_deletable_) { - delete branch_; - branch_ = 0; + destroy_node(branch_); } } @@ -5653,23 +5867,21 @@ namespace exprtk { if (branch[i].first && branch[i].second) { - delete branch[i].first; - branch[i].first = 0; + destroy_node(branch[i].first); } } } template class Sequence> + template class Sequence> static inline void execute(Sequence*,bool>,Allocator>& branch) { for (std::size_t i = 0; i < branch.size(); ++i) { if (branch[i].first && branch[i].second) { - delete branch[i].first; - branch[i].first = 0; + destroy_node(branch[i].first); } } } @@ -5688,7 +5900,7 @@ namespace exprtk expression_ptr branch1) : operation_(opr) { - init_branches<2>(branch_,branch0,branch1); + init_branches<2>(branch_, branch0, branch1); } ~binary_node() @@ -5740,7 +5952,7 @@ namespace exprtk binary_ext_node(expression_ptr branch0, expression_ptr branch1) { - init_branches<2>(branch_,branch0,branch1); + init_branches<2>(branch_, branch0, branch1); } ~binary_ext_node() @@ -5795,7 +6007,7 @@ namespace exprtk expression_ptr branch2) : operation_(opr) { - init_branches<3>(branch_,branch0,branch1,branch2); + init_branches<3>(branch_, branch0, branch1, branch2); } ~trinary_node() @@ -5820,10 +6032,8 @@ namespace exprtk else return ((T(2) * arg1 <= (arg2 + arg0)) ? arg0 : arg2); - default : { - exprtk_debug(("trinary_node::value() - Error: Invalid operation\n")); - return std::numeric_limits::quiet_NaN(); - } + default : exprtk_debug(("trinary_node::value() - Error: Invalid operation\n")); + return std::numeric_limits::quiet_NaN(); } } @@ -5853,7 +6063,7 @@ namespace exprtk expression_ptr branch3) : operation_(opr) { - init_branches<4>(branch_,branch0,branch1,branch2,branch3); + init_branches<4>(branch_, branch0, branch1, branch2, branch3); } ~quaternary_node() @@ -5897,9 +6107,20 @@ namespace exprtk ~conditional_node() { - if (test_ && test_deletable_ ) delete test_; - if (consequent_ && consequent_deletable_ ) delete consequent_; - if (alternative_ && alternative_deletable_) delete alternative_; + if (test_ && test_deletable_) + { + destroy_node(test_); + } + + if (consequent_ && consequent_deletable_ ) + { + destroy_node(consequent_); + } + + if (alternative_ && alternative_deletable_) + { + destroy_node(alternative_); + } } inline T value() const @@ -5920,9 +6141,9 @@ namespace exprtk expression_ptr test_; expression_ptr consequent_; expression_ptr alternative_; - bool test_deletable_; - bool consequent_deletable_; - bool alternative_deletable_; + const bool test_deletable_; + const bool consequent_deletable_; + const bool alternative_deletable_; }; template @@ -5943,8 +6164,15 @@ namespace exprtk ~cons_conditional_node() { - if (test_ && test_deletable_ ) delete test_; - if (consequent_ && consequent_deletable_) delete consequent_; + if (test_ && test_deletable_) + { + destroy_node(test_); + } + + if (consequent_ && consequent_deletable_) + { + destroy_node(consequent_); + } } inline T value() const @@ -5964,8 +6192,8 @@ namespace exprtk expression_ptr test_; expression_ptr consequent_; - bool test_deletable_; - bool consequent_deletable_; + const bool test_deletable_; + const bool consequent_deletable_; }; #ifndef exprtk_disable_break_continue @@ -6000,7 +6228,7 @@ namespace exprtk { if (return_deletable_) { - delete return_; + destroy_node(return_); } } @@ -6020,7 +6248,7 @@ namespace exprtk private: expression_ptr return_; - bool return_deletable_; + const bool return_deletable_; }; template @@ -6061,12 +6289,12 @@ namespace exprtk { if (condition_ && condition_deletable_) { - delete condition_; + destroy_node(condition_); } if (loop_body_ && loop_body_deletable_) { - delete loop_body_; + destroy_node(loop_body_); } } @@ -6091,8 +6319,8 @@ namespace exprtk expression_ptr condition_; expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; + const bool condition_deletable_; + const bool loop_body_deletable_; }; template @@ -6113,12 +6341,12 @@ namespace exprtk { if (condition_ && condition_deletable_) { - delete condition_; + destroy_node(condition_); } if (loop_body_ && loop_body_deletable_) { - delete loop_body_; + destroy_node(loop_body_); } } @@ -6144,8 +6372,8 @@ namespace exprtk expression_ptr condition_; expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; + const bool condition_deletable_; + const bool loop_body_deletable_; }; template @@ -6160,9 +6388,9 @@ namespace exprtk expression_ptr incrementor, expression_ptr loop_body) : initialiser_(initialiser), - condition_ (condition), + condition_ (condition ), incrementor_(incrementor), - loop_body_ (loop_body), + loop_body_ (loop_body ), initialiser_deletable_(branch_deletable(initialiser_)), condition_deletable_ (branch_deletable(condition_ )), incrementor_deletable_(branch_deletable(incrementor_)), @@ -6173,22 +6401,22 @@ namespace exprtk { if (initialiser_ && initialiser_deletable_) { - delete initialiser_; + destroy_node(initialiser_); } if (condition_ && condition_deletable_) { - delete condition_; + destroy_node(condition_); } if (incrementor_ && incrementor_deletable_) { - delete incrementor_; + destroy_node(incrementor_); } if (loop_body_ && loop_body_deletable_) { - delete loop_body_; + destroy_node(loop_body_); } } @@ -6225,14 +6453,14 @@ namespace exprtk private: - expression_ptr initialiser_; - expression_ptr condition_ ; - expression_ptr incrementor_; - expression_ptr loop_body_ ; - bool initialiser_deletable_; - bool condition_deletable_ ; - bool incrementor_deletable_; - bool loop_body_deletable_ ; + expression_ptr initialiser_ ; + expression_ptr condition_ ; + expression_ptr incrementor_ ; + expression_ptr loop_body_ ; + const bool initialiser_deletable_; + const bool condition_deletable_ ; + const bool incrementor_deletable_; + const bool loop_body_deletable_ ; }; #ifndef exprtk_disable_break_continue @@ -6254,12 +6482,12 @@ namespace exprtk { if (condition_ && condition_deletable_) { - delete condition_; + destroy_node(condition_); } if (loop_body_ && loop_body_deletable_) { - delete loop_body_; + destroy_node(loop_body_); } } @@ -6293,8 +6521,8 @@ namespace exprtk expression_ptr condition_; expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; + const bool condition_deletable_; + const bool loop_body_deletable_; }; template @@ -6315,12 +6543,12 @@ namespace exprtk { if (condition_ && condition_deletable_) { - delete condition_; + destroy_node(condition_); } if (loop_body_ && loop_body_deletable_) { - delete loop_body_; + destroy_node(loop_body_); } } @@ -6355,8 +6583,8 @@ namespace exprtk expression_ptr condition_; expression_ptr loop_body_; - bool condition_deletable_; - bool loop_body_deletable_; + const bool condition_deletable_; + const bool loop_body_deletable_; }; template @@ -6384,22 +6612,22 @@ namespace exprtk { if (initialiser_ && initialiser_deletable_) { - delete initialiser_; + destroy_node(initialiser_); } if (condition_ && condition_deletable_) { - delete condition_; + destroy_node(condition_); } if (incrementor_ && incrementor_deletable_) { - delete incrementor_; + destroy_node(incrementor_); } if (loop_body_ && loop_body_deletable_) { - delete loop_body_; + destroy_node(loop_body_); } } @@ -6459,10 +6687,10 @@ namespace exprtk expression_ptr condition_ ; expression_ptr incrementor_; expression_ptr loop_body_ ; - bool initialiser_deletable_; - bool condition_deletable_ ; - bool incrementor_deletable_; - bool loop_body_deletable_ ; + const bool initialiser_deletable_; + const bool condition_deletable_ ; + const bool incrementor_deletable_; + const bool loop_body_deletable_ ; }; #endif @@ -6474,8 +6702,8 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> - switch_node(const Sequence& arg_list) + template class Sequence> + explicit switch_node(const Sequence& arg_list) { if (1 != (arg_list.size() & 1)) return; @@ -6505,8 +6733,7 @@ namespace exprtk { if (arg_list_[i] && delete_branch_[i]) { - delete arg_list_[i]; - arg_list_[i] = 0; + destroy_node(arg_list_[i]); } } } @@ -6553,8 +6780,8 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> - switch_n_node(const Sequence& arg_list) + template class Sequence> + explicit switch_n_node(const Sequence& arg_list) : switch_node(arg_list) {} @@ -6572,8 +6799,8 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> - multi_switch_node(const Sequence& arg_list) + template class Sequence> + explicit multi_switch_node(const Sequence& arg_list) { if (0 != (arg_list.size() & 1)) return; @@ -6603,8 +6830,7 @@ namespace exprtk { if (arg_list_[i] && delete_branch_[i]) { - delete arg_list_[i]; - arg_list_[i] = 0; + destroy_node(arg_list_[i]); } } } @@ -6666,23 +6892,13 @@ namespace exprtk static T null_value; explicit variable_node() - : value_(&null_value), - delete_value_(false) + : value_(&null_value) {} - variable_node(T& v) - : value_(&v), - delete_value_(false) + explicit variable_node(T& v) + : value_(&v) {} - ~variable_node() - { - if (delete_value_) - { - delete value_; - } - } - inline bool operator <(const variable_node& v) const { return this < (&v); @@ -6708,15 +6924,9 @@ namespace exprtk return expression_node::e_variable; } - inline bool& delete_value() - { - return delete_value_; - } - private: T* value_; - bool delete_value_; }; template @@ -6756,8 +6966,7 @@ namespace exprtk !is_string_node (n0_e.second) ) { - delete n0_e.second; - n0_e.second = expression_node_ptr(0); + destroy_node(n0_e.second); } } @@ -6770,8 +6979,7 @@ namespace exprtk !is_string_node (n1_e.second) ) { - delete n1_e.second; - n1_e.second = expression_node_ptr(0); + destroy_node(n1_e.second); } } } @@ -6788,13 +6996,13 @@ namespace exprtk (!n0_c.first && !n1_c.first); } - bool operator()(std::size_t& r0, std::size_t& r1, const std::size_t& size = std::numeric_limits::max()) const + bool operator() (std::size_t& r0, std::size_t& r1, const std::size_t& size = std::numeric_limits::max()) const { if (n0_c.first) r0 = n0_c.second; else if (n0_e.first) { - T r0_value = n0_e.second->value(); + const T r0_value = n0_e.second->value(); if (r0_value < 0) return false; @@ -6808,7 +7016,7 @@ namespace exprtk r1 = n1_c.second; else if (n1_e.first) { - T r1_value = n1_e.second->value(); + const T r1_value = n1_e.second->value(); if (r1_value < 0) return false; @@ -6910,7 +7118,7 @@ namespace exprtk typedef vector_node* vector_node_ptr; typedef vec_data_store vds_t; - vector_node(vector_holder_t* vh) + explicit vector_node(vector_holder_t* vh) : vector_holder_(vh), vds_((*vector_holder_).size(),(*vector_holder_)[0]) { @@ -6989,7 +7197,7 @@ namespace exprtk { if (index_ && index_deletable_) { - delete index_; + destroy_node(index_); } } @@ -7023,7 +7231,7 @@ namespace exprtk expression_ptr index_; vector_holder_ptr vec_holder_; T* vector_base_; - bool index_deletable_; + const bool index_deletable_; }; template @@ -7050,7 +7258,7 @@ namespace exprtk { if (index_ && index_deletable_) { - delete index_; + destroy_node(index_); } } @@ -7082,7 +7290,7 @@ namespace exprtk private: expression_ptr index_; - bool index_deletable_; + const bool index_deletable_; vector_holder_ptr vector_holder_; vds_t vds_; }; @@ -7133,7 +7341,7 @@ namespace exprtk private: - std::size_t index_; + const std::size_t index_; vector_holder_ptr vector_holder_; vds_t vds_; }; @@ -7161,7 +7369,7 @@ namespace exprtk { if (branch_deletable(initialiser_list_[i])) { - delete initialiser_list_[i]; + destroy_node(initialiser_list_[i]); } } } @@ -7250,7 +7458,7 @@ namespace exprtk typedef ivariable* ivariable_ptr; swap_generic_node(expression_ptr var0, expression_ptr var1) - : binary_node(details::e_swap,var0,var1), + : binary_node(details::e_swap, var0, var1), var0_(dynamic_cast(var0)), var1_(dynamic_cast(var1)) {} @@ -7284,7 +7492,7 @@ namespace exprtk swap_vecvec_node(expression_ptr branch0, expression_ptr branch1) - : binary_node(details::e_swap,branch0,branch1), + : binary_node(details::e_swap, branch0, branch1), vec0_node_ptr_(0), vec1_node_ptr_(0), vec_size_ (0), @@ -7423,7 +7631,7 @@ namespace exprtk return ref(); } - const char* base() const + char_cptr base() const { return &(*value_)[0]; } @@ -7503,7 +7711,7 @@ namespace exprtk return (*value_); } - const char* base() const + char_cptr base() const { return &(*value_)[0]; } @@ -7581,7 +7789,7 @@ namespace exprtk return value_; } - const char* base() const + char_cptr base() const { return value_.data(); } @@ -7669,8 +7877,7 @@ namespace exprtk if (branch_ && branch_deletable_) { - delete branch_; - branch_ = 0; + destroy_node(branch_); } } @@ -7712,7 +7919,7 @@ namespace exprtk return value_; } - const char* base() const + char_cptr base() const { return &value_[0]; } @@ -7739,14 +7946,14 @@ namespace exprtk private: - bool initialised_; - expression_ptr branch_; - bool branch_deletable_; - str_base_ptr str_base_ptr_; - irange_ptr str_range_ptr_; - mutable range_t base_range_; - mutable range_t range_; - mutable std::string value_; + bool initialised_; + expression_ptr branch_; + const bool branch_deletable_; + str_base_ptr str_base_ptr_; + irange_ptr str_range_ptr_; + mutable range_t base_range_; + mutable range_t range_; + mutable std::string value_; }; template @@ -7766,7 +7973,7 @@ namespace exprtk string_concat_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), initialised_(false), str0_base_ptr_ (0), str1_base_ptr_ (0), @@ -7828,8 +8035,8 @@ namespace exprtk range_t& range1 = str1_range_ptr_->range_ref(); if ( - range0(str0_r0,str0_r1,str0_base_ptr_->size()) && - range1(str1_r0,str1_r1,str1_base_ptr_->size()) + range0(str0_r0, str0_r1, str0_base_ptr_->size()) && + range1(str1_r0, str1_r1, str1_base_ptr_->size()) ) { const std::size_t size0 = (str0_r1 - str0_r0) + 1; @@ -7851,7 +8058,7 @@ namespace exprtk return value_; } - const char* base() const + char_cptr base() const { return &value_[0]; } @@ -7903,7 +8110,7 @@ namespace exprtk typedef irange_t* irange_ptr; swap_string_node(expression_ptr branch0, expression_ptr branch1) - : binary_node(details::e_swap,branch0,branch1), + : binary_node(details::e_swap, branch0, branch1), initialised_(false), str0_node_ptr_(0), str1_node_ptr_(0) @@ -7939,7 +8146,7 @@ namespace exprtk return str0_node_ptr_->str(); } - const char* base() const + char_cptr base() const { return str0_node_ptr_->base(); } @@ -7985,7 +8192,7 @@ namespace exprtk swap_genstrings_node(expression_ptr branch0, expression_ptr branch1) - : binary_node(details::e_default,branch0,branch1), + : binary_node(details::e_default, branch0, branch1), str0_base_ptr_ (0), str1_base_ptr_ (0), str0_range_ptr_(0), @@ -7999,12 +8206,12 @@ namespace exprtk if (0 == str0_base_ptr_) return; - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); + irange_ptr range = dynamic_cast(binary_node::branch_[0].first); - if (0 == range_ptr) + if (0 == range) return; - str0_range_ptr_ = &(range_ptr->range_ref()); + str0_range_ptr_ = &(range->range_ref()); } if (is_generally_string_node(binary_node::branch_[1].first)) @@ -8014,12 +8221,12 @@ namespace exprtk if (0 == str1_base_ptr_) return; - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + irange_ptr range = dynamic_cast(binary_node::branch_[1].first); - if (0 == range_ptr) + if (0 == range) return; - str1_range_ptr_ = &(range_ptr->range_ref()); + str1_range_ptr_ = &(range->range_ref()); } initialised_ = str0_base_ptr_ && @@ -8045,19 +8252,19 @@ namespace exprtk range_t& range1 = (*str1_range_ptr_); if ( - range0(str0_r0,str0_r1,str0_base_ptr_->size()) && - range1(str1_r0,str1_r1,str1_base_ptr_->size()) + range0(str0_r0, str0_r1, str0_base_ptr_->size()) && + range1(str1_r0, str1_r1, str1_base_ptr_->size()) ) { const std::size_t size0 = range0.cache_size(); const std::size_t size1 = range1.cache_size(); const std::size_t max_size = std::min(size0,size1); - char* s0 = const_cast(str0_base_ptr_->base() + str0_r0); - char* s1 = const_cast(str1_base_ptr_->base() + str1_r0); + char_ptr s0 = const_cast(str0_base_ptr_->base() + str0_r0); + char_ptr s1 = const_cast(str1_base_ptr_->base() + str1_r0); loop_unroll::details lud(max_size); - const char* upper_bound = s0 + lud.upper_bound; + char_cptr upper_bound = s0 + lud.upper_bound; while (s0 < upper_bound) { @@ -8081,6 +8288,7 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { #define case_stmt(N) \ @@ -8097,6 +8305,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -8164,7 +8373,7 @@ namespace exprtk typedef expression_node * expression_ptr; typedef string_base_node* str_base_ptr; - string_size_node(expression_ptr brnch) + explicit string_size_node(expression_ptr brnch) : branch_(brnch), branch_deletable_(branch_deletable(branch_)), str_base_ptr_(0) @@ -8182,8 +8391,7 @@ namespace exprtk { if (branch_ && branch_deletable_) { - delete branch_; - branch_ = 0; + destroy_node(branch_); } } @@ -8207,20 +8415,20 @@ namespace exprtk private: - expression_ptr branch_; - bool branch_deletable_; - str_base_ptr str_base_ptr_; + expression_ptr branch_; + const bool branch_deletable_; + str_base_ptr str_base_ptr_; }; struct asn_assignment { - static inline void execute(std::string& s, const char* data, const std::size_t size) + static inline void execute(std::string& s, char_cptr data, const std::size_t size) { s.assign(data,size); } }; struct asn_addassignment { - static inline void execute(std::string& s, const char* data, const std::size_t size) + static inline void execute(std::string& s, char_cptr data, const std::size_t size) { s.append(data,size); } }; @@ -8242,7 +8450,7 @@ namespace exprtk assignment_string_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), initialised_(false), str0_base_ptr_ (0), str1_base_ptr_ (0), @@ -8263,12 +8471,12 @@ namespace exprtk if (0 == str1_base_ptr_) return; - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + irange_ptr range = dynamic_cast(binary_node::branch_[1].first); - if (0 == range_ptr) + if (0 == range) return; - str1_range_ptr_ = &(range_ptr->range_ref()); + str1_range_ptr_ = &(range->range_ref()); } initialised_ = str0_base_ptr_ && @@ -8288,7 +8496,7 @@ namespace exprtk range_t& range = (*str1_range_ptr_); - if (range(r0,r1,str1_base_ptr_->size())) + if (range(r0, r1, str1_base_ptr_->size())) { AssignmentProcess::execute(str0_node_ptr_->ref(), str1_base_ptr_->base() + r0, @@ -8306,7 +8514,7 @@ namespace exprtk return str0_node_ptr_->str(); } - const char* base() const + char_cptr base() const { return str0_node_ptr_->base(); } @@ -8358,7 +8566,7 @@ namespace exprtk assignment_string_range_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), initialised_(false), str0_base_ptr_ (0), str1_base_ptr_ (0), @@ -8372,12 +8580,12 @@ namespace exprtk str0_base_ptr_ = dynamic_cast(binary_node::branch_[0].first); - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); + irange_ptr range = dynamic_cast(binary_node::branch_[0].first); - if (0 == range_ptr) + if (0 == range) return; - str0_range_ptr_ = &(range_ptr->range_ref()); + str0_range_ptr_ = &(range->range_ref()); } if (is_generally_string_node(binary_node::branch_[1].first)) @@ -8387,12 +8595,12 @@ namespace exprtk if (0 == str1_base_ptr_) return; - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + irange_ptr range = dynamic_cast(binary_node::branch_[1].first); - if (0 == range_ptr) + if (0 == range) return; - str1_range_ptr_ = &(range_ptr->range_ref()); + str1_range_ptr_ = &(range->range_ref()); } initialised_ = str0_base_ptr_ && @@ -8419,15 +8627,15 @@ namespace exprtk range_t& range1 = (*str1_range_ptr_); if ( - range0(s0_r0,s0_r1,str0_base_ptr_->size()) && - range1(s1_r0,s1_r1,str1_base_ptr_->size()) + range0(s0_r0, s0_r1, str0_base_ptr_->size()) && + range1(s1_r0, s1_r1, str1_base_ptr_->size()) ) { std::size_t size = std::min((s0_r1 - s0_r0),(s1_r1 - s1_r0)) + 1; std::copy(str1_base_ptr_->base() + s1_r0, str1_base_ptr_->base() + s1_r0 + size, - const_cast(base() + s0_r0)); + const_cast(base() + s0_r0)); } } @@ -8439,7 +8647,7 @@ namespace exprtk return str0_node_ptr_->str(); } - const char* base() const + char_cptr base() const { return str0_node_ptr_->base(); } @@ -8553,7 +8761,7 @@ namespace exprtk range_t& range = str0_range_ptr_->range_ref(); - if (range(r0,r1,str0_base_ptr_->size())) + if (range(r0, r1, str0_base_ptr_->size())) { const std::size_t size = (r1 - r0) + 1; @@ -8571,7 +8779,7 @@ namespace exprtk range_t& range = str1_range_ptr_->range_ref(); - if (range(r0,r1,str1_base_ptr_->size())) + if (range(r0, r1, str1_base_ptr_->size())) { const std::size_t size = (r1 - r0) + 1; @@ -8593,7 +8801,7 @@ namespace exprtk return value_; } - const char* base() const + char_cptr base() const { return &value_[0]; } @@ -8649,7 +8857,7 @@ namespace exprtk cons_conditional_str_node(expression_ptr test, expression_ptr consequent) - : binary_node(details::e_default,consequent,test), + : binary_node(details::e_default, consequent, test), initialised_(false), str0_base_ptr_ (0), str0_range_ptr_(0), @@ -8691,7 +8899,7 @@ namespace exprtk std::size_t r0 = 0; std::size_t r1 = 0; - if (range(r0,r1,str0_base_ptr_->size())) + if (range(r0, r1, str0_base_ptr_->size())) { const std::size_t size = (r1 - r0) + 1; @@ -8713,7 +8921,7 @@ namespace exprtk return value_; } - const char* base() const + char_cptr base() const { return &value_[0]; } @@ -8765,8 +8973,8 @@ namespace exprtk typedef irange_t* irange_ptr; template class Sequence> - str_vararg_node(const Sequence& arg_list) + template class Sequence> + explicit str_vararg_node(const Sequence& arg_list) : final_node_(arg_list.back()), final_deletable_(branch_deletable(final_node_)), initialised_(false), @@ -8806,7 +9014,7 @@ namespace exprtk } else { - arg_list_.clear(); + arg_list_ .clear(); delete_branch_.clear(); return; } @@ -8818,16 +9026,14 @@ namespace exprtk { if (final_node_ && final_deletable_) { - delete final_node_; - final_node_ = 0; + destroy_node(final_node_); } for (std::size_t i = 0; i < arg_list_.size(); ++i) { if (arg_list_[i] && delete_branch_[i]) { - delete arg_list_[i]; - arg_list_[i] = 0; + destroy_node(arg_list_[i]); } } } @@ -8849,7 +9055,7 @@ namespace exprtk return str_base_ptr_->str(); } - const char* base() const + char_cptr base() const { return str_base_ptr_->base(); } @@ -8915,7 +9121,7 @@ namespace exprtk template \ struct sf##NN##_op : public sf_base \ { \ - typedef typename sf_base::Type Type; \ + typedef typename sf_base::Type const Type; \ static inline T process(Type x, Type y, Type z) \ { \ return (OP0); \ @@ -8979,7 +9185,7 @@ namespace exprtk template \ struct sf##NN##_op : public sf_base \ { \ - typedef typename sf_base::Type Type; \ + typedef typename sf_base::Type const Type; \ static inline T process(Type x, Type y, Type z, Type w) \ { \ return (OP0); \ @@ -9118,7 +9324,7 @@ namespace exprtk expression_ptr branch0, expression_ptr branch1, expression_ptr branch2) - : trinary_node(opr,branch0,branch1,branch2) + : trinary_node(opr, branch0, branch1, branch2) {} inline T value() const @@ -9127,7 +9333,7 @@ namespace exprtk const T y = trinary_node::branch_[1].first->value(); const T z = trinary_node::branch_[2].first->value(); - return SpecialFunction::process(x,y,z); + return SpecialFunction::process(x, y, z); } }; @@ -9143,7 +9349,7 @@ namespace exprtk expression_ptr branch1, expression_ptr branch2, expression_ptr branch3) - : quaternary_node(opr,branch0,branch1,branch2,branch3) + : quaternary_node(opr, branch0, branch1, branch2, branch3) {} inline T value() const @@ -9153,7 +9359,7 @@ namespace exprtk const T z = quaternary_node::branch_[2].first->value(); const T w = quaternary_node::branch_[3].first->value(); - return SpecialFunction::process(x,y,z,w); + return SpecialFunction::process(x, y, z, w); } }; @@ -9172,7 +9378,7 @@ namespace exprtk inline T value() const { - return SpecialFunction::process(v0_,v1_,v2_); + return SpecialFunction::process(v0_, v1_, v2_); } inline typename expression_node::node_type type() const @@ -9206,7 +9412,7 @@ namespace exprtk inline T value() const { - return SpecialFunction::process(v0_,v1_,v2_,v3_); + return SpecialFunction::process(v0_, v1_, v2_, v3_); } inline typename expression_node::node_type type() const @@ -9233,10 +9439,10 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> - vararg_node(const Sequence& arg_list) + template class Sequence> + explicit vararg_node(const Sequence& arg_list) { - arg_list_.resize(arg_list.size()); + arg_list_ .resize(arg_list.size()); delete_branch_.resize(arg_list.size()); for (std::size_t i = 0; i < arg_list.size(); ++i) @@ -9261,18 +9467,14 @@ namespace exprtk { if (arg_list_[i] && delete_branch_[i]) { - delete arg_list_[i]; - arg_list_[i] = 0; + destroy_node(arg_list_[i]); } } } inline T value() const { - if (!arg_list_.empty()) - return VarArgFunction::process(arg_list_); - else - return std::numeric_limits::quiet_NaN(); + return VarArgFunction::process(arg_list_); } inline typename expression_node::node_type type() const @@ -9294,8 +9496,8 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> - vararg_varnode(const Sequence& arg_list) + template class Sequence> + explicit vararg_varnode(const Sequence& arg_list) { arg_list_.resize(arg_list.size()); @@ -9339,7 +9541,7 @@ namespace exprtk typedef expression_node* expression_ptr; - vectorize_node(const expression_ptr v) + explicit vectorize_node(const expression_ptr v) : ivec_ptr_(0), v_(v), v_deletable_(branch_deletable(v_)) @@ -9356,7 +9558,7 @@ namespace exprtk { if (v_ && v_deletable_) { - delete v_; + destroy_node(v_); } } @@ -9379,8 +9581,8 @@ namespace exprtk private: vector_interface* ivec_ptr_; - expression_ptr v_; - bool v_deletable_; + expression_ptr v_; + const bool v_deletable_; }; template @@ -9393,7 +9595,7 @@ namespace exprtk assignment_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), var_node_ptr_(0) { if (is_variable_node(binary_node::branch_[0].first)) @@ -9431,7 +9633,7 @@ namespace exprtk assignment_vec_elem_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec_node_ptr_(0) { if (is_vector_elem_node(binary_node::branch_[0].first)) @@ -9469,7 +9671,7 @@ namespace exprtk assignment_rebasevec_elem_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), rbvec_node_ptr_(0) { if (is_rebasevector_elem_node(binary_node::branch_[0].first)) @@ -9507,7 +9709,7 @@ namespace exprtk assignment_rebasevec_celem_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), rbvec_node_ptr_(0) { if (is_rebasevector_celem_node(binary_node::branch_[0].first)) @@ -9548,7 +9750,7 @@ namespace exprtk assignment_vec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec_node_ptr_(0) { if (is_vector_node(binary_node::branch_[0].first)) @@ -9571,8 +9773,8 @@ namespace exprtk while (vec < upper_bound) { - #define exprtk_loop(N) \ - vec[N] = v; \ + #define exprtk_loop(N) \ + vec[N] = v; \ exprtk_loop( 0) exprtk_loop( 1) exprtk_loop( 2) exprtk_loop( 3) @@ -9588,6 +9790,7 @@ namespace exprtk vec += lud.batch_size; } + exprtk_disable_fallthrough_begin switch (lud.remainder) { #define case_stmt(N) \ @@ -9604,6 +9807,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -9663,7 +9867,7 @@ namespace exprtk assignment_vecvec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec0_node_ptr_(0), vec1_node_ptr_(0), initialised_(false), @@ -9736,6 +9940,7 @@ namespace exprtk vec1 += lud.batch_size; } + exprtk_disable_fallthrough_begin switch (lud.remainder) { #define case_stmt(N) \ @@ -9752,6 +9957,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -9811,7 +10017,7 @@ namespace exprtk assignment_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), var_node_ptr_(0) { if (is_variable_node(binary_node::branch_[0].first)) @@ -9848,7 +10054,7 @@ namespace exprtk assignment_vec_elem_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec_node_ptr_(0) { if (is_vector_elem_node(binary_node::branch_[0].first)) @@ -9885,7 +10091,7 @@ namespace exprtk assignment_rebasevec_elem_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), rbvec_node_ptr_(0) { if (is_rebasevector_elem_node(binary_node::branch_[0].first)) @@ -9922,7 +10128,7 @@ namespace exprtk assignment_rebasevec_celem_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), rbvec_node_ptr_(0) { if (is_rebasevector_celem_node(binary_node::branch_[0].first)) @@ -9962,7 +10168,7 @@ namespace exprtk assignment_vec_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec_node_ptr_(0) { if (is_vector_node(binary_node::branch_[0].first)) @@ -10002,6 +10208,7 @@ namespace exprtk vec += lud.batch_size; } + exprtk_disable_fallthrough_begin switch (lud.remainder) { #define case_stmt(N) \ @@ -10018,6 +10225,8 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end + #undef exprtk_loop #undef case_stmt @@ -10082,7 +10291,7 @@ namespace exprtk assignment_vecvec_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec0_node_ptr_(0), vec1_node_ptr_(0), initialised_(false) @@ -10121,16 +10330,16 @@ namespace exprtk binary_node::branch_[0].first->value(); binary_node::branch_[1].first->value(); - T* vec0 = vec0_node_ptr_->vds().data(); - T* vec1 = vec1_node_ptr_->vds().data(); + T* vec0 = vec0_node_ptr_->vds().data(); + const T* vec1 = vec1_node_ptr_->vds().data(); loop_unroll::details lud(size()); const T* upper_bound = vec0 + lud.upper_bound; while (vec0 < upper_bound) { - #define exprtk_loop(N) \ - vec0[N] = Operation::process(vec0[N],vec1[N]); \ + #define exprtk_loop(N) \ + vec0[N] = Operation::process(vec0[N], vec1[N]); \ exprtk_loop( 0) exprtk_loop( 1) exprtk_loop( 2) exprtk_loop( 3) @@ -10149,10 +10358,11 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { - #define case_stmt(N) \ - case N : { vec0[i] = Operation::process(vec0[i],vec1[i]); ++i; } \ + #define case_stmt(N) \ + case N : { vec0[i] = Operation::process(vec0[i], vec1[i]); ++i; } \ #ifndef exprtk_disable_superscalar_unroll case_stmt(15) case_stmt(14) @@ -10165,6 +10375,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -10232,7 +10443,7 @@ namespace exprtk vec_binop_vecvec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec0_node_ptr_(0), vec1_node_ptr_(0), temp_ (0), @@ -10304,17 +10515,17 @@ namespace exprtk binary_node::branch_[0].first->value(); binary_node::branch_[1].first->value(); - T* vec0 = vec0_node_ptr_->vds().data(); - T* vec1 = vec1_node_ptr_->vds().data(); - T* vec2 = vds().data(); + const T* vec0 = vec0_node_ptr_->vds().data(); + const T* vec1 = vec1_node_ptr_->vds().data(); + T* vec2 = vds().data(); loop_unroll::details lud(size()); const T* upper_bound = vec2 + lud.upper_bound; while (vec2 < upper_bound) { - #define exprtk_loop(N) \ - vec2[N] = Operation::process(vec0[N],vec1[N]); \ + #define exprtk_loop(N) \ + vec2[N] = Operation::process(vec0[N], vec1[N]); \ exprtk_loop( 0) exprtk_loop( 1) exprtk_loop( 2) exprtk_loop( 3) @@ -10334,10 +10545,11 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { - #define case_stmt(N) \ - case N : { vec2[i] = Operation::process(vec0[i],vec1[i]); ++i; } \ + #define case_stmt(N) \ + case N : { vec2[i] = Operation::process(vec0[i], vec1[i]); ++i; } \ #ifndef exprtk_disable_superscalar_unroll case_stmt(15) case_stmt(14) @@ -10350,6 +10562,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -10414,7 +10627,7 @@ namespace exprtk vec_binop_vecval_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec0_node_ptr_(0), temp_ (0), temp_vec_node_(0) @@ -10461,16 +10674,16 @@ namespace exprtk binary_node::branch_[0].first->value(); const T v = binary_node::branch_[1].first->value(); - T* vec0 = vec0_node_ptr_->vds().data(); - T* vec1 = vds().data(); + const T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vds().data(); loop_unroll::details lud(size()); const T* upper_bound = vec0 + lud.upper_bound; while (vec0 < upper_bound) { - #define exprtk_loop(N) \ - vec1[N] = Operation::process(vec0[N],v); \ + #define exprtk_loop(N) \ + vec1[N] = Operation::process(vec0[N], v); \ exprtk_loop( 0) exprtk_loop( 1) exprtk_loop( 2) exprtk_loop( 3) @@ -10489,10 +10702,11 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { - #define case_stmt(N) \ - case N : { vec1[i] = Operation::process(vec0[i],v); ++i; } \ + #define case_stmt(N) \ + case N : { vec1[i] = Operation::process(vec0[i], v); ++i; } \ #ifndef exprtk_disable_superscalar_unroll case_stmt(15) case_stmt(14) @@ -10505,6 +10719,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -10567,7 +10782,7 @@ namespace exprtk vec_binop_valvec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), vec1_node_ptr_(0), temp_ (0), temp_vec_node_(0) @@ -10614,16 +10829,16 @@ namespace exprtk const T v = binary_node::branch_[0].first->value(); binary_node::branch_[1].first->value(); - T* vec0 = vds().data(); - T* vec1 = vec1_node_ptr_->vds().data(); + T* vec0 = vds().data(); + const T* vec1 = vec1_node_ptr_->vds().data(); loop_unroll::details lud(size()); const T* upper_bound = vec0 + lud.upper_bound; while (vec0 < upper_bound) { - #define exprtk_loop(N) \ - vec0[N] = Operation::process(v,vec1[N]); \ + #define exprtk_loop(N) \ + vec0[N] = Operation::process(v, vec1[N]); \ exprtk_loop( 0) exprtk_loop( 1) exprtk_loop( 2) exprtk_loop( 3) @@ -10642,10 +10857,11 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { - #define case_stmt(N) \ - case N : { vec0[i] = Operation::process(v,vec1[i]); ++i; } \ + #define case_stmt(N) \ + case N : { vec0[i] = Operation::process(v, vec1[i]); ++i; } \ #ifndef exprtk_disable_superscalar_unroll case_stmt(15) case_stmt(14) @@ -10658,6 +10874,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -10718,7 +10935,7 @@ namespace exprtk typedef vec_data_store vds_t; unary_vector_node(const operator_type& opr, expression_ptr branch0) - : unary_node(opr,branch0), + : unary_node(opr, branch0), vec0_node_ptr_(0), temp_ (0), temp_vec_node_(0) @@ -10764,8 +10981,8 @@ namespace exprtk if (vec0_node_ptr_) { - T* vec0 = vec0_node_ptr_->vds().data(); - T* vec1 = vds().data(); + const T* vec0 = vec0_node_ptr_->vds().data(); + T* vec1 = vds().data(); loop_unroll::details lud(size()); const T* upper_bound = vec0 + lud.upper_bound; @@ -10792,6 +11009,7 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { #define case_stmt(N) \ @@ -10808,6 +11026,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -10866,7 +11085,7 @@ namespace exprtk scand_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1) + : binary_node(opr, branch0, branch1) {} inline T value() const @@ -10890,7 +11109,7 @@ namespace exprtk scor_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1) + : binary_node(opr, branch0, branch1) {} inline T value() const @@ -10914,7 +11133,7 @@ namespace exprtk typedef std::pair branch_t; typedef IFunction ifunction; - function_N_node(ifunction* func) + explicit function_N_node(ifunction* func) : function_((N == func->param_count) ? func : reinterpret_cast(0)), parameter_count_(func->param_count) {} @@ -11192,9 +11411,9 @@ namespace exprtk private: - ifunction* function_; + ifunction* function_; std::size_t parameter_count_; - branch_t branch_[N]; + branch_t branch_[N]; }; template @@ -11205,7 +11424,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef IFunction ifunction; - function_N_node(ifunction* func) + explicit function_N_node(ifunction* func) : function_((0 == func->param_count) ? func : reinterpret_cast(0)) {} @@ -11253,8 +11472,7 @@ namespace exprtk { if (arg_list_[i] && !details::is_variable_node(arg_list_[i])) { - delete arg_list_[i]; - arg_list_[i] = 0; + destroy_node(arg_list_[i]); } } } @@ -11349,6 +11567,7 @@ namespace exprtk ts.size = vi->size(); ts.data = vi->vds().data(); ts.type = type_store_t::e_vector; + vi->vec()->vec_holder().set_ref(&ts.vec_data); } #ifndef exprtk_disable_string_capabilities else if (is_generally_string_node(arg_list_[i])) @@ -11359,7 +11578,7 @@ namespace exprtk return false; ts.size = sbn->size(); - ts.data = reinterpret_cast(const_cast(sbn->base())); + ts.data = reinterpret_cast(const_cast(sbn->base())); ts.type = type_store_t::e_string; range_list_[i].data = ts.data; @@ -11380,7 +11599,7 @@ namespace exprtk ) { ts.size = rp.const_size(); - ts.data = static_cast(ts.data) + rp.n0_c.second; + ts.data = static_cast(ts.data) + rp.n0_c.second; range_list_[i].range = reinterpret_cast(0); } else @@ -11462,10 +11681,10 @@ namespace exprtk ts.size = rp.cache_size(); #ifndef exprtk_disable_string_capabilities if (ts.type == type_store_t::e_string) - ts.data = const_cast(rdt.str_node->base()) + rp.cache.first; + ts.data = const_cast(rdt.str_node->base()) + rp.cache.first; else #endif - ts.data = static_cast(rdt.data) + (rp.cache.first * rdt.type_size); + ts.data = static_cast(rdt.data) + (rp.cache.first * rdt.type_size); } else return false; @@ -11481,9 +11700,9 @@ namespace exprtk private: std::vector arg_list_; - std::vector branch_; - mutable tmp_vs_t expr_as_vec1_store_; - mutable range_list_t range_list_; + std::vector branch_; + mutable tmp_vs_t expr_as_vec1_store_; + mutable range_list_t range_list_; }; #ifndef exprtk_disable_string_capabilities @@ -11514,16 +11733,14 @@ namespace exprtk inline T value() const { - T result = std::numeric_limits::quiet_NaN(); - if (gen_function_t::function_) { if (gen_function_t::populate_value_list()) { typedef typename StringFunction::parameter_list_t parameter_list_t; - result = (*gen_function_t::function_)(ret_string_, - parameter_list_t(gen_function_t::typestore_list_)); + const T result = (*gen_function_t::function_) + (ret_string_, parameter_list_t(gen_function_t::typestore_list_)); range_.n1_c.second = ret_string_.size() - 1; range_.cache.second = range_.n1_c.second; @@ -11532,7 +11749,7 @@ namespace exprtk } } - return result; + return std::numeric_limits::quiet_NaN(); } inline typename expression_node::node_type type() const @@ -11545,7 +11762,7 @@ namespace exprtk return ret_string_; } - const char* base() const + char_cptr base() const { return &ret_string_[0]; } @@ -11589,8 +11806,6 @@ namespace exprtk inline T value() const { - T result = std::numeric_limits::quiet_NaN(); - if (gen_function_t::function_) { if (gen_function_t::populate_value_list()) @@ -11602,7 +11817,7 @@ namespace exprtk } } - return result; + return std::numeric_limits::quiet_NaN(); } inline typename expression_node::node_type type() const @@ -11633,17 +11848,15 @@ namespace exprtk inline T value() const { - T result = std::numeric_limits::quiet_NaN(); - if (str_function_t::function_) { if (str_function_t::populate_value_list()) { typedef typename StringFunction::parameter_list_t parameter_list_t; - result = (*str_function_t::function_)(param_seq_index_, - str_function_t::ret_string_, - parameter_list_t(str_function_t::typestore_list_)); + const T result = (*str_function_t::function_)(param_seq_index_, + str_function_t::ret_string_, + parameter_list_t(str_function_t::typestore_list_)); str_function_t::range_.n1_c.second = str_function_t::ret_string_.size() - 1; str_function_t::range_.cache.second = str_function_t::range_.n1_c.second; @@ -11652,7 +11865,7 @@ namespace exprtk } } - return result; + return std::numeric_limits::quiet_NaN(); } inline typename expression_node::node_type type() const @@ -11662,7 +11875,7 @@ namespace exprtk private: - std::size_t param_seq_index_; + const std::size_t param_seq_index_; }; #endif @@ -11680,7 +11893,7 @@ namespace exprtk typedef type_store generic_type; typedef typename generic_type::parameter_list parameter_list_t; - inline virtual T operator()(parameter_list_t) + inline virtual T operator() (parameter_list_t) { return std::numeric_limits::quiet_NaN(); } @@ -11740,9 +11953,9 @@ namespace exprtk typedef results_context results_context_t; return_envelope_node(expression_ptr body, results_context_t& rc) - : results_context_(&rc), + : results_context_(&rc ), return_invoked_ (false), - body_ (body), + body_ (body ), body_deletable_ (branch_deletable(body_)) {} @@ -11750,7 +11963,7 @@ namespace exprtk { if (body_ && body_deletable_) { - delete body_; + destroy_node(body_); } } @@ -11785,7 +11998,7 @@ namespace exprtk results_context_t* results_context_; mutable bool return_invoked_; expression_ptr body_; - bool body_deletable_; + const bool body_deletable_; }; #endif @@ -11857,20 +12070,21 @@ namespace exprtk template struct opr_base { - typedef typename details::functor_t::Type Type; + typedef typename details::functor_t::Type Type; typedef typename details::functor_t::RefType RefType; - typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; + typedef typename details::functor_t functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; }; template struct add_op : public opr_base { - typedef typename opr_base::Type Type; + typedef typename opr_base::Type Type; typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 + t2; } static inline T process(Type t1, Type t2, Type t3) { return t1 + t2 + t3; } static inline void assign(RefType t1, Type t2) { t1 += t2; } @@ -11881,8 +12095,9 @@ namespace exprtk template struct mul_op : public opr_base { - typedef typename opr_base::Type Type; + typedef typename opr_base::Type Type; typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 * t2; } static inline T process(Type t1, Type t2, Type t3) { return t1 * t2 * t3; } static inline void assign(RefType t1, Type t2) { t1 *= t2; } @@ -11893,8 +12108,9 @@ namespace exprtk template struct sub_op : public opr_base { - typedef typename opr_base::Type Type; + typedef typename opr_base::Type Type; typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 - t2; } static inline T process(Type t1, Type t2, Type t3) { return t1 - t2 - t3; } static inline void assign(RefType t1, Type t2) { t1 -= t2; } @@ -11905,8 +12121,9 @@ namespace exprtk template struct div_op : public opr_base { - typedef typename opr_base::Type Type; + typedef typename opr_base::Type Type; typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return t1 / t2; } static inline T process(Type t1, Type t2, Type t3) { return t1 / t2 / t3; } static inline void assign(RefType t1, Type t2) { t1 /= t2; } @@ -11917,8 +12134,9 @@ namespace exprtk template struct mod_op : public opr_base { - typedef typename opr_base::Type Type; + typedef typename opr_base::Type Type; typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return numeric::modulus(t1,t2); } static inline void assign(RefType t1, Type t2) { t1 = numeric::modulus(t1,t2); } static inline typename expression_node::node_type type() { return expression_node::e_mod; } @@ -11928,8 +12146,9 @@ namespace exprtk template struct pow_op : public opr_base { - typedef typename opr_base::Type Type; + typedef typename opr_base::Type Type; typedef typename opr_base::RefType RefType; + static inline T process(Type t1, Type t2) { return numeric::pow(t1,t2); } static inline void assign(RefType t1, Type t2) { t1 = numeric::pow(t1,t2); } static inline typename expression_node::node_type type() { return expression_node::e_pow; } @@ -11940,6 +12159,7 @@ namespace exprtk struct lt_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 < t2) ? T(1) : T(0)); } static inline T process(const std::string& t1, const std::string& t2) { return ((t1 < t2) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_lt; } @@ -11950,6 +12170,7 @@ namespace exprtk struct lte_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 <= t2) ? T(1) : T(0)); } static inline T process(const std::string& t1, const std::string& t2) { return ((t1 <= t2) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_lte; } @@ -11960,6 +12181,7 @@ namespace exprtk struct gt_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 > t2) ? T(1) : T(0)); } static inline T process(const std::string& t1, const std::string& t2) { return ((t1 > t2) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_gt; } @@ -11970,6 +12192,7 @@ namespace exprtk struct gte_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return ((t1 >= t2) ? T(1) : T(0)); } static inline T process(const std::string& t1, const std::string& t2) { return ((t1 >= t2) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_gte; } @@ -11990,7 +12213,8 @@ namespace exprtk struct equal_op : public opr_base { typedef typename opr_base::Type Type; - static inline T process(Type t1, Type t2) { return (numeric::equal(t1,t2) ? T(1) : T(0)); } + + static inline T process(Type t1, Type t2) { return numeric::equal(t1,t2); } static inline T process(const std::string& t1, const std::string& t2) { return ((t1 == t2) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_eq; } static inline details::operator_type operation() { return details::e_equal; } @@ -12000,6 +12224,7 @@ namespace exprtk struct ne_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (std::not_equal_to()(t1,t2) ? T(1) : T(0)); } static inline T process(const std::string& t1, const std::string& t2) { return ((t1 != t2) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_ne; } @@ -12010,6 +12235,7 @@ namespace exprtk struct and_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) && details::is_true(t2)) ? T(1) : T(0); } static inline typename expression_node::node_type type() { return expression_node::e_and; } static inline details::operator_type operation() { return details::e_and; } @@ -12019,6 +12245,7 @@ namespace exprtk struct nand_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) && details::is_true(t2)) ? T(0) : T(1); } static inline typename expression_node::node_type type() { return expression_node::e_nand; } static inline details::operator_type operation() { return details::e_nand; } @@ -12028,6 +12255,7 @@ namespace exprtk struct or_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) || details::is_true(t2)) ? T(1) : T(0); } static inline typename expression_node::node_type type() { return expression_node::e_or; } static inline details::operator_type operation() { return details::e_or; } @@ -12037,6 +12265,7 @@ namespace exprtk struct nor_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return (details::is_true(t1) || details::is_true(t2)) ? T(0) : T(1); } static inline typename expression_node::node_type type() { return expression_node::e_nor; } static inline details::operator_type operation() { return details::e_nor; } @@ -12046,6 +12275,7 @@ namespace exprtk struct xor_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return numeric::xor_opr(t1,t2); } static inline typename expression_node::node_type type() { return expression_node::e_nor; } static inline details::operator_type operation() { return details::e_xor; } @@ -12055,6 +12285,7 @@ namespace exprtk struct xnor_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(Type t1, Type t2) { return numeric::xnor_opr(t1,t2); } static inline typename expression_node::node_type type() { return expression_node::e_nor; } static inline details::operator_type operation() { return details::e_xnor; } @@ -12064,6 +12295,7 @@ namespace exprtk struct in_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } static inline T process(const std::string& t1, const std::string& t2) { return ((std::string::npos != t2.find(t1)) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_in; } @@ -12074,6 +12306,7 @@ namespace exprtk struct like_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } static inline T process(const std::string& t1, const std::string& t2) { return (details::wc_match(t2,t1) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_like; } @@ -12084,6 +12317,7 @@ namespace exprtk struct ilike_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(const T&, const T&) { return std::numeric_limits::quiet_NaN(); } static inline T process(const std::string& t1, const std::string& t2) { return (details::wc_imatch(t2,t1) ? T(1) : T(0)); } static inline typename expression_node::node_type type() { return expression_node::e_ilike; } @@ -12094,6 +12328,7 @@ namespace exprtk struct inrange_op : public opr_base { typedef typename opr_base::Type Type; + static inline T process(const T& t0, const T& t1, const T& t2) { return ((t0 <= t1) && (t1 <= t2)) ? T(1) : T(0); } static inline T process(const std::string& t0, const std::string& t1, const std::string& t2) { @@ -12122,7 +12357,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12163,14 +12398,14 @@ namespace exprtk static inline T process_3(const Sequence& arg_list) { return value(arg_list[0]) + value(arg_list[1]) + - value(arg_list[2]); + value(arg_list[2]) ; } template static inline T process_4(const Sequence& arg_list) { return value(arg_list[0]) + value(arg_list[1]) + - value(arg_list[2]) + value(arg_list[3]); + value(arg_list[2]) + value(arg_list[3]) ; } template @@ -12178,7 +12413,7 @@ namespace exprtk { return value(arg_list[0]) + value(arg_list[1]) + value(arg_list[2]) + value(arg_list[3]) + - value(arg_list[4]); + value(arg_list[4]) ; } }; @@ -12189,7 +12424,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12230,14 +12465,14 @@ namespace exprtk static inline T process_3(const Sequence& arg_list) { return value(arg_list[0]) * value(arg_list[1]) * - value(arg_list[2]); + value(arg_list[2]) ; } template static inline T process_4(const Sequence& arg_list) { return value(arg_list[0]) * value(arg_list[1]) * - value(arg_list[2]) * value(arg_list[3]); + value(arg_list[2]) * value(arg_list[3]) ; } template @@ -12245,7 +12480,7 @@ namespace exprtk { return value(arg_list[0]) * value(arg_list[1]) * value(arg_list[2]) * value(arg_list[3]) * - value(arg_list[4]); + value(arg_list[4]) ; } }; @@ -12256,7 +12491,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12312,7 +12547,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12383,7 +12618,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12454,7 +12689,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12468,7 +12703,7 @@ namespace exprtk { for (std::size_t i = 0; i < arg_list.size(); ++i) { - if (std::equal_to()(T(0),value(arg_list[i]))) + if (std::equal_to()(T(0), value(arg_list[i]))) return T(0); } @@ -12481,15 +12716,15 @@ namespace exprtk static inline T process_1(const Sequence& arg_list) { return std::not_equal_to() - (T(0),value(arg_list[0])) ? T(1) : T(0); + (T(0), value(arg_list[0])) ? T(1) : T(0); } template static inline T process_2(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) + std::not_equal_to()(T(0), value(arg_list[0])) && + std::not_equal_to()(T(0), value(arg_list[1])) ) ? T(1) : T(0); } @@ -12497,9 +12732,9 @@ namespace exprtk static inline T process_3(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) && - std::not_equal_to()(T(0),value(arg_list[2])) + std::not_equal_to()(T(0), value(arg_list[0])) && + std::not_equal_to()(T(0), value(arg_list[1])) && + std::not_equal_to()(T(0), value(arg_list[2])) ) ? T(1) : T(0); } @@ -12507,10 +12742,10 @@ namespace exprtk static inline T process_4(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) && - std::not_equal_to()(T(0),value(arg_list[2])) && - std::not_equal_to()(T(0),value(arg_list[3])) + std::not_equal_to()(T(0), value(arg_list[0])) && + std::not_equal_to()(T(0), value(arg_list[1])) && + std::not_equal_to()(T(0), value(arg_list[2])) && + std::not_equal_to()(T(0), value(arg_list[3])) ) ? T(1) : T(0); } @@ -12518,11 +12753,11 @@ namespace exprtk static inline T process_5(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) && - std::not_equal_to()(T(0),value(arg_list[1])) && - std::not_equal_to()(T(0),value(arg_list[2])) && - std::not_equal_to()(T(0),value(arg_list[3])) && - std::not_equal_to()(T(0),value(arg_list[4])) + std::not_equal_to()(T(0), value(arg_list[0])) && + std::not_equal_to()(T(0), value(arg_list[1])) && + std::not_equal_to()(T(0), value(arg_list[2])) && + std::not_equal_to()(T(0), value(arg_list[3])) && + std::not_equal_to()(T(0), value(arg_list[4])) ) ? T(1) : T(0); } }; @@ -12534,7 +12769,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12548,7 +12783,7 @@ namespace exprtk { for (std::size_t i = 0; i < arg_list.size(); ++i) { - if (std::not_equal_to()(T(0),value(arg_list[i]))) + if (std::not_equal_to()(T(0), value(arg_list[i]))) return T(1); } @@ -12561,15 +12796,15 @@ namespace exprtk static inline T process_1(const Sequence& arg_list) { return std::not_equal_to() - (T(0),value(arg_list[0])) ? T(1) : T(0); + (T(0), value(arg_list[0])) ? T(1) : T(0); } template static inline T process_2(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) + std::not_equal_to()(T(0), value(arg_list[0])) || + std::not_equal_to()(T(0), value(arg_list[1])) ) ? T(1) : T(0); } @@ -12577,9 +12812,9 @@ namespace exprtk static inline T process_3(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) || - std::not_equal_to()(T(0),value(arg_list[2])) + std::not_equal_to()(T(0), value(arg_list[0])) || + std::not_equal_to()(T(0), value(arg_list[1])) || + std::not_equal_to()(T(0), value(arg_list[2])) ) ? T(1) : T(0); } @@ -12587,10 +12822,10 @@ namespace exprtk static inline T process_4(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) || - std::not_equal_to()(T(0),value(arg_list[2])) || - std::not_equal_to()(T(0),value(arg_list[3])) + std::not_equal_to()(T(0), value(arg_list[0])) || + std::not_equal_to()(T(0), value(arg_list[1])) || + std::not_equal_to()(T(0), value(arg_list[2])) || + std::not_equal_to()(T(0), value(arg_list[3])) ) ? T(1) : T(0); } @@ -12598,11 +12833,11 @@ namespace exprtk static inline T process_5(const Sequence& arg_list) { return ( - std::not_equal_to()(T(0),value(arg_list[0])) || - std::not_equal_to()(T(0),value(arg_list[1])) || - std::not_equal_to()(T(0),value(arg_list[2])) || - std::not_equal_to()(T(0),value(arg_list[3])) || - std::not_equal_to()(T(0),value(arg_list[4])) + std::not_equal_to()(T(0), value(arg_list[0])) || + std::not_equal_to()(T(0), value(arg_list[1])) || + std::not_equal_to()(T(0), value(arg_list[2])) || + std::not_equal_to()(T(0), value(arg_list[3])) || + std::not_equal_to()(T(0), value(arg_list[4])) ) ? T(1) : T(0); } }; @@ -12614,7 +12849,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12734,6 +12969,7 @@ namespace exprtk T result = T(0); int i = 0; + exprtk_disable_fallthrough_begin switch (vec_size) { #define case_stmt(N) \ @@ -12750,6 +12986,7 @@ namespace exprtk case_stmt( 4) case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef case_stmt @@ -12784,6 +13021,7 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { #define case_stmt(N) \ @@ -12800,6 +13038,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -12831,6 +13070,7 @@ namespace exprtk T result = T(1); int i = 0; + exprtk_disable_fallthrough_begin switch (vec_size) { #define case_stmt(N) \ @@ -12847,6 +13087,7 @@ namespace exprtk case_stmt( 4) case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef case_stmt @@ -12881,6 +13122,7 @@ namespace exprtk int i = 0; + exprtk_disable_fallthrough_begin switch (lud.remainder) { #define case_stmt(N) \ @@ -12897,6 +13139,7 @@ namespace exprtk case_stmt( 3) case_stmt( 2) case_stmt( 1) } + exprtk_disable_fallthrough_end #undef exprtk_loop #undef case_stmt @@ -13210,9 +13453,9 @@ namespace exprtk ufunc_t uf0, ufunc_t uf1, bfunc_t bf) : v0_(var0), v1_(var1), - u0_(uf0), - u1_(uf1), - f_ (bf) + u0_(uf0 ), + u1_(uf1 ), + f_ (bf ) {} inline T value() const @@ -13284,8 +13527,7 @@ namespace exprtk { if (branch_ && branch_deletable_) { - delete branch_; - branch_ = 0; + destroy_node(branch_); } } @@ -13507,15 +13749,15 @@ namespace exprtk template \ const typename expression_node::node_type nodetype_T0oT1::result = expression_node:: v_; \ - synthesis_node_type_define(const T0&,const T1&, e_vov) - synthesis_node_type_define(const T0&,const T1 , e_voc) - synthesis_node_type_define(const T0 ,const T1&, e_cov) - synthesis_node_type_define( T0&, T1&,e_none) - synthesis_node_type_define(const T0 ,const T1 ,e_none) - synthesis_node_type_define( T0&,const T1 ,e_none) - synthesis_node_type_define(const T0 , T1&,e_none) - synthesis_node_type_define(const T0&, T1&,e_none) - synthesis_node_type_define( T0&,const T1&,e_none) + synthesis_node_type_define(const T0&, const T1&, e_vov) + synthesis_node_type_define(const T0&, const T1 , e_voc) + synthesis_node_type_define(const T0 , const T1&, e_cov) + synthesis_node_type_define( T0&, T1&, e_none) + synthesis_node_type_define(const T0 , const T1 , e_none) + synthesis_node_type_define( T0&, const T1 , e_none) + synthesis_node_type_define(const T0 , T1&, e_none) + synthesis_node_type_define(const T0&, T1&, e_none) + synthesis_node_type_define( T0&, const T1&, e_none) #undef synthesis_node_type_define template @@ -13529,15 +13771,15 @@ namespace exprtk template \ const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node:: v_; \ - synthesis_node_type_define(const T0&,const T1&,const T2&, e_vovov) - synthesis_node_type_define(const T0&,const T1&,const T2 , e_vovoc) - synthesis_node_type_define(const T0&,const T1 ,const T2&, e_vocov) - synthesis_node_type_define(const T0 ,const T1&,const T2&, e_covov) - synthesis_node_type_define(const T0 ,const T1&,const T2 , e_covoc) - synthesis_node_type_define(const T0 ,const T1 ,const T2 , e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2&, e_none ) - synthesis_node_type_define(const T0&,const T1 ,const T2 , e_none ) - synthesis_node_type_define( T0&, T1&, T2&, e_none ) + synthesis_node_type_define(const T0&, const T1&, const T2&, e_vovov) + synthesis_node_type_define(const T0&, const T1&, const T2 , e_vovoc) + synthesis_node_type_define(const T0&, const T1 , const T2&, e_vocov) + synthesis_node_type_define(const T0 , const T1&, const T2&, e_covov) + synthesis_node_type_define(const T0 , const T1&, const T2 , e_covoc) + synthesis_node_type_define(const T0 , const T1 , const T2 , e_none ) + synthesis_node_type_define(const T0 , const T1 , const T2&, e_none ) + synthesis_node_type_define(const T0&, const T1 , const T2 , e_none ) + synthesis_node_type_define( T0&, T1&, T2&, e_none ) #undef synthesis_node_type_define template @@ -13551,22 +13793,22 @@ namespace exprtk template \ const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node:: v_; \ - synthesis_node_type_define(const T0&,const T1&,const T2&, const T3&,e_vovovov) - synthesis_node_type_define(const T0&,const T1&,const T2&, const T3 ,e_vovovoc) - synthesis_node_type_define(const T0&,const T1&,const T2 , const T3&,e_vovocov) - synthesis_node_type_define(const T0&,const T1 ,const T2&, const T3&,e_vocovov) - synthesis_node_type_define(const T0 ,const T1&,const T2&, const T3&,e_covovov) - synthesis_node_type_define(const T0 ,const T1&,const T2 , const T3&,e_covocov) - synthesis_node_type_define(const T0&,const T1 ,const T2&, const T3 ,e_vocovoc) - synthesis_node_type_define(const T0 ,const T1&,const T2&, const T3 ,e_covovoc) - synthesis_node_type_define(const T0&,const T1 ,const T2 , const T3&,e_vococov) - synthesis_node_type_define(const T0 ,const T1 ,const T2 , const T3 ,e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2 , const T3&,e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2&, const T3 ,e_none ) - synthesis_node_type_define(const T0 ,const T1&,const T2 , const T3 ,e_none ) - synthesis_node_type_define(const T0&,const T1 ,const T2 , const T3 ,e_none ) - synthesis_node_type_define(const T0 ,const T1 ,const T2&, const T3&,e_none ) - synthesis_node_type_define(const T0&,const T1&,const T2 , const T3 ,e_none ) + synthesis_node_type_define(const T0&, const T1&, const T2&, const T3&, e_vovovov) + synthesis_node_type_define(const T0&, const T1&, const T2&, const T3 , e_vovovoc) + synthesis_node_type_define(const T0&, const T1&, const T2 , const T3&, e_vovocov) + synthesis_node_type_define(const T0&, const T1 , const T2&, const T3&, e_vocovov) + synthesis_node_type_define(const T0 , const T1&, const T2&, const T3&, e_covovov) + synthesis_node_type_define(const T0 , const T1&, const T2 , const T3&, e_covocov) + synthesis_node_type_define(const T0&, const T1 , const T2&, const T3 , e_vocovoc) + synthesis_node_type_define(const T0 , const T1&, const T2&, const T3 , e_covovoc) + synthesis_node_type_define(const T0&, const T1 , const T2 , const T3&, e_vococov) + synthesis_node_type_define(const T0 , const T1 , const T2 , const T3 , e_none ) + synthesis_node_type_define(const T0 , const T1 , const T2 , const T3&, e_none ) + synthesis_node_type_define(const T0 , const T1 , const T2&, const T3 , e_none ) + synthesis_node_type_define(const T0 , const T1&, const T2 , const T3 , e_none ) + synthesis_node_type_define(const T0&, const T1 , const T2 , const T3 , e_none ) + synthesis_node_type_define(const T0 , const T1 , const T2&, const T3&, e_none ) + synthesis_node_type_define(const T0&, const T1&, const T2 , const T3 , e_none ) #undef synthesis_node_type_define template @@ -13621,13 +13863,15 @@ namespace exprtk T0 p0, T1 p1, bfunc_t p2) { - return allocator.template allocate_type(p0,p1,p2); + return allocator + .template allocate_type + (p0, p1, p2); } private: T0oT1(T0oT1&) {} - T0oT1& operator=(T0oT1&) { return *this; } + T0oT1& operator=(T0oT1&) { return (*this); } T0 t0_; T1 t1_; @@ -13666,7 +13910,7 @@ namespace exprtk inline T value() const { - return ProcessMode::process(t0_,t1_,t2_,f0_,f1_); + return ProcessMode::process(t0_, t1_, t2_, f0_, f1_); } inline T0 t0() const @@ -13707,13 +13951,15 @@ namespace exprtk template static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, bfunc_t p3, bfunc_t p4) { - return allocator.template allocate_type(p0,p1,p2,p3,p4); + return allocator + .template allocate_type + (p0, p1, p2, p3, p4); } private: T0oT1oT2(node_type&) {} - node_type& operator=(node_type&) { return *this; } + node_type& operator=(node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -13749,7 +13995,7 @@ namespace exprtk inline T value() const { - return ProcessMode::process(t0_,t1_,t2_,t3_,f0_,f1_,f2_); + return ProcessMode::process(t0_, t1_, t2_, t3_, f0_, f1_, f2_); } inline T0 t0() const @@ -13794,7 +14040,7 @@ namespace exprtk static inline std::string id() { - return process_mode_t::template id(); + return process_mode_t::template id(); } template @@ -13802,13 +14048,15 @@ namespace exprtk T0 p0, T1 p1, T2 p2, T3 p3, bfunc_t p4, bfunc_t p5, bfunc_t p6) { - return allocator.template allocate_type(p0,p1,p2,p3,p4,p5,p6); + return allocator + .template allocate_type + (p0, p1, p2, p3, p4, p5, p6); } private: T0oT1oT2oT3(node_type&) {} - node_type& operator=(node_type&) { return *this; } + node_type& operator=(node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -13849,7 +14097,7 @@ namespace exprtk inline T value() const { - return f_(t0_,t1_,t2_); + return f_(t0_, t1_, t2_); } inline T0 t0() const @@ -13885,13 +14133,15 @@ namespace exprtk template static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, tfunc_t p3) { - return allocator.template allocate_type(p0,p1,p2,p3); + return allocator + .template allocate_type + (p0, p1, p2, p3); } private: T0oT1oT2_sf3(node_type&) {} - node_type& operator=(node_type&) { return *this; } + node_type& operator=(node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -13943,7 +14193,7 @@ namespace exprtk inline T value() const { - return SF3Operation::process(t0_,t1_,t2_); + return SF3Operation::process(t0_, t1_, t2_); } T0 t0() const @@ -13974,13 +14224,15 @@ namespace exprtk template static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2) { - return allocator.template allocate_type(p0,p1,p2); + return allocator + .template allocate_type + (p0, p1, p2); } private: T0oT1oT2_sf3ext(node_type&) {} - node_type& operator=(node_type&) { return *this; } + node_type& operator=(node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14032,7 +14284,7 @@ namespace exprtk inline T value() const { - return f_(t0_,t1_,t2_,t3_); + return f_(t0_, t1_, t2_, t3_); } inline T0 t0() const @@ -14073,13 +14325,15 @@ namespace exprtk template static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3, qfunc_t p4) { - return allocator.template allocate_type(p0,p1,p2,p3,p4); + return allocator + .template allocate_type + (p0, p1, p2, p3, p4); } private: T0oT1oT2oT3_sf4(node_type&) {} - node_type& operator=(node_type&) { return *this; } + node_type& operator=(node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14118,7 +14372,7 @@ namespace exprtk inline T value() const { - return SF4Operation::process(t0_,t1_,t2_,t3_); + return SF4Operation::process(t0_, t1_, t2_, t3_); } inline T0 t0() const @@ -14138,7 +14392,7 @@ namespace exprtk inline T3 t3() const { - return t2_; + return t3_; } std::string type_id() const @@ -14154,13 +14408,15 @@ namespace exprtk template static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3) { - return allocator.template allocate_type(p0,p1,p2,p3); + return allocator + .template allocate_type + (p0, p1, p2, p3); } private: T0oT1oT2oT3_sf4ext(node_type&) {} - node_type& operator=(node_type&) { return *this; } + node_type& operator=(node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14189,27 +14445,27 @@ namespace exprtk template struct T0oT1_define { - typedef details::T0oT1 type0; + typedef details::T0oT1 type0; }; template struct T0oT1oT2_define { - typedef details::T0oT1oT2::mode0> type0; - typedef details::T0oT1oT2::mode1> type1; - typedef details::T0oT1oT2_sf3 sf3_type; - typedef details::sf3ext_type_node sf3_type_node; + typedef details::T0oT1oT2::mode0> type0; + typedef details::T0oT1oT2::mode1> type1; + typedef details::T0oT1oT2_sf3 sf3_type; + typedef details::sf3ext_type_node sf3_type_node; }; template struct T0oT1oT2oT3_define { - typedef details::T0oT1oT2oT3::mode0> type0; - typedef details::T0oT1oT2oT3::mode1> type1; - typedef details::T0oT1oT2oT3::mode2> type2; - typedef details::T0oT1oT2oT3::mode3> type3; - typedef details::T0oT1oT2oT3::mode4> type4; - typedef details::T0oT1oT2oT3_sf4 sf4_type; + typedef details::T0oT1oT2oT3::mode0> type0; + typedef details::T0oT1oT2oT3::mode1> type1; + typedef details::T0oT1oT2oT3::mode2> type2; + typedef details::T0oT1oT2oT3::mode3> type3; + typedef details::T0oT1oT2oT3::mode4> type4; + typedef details::T0oT1oT2oT3_sf4 sf4_type; }; template @@ -14514,7 +14770,7 @@ namespace exprtk cob_node(const cob_node&); cob_node& operator=(const cob_node&); - const T c_; + const T c_; branch_t branch_[1]; }; @@ -14575,7 +14831,7 @@ namespace exprtk boc_node(const boc_node&); boc_node& operator=(const boc_node&); - const T c_; + const T c_; branch_t branch_[1]; }; @@ -14640,8 +14896,8 @@ namespace exprtk // string-range op string node explicit str_xrox_node(SType0 p0, SType1 p1, RangePack rp0) - : s0_(p0), - s1_(p1), + : s0_ (p0 ), + s1_ (p1 ), rp0_(rp0) {} @@ -14655,8 +14911,8 @@ namespace exprtk std::size_t r0 = 0; std::size_t r1 = 0; - if (rp0_(r0,r1,s0_.size())) - return Operation::process(s0_.substr(r0,(r1 - r0) + 1),s1_); + if (rp0_(r0, r1, s0_.size())) + return Operation::process(s0_.substr(r0, (r1 - r0) + 1), s1_); else return T(0); } @@ -14718,8 +14974,8 @@ namespace exprtk std::size_t r0 = 0; std::size_t r1 = 0; - if (rp1_(r0,r1,s1_.size())) - return Operation::process(s0_,s1_.substr(r0,(r1 - r0) + 1)); + if (rp1_(r0, r1, s1_.size())) + return Operation::process(s0_, s1_.substr(r0, (r1 - r0) + 1)); else return T(0); } @@ -14784,14 +15040,15 @@ namespace exprtk std::size_t r0_1 = 0; std::size_t r1_0 = 0; std::size_t r1_1 = 0; + if ( - rp0_(r0_0,r1_0,s0_.size()) && - rp1_(r0_1,r1_1,s1_.size()) + rp0_(r0_0, r1_0, s0_.size()) && + rp1_(r0_1, r1_1, s1_.size()) ) { return Operation::process( - s0_.substr(r0_0,(r1_0 - r0_0) + 1), - s1_.substr(r0_1,(r1_1 - r0_1) + 1) + s0_.substr(r0_0, (r1_0 - r0_0) + 1), + s1_.substr(r0_1, (r1_1 - r0_1) + 1) ); } else @@ -14846,7 +15103,7 @@ namespace exprtk str_sogens_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr,branch0,branch1), + : binary_node(opr, branch0, branch1), str0_base_ptr_ (0), str1_base_ptr_ (0), str0_range_ptr_(0), @@ -14859,12 +15116,12 @@ namespace exprtk if (0 == str0_base_ptr_) return; - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[0].first); + irange_ptr range = dynamic_cast(binary_node::branch_[0].first); - if (0 == range_ptr) + if (0 == range) return; - str0_range_ptr_ = &(range_ptr->range_ref()); + str0_range_ptr_ = &(range->range_ref()); } if (is_generally_string_node(binary_node::branch_[1].first)) @@ -14874,12 +15131,12 @@ namespace exprtk if (0 == str1_base_ptr_) return; - irange_ptr range_ptr = dynamic_cast(binary_node::branch_[1].first); + irange_ptr range = dynamic_cast(binary_node::branch_[1].first); - if (0 == range_ptr) + if (0 == range) return; - str1_range_ptr_ = &(range_ptr->range_ref()); + str1_range_ptr_ = &(range->range_ref()); } } @@ -14905,8 +15162,8 @@ namespace exprtk range_t& range1 = (*str1_range_ptr_); if ( - range0(str0_r0,str0_r1,str0_base_ptr_->size()) && - range1(str1_r0,str1_r1,str1_base_ptr_->size()) + range0(str0_r0, str0_r1, str0_base_ptr_->size()) && + range1(str1_r0, str1_r1, str1_base_ptr_->size()) ) { return Operation::process( @@ -15278,134 +15535,134 @@ namespace exprtk template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[1]) { - return allocate(operation,branch[0]); + return allocate(operation, branch[0]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[2]) { - return allocate(operation,branch[0],branch[1]); + return allocate(operation, branch[0], branch[1]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[3]) { - return allocate(operation,branch[0],branch[1],branch[2]); + return allocate(operation, branch[0], branch[1], branch[2]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[4]) { - return allocate(operation,branch[0],branch[1],branch[2],branch[3]); + return allocate(operation, branch[0], branch[1], branch[2], branch[3]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[5]) { - return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4]); + return allocate(operation, branch[0],branch[1], branch[2], branch[3], branch[4]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[6]) { - return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4],branch[5]); + return allocate(operation, branch[0], branch[1], branch[2], branch[3], branch[4], branch[5]); } template inline expression_node* allocate() const { - return new node_type(); + return (new node_type()); } template class Sequence> + template class Sequence> inline expression_node* allocate(const Sequence& seq) const { - return new node_type(seq); + return (new node_type(seq)); } template inline expression_node* allocate(T1& t1) const { - return new node_type(t1); + return (new node_type(t1)); } template inline expression_node* allocate_c(const T1& t1) const { - return new node_type(t1); + return (new node_type(t1)); } template inline expression_node* allocate(const T1& t1, const T2& t2) const { - return new node_type(t1,t2); + return (new node_type(t1, t2)); } template inline expression_node* allocate_cr(const T1& t1, T2& t2) const { - return new node_type(t1,t2); + return (new node_type(t1, t2)); } template inline expression_node* allocate_rc(T1& t1, const T2& t2) const { - return new node_type(t1,t2); + return (new node_type(t1, t2)); } template inline expression_node* allocate_rr(T1& t1, T2& t2) const { - return new node_type(t1,t2); + return (new node_type(t1, t2)); } template inline expression_node* allocate_tt(T1 t1, T2 t2) const { - return new node_type(t1,t2); + return (new node_type(t1, t2)); } template inline expression_node* allocate_ttt(T1 t1, T2 t2, T3 t3) const { - return new node_type(t1,t2,t3); + return (new node_type(t1, t2, t3)); } template inline expression_node* allocate_tttt(T1 t1, T2 t2, T3 t3, T4 t4) const { - return new node_type(t1,t2,t3,t4); + return (new node_type(t1, t2, t3, t4)); } template inline expression_node* allocate_rrr(T1& t1, T2& t2, T3& t3) const { - return new node_type(t1,t2,t3); + return (new node_type(t1, t2, t3)); } template inline expression_node* allocate_rrrr(T1& t1, T2& t2, T3& t3, T4& t4) const { - return new node_type(t1,t2,t3,t4); + return (new node_type(t1, t2, t3, t4)); } template inline expression_node* allocate_rrrrr(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5) const { - return new node_type(t1,t2,t3,t4,t5); + return (new node_type(t1, t2, t3, t4, t5)); } template * allocate(const T1& t1, const T2& t2, const T3& t3) const { - return new node_type(t1,t2,t3); + return (new node_type(t1, t2, t3)); } template * allocate(const T1& t1, const T2& t2, const T3& t3, const T4& t4) const { - return new node_type(t1,t2,t3,t4); + return (new node_type(t1, t2, t3, t4)); } template inline expression_node* allocate_type(T1 t1, T2 t2, T3 t3) const { - return new node_type(t1,t2,t3); + return (new node_type(t1, t2, t3)); } template * allocate_type(T1 t1, T2 t2, T3 t3, T4 t4) const { - return new node_type(t1,t2,t3,t4); + return (new node_type(t1, t2, t3, t4)); } template + inline expression_node* allocate_type(T1 t1, T2 t2, + T3 t3, T4 t4, + T5 t5, T6 t6) const + { + return (new node_type(t1, t2, t3, t4, t5, t6)); } template @@ -15551,58 +15819,58 @@ namespace exprtk #define register_op(Symbol,Type,Args) \ m.insert(std::make_pair(std::string(Symbol),details::base_operation_t(Type,Args))); \ - register_op( "abs",e_abs , 1) - register_op( "acos",e_acos , 1) - register_op( "acosh",e_acosh , 1) - register_op( "asin",e_asin , 1) - register_op( "asinh",e_asinh , 1) - register_op( "atan",e_atan , 1) - register_op( "atanh",e_atanh , 1) - register_op( "ceil",e_ceil , 1) - register_op( "cos",e_cos , 1) - register_op( "cosh",e_cosh , 1) - register_op( "exp",e_exp , 1) - register_op( "expm1",e_expm1 , 1) - register_op( "floor",e_floor , 1) - register_op( "log",e_log , 1) - register_op( "log10",e_log10 , 1) - register_op( "log2",e_log2 , 1) - register_op( "log1p",e_log1p , 1) - register_op( "round",e_round , 1) - register_op( "sin",e_sin , 1) - register_op( "sinc",e_sinc , 1) - register_op( "sinh",e_sinh , 1) - register_op( "sec",e_sec , 1) - register_op( "csc",e_csc , 1) - register_op( "sqrt",e_sqrt , 1) - register_op( "tan",e_tan , 1) - register_op( "tanh",e_tanh , 1) - register_op( "cot",e_cot , 1) - register_op( "rad2deg",e_r2d , 1) - register_op( "deg2rad",e_d2r , 1) - register_op( "deg2grad",e_d2g , 1) - register_op( "grad2deg",e_g2d , 1) - register_op( "sgn",e_sgn , 1) - register_op( "not",e_notl , 1) - register_op( "erf",e_erf , 1) - register_op( "erfc",e_erfc , 1) - register_op( "ncdf",e_ncdf , 1) - register_op( "frac",e_frac , 1) - register_op( "trunc",e_trunc , 1) - register_op( "atan2",e_atan2 , 2) - register_op( "mod",e_mod , 2) - register_op( "logn",e_logn , 2) - register_op( "pow",e_pow , 2) - register_op( "root",e_root , 2) - register_op( "roundn",e_roundn , 2) - register_op( "equal",e_equal , 2) - register_op("not_equal",e_nequal , 2) - register_op( "hypot",e_hypot , 2) - register_op( "shr",e_shr , 2) - register_op( "shl",e_shl , 2) - register_op( "clamp",e_clamp , 3) - register_op( "iclamp",e_iclamp , 3) - register_op( "inrange",e_inrange , 3) + register_op( "abs", e_abs , 1) + register_op( "acos", e_acos , 1) + register_op( "acosh", e_acosh , 1) + register_op( "asin", e_asin , 1) + register_op( "asinh", e_asinh , 1) + register_op( "atan", e_atan , 1) + register_op( "atanh", e_atanh , 1) + register_op( "ceil", e_ceil , 1) + register_op( "cos", e_cos , 1) + register_op( "cosh", e_cosh , 1) + register_op( "exp", e_exp , 1) + register_op( "expm1", e_expm1 , 1) + register_op( "floor", e_floor , 1) + register_op( "log", e_log , 1) + register_op( "log10", e_log10 , 1) + register_op( "log2", e_log2 , 1) + register_op( "log1p", e_log1p , 1) + register_op( "round", e_round , 1) + register_op( "sin", e_sin , 1) + register_op( "sinc", e_sinc , 1) + register_op( "sinh", e_sinh , 1) + register_op( "sec", e_sec , 1) + register_op( "csc", e_csc , 1) + register_op( "sqrt", e_sqrt , 1) + register_op( "tan", e_tan , 1) + register_op( "tanh", e_tanh , 1) + register_op( "cot", e_cot , 1) + register_op( "rad2deg", e_r2d , 1) + register_op( "deg2rad", e_d2r , 1) + register_op( "deg2grad", e_d2g , 1) + register_op( "grad2deg", e_g2d , 1) + register_op( "sgn", e_sgn , 1) + register_op( "not", e_notl , 1) + register_op( "erf", e_erf , 1) + register_op( "erfc", e_erfc , 1) + register_op( "ncdf", e_ncdf , 1) + register_op( "frac", e_frac , 1) + register_op( "trunc", e_trunc , 1) + register_op( "atan2", e_atan2 , 2) + register_op( "mod", e_mod , 2) + register_op( "logn", e_logn , 2) + register_op( "pow", e_pow , 2) + register_op( "root", e_root , 2) + register_op( "roundn", e_roundn , 2) + register_op( "equal", e_equal , 2) + register_op("not_equal", e_nequal , 2) + register_op( "hypot", e_hypot , 2) + register_op( "shr", e_shr , 2) + register_op( "shl", e_shl , 2) + register_op( "clamp", e_clamp , 3) + register_op( "iclamp", e_iclamp , 3) + register_op( "inrange", e_inrange , 3) #undef register_op } @@ -15708,77 +15976,77 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); \ } \ - inline virtual T operator()() + inline virtual T operator() () empty_method_body - inline virtual T operator()(const T&) + inline virtual T operator() (const T&) empty_method_body - inline virtual T operator()(const T&,const T&) + inline virtual T operator() (const T&,const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body - inline virtual T operator()(const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, - const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) + inline virtual T operator() (const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, + const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&, const T&) empty_method_body #undef empty_method_body @@ -15794,7 +16062,7 @@ namespace exprtk virtual ~ivararg_function() {} - inline virtual T operator()(const std::vector&) + inline virtual T operator() (const std::vector&) { exprtk_debug(("ivararg_function::operator() - Operator has not been overridden.\n")); return std::numeric_limits::quiet_NaN(); @@ -15808,8 +16076,9 @@ namespace exprtk enum return_type { - e_rtrn_scalar = 0, - e_rtrn_string = 1 + e_rtrn_scalar = 0, + e_rtrn_string = 1, + e_rtrn_overload = 2 }; typedef T type; @@ -15831,19 +16100,19 @@ namespace exprtk } \ // f(i_0,i_1,....,i_N) --> Scalar - inline virtual T operator()(parameter_list_t) + inline virtual T operator() (parameter_list_t) igeneric_function_empty_body(1) // f(i_0,i_1,....,i_N) --> String - inline virtual T operator()(std::string&, parameter_list_t) + inline virtual T operator() (std::string&, parameter_list_t) igeneric_function_empty_body(2) // f(psi,i_0,i_1,....,i_N) --> Scalar - inline virtual T operator()(const std::size_t&, parameter_list_t) + inline virtual T operator() (const std::size_t&, parameter_list_t) igeneric_function_empty_body(3) // f(psi,i_0,i_1,....,i_N) --> String - inline virtual T operator()(const std::size_t&, std::string&, parameter_list_t) + inline virtual T operator() (const std::size_t&, std::string&, parameter_list_t) igeneric_function_empty_body(4) std::string parameter_sequence; @@ -15858,30 +16127,41 @@ namespace exprtk { public: + typedef T (*ff00_functor)(); typedef T (*ff01_functor)(T); - typedef T (*ff02_functor)(T,T); - typedef T (*ff03_functor)(T,T,T); - typedef T (*ff04_functor)(T,T,T,T); - typedef T (*ff05_functor)(T,T,T,T,T); - typedef T (*ff06_functor)(T,T,T,T,T,T); - typedef T (*ff07_functor)(T,T,T,T,T,T,T); - typedef T (*ff08_functor)(T,T,T,T,T,T,T,T); - typedef T (*ff09_functor)(T,T,T,T,T,T,T,T,T); - typedef T (*ff10_functor)(T,T,T,T,T,T,T,T,T,T); - typedef T (*ff11_functor)(T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff12_functor)(T,T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff13_functor)(T,T,T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff14_functor)(T,T,T,T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff15_functor)(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T); + typedef T (*ff02_functor)(T, T); + typedef T (*ff03_functor)(T, T, T); + typedef T (*ff04_functor)(T, T, T, T); + typedef T (*ff05_functor)(T, T, T, T, T); + typedef T (*ff06_functor)(T, T, T, T, T, T); + typedef T (*ff07_functor)(T, T, T, T, T, T, T); + typedef T (*ff08_functor)(T, T, T, T, T, T, T, T); + typedef T (*ff09_functor)(T, T, T, T, T, T, T, T, T); + typedef T (*ff10_functor)(T, T, T, T, T, T, T, T, T, T); + typedef T (*ff11_functor)(T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff12_functor)(T, T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff13_functor)(T, T, T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff14_functor)(T, T, T, T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff15_functor)(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T); protected: + struct freefunc00 : public exprtk::ifunction + { + using exprtk::ifunction::operator(); + + explicit freefunc00(ff00_functor ff) : exprtk::ifunction(0), f(ff) {} + inline T operator() () + { return f(); } + ff00_functor f; + }; + struct freefunc01 : public exprtk::ifunction { using exprtk::ifunction::operator(); - freefunc01(ff01_functor ff) : exprtk::ifunction(1), f(ff) {} - inline T operator()(const T& v0) + explicit freefunc01(ff01_functor ff) : exprtk::ifunction(1), f(ff) {} + inline T operator() (const T& v0) { return f(v0); } ff01_functor f; }; @@ -15890,9 +16170,9 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc02(ff02_functor ff) : exprtk::ifunction(2), f(ff) {} - inline T operator()(const T& v0, const T& v1) - { return f(v0,v1); } + explicit freefunc02(ff02_functor ff) : exprtk::ifunction(2), f(ff) {} + inline T operator() (const T& v0, const T& v1) + { return f(v0, v1); } ff02_functor f; }; @@ -15900,9 +16180,9 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc03(ff03_functor ff) : exprtk::ifunction(3), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2) - { return f(v0,v1,v2); } + explicit freefunc03(ff03_functor ff) : exprtk::ifunction(3), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2) + { return f(v0, v1, v2); } ff03_functor f; }; @@ -15910,9 +16190,9 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc04(ff04_functor ff) : exprtk::ifunction(4), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3) - { return f(v0,v1,v2,v3); } + explicit freefunc04(ff04_functor ff) : exprtk::ifunction(4), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3) + { return f(v0, v1, v2, v3); } ff04_functor f; }; @@ -15920,9 +16200,9 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc05(ff05_functor ff) : exprtk::ifunction(5), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4) - { return f(v0,v1,v2,v3,v4); } + explicit freefunc05(ff05_functor ff) : exprtk::ifunction(5), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3, const T& v4) + { return f(v0, v1, v2, v3, v4); } ff05_functor f; }; @@ -15930,9 +16210,9 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc06(ff06_functor ff) : exprtk::ifunction(6), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) - { return f(v0,v1,v2,v3,v4,v5); } + explicit freefunc06(ff06_functor ff) : exprtk::ifunction(6), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) + { return f(v0, v1, v2, v3, v4, v5); } ff06_functor f; }; @@ -15940,10 +16220,10 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc07(ff07_functor ff) : exprtk::ifunction(7), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, - const T& v5, const T& v6) - { return f(v0,v1,v2,v3,v4,v5,v6); } + explicit freefunc07(ff07_functor ff) : exprtk::ifunction(7), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, + const T& v5, const T& v6) + { return f(v0, v1, v2, v3, v4, v5, v6); } ff07_functor f; }; @@ -15951,10 +16231,10 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc08(ff08_functor ff) : exprtk::ifunction(8), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, - const T& v5, const T& v6, const T& v7) - { return f(v0,v1,v2,v3,v4,v5,v6,v7); } + explicit freefunc08(ff08_functor ff) : exprtk::ifunction(8), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, + const T& v5, const T& v6, const T& v7) + { return f(v0, v1, v2, v3, v4, v5, v6, v7); } ff08_functor f; }; @@ -15962,10 +16242,10 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc09(ff09_functor ff) : exprtk::ifunction(9), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, - const T& v5, const T& v6, const T& v7, const T& v8) - { return f(v0,v1,v2,v3,v4,v5,v6,v7,v8); } + explicit freefunc09(ff09_functor ff) : exprtk::ifunction(9), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, + const T& v5, const T& v6, const T& v7, const T& v8) + { return f(v0, v1, v2, v3, v4, v5, v6, v7, v8); } ff09_functor f; }; @@ -15973,10 +16253,10 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc10(ff10_functor ff) : exprtk::ifunction(10), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, - const T& v5, const T& v6, const T& v7, const T& v8, const T& v9) - { return f(v0,v1,v2,v3,v4,v5,v6,v7,v8,v9); } + explicit freefunc10(ff10_functor ff) : exprtk::ifunction(10), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, + const T& v5, const T& v6, const T& v7, const T& v8, const T& v9) + { return f(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9); } ff10_functor f; }; @@ -15984,10 +16264,10 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc11(ff11_functor ff) : exprtk::ifunction(11), f(ff) {} - inline T operator()(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, - const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10) - { return f(v0,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10); } + explicit freefunc11(ff11_functor ff) : exprtk::ifunction(11), f(ff) {} + inline T operator() (const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, + const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10) + { return f(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); } ff11_functor f; }; @@ -15995,11 +16275,11 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc12(ff12_functor ff) : exprtk::ifunction(12), f(ff) {} - inline T operator()(const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, - const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, - const T& v10, const T& v11) - { return f(v00,v01,v02,v03,v04,v05,v06,v07,v08,v09,v10,v11); } + explicit freefunc12(ff12_functor ff) : exprtk::ifunction(12), f(ff) {} + inline T operator() (const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, + const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, + const T& v10, const T& v11) + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11); } ff12_functor f; }; @@ -16007,11 +16287,11 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc13(ff13_functor ff) : exprtk::ifunction(13), f(ff) {} - inline T operator()(const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, - const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, - const T& v10, const T& v11, const T& v12) - { return f(v00,v01,v02,v03,v04,v05,v06,v07,v08,v09,v10,v11,v12); } + explicit freefunc13(ff13_functor ff) : exprtk::ifunction(13), f(ff) {} + inline T operator() (const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, + const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, + const T& v10, const T& v11, const T& v12) + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12); } ff13_functor f; }; @@ -16019,11 +16299,11 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc14(ff14_functor ff) : exprtk::ifunction(14), f(ff) {} - inline T operator()(const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, - const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, - const T& v10, const T& v11, const T& v12, const T& v13) - { return f(v00,v01,v02,v03,v04,v05,v06,v07,v08,v09,v10,v11,v12,v13); } + explicit freefunc14(ff14_functor ff) : exprtk::ifunction(14), f(ff) {} + inline T operator() (const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, + const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, + const T& v10, const T& v11, const T& v12, const T& v13) + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13); } ff14_functor f; }; @@ -16031,11 +16311,11 @@ namespace exprtk { using exprtk::ifunction::operator(); - freefunc15(ff15_functor ff) : exprtk::ifunction(15), f(ff) {} - inline T operator()(const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, - const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, - const T& v10, const T& v11, const T& v12, const T& v13, const T& v14) - { return f(v00,v01,v02,v03,v04,v05,v06,v07,v08,v09,v10,v11,v12,v13,v14); } + explicit freefunc15(ff15_functor ff) : exprtk::ifunction(15), f(ff) {} + inline T operator() (const T& v00, const T& v01, const T& v02, const T& v03, const T& v04, + const T& v05, const T& v06, const T& v07, const T& v08, const T& v09, + const T& v10, const T& v11, const T& v12, const T& v13, const T& v14) + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14); } ff15_functor f; }; @@ -16105,7 +16385,7 @@ namespace exprtk return false; else { - tm_const_itr_t itr = map.find(symbol_name); + const tm_const_itr_t itr = map.find(symbol_name); if (map.end() == itr) return false; @@ -16121,14 +16401,14 @@ namespace exprtk { for (std::size_t i = 0; i < details::reserved_symbols_size; ++i) { - if (details::imatch(symbol_name,details::reserved_symbols[i])) + if (details::imatch(symbol_name, details::reserved_symbols[i])) { return false; } } } - tm_itr_t itr = map.find(symbol_name); + const tm_itr_t itr = map.find(symbol_name); if (map.end() == itr) { @@ -16143,7 +16423,7 @@ namespace exprtk { static inline std::pair make(std::pair v, const bool is_const = false) { - return std::make_pair(is_const,new vector_t(v.first,v.second)); + return std::make_pair(is_const, new vector_t(v.first, v.second)); } }; @@ -16152,7 +16432,7 @@ namespace exprtk template static inline std::pair make(std::vector& v, const bool is_const = false) { - return std::make_pair(is_const,new vector_t(v)); + return std::make_pair(is_const, new vector_t(v)); } }; @@ -16160,7 +16440,7 @@ namespace exprtk { static inline std::pair make(exprtk::vector_view& v, const bool is_const = false) { - return std::make_pair(is_const,new vector_t(v)); + return std::make_pair(is_const, new vector_t(v)); } }; @@ -16169,36 +16449,41 @@ namespace exprtk template static inline std::pair make(std::deque& v, const bool is_const = false) { - return std::make_pair(is_const,new vector_t(v)); + return std::make_pair(is_const, new vector_t(v)); } }; template inline bool add(const std::string& symbol_name, T (&v)[v_size], const bool is_const = false) { - return add_impl >(symbol_name,std::make_pair(v,v_size),is_const); + return add_impl > + (symbol_name, std::make_pair(v,v_size), is_const); } inline bool add(const std::string& symbol_name, T* v, const std::size_t v_size, const bool is_const = false) { - return add_impl >(symbol_name,std::make_pair(v,v_size),is_const); + return add_impl > + (symbol_name, std::make_pair(v,v_size), is_const); } template inline bool add(const std::string& symbol_name, std::vector& v, const bool is_const = false) { - return add_impl&>(symbol_name,v,is_const); + return add_impl&> + (symbol_name, v, is_const); } inline bool add(const std::string& symbol_name, exprtk::vector_view& v, const bool is_const = false) { - return add_impl&>(symbol_name,v,is_const); + return add_impl&> + (symbol_name, v, is_const); } template inline bool add(const std::string& symbol_name, std::deque& v, const bool is_const = false) { - return add_impl&>(symbol_name,v,is_const); + return add_impl&> + (symbol_name, v, is_const); } inline bool add(const std::string& symbol_name, RawType& t, const bool is_const = false) @@ -16207,13 +16492,13 @@ namespace exprtk { static inline std::pair make(T& t,const bool is_const = false) { - return std::make_pair(is_const,new variable_node_t(t)); + return std::make_pair(is_const, new variable_node_t(t)); } #ifndef exprtk_disable_string_capabilities static inline std::pair make(std::string& t,const bool is_const = false) { - return std::make_pair(is_const,new stringvar_node_t(t)); + return std::make_pair(is_const, new stringvar_node_t(t)); } #endif @@ -16233,7 +16518,7 @@ namespace exprtk } }; - tm_itr_t itr = map.find(symbol_name); + const tm_itr_t itr = map.find(symbol_name); if (map.end() == itr) { @@ -16246,7 +16531,7 @@ namespace exprtk inline type_ptr get(const std::string& symbol_name) const { - tm_const_itr_t itr = map.find(symbol_name); + const tm_const_itr_t itr = map.find(symbol_name); if (map.end() == itr) return reinterpret_cast(0); @@ -16294,7 +16579,7 @@ namespace exprtk inline bool remove(const std::string& symbol_name, const bool delete_node = true) { - tm_itr_t itr = map.find(symbol_name); + const tm_itr_t itr = map.find(symbol_name); if (map.end() != itr) { @@ -16334,7 +16619,7 @@ namespace exprtk static RawType null_type = init_type::set(RawType()); - tm_const_itr_t itr = map.find(symbol_name); + const tm_const_itr_t itr = map.find(symbol_name); if (map.end() == itr) return null_type; @@ -16359,7 +16644,7 @@ namespace exprtk if (delete_node) { tm_itr_t itr = map.begin(); - tm_itr_t end = map.end(); + tm_itr_t end = map.end (); while (end != itr) { @@ -16383,7 +16668,7 @@ namespace exprtk if (!map.empty()) { tm_const_itr_t itr = map.begin(); - tm_const_itr_t end = map.end(); + tm_const_itr_t end = map.end (); while (end != itr) { @@ -16405,7 +16690,7 @@ namespace exprtk if (!map.empty()) { tm_const_itr_t itr = map.begin(); - tm_const_itr_t end = map.end(); + tm_const_itr_t end = map.end (); while (end != itr) { @@ -16445,11 +16730,12 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities type_store,std::string> stringvar_store; #endif - type_store,ifunction > function_store; + type_store,ifunction > function_store; type_store,ivararg_function > vararg_function_store; type_store,igeneric_function > generic_function_store; type_store,igeneric_function > string_function_store; - type_store vector_store; + type_store,igeneric_function > overload_function_store; + type_store vector_store; st_data() { @@ -16477,6 +16763,17 @@ namespace exprtk return (reserved_symbol_table_.end() != reserved_symbol_table_.find(symbol)); } + static inline st_data* create() + { + return (new st_data); + } + + static inline void destroy(st_data*& sd) + { + delete sd; + sd = reinterpret_cast(0); + } + std::list local_symbol_list_; std::list local_stringvar_list_; std::set reserved_symbol_table_; @@ -16485,10 +16782,10 @@ namespace exprtk control_block() : ref_count(1), - data_(new st_data) + data_(st_data::create()) {} - control_block(st_data* data) + explicit control_block(st_data* data) : ref_count(1), data_(data) {} @@ -16497,14 +16794,13 @@ namespace exprtk { if (data_ && (0 == ref_count)) { - delete data_; - data_ = 0; + st_data::destroy(data_); } } static inline control_block* create() { - return new control_block; + return (new control_block); } template @@ -16560,10 +16856,10 @@ namespace exprtk control_block_->ref_count++; } - return *this; + return (*this); } - inline bool operator==(const symbol_table& st) + inline bool operator==(const symbol_table& st) const { return (this == &st) || (control_block_ == st.control_block_); } @@ -16710,6 +17006,16 @@ namespace exprtk return local_data().string_function_store.get(function_name); } + inline generic_function_ptr get_overload_function(const std::string& function_name) const + { + if (!valid()) + return reinterpret_cast(0); + else if (!valid_symbol(function_name)) + return reinterpret_cast(0); + else + return local_data().overload_function_store.get(function_name); + } + typedef vector_holder_t* vector_holder_ptr; inline vector_holder_ptr get_vector(const std::string& vector_name) const @@ -16875,25 +17181,44 @@ namespace exprtk return false; else if (symbol_exists(function_name)) return false; - else if (std::string::npos != function.parameter_sequence.find_first_not_of("STVZ*?|")) + else if ( + ( + (generic_function_t::e_rtrn_scalar == function.rtrn_type) || + (generic_function_t::e_rtrn_string == function.rtrn_type) + ) && + std::string::npos != function.parameter_sequence.find_first_not_of("STVZ*?|") + ) return false; - else if (generic_function_t::e_rtrn_scalar == function.rtrn_type) - return local_data().generic_function_store.add(function_name,function); - else if (generic_function_t::e_rtrn_string == function.rtrn_type) - return local_data().string_function_store.add(function_name, function); - else + else if ( + (generic_function_t::e_rtrn_overload == function.rtrn_type) && + std::string::npos != function.parameter_sequence.find_first_not_of("STVZ*?|:") + ) return false; + + switch (function.rtrn_type) + { + case generic_function_t::e_rtrn_scalar : + return local_data().generic_function_store.add(function_name,function); + + case generic_function_t::e_rtrn_string : + return local_data().string_function_store.add(function_name,function); + + case generic_function_t::e_rtrn_overload : + return local_data().overload_function_store.add(function_name,function); + } + + return false; } #define exprtk_define_freefunction(NN) \ inline bool add_function(const std::string& function_name, ff##NN##_functor function) \ { \ if (!valid()) \ - return false; \ - else if (!valid_symbol(function_name)) \ - return false; \ - else if (symbol_exists(function_name)) \ - return false; \ + { return false; } \ + if (!valid_symbol(function_name)) \ + { return false; } \ + if (symbol_exists(function_name)) \ + { return false; } \ \ exprtk::ifunction* ifunc = new freefunc##NN(function); \ \ @@ -16902,14 +17227,14 @@ namespace exprtk return add_function(function_name,(*local_data().free_function_list_.back())); \ } \ - exprtk_define_freefunction(01) exprtk_define_freefunction(02) - exprtk_define_freefunction(03) exprtk_define_freefunction(04) - exprtk_define_freefunction(05) exprtk_define_freefunction(06) - exprtk_define_freefunction(07) exprtk_define_freefunction(08) - exprtk_define_freefunction(09) exprtk_define_freefunction(10) - exprtk_define_freefunction(11) exprtk_define_freefunction(12) - exprtk_define_freefunction(13) exprtk_define_freefunction(14) - exprtk_define_freefunction(15) + exprtk_define_freefunction(00) exprtk_define_freefunction(01) + exprtk_define_freefunction(02) exprtk_define_freefunction(03) + exprtk_define_freefunction(04) exprtk_define_freefunction(05) + exprtk_define_freefunction(06) exprtk_define_freefunction(07) + exprtk_define_freefunction(08) exprtk_define_freefunction(09) + exprtk_define_freefunction(10) exprtk_define_freefunction(11) + exprtk_define_freefunction(12) exprtk_define_freefunction(13) + exprtk_define_freefunction(14) exprtk_define_freefunction(15) #undef exprtk_define_freefunction @@ -16945,14 +17270,33 @@ namespace exprtk return false; else if (symbol_exists(function_name,false)) return false; - else if (std::string::npos != function.parameter_sequence.find_first_not_of("STV*?|")) + else if ( + ( + (generic_function_t::e_rtrn_scalar == function.rtrn_type) || + (generic_function_t::e_rtrn_string == function.rtrn_type) + ) && + std::string::npos != function.parameter_sequence.find_first_not_of("STV*?|") + ) return false; - else if (generic_function_t::e_rtrn_scalar == function.rtrn_type) - return local_data().generic_function_store.add(function_name,function); - else if (generic_function_t::e_rtrn_string == function.rtrn_type) - return local_data().string_function_store.add(function_name, function); - else + else if ( + generic_function_t::e_rtrn_overload && + std::string::npos != function.parameter_sequence.find_first_not_of("STV*?|:") + ) return false; + + switch (function.rtrn_type) + { + case generic_function_t::e_rtrn_scalar : + return local_data().generic_function_store.add(function_name,function); + + case generic_function_t::e_rtrn_string : + return local_data().string_function_store.add(function_name,function); + + case generic_function_t::e_rtrn_overload : + return local_data().overload_function_store.add(function_name,function); + } + + return false; } template @@ -16976,6 +17320,8 @@ namespace exprtk return false; else if (symbol_exists(vector_name)) return false; + else if (0 == v_size) + return false; else return local_data().vector_store.add(vector_name,v,v_size); } @@ -16989,6 +17335,8 @@ namespace exprtk return false; else if (symbol_exists(vector_name)) return false; + else if (0 == v.size()) + return false; else return local_data().vector_store.add(vector_name,v); } @@ -17001,6 +17349,8 @@ namespace exprtk return false; else if (symbol_exists(vector_name)) return false; + else if (0 == v.size()) + return false; else return local_data().vector_store.add(vector_name,v); } @@ -17051,12 +17401,13 @@ namespace exprtk { return add_pi () && add_epsilon () && - add_infinity(); + add_infinity() ; } inline bool add_pi() { - static const T local_pi = T(details::numeric::constant::pi); + const typename details::numeric::details::number_type::type num_type; + static const T local_pi = details::numeric::details::const_pi_impl(num_type); return add_constant("pi",local_pi); } @@ -17134,8 +17485,8 @@ namespace exprtk { /* Function will return true if symbol_name exists as either a - reserved symbol, variable, stringvar or function name in any - of the type stores. + reserved symbol, variable, stringvar, vector or function name + in any of the type stores. */ if (!valid()) return false; @@ -17145,6 +17496,8 @@ namespace exprtk else if (local_data().stringvar_store.symbol_exists(symbol_name)) return true; #endif + else if (local_data().vector_store.symbol_exists(symbol_name)) + return true; else if (local_data().function_store.symbol_exists(symbol_name)) return true; else if (check_reserved_symb && local_data().is_reserved_symbol(symbol_name)) @@ -17299,6 +17652,21 @@ namespace exprtk } } } + + { + std::vector name_list; + + st.local_data().overload_function_store.get_list(name_list); + + if (!name_list.empty()) + { + for (std::size_t i = 0; i < name_list.size(); ++i) + { + exprtk::igeneric_function& ifunc = *st.get_overload_function(name_list[i]); + add_function(name_list[i],ifunc); + } + } + } } private: @@ -17404,7 +17772,7 @@ namespace exprtk size(0) {} - data_pack(void* ptr, data_type dt, std::size_t sz = 0) + data_pack(void* ptr, const data_type dt, const std::size_t sz = 0) : pointer(ptr), type(dt), size(sz) @@ -17426,7 +17794,7 @@ namespace exprtk return_invoked(&retinv_null) {} - control_block(expression_ptr e) + explicit control_block(expression_ptr e) : ref_count(1), expr (e), results (0), @@ -17438,8 +17806,7 @@ namespace exprtk { if (expr && details::branch_deletable(expr)) { - delete expr; - expr = reinterpret_cast(0); + destroy_node(expr); } if (!local_data_list.empty()) @@ -17514,12 +17881,19 @@ namespace exprtk } expression(const expression& e) - : control_block_(e.control_block_), + : control_block_ (e.control_block_ ), symbol_table_list_(e.symbol_table_list_) { control_block_->ref_count++; } + explicit expression(const symbol_table& symbol_table) + : control_block_(0) + { + set_expression(new details::null_node()); + symbol_table_list_.push_back(symbol_table); + } + inline expression& operator=(const expression& e) { if (this != &e) @@ -17545,7 +17919,7 @@ namespace exprtk return *this; } - inline bool operator==(const expression& e) + inline bool operator==(const expression& e) const { return (this == &e); } @@ -17562,7 +17936,7 @@ namespace exprtk { control_block::destroy(control_block_); - return *this; + return (*this); } ~expression() @@ -17575,7 +17949,7 @@ namespace exprtk return control_block_->expr->value(); } - inline T operator()() const + inline T operator() () const { return value(); } @@ -17694,7 +18068,7 @@ namespace exprtk control_block_-> local_data_list.push_back( typename expression::control_block:: - data_pack(reinterpret_cast(data),dt,size)); + data_pack(reinterpret_cast(data), dt, size)); } } } @@ -17802,27 +18176,35 @@ namespace exprtk lexer::token token; error_mode mode; std::string diagnostic; + std::string src_location; std::string error_line; std::size_t line_no; std::size_t column_no; }; - inline type make_error(error_mode mode, const std::string& diagnostic = "") + inline type make_error(const error_mode mode, + const std::string& diagnostic = "", + const std::string& src_location = "") { type t; - t.mode = mode; - t.token.type = lexer::token::e_error; - t.diagnostic = diagnostic; + t.mode = mode; + t.token.type = lexer::token::e_error; + t.diagnostic = diagnostic; + t.src_location = src_location; exprtk_debug(("%s\n",diagnostic .c_str())); return t; } - inline type make_error(error_mode mode, const lexer::token& tk, const std::string& diagnostic = "") + inline type make_error(const error_mode mode, + const lexer::token& tk, + const std::string& diagnostic = "", + const std::string& src_location = "") { type t; t.mode = mode; t.token = tk; t.diagnostic = diagnostic; + t.src_location = src_location; exprtk_debug(("%s\n",diagnostic .c_str())); return t; } @@ -17979,15 +18361,16 @@ namespace exprtk typedef details::scor_node scor_node_t; typedef lexer::token token_t; typedef expression_node_t* expression_node_ptr; + typedef expression expression_t; typedef symbol_table symbol_table_t; typedef typename expression::symtab_list_t symbol_table_list_t; typedef details::vector_holder* vector_holder_ptr; - typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; + typedef typename details::functor_t functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; typedef details::operator_type operator_t; @@ -18002,28 +18385,28 @@ namespace exprtk typedef std::multimap base_ops_map_t; typedef std::set disabled_func_set_t; - typedef details::T0oT1_define vov_t; - typedef details::T0oT1_define cov_t; - typedef details::T0oT1_define voc_t; - - typedef details::T0oT1oT2_define vovov_t; - typedef details::T0oT1oT2_define vovoc_t; - typedef details::T0oT1oT2_define vocov_t; - typedef details::T0oT1oT2_define covov_t; - typedef details::T0oT1oT2_define covoc_t; - typedef details::T0oT1oT2_define cocov_t; - typedef details::T0oT1oT2_define vococ_t; - - typedef details::T0oT1oT2oT3_define vovovov_t; - typedef details::T0oT1oT2oT3_define vovovoc_t; - typedef details::T0oT1oT2oT3_define vovocov_t; - typedef details::T0oT1oT2oT3_define vocovov_t; - typedef details::T0oT1oT2oT3_define covovov_t; - - typedef details::T0oT1oT2oT3_define covocov_t; - typedef details::T0oT1oT2oT3_define vocovoc_t; - typedef details::T0oT1oT2oT3_define covovoc_t; - typedef details::T0oT1oT2oT3_define vococov_t; + typedef details::T0oT1_define vov_t; + typedef details::T0oT1_define cov_t; + typedef details::T0oT1_define voc_t; + + typedef details::T0oT1oT2_define vovov_t; + typedef details::T0oT1oT2_define vovoc_t; + typedef details::T0oT1oT2_define vocov_t; + typedef details::T0oT1oT2_define covov_t; + typedef details::T0oT1oT2_define covoc_t; + typedef details::T0oT1oT2_define cocov_t; + typedef details::T0oT1oT2_define vococ_t; + + typedef details::T0oT1oT2oT3_define vovovov_t; + typedef details::T0oT1oT2oT3_define vovovoc_t; + typedef details::T0oT1oT2oT3_define vovocov_t; + typedef details::T0oT1oT2oT3_define vocovov_t; + typedef details::T0oT1oT2oT3_define covovov_t; + + typedef details::T0oT1oT2oT3_define covocov_t; + typedef details::T0oT1oT2oT3_define vocovoc_t; + typedef details::T0oT1oT2oT3_define covovoc_t; + typedef details::T0oT1oT2oT3_define vococov_t; typedef results_context results_context_t; @@ -18125,7 +18508,7 @@ namespace exprtk typedef variable_node_t* variable_node_ptr; typedef parser parser_t; - scope_element_manager(parser& p) + explicit scope_element_manager(parser& p) : parser_(p), input_param_cnt_(0) {} @@ -18160,7 +18543,7 @@ namespace exprtk if (se.depth > current_depth) continue; else if ( - (se.name == var_name) && + details::imatch(se.name, var_name) && (se.index == index) ) return se; @@ -18181,8 +18564,8 @@ namespace exprtk if (se.depth > current_depth) continue; else if ( - (se.name == var_name) && - (se.index == index) && + details::imatch(se.name, var_name) && + (se.index == index) && (se.active) ) return se; @@ -18198,11 +18581,11 @@ namespace exprtk scope_element& cse = element_[i]; if ( - (cse.name == se.name ) && - (cse.depth <= se.depth) && - (cse.index == se.index) && - (cse.size == se.size ) && - (cse.type == se.type ) && + details::imatch(cse.name, se.name) && + (cse.depth <= se.depth) && + (cse.index == se.index) && + (cse.size == se.size ) && + (cse.type == se.type ) && (cse.active) ) return false; @@ -18236,6 +18619,10 @@ namespace exprtk inline void free_element(scope_element& se) { + #ifdef exprtk_enable_debugging + exprtk_debug(("free_element() - se[%s]\n", se.name.c_str())); + #endif + switch (se.type) { case scope_element::e_variable : if (se.data ) delete (T*) se.data; @@ -18288,7 +18675,7 @@ namespace exprtk se.active && se.var_node && details::is_variable_node(se.var_node) - ) + ) { variable_node_ptr vn = reinterpret_cast(se.var_node); @@ -18318,12 +18705,12 @@ namespace exprtk typedef parser parser_t; - scope_handler(parser& p) + explicit scope_handler(parser& p) : parser_(p) { parser_.state_.scope_depth++; #ifdef exprtk_enable_debugging - std::string depth(2 * parser_.state_.scope_depth,'-'); + const std::string depth(2 * parser_.state_.scope_depth,'-'); exprtk_debug(("%s> Scope Depth: %02d\n", depth.c_str(), static_cast(parser_.state_.scope_depth))); @@ -18335,7 +18722,7 @@ namespace exprtk parser_.sem_.deactivate(parser_.state_.scope_depth); parser_.state_.scope_depth--; #ifdef exprtk_enable_debugging - std::string depth(2 * parser_.state_.scope_depth,'-'); + const std::string depth(2 * parser_.state_.scope_depth,'-'); exprtk_debug(("<%s Scope Depth: %02d\n", depth.c_str(), static_cast(parser_.state_.scope_depth))); @@ -18549,6 +18936,27 @@ namespace exprtk return result; } + inline generic_function_ptr get_overload_function(const std::string& function_name) const + { + if (!valid_function_name(function_name)) + return reinterpret_cast(0); + + generic_function_ptr result = reinterpret_cast(0); + + for (std::size_t i = 0; i < symtab_list_.size(); ++i) + { + if (!symtab_list_[i].valid()) + continue; + else + result = + local_data(i).overload_function_store.get(function_name); + + if (result) break; + } + + return result; + } + inline vector_holder_ptr get_vector(const std::string& vector_name) const { if (!valid_symbol(vector_name)) @@ -18807,8 +19215,9 @@ namespace exprtk enum usr_symbol_type { - e_usr_variable_type = 0, - e_usr_constant_type = 1 + e_usr_unknown_type = 0, + e_usr_variable_type = 1, + e_usr_constant_type = 2 }; enum usr_mode @@ -18887,7 +19296,7 @@ namespace exprtk {} template class Sequence> + template class Sequence> inline std::size_t symbols(Sequence& symbols_list) { if (!collect_variables_ && !collect_functions_) @@ -18897,23 +19306,20 @@ namespace exprtk for (std::size_t i = 0; i < symbol_name_list_.size(); ++i) { - std::string& s = symbol_name_list_[i].first; - #ifndef MODIFICATION - std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); - #endif + details::case_normalise(symbol_name_list_[i].first); } std::sort(symbol_name_list_.begin(),symbol_name_list_.end()); std::unique_copy(symbol_name_list_.begin(), - symbol_name_list_.end(), + symbol_name_list_.end (), std::back_inserter(symbols_list)); return symbols_list.size(); } template class Sequence> + template class Sequence> inline std::size_t assignment_symbols(Sequence& assignment_list) { if (!collect_assignments_) @@ -18923,16 +19329,13 @@ namespace exprtk for (std::size_t i = 0; i < assignment_name_list_.size(); ++i) { - std::string& s = assignment_name_list_[i].first; - #ifndef MODIFICATION - std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); - #endif + details::case_normalise(assignment_name_list_[i].first); } std::sort(assignment_name_list_.begin(),assignment_name_list_.end()); std::unique_copy(assignment_name_list_.begin(), - assignment_name_list_.end(), + assignment_name_list_.end (), std::back_inserter(assignment_list)); return assignment_list.size(); @@ -18991,11 +19394,13 @@ namespace exprtk case e_st_local_variable : case e_st_local_vector : case e_st_local_string : if (collect_variables_) - symbol_name_list_.push_back(std::make_pair(symbol,st)); + symbol_name_list_ + .push_back(std::make_pair(symbol, st)); break; case e_st_function : if (collect_functions_) - symbol_name_list_.push_back(std::make_pair(symbol,st)); + symbol_name_list_ + .push_back(std::make_pair(symbol, st)); break; default : return; @@ -19008,10 +19413,10 @@ namespace exprtk { case e_st_variable : case e_st_vector : - case e_st_string : - if (collect_assignments_) - assignment_name_list_.push_back(std::make_pair(symbol,st)); - break; + case e_st_string : if (collect_assignments_) + assignment_name_list_ + .push_back(std::make_pair(symbol, st)); + break; default : return; } @@ -19134,43 +19539,43 @@ namespace exprtk settings_store& enable_all_base_functions() { disabled_func_set_.clear(); - return *this; + return (*this); } settings_store& enable_all_control_structures() { disabled_ctrl_set_.clear(); - return *this; + return (*this); } settings_store& enable_all_logic_ops() { disabled_logic_set_.clear(); - return *this; + return (*this); } settings_store& enable_all_arithmetic_ops() { disabled_arithmetic_set_.clear(); - return *this; + return (*this); } settings_store& enable_all_assignment_ops() { disabled_assignment_set_.clear(); - return *this; + return (*this); } settings_store& enable_all_inequality_ops() { disabled_inequality_set_.clear(); - return *this; + return (*this); } settings_store& enable_local_vardef() { disable_vardef_ = false; - return *this; + return (*this); } settings_store& disable_all_base_functions() @@ -19178,8 +19583,8 @@ namespace exprtk std::copy(details::base_function_list, details::base_function_list + details::base_function_list_size, std::insert_iterator - (disabled_func_set_,disabled_func_set_.begin())); - return *this; + (disabled_func_set_, disabled_func_set_.begin())); + return (*this); } settings_store& disable_all_control_structures() @@ -19187,8 +19592,8 @@ namespace exprtk std::copy(details::cntrl_struct_list, details::cntrl_struct_list + details::cntrl_struct_list_size, std::insert_iterator - (disabled_ctrl_set_,disabled_ctrl_set_.begin())); - return *this; + (disabled_ctrl_set_, disabled_ctrl_set_.begin())); + return (*this); } settings_store& disable_all_logic_ops() @@ -19196,8 +19601,8 @@ namespace exprtk std::copy(details::logic_ops_list, details::logic_ops_list + details::logic_ops_list_size, std::insert_iterator - (disabled_logic_set_,disabled_logic_set_.begin())); - return *this; + (disabled_logic_set_, disabled_logic_set_.begin())); + return (*this); } settings_store& disable_all_arithmetic_ops() @@ -19205,8 +19610,8 @@ namespace exprtk std::copy(details::arithmetic_ops_list, details::arithmetic_ops_list + details::arithmetic_ops_list_size, std::insert_iterator - (disabled_arithmetic_set_,disabled_arithmetic_set_.begin())); - return *this; + (disabled_arithmetic_set_, disabled_arithmetic_set_.begin())); + return (*this); } settings_store& disable_all_assignment_ops() @@ -19214,8 +19619,8 @@ namespace exprtk std::copy(details::assignment_ops_list, details::assignment_ops_list + details::assignment_ops_list_size, std::insert_iterator - (disabled_assignment_set_,disabled_assignment_set_.begin())); - return *this; + (disabled_assignment_set_, disabled_assignment_set_.begin())); + return (*this); } settings_store& disable_all_inequality_ops() @@ -19223,14 +19628,14 @@ namespace exprtk std::copy(details::inequality_ops_list, details::inequality_ops_list + details::inequality_ops_list_size, std::insert_iterator - (disabled_inequality_set_,disabled_inequality_set_.begin())); - return *this; + (disabled_inequality_set_, disabled_inequality_set_.begin())); + return (*this); } settings_store& disable_local_vardef() { disable_vardef_ = true; - return *this; + return (*this); } bool replacer_enabled () const { return enable_replacer_; } @@ -19247,7 +19652,7 @@ namespace exprtk bool rsrvd_sym_usr_disabled () const { return disable_rsrvd_sym_usr_; } bool zero_return_disabled () const { return disable_zero_return_; } - bool function_enabled(const std::string& function_name) + bool function_enabled(const std::string& function_name) const { if (disabled_func_set_.empty()) return true; @@ -19255,7 +19660,7 @@ namespace exprtk return (disabled_func_set_.end() == disabled_func_set_.find(function_name)); } - bool control_struct_enabled(const std::string& control_struct) + bool control_struct_enabled(const std::string& control_struct) const { if (disabled_ctrl_set_.empty()) return true; @@ -19263,7 +19668,7 @@ namespace exprtk return (disabled_ctrl_set_.end() == disabled_ctrl_set_.find(control_struct)); } - bool logic_enabled(const std::string& logic_operation) + bool logic_enabled(const std::string& logic_operation) const { if (disabled_logic_set_.empty()) return true; @@ -19271,31 +19676,34 @@ namespace exprtk return (disabled_logic_set_.end() == disabled_logic_set_.find(logic_operation)); } - bool arithmetic_enabled(const details::operator_type& arithmetic_operation) + bool arithmetic_enabled(const details::operator_type& arithmetic_operation) const { if (disabled_logic_set_.empty()) return true; else - return (disabled_arithmetic_set_.end() == disabled_arithmetic_set_.find(arith_opr_to_string(arithmetic_operation))); + return disabled_arithmetic_set_.end() == disabled_arithmetic_set_ + .find(arith_opr_to_string(arithmetic_operation)); } - bool assignment_enabled(const details::operator_type& assignment) + bool assignment_enabled(const details::operator_type& assignment) const { if (disabled_assignment_set_.empty()) return true; else - return (disabled_assignment_set_.end() == disabled_assignment_set_.find(assign_opr_to_string(assignment))); + return disabled_assignment_set_.end() == disabled_assignment_set_ + .find(assign_opr_to_string(assignment)); } - bool inequality_enabled(const details::operator_type& inequality) + bool inequality_enabled(const details::operator_type& inequality) const { if (disabled_inequality_set_.empty()) return true; else - return (disabled_inequality_set_.end() == disabled_inequality_set_.find(inequality_opr_to_string(inequality))); + return disabled_inequality_set_.end() == disabled_inequality_set_ + .find(inequality_opr_to_string(inequality)); } - bool function_disabled(const std::string& function_name) + bool function_disabled(const std::string& function_name) const { if (disabled_func_set_.empty()) return false; @@ -19303,7 +19711,7 @@ namespace exprtk return (disabled_func_set_.end() != disabled_func_set_.find(function_name)); } - bool control_struct_disabled(const std::string& control_struct) + bool control_struct_disabled(const std::string& control_struct) const { if (disabled_ctrl_set_.empty()) return false; @@ -19311,7 +19719,7 @@ namespace exprtk return (disabled_ctrl_set_.end() != disabled_ctrl_set_.find(control_struct)); } - bool logic_disabled(const std::string& logic_operation) + bool logic_disabled(const std::string& logic_operation) const { if (disabled_logic_set_.empty()) return false; @@ -19319,28 +19727,31 @@ namespace exprtk return (disabled_logic_set_.end() != disabled_logic_set_.find(logic_operation)); } - bool assignment_disabled(const details::operator_type assignment_operation) + bool assignment_disabled(const details::operator_type assignment_operation) const { if (disabled_assignment_set_.empty()) return false; else - return (disabled_assignment_set_.end() != disabled_assignment_set_.find(assign_opr_to_string(assignment_operation))); + return disabled_assignment_set_.end() != disabled_assignment_set_ + .find(assign_opr_to_string(assignment_operation)); } - bool arithmetic_disabled(const details::operator_type arithmetic_operation) + bool arithmetic_disabled(const details::operator_type arithmetic_operation) const { if (disabled_arithmetic_set_.empty()) return false; else - return (disabled_arithmetic_set_.end() != disabled_arithmetic_set_.find(arith_opr_to_string(arithmetic_operation))); + return disabled_arithmetic_set_.end() != disabled_arithmetic_set_ + .find(arith_opr_to_string(arithmetic_operation)); } - bool inequality_disabled(const details::operator_type& inequality) + bool inequality_disabled(const details::operator_type& inequality) const { if (disabled_inequality_set_.empty()) return false; else - return (disabled_inequality_set_.end() != disabled_inequality_set_.find(inequality_opr_to_string(inequality))); + return disabled_inequality_set_.end() != disabled_inequality_set_ + .find(inequality_opr_to_string(inequality)); } settings_store& disable_base_function(settings_base_funcs bf) @@ -19353,7 +19764,7 @@ namespace exprtk disabled_func_set_.insert(details::base_function_list[bf - 1]); } - return *this; + return (*this); } settings_store& disable_control_structure(settings_control_structs ctrl_struct) @@ -19366,7 +19777,7 @@ namespace exprtk disabled_ctrl_set_.insert(details::cntrl_struct_list[ctrl_struct - 1]); } - return *this; + return (*this); } settings_store& disable_logic_operation(settings_logic_opr logic) @@ -19379,7 +19790,7 @@ namespace exprtk disabled_logic_set_.insert(details::logic_ops_list[logic - 1]); } - return *this; + return (*this); } settings_store& disable_arithmetic_operation(settings_arithmetic_opr arithmetic) @@ -19392,7 +19803,7 @@ namespace exprtk disabled_arithmetic_set_.insert(details::arithmetic_ops_list[arithmetic - 1]); } - return *this; + return (*this); } settings_store& disable_assignment_operation(settings_assignment_opr assignment) @@ -19405,7 +19816,7 @@ namespace exprtk disabled_assignment_set_.insert(details::assignment_ops_list[assignment - 1]); } - return *this; + return (*this); } settings_store& disable_inequality_operation(settings_inequality_opr inequality) @@ -19418,7 +19829,7 @@ namespace exprtk disabled_inequality_set_.insert(details::inequality_ops_list[inequality - 1]); } - return *this; + return (*this); } settings_store& enable_base_function(settings_base_funcs bf) @@ -19428,7 +19839,7 @@ namespace exprtk (static_cast(bf) < (details::base_function_list_size + 1)) ) { - des_itr_t itr = disabled_func_set_.find(details::base_function_list[bf - 1]); + const des_itr_t itr = disabled_func_set_.find(details::base_function_list[bf - 1]); if (disabled_func_set_.end() != itr) { @@ -19436,7 +19847,7 @@ namespace exprtk } } - return *this; + return (*this); } settings_store& enable_control_structure(settings_control_structs ctrl_struct) @@ -19446,7 +19857,7 @@ namespace exprtk (static_cast(ctrl_struct) < (details::cntrl_struct_list_size + 1)) ) { - des_itr_t itr = disabled_ctrl_set_.find(details::cntrl_struct_list[ctrl_struct - 1]); + const des_itr_t itr = disabled_ctrl_set_.find(details::cntrl_struct_list[ctrl_struct - 1]); if (disabled_ctrl_set_.end() != itr) { @@ -19454,7 +19865,7 @@ namespace exprtk } } - return *this; + return (*this); } settings_store& enable_logic_operation(settings_logic_opr logic) @@ -19464,7 +19875,7 @@ namespace exprtk (static_cast(logic) < (details::logic_ops_list_size + 1)) ) { - des_itr_t itr = disabled_logic_set_.find(details::logic_ops_list[logic - 1]); + const des_itr_t itr = disabled_logic_set_.find(details::logic_ops_list[logic - 1]); if (disabled_logic_set_.end() != itr) { @@ -19472,7 +19883,7 @@ namespace exprtk } } - return *this; + return (*this); } settings_store& enable_arithmetic_operation(settings_arithmetic_opr arithmetic) @@ -19482,7 +19893,7 @@ namespace exprtk (static_cast(arithmetic) < (details::arithmetic_ops_list_size + 1)) ) { - des_itr_t itr = disabled_arithmetic_set_.find(details::arithmetic_ops_list[arithmetic - 1]); + const des_itr_t itr = disabled_arithmetic_set_.find(details::arithmetic_ops_list[arithmetic - 1]); if (disabled_arithmetic_set_.end() != itr) { @@ -19490,7 +19901,7 @@ namespace exprtk } } - return *this; + return (*this); } settings_store& enable_assignment_operation(settings_assignment_opr assignment) @@ -19500,7 +19911,7 @@ namespace exprtk (static_cast(assignment) < (details::assignment_ops_list_size + 1)) ) { - des_itr_t itr = disabled_assignment_set_.find(details::assignment_ops_list[assignment - 1]); + const des_itr_t itr = disabled_assignment_set_.find(details::assignment_ops_list[assignment - 1]); if (disabled_assignment_set_.end() != itr) { @@ -19508,7 +19919,7 @@ namespace exprtk } } - return *this; + return (*this); } settings_store& enable_inequality_operation(settings_inequality_opr inequality) @@ -19518,7 +19929,7 @@ namespace exprtk (static_cast(inequality) < (details::inequality_ops_list_size + 1)) ) { - des_itr_t itr = disabled_inequality_set_.find(details::inequality_ops_list[inequality - 1]); + const des_itr_t itr = disabled_inequality_set_.find(details::inequality_ops_list[inequality - 1]); if (disabled_inequality_set_.end() != itr) { @@ -19526,7 +19937,7 @@ namespace exprtk } } - return *this; + return (*this); } private: @@ -19548,7 +19959,7 @@ namespace exprtk disable_zero_return_ = (compile_options & e_disable_zero_return ) == e_disable_zero_return; } - std::string assign_opr_to_string(details::operator_type opr) + std::string assign_opr_to_string(details::operator_type opr) const { switch (opr) { @@ -19562,7 +19973,7 @@ namespace exprtk } } - std::string arith_opr_to_string(details::operator_type opr) + std::string arith_opr_to_string(details::operator_type opr) const { switch (opr) { @@ -19575,7 +19986,7 @@ namespace exprtk } } - std::string inequality_opr_to_string(details::operator_type opr) + std::string inequality_opr_to_string(details::operator_type opr) const { switch (opr) { @@ -19713,7 +20124,8 @@ namespace exprtk if (settings_.sequence_check_enabled()) { - helper_assembly_.register_scanner(&sequence_validator_); + helper_assembly_.register_scanner(&sequence_validator_ ); + helper_assembly_.register_scanner(&sequence_validator_3tkns_); } } } @@ -19734,7 +20146,8 @@ namespace exprtk { set_error( make_error(parser_error::e_syntax, - "ERR000 - Empty expression!")); + "ERR000 - Empty expression!", + exprtk_error_location)); return false; } @@ -19749,7 +20162,8 @@ namespace exprtk { set_error( make_error(parser_error::e_syntax, - "ERR001 - Empty expression!")); + "ERR001 - Empty expression!", + exprtk_error_location)); return false; } @@ -19777,7 +20191,7 @@ namespace exprtk dec_.return_present_ = true; e = expression_generator_ - .return_envelope(e,results_context_,retinvk_ptr); + .return_envelope(e, results_context_, retinvk_ptr); } expr.set_expression(e); @@ -19795,22 +20209,34 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR002 - Invalid expression encountered")); + "ERR002 - Invalid expression encountered", + exprtk_error_location)); } - dec_.clear (); - sem_.cleanup (); - return_cleanup(); - if ((0 != e) && branch_deletable(e)) { - delete e; + destroy_node(e); } + dec_.clear (); + sem_.cleanup (); + return_cleanup(); + return false; } } + inline expression_t compile(const std::string& expression_string, symbol_table_t& symtab) + { + expression_t expr; + + expr.register_symbol_table(symtab); + + compile(expression_string,expr); + + return expr; + } + void process_lexer_errors() { for (std::size_t i = 0; i < lexer().size(); ++i) @@ -19842,7 +20268,8 @@ namespace exprtk set_error( make_error(parser_error::e_lexer, lexer()[i], - diagnostic + ": " + lexer()[i].value)); + diagnostic + ": " + lexer()[i].value, + exprtk_error_location)); } } } @@ -19874,16 +20301,18 @@ namespace exprtk { if (helper_assembly_.error_token_scanner) { - lexer::helper::bracket_checker* bracket_checker_ptr = 0; - lexer::helper::numeric_checker* numeric_checker_ptr = 0; - lexer::helper::sequence_validator* sequence_validator_ptr = 0; + lexer::helper::bracket_checker* bracket_checker_ptr = 0; + lexer::helper::numeric_checker* numeric_checker_ptr = 0; + lexer::helper::sequence_validator* sequence_validator_ptr = 0; + lexer::helper::sequence_validator_3tokens* sequence_validator3_ptr = 0; if (0 != (bracket_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) { set_error( make_error(parser_error::e_token, bracket_checker_ptr->error_token(), - "ERR004 - Mismatched brackets: '" + bracket_checker_ptr->error_token().value + "'")); + "ERR004 - Mismatched brackets: '" + bracket_checker_ptr->error_token().value + "'", + exprtk_error_location)); } else if (0 != (numeric_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) { @@ -19894,7 +20323,8 @@ namespace exprtk set_error( make_error(parser_error::e_token, error_token, - "ERR005 - Invalid numeric token: '" + error_token.value + "'")); + "ERR005 - Invalid numeric token: '" + error_token.value + "'", + exprtk_error_location)); } if (numeric_checker_ptr->error_count()) @@ -19913,7 +20343,8 @@ namespace exprtk error_token.first, "ERR006 - Invalid token sequence: '" + error_token.first.value + "' and '" + - error_token.second.value + "'")); + error_token.second.value + "'", + exprtk_error_location)); } if (sequence_validator_ptr->error_count()) @@ -19921,6 +20352,26 @@ namespace exprtk sequence_validator_ptr->clear_errors(); } } + else if (0 != (sequence_validator3_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) + { + for (std::size_t i = 0; i < sequence_validator3_ptr->error_count(); ++i) + { + std::pair error_token = sequence_validator3_ptr->error(i); + + set_error( + make_error(parser_error::e_token, + error_token.first, + "ERR007 - Invalid token sequence: '" + + error_token.first.value + "' and '" + + error_token.second.value + "'", + exprtk_error_location)); + } + + if (sequence_validator3_ptr->error_count()) + { + sequence_validator3_ptr->clear_errors(); + } + } } return false; @@ -19935,7 +20386,7 @@ namespace exprtk return settings_; } - inline parser_error::type get_error(const std::size_t& index) + inline parser_error::type get_error(const std::size_t& index) const { if (index < error_list_.size()) return error_list_[index]; @@ -20006,7 +20457,7 @@ namespace exprtk private: - inline bool valid_base_operation(const std::string& symbol) + inline bool valid_base_operation(const std::string& symbol) const { const std::size_t length = symbol.size(); @@ -20020,7 +20471,7 @@ namespace exprtk (base_ops_map_.end() != base_ops_map_.find(symbol)); } - inline bool valid_vararg_operation(const std::string& symbol) + inline bool valid_vararg_operation(const std::string& symbol) const { static const std::string s_sum = "sum" ; static const std::string s_mul = "mul" ; @@ -20047,17 +20498,17 @@ namespace exprtk settings_.function_enabled(symbol); } - bool is_invalid_arithmetic_operation(const details::operator_type operation) + bool is_invalid_arithmetic_operation(const details::operator_type operation) const { return settings_.arithmetic_disabled(operation); } - bool is_invalid_assignment_operation(const details::operator_type operation) + bool is_invalid_assignment_operation(const details::operator_type operation) const { return settings_.assignment_disabled(operation); } - bool is_invalid_inequality_operation(const details::operator_type operation) + bool is_invalid_inequality_operation(const details::operator_type operation) const { return settings_.inequality_disabled(operation); } @@ -20065,9 +20516,9 @@ namespace exprtk #ifdef exprtk_enable_debugging inline void next_token() { - std::string ct_str = current_token().value; + const std::string ct_str = current_token().value; parser_helper::next_token(); - std::string depth(2 * state_.scope_depth,' '); + const std::string depth(2 * state_.scope_depth,' '); exprtk_debug(("%s" "prev[%s] --> curr[%s]\n", depth.c_str(), @@ -20081,9 +20532,7 @@ namespace exprtk std::vector arg_list; std::vector side_effect_list; - expression_node_ptr result = error_node(); - - scoped_vec_delete sdd(*this,arg_list); + scoped_vec_delete sdd((*this),arg_list); lexer::token begin_token; lexer::token end_token; @@ -20103,7 +20552,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR007 - Invalid expression encountered")); + "ERR008 - Invalid expression encountered", + exprtk_error_location)); } return error_node(); @@ -20116,7 +20566,7 @@ namespace exprtk end_token = current_token(); - std::string sub_expr = construct_subexpr(begin_token,end_token); + const std::string sub_expr = construct_subexpr(begin_token, end_token); exprtk_debug(("parse_corpus(%02d) Subexpr: %s\n", static_cast(arg_list.size() - 1), @@ -20148,7 +20598,7 @@ namespace exprtk dec_.final_stmt_return_ = true; } - result = simplify(arg_list,side_effect_list); + const expression_node_ptr result = simplify(arg_list,side_effect_list); sdd.delete_ptr = (0 == result); @@ -20211,25 +20661,25 @@ namespace exprtk switch (current_token().type) { - case token_t::e_assign : current_state.set(e_level00,e_level00,details::e_assign); break; - case token_t::e_addass : current_state.set(e_level00,e_level00,details::e_addass); break; - case token_t::e_subass : current_state.set(e_level00,e_level00,details::e_subass); break; - case token_t::e_mulass : current_state.set(e_level00,e_level00,details::e_mulass); break; - case token_t::e_divass : current_state.set(e_level00,e_level00,details::e_divass); break; - case token_t::e_modass : current_state.set(e_level00,e_level00,details::e_modass); break; - case token_t::e_swap : current_state.set(e_level00,e_level00,details::e_swap ); break; - case token_t::e_lt : current_state.set(e_level05,e_level06,details:: e_lt); break; - case token_t::e_lte : current_state.set(e_level05,e_level06,details:: e_lte); break; - case token_t::e_eq : current_state.set(e_level05,e_level06,details:: e_eq); break; - case token_t::e_ne : current_state.set(e_level05,e_level06,details:: e_ne); break; - case token_t::e_gte : current_state.set(e_level05,e_level06,details:: e_gte); break; - case token_t::e_gt : current_state.set(e_level05,e_level06,details:: e_gt); break; - case token_t::e_add : current_state.set(e_level07,e_level08,details:: e_add); break; - case token_t::e_sub : current_state.set(e_level07,e_level08,details:: e_sub); break; - case token_t::e_div : current_state.set(e_level10,e_level11,details:: e_div); break; - case token_t::e_mul : current_state.set(e_level10,e_level11,details:: e_mul); break; - case token_t::e_mod : current_state.set(e_level10,e_level11,details:: e_mod); break; - case token_t::e_pow : current_state.set(e_level12,e_level12,details:: e_pow); break; + case token_t::e_assign : current_state.set(e_level00,e_level00, details::e_assign); break; + case token_t::e_addass : current_state.set(e_level00,e_level00, details::e_addass); break; + case token_t::e_subass : current_state.set(e_level00,e_level00, details::e_subass); break; + case token_t::e_mulass : current_state.set(e_level00,e_level00, details::e_mulass); break; + case token_t::e_divass : current_state.set(e_level00,e_level00, details::e_divass); break; + case token_t::e_modass : current_state.set(e_level00,e_level00, details::e_modass); break; + case token_t::e_swap : current_state.set(e_level00,e_level00, details::e_swap ); break; + case token_t::e_lt : current_state.set(e_level05,e_level06, details:: e_lt); break; + case token_t::e_lte : current_state.set(e_level05,e_level06, details:: e_lte); break; + case token_t::e_eq : current_state.set(e_level05,e_level06, details:: e_eq); break; + case token_t::e_ne : current_state.set(e_level05,e_level06, details:: e_ne); break; + case token_t::e_gte : current_state.set(e_level05,e_level06, details:: e_gte); break; + case token_t::e_gt : current_state.set(e_level05,e_level06, details:: e_gt); break; + case token_t::e_add : current_state.set(e_level07,e_level08, details:: e_add); break; + case token_t::e_sub : current_state.set(e_level07,e_level08, details:: e_sub); break; + case token_t::e_div : current_state.set(e_level10,e_level11, details:: e_div); break; + case token_t::e_mul : current_state.set(e_level10,e_level11, details:: e_mul); break; + case token_t::e_mod : current_state.set(e_level10,e_level11, details:: e_mod); break; + case token_t::e_pow : current_state.set(e_level12,e_level12, details:: e_pow); break; default : if (token_t::e_symbol == current_token().type) { static const std::string s_and = "and"; @@ -20243,68 +20693,73 @@ namespace exprtk static const std::string s_ilike = "ilike"; static const std::string s_and1 = "&"; static const std::string s_or1 = "|"; + static const std::string s_not = "not"; if (details::imatch(current_token().value,s_and)) { - current_state.set(e_level03,e_level04,details::e_and); + current_state.set(e_level03, e_level04, details::e_and); break; } else if (details::imatch(current_token().value,s_and1)) { #ifndef exprtk_disable_sc_andor - current_state.set(e_level03,e_level04,details::e_scand); + current_state.set(e_level03, e_level04, details::e_scand); #else - current_state.set(e_level03,e_level04,details::e_and); + current_state.set(e_level03, e_level04, details::e_and); #endif break; } else if (details::imatch(current_token().value,s_nand)) { - current_state.set(e_level03,e_level04,details::e_nand); + current_state.set(e_level03, e_level04, details::e_nand); break; } else if (details::imatch(current_token().value,s_or)) { - current_state.set(e_level01,e_level02,details::e_or); + current_state.set(e_level01, e_level02, details::e_or); break; } else if (details::imatch(current_token().value,s_or1)) { #ifndef exprtk_disable_sc_andor - current_state.set(e_level01,e_level02,details::e_scor); + current_state.set(e_level01, e_level02, details::e_scor); #else - current_state.set(e_level01,e_level02,details::e_or); + current_state.set(e_level01, e_level02, details::e_or); #endif break; } else if (details::imatch(current_token().value,s_nor)) { - current_state.set(e_level01,e_level02,details::e_nor); + current_state.set(e_level01, e_level02, details::e_nor); break; } else if (details::imatch(current_token().value,s_xor)) { - current_state.set(e_level01,e_level02,details::e_xor); + current_state.set(e_level01, e_level02, details::e_xor); break; } else if (details::imatch(current_token().value,s_xnor)) { - current_state.set(e_level01,e_level02,details::e_xnor); + current_state.set(e_level01, e_level02, details::e_xnor); break; } else if (details::imatch(current_token().value,s_in)) { - current_state.set(e_level04,e_level04,details::e_in); + current_state.set(e_level04, e_level04, details::e_in); break; } else if (details::imatch(current_token().value,s_like)) { - current_state.set(e_level04,e_level04,details::e_like); + current_state.set(e_level04, e_level04, details::e_like); break; } else if (details::imatch(current_token().value,s_ilike)) { - current_state.set(e_level04,e_level04,details::e_ilike); + current_state.set(e_level04, e_level04, details::e_ilike); + break; + } + else if (details::imatch(current_token().value,s_not)) + { break; } } @@ -20320,7 +20775,7 @@ namespace exprtk else if (current_state.left < precedence) break; - lexer::token prev_token = current_token(); + const lexer::token prev_token = current_token(); next_token(); @@ -20334,7 +20789,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR008 - Invalid arithmetic operation '" + details::to_str(current_state.operation) + "'")); + "ERR009 - Invalid arithmetic operation '" + details::to_str(current_state.operation) + "'", + exprtk_error_location)); return error_node(); } @@ -20345,7 +20801,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR009 - Invalid inequality operation '" + details::to_str(current_state.operation) + "'")); + "ERR010 - Invalid inequality operation '" + details::to_str(current_state.operation) + "'", + exprtk_error_location)); return error_node(); } @@ -20356,7 +20813,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR010 - Invalid assignment operation '" + details::to_str(current_state.operation) + "'")); + "ERR011 - Invalid assignment operation '" + details::to_str(current_state.operation) + "'", + exprtk_error_location)); return error_node(); } @@ -20368,13 +20826,14 @@ namespace exprtk details::is_return_node(right_branch) ) { - free_node(node_allocator_, expression); - free_node(node_allocator_,right_branch); + free_node(node_allocator_, expression); + free_node(node_allocator_, right_branch); set_error( make_error(parser_error::e_syntax, prev_token, - "ERR011 - Return statements cannot be part of sub-expressions")); + "ERR012 - Return statements cannot be part of sub-expressions", + exprtk_error_location)); return error_node(); } @@ -20396,10 +20855,12 @@ namespace exprtk prev_token, !synthesis_error_.empty() ? synthesis_error_ : - "ERR012 - General parsing error at token: '" + prev_token.value + "'")); + "ERR013 - General parsing error at token: '" + prev_token.value + "'", + exprtk_error_location)); } - free_node(node_allocator_,expression); + free_node(node_allocator_, expression); + free_node(node_allocator_, right_branch); return error_node(); } @@ -20464,7 +20925,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR013 - Failed to find variable node in symbol table")); + "ERR014 - Failed to find variable node in symbol table", + exprtk_error_location)); free_node(node_allocator_,node); @@ -20586,7 +21048,7 @@ namespace exprtk struct scoped_bool_negator { - scoped_bool_negator(bool& bb) + explicit scoped_bool_negator(bool& bb) : b(bb) { b = !b; } @@ -20598,7 +21060,7 @@ namespace exprtk struct scoped_bool_or_restorer { - scoped_bool_or_restorer(bool& bb) + explicit scoped_bool_or_restorer(bool& bb) : b(bb), original_value_(bb) {} @@ -20643,7 +21105,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR014 - Invalid number of parameters for function: '" + function_name + "'")); + "ERR015 - Invalid number of parameters for function: '" + function_name + "'", + exprtk_error_location)); return error_node(); } @@ -20656,7 +21119,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR015 - Failed to generate call to function: '" + function_name + "'")); + "ERR016 - Failed to generate call to function: '" + function_name + "'", + exprtk_error_location)); return error_node(); } @@ -20674,7 +21138,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR016 - Expecting ifunction '" + function_name + "' to have non-zero parameter count")); + "ERR017 - Expecting ifunction '" + function_name + "' to have non-zero parameter count", + exprtk_error_location)); return error_node(); } @@ -20685,8 +21150,9 @@ namespace exprtk expression_node_ptr branch[NumberofParameters]; expression_node_ptr result = error_node(); - std::fill_n(branch,NumberofParameters,reinterpret_cast(0)); - scoped_delete sd(*this,branch); + std::fill_n(branch, NumberofParameters, reinterpret_cast(0)); + + scoped_delete sd((*this),branch); next_token(); @@ -20695,7 +21161,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR017 - Expecting argument list for function: '" + function_name + "'")); + "ERR018 - Expecting argument list for function: '" + function_name + "'", + exprtk_error_location)); return error_node(); } @@ -20709,7 +21176,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR018 - Failed to parse argument " + details::to_str(i) + " for function: '" + function_name + "'")); + "ERR019 - Failed to parse argument " + details::to_str(i) + " for function: '" + function_name + "'", + exprtk_error_location)); return error_node(); } @@ -20720,7 +21188,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR019 - Invalid number of arguments for function: '" + function_name + "'")); + "ERR020 - Invalid number of arguments for function: '" + function_name + "'", + exprtk_error_location)); return error_node(); } @@ -20732,7 +21201,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR020 - Invalid number of arguments for function: '" + function_name + "'")); + "ERR021 - Invalid number of arguments for function: '" + function_name + "'", + exprtk_error_location)); return error_node(); } @@ -20760,7 +21230,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR021 - Expecting '()' to proceed call to function: '" + function_name + "'")); + "ERR022 - Expecting '()' to proceed call to function: '" + function_name + "'", + exprtk_error_location)); free_node(node_allocator_,result); @@ -20771,11 +21242,11 @@ namespace exprtk } template - inline int parse_base_function_call(expression_node_ptr (¶m_list)[MaxNumberofParameters]) + inline std::size_t parse_base_function_call(expression_node_ptr (¶m_list)[MaxNumberofParameters], const std::string& function_name = "") { - std::fill_n(param_list,MaxNumberofParameters,reinterpret_cast(0)); + std::fill_n(param_list, MaxNumberofParameters, reinterpret_cast(0)); - scoped_delete sd(*this,param_list); + scoped_delete sd((*this),param_list); next_token(); @@ -20784,21 +21255,37 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR022 - Expected a '(' at start of function call, instead got: '" + current_token().value + "'")); + "ERR023 - Expected a '(' at start of function call to '" + function_name + + "', instead got: '" + current_token().value + "'", + exprtk_error_location)); return 0; } - int param_index = 0; + if (token_is(token_t::e_rbracket, e_hold)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR024 - Expected at least one input parameter for function call '" + function_name + "'", + exprtk_error_location)); - for (; param_index < static_cast(MaxNumberofParameters); ++param_index) + return 0; + } + + std::size_t param_index = 0; + + for (; param_index < MaxNumberofParameters; ++param_index) { param_list[param_index] = parse_expression(); if (0 == param_list[param_index]) return 0; else if (token_is(token_t::e_rbracket)) + { + sd.delete_ptr = false; break; + } else if (token_is(token_t::e_comma)) continue; else @@ -20806,13 +21293,23 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR023 - Expected a ',' between function input parameters, instead got: '" + current_token().value + "'")); + "ERR025 - Expected a ',' between function input parameters, instead got: '" + current_token().value + "'", + exprtk_error_location)); return 0; } } - sd.delete_ptr = false; + if (sd.delete_ptr) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR026 - Invalid number of input parameters passed to function '" + function_name + "'", + exprtk_error_location)); + + return 0; + } return (param_index + 1); } @@ -20821,15 +21318,18 @@ namespace exprtk { typedef std::pair map_range_t; - const std::string operation_name = current_token().value; + const std::string operation_name = current_token().value; + const token_t diagnostic_token = current_token(); + map_range_t itr_range = base_ops_map_.equal_range(operation_name); if (0 == std::distance(itr_range.first,itr_range.second)) { set_error( make_error(parser_error::e_syntax, - current_token(), - "ERR024 - No entry found for base operation: " + operation_name)); + diagnostic_token, + "ERR027 - No entry found for base operation: " + operation_name, + exprtk_error_location)); return error_node(); } @@ -20837,29 +21337,25 @@ namespace exprtk static const std::size_t MaxNumberofParameters = 4; expression_node_ptr param_list[MaxNumberofParameters] = {0}; - std::size_t parameter_count = parse_base_function_call(param_list); + const std::size_t parameter_count = parse_base_function_call(param_list, operation_name); - if (0 == parameter_count) - { - return error_node(); - } - else if (parameter_count <= MaxNumberofParameters) + if ((parameter_count > 0) && (parameter_count <= MaxNumberofParameters)) { for (base_ops_map_t::iterator itr = itr_range.first; itr != itr_range.second; ++itr) { - details::base_operation_t& operation = itr->second; + const details::base_operation_t& operation = itr->second; if (operation.num_params == parameter_count) { switch (parameter_count) { - #define base_opr_case(N) \ - case N : { \ - expression_node_ptr pl##N[N] = {0}; \ - std::copy(param_list,param_list + N,pl##N); \ - lodge_symbol(operation_name,e_st_function); \ - return expression_generator_(operation.type,pl##N); \ - } \ + #define base_opr_case(N) \ + case N : { \ + expression_node_ptr pl##N[N] = {0}; \ + std::copy(param_list, param_list + N, pl##N); \ + lodge_symbol(operation_name, e_st_function); \ + return expression_generator_(operation.type, pl##N); \ + } \ base_opr_case(1) base_opr_case(2) @@ -20873,13 +21369,14 @@ namespace exprtk for (std::size_t i = 0; i < MaxNumberofParameters; ++i) { - free_node(node_allocator_,param_list[i]); + free_node(node_allocator_, param_list[i]); } set_error( make_error(parser_error::e_syntax, - current_token(), - "ERR025 - Invalid number of parameters for call to function: '" + operation_name + "'")); + diagnostic_token, + "ERR028 - Invalid number of input parameters for call to function: '" + operation_name + "'", + exprtk_error_location)); return error_node(); } @@ -20898,7 +21395,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR026 - Expected ',' between if-statement condition and consequent")); + "ERR029 - Expected ',' between if-statement condition and consequent", + exprtk_error_location)); result = false; } else if (0 == (consequent = parse_expression())) @@ -20906,7 +21404,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR027 - Failed to parse consequent for if-statement")); + "ERR030 - Failed to parse consequent for if-statement", + exprtk_error_location)); result = false; } else if (!token_is(token_t::e_comma)) @@ -20914,7 +21413,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR028 - Expected ',' between if-statement consequent and alternative")); + "ERR031 - Expected ',' between if-statement consequent and alternative", + exprtk_error_location)); result = false; } else if (0 == (alternative = parse_expression())) @@ -20922,7 +21422,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR029 - Failed to parse alternative for if-statement")); + "ERR032 - Failed to parse alternative for if-statement", + exprtk_error_location)); result = false; } else if (!token_is(token_t::e_rbracket)) @@ -20930,7 +21431,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR030 - Expected ')' at the end of if-statement")); + "ERR033 - Expected ')' at the end of if-statement", + exprtk_error_location)); result = false; } @@ -20951,7 +21453,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR031 - Return types of ternary if-statement differ")); + "ERR034 - Return types of ternary if-statement differ", + exprtk_error_location)); result = false; } @@ -20985,7 +21488,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR032 - Failed to parse body of consequent for if-statement")); + "ERR035 - Failed to parse body of consequent for if-statement", + exprtk_error_location)); + result = false; } } @@ -21006,7 +21511,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR033 - Expected ';' at the end of the consequent for if-statement")); + "ERR036 - Expected ';' at the end of the consequent for if-statement", + exprtk_error_location)); + result = false; } } @@ -21015,7 +21522,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR034 - Failed to parse body of consequent for if-statement")); + "ERR037 - Failed to parse body of consequent for if-statement", + exprtk_error_location)); + result = false; } } @@ -21033,7 +21542,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR035 - Failed to parse body of the 'else' for if-statement")); + "ERR038 - Failed to parse body of the 'else' for if-statement", + exprtk_error_location)); + result = false; } } @@ -21044,7 +21555,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR036 - Failed to parse body of if-else statement")); + "ERR039 - Failed to parse body of if-else statement", + exprtk_error_location)); + result = false; } } @@ -21055,7 +21568,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR037 - Expected ';' at the end of the 'else-if' for the if-statement")); + "ERR040 - Expected ';' at the end of the 'else-if' for the if-statement", + exprtk_error_location)); + result = false; } } @@ -21064,7 +21579,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR038 - Failed to parse body of the 'else' for if-statement")); + "ERR041 - Failed to parse body of the 'else' for if-statement", + exprtk_error_location)); + result = false; } } @@ -21081,13 +21598,14 @@ namespace exprtk if (consq_is_str && alter_is_str) { return expression_generator_ - .conditional_string(condition,consequent,alternative); + .conditional_string(condition, consequent, alternative); } set_error( make_error(parser_error::e_syntax, current_token(), - "ERR039 - Return types of ternary if-statement differ")); + "ERR042 - Return types of ternary if-statement differ", + exprtk_error_location)); result = false; } @@ -21096,15 +21614,15 @@ namespace exprtk if (!result) { - free_node(node_allocator_, condition); - free_node(node_allocator_, consequent); - free_node(node_allocator_,alternative); + free_node(node_allocator_, condition); + free_node(node_allocator_, consequent); + free_node(node_allocator_, alternative); return error_node(); } else return expression_generator_ - .conditional(condition,consequent,alternative); + .conditional(condition, consequent, alternative); } inline expression_node_ptr parse_conditional_statement() @@ -21118,7 +21636,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR040 - Expected '(' at start of if-statement, instead got: '" + current_token().value + "'")); + "ERR043 - Expected '(' at start of if-statement, instead got: '" + current_token().value + "'", + exprtk_error_location)); return error_node(); } @@ -21127,7 +21646,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR041 - Failed to parse condition for if-statement")); + "ERR044 - Failed to parse condition for if-statement", + exprtk_error_location)); return error_node(); } @@ -21158,7 +21678,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR042 - Invalid if-statement")); + "ERR045 - Invalid if-statement", + exprtk_error_location)); free_node(node_allocator_,condition); @@ -21178,7 +21699,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR043 - Encountered invalid condition branch for ternary if-statement")); + "ERR046 - Encountered invalid condition branch for ternary if-statement", + exprtk_error_location)); return error_node(); } @@ -21187,7 +21709,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR044 - Expected '?' after condition of ternary if-statement")); + "ERR047 - Expected '?' after condition of ternary if-statement", + exprtk_error_location)); result = false; } @@ -21196,7 +21719,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR045 - Failed to parse consequent for ternary if-statement")); + "ERR048 - Failed to parse consequent for ternary if-statement", + exprtk_error_location)); result = false; } @@ -21205,7 +21729,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR046 - Expected ':' between ternary if-statement consequent and alternative")); + "ERR049 - Expected ':' between ternary if-statement consequent and alternative", + exprtk_error_location)); result = false; } @@ -21214,7 +21739,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR047 - Failed to parse alternative for ternary if-statement")); + "ERR050 - Failed to parse alternative for ternary if-statement", + exprtk_error_location)); result = false; } @@ -21230,13 +21756,14 @@ namespace exprtk if (consq_is_str && alter_is_str) { return expression_generator_ - .conditional_string(condition,consequent,alternative); + .conditional_string(condition, consequent, alternative); } set_error( make_error(parser_error::e_syntax, current_token(), - "ERR048 - Return types of ternary if-statement differ")); + "ERR051 - Return types of ternary if-statement differ", + exprtk_error_location)); result = false; } @@ -21245,15 +21772,15 @@ namespace exprtk if (!result) { - free_node(node_allocator_, condition); - free_node(node_allocator_, consequent); - free_node(node_allocator_,alternative); + free_node(node_allocator_, condition); + free_node(node_allocator_, consequent); + free_node(node_allocator_, alternative); return error_node(); } else return expression_generator_ - .conditional(condition,consequent,alternative); + .conditional(condition, consequent, alternative); } inline expression_node_ptr parse_while_loop() @@ -21272,7 +21799,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR049 - Expected '(' at start of while-loop condition statement")); + "ERR052 - Expected '(' at start of while-loop condition statement", + exprtk_error_location)); return error_node(); } @@ -21281,7 +21809,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR050 - Failed to parse condition for while-loop")); + "ERR053 - Failed to parse condition for while-loop", + exprtk_error_location)); return error_node(); } @@ -21290,7 +21819,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR051 - Expected ')' at end of while-loop condition statement")); + "ERR054 - Expected ')' at end of while-loop condition statement", + exprtk_error_location)); + result = false; } @@ -21303,7 +21834,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR052 - Failed to parse body of while-loop")); + "ERR055 - Failed to parse body of while-loop")); result = false; } else if (0 == (result_node = expression_generator_.while_loop(condition, @@ -21313,16 +21844,18 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR053 - Failed to synthesize while-loop")); + "ERR056 - Failed to synthesize while-loop", + exprtk_error_location)); + result = false; } } if (!result) { - free_node(node_allocator_, branch); - free_node(node_allocator_, condition); - free_node(node_allocator_,result_node); + free_node(node_allocator_, branch); + free_node(node_allocator_, condition); + free_node(node_allocator_, result_node); brkcnt_list_.pop_front(); @@ -21342,7 +21875,7 @@ namespace exprtk std::vector arg_list; std::vector side_effect_list; - scoped_vec_delete sdd(*this,arg_list); + scoped_vec_delete sdd((*this),arg_list); brkcnt_list_.push_front(false); @@ -21353,7 +21886,7 @@ namespace exprtk } else { - token_t::token_type seperator = token_t::e_eof; + const token_t::token_type seperator = token_t::e_eof; scope_handler sh(*this); @@ -21379,15 +21912,16 @@ namespace exprtk break; } - bool is_next_until = peek_token_is(token_t::e_symbol) && - peek_token_is("until"); + const bool is_next_until = peek_token_is(token_t::e_symbol) && + peek_token_is("until"); if (!token_is(seperator) && is_next_until) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR054 - Expected '" + token_t::to_str(seperator) + "' in body of repeat until loop")); + "ERR057 - Expected '" + token_t::to_str(seperator) + "' in body of repeat until loop", + exprtk_error_location)); return error_node(); } @@ -21410,7 +21944,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR055 - Failed to parse body of repeat until loop")); + "ERR058 - Failed to parse body of repeat until loop", + exprtk_error_location)); return error_node(); } @@ -21423,7 +21958,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR056 - Expected '(' before condition statement of repeat until loop")); + "ERR059 - Expected '(' before condition statement of repeat until loop", + exprtk_error_location)); free_node(node_allocator_,branch); @@ -21436,7 +21972,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR057 - Failed to parse condition for repeat until loop")); + "ERR060 - Failed to parse condition for repeat until loop", + exprtk_error_location)); free_node(node_allocator_,branch); @@ -21447,7 +21984,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR058 - Expected ')' after condition of repeat until loop")); + "ERR061 - Expected ')' after condition of repeat until loop", + exprtk_error_location)); free_node(node_allocator_, branch); free_node(node_allocator_, condition); @@ -21460,16 +21998,18 @@ namespace exprtk expression_node_ptr result; result = expression_generator_ - .repeat_until_loop(condition,branch,brkcnt_list_.front()); + .repeat_until_loop(condition, branch, brkcnt_list_.front()); if (0 == result) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR059 - Failed to synthesize repeat until loop")); + "ERR062 - Failed to synthesize repeat until loop", + exprtk_error_location)); + + free_node(node_allocator_,condition); - free_node(node_allocator_, condition); brkcnt_list_.pop_front(); return error_node(); @@ -21490,7 +22030,6 @@ namespace exprtk scope_element* se = 0; bool result = true; - std::string loop_counter_symbol; next_token(); @@ -21501,7 +22040,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR060 - Expected '(' at start of for-loop")); + "ERR063 - Expected '(' at start of for-loop", + exprtk_error_location)); return error_node(); } @@ -21520,7 +22060,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR061 - Expected a variable at the start of initialiser section of for-loop")); + "ERR064 - Expected a variable at the start of initialiser section of for-loop", + exprtk_error_location)); return error_node(); } @@ -21529,12 +22070,13 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR062 - Expected variable assignment of initialiser section of for-loop")); + "ERR065 - Expected variable assignment of initialiser section of for-loop", + exprtk_error_location)); return error_node(); } - loop_counter_symbol = current_token().value; + const std::string loop_counter_symbol = current_token().value; se = &sem_.get_element(loop_counter_symbol); @@ -21543,7 +22085,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR063 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration")); + "ERR066 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration", + exprtk_error_location)); return error_node(); } @@ -21574,7 +22117,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR064 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM")); + "ERR067 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM", + exprtk_error_location)); sem_.free_element(nse); @@ -21595,7 +22139,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR065 - Failed to parse initialiser of for-loop")); + "ERR068 - Failed to parse initialiser of for-loop", + exprtk_error_location)); + result = false; } else if (!token_is(token_t::e_eof)) @@ -21603,7 +22149,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR066 - Expected ';' after initialiser of for-loop")); + "ERR069 - Expected ';' after initialiser of for-loop", + exprtk_error_location)); + result = false; } } @@ -21615,7 +22163,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR067 - Failed to parse condition of for-loop")); + "ERR070 - Failed to parse condition of for-loop", + exprtk_error_location)); + result = false; } else if (!token_is(token_t::e_eof)) @@ -21623,7 +22173,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR068 - Expected ';' after condition section of for-loop")); + "ERR071 - Expected ';' after condition section of for-loop", + exprtk_error_location)); + result = false; } } @@ -21635,7 +22187,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR069 - Failed to parse incrementor of for-loop")); + "ERR072 - Failed to parse incrementor of for-loop", + exprtk_error_location)); + result = false; } else if (!token_is(token_t::e_rbracket)) @@ -21643,7 +22197,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR070 - Expected ')' after incrementor section of for-loop")); + "ERR073 - Expected ')' after incrementor section of for-loop", + exprtk_error_location)); + result = false; } } @@ -21657,7 +22213,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR071 - Failed to parse body of for-loop")); + "ERR074 - Failed to parse body of for-loop", + exprtk_error_location)); + result = false; } } @@ -21669,12 +22227,10 @@ namespace exprtk se->ref_count--; } - sem_.cleanup(); - - free_node(node_allocator_,initialiser); - free_node(node_allocator_, condition); - free_node(node_allocator_,incrementor); - free_node(node_allocator_, loop_body); + free_node(node_allocator_, initialiser); + free_node(node_allocator_, condition); + free_node(node_allocator_, incrementor); + free_node(node_allocator_, loop_body); if (!brkcnt_list_.empty()) { @@ -21707,12 +22263,13 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR072 - Expected keyword 'switch'")); + "ERR075 - Expected keyword 'switch'", + exprtk_error_location)); return error_node(); } - scoped_vec_delete svd(*this,arg_list); + scoped_vec_delete svd((*this),arg_list); next_token(); @@ -21721,7 +22278,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR073 - Expected '{' for call to switch statement")); + "ERR076 - Expected '{' for call to switch statement", + exprtk_error_location)); return error_node(); } @@ -21733,7 +22291,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR074 - Expected either a 'case' or 'default' statement")); + "ERR077 - Expected either a 'case' or 'default' statement", + exprtk_error_location)); return error_node(); } @@ -21749,7 +22308,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR075 - Expected ':' for case of switch statement")); + "ERR078 - Expected ':' for case of switch statement", + exprtk_error_location)); return error_node(); } @@ -21763,7 +22323,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR076 - Expected ';' at end of case for switch statement")); + "ERR079 - Expected ';' at end of case for switch statement", + exprtk_error_location)); return error_node(); } @@ -21771,11 +22332,8 @@ namespace exprtk // Can we optimise away the case statement? if (is_constant_node(condition) && is_false(condition)) { - free_node(node_allocator_, condition); - free_node(node_allocator_,consequent); - - condition = 0; - consequent = 0; + free_node(node_allocator_, condition); + free_node(node_allocator_, consequent); } else { @@ -21791,7 +22349,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR077 - Expected ':' for default of switch statement")); + "ERR080 - Expected ':' for default of switch statement", + exprtk_error_location)); return error_node(); } @@ -21812,7 +22371,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR078 - Expected ';' at end of default for switch statement")); + "ERR081 - Expected ';' at end of default for switch statement", + exprtk_error_location)); return error_node(); } @@ -21827,7 +22387,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR079 - Expected '}' at end of switch statement")); + "ERR082 - Expected '}' at end of switch statement", + exprtk_error_location)); return error_node(); } @@ -21842,19 +22403,19 @@ namespace exprtk inline expression_node_ptr parse_multi_switch_statement() { std::vector arg_list; - expression_node_ptr result = error_node(); if (!details::imatch(current_token().value,"[*]")) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR080 - Expected token '[*]'")); + "ERR083 - Expected token '[*]'", + exprtk_error_location)); return error_node(); } - scoped_vec_delete svd(*this,arg_list); + scoped_vec_delete svd((*this),arg_list); next_token(); @@ -21863,7 +22424,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR081 - Expected '{' for call to [*] statement")); + "ERR084 - Expected '{' for call to [*] statement", + exprtk_error_location)); return error_node(); } @@ -21875,7 +22437,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR082 - Expected a 'case' statement for multi-switch")); + "ERR085 - Expected a 'case' statement for multi-switch", + exprtk_error_location)); return error_node(); } @@ -21892,7 +22455,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR083 - Expected ':' for case of [*] statement")); + "ERR086 - Expected ':' for case of [*] statement", + exprtk_error_location)); return error_node(); } @@ -21907,7 +22471,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR084 - Expected ';' at end of case for [*] statement")); + "ERR087 - Expected ';' at end of case for [*] statement", + exprtk_error_location)); return error_node(); } @@ -21915,15 +22480,12 @@ namespace exprtk // Can we optimise away the case statement? if (is_constant_node(condition) && is_false(condition)) { - free_node(node_allocator_, condition); - free_node(node_allocator_,consequent); - - condition = 0; - consequent = 0; + free_node(node_allocator_, condition); + free_node(node_allocator_, consequent); } else { - arg_list.push_back(condition); + arg_list.push_back( condition); arg_list.push_back(consequent); } @@ -21938,12 +22500,13 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR085 - Expected '}' at end of [*] statement")); + "ERR088 - Expected '}' at end of [*] statement", + exprtk_error_location)); return error_node(); } - result = expression_generator_.multi_switch_statement(arg_list); + const expression_node_ptr result = expression_generator_.multi_switch_statement(arg_list); svd.delete_ptr = (0 == result); @@ -21953,7 +22516,6 @@ namespace exprtk inline expression_node_ptr parse_vararg_function() { std::vector arg_list; - expression_node_ptr result = error_node(); details::operator_type opt_type = details::e_default; const std::string symbol = current_token().value; @@ -21967,26 +22529,27 @@ namespace exprtk { return parse_multi_switch_statement(); } - else if (details::imatch(symbol,"avg" )) opt_type = details::e_avg; - else if (details::imatch(symbol,"mand")) opt_type = details::e_mand; - else if (details::imatch(symbol,"max" )) opt_type = details::e_max; - else if (details::imatch(symbol,"min" )) opt_type = details::e_min; - else if (details::imatch(symbol,"mor" )) opt_type = details::e_mor; - else if (details::imatch(symbol,"mul" )) opt_type = details::e_prod; - else if (details::imatch(symbol,"sum" )) opt_type = details::e_sum; + else if (details::imatch(symbol, "avg" )) opt_type = details::e_avg ; + else if (details::imatch(symbol, "mand")) opt_type = details::e_mand; + else if (details::imatch(symbol, "max" )) opt_type = details::e_max ; + else if (details::imatch(symbol, "min" )) opt_type = details::e_min ; + else if (details::imatch(symbol, "mor" )) opt_type = details::e_mor ; + else if (details::imatch(symbol, "mul" )) opt_type = details::e_prod; + else if (details::imatch(symbol, "sum" )) opt_type = details::e_sum ; else { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR086 - Unsupported vararg function: " + symbol)); + "ERR089 - Unsupported vararg function: " + symbol, + exprtk_error_location)); return error_node(); } - scoped_vec_delete sdd(*this,arg_list); + scoped_vec_delete sdd((*this),arg_list); - lodge_symbol(symbol,e_st_function); + lodge_symbol(symbol, e_st_function); next_token(); @@ -21995,7 +22558,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR087 - Expected '(' for call to vararg function: " + symbol)); + "ERR090 - Expected '(' for call to vararg function: " + symbol, + exprtk_error_location)); return error_node(); } @@ -22016,13 +22580,14 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR088 - Expected ',' for call to vararg function: " + symbol)); + "ERR091 - Expected ',' for call to vararg function: " + symbol, + exprtk_error_location)); return error_node(); } } - result = expression_generator_.vararg_function(opt_type,arg_list); + const expression_node_ptr result = expression_generator_.vararg_function(opt_type,arg_list); sdd.delete_ptr = (0 == result); return result; @@ -22036,7 +22601,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR089 - Expected '[' as start of string range definition")); + "ERR092 - Expected '[' as start of string range definition", + exprtk_error_location)); free_node(node_allocator_,expression); @@ -22063,7 +22629,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR090 - Failed to generate string range node")); + "ERR093 - Failed to generate string range node", + exprtk_error_location)); free_node(node_allocator_,expression); } @@ -22101,7 +22668,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline expression_node_ptr simplify(Sequence& expression_list, Sequence& side_effect_list, const bool specialise_on_final_type = false) @@ -22198,8 +22765,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR091 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + - ((!source.empty()) ? std::string(" section of " + source): ""))); + "ERR094 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + + ((!source.empty()) ? std::string(" section of " + source): ""), + exprtk_error_location)); return error_node(); } @@ -22214,7 +22782,7 @@ namespace exprtk expression_node_ptr result = error_node(); - scoped_vec_delete sdd(*this,arg_list); + scoped_vec_delete sdd((*this),arg_list); scope_handler sh(*this); @@ -22237,14 +22805,15 @@ namespace exprtk if (token_is(close_bracket)) break; - bool is_next_close = peek_token_is(close_bracket); + const bool is_next_close = peek_token_is(close_bracket); if (!token_is(seperator) && is_next_close) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR092 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source)); + "ERR095 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source, + exprtk_error_location)); return error_node(); } @@ -22277,7 +22846,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR093 - Expected '[' for start of range")); + "ERR096 - Expected '[' for start of range", + exprtk_error_location)); return false; } @@ -22297,14 +22867,14 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR094 - Failed parse begin section of range")); + "ERR097 - Failed parse begin section of range", + exprtk_error_location)); return false; - } else if (is_constant_node(r0)) { - T r0_value = r0->value(); + const T r0_value = r0->value(); if (r0_value >= T(0)) { @@ -22320,7 +22890,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR095 - Range lower bound less than zero! Constraint: r0 >= 0")); + "ERR098 - Range lower bound less than zero! Constraint: r0 >= 0", + exprtk_error_location)); return false; } @@ -22336,9 +22907,11 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR096 - Expected ':' for break in range")); + "ERR099 - Expected ':' for break in range", + exprtk_error_location)); rp.free(); + return false; } } @@ -22357,15 +22930,16 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR097 - Failed parse end section of range")); + "ERR100 - Failed parse end section of range", + exprtk_error_location)); rp.free(); - return false; + return false; } else if (is_constant_node(r1)) { - T r1_value = r1->value(); + const T r1_value = r1->value(); if (r1_value >= T(0)) { @@ -22381,7 +22955,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR098 - Range upper bound less than zero! Constraint: r1 >= 0")); + "ERR101 - Range upper bound less than zero! Constraint: r1 >= 0", + exprtk_error_location)); return false; } @@ -22397,9 +22972,11 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR099 - Expected ']' for start of range")); + "ERR102 - Expected ']' for start of range", + exprtk_error_location)); rp.free(); + return false; } } @@ -22409,14 +22986,15 @@ namespace exprtk std::size_t r0 = 0; std::size_t r1 = 0; - bool rp_result = rp(r0,r1); + const bool rp_result = rp(r0,r1); if (!rp_result || (r0 > r1)) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR100 - Invalid range, Constraint: r0 <= r1")); + "ERR103 - Invalid range, Constraint: r0 <= r1", + exprtk_error_location)); return false; } @@ -22440,7 +23018,6 @@ namespace exprtk expression_node_ptr result = error_node(); strvar_node_t const_str_node = static_cast(0); - bool is_const_string = false; scope_element& se = sem_.get_active_element(symbol); @@ -22448,7 +23025,7 @@ namespace exprtk { se.active = true; result = se.str_node; - lodge_symbol(symbol,e_st_local_string); + lodge_symbol(symbol, e_st_local_string); } else { @@ -22457,22 +23034,21 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR101 - Unknown string symbol")); + "ERR104 - Unknown string symbol", + exprtk_error_location)); return error_node(); } result = symtab_store_.get_stringvar(symbol); - is_const_string = symtab_store_.is_constant_string(symbol); - - if (is_const_string) + if (symtab_store_.is_constant_string(symbol)) { const_str_node = static_cast(result); result = expression_generator_(const_str_node->str()); } - lodge_symbol(symbol,e_st_string); + lodge_symbol(symbol, e_st_string); } if (peek_token_is(token_t::e_lsqrbracket)) @@ -22509,7 +23085,8 @@ namespace exprtk result = expression_generator_(const_str_node->ref(),rp); } else - result = expression_generator_(static_cast*>(result)->ref(),rp); + result = expression_generator_(static_cast*> + (result)->ref(), rp); if (result) rp.clear(); @@ -22529,8 +23106,8 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities inline expression_node_ptr parse_const_string() { - const std::string const_str = current_token().value; - expression_node_ptr result = expression_generator_(const_str); + const std::string const_str = current_token().value; + expression_node_ptr result = expression_generator_(const_str); if (peek_token_is(token_t::e_lsqrbracket)) { @@ -22571,9 +23148,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR102 - Overflow in range for string: '" + const_str + "'[" + + "ERR105 - Overflow in range for string: '" + const_str + "'[" + (rp.n0_c.first ? details::to_str(static_cast(rp.n0_c.second)) : "?") + ":" + - (rp.n1_c.first ? details::to_str(static_cast(rp.n1_c.second)) : "?") + "]")); + (rp.n1_c.first ? details::to_str(static_cast(rp.n1_c.second)) : "?") + "]", + exprtk_error_location)); return error_node(); } @@ -22604,8 +23182,8 @@ namespace exprtk const scope_element& se = sem_.get_active_element(symbol); if ( - (se.name != symbol) || - (se.depth > state_.scope_depth) || + !details::imatch(se.name, symbol) || + (se.depth > state_.scope_depth) || (scope_element::e_vector != se.type) ) { @@ -22614,7 +23192,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR103 - Symbol '" + symbol+ " not a vector")); + "ERR106 - Symbol '" + symbol+ " not a vector", + exprtk_error_location)); return error_node(); } @@ -22639,7 +23218,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR104 - Failed to parse index for vector: '" + symbol + "'")); + "ERR107 - Failed to parse index for vector: '" + symbol + "'", + exprtk_error_location)); return error_node(); } @@ -22648,7 +23228,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR105 - Expected ']' for index of vector: '" + symbol + "'")); + "ERR108 - Expected ']' for index of vector: '" + symbol + "'", + exprtk_error_location)); free_node(node_allocator_,index_expr); @@ -22658,7 +23239,7 @@ namespace exprtk // Perform compile-time range check if (details::is_constant_node(index_expr)) { - const std::size_t index = std::size_t(index_expr->value()); + const std::size_t index = static_cast(details::numeric::to_int32(index_expr->value())); const std::size_t vec_size = vec->size(); if (index >= vec_size) @@ -22666,8 +23247,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR106 - Index of " + details::to_str(index) + " out of range for " - "vector '" + symbol + "' of size " + details::to_str(vec_size))); + "ERR109 - Index of " + details::to_str(index) + " out of range for " + "vector '" + symbol + "' of size " + details::to_str(vec_size), + exprtk_error_location)); free_node(node_allocator_,index_expr); @@ -22681,9 +23263,10 @@ namespace exprtk inline expression_node_ptr parse_vararg_function_call(ivararg_function* vararg_function, const std::string& vararg_function_name) { std::vector arg_list; + expression_node_ptr result = error_node(); - scoped_vec_delete sdd(*this,arg_list); + scoped_vec_delete sdd((*this),arg_list); next_token(); @@ -22696,8 +23279,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR107 - Zero parameter call to vararg function: " - + vararg_function_name + " not allowed")); + "ERR110 - Zero parameter call to vararg function: " + + vararg_function_name + " not allowed", + exprtk_error_location)); return error_node(); } @@ -22720,8 +23304,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR108 - Expected ',' for call to vararg function: " - + vararg_function_name)); + "ERR111 - Expected ',' for call to vararg function: " + + vararg_function_name, + exprtk_error_location)); return error_node(); } @@ -22733,8 +23318,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR109 - Zero parameter call to vararg function: " - + vararg_function_name + " not allowed")); + "ERR112 - Zero parameter call to vararg function: " + + vararg_function_name + " not allowed", + exprtk_error_location)); return error_node(); } @@ -22744,9 +23330,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR110 - Invalid number of parameters to call to vararg function: " + "ERR113 - Invalid number of parameters to call to vararg function: " + vararg_function_name + ", require at least " - + details::to_str(static_cast(vararg_function->min_num_args())) + " parameters")); + + details::to_str(static_cast(vararg_function->min_num_args())) + " parameters", + exprtk_error_location)); return error_node(); } @@ -22755,9 +23342,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR111 - Invalid number of parameters to call to vararg function: " + "ERR114 - Invalid number of parameters to call to vararg function: " + vararg_function_name + ", require no more than " - + details::to_str(static_cast(vararg_function->max_num_args())) + " parameters")); + + details::to_str(static_cast(vararg_function->max_num_args())) + " parameters", + exprtk_error_location)); return error_node(); } @@ -22773,34 +23361,54 @@ namespace exprtk { public: + enum return_type_t + { + e_overload = ' ', + e_numeric = 'T', + e_string = 'S' + }; + + struct function_prototype_t + { + return_type_t return_type; + std::string param_seq; + }; + typedef parser parser_t; - typedef std::vector param_seq_list_t; + typedef std::vector function_definition_list_t; type_checker(parser_t& p, const std::string& func_name, - const std::string& param_seq) + const std::string& func_prototypes, + const return_type_t default_return_type) : invalid_state_(true), parser_(p), - function_name_(func_name) + function_name_(func_name), + default_return_type_(default_return_type) { - split(param_seq); + parse_function_prototypes(func_prototypes); + } + + void set_default_return_type(const std::string& return_type) + { + default_return_type_ = return_type; } bool verify(const std::string& param_seq, std::size_t& pseq_index) { - if (param_seq_list_.empty()) + if (function_definition_list_.empty()) return true; std::vector > error_list; - for (std::size_t i = 0; i < param_seq_list_.size(); ++i) + for (std::size_t i = 0; i < function_definition_list_.size(); ++i) { details::char_t diff_value = 0; std::size_t diff_index = 0; - bool result = details::sequence_match(param_seq_list_[i], - param_seq, - diff_index,diff_value); + const bool result = details::sequence_match(function_definition_list_[i].param_seq, + param_seq, + diff_index, diff_value); if (result) { @@ -22808,7 +23416,7 @@ namespace exprtk return true; } else - error_list.push_back(std::make_pair(diff_index,diff_value)); + error_list.push_back(std::make_pair(diff_index, diff_value)); } if (1 == error_list.size()) @@ -22817,8 +23425,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR112 - Failed parameter type check for function '" + function_name_ + "', " - "Expected '" + param_seq_list_[0] + "' call set: '" + param_seq +"'")); + "ERR115 - Failed parameter type check for function '" + function_name_ + "', " + "Expected '" + function_definition_list_[0].param_seq + + "' call set: '" + param_seq + "'", + exprtk_error_location)); } else { @@ -22837,8 +23447,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR113 - Failed parameter type check for function '" + function_name_ + "', " - "Best match: '" + param_seq_list_[max_diff_index] + "' call set: '" + param_seq +"'")); + "ERR116 - Failed parameter type check for function '" + function_name_ + "', " + "Best match: '" + function_definition_list_[max_diff_index].param_seq + + "' call set: '" + param_seq + "'", + exprtk_error_location)); } return false; @@ -22846,12 +23458,17 @@ namespace exprtk std::size_t paramseq_count() const { - return param_seq_list_.size(); + return function_definition_list_.size(); } std::string paramseq(const std::size_t& index) const { - return param_seq_list_[index]; + return function_definition_list_[index].param_seq; + } + + return_type_t return_type(const std::size_t& index) const + { + return function_definition_list_[index].return_type; } bool invalid() const @@ -22861,91 +23478,142 @@ namespace exprtk bool allow_zero_parameters() const { - return - param_seq_list_.end() != std::find(param_seq_list_.begin(), - param_seq_list_.end(), - "Z"); + + for (std::size_t i = 0; i < function_definition_list_.size(); ++i) + { + if (std::string::npos != function_definition_list_[i].param_seq.find("Z")) + { + return true; + } + } + + return false; } private: - void split(const std::string& s) + std::vector split_param_seq(const std::string& param_seq, const details::char_t delimiter = '|') const { - if (s.empty()) - return; + std::string::const_iterator current_begin = param_seq.begin(); + std::string::const_iterator iter = param_seq.begin(); + + std::vector result; + + while (iter != param_seq.end()) + { + if (*iter == delimiter) + { + result.push_back(std::string(current_begin, iter)); + current_begin = ++iter; + } + else + ++iter; + } + + if (current_begin != iter) + { + result.push_back(std::string(current_begin, iter)); + } - std::size_t start = 0; - std::size_t end = 0; + return result; + } - param_seq_list_t param_seq_list; + inline bool is_valid_token(std::string param_seq, + function_prototype_t& funcproto) const + { + // Determine return type + funcproto.return_type = default_return_type_; - struct token_validator + if (param_seq.size() > 2) { - static inline bool process(const std::string& str, - std::size_t s, std::size_t e, - param_seq_list_t& psl) + if (':' == param_seq[1]) { - if ( - (e - s) && - (std::string::npos == str.find("?*")) && - (std::string::npos == str.find("**")) - ) + // Note: Only overloaded igeneric functions can have return + // type definitions. + if (type_checker::e_overload != default_return_type_) + return false; + + switch (param_seq[0]) { - const std::string curr_str = str.substr(s,e - s); + case 'T' : funcproto.return_type = type_checker::e_numeric; + break; - if ("Z" == curr_str) - { - psl.push_back(curr_str); - return true; - } - else if (std::string::npos == curr_str.find_first_not_of("STV*?|")) - { - psl.push_back(curr_str); - return true; - } + case 'S' : funcproto.return_type = type_checker::e_string; + break; + + default : return false; } - return false; + param_seq.erase(0,2); } - }; + } - while (std::string::npos != (end = s.find('|',start))) + if ( + (std::string::npos != param_seq.find("?*")) || + (std::string::npos != param_seq.find("**")) + ) { - if (!token_validator::process(s,start,end,param_seq_list)) + return false; + } + else if ( + (std::string::npos == param_seq.find_first_not_of("STV*?|")) || + ("Z" == param_seq) + ) + { + funcproto.param_seq = param_seq; + return true; + } + + return false; + } + + void parse_function_prototypes(const std::string& func_prototypes) + { + if (func_prototypes.empty()) + return; + + std::vector param_seq_list = split_param_seq(func_prototypes); + + typedef std::map param_seq_map_t; + param_seq_map_t param_seq_map; + + for (std::size_t i = 0; i < param_seq_list.size(); ++i) + { + function_prototype_t func_proto; + + if (!is_valid_token(param_seq_list[i], func_proto)) { invalid_state_ = false; - const std::string err_param_seq = s.substr(start,end - start); - parser_. set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR114 - Invalid parameter sequence of '" + err_param_seq + - "' for function: " + function_name_)); - + "ERR117 - Invalid parameter sequence of '" + param_seq_list[i] + + "' for function: " + function_name_, + exprtk_error_location)); return; } - else - start = end + 1; - } - if (start < s.size()) - { - if (token_validator::process(s,start,s.size(),param_seq_list)) - param_seq_list_ = param_seq_list; - else + param_seq_map_t::const_iterator seq_itr = param_seq_map.find(param_seq_list[i]); + + if (param_seq_map.end() != seq_itr) { - const std::string err_param_seq = s.substr(start,s.size() - start); + invalid_state_ = false; parser_. set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR115 - Invalid parameter sequence of '" + err_param_seq + - "' for function: " + function_name_)); + "ERR118 - Function '" + function_name_ + "' has a parameter sequence conflict between " + + "pseq_idx[" + details::to_str(seq_itr->second) + "] and" + + "pseq_idx[" + details::to_str(i) + "] " + + "param seq: " + param_seq_list[i], + exprtk_error_location)); return; } + + function_definition_list_.push_back(func_proto); } } @@ -22955,42 +23623,29 @@ namespace exprtk bool invalid_state_; parser_t& parser_; std::string function_name_; - param_seq_list_t param_seq_list_; + const return_type_t default_return_type_; + function_definition_list_t function_definition_list_; }; inline expression_node_ptr parse_generic_function_call(igeneric_function* function, const std::string& function_name) { std::vector arg_list; - scoped_vec_delete sdd(*this,arg_list); + scoped_vec_delete sdd((*this),arg_list); next_token(); std::string param_type_list; - type_checker tc(*this,function_name,function->parameter_sequence); + type_checker tc((*this), function_name, function->parameter_sequence, type_checker::e_string); if (tc.invalid()) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR116 - Type checker instantiation failure for generic function: " + function_name)); - - return error_node(); - } - - if ( - !function->parameter_sequence.empty() && - function->allow_zero_parameters () && - !tc .allow_zero_parameters () - ) - { - set_error( - make_error(parser_error::e_syntax, - current_token(), - "ERR117 - Mismatch in zero parameter condition for generic function: " - + function_name)); + "ERR119 - Type checker instantiation failure for generic function: " + function_name, + exprtk_error_location)); return error_node(); } @@ -23007,8 +23662,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR118 - Zero parameter call to generic function: " - + function_name + " not allowed")); + "ERR120 - Zero parameter call to generic function: " + + function_name + " not allowed", + exprtk_error_location)); return error_node(); } @@ -23038,7 +23694,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR119 - Expected ',' for call to generic function: " + function_name)); + "ERR121 - Expected ',' for call to generic function: " + function_name, + exprtk_error_location)); return error_node(); } @@ -23054,8 +23711,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR120 - Zero parameter call to generic function: " - + function_name + " not allowed")); + "ERR122 - Zero parameter call to generic function: " + + function_name + " not allowed", + exprtk_error_location)); return error_node(); } @@ -23070,7 +23728,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR121 - Expected ',' for call to generic function: " + function_name)); + "ERR123 - Invalid input parameter sequence for call to generic function: " + function_name, + exprtk_error_location)); return error_node(); } @@ -23079,47 +23738,49 @@ namespace exprtk if (tc.paramseq_count() <= 1) result = expression_generator_ - .generic_function_call(function,arg_list); + .generic_function_call(function, arg_list); else result = expression_generator_ - .generic_function_call(function,arg_list,param_seq_index); + .generic_function_call(function, arg_list, param_seq_index); sdd.delete_ptr = (0 == result); return result; } - #ifndef exprtk_disable_string_capabilities - inline expression_node_ptr parse_string_function_call(igeneric_function* function, const std::string& function_name) + inline bool parse_igeneric_function_params(std::string& param_type_list, + std::vector& arg_list, + const std::string function_name, + igeneric_function* function, + const type_checker& tc) { - std::vector arg_list; - - scoped_vec_delete sdd(*this,arg_list); - - next_token(); - - std::string param_type_list; - - type_checker tc(*this,function_name,function->parameter_sequence); - - if ( - (!function->parameter_sequence.empty()) && - (0 == tc.paramseq_count()) - ) - { - return error_node(); - } - if (token_is(token_t::e_lbracket)) { - if (!token_is(token_t::e_rbracket)) + if (token_is(token_t::e_rbracket)) + { + if ( + !function->allow_zero_parameters() && + !tc .allow_zero_parameters() + ) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR124 - Zero parameter call to generic function: " + + function_name + " not allowed", + exprtk_error_location)); + + return false; + } + } + else { for ( ; ; ) { expression_node_ptr arg = parse_expression(); if (0 == arg) - return error_node(); + return false; if (is_ivector_node(arg)) param_type_list += 'V'; @@ -23137,12 +23798,44 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR122 - Expected ',' for call to string function: " + function_name)); + "ERR125 - Expected ',' for call to string function: " + function_name, + exprtk_error_location)); - return error_node(); + return false; } } } + + return true; + } + else + return false; + } + + #ifndef exprtk_disable_string_capabilities + inline expression_node_ptr parse_string_function_call(igeneric_function* function, const std::string& function_name) + { + // Move pass the function name + next_token(); + + std::string param_type_list; + + type_checker tc((*this), function_name, function->parameter_sequence, type_checker::e_string); + + if ( + (!function->parameter_sequence.empty()) && + (0 == tc.paramseq_count()) + ) + { + return error_node(); + } + + std::vector arg_list; + scoped_vec_delete sdd((*this),arg_list); + + if (!parse_igeneric_function_params(param_type_list, arg_list, function_name, function, tc)) + { + return error_node(); } std::size_t param_seq_index = 0; @@ -23152,7 +23845,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR123 - Expected ',' for call to string function: " + function_name)); + "ERR126 - Invalid input parameter sequence for call to string function: " + function_name, + exprtk_error_location)); return error_node(); } @@ -23161,25 +23855,98 @@ namespace exprtk if (tc.paramseq_count() <= 1) result = expression_generator_ - .string_function_call(function,arg_list); + .string_function_call(function, arg_list); else result = expression_generator_ - .string_function_call(function,arg_list,param_seq_index); + .string_function_call(function, arg_list, param_seq_index); sdd.delete_ptr = (0 == result); return result; } + + inline expression_node_ptr parse_overload_function_call(igeneric_function* function, const std::string& function_name) + { + // Move pass the function name + next_token(); + + std::string param_type_list; + + type_checker tc((*this), function_name, function->parameter_sequence, type_checker::e_overload); + + if ( + (!function->parameter_sequence.empty()) && + (0 == tc.paramseq_count()) + ) + { + return error_node(); + } + + std::vector arg_list; + scoped_vec_delete sdd((*this),arg_list); + + if (!parse_igeneric_function_params(param_type_list, arg_list, function_name, function, tc)) + { + return error_node(); + } + + std::size_t param_seq_index = 0; + + if (!tc.verify(param_type_list, param_seq_index)) + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR127 - Invalid input parameter sequence for call to overloaded function: " + function_name, + exprtk_error_location)); + + return error_node(); + } + + expression_node_ptr result = error_node(); + + if (type_checker::e_numeric == tc.return_type(param_seq_index)) + { + if (tc.paramseq_count() <= 1) + result = expression_generator_ + .generic_function_call(function, arg_list); + else + result = expression_generator_ + .generic_function_call(function, arg_list, param_seq_index); + } + else if (type_checker::e_string == tc.return_type(param_seq_index)) + { + if (tc.paramseq_count() <= 1) + result = expression_generator_ + .string_function_call(function, arg_list); + else + result = expression_generator_ + .string_function_call(function, arg_list, param_seq_index); + } + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR128 - Invalid return type for call to overloaded function: " + function_name, + exprtk_error_location)); + } + + sdd.delete_ptr = (0 == result); + return result; + } #endif template struct parse_special_function_impl { - static inline expression_node_ptr process(parser& p,const details::operator_type opt_type) + static inline expression_node_ptr process(parser& p,const details::operator_type opt_type, const std::string& sf_name) { expression_node_ptr branch[NumberOfParameters]; expression_node_ptr result = error_node(); + std::fill_n(branch,NumberOfParameters,reinterpret_cast(0)); + scoped_delete sd(p,branch); p.next_token(); @@ -23189,7 +23956,8 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR124 - Expected '(' for special function")); + "ERR129 - Expected '(' for special function '" + sf_name + "'", + exprtk_error_location)); return error_node(); } @@ -23209,7 +23977,8 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR125 - Expected ',' before next parameter of special function")); + "ERR130 - Expected ',' before next parameter of special function '" + sf_name + "'", + exprtk_error_location)); return p.error_node(); } @@ -23217,7 +23986,15 @@ namespace exprtk } if (!p.token_is(token_t::e_rbracket)) + { + p.set_error( + make_error(parser_error::e_syntax, + p.current_token(), + "ERR131 - Invalid number of parameters for special function '" + sf_name + "'", + exprtk_error_location)); + return p.error_node(); + } else result = p.expression_generator_.special_function(opt_type,branch); @@ -23229,40 +24006,45 @@ namespace exprtk inline expression_node_ptr parse_special_function() { + const std::string sf_name = current_token().value; + // Expect: $fDD(expr0,expr1,expr2) or $fDD(expr0,expr1,expr2,expr3) if ( - !details::is_digit(current_token().value[2]) || - !details::is_digit(current_token().value[3]) + !details::is_digit(sf_name[2]) || + !details::is_digit(sf_name[3]) ) { set_error( make_error(parser_error::e_token, current_token(), - "ERR126 - Invalid special function[1]: " + current_token().value)); + "ERR132 - Invalid special function[1]: " + sf_name, + exprtk_error_location)); return error_node(); } - const unsigned int id = (current_token().value[2] - '0') * 10 + (current_token().value[3] - '0'); + const int id = (sf_name[2] - '0') * 10 + + (sf_name[3] - '0'); if (id >= details::e_sffinal) { set_error( make_error(parser_error::e_token, current_token(), - "ERR127 - Invalid special function[2]: " + current_token().value)); + "ERR133 - Invalid special function[2]: " + sf_name, + exprtk_error_location)); return error_node(); } - const std::size_t sf_3_to_4 = details::e_sf48; + const int sf_3_to_4 = details::e_sf48; const details::operator_type opt_type = details::operator_type(id + 1000); - const std::size_t NumberOfParameters = (id < (sf_3_to_4 - 1000)) ? 3 : 4; + const std::size_t NumberOfParameters = (id < (sf_3_to_4 - 1000)) ? 3U : 4U; switch (NumberOfParameters) { - case 3 : return parse_special_function_impl::process(*this,opt_type); - case 4 : return parse_special_function_impl::process(*this,opt_type); + case 3 : return parse_special_function_impl::process((*this), opt_type, sf_name); + case 4 : return parse_special_function_impl::process((*this), opt_type, sf_name); default : return error_node(); } } @@ -23281,7 +24063,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR128 - Break call within a break call is not allowed")); + "ERR134 - Break call within a break call is not allowed", + exprtk_error_location)); return error_node(); } @@ -23303,7 +24086,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR129 - Failed to parse return expression for 'break' statement")); + "ERR135 - Failed to parse return expression for 'break' statement", + exprtk_error_location)); return error_node(); } @@ -23312,7 +24096,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR130 - Expected ']' at the completion of break's return expression")); + "ERR136 - Expected ']' at the completion of break's return expression", + exprtk_error_location)); free_node(node_allocator_,return_expr); @@ -23329,7 +24114,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR131 - Invalid use of 'break', allowed only in the scope of a loop")); + "ERR137 - Invalid use of 'break', allowed only in the scope of a loop", + exprtk_error_location)); } return error_node(); @@ -23351,7 +24137,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR132 - Invalid use of 'continue', allowed only in the scope of a loop")); + "ERR138 - Invalid use of 'continue', allowed only in the scope of a loop", + exprtk_error_location)); return error_node(); } @@ -23367,7 +24154,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR133 - Expected '[' as part of vector size definition")); + "ERR139 - Expected '[' as part of vector size definition", + exprtk_error_location)); return error_node(); } @@ -23376,7 +24164,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR134 - Failed to determine size of vector '" + vec_name + "'")); + "ERR140 - Failed to determine size of vector '" + vec_name + "'", + exprtk_error_location)); return error_node(); } @@ -23387,33 +24176,38 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR135 - Expected a literal number as size of vector '" + vec_name + "'")); + "ERR141 - Expected a literal number as size of vector '" + vec_name + "'", + exprtk_error_location)); return error_node(); } - T vector_size = size_expr->value(); + const T vector_size = size_expr->value(); free_node(node_allocator_,size_expr); + const T max_vector_size = T(2000000000.0); + if ( (vector_size <= T(0)) || std::not_equal_to() - (T(0),vector_size - details::numeric::trunc(vector_size)) + (T(0),vector_size - details::numeric::trunc(vector_size)) || + (vector_size > max_vector_size) ) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR136 - Invalid vector size. Must be an integer greater than zero, size: " + - details::to_str(details::numeric::to_int32(vector_size)))); + "ERR142 - Invalid vector size. Must be an integer in the range [0,2e9], size: " + + details::to_str(details::numeric::to_int32(vector_size)), + exprtk_error_location)); return error_node(); } std::vector vec_initilizer_list; - scoped_vec_delete svd(*this,vec_initilizer_list); + scoped_vec_delete svd((*this),vec_initilizer_list); bool single_value_initialiser = false; bool vec_to_vec_initialiser = false; @@ -23424,7 +24218,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR137 - Expected ']' as part of vector size definition")); + "ERR143 - Expected ']' as part of vector size definition", + exprtk_error_location)); return error_node(); } @@ -23435,7 +24230,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR138 - Expected ':=' as part of vector definition")); + "ERR144 - Expected ':=' as part of vector definition", + exprtk_error_location)); return error_node(); } @@ -23448,7 +24244,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR139 - Failed to parse single vector initialiser")); + "ERR145 - Failed to parse single vector initialiser", + exprtk_error_location)); return error_node(); } @@ -23460,7 +24257,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR140 - Expected ']' to close single value vector initialiser")); + "ERR146 - Expected ']' to close single value vector initialiser", + exprtk_error_location)); return error_node(); } @@ -23487,7 +24285,7 @@ namespace exprtk // Are we dealing with a user defined vector? else if (symtab_store_.is_vector(current_token().value)) { - lodge_symbol(current_token().value,e_st_vector); + lodge_symbol(current_token().value, e_st_vector); if (0 != (initialiser = parse_expression())) vec_initilizer_list.push_back(initialiser); @@ -23506,7 +24304,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR141 - Expected '{' as part of vector initialiser list")); + "ERR147 - Expected '{' as part of vector initialiser list", + exprtk_error_location)); return error_node(); } @@ -23525,7 +24324,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR142 - Expected '{' as part of vector initialiser list")); + "ERR148 - Expected '{' as part of vector initialiser list", + exprtk_error_location)); return error_node(); } @@ -23535,14 +24335,15 @@ namespace exprtk if (token_is(token_t::e_rcrlbracket)) break; - bool is_next_close = peek_token_is(token_t::e_rcrlbracket); + const bool is_next_close = peek_token_is(token_t::e_rcrlbracket); if (!token_is(token_t::e_comma) && is_next_close) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR143 - Expected ',' between vector initialisers")); + "ERR149 - Expected ',' between vector initialisers", + exprtk_error_location)); return error_node(); } @@ -23553,9 +24354,9 @@ namespace exprtk } if ( - !token_is(token_t::e_rbracket ,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rcrlbracket,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rsqrbracket,prsrhlpr_t::e_hold) + !token_is(token_t::e_rbracket , prsrhlpr_t::e_hold) && + !token_is(token_t::e_rcrlbracket, prsrhlpr_t::e_hold) && + !token_is(token_t::e_rsqrbracket, prsrhlpr_t::e_hold) ) { if (!token_is(token_t::e_eof)) @@ -23563,7 +24364,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR144 - Expected ';' at end of vector definition")); + "ERR150 - Expected ';' at end of vector definition", + exprtk_error_location)); return error_node(); } @@ -23574,7 +24376,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR145 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'")); + "ERR151 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'", + exprtk_error_location)); return error_node(); } @@ -23582,7 +24385,7 @@ namespace exprtk typename symbol_table_t::vector_holder_ptr vec_holder = typename symbol_table_t::vector_holder_ptr(0); - std::size_t vec_size = static_cast(details::numeric::to_int32(vector_size)); + const std::size_t vec_size = static_cast(details::numeric::to_int32(vector_size)); scope_element& se = sem_.get_element(vec_name); @@ -23593,7 +24396,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR146 - Illegal redefinition of local vector: '" + vec_name + "'")); + "ERR152 - Illegal redefinition of local vector: '" + vec_name + "'", + exprtk_error_location)); return error_node(); } @@ -23626,7 +24430,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR147 - Failed to add new local vector '" + vec_name + "' to SEM")); + "ERR153 - Failed to add new local vector '" + vec_name + "' to SEM", + exprtk_error_location)); sem_.free_element(nse); @@ -23642,17 +24447,21 @@ namespace exprtk state_.activate_side_effect("parse_define_vector_statement()"); - lodge_symbol(vec_name,e_st_local_vector); + lodge_symbol(vec_name, e_st_local_vector); expression_node_ptr result = error_node(); if (null_initialisation) result = expression_generator_(T(0.0)); else if (vec_to_vec_initialiser) + { + expression_node_ptr vec_node = node_allocator_.allocate(vec_holder); + result = expression_generator_( details::e_assign, - node_allocator_.allocate(vec_holder), + vec_node, vec_initilizer_list[0]); + } else result = node_allocator_ .allocate >( @@ -23680,7 +24489,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR148 - Illegal redefinition of local variable: '" + str_name + "'")); + "ERR154 - Illegal redefinition of local variable: '" + str_name + "'", + exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -23711,7 +24521,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR149 - Failed to add new local string variable '" + str_name + "' to SEM")); + "ERR155 - Failed to add new local string variable '" + str_name + "' to SEM", + exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -23725,7 +24536,7 @@ namespace exprtk exprtk_debug(("parse_define_string_statement() - INFO - Added new local string variable: %s\n",nse.name.c_str())); } - lodge_symbol(str_name,e_st_local_string); + lodge_symbol(str_name, e_st_local_string); state_.activate_side_effect("parse_define_string_statement()"); @@ -23756,7 +24567,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR150 - Illegal variable definition")); + "ERR156 - Illegal variable definition", + exprtk_error_location)); return error_node(); } @@ -23776,7 +24588,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR151 - Expected a symbol for variable definition")); + "ERR157 - Expected a symbol for variable definition", + exprtk_error_location)); return error_node(); } @@ -23785,7 +24598,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR152 - Illegal redefinition of reserved keyword: '" + var_name + "'")); + "ERR158 - Illegal redefinition of reserved keyword: '" + var_name + "'", + exprtk_error_location)); return error_node(); } @@ -23794,7 +24608,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR153 - Illegal redefinition of variable '" + var_name + "'")); + "ERR159 - Illegal redefinition of variable '" + var_name + "'", + exprtk_error_location)); return error_node(); } @@ -23803,7 +24618,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR154 - Illegal redefinition of local variable: '" + var_name + "'")); + "ERR160 - Illegal redefinition of local variable: '" + var_name + "'", + exprtk_error_location)); return error_node(); } @@ -23822,16 +24638,17 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR155 - Failed to parse initialisation expression")); + "ERR161 - Failed to parse initialisation expression", + exprtk_error_location)); return error_node(); } } if ( - !token_is(token_t::e_rbracket ,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rcrlbracket,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rsqrbracket,prsrhlpr_t::e_hold) + !token_is(token_t::e_rbracket , prsrhlpr_t::e_hold) && + !token_is(token_t::e_rcrlbracket, prsrhlpr_t::e_hold) && + !token_is(token_t::e_rsqrbracket, prsrhlpr_t::e_hold) ) { if (!token_is(token_t::e_eof,prsrhlpr_t::e_hold)) @@ -23839,7 +24656,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR156 - Expected ';' after variable definition")); + "ERR162 - Expected ';' after variable definition", + exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -23866,9 +24684,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR157 - Illegal redefinition of local variable: '" + var_name + "'")); + "ERR163 - Illegal redefinition of local variable: '" + var_name + "'", + exprtk_error_location)); - free_node(node_allocator_,initialisation_expression); + free_node(node_allocator_, initialisation_expression); return error_node(); } @@ -23897,9 +24716,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR158 - Failed to add new local variable '" + var_name + "' to SEM")); + "ERR164 - Failed to add new local variable '" + var_name + "' to SEM", + exprtk_error_location)); - free_node(node_allocator_,initialisation_expression); + free_node(node_allocator_, initialisation_expression); sem_.free_element(nse); @@ -23913,7 +24733,7 @@ namespace exprtk state_.activate_side_effect("parse_define_var_statement()"); - lodge_symbol(var_name,e_st_local_variable); + lodge_symbol(var_name, e_st_local_variable); expression_node_ptr branch[2] = {0}; @@ -23933,7 +24753,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR159 - Expected a '{}' for uninitialised var definition")); + "ERR165 - Expected a '{}' for uninitialised var definition", + exprtk_error_location)); return error_node(); } @@ -23942,7 +24763,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR160 - Expected ';' after uninitialised variable definition")); + "ERR166 - Expected ';' after uninitialised variable definition", + exprtk_error_location)); return error_node(); } @@ -23958,7 +24780,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR161 - Illegal redefinition of local variable: '" + var_name + "'")); + "ERR167 - Illegal redefinition of local variable: '" + var_name + "'", + exprtk_error_location)); return error_node(); } @@ -23987,7 +24810,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR162 - Failed to add new local variable '" + var_name + "' to SEM")); + "ERR168 - Failed to add new local variable '" + var_name + "' to SEM", + exprtk_error_location)); sem_.free_element(nse); @@ -23998,7 +24822,7 @@ namespace exprtk nse.name.c_str())); } - lodge_symbol(var_name,e_st_local_variable); + lodge_symbol(var_name, e_st_local_variable); state_.activate_side_effect("parse_uninitialised_var_statement()"); @@ -24019,7 +24843,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR163 - Expected '(' at start of swap statement")); + "ERR169 - Expected '(' at start of swap statement", + exprtk_error_location)); return error_node(); } @@ -24037,7 +24862,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR164 - Expected a symbol for variable or vector element definition")); + "ERR170 - Expected a symbol for variable or vector element definition", + exprtk_error_location)); return error_node(); } @@ -24048,7 +24874,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR165 - First parameter to swap is an invalid vector element: '" + var0_name + "'")); + "ERR171 - First parameter to swap is an invalid vector element: '" + var0_name + "'", + exprtk_error_location)); return error_node(); } @@ -24073,14 +24900,15 @@ namespace exprtk variable0 = se.var_node; } - lodge_symbol(var0_name,e_st_variable); + lodge_symbol(var0_name, e_st_variable); if (0 == variable0) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR166 - First parameter to swap is an invalid variable: '" + var0_name + "'")); + "ERR172 - First parameter to swap is an invalid variable: '" + var0_name + "'", + exprtk_error_location)); return error_node(); } @@ -24093,7 +24921,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR167 - Expected ',' between parameters to swap")); + "ERR173 - Expected ',' between parameters to swap", + exprtk_error_location)); if (variable0_generated) { @@ -24110,7 +24939,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR168 - Expected a symbol for variable or vector element definition")); + "ERR174 - Expected a symbol for variable or vector element definition", + exprtk_error_location)); if (variable0_generated) { @@ -24126,7 +24956,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR169 - Second parameter to swap is an invalid vector element: '" + var1_name + "'")); + "ERR175 - Second parameter to swap is an invalid vector element: '" + var1_name + "'", + exprtk_error_location)); if (variable0_generated) { @@ -24156,14 +24987,15 @@ namespace exprtk variable1 = se.var_node; } - lodge_symbol(var1_name,e_st_variable); + lodge_symbol(var1_name, e_st_variable); if (0 == variable1) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR170 - Second parameter to swap is an invalid variable: '" + var1_name + "'")); + "ERR176 - Second parameter to swap is an invalid variable: '" + var1_name + "'", + exprtk_error_location)); if (variable0_generated) { @@ -24181,7 +25013,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR171 - Expected ')' at end of swap statement")); + "ERR177 - Expected ')' at end of swap statement", + exprtk_error_location)); if (variable0_generated) { @@ -24197,6 +25030,7 @@ namespace exprtk } typedef details::variable_node* variable_node_ptr; + variable_node_ptr v0 = variable_node_ptr(0); variable_node_ptr v1 = variable_node_ptr(0); @@ -24207,7 +25041,7 @@ namespace exprtk (0 != (v1 = dynamic_cast(variable1))) ) { - result = node_allocator_.allocate >(v0,v1); + result = node_allocator_.allocate >(v0, v1); if (variable0_generated) { @@ -24220,7 +25054,8 @@ namespace exprtk } } else - result = node_allocator_.allocate >(variable0,variable1); + result = node_allocator_.allocate > + (variable0, variable1); state_.activate_side_effect("parse_swap_statement()"); @@ -24235,7 +25070,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR172 - Return call within a return call is not allowed")); + "ERR178 - Return call within a return call is not allowed", + exprtk_error_location)); return error_node(); } @@ -24244,7 +25080,7 @@ namespace exprtk std::vector arg_list; - scoped_vec_delete sdd(*this,arg_list); + scoped_vec_delete sdd((*this),arg_list); if (!details::imatch(current_token().value,"return")) { @@ -24258,7 +25094,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR173 - Expected '[' at start of return statement")); + "ERR179 - Expected '[' at start of return statement", + exprtk_error_location)); return error_node(); } @@ -24280,7 +25117,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR174 - Expected ',' between values during call to return")); + "ERR180 - Expected ',' between values during call to return", + exprtk_error_location)); return error_node(); } @@ -24291,12 +25129,13 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR175 - Zero parameter return statement not allowed")); + "ERR181 - Zero parameter return statement not allowed", + exprtk_error_location)); return error_node(); } - lexer::token prev_token = current_token(); + const lexer::token prev_token = current_token(); if (token_is(token_t::e_rsqrbracket)) { @@ -24305,7 +25144,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR176 - Invalid ']' found during return call")); + "ERR182 - Invalid ']' found during return call", + exprtk_error_location)); return error_node(); } @@ -24357,7 +25197,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR177 - Invalid sequence of variable '"+ symbol + "' and bracket")); + "ERR183 - Invalid sequence of variable '"+ symbol + "' and bracket", + exprtk_error_location)); return false; } @@ -24404,7 +25245,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR178 - Invalid sequence of brackets")); + "ERR184 - Invalid sequence of brackets", + exprtk_error_location)); return false; } @@ -24436,7 +25278,7 @@ namespace exprtk if (!post_variable_process(symbol)) return error_node(); - lodge_symbol(symbol,e_st_variable); + lodge_symbol(symbol, e_st_variable); next_token(); return variable; @@ -24447,12 +25289,12 @@ namespace exprtk { scope_element& se = sem_.get_active_element(symbol); - if (se.active && (se.name == symbol)) + if (se.active && details::imatch(se.name, symbol)) { if (scope_element::e_variable == se.type) { se.active = true; - lodge_symbol(symbol,e_st_local_variable); + lodge_symbol(symbol, e_st_local_variable); if (!post_variable_process(symbol)) return error_node(); @@ -24488,7 +25330,7 @@ namespace exprtk if (function) { - lodge_symbol(symbol,e_st_function); + lodge_symbol(symbol, e_st_function); expression_node_ptr func_node = parse_function_invocation(function,symbol); @@ -24500,7 +25342,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR179 - Failed to generate node for function: '" + symbol + "'")); + "ERR185 - Failed to generate node for function: '" + symbol + "'", + exprtk_error_location)); return error_node(); } @@ -24513,10 +25356,10 @@ namespace exprtk if (vararg_function) { - lodge_symbol(symbol,e_st_function); + lodge_symbol(symbol, e_st_function); expression_node_ptr vararg_func_node = - parse_vararg_function_call(vararg_function,symbol); + parse_vararg_function_call(vararg_function, symbol); if (vararg_func_node) return vararg_func_node; @@ -24525,7 +25368,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR180 - Failed to generate node for vararg function: '" + symbol + "'")); + "ERR186 - Failed to generate node for vararg function: '" + symbol + "'", + exprtk_error_location)); return error_node(); } @@ -24538,10 +25382,10 @@ namespace exprtk if (generic_function) { - lodge_symbol(symbol,e_st_function); + lodge_symbol(symbol, e_st_function); expression_node_ptr genericfunc_node = - parse_generic_function_call(generic_function,symbol); + parse_generic_function_call(generic_function, symbol); if (genericfunc_node) return genericfunc_node; @@ -24550,7 +25394,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR181 - Failed to generate node for generic function: '" + symbol + "'")); + "ERR187 - Failed to generate node for generic function: '" + symbol + "'", + exprtk_error_location)); return error_node(); } @@ -24564,10 +25409,10 @@ namespace exprtk if (string_function) { - lodge_symbol(symbol,e_st_function); + lodge_symbol(symbol, e_st_function); expression_node_ptr stringfunc_node = - parse_string_function_call(string_function,symbol); + parse_string_function_call(string_function, symbol); if (stringfunc_node) return stringfunc_node; @@ -24576,7 +25421,34 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR182 - Failed to generate node for string function: '" + symbol + "'")); + "ERR188 - Failed to generate node for string function: '" + symbol + "'", + exprtk_error_location)); + + return error_node(); + } + } + } + + { + // Are we dealing with a vararg overloaded scalar/string returning function? + igeneric_function* overload_function = symtab_store_.get_overload_function(symbol); + + if (overload_function) + { + lodge_symbol(symbol, e_st_function); + + expression_node_ptr overloadfunc_node = + parse_overload_function_call(overload_function, symbol); + + if (overloadfunc_node) + return overloadfunc_node; + else + { + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR189 - Failed to generate node for overload function: '" + symbol + "'", + exprtk_error_location)); return error_node(); } @@ -24587,18 +25459,22 @@ namespace exprtk // Are we dealing with a vector? if (symtab_store_.is_vector(symbol)) { - lodge_symbol(symbol,e_st_vector); + lodge_symbol(symbol, e_st_vector); return parse_vector(); } if (details::is_reserved_symbol(symbol)) { - if (settings_.function_enabled(symbol) || !details::is_base_function(symbol)) + if ( + settings_.function_enabled(symbol) || + !details::is_base_function(symbol) + ) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR183 - Invalid use of reserved symbol '" + symbol + "'")); + "ERR190 - Invalid use of reserved symbol '" + symbol + "'", + exprtk_error_location)); return error_node(); } @@ -24610,12 +25486,14 @@ namespace exprtk if (!(settings_.rsrvd_sym_usr_disabled() && details::is_reserved_symbol(symbol))) { symbol_table_t& symtab = symtab_store_.get_symbol_table(); + std::string error_message; if (unknown_symbol_resolver::e_usrmode_default == unknown_symbol_resolver_->mode) { T default_value = T(0); - typename unknown_symbol_resolver::usr_symbol_type usr_symbol_type; + + typename unknown_symbol_resolver::usr_symbol_type usr_symbol_type = unknown_symbol_resolver::e_usr_unknown_type; if (unknown_symbol_resolver_->process(symbol, usr_symbol_type, default_value, error_message)) { @@ -24643,7 +25521,7 @@ namespace exprtk var = expression_generator_(var->value()); } - lodge_symbol(symbol,e_st_variable); + lodge_symbol(symbol, e_st_variable); if (!post_variable_process(symbol)) return error_node(); @@ -24658,34 +25536,29 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR184 - Failed to create variable: '" + symbol + "'" + - (error_message.empty() ? "" : " - " + error_message))); + "ERR191 - Failed to create variable: '" + symbol + "'" + + (error_message.empty() ? "" : " - " + error_message), + exprtk_error_location)); } else if (unknown_symbol_resolver::e_usrmode_extended == unknown_symbol_resolver_->mode) { if (unknown_symbol_resolver_->process(symbol, symtab, error_message)) { - static bool usr_extmode_active = false; + expression_node_ptr result = parse_symtab_symbol(); - if (!usr_extmode_active) + if (result) { - usr_extmode_active = true; - expression_node_ptr result = parse_symtab_symbol(); - usr_extmode_active = false; - - if (result) - { - return result; - } + return result; } } set_error( make_error(parser_error::e_symtab, current_token(), - "ERR185 - Failed to resolve symbol: '" + symbol + "'" + - (error_message.empty() ? "" : " - " + error_message))); + "ERR192 - Failed to resolve symbol: '" + symbol + "'" + + (error_message.empty() ? "" : " - " + error_message), + exprtk_error_location)); } return error_node(); @@ -24695,7 +25568,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR186 - Undefined symbol: '" + symbol + "'")); + "ERR193 - Undefined symbol: '" + symbol + "'", + exprtk_error_location)); return error_node(); } @@ -24723,35 +25597,35 @@ namespace exprtk return parse_base_operation(); } else if ( - details::imatch(current_token().value,symbol_if) && + details::imatch(current_token().value, symbol_if) && settings_.control_struct_enabled(current_token().value) ) { return parse_conditional_statement(); } else if ( - details::imatch(current_token().value,symbol_while) && + details::imatch(current_token().value, symbol_while) && settings_.control_struct_enabled(current_token().value) ) { return parse_while_loop(); } else if ( - details::imatch(current_token().value,symbol_repeat) && + details::imatch(current_token().value, symbol_repeat) && settings_.control_struct_enabled(current_token().value) ) { return parse_repeat_until_loop(); } else if ( - details::imatch(current_token().value,symbol_for) && + details::imatch(current_token().value, symbol_for) && settings_.control_struct_enabled(current_token().value) ) { return parse_for_loop(); } else if ( - details::imatch(current_token().value,symbol_switch) && + details::imatch(current_token().value, symbol_switch) && settings_.control_struct_enabled(current_token().value) ) { @@ -24761,31 +25635,31 @@ namespace exprtk { return parse_special_function(); } - else if (details::imatch(current_token().value,symbol_null)) + else if (details::imatch(current_token().value, symbol_null)) { return parse_null_statement(); } #ifndef exprtk_disable_break_continue - else if (details::imatch(current_token().value,symbol_break)) + else if (details::imatch(current_token().value, symbol_break)) { return parse_break_statement(); } - else if (details::imatch(current_token().value,symbol_continue)) + else if (details::imatch(current_token().value, symbol_continue)) { return parse_continue_statement(); } #endif - else if (details::imatch(current_token().value,symbol_var)) + else if (details::imatch(current_token().value, symbol_var)) { return parse_define_var_statement(); } - else if (details::imatch(current_token().value,symbol_swap)) + else if (details::imatch(current_token().value, symbol_swap)) { return parse_swap_statement(); } #ifndef exprtk_disable_return_statement else if ( - details::imatch(current_token().value,symbol_return) && + details::imatch(current_token().value, symbol_return) && settings_.control_struct_enabled(current_token().value) ) { @@ -24801,7 +25675,8 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR187 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value)); + "ERR194 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value, + exprtk_error_location)); return error_node(); } @@ -24815,9 +25690,21 @@ namespace exprtk { T numeric_value = T(0); - if (details::string_to_real(current_token().value,numeric_value)) + if (details::string_to_real(current_token().value, numeric_value)) { expression_node_ptr literal_exp = expression_generator_(numeric_value); + + if (0 == literal_exp) + { + set_error( + make_error(parser_error::e_numeric, + current_token(), + "ERR195 - Failed generate node for scalar: '" + current_token().value + "'", + exprtk_error_location)); + + return error_node(); + } + next_token(); branch = literal_exp; } @@ -24826,7 +25713,8 @@ namespace exprtk set_error( make_error(parser_error::e_numeric, current_token(), - "ERR188 - Failed to convert '" + current_token().value + "' to a number")); + "ERR196 - Failed to convert '" + current_token().value + "' to a number", + exprtk_error_location)); return error_node(); } @@ -24852,7 +25740,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR189 - Expected ')' instead of: '" + current_token().value + "'")); + "ERR197 - Expected ')' instead of: '" + current_token().value + "'", + exprtk_error_location)); free_node(node_allocator_,branch); @@ -24876,7 +25765,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR190 - Expected ']' instead of: '" + current_token().value + "'")); + "ERR198 - Expected ']' instead of: '" + current_token().value + "'", + exprtk_error_location)); free_node(node_allocator_,branch); @@ -24900,7 +25790,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR191 - Expected '}' instead of: '" + current_token().value + "'")); + "ERR199 - Expected '}' instead of: '" + current_token().value + "'", + exprtk_error_location)); free_node(node_allocator_,branch); @@ -24939,7 +25830,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR192 - Premature end of expression[1]")); + "ERR200 - Premature end of expression[1]", + exprtk_error_location)); return error_node(); } @@ -24948,7 +25840,8 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR193 - Premature end of expression[2]")); + "ERR201 - Premature end of expression[2]", + exprtk_error_location)); return error_node(); } @@ -25121,33 +26014,33 @@ namespace exprtk return true; } - inline details::operator_type get_operator(const binary_functor_t& bop) + inline details::operator_type get_operator(const binary_functor_t& bop) const { return (*inv_binary_op_map_).find(bop)->second; } - inline expression_node_ptr operator()(const Type& v) const + inline expression_node_ptr operator() (const Type& v) const { return node_allocator_->allocate(v); } #ifndef exprtk_disable_string_capabilities - inline expression_node_ptr operator()(const std::string& s) const + inline expression_node_ptr operator() (const std::string& s) const { return node_allocator_->allocate(s); } - inline expression_node_ptr operator()(std::string& s, range_t& rp) const + inline expression_node_ptr operator() (std::string& s, range_t& rp) const { return node_allocator_->allocate_rr(s,rp); } - inline expression_node_ptr operator()(const std::string& s, range_t& rp) const + inline expression_node_ptr operator() (const std::string& s, range_t& rp) const { return node_allocator_->allocate_tt(s,rp); } - inline expression_node_ptr operator()(expression_node_ptr branch, range_t& rp) const + inline expression_node_ptr operator() (expression_node_ptr branch, range_t& rp) const { if (is_generally_string_node(branch)) return node_allocator_->allocate_tt(branch,rp); @@ -25180,9 +26073,9 @@ namespace exprtk (details::e_frac == operation) || (details::e_trunc == operation) ; } - inline bool sf3_optimisable(const std::string& sf3id, trinary_functor_t& tfunc) + inline bool sf3_optimisable(const std::string& sf3id, trinary_functor_t& tfunc) const { - typename sf3_map_t::iterator itr = sf3_map_->find(sf3id); + typename sf3_map_t::const_iterator itr = sf3_map_->find(sf3id); if (sf3_map_->end() == itr) return false; @@ -25192,9 +26085,9 @@ namespace exprtk return true; } - inline bool sf4_optimisable(const std::string& sf4id, quaternary_functor_t& qfunc) + inline bool sf4_optimisable(const std::string& sf4id, quaternary_functor_t& qfunc) const { - typename sf4_map_t::iterator itr = sf4_map_->find(sf4id); + typename sf4_map_t::const_iterator itr = sf4_map_->find(sf4id); if (sf4_map_->end() == itr) return false; @@ -25204,9 +26097,9 @@ namespace exprtk return true; } - inline bool sf3_optimisable(const std::string& sf3id, details::operator_type& operation) + inline bool sf3_optimisable(const std::string& sf3id, details::operator_type& operation) const { - typename sf3_map_t::iterator itr = sf3_map_->find(sf3id); + typename sf3_map_t::const_iterator itr = sf3_map_->find(sf3id); if (sf3_map_->end() == itr) return false; @@ -25216,9 +26109,9 @@ namespace exprtk return true; } - inline bool sf4_optimisable(const std::string& sf4id, details::operator_type& operation) + inline bool sf4_optimisable(const std::string& sf4id, details::operator_type& operation) const { - typename sf4_map_t::iterator itr = sf4_map_->find(sf4id); + typename sf4_map_t::const_iterator itr = sf4_map_->find(sf4id); if (sf4_map_->end() == itr) return false; @@ -25228,22 +26121,36 @@ namespace exprtk return true; } - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[1]) + inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr (&branch)[1]) { if (0 == branch[0]) + { return error_node(); + } else if (details::is_null_node(branch[0])) + { return branch[0]; + } else if (details::is_break_node(branch[0])) + { return error_node(); + } else if (details::is_continue_node(branch[0])) + { return error_node(); + } else if (details::is_constant_node(branch[0])) + { return synthesize_expression(operation,branch); + } else if (unary_optimisable(operation) && details::is_variable_node(branch[0])) + { return synthesize_uv_expression(operation,branch); + } else if (unary_optimisable(operation) && details::is_ivector_node(branch[0])) + { return synthesize_uvec_expression(operation,branch); + } else return synthesize_unary_expression(operation,branch); } @@ -25251,11 +26158,11 @@ namespace exprtk inline bool is_assignment_operation(const details::operator_type& operation) const { return ( - (details::e_addass == operation) || - (details::e_subass == operation) || - (details::e_mulass == operation) || - (details::e_divass == operation) || - (details::e_modass == operation) + (details::e_addass == operation) || + (details::e_subass == operation) || + (details::e_mulass == operation) || + (details::e_divass == operation) || + (details::e_modass == operation) ) && parser_->settings_.assignment_enabled(operation); } @@ -25288,24 +26195,24 @@ namespace exprtk { switch (operation) { - case details::e_add : return "+"; - case details::e_sub : return "-"; - case details::e_mul : return "*"; - case details::e_div : return "/"; - case details::e_mod : return "%"; - case details::e_pow : return "^"; - case details::e_lt : return "<"; - case details::e_lte : return "<="; - case details::e_gt : return ">"; - case details::e_gte : return ">="; - case details::e_eq : return "=="; - case details::e_ne : return "!="; - case details::e_and : return "and"; - case details::e_nand : return "nand"; - case details::e_or : return "or"; - case details::e_nor : return "nor"; - case details::e_xor : return "xor"; - case details::e_xnor : return "xnor"; + case details::e_add : return "+" ; + case details::e_sub : return "-" ; + case details::e_mul : return "*" ; + case details::e_div : return "/" ; + case details::e_mod : return "%" ; + case details::e_pow : return "^" ; + case details::e_lt : return "<" ; + case details::e_lte : return "<=" ; + case details::e_gt : return ">" ; + case details::e_gte : return ">=" ; + case details::e_eq : return "==" ; + case details::e_ne : return "!=" ; + case details::e_and : return "and" ; + case details::e_nand : return "nand" ; + case details::e_or : return "or" ; + case details::e_nor : return "nor" ; + case details::e_xor : return "xor" ; + case details::e_xnor : return "xnor" ; default : return "UNKNOWN"; } } @@ -25332,7 +26239,7 @@ namespace exprtk (details::e_xnor == operation) ; } - inline std::string branch_to_id(expression_node_ptr branch) + inline std::string branch_to_id(expression_node_ptr branch) const { static const std::string null_str ("(null)" ); static const std::string const_str ("(c)" ); @@ -25373,7 +26280,7 @@ namespace exprtk return "ERROR"; } - inline std::string branch_to_id(expression_node_ptr (&branch)[2]) + inline std::string branch_to_id(expression_node_ptr (&branch)[2]) const { return branch_to_id(branch[0]) + std::string("o") + branch_to_id(branch[1]); } @@ -25383,7 +26290,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (details::is_constant_node(branch[0]) && details::is_variable_node(branch[1])); + return details::is_constant_node(branch[0]) && + details::is_variable_node(branch[1]) ; } inline bool voc_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25391,7 +26299,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (details::is_variable_node(branch[0]) && details::is_constant_node(branch[1])); + return details::is_variable_node(branch[0]) && + details::is_constant_node(branch[1]) ; } inline bool vov_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25399,7 +26308,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (details::is_variable_node(branch[0]) && details::is_variable_node(branch[1])); + return details::is_variable_node(branch[0]) && + details::is_variable_node(branch[1]) ; } inline bool cob_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25407,7 +26317,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (details::is_constant_node(branch[0]) && !details::is_constant_node(branch[1])); + return details::is_constant_node(branch[0]) && + !details::is_constant_node(branch[1]) ; } inline bool boc_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25415,7 +26326,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (!details::is_constant_node(branch[0]) && details::is_constant_node(branch[1])); + return !details::is_constant_node(branch[0]) && + details::is_constant_node(branch[1]) ; } inline bool cocob_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25428,7 +26340,7 @@ namespace exprtk ) { return (details::is_constant_node(branch[0]) && details::is_cob_node(branch[1])) || - (details::is_constant_node(branch[1]) && details::is_cob_node(branch[0])); + (details::is_constant_node(branch[1]) && details::is_cob_node(branch[0])) ; } else return false; @@ -25444,7 +26356,7 @@ namespace exprtk ) { return (details::is_constant_node(branch[0]) && details::is_boc_node(branch[1])) || - (details::is_constant_node(branch[1]) && details::is_boc_node(branch[0])); + (details::is_constant_node(branch[1]) && details::is_boc_node(branch[0])) ; } else return false; @@ -25455,7 +26367,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (details::is_uv_node(branch[0]) && details::is_uv_node(branch[1])); + return details::is_uv_node(branch[0]) && + details::is_uv_node(branch[1]) ; } inline bool vob_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25463,7 +26376,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (details::is_variable_node(branch[0]) && !details::is_variable_node(branch[1])); + return details::is_variable_node(branch[0]) && + !details::is_variable_node(branch[1]) ; } inline bool bov_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25471,7 +26385,8 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (!details::is_variable_node(branch[0]) && details::is_variable_node(branch[1])); + return !details::is_variable_node(branch[0]) && + details::is_variable_node(branch[1]) ; } inline bool binext_optimisable(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const @@ -25479,10 +26394,11 @@ namespace exprtk if (!operation_optimisable(operation)) return false; else - return (!details::is_constant_node(branch[0]) || !details::is_constant_node(branch[1])); + return !details::is_constant_node(branch[0]) || + !details::is_constant_node(branch[1]) ; } - inline bool is_invalid_assignment_op(const details::operator_type& operation, expression_node_ptr (&branch)[2]) + inline bool is_invalid_assignment_op(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const { if (is_assignment_operation(operation)) { @@ -25504,14 +26420,14 @@ namespace exprtk return false; } - inline bool is_constpow_operation(const details::operator_type& operation, expression_node_ptr(&branch)[2]) + inline bool is_constpow_operation(const details::operator_type& operation, expression_node_ptr(&branch)[2]) const { if ( - !is_constant_node(branch[1]) || - is_constant_node(branch[0]) || - is_variable_node(branch[0]) || - is_vector_node (branch[0]) || - is_generally_string_node(branch[0]) + !details::is_constant_node(branch[1]) || + details::is_constant_node(branch[0]) || + details::is_variable_node(branch[0]) || + details::is_vector_node (branch[0]) || + details::is_generally_string_node(branch[0]) ) return false; @@ -25520,7 +26436,7 @@ namespace exprtk return cardinal_pow_optimisable(operation, c); } - inline bool is_invalid_break_continue_op(expression_node_ptr (&branch)[2]) + inline bool is_invalid_break_continue_op(expression_node_ptr (&branch)[2]) const { return ( details::is_break_node (branch[0]) || @@ -25530,7 +26446,7 @@ namespace exprtk ); } - inline bool is_invalid_string_op(const details::operator_type& operation, expression_node_ptr (&branch)[2]) + inline bool is_invalid_string_op(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const { const bool b0_string = is_generally_string_node(branch[0]); const bool b1_string = is_generally_string_node(branch[1]); @@ -25550,7 +26466,7 @@ namespace exprtk return result; } - inline bool is_invalid_string_op(const details::operator_type& operation, expression_node_ptr (&branch)[3]) + inline bool is_invalid_string_op(const details::operator_type& operation, expression_node_ptr (&branch)[3]) const { const bool b0_string = is_generally_string_node(branch[0]); const bool b1_string = is_generally_string_node(branch[1]); @@ -25571,7 +26487,7 @@ namespace exprtk return result; } - inline bool is_string_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) + inline bool is_string_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const { const bool b0_string = is_generally_string_node(branch[0]); const bool b1_string = is_generally_string_node(branch[1]); @@ -25579,7 +26495,7 @@ namespace exprtk return (b0_string && b1_string && valid_string_operation(operation)); } - inline bool is_string_operation(const details::operator_type& operation, expression_node_ptr (&branch)[3]) + inline bool is_string_operation(const details::operator_type& operation, expression_node_ptr (&branch)[3]) const { const bool b0_string = is_generally_string_node(branch[0]); const bool b1_string = is_generally_string_node(branch[1]); @@ -25589,7 +26505,7 @@ namespace exprtk } #ifndef exprtk_disable_sc_andor - inline bool is_shortcircuit_expression(const details::operator_type& operation) + inline bool is_shortcircuit_expression(const details::operator_type& operation) const { return ( (details::e_scand == operation) || @@ -25597,13 +26513,13 @@ namespace exprtk ); } #else - inline bool is_shortcircuit_expression(const details::operator_type&) + inline bool is_shortcircuit_expression(const details::operator_type&) const { return false; } #endif - inline bool is_null_present(expression_node_ptr (&branch)[2]) + inline bool is_null_present(expression_node_ptr (&branch)[2]) const { return ( details::is_null_node(branch[0]) || @@ -25611,29 +26527,29 @@ namespace exprtk ); } - inline bool is_vector_eqineq_logic_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) + inline bool is_vector_eqineq_logic_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const { if (!is_ivector_node(branch[0]) && !is_ivector_node(branch[1])) return false; else return ( - (details::e_lt == operation) || - (details::e_lte == operation) || - (details::e_gt == operation) || - (details::e_gte == operation) || - (details::e_eq == operation) || - (details::e_ne == operation) || - (details::e_equal == operation) || - (details::e_and == operation) || - (details::e_nand == operation) || - (details:: e_or == operation) || - (details:: e_nor == operation) || - (details:: e_xor == operation) || - (details::e_xnor == operation) + (details::e_lt == operation) || + (details::e_lte == operation) || + (details::e_gt == operation) || + (details::e_gte == operation) || + (details::e_eq == operation) || + (details::e_ne == operation) || + (details::e_equal == operation) || + (details::e_and == operation) || + (details::e_nand == operation) || + (details:: e_or == operation) || + (details:: e_nor == operation) || + (details:: e_xor == operation) || + (details::e_xnor == operation) ); } - inline bool is_vector_arithmetic_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) + inline bool is_vector_arithmetic_operation(const details::operator_type& operation, expression_node_ptr (&branch)[2]) const { if (!is_ivector_node(branch[0]) && !is_ivector_node(branch[1])) return false; @@ -25647,42 +26563,70 @@ namespace exprtk ); } - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[2]) + inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr (&branch)[2]) { if ((0 == branch[0]) || (0 == branch[1])) + { return error_node(); + } else if (is_invalid_string_op(operation,branch)) + { return error_node(); + } else if (is_invalid_assignment_op(operation,branch)) + { return error_node(); + } else if (is_invalid_break_continue_op(branch)) + { return error_node(); + } else if (details::e_assign == operation) - return synthesize_assignment_expression(operation,branch); + { + return synthesize_assignment_expression(operation, branch); + } else if (details::e_swap == operation) + { return synthesize_swap_expression(branch); + } else if (is_assignment_operation(operation)) - return synthesize_assignment_operation_expression(operation,branch); - else if (is_vector_eqineq_logic_operation(operation,branch)) - return synthesize_veceqineqlogic_operation_expression(operation,branch); - else if (is_vector_arithmetic_operation(operation,branch)) - return synthesize_vecarithmetic_operation_expression(operation,branch); + { + return synthesize_assignment_operation_expression(operation, branch); + } + else if (is_vector_eqineq_logic_operation(operation, branch)) + { + return synthesize_veceqineqlogic_operation_expression(operation, branch); + } + else if (is_vector_arithmetic_operation(operation, branch)) + { + return synthesize_vecarithmetic_operation_expression(operation, branch); + } else if (is_shortcircuit_expression(operation)) - return synthesize_shortcircuit_expression(operation,branch); - else if (is_string_operation(operation,branch)) - return synthesize_string_expression(operation,branch); + { + return synthesize_shortcircuit_expression(operation, branch); + } + else if (is_string_operation(operation, branch)) + { + return synthesize_string_expression(operation, branch); + } else if (is_null_present(branch)) + { return synthesize_null_expression(operation, branch); + } #ifndef exprtk_disable_cardinal_pow_optimisation else if (is_constpow_operation(operation, branch)) + { return cardinal_pow_optimisation(branch); + } #endif expression_node_ptr result = error_node(); #ifndef exprtk_disable_enhanced_features - if (synthesize_expression(operation,branch,result)) + if (synthesize_expression(operation, branch, result)) + { return result; + } else #endif @@ -25696,36 +26640,54 @@ namespace exprtk */ result = error_node(); - if (cocob_optimisable(operation,branch)) - result = synthesize_cocob_expression::process(*this,operation,branch); - else if (coboc_optimisable(operation,branch) && (0 == result)) - result = synthesize_coboc_expression::process(*this,operation,branch); + if (cocob_optimisable(operation, branch)) + { + result = synthesize_cocob_expression::process((*this), operation, branch); + } + else if (coboc_optimisable(operation, branch) && (0 == result)) + { + result = synthesize_coboc_expression::process((*this), operation, branch); + } if (result) return result; } - if (uvouv_optimisable(operation,branch)) - return synthesize_uvouv_expression(operation,branch); - else if (vob_optimisable(operation,branch)) - return synthesize_vob_expression::process(*this,operation,branch); - else if (bov_optimisable(operation,branch)) - return synthesize_bov_expression::process(*this,operation,branch); - else if (cob_optimisable(operation,branch)) - return synthesize_cob_expression::process(*this,operation,branch); - else if (boc_optimisable(operation,branch)) - return synthesize_boc_expression::process(*this,operation,branch); + if (uvouv_optimisable(operation, branch)) + { + return synthesize_uvouv_expression(operation, branch); + } + else if (vob_optimisable(operation, branch)) + { + return synthesize_vob_expression::process((*this), operation, branch); + } + else if (bov_optimisable(operation, branch)) + { + return synthesize_bov_expression::process((*this), operation, branch); + } + else if (cob_optimisable(operation, branch)) + { + return synthesize_cob_expression::process((*this), operation, branch); + } + else if (boc_optimisable(operation, branch)) + { + return synthesize_boc_expression::process((*this), operation, branch); + } #ifndef exprtk_disable_enhanced_features - else if (cov_optimisable(operation,branch)) - return synthesize_cov_expression::process(*this,operation,branch); + else if (cov_optimisable(operation, branch)) + { + return synthesize_cov_expression::process((*this), operation, branch); + } #endif - else if (binext_optimisable(operation,branch)) - return synthesize_binary_ext_expression::process(*this,operation,branch); + else if (binext_optimisable(operation, branch)) + { + return synthesize_binary_ext_expression::process((*this), operation, branch); + } else - return synthesize_expression(operation,branch); + return synthesize_expression(operation, branch); } - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[3]) + inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr (&branch)[3]) { if ( (0 == branch[0]) || @@ -25737,34 +26699,42 @@ namespace exprtk return error_node(); } - else if (is_invalid_string_op(operation,branch)) + else if (is_invalid_string_op(operation, branch)) + { return error_node(); - else if (is_string_operation(operation,branch)) - return synthesize_string_expression(operation,branch); + } + else if (is_string_operation(operation, branch)) + { + return synthesize_string_expression(operation, branch); + } else - return synthesize_expression(operation,branch); + return synthesize_expression(operation, branch); } - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr (&branch)[4]) + inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr (&branch)[4]) { return synthesize_expression(operation,branch); } - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr b0) + inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr b0) { expression_node_ptr branch[1] = { b0 }; return (*this)(operation,branch); } - inline expression_node_ptr operator()(const details::operator_type& operation, expression_node_ptr b0, expression_node_ptr b1) + inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr& b0, expression_node_ptr& b1) { - if ((0 == b0) || (0 == b1)) - return error_node(); - else + expression_node_ptr result = error_node(); + + if ((0 != b0) && (0 != b1)) { expression_node_ptr branch[2] = { b0, b1 }; - return expression_generator::operator()(operation,branch); + result = expression_generator::operator()(operation, branch); + b0 = branch[0]; + b1 = branch[1]; } + + return result; } inline expression_node_ptr conditional(expression_node_ptr condition, @@ -25773,9 +26743,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,consequent ); - free_node(*node_allocator_,alternative); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, consequent); + free_node(*node_allocator_, alternative); return error_node(); } @@ -25785,16 +26755,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,alternative); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,consequent); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -25805,11 +26775,11 @@ namespace exprtk else if ((0 != consequent) && (0 != alternative)) { return node_allocator_-> - allocate(condition,consequent,alternative); + allocate(condition, consequent, alternative); } else return node_allocator_-> - allocate(condition,consequent); + allocate(condition, consequent); } #ifndef exprtk_disable_string_capabilities @@ -25819,9 +26789,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,consequent ); - free_node(*node_allocator_,alternative); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, consequent); + free_node(*node_allocator_, alternative); return error_node(); } @@ -25831,16 +26801,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,alternative); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,consequent); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -25851,7 +26821,7 @@ namespace exprtk } else if ((0 != consequent) && (0 != alternative)) return node_allocator_-> - allocate(condition,consequent,alternative); + allocate(condition, consequent, alternative); else return error_node(); } @@ -25878,7 +26848,7 @@ namespace exprtk result = node_allocator_->allocate >(); free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); + free_node(*node_allocator_, branch); return result; } @@ -25904,7 +26874,10 @@ namespace exprtk { if (!brkcont && details::is_constant_node(condition)) { - if (details::is_true(condition) && details::is_constant_node(branch)) + if ( + details::is_true(condition) && + details::is_constant_node(branch) + ) { free_node(*node_allocator_,condition); @@ -25912,7 +26885,7 @@ namespace exprtk } free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); + free_node(*node_allocator_, branch); return error_node(); } @@ -25948,39 +26921,46 @@ namespace exprtk else result = node_allocator_->allocate >(); - free_node(*node_allocator_,initialiser); - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,incrementor); - free_node(*node_allocator_,loop_body ); + free_node(*node_allocator_, initialiser); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, incrementor); + free_node(*node_allocator_, loop_body); return result; } - else if (details::is_null_node(condition)) + else if (details::is_null_node(condition) || (0 == condition)) { - free_node(*node_allocator_,initialiser); - free_node(*node_allocator_,condition ); - free_node(*node_allocator_,incrementor); + free_node(*node_allocator_, initialiser); + free_node(*node_allocator_, condition); + free_node(*node_allocator_, incrementor); return loop_body; } else if (!brkcont) - return node_allocator_->allocate(initialiser, - condition, - incrementor, - loop_body); + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); + #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate(initialiser, - condition, - incrementor, - loop_body); + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); #else return error_node(); #endif } template class Sequence> + template class Sequence> inline expression_node_ptr const_optimise_switch(Sequence& arg_list) { expression_node_ptr result = error_node(); @@ -26016,7 +26996,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr const_optimise_mswitch(Sequence& arg_list) { expression_node_ptr result = error_node(); @@ -26063,6 +27043,7 @@ namespace exprtk static inline T process(const arg_list_t& arg) { case_stmt(0) + return arg.back()->value(); } }; @@ -26072,6 +27053,7 @@ namespace exprtk static inline T process(const arg_list_t& arg) { case_stmt(0) case_stmt(1) + return arg.back()->value(); } }; @@ -26082,6 +27064,7 @@ namespace exprtk { case_stmt(0) case_stmt(1) case_stmt(2) + return arg.back()->value(); } }; @@ -26092,6 +27075,7 @@ namespace exprtk { case_stmt(0) case_stmt(1) case_stmt(2) case_stmt(3) + return arg.back()->value(); } }; @@ -26103,6 +27087,7 @@ namespace exprtk case_stmt(0) case_stmt(1) case_stmt(2) case_stmt(3) case_stmt(4) + return arg.back()->value(); } }; @@ -26114,6 +27099,7 @@ namespace exprtk case_stmt(0) case_stmt(1) case_stmt(2) case_stmt(3) case_stmt(4) case_stmt(5) + return arg.back()->value(); } }; @@ -26126,6 +27112,7 @@ namespace exprtk case_stmt(2) case_stmt(3) case_stmt(4) case_stmt(5) case_stmt(6) + return arg.back()->value(); } }; @@ -26134,7 +27121,7 @@ namespace exprtk }; template class Sequence> + template class Sequence> inline expression_node_ptr switch_statement(Sequence& arg_list) { if (arg_list.empty()) @@ -26174,7 +27161,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr multi_switch_statement(Sequence& arg_list) { if (!all_nodes_valid(arg_list)) @@ -26189,47 +27176,47 @@ namespace exprtk return node_allocator_->allocate >(arg_list); } - #define unary_opr_switch_statements \ - case_stmt(details:: e_abs,details:: abs_op) \ - case_stmt(details:: e_acos,details:: acos_op) \ - case_stmt(details::e_acosh,details::acosh_op) \ - case_stmt(details:: e_asin,details:: asin_op) \ - case_stmt(details::e_asinh,details::asinh_op) \ - case_stmt(details:: e_atan,details:: atan_op) \ - case_stmt(details::e_atanh,details::atanh_op) \ - case_stmt(details:: e_ceil,details:: ceil_op) \ - case_stmt(details:: e_cos,details:: cos_op) \ - case_stmt(details:: e_cosh,details:: cosh_op) \ - case_stmt(details:: e_exp,details:: exp_op) \ - case_stmt(details::e_expm1,details::expm1_op) \ - case_stmt(details::e_floor,details::floor_op) \ - case_stmt(details:: e_log,details:: log_op) \ - case_stmt(details::e_log10,details::log10_op) \ - case_stmt(details:: e_log2,details:: log2_op) \ - case_stmt(details::e_log1p,details::log1p_op) \ - case_stmt(details:: e_neg,details:: neg_op) \ - case_stmt(details:: e_pos,details:: pos_op) \ - case_stmt(details::e_round,details::round_op) \ - case_stmt(details:: e_sin,details:: sin_op) \ - case_stmt(details:: e_sinc,details:: sinc_op) \ - case_stmt(details:: e_sinh,details:: sinh_op) \ - case_stmt(details:: e_sqrt,details:: sqrt_op) \ - case_stmt(details:: e_tan,details:: tan_op) \ - case_stmt(details:: e_tanh,details:: tanh_op) \ - case_stmt(details:: e_cot,details:: cot_op) \ - case_stmt(details:: e_sec,details:: sec_op) \ - case_stmt(details:: e_csc,details:: csc_op) \ - case_stmt(details:: e_r2d,details:: r2d_op) \ - case_stmt(details:: e_d2r,details:: d2r_op) \ - case_stmt(details:: e_d2g,details:: d2g_op) \ - case_stmt(details:: e_g2d,details:: g2d_op) \ - case_stmt(details:: e_notl,details:: notl_op) \ - case_stmt(details:: e_sgn,details:: sgn_op) \ - case_stmt(details:: e_erf,details:: erf_op) \ - case_stmt(details:: e_erfc,details:: erfc_op) \ - case_stmt(details:: e_ncdf,details:: ncdf_op) \ - case_stmt(details:: e_frac,details:: frac_op) \ - case_stmt(details::e_trunc,details::trunc_op) \ + #define unary_opr_switch_statements \ + case_stmt(details:: e_abs, details:: abs_op) \ + case_stmt(details:: e_acos, details:: acos_op) \ + case_stmt(details::e_acosh, details::acosh_op) \ + case_stmt(details:: e_asin, details:: asin_op) \ + case_stmt(details::e_asinh, details::asinh_op) \ + case_stmt(details:: e_atan, details:: atan_op) \ + case_stmt(details::e_atanh, details::atanh_op) \ + case_stmt(details:: e_ceil, details:: ceil_op) \ + case_stmt(details:: e_cos, details:: cos_op) \ + case_stmt(details:: e_cosh, details:: cosh_op) \ + case_stmt(details:: e_exp, details:: exp_op) \ + case_stmt(details::e_expm1, details::expm1_op) \ + case_stmt(details::e_floor, details::floor_op) \ + case_stmt(details:: e_log, details:: log_op) \ + case_stmt(details::e_log10, details::log10_op) \ + case_stmt(details:: e_log2, details:: log2_op) \ + case_stmt(details::e_log1p, details::log1p_op) \ + case_stmt(details:: e_neg, details:: neg_op) \ + case_stmt(details:: e_pos, details:: pos_op) \ + case_stmt(details::e_round, details::round_op) \ + case_stmt(details:: e_sin, details:: sin_op) \ + case_stmt(details:: e_sinc, details:: sinc_op) \ + case_stmt(details:: e_sinh, details:: sinh_op) \ + case_stmt(details:: e_sqrt, details:: sqrt_op) \ + case_stmt(details:: e_tan, details:: tan_op) \ + case_stmt(details:: e_tanh, details:: tanh_op) \ + case_stmt(details:: e_cot, details:: cot_op) \ + case_stmt(details:: e_sec, details:: sec_op) \ + case_stmt(details:: e_csc, details:: csc_op) \ + case_stmt(details:: e_r2d, details:: r2d_op) \ + case_stmt(details:: e_d2r, details:: d2r_op) \ + case_stmt(details:: e_d2g, details:: d2g_op) \ + case_stmt(details:: e_g2d, details:: g2d_op) \ + case_stmt(details:: e_notl, details:: notl_op) \ + case_stmt(details:: e_sgn, details:: sgn_op) \ + case_stmt(details:: e_erf, details:: erf_op) \ + case_stmt(details:: e_erfc, details:: erfc_op) \ + case_stmt(details:: e_ncdf, details:: ncdf_op) \ + case_stmt(details:: e_frac, details:: frac_op) \ + case_stmt(details::e_trunc, details::trunc_op) \ inline expression_node_ptr synthesize_uv_expression(const details::operator_type& operation, expression_node_ptr (&branch)[1]) @@ -26256,7 +27243,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ allocate > > \ - (operation,branch[0]); \ + (operation, branch[0]); \ unary_opr_switch_statements #undef case_stmt @@ -26289,8 +27276,8 @@ namespace exprtk #define case_stmt(op) \ case details::e_sf##op : temp_node = node_allocator_-> \ allocate > > \ - (operation,branch); \ - break; \ + (operation, branch); \ + break; \ case_stmt(00) case_stmt(01) case_stmt(02) case_stmt(03) case_stmt(04) case_stmt(05) case_stmt(06) case_stmt(07) @@ -26308,7 +27295,7 @@ namespace exprtk default : return error_node(); } - T v = temp_node->value(); + const T v = temp_node->value(); details::free_node(*node_allocator_,temp_node); @@ -26328,7 +27315,7 @@ namespace exprtk #define case_stmt(op) \ case details::e_sf##op : return node_allocator_-> \ allocate_rrr > > \ - (v0,v1,v2); \ + (v0, v1, v2); \ case_stmt(00) case_stmt(01) case_stmt(02) case_stmt(03) case_stmt(04) case_stmt(05) case_stmt(06) case_stmt(07) @@ -26362,7 +27349,7 @@ namespace exprtk #define case_stmt(op) \ case details::e_sf##op : return node_allocator_-> \ allocate > > \ - (operation,branch); \ + (operation, branch); \ case_stmt(00) case_stmt(01) case_stmt(02) case_stmt(03) case_stmt(04) case_stmt(05) case_stmt(06) case_stmt(07) @@ -26391,8 +27378,8 @@ namespace exprtk #define case_stmt(op) \ case details::e_sf##op : temp_node = node_allocator_-> \ allocate > > \ - (operation,branch); \ - break; \ + (operation, branch); \ + break; \ case_stmt(48) case_stmt(49) case_stmt(50) case_stmt(51) case_stmt(52) case_stmt(53) case_stmt(54) case_stmt(55) @@ -26411,7 +27398,8 @@ namespace exprtk default : return error_node(); } - T v = temp_node->value(); + const T v = temp_node->value(); + details::free_node(*node_allocator_,temp_node); return node_allocator_->allocate(v); @@ -26431,7 +27419,7 @@ namespace exprtk #define case_stmt(op) \ case details::e_sf##op : return node_allocator_-> \ allocate_rrrr > > \ - (v0,v1,v2,v3); \ + (v0, v1, v2, v3); \ case_stmt(48) case_stmt(49) case_stmt(50) case_stmt(51) case_stmt(52) case_stmt(53) case_stmt(54) case_stmt(55) @@ -26464,7 +27452,7 @@ namespace exprtk #define case_stmt(op) \ case details::e_sf##op : return node_allocator_-> \ allocate > > \ - (operation,branch); \ + (operation, branch); \ case_stmt(48) case_stmt(49) case_stmt(50) case_stmt(51) case_stmt(52) case_stmt(53) case_stmt(54) case_stmt(55) @@ -26485,7 +27473,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr const_optimise_varargfunc(const details::operator_type& operation, Sequence& arg_list) { expression_node_ptr temp_node = error_node(); @@ -26498,25 +27486,26 @@ namespace exprtk (arg_list); \ break; \ - case_stmt(details::e_sum, details::vararg_add_op ) - case_stmt(details::e_prod, details::vararg_mul_op ) - case_stmt(details::e_avg, details::vararg_avg_op ) - case_stmt(details::e_min, details::vararg_min_op ) - case_stmt(details::e_max, details::vararg_max_op ) - case_stmt(details::e_mand, details::vararg_mand_op ) - case_stmt(details::e_mor, details::vararg_mor_op ) - case_stmt(details::e_multi,details::vararg_multi_op) + case_stmt(details::e_sum , details::vararg_add_op ) + case_stmt(details::e_prod , details::vararg_mul_op ) + case_stmt(details::e_avg , details::vararg_avg_op ) + case_stmt(details::e_min , details::vararg_min_op ) + case_stmt(details::e_max , details::vararg_max_op ) + case_stmt(details::e_mand , details::vararg_mand_op ) + case_stmt(details::e_mor , details::vararg_mor_op ) + case_stmt(details::e_multi , details::vararg_multi_op) #undef case_stmt default : return error_node(); } - T v = temp_node->value(); + const T v = temp_node->value(); + details::free_node(*node_allocator_,temp_node); return node_allocator_->allocate(v); } - inline bool special_one_parameter_vararg(const details::operator_type& operation) + inline bool special_one_parameter_vararg(const details::operator_type& operation) const { return ( (details::e_sum == operation) || @@ -26528,7 +27517,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr varnode_optimise_varargfunc(const details::operator_type& operation, Sequence& arg_list) { switch (operation) @@ -26537,21 +27526,21 @@ namespace exprtk case op0 : return node_allocator_-> \ allocate > >(arg_list); \ - case_stmt(details::e_sum, details::vararg_add_op ) - case_stmt(details::e_prod, details::vararg_mul_op ) - case_stmt(details::e_avg, details::vararg_avg_op ) - case_stmt(details::e_min, details::vararg_min_op ) - case_stmt(details::e_max, details::vararg_max_op ) - case_stmt(details::e_mand, details::vararg_mand_op ) - case_stmt(details::e_mor, details::vararg_mor_op ) - case_stmt(details::e_multi,details::vararg_multi_op) + case_stmt(details::e_sum , details::vararg_add_op ) + case_stmt(details::e_prod , details::vararg_mul_op ) + case_stmt(details::e_avg , details::vararg_avg_op ) + case_stmt(details::e_min , details::vararg_min_op ) + case_stmt(details::e_max , details::vararg_max_op ) + case_stmt(details::e_mand , details::vararg_mand_op ) + case_stmt(details::e_mor , details::vararg_mor_op ) + case_stmt(details::e_multi , details::vararg_multi_op) #undef case_stmt default : return error_node(); } } template class Sequence> + template class Sequence> inline expression_node_ptr vectorize_func(const details::operator_type& operation, Sequence& arg_list) { if (1 == arg_list.size()) @@ -26562,11 +27551,11 @@ namespace exprtk case op0 : return node_allocator_-> \ allocate > >(arg_list[0]); \ - case_stmt(details::e_sum, details::vec_add_op) - case_stmt(details::e_prod, details::vec_mul_op) - case_stmt(details::e_avg, details::vec_avg_op) - case_stmt(details::e_min, details::vec_min_op) - case_stmt(details::e_max, details::vec_max_op) + case_stmt(details::e_sum , details::vec_add_op) + case_stmt(details::e_prod , details::vec_mul_op) + case_stmt(details::e_avg , details::vec_avg_op) + case_stmt(details::e_min , details::vec_min_op) + case_stmt(details::e_max , details::vec_max_op) #undef case_stmt default : return error_node(); } @@ -26576,7 +27565,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr vararg_function(const details::operator_type& operation, Sequence& arg_list) { if (!all_nodes_valid(arg_list)) @@ -26609,14 +27598,14 @@ namespace exprtk case op0 : return node_allocator_-> \ allocate > >(arg_list); \ - case_stmt(details::e_sum, details::vararg_add_op ) - case_stmt(details::e_prod, details::vararg_mul_op ) - case_stmt(details::e_avg, details::vararg_avg_op ) - case_stmt(details::e_min, details::vararg_min_op ) - case_stmt(details::e_max, details::vararg_max_op ) - case_stmt(details::e_mand, details::vararg_mand_op ) - case_stmt(details::e_mor, details::vararg_mor_op ) - case_stmt(details::e_multi,details::vararg_multi_op) + case_stmt(details::e_sum , details::vararg_add_op ) + case_stmt(details::e_prod , details::vararg_mul_op ) + case_stmt(details::e_avg , details::vararg_avg_op ) + case_stmt(details::e_min , details::vararg_min_op ) + case_stmt(details::e_max , details::vararg_max_op ) + case_stmt(details::e_mand , details::vararg_mand_op ) + case_stmt(details::e_mor , details::vararg_mor_op ) + case_stmt(details::e_multi , details::vararg_multi_op) #undef case_stmt default : return error_node(); } @@ -26684,7 +27673,7 @@ namespace exprtk is_constant_foldable(arg_list) ) { - Type v = result->value(); + const Type v = result->value(); details::free_node(*node_allocator_,result); result = node_allocator_->allocate(v); } @@ -26714,7 +27703,7 @@ namespace exprtk if (no_psi == param_seq_index) result = node_allocator_->allocate(arg_list,gf); else - result = node_allocator_->allocate(gf,param_seq_index,arg_list); + result = node_allocator_->allocate(gf, param_seq_index, arg_list); alloc_type1* genfunc_node_ptr = static_cast(result); @@ -26726,19 +27715,24 @@ namespace exprtk ) { genfunc_node_ptr->init_branches(); - Type v = result->value(); + + const Type v = result->value(); + details::free_node(*node_allocator_,result); + return node_allocator_->allocate(v); } else if (genfunc_node_ptr->init_branches()) { parser_->state_.activate_side_effect("generic_function_call()"); + return result; } else { - details::free_node(*node_allocator_,result); - details::free_all_nodes(*node_allocator_,arg_list); + details::free_node(*node_allocator_, result); + details::free_all_nodes(*node_allocator_, arg_list); + return error_node(); } } @@ -26764,7 +27758,7 @@ namespace exprtk if (no_psi == param_seq_index) result = node_allocator_->allocate(gf,arg_list); else - result = node_allocator_->allocate(gf,param_seq_index,arg_list); + result = node_allocator_->allocate(gf, param_seq_index, arg_list); alloc_type1* strfunc_node_ptr = static_cast(result); @@ -26776,7 +27770,7 @@ namespace exprtk { strfunc_node_ptr->init_branches(); - Type v = result->value(); + const Type v = result->value(); details::free_node(*node_allocator_,result); @@ -26790,7 +27784,7 @@ namespace exprtk } else { - details::free_node(*node_allocator_,result); + details::free_node (*node_allocator_,result ); details::free_all_nodes(*node_allocator_,arg_list); return error_node(); @@ -26822,7 +27816,7 @@ namespace exprtk } else { - details::free_node(*node_allocator_,result); + details::free_node (*node_allocator_,result ); details::free_all_nodes(*node_allocator_,arg_list); return error_node(); @@ -26933,7 +27927,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline bool is_constant_foldable(const Sequence& b) const { for (std::size_t i = 0; i < b.size(); ++i) @@ -27028,13 +28022,13 @@ namespace exprtk { lodge_assignment(e_st_string,branch[0]); - return synthesize_expression(operation,branch); + return synthesize_expression(operation, branch); } else if (details::is_string_range_node(branch[0])) { lodge_assignment(e_st_string,branch[0]); - return synthesize_expression(operation,branch); + return synthesize_expression(operation, branch); } #endif else if (details::is_vector_node(branch[0])) @@ -27042,9 +28036,9 @@ namespace exprtk lodge_assignment(e_st_vector,branch[0]); if (details::is_ivector_node(branch[1])) - return synthesize_expression(operation,branch); + return synthesize_expression(operation, branch); else - return synthesize_expression(operation,branch); + return synthesize_expression(operation, branch); } else { @@ -27066,7 +28060,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ case_stmt(details::e_addass,details::add_op) case_stmt(details::e_subass,details::sub_op) @@ -27079,12 +28073,14 @@ namespace exprtk } else if (details::is_vector_elem_node(branch[0])) { + lodge_assignment(e_st_vecelem,branch[0]); + switch (operation) { #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ case_stmt(details::e_addass,details::add_op) case_stmt(details::e_subass,details::sub_op) @@ -27097,12 +28093,14 @@ namespace exprtk } else if (details::is_rebasevector_elem_node(branch[0])) { + lodge_assignment(e_st_vecelem,branch[0]); + switch (operation) { #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ case_stmt(details::e_addass,details::add_op) case_stmt(details::e_subass,details::sub_op) @@ -27115,12 +28113,14 @@ namespace exprtk } else if (details::is_rebasevector_celem_node(branch[0])) { + lodge_assignment(e_st_vecelem,branch[0]); + switch (operation) { #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ case_stmt(details::e_addass,details::add_op) case_stmt(details::e_subass,details::sub_op) @@ -27142,7 +28142,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ case_stmt(details::e_addass,details::add_op) case_stmt(details::e_subass,details::sub_op) @@ -27160,7 +28160,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ case_stmt(details::e_addass,details::add_op) case_stmt(details::e_subass,details::sub_op) @@ -27199,20 +28199,20 @@ namespace exprtk const bool is_b0_ivec = details::is_ivector_node(branch[0]); const bool is_b1_ivec = details::is_ivector_node(branch[1]); - #define batch_eqineq_logic_case \ - case_stmt(details:: e_lt,details:: lt_op) \ - case_stmt(details:: e_lte,details:: lte_op) \ - case_stmt(details:: e_gt,details:: gt_op) \ - case_stmt(details:: e_gte,details:: gte_op) \ - case_stmt(details:: e_eq,details:: eq_op) \ - case_stmt(details:: e_ne,details:: ne_op) \ - case_stmt(details::e_equal,details::equal_op) \ - case_stmt(details:: e_and, details::and_op) \ - case_stmt(details:: e_nand, details::nand_op) \ - case_stmt(details:: e_or, details:: or_op) \ - case_stmt(details:: e_nor, details:: nor_op) \ - case_stmt(details:: e_xor, details:: xor_op) \ - case_stmt(details:: e_xnor, details::xnor_op) \ + #define batch_eqineq_logic_case \ + case_stmt(details:: e_lt, details:: lt_op) \ + case_stmt(details:: e_lte, details:: lte_op) \ + case_stmt(details:: e_gt, details:: gt_op) \ + case_stmt(details:: e_gte, details:: gte_op) \ + case_stmt(details:: e_eq, details:: eq_op) \ + case_stmt(details:: e_ne, details:: ne_op) \ + case_stmt(details::e_equal, details::equal_op) \ + case_stmt(details:: e_and, details:: and_op) \ + case_stmt(details:: e_nand, details:: nand_op) \ + case_stmt(details:: e_or, details:: or_op) \ + case_stmt(details:: e_nor, details:: nor_op) \ + case_stmt(details:: e_xor, details:: xor_op) \ + case_stmt(details:: e_xnor, details:: xnor_op) \ if (is_b0_ivec && is_b1_ivec) { @@ -27221,7 +28221,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ batch_eqineq_logic_case #undef case_stmt @@ -27235,7 +28235,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ batch_eqineq_logic_case #undef case_stmt @@ -27249,7 +28249,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ batch_eqineq_logic_case #undef case_stmt @@ -27282,7 +28282,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ vector_ops case_stmt(details::e_pow,details:: pow_op) @@ -27297,7 +28297,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ vector_ops case_stmt(details::e_pow,details:: pow_op) @@ -27312,7 +28312,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ - (operation,branch[0],branch[1]); \ + (operation, branch[0], branch[1]); \ vector_ops #undef case_stmt @@ -27330,8 +28330,8 @@ namespace exprtk const bool v0_is_ivar = details::is_ivariable_node(branch[0]); const bool v1_is_ivar = details::is_ivariable_node(branch[1]); - const bool v0_is_ivec = details::is_ivector_node(branch[0]); - const bool v1_is_ivec = details::is_ivector_node(branch[1]); + const bool v0_is_ivec = details::is_ivector_node (branch[0]); + const bool v1_is_ivec = details::is_ivector_node (branch[1]); #ifndef exprtk_disable_string_capabilities const bool v0_is_str = details::is_generally_string_node(branch[0]); @@ -27365,9 +28365,11 @@ namespace exprtk else if (v0_is_str && v1_is_str) { if (is_string_node(branch[0]) && is_string_node(branch[1])) - result = node_allocator_->allocate >(branch[0],branch[1]); + result = node_allocator_->allocate > + (branch[0], branch[1]); else - result = node_allocator_->allocate >(branch[0],branch[1]); + result = node_allocator_->allocate > + (branch[0], branch[1]); } #endif else @@ -27417,15 +28419,19 @@ namespace exprtk if (result) { - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); + free_node(*node_allocator_, branch[0]); + free_node(*node_allocator_, branch[1]); return result; } else if (details::e_scand == operation) - return synthesize_expression(operation,branch); + { + return synthesize_expression(operation, branch); + } else if (details::e_scor == operation) - return synthesize_expression(operation,branch); + { + return synthesize_expression(operation, branch); + } else return error_node(); } @@ -27436,30 +28442,30 @@ namespace exprtk } #endif - #define basic_opr_switch_statements \ - case_stmt(details::e_add,details::add_op) \ - case_stmt(details::e_sub,details::sub_op) \ - case_stmt(details::e_mul,details::mul_op) \ - case_stmt(details::e_div,details::div_op) \ - case_stmt(details::e_mod,details::mod_op) \ - case_stmt(details::e_pow,details::pow_op) \ - - #define extended_opr_switch_statements \ - case_stmt(details:: e_lt,details:: lt_op) \ - case_stmt(details:: e_lte,details:: lte_op) \ - case_stmt(details:: e_gt,details:: gt_op) \ - case_stmt(details:: e_gte,details:: gte_op) \ - case_stmt(details:: e_eq,details:: eq_op) \ - case_stmt(details:: e_ne,details:: ne_op) \ - case_stmt(details:: e_and,details:: and_op) \ - case_stmt(details::e_nand,details::nand_op) \ - case_stmt(details:: e_or,details:: or_op) \ - case_stmt(details:: e_nor,details:: nor_op) \ - case_stmt(details:: e_xor,details:: xor_op) \ - case_stmt(details::e_xnor,details::xnor_op) \ + #define basic_opr_switch_statements \ + case_stmt(details::e_add, details::add_op) \ + case_stmt(details::e_sub, details::sub_op) \ + case_stmt(details::e_mul, details::mul_op) \ + case_stmt(details::e_div, details::div_op) \ + case_stmt(details::e_mod, details::mod_op) \ + case_stmt(details::e_pow, details::pow_op) \ + + #define extended_opr_switch_statements \ + case_stmt(details:: e_lt, details:: lt_op) \ + case_stmt(details:: e_lte, details:: lte_op) \ + case_stmt(details:: e_gt, details:: gt_op) \ + case_stmt(details:: e_gte, details:: gte_op) \ + case_stmt(details:: e_eq, details:: eq_op) \ + case_stmt(details:: e_ne, details:: ne_op) \ + case_stmt(details:: e_and, details:: and_op) \ + case_stmt(details::e_nand, details::nand_op) \ + case_stmt(details:: e_or, details:: or_op) \ + case_stmt(details:: e_nor, details:: nor_op) \ + case_stmt(details:: e_xor, details:: xor_op) \ + case_stmt(details::e_xnor, details::xnor_op) \ #ifndef exprtk_disable_cardinal_pow_optimisation - template class IPowNode> + template class IPowNode> inline expression_node_ptr cardinal_pow_optimisation_impl(const TType& v, const unsigned int& p) { switch (p) @@ -27491,7 +28497,7 @@ namespace exprtk inline expression_node_ptr cardinal_pow_optimisation(const T& v, const T& c) { const bool not_recipricol = (c >= T(0)); - const int p = details::numeric::to_int32(details::numeric::abs(c)); + const unsigned int p = static_cast(details::numeric::to_int32(details::numeric::abs(c))); if (0 == p) return node_allocator_->allocate_c(T(1)); @@ -27509,7 +28515,7 @@ namespace exprtk } } - inline bool cardinal_pow_optimisable(const details::operator_type& operation, const T& c) + inline bool cardinal_pow_optimisable(const details::operator_type& operation, const T& c) const { return (details::e_pow == operation) && (details::numeric::abs(c) <= T(60)) && details::numeric::is_integer(c); } @@ -27518,13 +28524,14 @@ namespace exprtk { const Type c = static_cast*>(branch[1])->value(); const bool not_recipricol = (c >= T(0)); - const int p = details::numeric::to_int32(details::numeric::abs(c)); + const unsigned int p = static_cast(details::numeric::to_int32(details::numeric::abs(c))); node_allocator_->free(branch[1]); if (0 == p) { details::free_all_nodes(*node_allocator_, branch); + return node_allocator_->allocate_c(T(1)); } else if (not_recipricol) @@ -27615,25 +28622,25 @@ namespace exprtk // -f(x + 1) + g(y + 1) --> g(y + 1) - f(x + 1) case details::e_add : return expr_gen.node_allocator_-> template allocate > > - (branch[1],branch[0]); + (branch[1], branch[0]); // -f(x + 1) - g(y + 1) --> -(f(x + 1) + g(y + 1)) case details::e_sub : return expr_gen(details::e_neg, expr_gen.node_allocator_-> template allocate > > - (branch[0],branch[1])); + (branch[0], branch[1])); // -f(x + 1) * g(y + 1) --> -(f(x + 1) * g(y + 1)) case details::e_mul : return expr_gen(details::e_neg, expr_gen.node_allocator_-> template allocate > > - (branch[0],branch[1])); + (branch[0], branch[1])); // -f(x + 1) / g(y + 1) --> -(f(x + 1) / g(y + 1)) case details::e_div : return expr_gen(details::e_neg, expr_gen.node_allocator_-> template allocate > > - (branch[0],branch[1])); + (branch[0], branch[1])); default : return error_node(); } @@ -27660,24 +28667,24 @@ namespace exprtk // f(x + 1) + -g(y + 1) --> f(x + 1) - g(y + 1) case details::e_add : return expr_gen.node_allocator_-> template allocate > > - (branch[0],branch[1]); + (branch[0], branch[1]); // f(x + 1) - - g(y + 1) --> f(x + 1) + g(y + 1) case details::e_sub : return expr_gen.node_allocator_-> template allocate > > - (branch[0],branch[1]); + (branch[0], branch[1]); // f(x + 1) * -g(y + 1) --> -(f(x + 1) * g(y + 1)) case details::e_mul : return expr_gen(details::e_neg, expr_gen.node_allocator_-> template allocate > > - (branch[0],branch[1])); + (branch[0], branch[1])); // f(x + 1) / -g(y + 1) --> -(f(x + 1) / g(y + 1)) case details::e_div : return expr_gen(details::e_neg, expr_gen.node_allocator_-> template allocate > > - (branch[0],branch[1])); + (branch[0], branch[1])); default : return error_node(); } @@ -27689,7 +28696,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate > > \ - (branch[0],branch[1]); \ + (branch[0], branch[1]); \ basic_opr_switch_statements extended_opr_switch_statements @@ -27712,7 +28719,10 @@ namespace exprtk { expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile_right(expr_gen,v,operation,branch[1],result)) + const bool synthesis_result = synthesize_sf4ext_expression::template compile_right + (expr_gen, v, operation, branch[1], result); + + if (synthesis_result) { free_node(*expr_gen.node_allocator_,branch[1]); return result; @@ -27760,7 +28770,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ - (v,branch[1]); \ + (v, branch[1]); \ basic_opr_switch_statements extended_opr_switch_statements @@ -27783,9 +28793,12 @@ namespace exprtk { expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile_left(expr_gen,v,operation,branch[0],result)) + const bool synthesis_result = synthesize_sf4ext_expression::template compile_left + (expr_gen, v, operation, branch[0], result); + + if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[0]); + free_node(*expr_gen.node_allocator_, branch[0]); return result; } @@ -27842,7 +28855,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ - (branch[0],v); \ + (branch[0], v); \ basic_opr_switch_statements extended_opr_switch_statements @@ -27862,21 +28875,21 @@ namespace exprtk free_node(*expr_gen.node_allocator_,branch[0]); - if ((T(0) == c) && (details::e_mul == operation)) + if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { free_node(*expr_gen.node_allocator_,branch[1]); return expr_gen(T(0)); } - else if ((T(0) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } - else if ((T(0) == c) && (details::e_add == operation)) + else if (std::equal_to()(T(0),c) && (details::e_add == operation)) return branch[1]; - else if ((T(1) == c) && (details::e_mul == operation)) + else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) return branch[1]; if (details::is_cob_node(branch[1])) @@ -27940,12 +28953,12 @@ namespace exprtk { case details::e_div : new_cobnode = expr_gen.node_allocator_-> template allocate_tt > > - (c / cobnode->c(),cobnode->move_branch(0)); + (c / cobnode->c(), cobnode->move_branch(0)); break; case details::e_mul : new_cobnode = expr_gen.node_allocator_-> template allocate_tt > > - (c / cobnode->c(),cobnode->move_branch(0)); + (c / cobnode->c(), cobnode->move_branch(0)); break; default : return error_node(); @@ -27976,7 +28989,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_tt > > \ - (c,branch[1]); \ + (c, branch[1]); \ basic_opr_switch_statements extended_opr_switch_statements @@ -27994,23 +29007,23 @@ namespace exprtk { const Type c = static_cast*>(branch[1])->value(); - details::free_node(*(expr_gen.node_allocator_),branch[1]); + details::free_node(*(expr_gen.node_allocator_), branch[1]); - if ((T(0) == c) && (details::e_mul == operation)) + if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_,branch[0]); + free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(T(0)); } - else if ((T(0) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(std::numeric_limits::quiet_NaN()); } - else if ((T(0) == c) && (details::e_add == operation)) + else if (std::equal_to()(T(0),c) && (details::e_add == operation)) return branch[0]; - else if ((T(1) == c) && (details::e_mul == operation)) + else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) return branch[0]; if (details::is_boc_node(branch[0])) @@ -28040,7 +29053,7 @@ namespace exprtk else if (operation == details::e_div) { details::boc_base_node* bocnode = static_cast*>(branch[0]); - details::operator_type boc_opr = bocnode->operation(); + details::operator_type boc_opr = bocnode->operation(); if ( (details::e_div == boc_opr) || @@ -28061,7 +29074,7 @@ namespace exprtk { // (v ^ c0) ^ c1 --> v ^(c0 * c1) details::boc_base_node* bocnode = static_cast*>(branch[0]); - details::operator_type boc_opr = bocnode->operation(); + details::operator_type boc_opr = bocnode->operation(); if (details::e_pow == boc_opr) { @@ -28077,9 +29090,12 @@ namespace exprtk { expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile_left(expr_gen,c,operation,branch[0],result)) + const bool synthesis_result = synthesize_sf4ext_expression::template compile_left + (expr_gen, c, operation, branch[0], result); + + if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[0]); + free_node(*expr_gen.node_allocator_, branch[0]); return result; } @@ -28091,7 +29107,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ - (branch[0],c); \ + (branch[0], c); \ basic_opr_switch_statements extended_opr_switch_statements @@ -28113,40 +29129,44 @@ namespace exprtk if (details::is_cob_node(branch[0])) { details::cob_base_node* cobnode = static_cast*>(branch[0]); + const Type c = static_cast*>(branch[1])->value(); - if ((T(0) == c) && (details::e_mul == operation)) + if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_,branch[0]); - free_node(*expr_gen.node_allocator_,branch[1]); + free_node(*expr_gen.node_allocator_, branch[0]); + free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } - else if ((T(0) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_,branch[0]); - free_node(*expr_gen.node_allocator_,branch[1]); + free_node(*expr_gen.node_allocator_, branch[0]); + free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(std::numeric_limits::quiet_NaN())); } - else if ((T(0) == c) && (details::e_add == operation)) + else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { free_node(*expr_gen.node_allocator_, branch[1]); + return branch[0]; } - else if ((T(1) == c) && (details::e_mul == operation)) + else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { free_node(*expr_gen.node_allocator_, branch[1]); + return branch[0]; } - else if ((T(1) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(1),c) && (details::e_div == operation)) { free_node(*expr_gen.node_allocator_, branch[1]); + return branch[0]; } - bool op_addsub = (details::e_add == cobnode->operation()) || - (details::e_sub == cobnode->operation()); + const bool op_addsub = (details::e_add == cobnode->operation()) || + (details::e_sub == cobnode->operation()) ; if (op_addsub) { @@ -28181,9 +29201,9 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (cobnode->c() / c,cobnode->move_branch(0)); + (cobnode->c() / c, cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[0]); + free_node(*expr_gen.node_allocator_, branch[0]); } } @@ -28197,30 +29217,33 @@ namespace exprtk else if (details::is_cob_node(branch[1])) { details::cob_base_node* cobnode = static_cast*>(branch[1]); + const Type c = static_cast*>(branch[0])->value(); - if ((T(0) == c) && (details::e_mul == operation)) + if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_,branch[0]); - free_node(*expr_gen.node_allocator_,branch[1]); + free_node(*expr_gen.node_allocator_, branch[0]); + free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } - else if ((T(0) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_,branch[0]); - free_node(*expr_gen.node_allocator_,branch[1]); + free_node(*expr_gen.node_allocator_, branch[0]); + free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } - else if ((T(0) == c) && (details::e_add == operation)) + else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { free_node(*expr_gen.node_allocator_, branch[0]); + return branch[1]; } - else if ((T(1) == c) && (details::e_mul == operation)) + else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { free_node(*expr_gen.node_allocator_, branch[0]); + return branch[1]; } @@ -28235,7 +29258,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c - cobnode->c(),cobnode->move_branch(0)); + (c - cobnode->c(), cobnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28251,7 +29274,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c - cobnode->c(),cobnode->move_branch(0)); + (c - cobnode->c(), cobnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28267,7 +29290,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c / cobnode->c(),cobnode->move_branch(0)); + (c / cobnode->c(), cobnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28283,7 +29306,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c / cobnode->c(),cobnode->move_branch(0)); + (c / cobnode->c(), cobnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28311,6 +29334,7 @@ namespace exprtk if (details::is_boc_node(branch[0])) { details::boc_base_node* bocnode = static_cast*>(branch[0]); + const Type c = static_cast*>(branch[1])->value(); if (details::e_add == bocnode->operation()) @@ -28341,7 +29365,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (bocnode->move_branch(0),c - bocnode->c()); + (bocnode->move_branch(0), c - bocnode->c()); free_node(*expr_gen.node_allocator_,branch[0]); } @@ -28365,7 +29389,7 @@ namespace exprtk if (result) { - free_node(*expr_gen.node_allocator_,branch[1]); + free_node(*expr_gen.node_allocator_, branch[1]); } } @@ -28373,6 +29397,7 @@ namespace exprtk else if (details::is_boc_node(branch[1])) { details::boc_base_node* bocnode = static_cast*>(branch[1]); + const Type c = static_cast*>(branch[0])->value(); if (details::e_add == bocnode->operation()) @@ -28386,7 +29411,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c - bocnode->c(),bocnode->move_branch(0)); + (c - bocnode->c(), bocnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28397,7 +29422,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (bocnode->move_branch(0),c - bocnode->c()); + (bocnode->move_branch(0), c - bocnode->c()); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28405,7 +29430,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c + bocnode->c(),bocnode->move_branch(0)); + (c + bocnode->c(), bocnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28421,7 +29446,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c / bocnode->c(),bocnode->move_branch(0)); + (c / bocnode->c(), bocnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28437,7 +29462,7 @@ namespace exprtk { result = expr_gen.node_allocator_-> template allocate_tt > > - (c * bocnode->c(),bocnode->move_branch(0)); + (c * bocnode->c(), bocnode->move_branch(0)); free_node(*expr_gen.node_allocator_,branch[1]); } @@ -28465,11 +29490,11 @@ namespace exprtk const std::string node_id = branch_to_id(branch); - typename synthesize_map_t::iterator itr = synthesize_map_.find(node_id); + const typename synthesize_map_t::iterator itr = synthesize_map_.find(node_id); if (synthesize_map_.end() != itr) { - result = itr->second(*this,operation,branch); + result = itr->second((*this), operation, branch); return true; } @@ -28491,7 +29516,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rr > > \ - (v1,v2); \ + (v1, v2); \ basic_opr_switch_statements extended_opr_switch_statements @@ -28508,17 +29533,17 @@ namespace exprtk expression_node_ptr (&branch)[2]) { const Type c = static_cast*> (branch[0])->value(); - const Type& v = static_cast*>(branch[1])->ref(); + const Type& v = static_cast*>(branch[1])->ref (); details::free_node(*(expr_gen.node_allocator_),branch[0]); - if ((T(0) == c) && (details::e_mul == operation)) + if (std::equal_to()(T(0),c) && (details::e_mul == operation)) return expr_gen(T(0)); - else if ((T(0) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(0),c) && (details::e_div == operation)) return expr_gen(T(0)); - else if ((T(0) == c) && (details::e_add == operation)) + else if (std::equal_to()(T(0),c) && (details::e_add == operation)) return static_cast*>(branch[1]); - else if ((T(1) == c) && (details::e_mul == operation)) + else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) return static_cast*>(branch[1]); switch (operation) @@ -28526,7 +29551,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ - (c,v); \ + (c, v); \ basic_opr_switch_statements extended_opr_switch_statements @@ -28542,10 +29567,10 @@ namespace exprtk const details::operator_type& operation, expression_node_ptr (&branch)[2]) { - const Type& v = static_cast*>(branch[0])->ref(); + const Type& v = static_cast*>(branch[0])->ref (); const Type c = static_cast*> (branch[1])->value(); - details::free_node(*(expr_gen.node_allocator_),branch[1]); + details::free_node(*(expr_gen.node_allocator_), branch[1]); if (expr_gen.cardinal_pow_optimisable(operation,c)) { @@ -28554,15 +29579,15 @@ namespace exprtk else return expr_gen.cardinal_pow_optimisation(v,c); } - else if ((T(0) == c) && (details::e_mul == operation)) + else if (std::equal_to()(T(0),c) && (details::e_mul == operation)) return expr_gen(T(0)); - else if ((T(0) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(0),c) && (details::e_div == operation)) return expr_gen(std::numeric_limits::quiet_NaN()); - else if ((T(0) == c) && (details::e_add == operation)) + else if (std::equal_to()(T(0),c) && (details::e_add == operation)) return static_cast*>(branch[0]); - else if ((T(1) == c) && (details::e_mul == operation)) + else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) return static_cast*>(branch[0]); - else if ((T(1) == c) && (details::e_div == operation)) + else if (std::equal_to()(T(1),c) && (details::e_div == operation)) return static_cast*>(branch[0]); switch (operation) @@ -28570,7 +29595,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ - (v,c); \ + (v, c); \ basic_opr_switch_statements extended_opr_switch_statements @@ -28591,7 +29616,7 @@ namespace exprtk { #define case_stmt(op) \ case details::e_sf##op : return details::T0oT1oT2_sf3ext >:: \ - allocate(*(expr_gen.node_allocator_),t0,t1,t2); \ + allocate(*(expr_gen.node_allocator_), t0, t1, t2); \ case_stmt(00) case_stmt(01) case_stmt(02) case_stmt(03) case_stmt(04) case_stmt(05) case_stmt(06) case_stmt(07) @@ -28616,7 +29641,8 @@ namespace exprtk if (!expr_gen.sf3_optimisable(id,sf3opr)) return false; else - result = synthesize_sf3ext_expression::template process(expr_gen,sf3opr,t0,t1,t2); + result = synthesize_sf3ext_expression::template process + (expr_gen, sf3opr, t0, t1, t2); return true; } @@ -28633,12 +29659,12 @@ namespace exprtk { #define case_stmt0(op) \ case details::e_sf##op : return details::T0oT1oT2oT3_sf4ext >:: \ - allocate(*(expr_gen.node_allocator_),t0,t1,t2,t3); \ + allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ #define case_stmt1(op) \ case details::e_sf4ext##op : return details::T0oT1oT2oT3_sf4ext >:: \ - allocate(*(expr_gen.node_allocator_),t0,t1,t2,t3); \ + allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ case_stmt0(48) case_stmt0(49) case_stmt0(50) case_stmt0(51) case_stmt0(52) case_stmt0(53) case_stmt0(54) case_stmt0(55) @@ -28683,7 +29709,8 @@ namespace exprtk if (!expr_gen.sf4_optimisable(id,sf4opr)) return false; else - result = synthesize_sf4ext_expression::template process(expr_gen,sf4opr,t0,t1,t2,t3); + result = synthesize_sf4ext_expression::template process + (expr_gen, sf4opr, t0, t1, t2, t3); return true; } @@ -28702,29 +29729,29 @@ namespace exprtk typedef details::T0oT1oT2_base_node* sf3ext_base_ptr; sf3ext_base_ptr n = static_cast(sf3node); - std::string id = "t" + expr_gen.to_str(operation) + "(" + n->type_id() + ")"; + const std::string id = "t" + expr_gen.to_str(operation) + "(" + n->type_id() + ")"; switch (n->type()) { case details::expression_node::e_covoc : return compile_right_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_covov : return compile_right_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_vocov : return compile_right_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_vovoc : return compile_right_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_vovov : return compile_right_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); default : return false; } @@ -28745,29 +29772,29 @@ namespace exprtk sf3ext_base_ptr n = static_cast(sf3node); - std::string id = "(" + n->type_id() + ")" + expr_gen.to_str(operation) + "t"; + const std::string id = "(" + n->type_id() + ")" + expr_gen.to_str(operation) + "t"; switch (n->type()) { case details::expression_node::e_covoc : return compile_left_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_covov : return compile_left_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_vocov : return compile_left_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_vovoc : return compile_left_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); case details::expression_node::e_vovov : return compile_left_impl - - (expr_gen,id,t,sf3node,result); + + (expr_gen, id, t, sf3node, result); default : return false; } @@ -28788,8 +29815,8 @@ namespace exprtk T1 t1 = n->t1(); T2 t2 = n->t2(); - return synthesize_sf4ext_expression:: - template compile(expr_gen,id,t,t0,t1,t2,result); + return synthesize_sf4ext_expression::template compile + (expr_gen, id, t, t0, t1, t2, result); } else return false; @@ -28810,8 +29837,8 @@ namespace exprtk T1 t1 = n->t1(); T2 t2 = n->t2(); - return synthesize_sf4ext_expression:: - template compile(expr_gen,id,t0,t1,t2,t,result); + return synthesize_sf4ext_expression::template compile + (expr_gen, id, t0, t1, t2, t, result); } else return false; @@ -28849,7 +29876,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",v0,v1,v2,result); + template compile(expr_gen, "t/(t*t)", v0, v1, v2, result); exprtk_debug(("(v0 / v1) / v2 --> (vovov) v0 / (v1 * v2)\n")); @@ -28857,20 +29884,27 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,v2,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), v0, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -28905,7 +29939,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",v0,v2,v1,result); + template compile(expr_gen, "(t*t)/t", v0, v2, v1, result); exprtk_debug(("v0 / (v1 / v2) --> (vovov) (v0 * v2) / v1\n")); @@ -28913,20 +29947,27 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,v2,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), v0, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -28962,7 +30003,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",v0,v1,c,result); + template compile(expr_gen, "t/(t*t)", v0, v1, c, result); exprtk_debug(("(v0 / v1) / c --> (vovoc) v0 / (v1 * c)\n")); @@ -28970,20 +30011,27 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,c,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), v0, v1, c, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,c,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, c, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29018,7 +30066,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",v0,c,v1,result); + template compile(expr_gen, "(t*t)/t", v0, c, v1, result); exprtk_debug(("v0 / (v1 / c) --> (vocov) (v0 * c) / v1\n")); @@ -29026,20 +30074,27 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,c,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), v0, v1, c, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,c,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, c, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29074,7 +30129,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",v0,v1,c,result); + template compile(expr_gen, "t/(t*t)", v0, v1, c, result); exprtk_debug(("(v0 / c) / v1 --> (vovoc) v0 / (v1 * c)\n")); @@ -29082,20 +30137,27 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,c,v1,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), v0, c, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,c,v1,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c, v1, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29130,7 +30192,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",v0,v1,c,result); + template compile(expr_gen, "(t*t)/t", v0, v1, c, result); exprtk_debug(("v0 / (c / v1) --> (vovoc) (v0 * v1) / c\n")); @@ -29138,20 +30200,27 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,c,v1,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), v0, c, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,c,v1,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c, v1, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29186,7 +30255,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",c,v0,v1,result); + template compile(expr_gen, "t/(t*t)", c, v0, v1, result); exprtk_debug(("(c / v0) / v1 --> (covov) c / (v0 * v1)\n")); @@ -29194,20 +30263,27 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c,v0,v1,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), c, v0, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c,v0,v1,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29243,7 +30319,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",c,v1,v0,result); + template compile(expr_gen, "(t*t)/t", c, v1, v0, result); exprtk_debug(("c / (v0 / v1) --> (covov) (c * v1) / v0\n")); @@ -29251,19 +30327,26 @@ namespace exprtk } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c,v0,v1,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), c, v0, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c,v0,v1,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29300,7 +30383,7 @@ namespace exprtk exprtk_debug(("(c0 + v) + c1 --> (cov) (c0 + c1) + v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 + c1,v); + template allocate_cr > >(c0 + c1, v); } // (c0 + v) - c1 --> (cov) (c0 - c1) + v else if ((details::e_add == o0) && (details::e_sub == o1)) @@ -29308,7 +30391,7 @@ namespace exprtk exprtk_debug(("(c0 + v) - c1 --> (cov) (c0 - c1) + v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 - c1,v); + template allocate_cr > >(c0 - c1, v); } // (c0 - v) + c1 --> (cov) (c0 + c1) - v else if ((details::e_sub == o0) && (details::e_add == o1)) @@ -29316,7 +30399,7 @@ namespace exprtk exprtk_debug(("(c0 - v) + c1 --> (cov) (c0 + c1) - v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 + c1,v); + template allocate_cr > >(c0 + c1, v); } // (c0 - v) - c1 --> (cov) (c0 - c1) - v else if ((details::e_sub == o0) && (details::e_sub == o1)) @@ -29324,7 +30407,7 @@ namespace exprtk exprtk_debug(("(c0 - v) - c1 --> (cov) (c0 - c1) - v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 - c1,v); + template allocate_cr > >(c0 - c1, v); } // (c0 * v) * c1 --> (cov) (c0 * c1) * v else if ((details::e_mul == o0) && (details::e_mul == o1)) @@ -29332,7 +30415,7 @@ namespace exprtk exprtk_debug(("(c0 * v) * c1 --> (cov) (c0 * c1) * v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 * c1,v); + template allocate_cr > >(c0 * c1, v); } // (c0 * v) / c1 --> (cov) (c0 / c1) * v else if ((details::e_mul == o0) && (details::e_div == o1)) @@ -29340,7 +30423,7 @@ namespace exprtk exprtk_debug(("(c0 * v) / c1 --> (cov) (c0 / c1) * v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 / c1,v); + template allocate_cr > >(c0 / c1, v); } // (c0 / v) * c1 --> (cov) (c0 * c1) / v else if ((details::e_div == o0) && (details::e_mul == o1)) @@ -29348,7 +30431,7 @@ namespace exprtk exprtk_debug(("(c0 / v) * c1 --> (cov) (c0 * c1) / v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 * c1,v); + template allocate_cr > >(c0 * c1, v); } // (c0 / v) / c1 --> (cov) (c0 / c1) / v else if ((details::e_div == o0) && (details::e_div == o1)) @@ -29356,24 +30439,31 @@ namespace exprtk exprtk_debug(("(c0 / v) / c1 --> (cov) (c0 / c1) / v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 / c1,v); + template allocate_cr > >(c0 / c1, v); } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c0,v,c1,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), c0, v, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c0,v,c1,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v, c1, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29410,7 +30500,7 @@ namespace exprtk exprtk_debug(("(c0) + (v + c1) --> (cov) (c0 + c1) + v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 + c1,v); + template allocate_cr > >(c0 + c1, v); } // (c0) + (v - c1) --> (cov) (c0 - c1) + v else if ((details::e_add == o0) && (details::e_sub == o1)) @@ -29418,7 +30508,7 @@ namespace exprtk exprtk_debug(("(c0) + (v - c1) --> (cov) (c0 - c1) + v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 - c1,v); + template allocate_cr > >(c0 - c1, v); } // (c0) - (v + c1) --> (cov) (c0 - c1) - v else if ((details::e_sub == o0) && (details::e_add == o1)) @@ -29426,7 +30516,7 @@ namespace exprtk exprtk_debug(("(c0) - (v + c1) --> (cov) (c0 - c1) - v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 - c1,v); + template allocate_cr > >(c0 - c1, v); } // (c0) - (v - c1) --> (cov) (c0 + c1) - v else if ((details::e_sub == o0) && (details::e_sub == o1)) @@ -29434,7 +30524,7 @@ namespace exprtk exprtk_debug(("(c0) - (v - c1) --> (cov) (c0 + c1) - v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 + c1,v); + template allocate_cr > >(c0 + c1, v); } // (c0) * (v * c1) --> (voc) v * (c0 * c1) else if ((details::e_mul == o0) && (details::e_mul == o1)) @@ -29442,7 +30532,7 @@ namespace exprtk exprtk_debug(("(c0) * (v * c1) --> (voc) v * (c0 * c1)\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 * c1,v); + template allocate_cr > >(c0 * c1, v); } // (c0) * (v / c1) --> (cov) (c0 / c1) * v else if ((details::e_mul == o0) && (details::e_div == o1)) @@ -29450,7 +30540,7 @@ namespace exprtk exprtk_debug(("(c0) * (v / c1) --> (cov) (c0 / c1) * v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 / c1,v); + template allocate_cr > >(c0 / c1, v); } // (c0) / (v * c1) --> (cov) (c0 / c1) / v else if ((details::e_div == o0) && (details::e_mul == o1)) @@ -29458,7 +30548,7 @@ namespace exprtk exprtk_debug(("(c0) / (v * c1) --> (cov) (c0 / c1) / v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 / c1,v); + template allocate_cr > >(c0 / c1, v); } // (c0) / (v / c1) --> (cov) (c0 * c1) / v else if ((details::e_div == o0) && (details::e_div == o1)) @@ -29466,24 +30556,31 @@ namespace exprtk exprtk_debug(("(c0) / (v / c1) --> (cov) (c0 * c1) / v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 * c1,v); + template allocate_cr > >(c0 * c1, v); } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c0,v,c1,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), c0, v, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c0,v,c1,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v, c1, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29530,7 +30627,7 @@ namespace exprtk exprtk_debug(("(c0) + (c1 + v) --> (cov) (c0 + c1) + v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 + c1,v); + template allocate_cr > >(c0 + c1, v); } // (c0) + (c1 - v) --> (cov) (c0 + c1) - v else if ((details::e_add == o0) && (details::e_sub == o1)) @@ -29538,7 +30635,7 @@ namespace exprtk exprtk_debug(("(c0) + (c1 - v) --> (cov) (c0 + c1) - v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 + c1,v); + template allocate_cr > >(c0 + c1, v); } // (c0) - (c1 + v) --> (cov) (c0 - c1) - v else if ((details::e_sub == o0) && (details::e_add == o1)) @@ -29546,7 +30643,7 @@ namespace exprtk exprtk_debug(("(c0) - (c1 + v) --> (cov) (c0 - c1) - v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 - c1,v); + template allocate_cr > >(c0 - c1, v); } // (c0) - (c1 - v) --> (cov) (c0 - c1) + v else if ((details::e_sub == o0) && (details::e_sub == o1)) @@ -29554,7 +30651,7 @@ namespace exprtk exprtk_debug(("(c0) - (c1 - v) --> (cov) (c0 - c1) + v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 - c1,v); + template allocate_cr > >(c0 - c1, v); } // (c0) * (c1 * v) --> (cov) (c0 * c1) * v else if ((details::e_mul == o0) && (details::e_mul == o1)) @@ -29562,7 +30659,7 @@ namespace exprtk exprtk_debug(("(c0) * (c1 * v) --> (cov) (c0 * c1) * v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 * c1,v); + template allocate_cr > >(c0 * c1, v); } // (c0) * (c1 / v) --> (cov) (c0 * c1) / v else if ((details::e_mul == o0) && (details::e_div == o1)) @@ -29570,7 +30667,7 @@ namespace exprtk exprtk_debug(("(c0) * (c1 / v) --> (cov) (c0 * c1) / v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 * c1,v); + template allocate_cr > >(c0 * c1, v); } // (c0) / (c1 * v) --> (cov) (c0 / c1) / v else if ((details::e_div == o0) && (details::e_mul == o1)) @@ -29578,7 +30675,7 @@ namespace exprtk exprtk_debug(("(c0) / (c1 * v) --> (cov) (c0 / c1) / v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 / c1,v); + template allocate_cr > >(c0 / c1, v); } // (c0) / (c1 / v) --> (cov) (c0 / c1) * v else if ((details::e_div == o0) && (details::e_div == o1)) @@ -29586,23 +30683,30 @@ namespace exprtk exprtk_debug(("(c0) / (c1 / v) --> (cov) (c0 / c1) * v\n")); return expr_gen.node_allocator_-> - template allocate_cr > >(c0 / c1,v); + template allocate_cr > >(c0 / c1, v); } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c0,c1,v,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), c0, c1, v, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c0,c1,v,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), c0, c1, v, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29639,7 +30743,7 @@ namespace exprtk exprtk_debug(("(v + c0) + c1 --> (voc) v + (c0 + c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c0 + c1); + template allocate_rc > >(v, c0 + c1); } // (v + c0) - c1 --> (voc) v + (c0 - c1) else if ((details::e_add == o0) && (details::e_sub == o1)) @@ -29647,7 +30751,7 @@ namespace exprtk exprtk_debug(("(v + c0) - c1 --> (voc) v + (c0 - c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c0 - c1); + template allocate_rc > >(v, c0 - c1); } // (v - c0) + c1 --> (voc) v - (c0 + c1) else if ((details::e_sub == o0) && (details::e_add == o1)) @@ -29655,7 +30759,7 @@ namespace exprtk exprtk_debug(("(v - c0) + c1 --> (voc) v - (c0 + c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c1 - c0); + template allocate_rc > >(v, c1 - c0); } // (v - c0) - c1 --> (voc) v - (c0 + c1) else if ((details::e_sub == o0) && (details::e_sub == o1)) @@ -29663,7 +30767,7 @@ namespace exprtk exprtk_debug(("(v - c0) - c1 --> (voc) v - (c0 + c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c0 + c1); + template allocate_rc > >(v, c0 + c1); } // (v * c0) * c1 --> (voc) v * (c0 * c1) else if ((details::e_mul == o0) && (details::e_mul == o1)) @@ -29671,7 +30775,7 @@ namespace exprtk exprtk_debug(("(v * c0) * c1 --> (voc) v * (c0 * c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c0 * c1); + template allocate_rc > >(v, c0 * c1); } // (v * c0) / c1 --> (voc) v * (c0 / c1) else if ((details::e_mul == o0) && (details::e_div == o1)) @@ -29679,7 +30783,7 @@ namespace exprtk exprtk_debug(("(v * c0) / c1 --> (voc) v * (c0 / c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c0 / c1); + template allocate_rc > >(v, c0 / c1); } // (v / c0) * c1 --> (voc) v * (c1 / c0) else if ((details::e_div == o0) && (details::e_mul == o1)) @@ -29687,7 +30791,7 @@ namespace exprtk exprtk_debug(("(v / c0) * c1 --> (voc) v * (c1 / c0)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c1 / c0); + template allocate_rc > >(v, c1 / c0); } // (v / c0) / c1 --> (voc) v / (c0 * c1) else if ((details::e_div == o0) && (details::e_div == o1)) @@ -29695,7 +30799,7 @@ namespace exprtk exprtk_debug(("(v / c0) / c1 --> (voc) v / (c0 * c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c0 * c1); + template allocate_rc > >(v, c0 * c1); } // (v ^ c0) ^ c1 --> (voc) v ^ (c0 * c1) else if ((details::e_pow == o0) && (details::e_pow == o1)) @@ -29703,24 +30807,31 @@ namespace exprtk exprtk_debug(("(v ^ c0) ^ c1 --> (voc) v ^ (c0 * c1)\n")); return expr_gen.node_allocator_-> - template allocate_rc > >(v,c0 * c1); + template allocate_rc > >(v, c0 * c1); } } - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v,c0,c1,result)) + const bool synthesis_result = + synthesize_sf3ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1), v, c0, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v,c0,c1,f0,f1); + return node_type::allocate(*(expr_gen.node_allocator_), v, c0, c1, f0, f1); } static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29776,7 +30887,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,v2,v1,v3,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, v3, result); exprtk_debug(("(v0 / v1) * (v2 / v3) --> (vovovov) (v0 * v2) / (v1 * v3)\n")); @@ -29787,7 +30898,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,v3,v1,v2,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v3, v1, v2, result); exprtk_debug(("(v0 / v1) / (v2 / v3) --> (vovovov) (v0 * v3) / (v1 * v2)\n")); @@ -29798,7 +30909,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t+t)*(t/t)",v0,v1,v3,v2,result); + template compile(expr_gen, "(t+t)*(t/t)", v0, v1, v3, v2, result); exprtk_debug(("(v0 + v1) / (v2 / v3) --> (vovovov) (v0 + v1) * (v3 / v2)\n")); @@ -29809,7 +30920,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t-t)*(t/t)",v0,v1,v3,v2,result); + template compile(expr_gen, "(t-t)*(t/t)", v0, v1, v3, v2, result); exprtk_debug(("(v0 - v1) / (v2 / v3) --> (vovovov) (v0 - v1) * (v3 / v2)\n")); @@ -29820,7 +30931,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"((t*t)*t)/t",v0,v1,v3,v2,result); + template compile(expr_gen, "((t*t)*t)/t", v0, v1, v3, v2, result); exprtk_debug(("(v0 * v1) / (v2 / v3) --> (vovovov) ((v0 * v1) * v3) / v2\n")); @@ -29828,7 +30939,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,v3,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, v3, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -29837,7 +30952,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,v3,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, v3, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -29845,7 +30960,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -29889,7 +31008,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,v2,v1,c,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, c, result); exprtk_debug(("(v0 / v1) * (v2 / c) --> (vovovoc) (v0 * v2) / (v1 * c)\n")); @@ -29900,7 +31019,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,c,v1,v2,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, c, v1, v2, result); exprtk_debug(("(v0 / v1) / (v2 / c) --> (vocovov) (v0 * c) / (v1 * v2)\n")); @@ -29908,7 +31027,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,c,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, c, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -29917,7 +31040,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,c,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, c, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -29925,7 +31048,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -29969,7 +31096,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,c,v1,v2,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, c, v1, v2, result); exprtk_debug(("(v0 / v1) * (c / v2) --> (vocovov) (v0 * c) / (v1 * v2)\n")); @@ -29980,7 +31107,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,v2,v1,c,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, c, result); exprtk_debug(("(v0 / v1) / (c / v2) --> (vovovoc) (v0 * v2) / (v1 * c)\n")); @@ -29988,7 +31115,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,c,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, c, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -29997,7 +31128,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,c,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, c, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -30005,7 +31136,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30049,7 +31184,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,v1,c,v2,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v1, c, v2, result); exprtk_debug(("(v0 / c) * (v1 / v2) --> (vovocov) (v0 * v1) / (c * v2)\n")); @@ -30060,7 +31195,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",v0,v2,c,v1,result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, c, v1, result); exprtk_debug(("(v0 / c) / (v1 / v2) --> (vovocov) (v0 * v2) / (c * v1)\n")); @@ -30068,7 +31203,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -30077,7 +31216,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,c,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -30085,7 +31224,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30129,7 +31272,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",c,v1,v0,v2,result); + template compile(expr_gen, "(t*t)/(t*t)", c, v1, v0, v2, result); exprtk_debug(("(c / v0) * (v1 / v2) --> (covovov) (c * v1) / (v0 * v2)\n")); @@ -30140,7 +31283,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)/(t*t)",c,v2,v0,v1,result); + template compile(expr_gen, "(t*t)/(t*t)", c, v2, v0, v1, result); exprtk_debug(("(c / v0) / (v1 / v2) --> (covovov) (c * v2) / (v0 * v1)\n")); @@ -30148,7 +31291,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c,v0,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c, v0, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -30157,7 +31304,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c,v0,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -30165,7 +31312,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30209,7 +31360,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)+t",(c0 + c1),v0,v1,result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(c0 + v0) + (c1 + v1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -30220,7 +31371,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)-t",(c0 - c1),v0,v1,result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(c0 + v0) - (c1 + v1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -30231,7 +31382,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t-t)+t",(c0 - c1),v0,v1,result); + template compile(expr_gen, "(t-t)+t", (c0 - c1), v0, v1, result); exprtk_debug(("(c0 - v0) - (c1 - v1) --> (covov) (c0 - c1) - v0 + v1\n")); @@ -30242,7 +31393,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 * v0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -30253,7 +31404,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (c1 * v1) --> (covov) (c0 / c1) * (v0 / v1)\n")); @@ -30264,7 +31415,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",(c0 * c1),v0,v1,result); + template compile(expr_gen, "t/(t*t)", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 / v0) * (c1 / v1) --> (covov) (c0 * c1) / (v0 * v1)\n")); @@ -30275,7 +31426,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c0 / c1),v1,v0,result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v1, v0, result); exprtk_debug(("(c0 / v0) / (c1 / v1) --> (covov) ((c0 / c1) * v1) / v0\n")); @@ -30286,7 +31437,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t*(t*t)",(c0 / c1),v0,v1,result); + template compile(expr_gen, "t*(t*t)", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (c1 / v1) --> (covov) (c0 / c1) * (v0 * v1)\n")); @@ -30297,7 +31448,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",(c0 / c1),v0,v1,result); + template compile(expr_gen, "t/(t*t)", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 / v0) / (c1 * v1) --> (covov) (c0 / c1) / (v0 * v1)\n")); @@ -30325,7 +31476,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc,c0,v0,v1,result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(c * v0) +/- (c * v1) --> (covov) c * (v0 +/- v1)\n")); @@ -30333,7 +31484,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -30342,7 +31497,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -30350,7 +31505,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30394,7 +31553,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)+t",(c0 + c1),v0,v1,result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(v0 + c0) + (v1 + c1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -30405,7 +31564,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)-t",(c0 - c1),v0,v1,result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(v0 + c0) - (v1 + c1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -30416,7 +31575,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)-t",(c1 - c0),v0,v1,result); + template compile(expr_gen, "(t+t)-t", (c1 - c0), v0, v1, result); exprtk_debug(("(v0 - c0) - (v1 - c1) --> (covov) (c1 - c0) + v0 - v1\n")); @@ -30427,7 +31586,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(v0 * c0) * (v1 * c1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -30438,7 +31597,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (v1 * c1) --> (covov) (c0 / c1) * (v0 / v1)\n")); @@ -30449,7 +31608,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)*t",Type(1) / (c0 * c1),v0,v1,result); + template compile(expr_gen, "(t*t)*t", Type(1) / (c0 * c1), v0, v1, result); exprtk_debug(("(v0 / c0) * (v1 / c1) --> (covov) (1 / (c0 * c1)) * v0 * v1\n")); @@ -30460,7 +31619,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c1 / c0),v0,v1,result); + template compile(expr_gen, "(t*t)/t", (c1 / c0), v0, v1, result); exprtk_debug(("(v0 / c0) / (v1 / c1) --> (covov) ((c1 / c0) * v0) / v1\n")); @@ -30471,7 +31630,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t*(t/t)",(c0 * c1),v0,v1,result); + template compile(expr_gen, "t*(t/t)", (c0 * c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (v1 / c1) --> (covov) (c0 * c1) * (v0 / v1)\n")); @@ -30482,7 +31641,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t*(t/t)",Type(1) / (c0 * c1),v0,v1,result); + template compile(expr_gen, "t*(t/t)", Type(1) / (c0 * c1), v0, v1, result); exprtk_debug(("(v0 / c0) / (v1 * c1) --> (covov) (1 / (c0 * c1)) * v0 / v1\n")); @@ -30493,7 +31652,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)*(t+t)",v0,T(1) / c0,v1,c1,result); + template compile(expr_gen, "(t*t)*(t+t)", v0, T(1) / c0, v1, c1, result); exprtk_debug(("(v0 / c0) * (v1 + c1) --> (vocovoc) (v0 * (1 / c0)) * (v1 + c1)\n")); @@ -30504,7 +31663,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen,"(t*t)*(t-t)",v0,T(1) / c0,v1,c1,result); + template compile(expr_gen, "(t*t)*(t-t)", v0, T(1) / c0, v1, c1, result); exprtk_debug(("(v0 / c0) * (v1 - c1) --> (vocovoc) (v0 * (1 / c0)) * (v1 - c1)\n")); @@ -30532,7 +31691,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc,c0,v0,v1,result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(v0 * c) +/- (v1 * c) --> (covov) c * (v0 +/- v1)\n")); @@ -30560,7 +31719,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc,v0,v1,c0,result); + template compile(expr_gen, specfunc, v0, v1, c0, result); exprtk_debug(("(v0 / c) +/- (v1 / c) --> (vovoc) (v0 +/- v1) / c\n")); @@ -30568,7 +31727,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -30577,7 +31740,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -30585,7 +31748,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30629,7 +31796,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)+t",(c0 + c1),v0,v1,result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(c0 + v0) + (v1 + c1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -30640,7 +31807,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)-t",(c0 - c1),v0,v1,result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(c0 + v0) - (v1 + c1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -30651,7 +31818,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t-(t+t)",(c0 + c1),v0,v1,result); + template compile(expr_gen, "t-(t+t)", (c0 + c1), v0, v1, result); exprtk_debug(("(c0 - v0) - (v1 - c1) --> (covov) (c0 + c1) - v0 - v1\n")); @@ -30662,7 +31829,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 * v0) * (v1 * c1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -30673,7 +31840,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (v1 * c1) --> (covov) (c0 / c1) * (v0 / v1)\n")); @@ -30684,7 +31851,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t*(t/t)",(c0 / c1),v1,v0,result); + template compile(expr_gen, "t*(t/t)", (c0 / c1), v1, v0, result); exprtk_debug(("(c0 / v0) * (v1 / c1) --> (covov) (c0 / c1) * (v1 / v0)\n")); @@ -30695,7 +31862,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",(c0 * c1),v0,v1,result); + template compile(expr_gen, "t/(t*t)", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 / v0) / (v1 / c1) --> (covov) (c0 * c1) / (v0 * v1)\n")); @@ -30706,7 +31873,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c0 * c1),v0,v1,result); + template compile(expr_gen, "(t*t)/t", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (v1 / c1) --> (covov) (c0 * c1) * (v0 / v1)\n")); @@ -30717,7 +31884,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"t/(t*t)",(c0 / c1),v0,v1,result); + template compile(expr_gen, "t/(t*t)", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 / v0) / (v1 * c1) --> (covov) (c0 / c1) / (v0 * v1)\n")); @@ -30745,7 +31912,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc,c0,v0,v1,result); + template compile(expr_gen,specfunc, c0, v0, v1, result); exprtk_debug(("(c * v0) +/- (v1 * c) --> (covov) c * (v0 +/- v1)\n")); @@ -30753,7 +31920,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -30762,7 +31933,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -30770,7 +31941,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30814,7 +31989,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)+t",(c0 + c1),v0,v1,result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(v0 + c0) + (c1 + v1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -30825,7 +32000,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)-t",(c0 - c1),v0,v1,result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(v0 + c0) - (c1 + v1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -30836,7 +32011,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t+t)-t",v0,v1,(c1 + c0),result); + template compile(expr_gen, "(t+t)-t", v0, v1, (c1 + c0), result); exprtk_debug(("(v0 - c0) - (c1 - v1) --> (vovoc) v0 + v1 - (c1 + c0)\n")); @@ -30847,7 +32022,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(v0 * c0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -30858,7 +32033,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (c1 * v1) --> (covov) (c0 / c1) * (v0 * v1)\n")); @@ -30869,7 +32044,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",(c1 / c0),v0,v1,result); + template compile(expr_gen, "(t*t)/t", (c1 / c0), v0, v1, result); exprtk_debug(("(v0 / c0) * (c1 / v1) --> (covov) (c1 / c0) * (v0 / v1)\n")); @@ -30880,7 +32055,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)*t",(c0 / c1),v0,v1,result); + template compile(expr_gen, "(t*t)*t", (c0 / c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (c1 / v1) --> (covov) (c0 / c1) * (v0 * v1)\n")); @@ -30891,7 +32066,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)/t",Type(1) / (c0 * c1),v0,v1,result); + template compile(expr_gen, "(t*t)/t", Type(1) / (c0 * c1), v0, v1, result); exprtk_debug(("(v0 / c0) / (c1 * v1) --> (covov) (1 / (c0 * c1)) * (v0 / v1)\n")); @@ -30902,7 +32077,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,"(t*t)*t",v0,v1,Type(1) / (c0 * c1),result); + template compile(expr_gen, "(t*t)*t", v0, v1, Type(1) / (c0 * c1), result); exprtk_debug(("(v0 / c0) / (c1 / v1) --> (vovoc) (v0 * v1) * (1 / (c0 * c1))\n")); @@ -30929,7 +32104,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc,c0,v0,v1,result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(v0 * c) +/- (c * v1) --> (covov) c * (v0 +/- v1)\n")); @@ -30937,7 +32112,11 @@ namespace exprtk } } - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -30946,7 +32125,7 @@ namespace exprtk else if (!expr_gen.valid_operator(o2,f2)) return error_node(); else - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -30954,7 +32133,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31006,7 +32189,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31043,14 +32230,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,c,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, c, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 (v1 o1 (v2 o2 c))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,c,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, c, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31058,7 +32249,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31095,14 +32290,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,c,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, c, v2, result); + + if (synthesis_result) return result; if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 (v1 o1 (c o2 v2))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,c,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, c, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31110,7 +32309,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31147,14 +32350,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 (c o1 (v1 o2 v2))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31162,7 +32369,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31200,14 +32411,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c,v0,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c, v0, v1, v2, result); + + if (synthesis_result) return result; if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("c o0 (v0 o1 (v1 o2 v2))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c,v0,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31215,7 +32430,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31253,14 +32472,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("c0 o0 (v0 o1 (c1 o2 v1))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31268,7 +32491,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31305,14 +32532,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 (c0 o1 (v1 o2 c2))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31320,7 +32551,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31357,14 +32592,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("c0 o0 (v0 o1 (v1 o2 c1))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31372,7 +32611,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31409,14 +32652,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 (c0 o1 (c1 o2 v1))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31424,7 +32671,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31461,14 +32712,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,v3,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, v3, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 ((v1 o1 v2) o2 v3)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,v3,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, v3, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31476,7 +32731,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31513,14 +32772,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,c,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, c, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 ((v1 o1 v2) o2 c)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,c,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, c, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31528,7 +32791,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31565,14 +32832,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,c,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, c, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 ((v1 o1 c) o2 v2)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,c,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, c, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31580,7 +32851,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31617,14 +32892,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 ((c o1 v1) o2 v2)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31632,7 +32911,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31670,14 +32953,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c,v0,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c, v0, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("c o0 ((v1 o1 v2) o2 v3)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c,v0,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31685,7 +32972,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31723,14 +33014,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("c0 o0 ((v0 o1 c1) o2 v1)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31738,7 +33033,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31775,14 +33074,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 ((c0 o1 v1) o2 c1)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31790,7 +33093,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31828,14 +33135,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("c0 o0 ((v0 o1 v1) o2 c1)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31843,7 +33154,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31897,14 +33212,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,v3,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, v3, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 v1) o1 v2) o2 v3\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,v3,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, v3, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31912,7 +33231,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -31950,14 +33273,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,c,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, c, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 v1) o1 v2) o2 c\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,c,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, c, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -31965,7 +33292,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32002,14 +33333,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,c,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, c, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 v1) o1 c) o2 v2\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,c,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, c, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32017,7 +33352,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32054,14 +33393,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 c) o1 v1) o2 v2\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32069,7 +33412,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32106,14 +33453,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c,v0,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c, v0, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((c o0 v0) o1 v1) o2 v2\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c,v0,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32121,7 +33472,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32158,14 +33513,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((c0 o0 v0) o1 c1) o2 v1\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32173,7 +33532,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32211,14 +33574,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 c0) o1 v1) o2 c1\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32226,7 +33593,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32264,14 +33635,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((c0 o0 v0) o1 v1) o2 c1\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32279,7 +33654,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32316,14 +33695,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 c0) o1 c1) o2 v1\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32331,7 +33714,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32368,14 +33755,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,v3,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, v3, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("(v0 o0 (v1 o1 v2)) o2 v3\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,v3,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, v3, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32383,7 +33774,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32421,14 +33816,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,c,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, v2, c, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 (v1 o1 v2)) o2 c)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,c,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, c, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32436,7 +33835,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32473,14 +33876,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,c,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, v1, c, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 (v1 o1 c)) o2 v1)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,c,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, c, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32488,7 +33895,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32524,14 +33935,18 @@ namespace exprtk details::free_node(*(expr_gen.node_allocator_),branch[0]); expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 (c o1 v1)) o2 v2)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32539,7 +33954,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32576,14 +33995,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c,v0,v1,v2,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c, v0, v1, v2, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((c o0 (v0 o1 v1)) o2 v2)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c,v0,v1,v2,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, v2, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32591,7 +34014,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32628,14 +34055,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,c1,v1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, c1, v1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((c0 o0 (v0 o1 c1)) o2 v1)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,c1,v1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, c1, v1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32643,7 +34074,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32681,14 +34116,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), v0, c0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((v0 o0 (c0 o1 v1)) o2 c1)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,c0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, c0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32696,7 +34135,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32734,14 +34177,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,v1,c1,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen, id(expr_gen, o0, o1, o2), c0, v0, v1, c1, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o2,f2)) return error_node(); exprtk_debug(("((c0 o0 (v0 o1 v1)) o2 c1)\n")); - return node_type::allocate(*(expr_gen.node_allocator_),c0,v0,v1,c1,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), c0, v0, v1, c1, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -32749,7 +34196,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32802,28 +34253,28 @@ namespace exprtk case details::e_add : result = (*this)(details::e_neg, node_allocator_-> allocate_rr > >(v0,v1)); + vov_node > >(v0, v1)); exprtk_debug(("(-v0 + -v1) --> -(v0 + v1)\n")); break; // (-v0 - -v1) --> (v1 - v0) case details::e_sub : result = node_allocator_-> allocate_rr > >(v1,v0); + vov_node > >(v1, v0); exprtk_debug(("(-v0 - -v1) --> (v1 - v0)\n")); break; // (-v0 * -v1) --> (v0 * v1) case details::e_mul : result = node_allocator_-> allocate_rr > >(v0,v1); + vov_node > >(v0, v1); exprtk_debug(("(-v0 * -v1) --> (v0 * v1)\n")); break; // (-v0 / -v1) --> (v0 / v1) case details::e_div : result = node_allocator_-> allocate_rr > >(v0,v1); + vov_node > >(v0, v1); exprtk_debug(("(-v0 / -v1) --> (v0 / v1)\n")); break; @@ -32834,7 +34285,7 @@ namespace exprtk if (0 == result) { result = node_allocator_-> - allocate_rrrrr >(v0,v1,u0,u1,f); + allocate_rrrrr >(v0, v1, u0, u1, f); } details::free_all_nodes(*node_allocator_,branch); @@ -32868,7 +34319,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ - (s0,s1,rp0); \ + (s0, s1, rp0); \ string_opr_switch_statements #undef case_stmt @@ -32886,7 +34337,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ - (s0,s1,rp1); \ + (s0, s1, rp1); \ string_opr_switch_statements #undef case_stmt @@ -32904,7 +34355,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ allocate_tttt >,T0,T1> \ - (s0,s1,rp0,rp1); \ + (s0, s1, rp0, rp1); \ string_opr_switch_statements #undef case_stmt @@ -32917,9 +34368,9 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate_tt >,T0,T1>(s0,s1); \ + #define case_stmt(op0,op1) \ + case op0 : return node_allocator_-> \ + allocate_tt >,T0,T1>(s0, s1); \ string_opr_switch_statements #undef case_stmt @@ -32932,7 +34383,7 @@ namespace exprtk std::string& s0 = static_cast*>(branch[0])->ref(); std::string& s1 = static_cast*>(branch[1])->ref(); - return synthesize_sos_expression_impl(opr,s0,s1); + return synthesize_sos_expression_impl(opr, s0, s1); } inline expression_node_ptr synthesize_sros_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -32945,7 +34396,7 @@ namespace exprtk free_node(*node_allocator_,branch[0]); - return synthesize_str_xrox_expression_impl(opr,s0,s1,rp0); + return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } inline expression_node_ptr synthesize_sosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -32958,7 +34409,7 @@ namespace exprtk free_node(*node_allocator_,branch[1]); - return synthesize_str_xoxr_expression_impl(opr,s0,s1,rp1); + return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } inline expression_node_ptr synthesize_socsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -32971,7 +34422,7 @@ namespace exprtk free_node(*node_allocator_,branch[1]); - return synthesize_str_xoxr_expression_impl(opr,s0,s1,rp1); + return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } inline expression_node_ptr synthesize_srosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -32987,7 +34438,7 @@ namespace exprtk details::free_node(*node_allocator_,branch[0]); details::free_node(*node_allocator_,branch[1]); - return synthesize_str_xroxr_expression_impl(opr,s0,s1,rp0,rp1); + return synthesize_str_xroxr_expression_impl(opr, s0, s1, rp0, rp1); } inline expression_node_ptr synthesize_socs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -32997,7 +34448,7 @@ namespace exprtk details::free_node(*node_allocator_,branch[1]); - return synthesize_sos_expression_impl(opr,s0,s1); + return synthesize_sos_expression_impl(opr, s0, s1); } inline expression_node_ptr synthesize_csos_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -33007,7 +34458,7 @@ namespace exprtk details::free_node(*node_allocator_,branch[0]); - return synthesize_sos_expression_impl(opr,s0,s1); + return synthesize_sos_expression_impl(opr, s0, s1); } inline expression_node_ptr synthesize_csosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -33021,7 +34472,7 @@ namespace exprtk details::free_node(*node_allocator_,branch[0]); details::free_node(*node_allocator_,branch[1]); - return synthesize_str_xoxr_expression_impl(opr,s0,s1,rp1); + return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } inline expression_node_ptr synthesize_srocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -33035,7 +34486,7 @@ namespace exprtk details::free_node(*node_allocator_,branch[0]); details::free_node(*node_allocator_,branch[1]); - return synthesize_str_xrox_expression_impl(opr,s0,s1,rp0); + return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } inline expression_node_ptr synthesize_srocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -33051,7 +34502,7 @@ namespace exprtk details::free_node(*node_allocator_,branch[0]); details::free_node(*node_allocator_,branch[1]); - return synthesize_str_xroxr_expression_impl(opr,s0,s1,rp0,rp1); + return synthesize_str_xroxr_expression_impl(opr, s0, s1, rp0, rp1); } inline expression_node_ptr synthesize_csocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -33064,16 +34515,19 @@ namespace exprtk if (details::e_add == opr) result = node_allocator_->allocate_c >(s0 + s1); else if (details::e_in == opr) - result = node_allocator_->allocate_c >(details::in_op::process(s0,s1)); + result = node_allocator_->allocate_c >(details::in_op ::process(s0,s1)); else if (details::e_like == opr) - result = node_allocator_->allocate_c >(details::like_op::process(s0,s1)); + result = node_allocator_->allocate_c >(details::like_op ::process(s0,s1)); else if (details::e_ilike == opr) result = node_allocator_->allocate_c >(details::ilike_op::process(s0,s1)); else { - expression_node_ptr temp = synthesize_sos_expression_impl(opr,s0,s1); - Type v = temp->value(); + expression_node_ptr temp = synthesize_sos_expression_impl(opr, s0, s1); + + const Type v = temp->value(); + details::free_node(*node_allocator_,temp); + result = node_allocator_->allocate(v); } @@ -33093,7 +34547,7 @@ namespace exprtk free_node(*node_allocator_,branch[0]); free_node(*node_allocator_,branch[1]); - return synthesize_str_xoxr_expression_impl(opr,s0,s1,rp1); + return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } inline expression_node_ptr synthesize_csros_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -33106,15 +34560,15 @@ namespace exprtk free_node(*node_allocator_,branch[0]); - return synthesize_str_xrox_expression_impl(opr,s0,s1,rp0); + return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } inline expression_node_ptr synthesize_csrosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { const std::string s0 = static_cast*>(branch[0])->str (); std::string& s1 = static_cast*> (branch[1])->ref (); - range_t rp0 = static_cast*>(branch[0])->range(); - range_t rp1 = static_cast*> (branch[1])->range(); + const range_t rp0 = static_cast*>(branch[0])->range(); + const range_t rp1 = static_cast*> (branch[1])->range(); static_cast*>(branch[0])->range_ref().clear(); static_cast*> (branch[1])->range_ref().clear(); @@ -33122,35 +34576,35 @@ namespace exprtk free_node(*node_allocator_,branch[0]); free_node(*node_allocator_,branch[1]); - return synthesize_str_xroxr_expression_impl(opr,s0,s1,rp0,rp1); + return synthesize_str_xroxr_expression_impl(opr, s0, s1, rp0, rp1); } inline expression_node_ptr synthesize_csrocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string s0 = static_cast*>(branch[0])->str (); + const std::string s0 = static_cast*>(branch[0])->str (); const std::string s1 = static_cast*> (branch[1])->str (); - range_t rp0 = static_cast*>(branch[0])->range(); + const range_t rp0 = static_cast*>(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); details::free_all_nodes(*node_allocator_,branch); - return synthesize_str_xrox_expression_impl(opr,s0,s1,rp0); + return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } inline expression_node_ptr synthesize_csrocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string s0 = static_cast*>(branch[0])->str (); - std::string s1 = static_cast*>(branch[1])->str (); - range_t rp0 = static_cast*>(branch[0])->range(); - range_t rp1 = static_cast*>(branch[1])->range(); + const std::string s0 = static_cast*>(branch[0])->str (); + const std::string s1 = static_cast*>(branch[1])->str (); + const range_t rp0 = static_cast*>(branch[0])->range(); + const range_t rp1 = static_cast*>(branch[1])->range(); static_cast*>(branch[0])->range_ref().clear(); static_cast*>(branch[1])->range_ref().clear(); details::free_all_nodes(*node_allocator_,branch); - return synthesize_str_xroxr_expression_impl(opr,s0,s1,rp0,rp1); + return synthesize_str_xroxr_expression_impl(opr, s0, s1, rp0, rp1); } inline expression_node_ptr synthesize_strogen_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) @@ -33160,7 +34614,7 @@ namespace exprtk #define case_stmt(op0,op1) \ case op0 : return node_allocator_-> \ allocate_ttt > > \ - (opr,branch[0],branch[1]); \ + (opr, branch[0], branch[1]); \ string_opr_switch_statements #undef case_stmt @@ -33277,7 +34731,8 @@ namespace exprtk const std::string s1 = static_cast*>(branch[1])->str(); const std::string s2 = static_cast*>(branch[2])->str(); - Type v = (((s0 <= s1) && (s1 <= s2)) ? Type(1) : Type(0)); + const Type v = (((s0 <= s1) && (s1 <= s2)) ? Type(1) : Type(0)); + details::free_all_nodes(*node_allocator_,branch); return node_allocator_->allocate_c >(v); @@ -33292,9 +34747,9 @@ namespace exprtk std::string& s1 = static_cast*>(branch[1])->ref(); std::string& s2 = static_cast*>(branch[2])->ref(); - typedef typename details::sosos_node > inrange_t; + typedef typename details::sosos_node > inrange_t; - return node_allocator_->allocate_type(s0,s1,s2); + return node_allocator_->allocate_type(s0, s1, s2); } else if ( details::is_const_string_node(branch[0]) && @@ -33306,12 +34761,12 @@ namespace exprtk std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); std::string s2 = static_cast*>(branch[2])->str(); - typedef typename details::sosos_node > inrange_t; + typedef typename details::sosos_node > inrange_t; details::free_node(*node_allocator_,branch[0]); details::free_node(*node_allocator_,branch[2]); - return node_allocator_->allocate_type(s0,s1,s2); + return node_allocator_->allocate_type(s0, s1, s2); } else if ( details::is_string_node(branch[0]) && @@ -33323,11 +34778,11 @@ namespace exprtk std::string s1 = static_cast*>(branch[1])->str(); std::string& s2 = static_cast< details::stringvar_node*>(branch[2])->ref(); - typedef typename details::sosos_node > inrange_t; + typedef typename details::sosos_node > inrange_t; details::free_node(*node_allocator_,branch[1]); - return node_allocator_->allocate_type(s0,s1,s2); + return node_allocator_->allocate_type(s0, s1, s2); } else if ( details::is_string_node(branch[0]) && @@ -33339,11 +34794,11 @@ namespace exprtk std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); std::string s2 = static_cast*>(branch[2])->str(); - typedef typename details::sosos_node > inrange_t; + typedef typename details::sosos_node > inrange_t; details::free_node(*node_allocator_,branch[2]); - return node_allocator_->allocate_type(s0,s1,s2); + return node_allocator_->allocate_type(s0, s1, s2); } else if ( details::is_const_string_node(branch[0]) && @@ -33355,11 +34810,11 @@ namespace exprtk std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); std::string& s2 = static_cast< details::stringvar_node*>(branch[2])->ref(); - typedef typename details::sosos_node > inrange_t; + typedef typename details::sosos_node > inrange_t; details::free_node(*node_allocator_,branch[0]); - return node_allocator_->allocate_type(s0,s1,s2); + return node_allocator_->allocate_type(s0, s1, s2); } else return error_node(); @@ -33387,8 +34842,8 @@ namespace exprtk typedef typename details::null_eq_node nulleq_node_t; - bool b0_null = details::is_null_node(branch[0]); - bool b1_null = details::is_null_node(branch[1]); + const bool b0_null = details::is_null_node(branch[0]); + const bool b1_null = details::is_null_node(branch[1]); if (b0_null && b1_null) { @@ -33475,7 +34930,11 @@ namespace exprtk (details::e_like == operation) || (details::e_ilike == operation) ) + { + free_all_nodes(*node_allocator_,branch); + return error_node(); + } else if (!details::all_nodes_valid(branch)) { free_all_nodes(*node_allocator_,branch); @@ -33489,7 +34948,7 @@ namespace exprtk if (is_constant_foldable(branch)) { - Type v = expression_point->value(); + const Type v = expression_point->value(); details::free_node(*node_allocator_,expression_point); return node_allocator_->allocate(v); @@ -33540,15 +34999,15 @@ namespace exprtk return expression_point; } - bool strength_reduction_enabled_; + bool strength_reduction_enabled_; details::node_allocator* node_allocator_; - synthesize_map_t synthesize_map_; - unary_op_map_t* unary_op_map_; - binary_op_map_t* binary_op_map_; - inv_binary_op_map_t* inv_binary_op_map_; - sf3_map_t* sf3_map_; - sf4_map_t* sf4_map_; - parser_t* parser_; + synthesize_map_t synthesize_map_; + unary_op_map_t* unary_op_map_; + binary_op_map_t* binary_op_map_; + inv_binary_op_map_t* inv_binary_op_map_; + sf3_map_t* sf3_map_; + sf4_map_t* sf4_map_; + parser_t* parser_; }; inline void set_error(const parser_error::type& error_type) @@ -33590,7 +35049,7 @@ namespace exprtk if (se.data) { - e.register_local_data(se.data,1,0); + e.register_local_data(se.data, 1, 0); } } else if (scope_element::e_vector == se.type) @@ -33602,7 +35061,7 @@ namespace exprtk if (se.data) { - e.register_local_data(se.data,se.size,1); + e.register_local_data(se.data, se.size, 1); } } #ifndef exprtk_disable_string_capabilities @@ -33615,7 +35074,7 @@ namespace exprtk if (se.data) { - e.register_local_data(se.data,se.size,2); + e.register_local_data(se.data, se.size, 2); } } #endif @@ -33642,45 +35101,45 @@ namespace exprtk #define register_unary_op(Op,UnaryFunctor) \ m.insert(std::make_pair(Op,UnaryFunctor::process)); \ - register_unary_op(details:: e_abs,details:: abs_op) - register_unary_op(details:: e_acos,details:: acos_op) - register_unary_op(details::e_acosh,details::acosh_op) - register_unary_op(details:: e_asin,details:: asin_op) - register_unary_op(details::e_asinh,details::asinh_op) - register_unary_op(details::e_atanh,details::atanh_op) - register_unary_op(details:: e_ceil,details:: ceil_op) - register_unary_op(details:: e_cos,details:: cos_op) - register_unary_op(details:: e_cosh,details:: cosh_op) - register_unary_op(details:: e_exp,details:: exp_op) - register_unary_op(details::e_expm1,details::expm1_op) - register_unary_op(details::e_floor,details::floor_op) - register_unary_op(details:: e_log,details:: log_op) - register_unary_op(details::e_log10,details::log10_op) - register_unary_op(details:: e_log2,details:: log2_op) - register_unary_op(details::e_log1p,details::log1p_op) - register_unary_op(details:: e_neg,details:: neg_op) - register_unary_op(details:: e_pos,details:: pos_op) - register_unary_op(details::e_round,details::round_op) - register_unary_op(details:: e_sin,details:: sin_op) - register_unary_op(details:: e_sinc,details:: sinc_op) - register_unary_op(details:: e_sinh,details:: sinh_op) - register_unary_op(details:: e_sqrt,details:: sqrt_op) - register_unary_op(details:: e_tan,details:: tan_op) - register_unary_op(details:: e_tanh,details:: tanh_op) - register_unary_op(details:: e_cot,details:: cot_op) - register_unary_op(details:: e_sec,details:: sec_op) - register_unary_op(details:: e_csc,details:: csc_op) - register_unary_op(details:: e_r2d,details:: r2d_op) - register_unary_op(details:: e_d2r,details:: d2r_op) - register_unary_op(details:: e_d2g,details:: d2g_op) - register_unary_op(details:: e_g2d,details:: g2d_op) - register_unary_op(details:: e_notl,details:: notl_op) - register_unary_op(details:: e_sgn,details:: sgn_op) - register_unary_op(details:: e_erf,details:: erf_op) - register_unary_op(details:: e_erfc,details:: erfc_op) - register_unary_op(details:: e_ncdf,details:: ncdf_op) - register_unary_op(details:: e_frac,details:: frac_op) - register_unary_op(details::e_trunc,details::trunc_op) + register_unary_op(details:: e_abs, details:: abs_op) + register_unary_op(details:: e_acos, details:: acos_op) + register_unary_op(details::e_acosh, details::acosh_op) + register_unary_op(details:: e_asin, details:: asin_op) + register_unary_op(details::e_asinh, details::asinh_op) + register_unary_op(details::e_atanh, details::atanh_op) + register_unary_op(details:: e_ceil, details:: ceil_op) + register_unary_op(details:: e_cos, details:: cos_op) + register_unary_op(details:: e_cosh, details:: cosh_op) + register_unary_op(details:: e_exp, details:: exp_op) + register_unary_op(details::e_expm1, details::expm1_op) + register_unary_op(details::e_floor, details::floor_op) + register_unary_op(details:: e_log, details:: log_op) + register_unary_op(details::e_log10, details::log10_op) + register_unary_op(details:: e_log2, details:: log2_op) + register_unary_op(details::e_log1p, details::log1p_op) + register_unary_op(details:: e_neg, details:: neg_op) + register_unary_op(details:: e_pos, details:: pos_op) + register_unary_op(details::e_round, details::round_op) + register_unary_op(details:: e_sin, details:: sin_op) + register_unary_op(details:: e_sinc, details:: sinc_op) + register_unary_op(details:: e_sinh, details:: sinh_op) + register_unary_op(details:: e_sqrt, details:: sqrt_op) + register_unary_op(details:: e_tan, details:: tan_op) + register_unary_op(details:: e_tanh, details:: tanh_op) + register_unary_op(details:: e_cot, details:: cot_op) + register_unary_op(details:: e_sec, details:: sec_op) + register_unary_op(details:: e_csc, details:: csc_op) + register_unary_op(details:: e_r2d, details:: r2d_op) + register_unary_op(details:: e_d2r, details:: d2r_op) + register_unary_op(details:: e_d2g, details:: d2g_op) + register_unary_op(details:: e_g2d, details:: g2d_op) + register_unary_op(details:: e_notl, details:: notl_op) + register_unary_op(details:: e_sgn, details:: sgn_op) + register_unary_op(details:: e_erf, details:: erf_op) + register_unary_op(details:: e_erfc, details:: erfc_op) + register_unary_op(details:: e_ncdf, details:: ncdf_op) + register_unary_op(details:: e_frac, details:: frac_op) + register_unary_op(details::e_trunc, details::trunc_op) #undef register_unary_op } @@ -33691,24 +35150,24 @@ namespace exprtk #define register_binary_op(Op,BinaryFunctor) \ m.insert(value_type(Op,BinaryFunctor::process)); \ - register_binary_op(details:: e_add,details:: add_op) - register_binary_op(details:: e_sub,details:: sub_op) - register_binary_op(details:: e_mul,details:: mul_op) - register_binary_op(details:: e_div,details:: div_op) - register_binary_op(details:: e_mod,details:: mod_op) - register_binary_op(details:: e_pow,details:: pow_op) - register_binary_op(details:: e_lt,details:: lt_op) - register_binary_op(details:: e_lte,details:: lte_op) - register_binary_op(details:: e_gt,details:: gt_op) - register_binary_op(details:: e_gte,details:: gte_op) - register_binary_op(details:: e_eq,details:: eq_op) - register_binary_op(details:: e_ne,details:: ne_op) - register_binary_op(details:: e_and,details:: and_op) - register_binary_op(details::e_nand,details::nand_op) - register_binary_op(details:: e_or,details:: or_op) - register_binary_op(details:: e_nor,details:: nor_op) - register_binary_op(details:: e_xor,details:: xor_op) - register_binary_op(details::e_xnor,details::xnor_op) + register_binary_op(details:: e_add, details:: add_op) + register_binary_op(details:: e_sub, details:: sub_op) + register_binary_op(details:: e_mul, details:: mul_op) + register_binary_op(details:: e_div, details:: div_op) + register_binary_op(details:: e_mod, details:: mod_op) + register_binary_op(details:: e_pow, details:: pow_op) + register_binary_op(details:: e_lt, details:: lt_op) + register_binary_op(details:: e_lte, details:: lte_op) + register_binary_op(details:: e_gt, details:: gt_op) + register_binary_op(details:: e_gte, details:: gte_op) + register_binary_op(details:: e_eq, details:: eq_op) + register_binary_op(details:: e_ne, details:: ne_op) + register_binary_op(details:: e_and, details:: and_op) + register_binary_op(details::e_nand, details::nand_op) + register_binary_op(details:: e_or, details:: or_op) + register_binary_op(details:: e_nor, details:: nor_op) + register_binary_op(details:: e_xor, details:: xor_op) + register_binary_op(details::e_xnor, details::xnor_op) #undef register_binary_op } @@ -33719,24 +35178,24 @@ namespace exprtk #define register_binary_op(Op,BinaryFunctor) \ m.insert(value_type(BinaryFunctor::process,Op)); \ - register_binary_op(details:: e_add,details:: add_op) - register_binary_op(details:: e_sub,details:: sub_op) - register_binary_op(details:: e_mul,details:: mul_op) - register_binary_op(details:: e_div,details:: div_op) - register_binary_op(details:: e_mod,details:: mod_op) - register_binary_op(details:: e_pow,details:: pow_op) - register_binary_op(details:: e_lt,details:: lt_op) - register_binary_op(details:: e_lte,details:: lte_op) - register_binary_op(details:: e_gt,details:: gt_op) - register_binary_op(details:: e_gte,details:: gte_op) - register_binary_op(details:: e_eq,details:: eq_op) - register_binary_op(details:: e_ne,details:: ne_op) - register_binary_op(details:: e_and,details:: and_op) - register_binary_op(details::e_nand,details::nand_op) - register_binary_op(details:: e_or,details:: or_op) - register_binary_op(details:: e_nor,details:: nor_op) - register_binary_op(details:: e_xor,details:: xor_op) - register_binary_op(details::e_xnor,details::xnor_op) + register_binary_op(details:: e_add, details:: add_op) + register_binary_op(details:: e_sub, details:: sub_op) + register_binary_op(details:: e_mul, details:: mul_op) + register_binary_op(details:: e_div, details:: div_op) + register_binary_op(details:: e_mod, details:: mod_op) + register_binary_op(details:: e_pow, details:: pow_op) + register_binary_op(details:: e_lt, details:: lt_op) + register_binary_op(details:: e_lte, details:: lte_op) + register_binary_op(details:: e_gt, details:: gt_op) + register_binary_op(details:: e_gte, details:: gte_op) + register_binary_op(details:: e_eq, details:: eq_op) + register_binary_op(details:: e_ne, details:: ne_op) + register_binary_op(details:: e_and, details:: and_op) + register_binary_op(details::e_nand, details::nand_op) + register_binary_op(details:: e_or, details:: or_op) + register_binary_op(details:: e_nor, details:: nor_op) + register_binary_op(details:: e_xor, details:: xor_op) + register_binary_op(details::e_xnor, details::xnor_op) #undef register_binary_op } @@ -33756,6 +35215,12 @@ namespace exprtk register_sf3(24) register_sf3(25) register_sf3(26) register_sf3(27) register_sf3(28) register_sf3(29) register_sf3(30) #undef register_sf3 + + #define register_sf3_extid(Id, Op) \ + sf3_map[Id] = pair_t(details::sf##Op##_op::process,details::e_sf##Op); \ + + register_sf3_extid("(t-t)-t",23) // (t-t)-t --> t-(t+t) + #undef register_sf3_extid } inline void load_sf4_map(sf4_map_t& sf4_map) @@ -33849,48 +35314,123 @@ namespace exprtk lexer::helper::helper_assembly helper_assembly_; - lexer::helper::commutative_inserter commutative_inserter_; - lexer::helper::operator_joiner operator_joiner_2_; - lexer::helper::operator_joiner operator_joiner_3_; - lexer::helper::symbol_replacer symbol_replacer_; - lexer::helper::bracket_checker bracket_checker_; - lexer::helper::numeric_checker numeric_checker_; - lexer::helper::sequence_validator sequence_validator_; + lexer::helper::commutative_inserter commutative_inserter_; + lexer::helper::operator_joiner operator_joiner_2_; + lexer::helper::operator_joiner operator_joiner_3_; + lexer::helper::symbol_replacer symbol_replacer_; + lexer::helper::bracket_checker bracket_checker_; + lexer::helper::numeric_checker numeric_checker_; + lexer::helper::sequence_validator sequence_validator_; + lexer::helper::sequence_validator_3tokens sequence_validator_3tkns_; template friend void details::disable_type_checking(ParserType& p); }; + namespace details + { + template + struct collector_helper + { + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef typename parser_t::dependent_entity_collector::symbol_t symbol_t; + typedef typename parser_t::unknown_symbol_resolver usr_t; + + struct resolve_as_vector : public parser_t::unknown_symbol_resolver + { + typedef exprtk::parser parser_t; + + resolve_as_vector() + : usr_t(usr_t::e_usrmode_extended) + {} + + virtual bool process(const std::string& unknown_symbol, + symbol_table_t& symbol_table, + std::string&) + { + static T v[1]; + symbol_table.add_vector(unknown_symbol,v); + return true; + } + }; + + static inline bool collection_pass(const std::string& expression_string, + std::set& symbol_set, + const bool collect_variables, + const bool collect_functions, + const bool vector_pass, + symbol_table_t& ext_symbol_table) + { + symbol_table_t symbol_table; + expression_t expression; + parser_t parser; + + resolve_as_vector vect_resolver; + + expression.register_symbol_table(symbol_table ); + expression.register_symbol_table(ext_symbol_table); + + if (vector_pass) + parser.enable_unknown_symbol_resolver(&vect_resolver); + else + parser.enable_unknown_symbol_resolver(); + + if (collect_variables) + parser.dec().collect_variables() = true; + + if (collect_functions) + parser.dec().collect_functions() = true; + + bool pass_result = false; + + details::disable_type_checking(parser); + + if (parser.compile(expression_string, expression)) + { + pass_result = true; + + std::deque symb_list; + parser.dec().symbols(symb_list); + + for (std::size_t i = 0; i < symb_list.size(); ++i) + { + symbol_set.insert(symb_list[i].first); + } + } + + return pass_result; + } + }; + } + template class Sequence> - inline bool collect_variables(const std::string& expr_str, + inline bool collect_variables(const std::string& expression, Sequence& symbol_list) { typedef double T; - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef parser_t::dependent_entity_collector::symbol_t symbol_t; + typedef details::collector_helper collect_t; - symbol_table_t symbol_table; - expression_t expression; - parser_t parser; + collect_t::symbol_table_t null_symbol_table; - expression.register_symbol_table(symbol_table); + std::set symbol_set; - parser.enable_unknown_symbol_resolver(); - parser.dec().collect_variables() = true; + const bool variable_pass = collect_t::collection_pass + (expression, symbol_set, true, false, false, null_symbol_table); + const bool vector_pass = collect_t::collection_pass + (expression, symbol_set, true, false, true, null_symbol_table); - if (!parser.compile(expr_str, expression)) + if (!variable_pass && !vector_pass) return false; - std::deque symb_list; - - parser.dec().symbols(symb_list); + std::set::iterator itr = symbol_set.begin(); - for (std::size_t i = 0; i < symb_list.size(); ++i) + while (symbol_set.end() != itr) { - symbol_list.push_back(symb_list[i].first); + symbol_list.push_back(*itr); + ++itr; } return true; @@ -33899,37 +35439,28 @@ namespace exprtk template class Sequence> - inline bool collect_variables(const std::string& expr_str, + inline bool collect_variables(const std::string& expression, exprtk::symbol_table& extrnl_symbol_table, Sequence& symbol_list) { - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef typename parser_t::dependent_entity_collector::symbol_t symbol_t; + typedef details::collector_helper collect_t; - symbol_table_t symbol_table; - expression_t expression; - parser_t parser; + std::set symbol_set; - expression.register_symbol_table(symbol_table); - expression.register_symbol_table(extrnl_symbol_table); - - parser.enable_unknown_symbol_resolver(); - parser.dec().collect_variables() = true; + const bool variable_pass = collect_t::collection_pass + (expression, symbol_set, true, false, false, extrnl_symbol_table); + const bool vector_pass = collect_t::collection_pass + (expression, symbol_set, true, false, true, extrnl_symbol_table); - details::disable_type_checking(parser); - - if (!parser.compile(expr_str, expression)) + if (!variable_pass && !vector_pass) return false; - std::deque symb_list; - - parser.dec().symbols(symb_list); + std::set::iterator itr = symbol_set.begin(); - for (std::size_t i = 0; i < symb_list.size(); ++i) + while (symbol_set.end() != itr) { - symbol_list.push_back(symb_list[i].first); + symbol_list.push_back(*itr); + ++itr; } return true; @@ -33937,34 +35468,30 @@ namespace exprtk template class Sequence> - inline bool collect_functions(const std::string& expr_str, + inline bool collect_functions(const std::string& expression, Sequence& symbol_list) { typedef double T; - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef parser_t::dependent_entity_collector::symbol_t symbol_t; + typedef details::collector_helper collect_t; - symbol_table_t symbol_table; - expression_t expression; - parser_t parser; + collect_t::symbol_table_t null_symbol_table; - expression.register_symbol_table(symbol_table); + std::set symbol_set; - parser.enable_unknown_symbol_resolver(); - parser.dec().collect_functions() = true; + const bool variable_pass = collect_t::collection_pass + (expression, symbol_set, false, true, false, null_symbol_table); + const bool vector_pass = collect_t::collection_pass + (expression, symbol_set, false, true, true, null_symbol_table); - if (!parser.compile(expr_str, expression)) + if (!variable_pass && !vector_pass) return false; - std::deque symb_list; - - parser.dec().symbols(symb_list); + std::set::iterator itr = symbol_set.begin(); - for (std::size_t i = 0; i < symb_list.size(); ++i) + while (symbol_set.end() != itr) { - symbol_list.push_back(symb_list[i].first); + symbol_list.push_back(*itr); + ++itr; } return true; @@ -33973,37 +35500,28 @@ namespace exprtk template class Sequence> - inline bool collect_functions(const std::string& expr_str, + inline bool collect_functions(const std::string& expression, exprtk::symbol_table& extrnl_symbol_table, Sequence& symbol_list) { - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef typename parser_t::dependent_entity_collector::symbol_t symbol_t; - - symbol_table_t symbol_table; - expression_t expression; - parser_t parser; - - expression.register_symbol_table(symbol_table); - expression.register_symbol_table(extrnl_symbol_table); + typedef details::collector_helper collect_t; - parser.enable_unknown_symbol_resolver(); - parser.dec().collect_functions() = true; + std::set symbol_set; - details::disable_type_checking(parser); + const bool variable_pass = collect_t::collection_pass + (expression, symbol_set, false, true, false, extrnl_symbol_table); + const bool vector_pass = collect_t::collection_pass + (expression, symbol_set, false, true, true, extrnl_symbol_table); - if (!parser.compile(expr_str, expression)) + if (!variable_pass && !vector_pass) return false; - std::deque symb_list; - - parser.dec().symbols(symb_list); + std::set::iterator itr = symbol_set.begin(); - for (std::size_t i = 0; i < symb_list.size(); ++i) + while (symbol_set.end() != itr) { - symbol_list.push_back(symb_list[i].first); + symbol_list.push_back(*itr); + ++itr; } return true; @@ -34018,15 +35536,15 @@ namespace exprtk if (r0 > r1) return T(0); - T h = (r1 - r0) / (T(2) * number_of_intervals); + const T h = (r1 - r0) / (T(2) * number_of_intervals); T total_area = T(0); for (std::size_t i = 0; i < number_of_intervals; ++i) { x = r0 + T(2) * i * h; - T y0 = e.value(); x += h; - T y1 = e.value(); x += h; - T y2 = e.value(); x += h; + const T y0 = e.value(); x += h; + const T y1 = e.value(); x += h; + const T y2 = e.value(); x += h; total_area += h * (y0 + T(4) * y1 + y2) / T(3); } @@ -34050,7 +35568,7 @@ namespace exprtk { T& x = var->ref(); T x_original = x; - T result = integrate(e,x,r0,r1,number_of_intervals); + T result = integrate(e, x, r0, r1, number_of_intervals); x = x_original; return result; @@ -34068,13 +35586,13 @@ namespace exprtk const T _2h = T(2) * h; x = x_init + _2h; - T y0 = e.value(); + const T y0 = e.value(); x = x_init + h; - T y1 = e.value(); + const T y1 = e.value(); x = x_init - h; - T y2 = e.value(); + const T y2 = e.value(); x = x_init - _2h; - T y3 = e.value(); + const T y3 = e.value(); x = x_init; return (-y0 + T(8) * (y1 - y2) + y3) / (T(12) * h); @@ -34088,15 +35606,15 @@ namespace exprtk const T x_init = x; const T _2h = T(2) * h; - T y = e.value(); + const T y = e.value(); x = x_init + _2h; - T y0 = e.value(); + const T y0 = e.value(); x = x_init + h; - T y1 = e.value(); + const T y1 = e.value(); x = x_init - h; - T y2 = e.value(); + const T y2 = e.value(); x = x_init - _2h; - T y3 = e.value(); + const T y3 = e.value(); x = x_init; return (-y0 + T(16) * (y1 + y2) - T(30) * y - y3) / (T(12) * h * h); @@ -34111,13 +35629,13 @@ namespace exprtk const T _2h = T(2) * h; x = x_init + _2h; - T y0 = e.value(); + const T y0 = e.value(); x = x_init + h; - T y1 = e.value(); + const T y1 = e.value(); x = x_init - h; - T y2 = e.value(); + const T y2 = e.value(); x = x_init - _2h; - T y3 = e.value(); + const T y3 = e.value(); x = x_init; return (y0 + T(2) * (y2 - y1) - y3) / (T(2) * h * h * h); @@ -34141,7 +35659,7 @@ namespace exprtk { T& x = var->ref(); T x_original = x; - T result = derivative(e,x,h); + T result = derivative(e, x, h); x = x_original; return result; @@ -34167,8 +35685,8 @@ namespace exprtk if (var) { T& x = var->ref(); - T x_original = x; - T result = second_derivative(e,x,h); + const T x_original = x; + const T result = second_derivative(e, x, h); x = x_original; return result; @@ -34194,8 +35712,8 @@ namespace exprtk if (var) { T& x = var->ref(); - T x_original = x; - T result = third_derivative(e,x,h); + const T x_original = x; + const T result = third_derivative(e, x, h); x = x_original; return result; @@ -34486,79 +36004,79 @@ namespace exprtk #define poly_rtrn(NN) \ return (NN != N) ? std::numeric_limits::quiet_NaN() : - inline virtual T operator()(const T& x, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c1, const T& c0) { poly_rtrn(1) poly_impl::evaluate(x,c1,c0); } - inline virtual T operator()(const T& x, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c2, const T& c1, const T& c0) { poly_rtrn(2) poly_impl::evaluate(x,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(3) poly_impl::evaluate(x,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(4) poly_impl::evaluate(x,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(5) poly_impl::evaluate(x,c5,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(6) poly_impl::evaluate(x,c6,c5,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(7) poly_impl::evaluate(x,c7,c6,c5,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(8) poly_impl::evaluate(x,c8,c7,c6,c5,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(9) poly_impl::evaluate(x,c9,c8,c7,c6,c5,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(10) poly_impl::evaluate(x,c10,c9,c8,c7,c6,c5,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(11) poly_impl::evaluate(x,c11,c10,c9,c8,c7,c6,c5,c4,c3,c2,c1,c0); } - inline virtual T operator()(const T& x, const T& c12, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c12, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(12) poly_impl::evaluate(x,c12,c11,c10,c9,c8,c7,c6,c5,c4,c3,c2,c1,c0); } #undef poly_rtrn - inline virtual T operator()() + inline virtual T operator() () { return std::numeric_limits::quiet_NaN(); } - inline virtual T operator()(const T&) + inline virtual T operator() (const T&) { return std::numeric_limits::quiet_NaN(); } - inline virtual T operator()(const T&, const T&) + inline virtual T operator() (const T&, const T&) { return std::numeric_limits::quiet_NaN(); } @@ -34824,6 +36342,7 @@ namespace exprtk void copy(const lvr_vec_t& src_v, var_t& dest_v) { typename var_t::iterator itr = dest_v.begin(); + typedef typename std::iterator_traits::difference_type diff_t; for (std::size_t i = 0; i < src_v.size(); ++i) { @@ -34833,8 +36352,8 @@ namespace exprtk *itr++ = (*vr.first); else { - std::copy(vr.first,vr.first + vr.second,itr); - itr += vr.second; + std::copy(vr.first, vr.first + vr.second, itr); + itr += static_cast(vr.second); } } } @@ -34842,6 +36361,7 @@ namespace exprtk void copy(const var_t& src_v, lvr_vec_t& dest_v) { typename var_t::const_iterator itr = src_v.begin(); + typedef typename std::iterator_traits::difference_type diff_t; for (std::size_t i = 0; i < src_v.size(); ++i) { @@ -34851,8 +36371,8 @@ namespace exprtk (*vr.first) = *itr++; else { - std::copy(itr,itr + vr.second,vr.first); - itr += vr.second; + std::copy(itr, itr + static_cast(vr.second), vr.first); + itr += static_cast(vr.second); } } } @@ -34887,7 +36407,7 @@ namespace exprtk func_0param() : base_func(0) {} - inline T operator()() + inline T operator() () { return this->value(base_func::expression); } @@ -34915,13 +36435,11 @@ namespace exprtk func_1param() : base_func(1) {} - inline T operator()(type v0) + inline T operator() (type v0) { scoped_bft sb(*this); base_func::update(v0); - T result = this->value(base_func::expression); - - return result; + return this->value(base_func::expression); } }; @@ -34931,13 +36449,11 @@ namespace exprtk func_2param() : base_func(2) {} - inline T operator()(type v0, type v1) + inline T operator() (type v0, type v1) { scoped_bft sb(*this); - base_func::update(v0,v1); - T result = this->value(base_func::expression); - - return result; + base_func::update(v0, v1); + return this->value(base_func::expression); } }; @@ -34947,13 +36463,11 @@ namespace exprtk func_3param() : base_func(3) {} - inline T operator()(type v0, type v1, type v2) + inline T operator() (type v0, type v1, type v2) { scoped_bft sb(*this); - base_func::update(v0,v1,v2); - T result = this->value(base_func::expression); - - return result; + base_func::update(v0, v1, v2); + return this->value(base_func::expression); } }; @@ -34963,13 +36477,11 @@ namespace exprtk func_4param() : base_func(4) {} - inline T operator()(type v0, type v1, type v2, type v3) + inline T operator() (type v0, type v1, type v2, type v3) { scoped_bft sb(*this); - base_func::update(v0,v1,v2,v3); - T result = this->value(base_func::expression); - - return result; + base_func::update(v0, v1, v2, v3); + return this->value(base_func::expression); } }; @@ -34979,13 +36491,11 @@ namespace exprtk func_5param() : base_func(5) {} - inline T operator()(type v0, type v1, type v2, type v3, type v4) + inline T operator() (type v0, type v1, type v2, type v3, type v4) { scoped_bft sb(*this); - base_func::update(v0,v1,v2,v3,v4); - T result = this->value(base_func::expression); - - return result; + base_func::update(v0, v1, v2, v3, v4); + return this->value(base_func::expression); } }; @@ -34995,13 +36505,11 @@ namespace exprtk func_6param() : base_func(6) {} - inline T operator()(type v0, type v1, type v2, type v3, type v4, type v5) + inline T operator() (type v0, type v1, type v2, type v3, type v4, type v5) { scoped_bft sb(*this); - base_func::update(v0,v1,v2,v3,v4,v5); - T result = this->value(base_func::expression); - - return result; + base_func::update(v0, v1, v2, v3, v4, v5); + return this->value(base_func::expression); } }; @@ -35042,15 +36550,13 @@ namespace exprtk def_fp_retval(6) template class Sequence> + template class Sequence> inline bool add(const std::string& name, const std::string& expression, const Sequence& var_list, const bool override = false) { - const std::size_t n = var_list.size(); - - typename std::map::iterator itr = expr_map_.find(name); + const typename std::map::iterator itr = expr_map_.find(name); if (expr_map_.end() != itr) { @@ -35067,6 +36573,8 @@ namespace exprtk if (compile_expression(name,expression,var_list)) { + const std::size_t n = var_list.size(); + fp_map_[n][name]->setup(expr_map_[name]); return true; @@ -35132,13 +36640,13 @@ namespace exprtk inline bool add(const function& f, const bool override = false) { - return add(f.name_,f.expression_,f.v_,override); + return add(f.name_, f.expression_, f.v_,override); } private: template class Sequence> + template class Sequence> bool compile_expression(const std::string& name, const std::string& expression, const Sequence& input_var_list, @@ -35195,7 +36703,7 @@ namespace exprtk { remove(name,input_var_list.size()); - return compile_expression(name,expression,input_var_list,true); + return compile_expression(name, expression, input_var_list, true); } // Make sure every return point has a scalar as its first parameter @@ -35290,14 +36798,14 @@ namespace exprtk if (arg_count > 6) return; - typename std::map::iterator em_itr = expr_map_.find(name); + const typename std::map::iterator em_itr = expr_map_.find(name); if (expr_map_.end() != em_itr) { expr_map_.erase(em_itr); } - typename funcparam_t::iterator fp_itr = fp_map_[arg_count].find(name); + const typename funcparam_t::iterator fp_itr = fp_map_[arg_count].find(name); if (fp_map_[arg_count].end() != fp_itr) { @@ -35320,89 +36828,90 @@ namespace exprtk template inline bool pgo_primer() { - static const std::string expression_list[] - = { - "(y + x)", - "2 * (y + x)", - "(2 * y + 2 * x)", - "(y + x / y) * (x - y / x)", - "x / ((x + y) * (x - y)) / y", - "1 - ((x * y) + (y / x)) - 3", - "sin(2 * x) + cos(pi / y)", - "1 - sin(2 * x) + cos(pi / y)", - "sqrt(1 - sin(2 * x) + cos(pi / y) / 3)", - "(x^2 / sin(2 * pi / y)) -x / 2", - "x + (cos(y - sin(2 / x * pi)) - sin(x - cos(2 * y / pi))) - y", - "clamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)", - "iclamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)", - "max(3.33, min(sqrt(1 - sin(2 * x) + cos(pi / y) / 3), 1.11))", - "if(avg(x,y) <= x + y, x - y, x * y) + 2 * pi / x", - "1.1x^1 + 2.2y^2 - 3.3x^3 + 4.4y^4 - 5.5x^5 + 6.6y^6 - 7.7x^27 + 8.8y^55", - "(yy + xx)", - "2 * (yy + xx)", - "(2 * yy + 2 * xx)", - "(yy + xx / yy) * (xx - yy / xx)", - "xx / ((xx + yy) * (xx - yy)) / yy", - "1 - ((xx * yy) + (yy / xx)) - 3", - "sin(2 * xx) + cos(pi / yy)", - "1 - sin(2 * xx) + cos(pi / yy)", - "sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3)", - "(xx^2 / sin(2 * pi / yy)) -xx / 2", - "xx + (cos(yy - sin(2 / xx * pi)) - sin(xx - cos(2 * yy / pi))) - yy", - "clamp(-1.0, sin(2 * pi * xx) + cos(yy / 2 * pi), +1.0)", - "max(3.33, min(sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3), 1.11))", - "if(avg(xx,yy) <= xx + yy, xx - yy, xx * yy) + 2 * pi / xx", - "1.1xx^1 + 2.2yy^2 - 3.3xx^3 + 4.4yy^4 - 5.5xx^5 + 6.6yy^6 - 7.7xx^27 + 8.8yy^55", - "(1.1*(2.2*(3.3*(4.4*(5.5*(6.6*(7.7*(8.8*(9.9+x)))))))))", - "(((((((((x+9.9)*8.8)*7.7)*6.6)*5.5)*4.4)*3.3)*2.2)*1.1)", - "(x + y) * z", "x + (y * z)", "(x + y) * 7", "x + (y * 7)", - "(x + 7) * y", "x + (7 * y)", "(7 + x) * y", "7 + (x * y)", - "(2 + x) * 3", "2 + (x * 3)", "(2 + 3) * x", "2 + (3 * x)", - "(x + 2) * 3", "x + (2 * 3)", - "(x + y) * (z / w)", "(x + y) * (z / 7)", "(x + y) * (7 / z)", "(x + 7) * (y / z)", - "(7 + x) * (y / z)", "(2 + x) * (y / z)", "(x + 2) * (y / 3)", "(2 + x) * (y / 3)", - "(x + 2) * (3 / y)", "x + (y * (z / w))", "x + (y * (z / 7))", "x + (y * (7 / z))", - "x + (7 * (y / z))", "7 + (x * (y / z))", "2 + (x * (3 / y))", "x + (2 * (y / 4))", - "2 + (x * (y / 3))", "x + (2 * (3 / y))", - "x + ((y * z) / w)", "x + ((y * z) / 7)", "x + ((y * 7) / z)", "x + ((7 * y) / z)", - "7 + ((y * z) / w)", "2 + ((x * 3) / y)", "x + ((2 * y) / 3)", "2 + ((x * y) / 3)", - "x + ((2 * 3) / y)", "(((x + y) * z) / w)", - "(((x + y) * z) / 7)", "(((x + y) * 7) / z)", "(((x + 7) * y) / z)", "(((7 + x) * y) / z)", - "(((2 + x) * 3) / y)", "(((x + 2) * y) / 3)", "(((2 + x) * y) / 3)", "(((x + 2) * 3) / y)", - "((x + (y * z)) / w)", "((x + (y * z)) / 7)", "((x + (y * 7)) / y)", "((x + (7 * y)) / z)", - "((7 + (x * y)) / z)", "((2 + (x * 3)) / y)", "((x + (2 * y)) / 3)", "((2 + (x * y)) / 3)", - "((x + (2 * 3)) / y)", - "(xx + yy) * zz", "xx + (yy * zz)", - "(xx + yy) * 7", "xx + (yy * 7)", - "(xx + 7) * yy", "xx + (7 * yy)", - "(7 + xx) * yy", "7 + (xx * yy)", - "(2 + x) * 3", "2 + (x * 3)", - "(2 + 3) * x", "2 + (3 * x)", - "(x + 2) * 3", "x + (2 * 3)", - "(xx + yy) * (zz / ww)", "(xx + yy) * (zz / 7)", - "(xx + yy) * (7 / zz)", "(xx + 7) * (yy / zz)", - "(7 + xx) * (yy / zz)", "(2 + xx) * (yy / zz)", - "(xx + 2) * (yy / 3)", "(2 + xx) * (yy / 3)", - "(xx + 2) * (3 / yy)", "xx + (yy * (zz / ww))", - "xx + (yy * (zz / 7))", "xx + (yy * (7 / zz))", - "xx + (7 * (yy / zz))", "7 + (xx * (yy / zz))", - "2 + (xx * (3 / yy))", "xx + (2 * (yy / 4))", - "2 + (xx * (yy / 3))", "xx + (2 * (3 / yy))", - "xx + ((yy * zz) / ww)", "xx + ((yy * zz) / 7)", - "xx + ((yy * 7) / zz)", "xx + ((7 * yy) / zz)", - "7 + ((yy * zz) / ww)", "2 + ((xx * 3) / yy)", - "xx + ((2 * yy) / 3)", "2 + ((xx * yy) / 3)", - "xx + ((2 * 3) / yy)", "(((xx + yy) * zz) / ww)", - "(((xx + yy) * zz) / 7)", "(((xx + yy) * 7) / zz)", - "(((xx + 7) * yy) / zz)", "(((7 + xx) * yy) / zz)", - "(((2 + xx) * 3) / yy)", "(((xx + 2) * yy) / 3)", - "(((2 + xx) * yy) / 3)", "(((xx + 2) * 3) / yy)", - "((xx + (yy * zz)) / ww)", "((xx + (yy * zz)) / 7)", - "((xx + (yy * 7)) / yy)", "((xx + (7 * yy)) / zz)", - "((7 + (xx * yy)) / zz)", "((2 + (xx * 3)) / yy)", - "((xx + (2 * yy)) / 3)", "((2 + (xx * yy)) / 3)", - "((xx + (2 * 3)) / yy)" - }; + static const std::string expression_list[] = + { + "(y + x)", + "2 * (y + x)", + "(2 * y + 2 * x)", + "(y + x / y) * (x - y / x)", + "x / ((x + y) * (x - y)) / y", + "1 - ((x * y) + (y / x)) - 3", + "sin(2 * x) + cos(pi / y)", + "1 - sin(2 * x) + cos(pi / y)", + "sqrt(1 - sin(2 * x) + cos(pi / y) / 3)", + "(x^2 / sin(2 * pi / y)) -x / 2", + "x + (cos(y - sin(2 / x * pi)) - sin(x - cos(2 * y / pi))) - y", + "clamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)", + "iclamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)", + "max(3.33, min(sqrt(1 - sin(2 * x) + cos(pi / y) / 3), 1.11))", + "if(avg(x,y) <= x + y, x - y, x * y) + 2 * pi / x", + "1.1x^1 + 2.2y^2 - 3.3x^3 + 4.4y^4 - 5.5x^5 + 6.6y^6 - 7.7x^27 + 8.8y^55", + "(yy + xx)", + "2 * (yy + xx)", + "(2 * yy + 2 * xx)", + "(yy + xx / yy) * (xx - yy / xx)", + "xx / ((xx + yy) * (xx - yy)) / yy", + "1 - ((xx * yy) + (yy / xx)) - 3", + "sin(2 * xx) + cos(pi / yy)", + "1 - sin(2 * xx) + cos(pi / yy)", + "sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3)", + "(xx^2 / sin(2 * pi / yy)) -xx / 2", + "xx + (cos(yy - sin(2 / xx * pi)) - sin(xx - cos(2 * yy / pi))) - yy", + "clamp(-1.0, sin(2 * pi * xx) + cos(yy / 2 * pi), +1.0)", + "max(3.33, min(sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3), 1.11))", + "if(avg(xx,yy) <= xx + yy, xx - yy, xx * yy) + 2 * pi / xx", + "1.1xx^1 + 2.2yy^2 - 3.3xx^3 + 4.4yy^4 - 5.5xx^5 + 6.6yy^6 - 7.7xx^27 + 8.8yy^55", + "(1.1*(2.2*(3.3*(4.4*(5.5*(6.6*(7.7*(8.8*(9.9+x)))))))))", + "(((((((((x+9.9)*8.8)*7.7)*6.6)*5.5)*4.4)*3.3)*2.2)*1.1)", + "(x + y) * z", "x + (y * z)", "(x + y) * 7", "x + (y * 7)", + "(x + 7) * y", "x + (7 * y)", "(7 + x) * y", "7 + (x * y)", + "(2 + x) * 3", "2 + (x * 3)", "(2 + 3) * x", "2 + (3 * x)", + "(x + 2) * 3", "x + (2 * 3)", + "(x + y) * (z / w)", "(x + y) * (z / 7)", "(x + y) * (7 / z)", "(x + 7) * (y / z)", + "(7 + x) * (y / z)", "(2 + x) * (y / z)", "(x + 2) * (y / 3)", "(2 + x) * (y / 3)", + "(x + 2) * (3 / y)", "x + (y * (z / w))", "x + (y * (z / 7))", "x + (y * (7 / z))", + "x + (7 * (y / z))", "7 + (x * (y / z))", "2 + (x * (3 / y))", "x + (2 * (y / 4))", + "2 + (x * (y / 3))", "x + (2 * (3 / y))", + "x + ((y * z) / w)", "x + ((y * z) / 7)", "x + ((y * 7) / z)", "x + ((7 * y) / z)", + "7 + ((y * z) / w)", "2 + ((x * 3) / y)", "x + ((2 * y) / 3)", "2 + ((x * y) / 3)", + "x + ((2 * 3) / y)", "(((x + y) * z) / w)", + "(((x + y) * z) / 7)", "(((x + y) * 7) / z)", "(((x + 7) * y) / z)", "(((7 + x) * y) / z)", + "(((2 + x) * 3) / y)", "(((x + 2) * y) / 3)", "(((2 + x) * y) / 3)", "(((x + 2) * 3) / y)", + "((x + (y * z)) / w)", "((x + (y * z)) / 7)", "((x + (y * 7)) / y)", "((x + (7 * y)) / z)", + "((7 + (x * y)) / z)", "((2 + (x * 3)) / y)", "((x + (2 * y)) / 3)", "((2 + (x * y)) / 3)", + "((x + (2 * 3)) / y)", + "(xx + yy) * zz", "xx + (yy * zz)", + "(xx + yy) * 7", "xx + (yy * 7)", + "(xx + 7) * yy", "xx + (7 * yy)", + "(7 + xx) * yy", "7 + (xx * yy)", + "(2 + x) * 3", "2 + (x * 3)", + "(2 + 3) * x", "2 + (3 * x)", + "(x + 2) * 3", "x + (2 * 3)", + "(xx + yy) * (zz / ww)", "(xx + yy) * (zz / 7)", + "(xx + yy) * (7 / zz)", "(xx + 7) * (yy / zz)", + "(7 + xx) * (yy / zz)", "(2 + xx) * (yy / zz)", + "(xx + 2) * (yy / 3)", "(2 + xx) * (yy / 3)", + "(xx + 2) * (3 / yy)", "xx + (yy * (zz / ww))", + "xx + (yy * (zz / 7))", "xx + (yy * (7 / zz))", + "xx + (7 * (yy / zz))", "7 + (xx * (yy / zz))", + "2 + (xx * (3 / yy))", "xx + (2 * (yy / 4))", + "2 + (xx * (yy / 3))", "xx + (2 * (3 / yy))", + "xx + ((yy * zz) / ww)", "xx + ((yy * zz) / 7)", + "xx + ((yy * 7) / zz)", "xx + ((7 * yy) / zz)", + "7 + ((yy * zz) / ww)", "2 + ((xx * 3) / yy)", + "xx + ((2 * yy) / 3)", "2 + ((xx * yy) / 3)", + "xx + ((2 * 3) / yy)", "(((xx + yy) * zz) / ww)", + "(((xx + yy) * zz) / 7)", "(((xx + yy) * 7) / zz)", + "(((xx + 7) * yy) / zz)", "(((7 + xx) * yy) / zz)", + "(((2 + xx) * 3) / yy)", "(((xx + 2) * yy) / 3)", + "(((2 + xx) * yy) / 3)", "(((xx + 2) * 3) / yy)", + "((xx + (yy * zz)) / ww)", "((xx + (yy * zz)) / 7)", + "((xx + (yy * 7)) / yy)", "((xx + (7 * yy)) / zz)", + "((7 + (xx * yy)) / zz)", "((2 + (xx * 3)) / yy)", + "((xx + (2 * yy)) / 3)", "((2 + (xx * yy)) / 3)", + "((xx + (2 * 3)) / yy)" + }; + static const std::size_t expression_list_size = sizeof(expression_list) / sizeof(std::string); T x = T(0); @@ -35457,8 +36966,8 @@ namespace exprtk { static const T lower_bound = T(-20); static const T upper_bound = T(+20); + static const T delta = T(0.1); - T delta = T(0.1); T total = T(0); for (x = lower_bound; x <= upper_bound; x += delta) @@ -35482,7 +36991,7 @@ namespace exprtk { for (std::size_t i = 0; i < 10000; ++i) { - T v = T(123.456 + i); + const T v = T(123.456 + i); if (details::is_true(details::numeric::nequal(details::numeric::fast_exp::result(v),details::numeric::pow(v,T( 1))))) return false; @@ -35587,8 +37096,8 @@ namespace exprtk { if (stop_time_.tv_sec >= start_time_.tv_sec) { - return 1000000 * (stop_time_.tv_sec - start_time_.tv_sec ) + - (stop_time_.tv_usec - start_time_.tv_usec); + return 1000000LLU * static_cast(stop_time_.tv_sec - start_time_.tv_sec ) + + static_cast(stop_time_.tv_usec - start_time_.tv_usec) ; } else return std::numeric_limits::max(); @@ -35707,7 +37216,7 @@ namespace exprtk exprtk::enable_zero_parameters(*this); } - inline T operator()(parameter_list_t parameters) + inline T operator() (parameter_list_t parameters) { details::print_impl::process(scalar_format_,parameters); return T(0); @@ -35729,7 +37238,7 @@ namespace exprtk exprtk::enable_zero_parameters(*this); } - inline T operator()(parameter_list_t parameters) + inline T operator() (parameter_list_t parameters) { details::print_impl::process(scalar_format_,parameters); printf("\n"); @@ -35756,8 +37265,8 @@ namespace exprtk return false; \ } \ - exprtk_register_function("print" , p) - exprtk_register_function("println" ,pl) + exprtk_register_function("print" , p) + exprtk_register_function("println", pl) #undef exprtk_register_function return true; @@ -35925,7 +37434,7 @@ namespace exprtk } } - bool eof() + bool eof() const { switch (mode) { @@ -35936,7 +37445,7 @@ namespace exprtk } } - file_mode get_file_mode(const std::string& access) + file_mode get_file_mode(const std::string& access) const { if (access.empty() || access.size() > 2) return e_error; @@ -35946,11 +37455,7 @@ namespace exprtk for (std::size_t i = 0; i < access.size(); ++i) { - #ifdef MODIFICATION - switch (access[i]) - #else switch (std::tolower(access[i])) - #endif { case 'r' : r_cnt++; break; case 'w' : w_cnt++; break; @@ -35997,6 +37502,7 @@ namespace exprtk #pragma warning(pop) #endif } + } // namespace exprtk::rtl::io::file::details template @@ -36015,13 +37521,11 @@ namespace exprtk : exprtk::igeneric_function("S|SS") { details::perform_check(); } - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - std::string file_name; + std::string file_name = to_str(string_t(parameters[0])); std::string access; - file_name = to_str(string_t(parameters[0])); - if (file_name.empty()) return T(0); @@ -36038,7 +37542,7 @@ namespace exprtk { T t = T(0); - std::memcpy(reinterpret_cast(&t), + std::memcpy(reinterpret_cast(&t ), reinterpret_cast(&fd), sizeof(fd)); return t; @@ -36060,7 +37564,7 @@ namespace exprtk : exprtk::ifunction(1) { details::perform_check(); } - inline T operator()(const T& v) + inline T operator() (const T& v) { details::file_descriptor* fd = details::make_handle(v); @@ -36091,7 +37595,7 @@ namespace exprtk : igfun_t("TS|TST|TV|TVT") { details::perform_check(); } - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { details::file_descriptor* fd = details::make_handle(scalar_t(parameters[0])()); @@ -36100,29 +37604,29 @@ namespace exprtk switch (ps_index) { case 0 : { - string_t buffer(parameters[1]); + const string_t buffer(parameters[1]); amount = buffer.size(); - return T(fd->write(buffer,amount) ? 1 : 0); + return T(fd->write(buffer, amount) ? 1 : 0); } case 1 : { - string_t buffer(parameters[1]); + const string_t buffer(parameters[1]); amount = std::min(buffer.size(), static_cast(scalar_t(parameters[2])())); - return T(fd->write(buffer,amount) ? 1 : 0); + return T(fd->write(buffer, amount) ? 1 : 0); } case 2 : { - vector_t vec(parameters[1]); + const vector_t vec(parameters[1]); amount = vec.size(); - return T(fd->write(vec,amount) ? 1 : 0); + return T(fd->write(vec, amount) ? 1 : 0); } case 3 : { - vector_t vec(parameters[1]); + const vector_t vec(parameters[1]); amount = std::min(vec.size(), static_cast(scalar_t(parameters[2])())); - return T(fd->write(vec,amount) ? 1 : 0); + return T(fd->write(vec, amount) ? 1 : 0); } } @@ -36148,7 +37652,7 @@ namespace exprtk : igfun_t("TS|TST|TV|TVT") { details::perform_check(); } - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { details::file_descriptor* fd = details::make_handle(scalar_t(parameters[0])()); @@ -36204,8 +37708,8 @@ namespace exprtk : igfun_t("T",igfun_t::e_rtrn_string) { details::perform_check(); } - inline T operator()(std::string& result, - parameter_list_t parameters) + inline T operator() (std::string& result, + parameter_list_t parameters) { details::file_descriptor* fd = details::make_handle(scalar_t(parameters[0])()); return T(fd->getline(result) ? 1 : 0); @@ -36221,7 +37725,7 @@ namespace exprtk : exprtk::ifunction(1) { details::perform_check(); } - inline T operator()(const T& v) + inline T operator() (const T& v) { details::file_descriptor* fd = details::make_handle(v); @@ -36315,7 +37819,7 @@ namespace exprtk if (!scalar_t(parameters[r1_prmidx]).to_uint(r1)) return false; - return !invalid_range(vector_t(parameters[vec_idx]),r0,r1); + return !invalid_range(vector_t(parameters[vec_idx]), r0, r1); } }; } @@ -36323,10 +37827,10 @@ namespace exprtk namespace details { template - inline void kahan_sum(T& sum, T& error, T v) + inline void kahan_sum(T& sum, T& error, const T v) { - T x = v - error; - T y = sum + x; + const T x = v - error; + const T y = sum + x; error = (y - sum) - x; sum = y; } @@ -36354,14 +37858,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - const vector_t& vec(parameters[0]); + const vector_t vec(parameters[0]); std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,1,2,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 1, 2, 0) + ) return std::numeric_limits::quiet_NaN(); for (std::size_t i = r0; i <= r1; ++i) @@ -36397,14 +37904,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - const vector_t& vec(parameters[0]); + const vector_t vec(parameters[0]); std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,1,2,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 1, 2, 0) + ) return std::numeric_limits::quiet_NaN(); for (std::size_t i = r0; i <= r1; ++i) @@ -36440,14 +37950,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - const vector_t& vec(parameters[0]); + const vector_t vec(parameters[0]); std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,1,2,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 1, 2, 0) + ) return std::numeric_limits::quiet_NaN(); for (std::size_t i = r0; i <= r1; ++i) @@ -36483,14 +37996,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - const vector_t& vec(parameters[0]); + const vector_t vec(parameters[0]); std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,1,2,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 1, 2, 0) + ) return std::numeric_limits::quiet_NaN(); for (std::size_t i = r0; i <= r1; ++i) @@ -36526,14 +38042,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - const vector_t& vec(parameters[0]); + const vector_t vec(parameters[0]); std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,1,2,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 1, 2, 0) + ) return std::numeric_limits::quiet_NaN(); std::size_t cnt = 0; @@ -36569,10 +38088,10 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[0]); - vector_t y(parameters[(0 == ps_index) ? 1 : 3]); + const vector_t x(parameters[0]); + vector_t y(parameters[(0 == ps_index) ? 1 : 3]); std::size_t xr0 = 0; std::size_t xr1 = x.size() - 1; @@ -36580,10 +38099,14 @@ namespace exprtk std::size_t yr0 = 0; std::size_t yr1 = y.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,xr0,xr1,1,2,0)) - return T(0); - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,yr0,yr1,4,5,3)) - return T(0); + if (1 == ps_index) + { + if ( + !helper::load_vector_range::process(parameters, xr0, xr1, 1, 2, 0) || + !helper::load_vector_range::process(parameters, yr0, yr1, 4, 5, 3) + ) + return T(0); + } const std::size_t n = std::min(xr1 - xr0 + 1, yr1 - yr0 + 1); @@ -36615,7 +38138,7 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { vector_t vec(parameters[0]); @@ -36626,7 +38149,10 @@ namespace exprtk if (!scalar_t(parameters[1]).to_uint(n)) return T(0); - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0) + ) return T(0); std::size_t dist = r1 - r0 + 1; @@ -36660,7 +38186,7 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { vector_t vec(parameters[0]); @@ -36671,7 +38197,10 @@ namespace exprtk if (!scalar_t(parameters[1]).to_uint(n)) return T(0); - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0) + ) return T(0); std::size_t dist = r1 - r0 + 1; @@ -36705,7 +38234,7 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { vector_t vec(parameters[0]); @@ -36716,7 +38245,10 @@ namespace exprtk if (!scalar_t(parameters[1]).to_uint(n)) return T(0); - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0) + ) return T(0); std::size_t dist = r1 - r0 + 1; @@ -36757,7 +38289,7 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { vector_t vec(parameters[0]); @@ -36768,7 +38300,10 @@ namespace exprtk if (!scalar_t(parameters[1]).to_uint(n)) return T(0); - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ( + (1 == ps_index) && + !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0) + ) return T(0); std::size_t dist = r1 - r0 + 1; @@ -36813,16 +38348,16 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { vector_t vec(parameters[0]); std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,1,2,0)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 1, 2, 0)) return T(0); - if ((3 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ((3 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0)) return T(0); bool ascending = true; @@ -36868,7 +38403,7 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { vector_t vec(parameters[0]); @@ -36879,7 +38414,7 @@ namespace exprtk if (!scalar_t(parameters[1]).to_uint(n)) return T(0); - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0)) return std::numeric_limits::quiet_NaN(); std::nth_element(vec.begin() + r0, vec.begin() + r0 + n , vec.begin() + r1 + 1); @@ -36912,7 +38447,7 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { vector_t vec(parameters[0]); @@ -36922,9 +38457,9 @@ namespace exprtk std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((2 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ((2 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0)) return std::numeric_limits::quiet_NaN(); - else if ((3 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,3,4,0)) + else if ((3 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 3, 4, 0)) return std::numeric_limits::quiet_NaN(); else { @@ -36961,14 +38496,14 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t vec(parameters[0]); + const vector_t vec(parameters[0]); std::size_t r0 = 0; std::size_t r1 = vec.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,1,2,0)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 1, 2, 0)) return std::numeric_limits::quiet_NaN(); T result = T(0); @@ -36976,7 +38511,7 @@ namespace exprtk for (std::size_t i = r0; i <= r1; ++i) { - details::kahan_sum(result,error,vec[i]); + details::kahan_sum(result, error, vec[i]); } return result; @@ -37006,24 +38541,24 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[1]); - vector_t y(parameters[2]); + const vector_t x(parameters[1]); + vector_t y(parameters[2]); std::size_t r0 = 0; std::size_t r1 = std::min(x.size(),y.size()) - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,3,4,1)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 3, 4, 1)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(y,r0,r1)) + else if (helper::invalid_range(y, r0, r1)) return std::numeric_limits::quiet_NaN(); - T a = scalar_t(parameters[0])(); + const T a = scalar_t(parameters[0])(); for (std::size_t i = r0; i <= r1; ++i) { - y[i] = a * x[i] + y[i]; + y[i] = (a * x[i]) + y[i]; } return T(1); @@ -37053,17 +38588,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[1]); - vector_t y(parameters[3]); + const vector_t x(parameters[1]); + vector_t y(parameters[3]); std::size_t r0 = 0; std::size_t r1 = std::min(x.size(),y.size()) - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,4,5,1)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 4, 5, 1)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(y,r0,r1)) + else if (helper::invalid_range(y, r0, r1)) return std::numeric_limits::quiet_NaN(); const T a = scalar_t(parameters[0])(); @@ -37101,27 +38636,27 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[1]); - vector_t y(parameters[2]); - vector_t z(parameters[3]); + const vector_t x(parameters[1]); + const vector_t y(parameters[2]); + vector_t z(parameters[3]); std::size_t r0 = 0; std::size_t r1 = std::min(x.size(),y.size()) - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,3,4,1)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 3, 4, 1)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(y,r0,r1)) + else if (helper::invalid_range(y, r0, r1)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(z,r0,r1)) + else if (helper::invalid_range(z, r0, r1)) return std::numeric_limits::quiet_NaN(); - T a = scalar_t(parameters[0])(); + const T a = scalar_t(parameters[0])(); for (std::size_t i = r0; i <= r1; ++i) { - z[i] = a * x[i] + y[i]; + z[i] = (a * x[i]) + y[i]; } return T(1); @@ -37151,20 +38686,20 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[1]); - vector_t y(parameters[3]); - vector_t z(parameters[4]); + const vector_t x(parameters[1]); + const vector_t y(parameters[3]); + vector_t z(parameters[4]); std::size_t r0 = 0; std::size_t r1 = std::min(x.size(),y.size()) - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,4,5,1)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 4, 5, 1)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(y,r0,r1)) + else if (helper::invalid_range(y, r0, r1)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(z,r0,r1)) + else if (helper::invalid_range(z, r0, r1)) return std::numeric_limits::quiet_NaN(); const T a = scalar_t(parameters[0])(); @@ -37202,17 +38737,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[1]); - vector_t z(parameters[3]); + const vector_t x(parameters[1]); + vector_t z(parameters[3]); std::size_t r0 = 0; std::size_t r1 = x.size() - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,4,5,1)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 4, 5, 1)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(z,r0,r1)) + else if (helper::invalid_range(z, r0, r1)) return std::numeric_limits::quiet_NaN(); const T a = scalar_t(parameters[0])(); @@ -37220,7 +38755,7 @@ namespace exprtk for (std::size_t i = r0; i <= r1; ++i) { - z[i] = a * x[i] + b; + z[i] = (a * x[i]) + b; } return T(1); @@ -37249,17 +38784,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[0]); - vector_t y(parameters[1]); + const vector_t x(parameters[0]); + const vector_t y(parameters[1]); std::size_t r0 = 0; std::size_t r1 = std::min(x.size(),y.size()) - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(y,r0,r1)) + else if (helper::invalid_range(y, r0, r1)) return std::numeric_limits::quiet_NaN(); T result = T(0); @@ -37295,17 +38830,17 @@ namespace exprtk */ {} - inline T operator()(const std::size_t& ps_index, parameter_list_t parameters) + inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - vector_t x(parameters[0]); - vector_t y(parameters[1]); + const vector_t x(parameters[0]); + const vector_t y(parameters[1]); std::size_t r0 = 0; std::size_t r1 = std::min(x.size(),y.size()) - 1; - if ((1 == ps_index) && !helper::load_vector_range::process(parameters,r0,r1,2,3,0)) + if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0)) return std::numeric_limits::quiet_NaN(); - else if (helper::invalid_range(y,r0,r1)) + else if (helper::invalid_range(y, r0, r1)) return std::numeric_limits::quiet_NaN(); T result = T(0); @@ -37313,7 +38848,7 @@ namespace exprtk for (std::size_t i = r0; i <= r1; ++i) { - details::kahan_sum(result,error,(x[i] * y[i])); + details::kahan_sum(result, error, (x[i] * y[i])); } return result; @@ -37361,7 +38896,7 @@ namespace exprtk exprtk_register_function("any_true" ,nt) exprtk_register_function("any_false" ,nf) exprtk_register_function("count" , c) - exprtk_register_function("copy" , cp) + exprtk_register_function("copy" ,cp) exprtk_register_function("rotate_left" ,rl) exprtk_register_function("rol" ,rl) exprtk_register_function("rotate_right" ,rr) @@ -37395,9 +38930,9 @@ namespace exprtk namespace information { static const char* library = "Mathematical Expression Toolkit"; - static const char* version = "2.71828182845904523536028747135266249775724709" - "3699959574966967627724076630353547594571382178"; - static const char* date = "20170404"; + static const char* version = "2.7182818284590452353602874713526624977572470936999595749" + "669676277240766303535475945713821785251664274274663919320"; + static const char* date = "20200101"; static inline std::string data() { @@ -37409,6 +38944,22 @@ namespace exprtk } // namespace information + #ifdef exprtk_debug + #undef exprtk_debug + #endif + + #ifdef exprtk_error_location + #undef exprtk_error_location + #endif + + #ifdef exprtk_disable_fallthrough_begin + #undef exprtk_disable_fallthrough_begin + #endif + + #ifdef exprtk_disable_fallthrough_end + #undef exprtk_disable_fallthrough_end + #endif + } // namespace exprtk #endif diff --git a/src/storm/utility/exprtk.h b/src/storm/adapters/ExprttkAdapter.h similarity index 69% rename from src/storm/utility/exprtk.h rename to src/storm/adapters/ExprttkAdapter.h index 3aba1b8db..ddf013b48 100644 --- a/src/storm/utility/exprtk.h +++ b/src/storm/adapters/ExprttkAdapter.h @@ -5,6 +5,9 @@ #pragma GCC diagnostic push +// exprtk should be case sensitive in our case. +#define exprtk_disable_caseinsensitivity + #include "exprtk.hpp" #pragma GCC diagnostic pop diff --git a/src/storm/storage/expressions/ExprtkCompiledExpression.h b/src/storm/storage/expressions/ExprtkCompiledExpression.h index b2c98fc2b..1e88424b3 100644 --- a/src/storm/storage/expressions/ExprtkCompiledExpression.h +++ b/src/storm/storage/expressions/ExprtkCompiledExpression.h @@ -2,7 +2,7 @@ #include "storm/storage/expressions/CompiledExpression.h" -#include "storm/utility/exprtk.h" +#include "storm/adapters/ExprttkAdapter.h" namespace storm { namespace expressions { diff --git a/src/storm/storage/expressions/ExprtkExpressionEvaluator.h b/src/storm/storage/expressions/ExprtkExpressionEvaluator.h index e6a7c6fb4..874a35af8 100755 --- a/src/storm/storage/expressions/ExprtkExpressionEvaluator.h +++ b/src/storm/storage/expressions/ExprtkExpressionEvaluator.h @@ -6,7 +6,7 @@ #include "storm/storage/expressions/ExpressionEvaluatorBase.h" -#include "storm/utility/exprtk.h" +#include "storm/adapters/ExprttkAdapter.h" #include "storm/storage/expressions/ToExprtkStringVisitor.h"