From 9cddffaf52111aaf859831f63ed264bd1d9da583 Mon Sep 17 00:00:00 2001 From: Arash Partow Date: Wed, 1 Mar 2017 16:12:58 +1100 Subject: [PATCH] C++ Mathematical Expression Library (ExprTk) https://www.partow.net/programming/exprtk/index.html --- exprtk.hpp | 3085 ++++++++++++++++++++-------------- exprtk_benchmark.cpp | 2 +- exprtk_simple_example_01.cpp | 2 +- exprtk_simple_example_02.cpp | 2 +- exprtk_simple_example_03.cpp | 2 +- exprtk_simple_example_04.cpp | 2 +- exprtk_simple_example_05.cpp | 2 +- exprtk_simple_example_06.cpp | 2 +- exprtk_simple_example_07.cpp | 2 +- exprtk_simple_example_08.cpp | 2 +- exprtk_simple_example_09.cpp | 2 +- exprtk_simple_example_10.cpp | 2 +- exprtk_simple_example_11.cpp | 2 +- exprtk_simple_example_12.cpp | 2 +- exprtk_simple_example_13.cpp | 2 +- exprtk_simple_example_14.cpp | 2 +- exprtk_simple_example_15.cpp | 2 +- exprtk_simple_example_16.cpp | 2 +- exprtk_simple_example_17.cpp | 2 +- exprtk_simple_example_18.cpp | 2 +- exprtk_simple_example_19.cpp | 2 +- exprtk_test.cpp | 223 ++- readme.txt | 130 +- 23 files changed, 2150 insertions(+), 1328 deletions(-) diff --git a/exprtk.hpp b/exprtk.hpp index c29cd08..2da41d8 100644 --- a/exprtk.hpp +++ b/exprtk.hpp @@ -2,7 +2,7 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -141,6 +141,13 @@ namespace exprtk ('\'' != c); } + #ifndef exprtk_disable_caseinsensitivity + inline void case_normalise(std::string& s) + { + std::transform + (s.begin(), s.end(), s.begin(), static_cast(std::tolower)); + } + inline bool imatch(const char_t c1, const char_t c2) { return std::tolower(c1) == std::tolower(c2); @@ -164,6 +171,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 @@ -174,12 +225,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]; } @@ -245,7 +296,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 @@ -313,7 +365,7 @@ namespace exprtk return (*this); } - inline build_string& operator << (const char* s) + inline build_string& operator << (const char_t* s) { data_ += std::string(s); return (*this); @@ -334,27 +386,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) - { - 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(); - } - }; - static const std::string reserved_words[] = { "break", "case", "continue", "default", "false", "for", @@ -409,7 +440,7 @@ namespace exprtk static const std::string cntrl_struct_list[] = { - "if", "switch", "for", "while", "repeat" + "if", "switch", "for", "while", "repeat", "return" }; static const std::size_t cntrl_struct_list_size = sizeof(cntrl_struct_list) / sizeof(std::string); @@ -581,29 +612,29 @@ namespace exprtk 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()) { @@ -628,7 +659,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; @@ -651,7 +682,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; @@ -1302,161 +1333,161 @@ namespace exprtk inline int to_int32(const T v) { typename details::number_type::type num_type; - return to_int32_impl(v,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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + return is_integer_impl(v, num_type); } template @@ -1614,7 +1645,7 @@ namespace exprtk if (itr == end) return false; - bool negative = ('-' == (*itr)); + const bool negative = ('-' == (*itr)); if (negative || ('+' == (*itr))) { @@ -1622,11 +1653,13 @@ 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) { @@ -1634,19 +1667,32 @@ namespace exprtk { #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 } @@ -1704,12 +1750,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; + const char_t* inf_itr = ('i' == (*itr)) ? inf_lc : inf_uc; while (end != itr) { @@ -1740,7 +1786,7 @@ namespace exprtk T d = T(0); - bool negative = ('-' == (*itr)); + const bool negative = ('-' == (*itr)); if (negative || '+' == (*itr)) { @@ -1750,23 +1796,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 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) @@ -1891,10 +1941,10 @@ 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(); + const char_t* begin = s.data(); + const char_t* end = s.data() + s.size(); typename numeric::details::number_type::type num_type; - return string_to_real(begin,end,t,num_type); + return string_to_real(begin, end, t, num_type); } template @@ -1958,7 +2008,7 @@ namespace exprtk type = tt; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); + position = static_cast(std::distance(base_begin,begin)); return *this; } @@ -1968,7 +2018,7 @@ namespace exprtk type = e_symbol; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); + position = static_cast(std::distance(base_begin,begin)); return *this; } @@ -1978,7 +2028,7 @@ namespace exprtk type = e_number; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); + position = static_cast(std::distance(base_begin,begin)); return *this; } @@ -1988,7 +2038,7 @@ namespace exprtk type = e_string; value.assign(begin,end); if (base_begin) - position = std::distance(base_begin,begin); + position = static_cast(std::distance(base_begin,begin)); return *this; } @@ -2019,7 +2069,7 @@ 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; } @@ -2219,8 +2269,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 char_t* begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_; + const char_t* end_itr = ((base_itr_ + end) < s_end_) ? (base_itr_ + end) : s_end_; return std::string(begin_itr,end_itr); } @@ -2237,7 +2287,7 @@ namespace exprtk private: - inline bool is_end(const char* itr) + inline bool is_end(const char_t* itr) { return (s_end_ == itr); } @@ -2344,7 +2394,7 @@ namespace exprtk else if ('~' == (*s_itr_)) { token_t t; - t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); + t.set_symbol(s_itr_, s_itr_ + 1, base_itr_); token_list_.push_back(t); ++s_itr_; return; @@ -2352,7 +2402,7 @@ namespace exprtk else { token_t t; - t.set_error(token::e_error,s_itr_,s_itr_ + 2,base_itr_); + t.set_error(token::e_error, s_itr_, s_itr_ + 2, base_itr_); token_list_.push_back(t); ++s_itr_; } @@ -2374,7 +2424,7 @@ namespace exprtk if ((c0 == '<') && (c1 == '=') && (c2 == '>')) { - t.set_operator(token_t::e_swap,s_itr_,s_itr_ + 3,base_itr_); + t.set_operator(token_t::e_swap, s_itr_, s_itr_ + 3, base_itr_); token_list_.push_back(t); s_itr_ += 3; return; @@ -2399,7 +2449,7 @@ namespace exprtk if (token_t::e_none != ttype) { - t.set_operator(ttype,s_itr_,s_itr_ + 2,base_itr_); + t.set_operator(ttype, s_itr_, s_itr_ + 2, base_itr_); token_list_.push_back(t); s_itr_ += 2; return; @@ -2407,17 +2457,17 @@ 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_); + t.set_symbol(s_itr_, s_itr_ + 1, base_itr_); else if ('|' == c0) - t.set_symbol(s_itr_,s_itr_ + 1,base_itr_); + t.set_symbol(s_itr_, s_itr_ + 1, base_itr_); else - t.set_operator(token_t::token_type(c0),s_itr_,s_itr_ + 1,base_itr_); + t.set_operator(token_t::token_type(c0), s_itr_, s_itr_ + 1, base_itr_); token_list_.push_back(t); ++s_itr_; @@ -2425,7 +2475,7 @@ namespace exprtk inline void scan_symbol() { - const char* initial_itr = s_itr_; + const char_t* initial_itr = s_itr_; while (!is_end(s_itr_)) { @@ -2476,11 +2526,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; + const char_t* 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_)) @@ -2489,7 +2539,7 @@ namespace exprtk { if (dot_found) { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_number, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; } @@ -2499,13 +2549,13 @@ 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)) { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_number, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2516,7 +2566,7 @@ namespace exprtk !details::is_digit(c) ) { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_number, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2531,7 +2581,7 @@ namespace exprtk { if (post_e_sign_found) { - t.set_error(token::e_err_number,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_number, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2555,7 +2605,7 @@ namespace exprtk ++s_itr_; } - t.set_numeric(initial_itr,s_itr_,base_itr_); + t.set_numeric(initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2563,13 +2613,13 @@ namespace exprtk inline void scan_special_function() { - const char* initial_itr = s_itr_; + const char_t* initial_itr = s_itr_; token_t t; // $fdd(x,x,x) = at least 11 chars if (std::distance(s_itr_,s_end_) < 11) { - t.set_error(token::e_err_sfunc,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_sfunc, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2582,7 +2632,7 @@ namespace exprtk (details::is_digit(*(s_itr_ + 3)))) ) { - t.set_error(token::e_err_sfunc,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_sfunc, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2590,7 +2640,7 @@ namespace exprtk s_itr_ += 4; // $fdd = 4chars - t.set_symbol(initial_itr,s_itr_,base_itr_); + t.set_symbol(initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2599,12 +2649,12 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities inline void scan_string() { - const char* initial_itr = s_itr_ + 1; + const char_t* initial_itr = s_itr_ + 1; token_t t; if (std::distance(s_itr_,s_end_) < 2) { - t.set_error(token::e_err_string,s_itr_,s_end_,base_itr_); + t.set_error(token::e_err_string, s_itr_, s_end_, base_itr_); token_list_.push_back(t); return; } @@ -2654,7 +2704,7 @@ namespace exprtk if (!within_range || !x_seperator || !both_digits) { - t.set_error(token::e_err_string,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; @@ -2671,19 +2721,23 @@ namespace exprtk if (is_end(s_itr_)) { - t.set_error(token::e_err_string,initial_itr,s_itr_,base_itr_); + t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_); token_list_.push_back(t); return; } if (!escaped_found) - t.set_string(initial_itr,s_itr_,base_itr_); + t.set_string(initial_itr, s_itr_, base_itr_); 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); @@ -2699,9 +2753,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_; + const char_t* base_itr_; + const char_t* s_itr_; + const char_t* s_end_; friend class token_scanner; friend class token_modifier; @@ -2824,7 +2878,7 @@ namespace exprtk private: - std::size_t stride_; + const std::size_t stride_; }; class token_modifier : public helper_interface @@ -2878,22 +2932,26 @@ namespace exprtk case 1 : insert_index = insert(g.token_list_[i],t); break; - case 2 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],t); + case 2 : insert_index = insert(g.token_list_[i], g.token_list_[i + 1], t); break; - case 3 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],t); + case 3 : insert_index = insert(g.token_list_[i], g.token_list_[i + 1], g.token_list_[i + 2], t); break; - case 4 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],g.token_list_[i + 3],t); + case 4 : insert_index = insert(g.token_list_[i], g.token_list_[i + 1], g.token_list_[i + 2], g.token_list_[i + 3], t); break; - case 5 : insert_index = insert(g.token_list_[i],g.token_list_[i + 1],g.token_list_[i + 2],g.token_list_[i + 3],g.token_list_[i + 4],t); + case 5 : insert_index = insert(g.token_list_[i], g.token_list_[i + 1], g.token_list_[i + 2], g.token_list_[i + 3], g.token_list_[i + 4], t); 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++; } } @@ -2925,7 +2983,7 @@ namespace exprtk private: - std::size_t stride_; + const std::size_t stride_; }; class token_joiner : public helper_interface @@ -2956,6 +3014,8 @@ namespace exprtk 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; @@ -2965,11 +3025,11 @@ namespace exprtk { 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; } @@ -2980,6 +3040,8 @@ 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; @@ -2989,12 +3051,12 @@ namespace exprtk { 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; } } @@ -3002,7 +3064,7 @@ namespace exprtk return changes; } - std::size_t stride_; + const std::size_t stride_; }; namespace helper @@ -4007,7 +4069,7 @@ namespace exprtk private: - std::size_t size_; + const std::size_t size_; data_ptr_t data_; std::vector data_ref_; }; @@ -4207,11 +4269,13 @@ namespace exprtk return std::string(view.begin(),view.size()); } + #ifndef exprtk_disable_return_statement namespace details { template class return_node; template class return_envelope_node; } + #endif template class results_context @@ -4261,8 +4325,10 @@ namespace exprtk bool results_available_; ts_list_t parameter_list_; + #ifndef exprtk_disable_return_statement friend class details::return_node; friend class details::return_envelope_node; + #endif }; namespace details @@ -4291,7 +4357,8 @@ namespace exprtk e_erf , e_erfc , e_ncdf , e_frac , e_trunc , e_assign , e_addass , e_subass , e_mulass , e_divass , e_modass , e_in , - e_like , e_ilike , e_multi , e_swap , + e_like , e_ilike , e_multi , e_smulti , + e_swap , // Do not add new functions/operators after this point. e_sf00 = 1000, e_sf01 = 1001, e_sf02 = 1002, e_sf03 = 1003, @@ -4391,10 +4458,10 @@ namespace exprtk const unsigned int loop_batch_size = global_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; }; @@ -4459,14 +4526,14 @@ namespace exprtk } } - static inline control_block* create(const std::size_t& size, data_t data_ptr = data_t(0), bool dstrct = false) + static inline control_block* create(const std::size_t& dsize, data_t data_ptr = data_t(0), bool dstrct = false) { - if (size) + if (dsize) { if (0 == data_ptr) - return new control_block(size); + return new control_block(dsize); else - return new control_block(size, data_ptr, dstrct); + return new control_block(dsize, data_ptr, dstrct); } else return new control_block; @@ -4704,8 +4771,8 @@ namespace exprtk 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_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); @@ -4780,36 +4847,37 @@ namespace exprtk 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_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 + 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 }; typedef T value_type; @@ -5373,7 +5441,7 @@ namespace exprtk private: expression_ptr branch_; - bool branch_deletable_; + const bool branch_deletable_; bool equality_; }; @@ -5443,7 +5511,7 @@ namespace exprtk virtual std::string str () const = 0; - virtual const char* base() const = 0; + virtual const char_t* base() const = 0; virtual std::size_t size() const = 0; }; @@ -5486,7 +5554,7 @@ namespace exprtk return value_; } - const char* base() const + const char_t* base() const { return value_.data(); } @@ -5663,7 +5731,7 @@ namespace exprtk expression_ptr branch1) : operation_(opr) { - init_branches<2>(branch_,branch0,branch1); + init_branches<2>(branch_, branch0, branch1); } ~binary_node() @@ -5715,7 +5783,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() @@ -5770,7 +5838,7 @@ namespace exprtk expression_ptr branch2) : operation_(opr) { - init_branches<3>(branch_,branch0,branch1,branch2); + init_branches<3>(branch_, branch0, branch1, branch2); } ~trinary_node() @@ -5828,7 +5896,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() @@ -5895,9 +5963,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 @@ -5939,8 +6007,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 @@ -5995,7 +6063,7 @@ namespace exprtk private: expression_ptr return_; - bool return_deletable_; + const bool return_deletable_; }; template @@ -6066,8 +6134,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 @@ -6119,8 +6187,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 @@ -6200,14 +6268,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 @@ -6268,8 +6336,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 @@ -6330,8 +6398,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 @@ -6434,10 +6502,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 @@ -6641,23 +6709,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) + : value_(&v) {} - ~variable_node() - { - if (delete_value_) - { - delete value_; - } - } - inline bool operator <(const variable_node& v) const { return this < (&v); @@ -6683,15 +6741,9 @@ namespace exprtk return expression_node::e_variable; } - inline bool& delete_value() - { - return delete_value_; - } - private: T* value_; - bool delete_value_; }; template @@ -6998,7 +7050,7 @@ namespace exprtk expression_ptr index_; vector_holder_ptr vec_holder_; T* vector_base_; - bool index_deletable_; + const bool index_deletable_; }; template @@ -7057,7 +7109,7 @@ namespace exprtk private: expression_ptr index_; - bool index_deletable_; + const bool index_deletable_; vector_holder_ptr vector_holder_; vds_t vds_; }; @@ -7108,7 +7160,7 @@ namespace exprtk private: - std::size_t index_; + const std::size_t index_; vector_holder_ptr vector_holder_; vds_t vds_; }; @@ -7398,7 +7450,7 @@ namespace exprtk return ref(); } - const char* base() const + const char_t* base() const { return &(*value_)[0]; } @@ -7478,7 +7530,7 @@ namespace exprtk return (*value_); } - const char* base() const + const char_t* base() const { return &(*value_)[0]; } @@ -7556,7 +7608,7 @@ namespace exprtk return value_; } - const char* base() const + const char_t* base() const { return value_.data(); } @@ -7687,7 +7739,7 @@ namespace exprtk return value_; } - const char* base() const + const char_t* base() const { return &value_[0]; } @@ -7714,14 +7766,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 @@ -7826,7 +7878,7 @@ namespace exprtk return value_; } - const char* base() const + const char_t* base() const { return &value_[0]; } @@ -7914,7 +7966,7 @@ namespace exprtk return str0_node_ptr_->str(); } - const char* base() const + const char_t* base() const { return str0_node_ptr_->base(); } @@ -8028,11 +8080,11 @@ namespace exprtk 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_t* s0 = const_cast(str0_base_ptr_->base() + str0_r0); + char_t* s1 = const_cast(str1_base_ptr_->base() + str1_r0); loop_unroll::details lud(max_size); - const char* upper_bound = s0 + lud.upper_bound; + const char_t* upper_bound = s0 + lud.upper_bound; while (s0 < upper_bound) { @@ -8182,20 +8234,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, const char_t* 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, const char_t* data, const std::size_t size) { s.append(data,size); } }; @@ -8281,7 +8333,7 @@ namespace exprtk return str0_node_ptr_->str(); } - const char* base() const + const char_t* base() const { return str0_node_ptr_->base(); } @@ -8402,7 +8454,7 @@ namespace exprtk 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)); } } @@ -8414,7 +8466,7 @@ namespace exprtk return str0_node_ptr_->str(); } - const char* base() const + const char_t* base() const { return str0_node_ptr_->base(); } @@ -8568,7 +8620,7 @@ namespace exprtk return value_; } - const char* base() const + const char_t* base() const { return &value_[0]; } @@ -8688,7 +8740,7 @@ namespace exprtk return value_; } - const char* base() const + const char_t* base() const { return &value_[0]; } @@ -8724,6 +8776,141 @@ namespace exprtk expression_ptr test_; expression_ptr consequent_; }; + + template + class str_vararg_node : public expression_node , + public string_base_node, + public range_interface + { + public: + + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + + template class Sequence> + str_vararg_node(const Sequence& arg_list) + : final_node_(arg_list.back()), + final_deletable_(branch_deletable(final_node_)), + initialised_(false), + str_base_ptr_ (0), + str_range_ptr_(0) + { + if (0 == final_node_) + return; + else if (!is_generally_string_node(final_node_)) + return; + + str_base_ptr_ = dynamic_cast(final_node_); + + if (0 == str_base_ptr_) + return; + + str_range_ptr_ = dynamic_cast(final_node_); + + if (0 == str_range_ptr_) + return; + + initialised_ = str_base_ptr_ && str_range_ptr_; + + if (arg_list.size() > 1) + { + const std::size_t arg_list_size = arg_list.size() - 1; + + arg_list_.resize(arg_list_size); + delete_branch_.resize(arg_list_size); + + for (std::size_t i = 0; i < arg_list_size; ++i) + { + if (arg_list[i]) + { + arg_list_[i] = arg_list[i]; + delete_branch_[i] = static_cast(branch_deletable(arg_list_[i]) ? 1 : 0); + } + else + { + arg_list_.clear(); + delete_branch_.clear(); + return; + } + } + } + } + + ~str_vararg_node() + { + if (final_node_ && final_deletable_) + { + delete final_node_; + final_node_ = 0; + } + + 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; + } + } + } + + inline T value() const + { + if (!arg_list_.empty()) + { + VarArgFunction::process(arg_list_); + } + + final_node_->value(); + + return std::numeric_limits::quiet_NaN(); + } + + std::string str() const + { + return str_base_ptr_->str(); + } + + const char_t* base() const + { + return str_base_ptr_->base(); + } + + std::size_t size() const + { + return str_base_ptr_->size(); + } + + range_t& range_ref() + { + return str_range_ptr_->range_ref(); + } + + const range_t& range_ref() const + { + return str_range_ptr_->range_ref(); + } + + inline typename expression_node::node_type type() const + { + return expression_node::e_stringvararg; + } + + private: + + expression_ptr final_node_; + bool final_deletable_; + bool initialised_; + str_base_ptr str_base_ptr_; + irange_ptr str_range_ptr_; + std::vector arg_list_; + std::vector delete_branch_; + }; #endif template @@ -9219,8 +9406,8 @@ namespace exprtk private: vector_interface* ivec_ptr_; - expression_ptr v_; - bool v_deletable_; + expression_ptr v_; + const bool v_deletable_; }; template @@ -11032,9 +11219,9 @@ namespace exprtk private: - ifunction* function_; + ifunction* function_; std::size_t parameter_count_; - branch_t branch_[N]; + branch_t branch_[N]; }; template @@ -11199,7 +11386,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; @@ -11220,7 +11407,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 @@ -11302,10 +11489,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; @@ -11321,9 +11508,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 @@ -11385,7 +11572,7 @@ namespace exprtk return ret_string_; } - const char* base() const + const char_t* base() const { return &ret_string_[0]; } @@ -11502,7 +11689,7 @@ namespace exprtk private: - std::size_t param_seq_index_; + const std::size_t param_seq_index_; }; #endif @@ -11526,6 +11713,7 @@ namespace exprtk } }; + #ifndef exprtk_disable_return_statement template class return_node : public generic_function_node > { @@ -11624,8 +11812,9 @@ namespace exprtk results_context_t* results_context_; mutable bool return_invoked_; expression_ptr body_; - bool body_deletable_; + const bool body_deletable_; }; + #endif #define exprtk_define_unary_op(OpName) \ template \ @@ -11828,7 +12017,7 @@ 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; } @@ -14352,7 +14541,7 @@ namespace exprtk cob_node(const cob_node&); cob_node& operator=(const cob_node&); - const T c_; + const T c_; branch_t branch_[1]; }; @@ -14413,7 +14602,7 @@ namespace exprtk boc_node(const boc_node&); boc_node& operator=(const boc_node&); - const T c_; + const T c_; branch_t branch_[1]; }; @@ -14493,8 +14682,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); } @@ -14556,8 +14745,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); } @@ -14622,14 +14811,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 @@ -14743,8 +14933,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( @@ -15072,6 +15262,12 @@ namespace exprtk return node && (expression_node::e_strccondition == node->type()); } + template + inline bool is_string_vararg_node(const expression_node* node) + { + return node && (expression_node::e_stringvararg == node->type()); + } + template inline bool is_genricstring_range_node(const expression_node* node) { @@ -15094,7 +15290,8 @@ namespace exprtk case expression_node::e_strconcat : case expression_node::e_strfunction : case expression_node::e_strcondition : - case expression_node::e_strccondition : return true; + case expression_node::e_strccondition : + case expression_node::e_stringvararg : return true; default : return false; } } @@ -15382,58 +15579,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 } @@ -15723,7 +15920,7 @@ namespace exprtk freefunc02(ff02_functor ff) : exprtk::ifunction(2), f(ff) {} inline T operator()(const T& v0, const T& v1) - { return f(v0,v1); } + { return f(v0, v1); } ff02_functor f; }; @@ -15733,7 +15930,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2); } ff03_functor f; }; @@ -15743,7 +15940,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3); } ff04_functor f; }; @@ -15753,7 +15950,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3, v4); } ff05_functor f; }; @@ -15763,7 +15960,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3, v4, v5); } ff06_functor f; }; @@ -15774,7 +15971,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3, v4, v5, v6); } ff07_functor f; }; @@ -15785,7 +15982,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3, v4, v5, v6, v7); } ff08_functor f; }; @@ -15796,7 +15993,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3, v4, v5, v6, v7, v8); } ff09_functor f; }; @@ -15807,7 +16004,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9); } ff10_functor f; }; @@ -15818,7 +16015,7 @@ namespace exprtk 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); } + { return f(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); } ff11_functor f; }; @@ -15830,7 +16027,7 @@ namespace exprtk 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); } + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11); } ff12_functor f; }; @@ -15842,7 +16039,7 @@ namespace exprtk 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); } + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12); } ff13_functor f; }; @@ -15854,7 +16051,7 @@ namespace exprtk 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); } + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13); } ff14_functor f; }; @@ -15866,7 +16063,7 @@ namespace exprtk 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); } + { return f(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14); } ff15_functor f; }; @@ -15952,7 +16149,7 @@ 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; } @@ -15974,7 +16171,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)); } }; @@ -15983,7 +16180,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)); } }; @@ -15991,7 +16188,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)); } }; @@ -16000,36 +16197,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) @@ -16038,13 +16240,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 @@ -17833,28 +18035,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::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::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 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::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; @@ -17991,7 +18193,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; @@ -18012,8 +18214,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; @@ -18029,11 +18231,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; @@ -18642,20 +18844,42 @@ namespace exprtk e_usr_constant_type = 1 }; + enum usr_mode + { + e_usrmode_default = 0, + e_usrmode_extended = 1 + }; + + usr_mode mode; + + unknown_symbol_resolver(const usr_mode m = e_usrmode_default) + : mode(m) + {} + virtual ~unknown_symbol_resolver() {} virtual bool process(const std::string& /*unknown_symbol*/, - usr_symbol_type& st, - T& default_value, - std::string& error_message) + usr_symbol_type& st, + T& default_value, + std::string& error_message) { + if (e_usrmode_default != mode) + return false; + st = e_usr_variable_type; default_value = T(0); error_message.clear(); return true; } + + virtual bool process(const std::string& /* unknown_symbol */, + symbol_table_t& /* symbol_table */, + std::string& /* error_message */) + { + return false; + } }; enum collect_type @@ -18706,14 +18930,13 @@ namespace exprtk for (std::size_t i = 0; i < symbol_name_list_.size(); ++i) { - std::string& s = symbol_name_list_[i].first; - std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); + 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(); @@ -18730,14 +18953,13 @@ namespace exprtk for (std::size_t i = 0; i < assignment_name_list_.size(); ++i) { - std::string& s = assignment_name_list_[i].first; - std::transform(s.begin(),s.end(),s.begin(),static_cast(std::tolower)); + 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(); @@ -18796,11 +19018,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; @@ -18813,10 +19037,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; } @@ -18889,7 +19113,8 @@ namespace exprtk e_ctrl_switch, e_ctrl_for_loop, e_ctrl_while_loop, - e_ctrl_repeat_loop + e_ctrl_repeat_loop, + e_ctrl_return }; enum settings_logic_opr @@ -18982,7 +19207,7 @@ 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())); + (disabled_func_set_, disabled_func_set_.begin())); return *this; } @@ -18991,7 +19216,7 @@ 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())); + (disabled_ctrl_set_, disabled_ctrl_set_.begin())); return *this; } @@ -19000,7 +19225,7 @@ 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())); + (disabled_logic_set_, disabled_logic_set_.begin())); return *this; } @@ -19009,7 +19234,7 @@ 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())); + (disabled_arithmetic_set_, disabled_arithmetic_set_.begin())); return *this; } @@ -19018,7 +19243,7 @@ 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())); + (disabled_assignment_set_, disabled_assignment_set_.begin())); return *this; } @@ -19027,7 +19252,7 @@ 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())); + (disabled_inequality_set_, disabled_inequality_set_.begin())); return *this; } @@ -19080,7 +19305,8 @@ namespace exprtk 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) @@ -19088,7 +19314,8 @@ namespace exprtk 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) @@ -19096,7 +19323,8 @@ namespace exprtk 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) @@ -19128,7 +19356,8 @@ namespace exprtk 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) @@ -19136,7 +19365,8 @@ namespace exprtk 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) @@ -19144,7 +19374,8 @@ namespace exprtk 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) @@ -19797,6 +20028,11 @@ namespace exprtk unknown_symbol_resolver_ = &default_usr_; } + inline void enable_unknown_symbol_resolver(unknown_symbol_resolver& usr) + { + enable_unknown_symbol_resolver(&usr); + } + inline void disable_unknown_symbol_resolver() { resolve_unknown_symbol_ = false; @@ -20045,65 +20281,65 @@ namespace exprtk 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; } } @@ -20484,7 +20720,8 @@ namespace exprtk expression_node_ptr branch[NumberofParameters]; expression_node_ptr result = error_node(); - std::fill_n(branch,NumberofParameters,reinterpret_cast(0)); + std::fill_n(branch, NumberofParameters, reinterpret_cast(0)); + scoped_delete sd(*this,branch); next_token(); @@ -20570,9 +20807,9 @@ 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]) { - std::fill_n(param_list,MaxNumberofParameters,reinterpret_cast(0)); + std::fill_n(param_list, MaxNumberofParameters, reinterpret_cast(0)); scoped_delete sd(*this,param_list); @@ -20588,9 +20825,9 @@ namespace exprtk return 0; } - int param_index = 0; + std::size_t param_index = 0; - for (; param_index < static_cast(MaxNumberofParameters); ++param_index) + for (; param_index < MaxNumberofParameters; ++param_index) { param_list[param_index] = parse_expression(); @@ -20621,6 +20858,7 @@ namespace exprtk typedef std::pair map_range_t; const std::string operation_name = current_token().value; + map_range_t itr_range = base_ops_map_.equal_range(operation_name); if (0 == std::distance(itr_range.first,itr_range.second)) @@ -20636,7 +20874,7 @@ 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); if (0 == parameter_count) { @@ -20652,13 +20890,13 @@ namespace exprtk { 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) @@ -21029,7 +21267,7 @@ namespace exprtk if (consq_is_str && alter_is_str) { return expression_generator_ - .conditional_string(condition,consequent,alternative); + .conditional_string(condition, consequent, alternative); } set_error( @@ -21044,15 +21282,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() @@ -21259,7 +21497,7 @@ 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) { @@ -21268,7 +21506,8 @@ namespace exprtk current_token(), "ERR059 - Failed to synthesize repeat until loop")); - free_node(node_allocator_, condition); + free_node(node_allocator_,condition); + brkcnt_list_.pop_front(); return error_node(); @@ -21470,10 +21709,10 @@ namespace exprtk 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()) { @@ -21570,11 +21809,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 { @@ -21714,11 +21950,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 { @@ -21766,13 +21999,13 @@ namespace exprtk { return parse_multi_switch_statement(); } - else if (details::imatch(symbol,"avg" )) opt_type = details::e_avg; + 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,"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,"sum" )) opt_type = details::e_sum ; else { set_error( @@ -21902,7 +22135,8 @@ namespace exprtk typename Allocator2, template class Sequence> inline expression_node_ptr simplify(Sequence& expression_list, - Sequence& side_effect_list) + Sequence& side_effect_list, + const bool specialise_on_final_type = false) { if (expression_list.empty()) return error_node(); @@ -21973,6 +22207,8 @@ namespace exprtk if (1 == expression_list.size()) return expression_list[0]; + else if (specialise_on_final_type && is_generally_string_node(expression_list.back())) + return expression_generator_.vararg_function(details::e_smulti,expression_list); else return expression_generator_.vararg_function(details::e_multi,expression_list); } @@ -22049,7 +22285,7 @@ namespace exprtk break; } - result = simplify(arg_list,side_effect_list); + result = simplify(arg_list,side_effect_list,source.empty()); sdd.delete_ptr = (0 == result); return result; @@ -22100,7 +22336,7 @@ namespace exprtk } else if (is_constant_node(r0)) { - T r0_value = r0->value(); + const T r0_value = r0->value(); if (r0_value >= T(0)) { @@ -22161,7 +22397,7 @@ namespace exprtk } else if (is_constant_node(r1)) { - T r1_value = r1->value(); + const T r1_value = r1->value(); if (r1_value >= T(0)) { @@ -22205,7 +22441,7 @@ 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)) { @@ -22305,7 +22541,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(); @@ -22325,8 +22562,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)) { @@ -22400,8 +22637,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) ) { @@ -22451,12 +22688,33 @@ namespace exprtk return error_node(); } + // Perform compile-time range check + if (details::is_constant_node(index_expr)) + { + 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) + { + 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))); + + free_node(node_allocator_,index_expr); + + return error_node(); + } + } + return expression_generator_.vector_element(symbol,vec,index_expr); } 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); @@ -22472,7 +22730,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR106 - Zero parameter call to vararg function: " + "ERR107 - Zero parameter call to vararg function: " + vararg_function_name + " not allowed")); return error_node(); @@ -22496,7 +22754,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR107 - Expected ',' for call to vararg function: " + "ERR108 - Expected ',' for call to vararg function: " + vararg_function_name)); return error_node(); @@ -22509,7 +22767,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR108 - Zero parameter call to vararg function: " + "ERR109 - Zero parameter call to vararg function: " + vararg_function_name + " not allowed")); return error_node(); @@ -22520,7 +22778,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR109 - Invalid number of parameters to call to vararg function: " + "ERR110 - 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")); @@ -22531,7 +22789,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR110 - Invalid number of parameters to call to vararg function: " + "ERR111 - 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")); @@ -22593,7 +22851,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR111 - Failed parameter type check for function '" + function_name_ + "', " + "ERR112 - Failed parameter type check for function '" + function_name_ + "', " "Expected '" + param_seq_list_[0] + "' call set: '" + param_seq +"'")); } else @@ -22613,7 +22871,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR112 - Failed parameter type check for function '" + function_name_ + "', " + "ERR113 - Failed parameter type check for function '" + function_name_ + "', " "Best match: '" + param_seq_list_[max_diff_index] + "' call set: '" + param_seq +"'")); } @@ -22667,7 +22925,7 @@ namespace exprtk (std::string::npos == str.find("**")) ) { - const std::string curr_str = str.substr(s,e - s); + const std::string curr_str = str.substr(s, e - s); if ("Z" == curr_str) { @@ -22687,17 +22945,17 @@ namespace exprtk while (std::string::npos != (end = s.find('|',start))) { - if (!token_validator::process(s,start,end,param_seq_list)) + if (!token_validator::process(s, start, end, param_seq_list)) { invalid_state_ = false; - const std::string err_param_seq = s.substr(start,end - start); + const std::string err_param_seq = s.substr(start, end - start); parser_. set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR113 - Invalid parameter sequence of '" + err_param_seq + + "ERR114 - Invalid parameter sequence of '" + err_param_seq + "' for function: " + function_name_)); return; @@ -22708,17 +22966,17 @@ namespace exprtk if (start < s.size()) { - if (token_validator::process(s,start,s.size(),param_seq_list)) + if (token_validator::process(s, start, s.size(), param_seq_list)) param_seq_list_ = param_seq_list; else { - const std::string err_param_seq = s.substr(start,s.size() - start); + const std::string err_param_seq = s.substr(start, s.size() - start); parser_. set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR114 - Invalid parameter sequence of '" + err_param_seq + + "ERR115 - Invalid parameter sequence of '" + err_param_seq + "' for function: " + function_name_)); return; } @@ -22751,7 +23009,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR115 - Type checker instantiation failure for generic function: " + function_name)); + "ERR116 - Type checker instantiation failure for generic function: " + function_name)); return error_node(); } @@ -22765,7 +23023,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR116 - Mismatch in zero parameter condition for generic function: " + "ERR117 - Mismatch in zero parameter condition for generic function: " + function_name)); return error_node(); @@ -22783,7 +23041,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR117 - Zero parameter call to generic function: " + "ERR118 - Zero parameter call to generic function: " + function_name + " not allowed")); return error_node(); @@ -22814,7 +23072,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR118 - Expected ',' for call to generic function: " + function_name)); + "ERR119 - Expected ',' for call to generic function: " + function_name)); return error_node(); } @@ -22830,7 +23088,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR119 - Zero parameter call to generic function: " + "ERR120 - Zero parameter call to generic function: " + function_name + " not allowed")); return error_node(); @@ -22846,7 +23104,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR120 - Expected ',' for call to generic function: " + function_name)); + "ERR121 - Expected ',' for call to generic function: " + function_name)); return error_node(); } @@ -22855,10 +23113,10 @@ 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); @@ -22913,7 +23171,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR121 - Expected ',' for call to string function: " + function_name)); + "ERR122 - Expected ',' for call to string function: " + function_name)); return error_node(); } @@ -22928,7 +23186,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR122 - Expected ',' for call to string function: " + function_name)); + "ERR123 - Expected ',' for call to string function: " + function_name)); return error_node(); } @@ -22937,10 +23195,10 @@ 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); @@ -22955,7 +23213,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(p,branch); p.next_token(); @@ -22965,7 +23225,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR123 - Expected '(' for special function")); + "ERR124 - Expected '(' for special function")); return error_node(); } @@ -22985,7 +23245,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR124 - Expected ',' before next parameter of special function")); + "ERR125 - Expected ',' before next parameter of special function")); return p.error_node(); } @@ -23014,26 +23274,27 @@ namespace exprtk set_error( make_error(parser_error::e_token, current_token(), - "ERR125 - Invalid special function[1]: " + current_token().value)); + "ERR126 - Invalid special function[1]: " + current_token().value)); return error_node(); } - const unsigned int id = (current_token().value[2] - '0') * 10 + (current_token().value[3] - '0'); + const int id = (current_token().value[2] - '0') * 10 + + (current_token().value[3] - '0'); if (id >= details::e_sffinal) { set_error( make_error(parser_error::e_token, current_token(), - "ERR126 - Invalid special function[2]: " + current_token().value)); + "ERR127 - Invalid special function[2]: " + current_token().value)); 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) { @@ -23057,7 +23318,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR127 - Break call within a break call is not allowed")); + "ERR128 - Break call within a break call is not allowed")); return error_node(); } @@ -23079,7 +23340,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR128 - Failed to parse return expression for 'break' statement")); + "ERR129 - Failed to parse return expression for 'break' statement")); return error_node(); } @@ -23088,7 +23349,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR129 - Expected ']' at the completion of break's return expression")); + "ERR130 - Expected ']' at the completion of break's return expression")); free_node(node_allocator_,return_expr); @@ -23105,7 +23366,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR130 - Invalid use of 'break', allowed only in the scope of a loop")); + "ERR131 - Invalid use of 'break', allowed only in the scope of a loop")); } return error_node(); @@ -23127,7 +23388,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR131 - Invalid use of 'continue', allowed only in the scope of a loop")); + "ERR132 - Invalid use of 'continue', allowed only in the scope of a loop")); return error_node(); } @@ -23143,7 +23404,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR132 - Expected '[' as part of vector size definition")); + "ERR133 - Expected '[' as part of vector size definition")); return error_node(); } @@ -23152,7 +23413,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR133 - Failed to determine size of vector '" + vec_name + "'")); + "ERR134 - Failed to determine size of vector '" + vec_name + "'")); return error_node(); } @@ -23163,7 +23424,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR134 - Expected a literal number as size of vector '" + vec_name + "'")); + "ERR135 - Expected a literal number as size of vector '" + vec_name + "'")); return error_node(); } @@ -23181,7 +23442,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR135 - Invalid vector size. Must be an integer greater than zero, size: " + + "ERR136 - Invalid vector size. Must be an integer greater than zero, size: " + details::to_str(details::numeric::to_int32(vector_size)))); return error_node(); @@ -23200,7 +23461,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR136 - Expected ']' as part of vector size definition")); + "ERR137 - Expected ']' as part of vector size definition")); return error_node(); } @@ -23211,7 +23472,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR137 - Expected ':=' as part of vector definition")); + "ERR138 - Expected ':=' as part of vector definition")); return error_node(); } @@ -23224,7 +23485,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR138 - Failed to parse single vector initialiser")); + "ERR139 - Failed to parse single vector initialiser")); return error_node(); } @@ -23236,7 +23497,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR139 - Expected ']' to close single value vector initialiser")); + "ERR140 - Expected ']' to close single value vector initialiser")); return error_node(); } @@ -23282,7 +23543,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR140 - Expected '{' as part of vector initialiser list")); + "ERR141 - Expected '{' as part of vector initialiser list")); return error_node(); } @@ -23301,7 +23562,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR141 - Expected '{' as part of vector initialiser list")); + "ERR142 - Expected '{' as part of vector initialiser list")); return error_node(); } @@ -23318,7 +23579,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR142 - Expected ',' between vector initialisers")); + "ERR143 - Expected ',' between vector initialisers")); return error_node(); } @@ -23339,7 +23600,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR143 - Expected ';' at end of vector definition")); + "ERR144 - Expected ';' at end of vector definition")); return error_node(); } @@ -23350,7 +23611,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR144 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'")); + "ERR145 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'")); return error_node(); } @@ -23358,7 +23619,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); @@ -23369,7 +23630,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR145 - Illegal redefinition of local vector: '" + vec_name + "'")); + "ERR146 - Illegal redefinition of local vector: '" + vec_name + "'")); return error_node(); } @@ -23402,7 +23663,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR146 - Failed to add new local vector '" + vec_name + "' to SEM")); + "ERR147 - Failed to add new local vector '" + vec_name + "' to SEM")); sem_.free_element(nse); @@ -23456,7 +23717,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR147 - Illegal redefinition of local variable: '" + str_name + "'")); + "ERR148 - Illegal redefinition of local variable: '" + str_name + "'")); free_node(node_allocator_,initialisation_expression); @@ -23487,7 +23748,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR148 - Failed to add new local string variable '" + str_name + "' to SEM")); + "ERR149 - Failed to add new local string variable '" + str_name + "' to SEM")); free_node(node_allocator_,initialisation_expression); @@ -23532,7 +23793,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR149 - Illegal variable definition")); + "ERR150 - Illegal variable definition")); return error_node(); } @@ -23552,7 +23813,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR150 - Expected a symbol for variable definition")); + "ERR151 - Expected a symbol for variable definition")); return error_node(); } @@ -23561,7 +23822,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR151 - Illegal redefinition of reserved keyword: '" + var_name + "'")); + "ERR152 - Illegal redefinition of reserved keyword: '" + var_name + "'")); return error_node(); } @@ -23570,7 +23831,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR152 - Illegal redefinition of variable '" + var_name + "'")); + "ERR153 - Illegal redefinition of variable '" + var_name + "'")); return error_node(); } @@ -23579,7 +23840,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR153 - Illegal redefinition of local variable: '" + var_name + "'")); + "ERR154 - Illegal redefinition of local variable: '" + var_name + "'")); return error_node(); } @@ -23598,7 +23859,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR154 - Failed to parse initialisation expression")); + "ERR155 - Failed to parse initialisation expression")); return error_node(); } @@ -23615,7 +23876,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR155 - Expected ';' after variable definition")); + "ERR156 - Expected ';' after variable definition")); free_node(node_allocator_,initialisation_expression); @@ -23642,9 +23903,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR156 - Illegal redefinition of local variable: '" + var_name + "'")); + "ERR157 - Illegal redefinition of local variable: '" + var_name + "'")); - free_node(node_allocator_,initialisation_expression); + free_node(node_allocator_, initialisation_expression); return error_node(); } @@ -23673,9 +23934,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR157 - Failed to add new local variable '" + var_name + "' to SEM")); + "ERR158 - Failed to add new local variable '" + var_name + "' to SEM")); - free_node(node_allocator_,initialisation_expression); + free_node(node_allocator_, initialisation_expression); sem_.free_element(nse); @@ -23709,7 +23970,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR158 - Expected a '{}' for uninitialised var definition")); + "ERR159 - Expected a '{}' for uninitialised var definition")); return error_node(); } @@ -23718,7 +23979,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR159 - Expected ';' after uninitialised variable definition")); + "ERR160 - Expected ';' after uninitialised variable definition")); return error_node(); } @@ -23734,7 +23995,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR160 - Illegal redefinition of local variable: '" + var_name + "'")); + "ERR161 - Illegal redefinition of local variable: '" + var_name + "'")); return error_node(); } @@ -23763,7 +24024,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR161 - Failed to add new local variable '" + var_name + "' to SEM")); + "ERR162 - Failed to add new local variable '" + var_name + "' to SEM")); sem_.free_element(nse); @@ -23795,7 +24056,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR162 - Expected '(' at start of swap statement")); + "ERR163 - Expected '(' at start of swap statement")); return error_node(); } @@ -23813,7 +24074,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR163 - Expected a symbol for variable or vector element definition")); + "ERR164 - Expected a symbol for variable or vector element definition")); return error_node(); } @@ -23824,7 +24085,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR164 - First parameter to swap is an invalid vector element: '" + var0_name + "'")); + "ERR165 - First parameter to swap is an invalid vector element: '" + var0_name + "'")); return error_node(); } @@ -23856,7 +24117,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR165 - First parameter to swap is an invalid variable: '" + var0_name + "'")); + "ERR166 - First parameter to swap is an invalid variable: '" + var0_name + "'")); return error_node(); } @@ -23869,7 +24130,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR166 - Expected ',' between parameters to swap")); + "ERR167 - Expected ',' between parameters to swap")); if (variable0_generated) { @@ -23886,7 +24147,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR167 - Expected a symbol for variable or vector element definition")); + "ERR168 - Expected a symbol for variable or vector element definition")); if (variable0_generated) { @@ -23902,7 +24163,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR168 - Second parameter to swap is an invalid vector element: '" + var1_name + "'")); + "ERR169 - Second parameter to swap is an invalid vector element: '" + var1_name + "'")); if (variable0_generated) { @@ -23939,7 +24200,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR169 - Second parameter to swap is an invalid variable: '" + var1_name + "'")); + "ERR170 - Second parameter to swap is an invalid variable: '" + var1_name + "'")); if (variable0_generated) { @@ -23957,7 +24218,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR170 - Expected ')' at end of swap statement")); + "ERR171 - Expected ')' at end of swap statement")); if (variable0_generated) { @@ -23973,6 +24234,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); @@ -23983,7 +24245,7 @@ namespace exprtk (0 != (v1 = dynamic_cast(variable1))) ) { - result = node_allocator_.allocate >(v0,v1); + result = node_allocator_.allocate >(v0, v1); if (variable0_generated) { @@ -23996,13 +24258,15 @@ namespace exprtk } } else - result = node_allocator_.allocate >(variable0,variable1); + result = node_allocator_.allocate > + (variable0, variable1); state_.activate_side_effect("parse_swap_statement()"); return result; } + #ifndef exprtk_disable_return_statement inline expression_node_ptr parse_return_statement() { if (state_.parsing_return_stmt) @@ -24010,7 +24274,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR171 - Return call within a return call is not allowed")); + "ERR172 - Return call within a return call is not allowed")); return error_node(); } @@ -24033,7 +24297,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR172 - Expected '[' at start of return statement")); + "ERR173 - Expected '[' at start of return statement")); return error_node(); } @@ -24055,7 +24319,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR173 - Expected ',' between values during call to return")); + "ERR174 - Expected ',' between values during call to return")); return error_node(); } @@ -24066,7 +24330,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR174 - Zero parameter return statement not allowed")); + "ERR175 - Zero parameter return statement not allowed")); return error_node(); } @@ -24080,7 +24344,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR175 - Invalid ']' found during return call")); + "ERR176 - Invalid ']' found during return call")); return error_node(); } @@ -24112,6 +24376,12 @@ namespace exprtk return result; } + #else + inline expression_node_ptr parse_return_statement() + { + return error_node(); + } + #endif inline bool post_variable_process(const std::string& symbol) { @@ -24126,7 +24396,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR176 - Invalid sequence of variable '"+ symbol + "' and bracket")); + "ERR177 - Invalid sequence of variable '"+ symbol + "' and bracket")); return false; } @@ -24173,7 +24443,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR177 - Invalid sequence of brackets")); + "ERR178 - Invalid sequence of brackets")); return false; } @@ -24216,7 +24486,7 @@ 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) { @@ -24269,7 +24539,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR178 - Failed to generate node for function: '" + symbol + "'")); + "ERR179 - Failed to generate node for function: '" + symbol + "'")); return error_node(); } @@ -24285,7 +24555,7 @@ namespace exprtk 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; @@ -24294,7 +24564,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR179 - Failed to generate node for vararg function: '" + symbol + "'")); + "ERR180 - Failed to generate node for vararg function: '" + symbol + "'")); return error_node(); } @@ -24310,7 +24580,7 @@ namespace exprtk 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; @@ -24319,7 +24589,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR180 - Failed to generate node for generic function: '" + symbol + "'")); + "ERR181 - Failed to generate node for generic function: '" + symbol + "'")); return error_node(); } @@ -24336,7 +24606,7 @@ namespace exprtk 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; @@ -24345,7 +24615,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR181 - Failed to generate node for string function: '" + symbol + "'")); + "ERR182 - Failed to generate node for string function: '" + symbol + "'")); return error_node(); } @@ -24362,12 +24632,15 @@ namespace exprtk 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(), - "ERR182 - Invalid use of reserved symbol '" + symbol + "'")); + "ERR183 - Invalid use of reserved symbol '" + symbol + "'")); return error_node(); } @@ -24378,63 +24651,88 @@ namespace exprtk { if (!(settings_.rsrvd_sym_usr_disabled() && details::is_reserved_symbol(symbol))) { - T default_value = T(0); + symbol_table_t& symtab = symtab_store_.get_symbol_table(); + std::string error_message; - typename unknown_symbol_resolver::usr_symbol_type usr_symbol_type; - if (unknown_symbol_resolver_->process(symbol,usr_symbol_type,default_value,error_message)) + if (unknown_symbol_resolver::e_usrmode_default == unknown_symbol_resolver_->mode) { - bool create_result = false; + T default_value = T(0); - symbol_table_t& symtab = symtab_store_.get_symbol_table(); + typename unknown_symbol_resolver::usr_symbol_type usr_symbol_type; - switch (usr_symbol_type) + if (unknown_symbol_resolver_->process(symbol, usr_symbol_type, default_value, error_message)) { - case unknown_symbol_resolver::e_usr_variable_type : create_result = symtab.create_variable(symbol,default_value); - break; + bool create_result = false; - case unknown_symbol_resolver::e_usr_constant_type : create_result = symtab.add_constant(symbol,default_value); - break; - - default : create_result = false; - } - - if (create_result) - { - expression_node_ptr var = symtab_store_.get_variable(symbol); - - if (var) + switch (usr_symbol_type) { - if (symtab_store_.is_constant_node(symbol)) + case unknown_symbol_resolver::e_usr_variable_type : create_result = symtab.create_variable(symbol, default_value); + break; + + case unknown_symbol_resolver::e_usr_constant_type : create_result = symtab.add_constant(symbol, default_value); + break; + + default : create_result = false; + } + + if (create_result) + { + expression_node_ptr var = symtab_store_.get_variable(symbol); + + if (var) { - var = expression_generator_(var->value()); + if (symtab_store_.is_constant_node(symbol)) + { + var = expression_generator_(var->value()); + } + + lodge_symbol(symbol,e_st_variable); + + if (!post_variable_process(symbol)) + return error_node(); + + next_token(); + + return var; } - - lodge_symbol(symbol,e_st_variable); - - if (!post_variable_process(symbol)) - return error_node(); - - next_token(); - - return var; } } set_error( make_error(parser_error::e_symtab, current_token(), - "ERR183 - Failed to create variable: '" + symbol + "'")); + "ERR184 - Failed to create variable: '" + symbol + "'" + + (error_message.empty() ? "" : " - " + error_message))); - return error_node(); } + else if (unknown_symbol_resolver::e_usrmode_extended == unknown_symbol_resolver_->mode) + { + if (unknown_symbol_resolver_->process(symbol, symtab, error_message)) + { + expression_node_ptr result = parse_symtab_symbol(); + + if (result) + { + return result; + } + } + + set_error( + make_error(parser_error::e_symtab, + current_token(), + "ERR185 - Failed to resolve symbol: '" + symbol + "'" + + (error_message.empty() ? "" : " - " + error_message))); + } + + return error_node(); } } set_error( make_error(parser_error::e_syntax, current_token(), - "ERR184 - Undefined symbol: '" + symbol + "'")); + "ERR186 - Undefined symbol: '" + symbol + "'")); return error_node(); } @@ -24462,35 +24760,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) ) { @@ -24500,32 +24798,37 @@ 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(); } - else if (details::imatch(current_token().value,symbol_return)) + #ifndef exprtk_disable_return_statement + else if ( + details::imatch(current_token().value, symbol_return) && + settings_.control_struct_enabled(current_token().value) + ) { return parse_return_statement(); } + #endif else if (symtab_store_.valid() || !sem_.empty()) { return parse_symtab_symbol(); @@ -24535,7 +24838,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR185 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value)); + "ERR187 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value)); return error_node(); } @@ -24549,7 +24852,7 @@ 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); next_token(); @@ -24560,7 +24863,7 @@ namespace exprtk set_error( make_error(parser_error::e_numeric, current_token(), - "ERR186 - Failed to convert '" + current_token().value + "' to a number")); + "ERR188 - Failed to convert '" + current_token().value + "' to a number")); return error_node(); } @@ -24586,7 +24889,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR187 - Expected ')' instead of: '" + current_token().value + "'")); + "ERR189 - Expected ')' instead of: '" + current_token().value + "'")); free_node(node_allocator_,branch); @@ -24610,7 +24913,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR188 - Expected ']' instead of: '" + current_token().value + "'")); + "ERR190 - Expected ']' instead of: '" + current_token().value + "'")); free_node(node_allocator_,branch); @@ -24634,7 +24937,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR189 - Expected '}' instead of: '" + current_token().value + "'")); + "ERR191 - Expected '}' instead of: '" + current_token().value + "'")); free_node(node_allocator_,branch); @@ -24673,7 +24976,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR190 - Premature end of expression[1]")); + "ERR192 - Premature end of expression[1]")); return error_node(); } @@ -24682,7 +24985,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR191 - Premature end of expression[2]")); + "ERR193 - Premature end of expression[2]")); return error_node(); } @@ -24985,11 +25288,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); } @@ -25117,7 +25420,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 @@ -25125,7 +25429,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 @@ -25133,7 +25438,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 @@ -25141,7 +25447,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 @@ -25149,7 +25456,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 @@ -25162,7 +25470,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; @@ -25178,7 +25486,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; @@ -25189,7 +25497,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 @@ -25197,7 +25506,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 @@ -25205,7 +25515,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 @@ -25213,7 +25524,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 is_invalid_assignment_op(const details::operator_type& operation, expression_node_ptr (&branch)[2]) @@ -25507,9 +25819,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(); } @@ -25519,16 +25831,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; @@ -25553,9 +25865,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(); } @@ -25565,16 +25877,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; @@ -25638,7 +25950,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); @@ -25682,32 +25997,39 @@ 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)) { - 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 @@ -25923,47 +26245,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]) @@ -25990,7 +26312,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 @@ -26023,8 +26345,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) @@ -26062,7 +26384,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) @@ -26096,7 +26418,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) @@ -26125,8 +26447,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) @@ -26165,7 +26487,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) @@ -26198,7 +26520,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) @@ -26232,14 +26554,14 @@ 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(); } @@ -26271,14 +26593,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(); } @@ -26296,11 +26618,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(); } @@ -26328,22 +26650,32 @@ namespace exprtk else if (all_nodes_variables(arg_list)) return varnode_optimise_varargfunc(operation,arg_list); - switch (operation) + #ifndef exprtk_disable_string_capabilities + if (details::e_smulti == operation) { - #define case_stmt(op0,op1) \ - case op0 : return node_allocator_-> \ - allocate > >(arg_list); \ + return node_allocator_-> + allocate > >(arg_list); + } + else + #endif + { + switch (operation) + { + #define case_stmt(op0,op1) \ + 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) - #undef case_stmt - default : return error_node(); + 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(); + } } } @@ -26438,7 +26770,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); @@ -26461,8 +26793,9 @@ namespace exprtk } 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(); } } @@ -26488,7 +26821,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); @@ -26522,6 +26855,7 @@ namespace exprtk } #endif + #ifndef exprtk_disable_return_statement inline expression_node_ptr return_call(std::vector& arg_list) { if (!all_nodes_valid(arg_list)) @@ -26565,6 +26899,19 @@ namespace exprtk return result; } + #else + inline expression_node_ptr return_call(std::vector&) + { + return error_node(); + } + + inline expression_node_ptr return_envelope(expression_node_ptr, + results_context_t*, + bool*&) + { + return error_node(); + } + #endif inline expression_node_ptr vector_element(const std::string& symbol, vector_holder_ptr vector_base, @@ -26776,7 +27123,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) @@ -26794,7 +27141,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) @@ -26812,7 +27159,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) @@ -26830,7 +27177,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) @@ -26852,7 +27199,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) @@ -26870,7 +27217,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) @@ -26909,20 +27256,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) { @@ -26931,7 +27278,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 @@ -26945,7 +27292,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 @@ -26959,7 +27306,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 @@ -26992,7 +27339,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) @@ -27007,7 +27354,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) @@ -27022,7 +27369,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 @@ -27075,9 +27422,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 @@ -27127,8 +27476,8 @@ 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; } @@ -27146,27 +27495,27 @@ 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 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 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> @@ -27201,7 +27550,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)); @@ -27228,13 +27577,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) @@ -27325,25 +27675,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(); } @@ -27370,24 +27720,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(); } @@ -27422,7 +27772,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; @@ -27470,7 +27823,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 @@ -27493,9 +27846,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; } @@ -27572,21 +27928,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])) @@ -27686,7 +28042,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 @@ -27706,21 +28062,21 @@ namespace exprtk 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]); 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])) @@ -27787,9 +28143,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; } @@ -27801,7 +28160,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 @@ -27823,40 +28182,41 @@ 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) { @@ -27891,7 +28251,7 @@ 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]); } @@ -27909,26 +28269,26 @@ namespace exprtk 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]; @@ -27945,7 +28305,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]); } @@ -27961,7 +28321,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]); } @@ -27977,7 +28337,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]); } @@ -27993,7 +28353,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]); } @@ -28021,6 +28381,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()) @@ -28051,7 +28412,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]); } @@ -28075,7 +28436,7 @@ namespace exprtk if (result) { - free_node(*expr_gen.node_allocator_,branch[1]); + free_node(*expr_gen.node_allocator_, branch[1]); } } @@ -28096,7 +28457,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]); } @@ -28107,7 +28468,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]); } @@ -28115,7 +28476,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]); } @@ -28131,7 +28492,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]); } @@ -28147,7 +28508,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]); } @@ -28179,7 +28540,7 @@ namespace exprtk if (synthesize_map_.end() != itr) { - result = itr->second(*this,operation,branch); + result = itr->second(*this, operation, branch); return true; } @@ -28201,7 +28562,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 @@ -28222,13 +28583,13 @@ namespace exprtk 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) @@ -28236,7 +28597,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 @@ -28255,7 +28616,7 @@ namespace exprtk 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)) { @@ -28264,15 +28625,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) @@ -28280,7 +28641,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 @@ -28343,12 +28704,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) @@ -28393,7 +28754,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; } @@ -28418,23 +28780,23 @@ namespace exprtk { 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; } @@ -28461,23 +28823,23 @@ namespace exprtk { 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; } @@ -28498,8 +28860,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; @@ -28520,8 +28882,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; @@ -28559,7 +28921,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")); @@ -28567,14 +28929,18 @@ 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, @@ -28615,7 +28981,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")); @@ -28623,14 +28989,18 @@ 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, @@ -28672,7 +29042,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")); @@ -28680,14 +29050,18 @@ 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, @@ -28728,7 +29102,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")); @@ -28736,14 +29110,18 @@ 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, @@ -28784,7 +29162,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")); @@ -28792,14 +29170,18 @@ 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, @@ -28840,7 +29222,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")); @@ -28848,14 +29230,18 @@ 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, @@ -28896,7 +29282,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")); @@ -28904,14 +29290,18 @@ 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, @@ -28953,7 +29343,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")); @@ -28961,14 +29351,18 @@ 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) @@ -29070,14 +29464,18 @@ namespace exprtk } } - 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, @@ -29180,14 +29578,18 @@ namespace exprtk } } - 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, @@ -29300,14 +29702,18 @@ namespace exprtk } } - 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) @@ -29417,14 +29823,18 @@ namespace exprtk } } - 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, @@ -29486,7 +29896,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")); @@ -29497,7 +29907,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")); @@ -29508,7 +29918,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")); @@ -29519,7 +29929,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")); @@ -29530,7 +29940,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")); @@ -29538,7 +29948,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(); @@ -29547,7 +29961,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, @@ -29599,7 +30013,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")); @@ -29610,7 +30024,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")); @@ -29618,7 +30032,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(); @@ -29627,7 +30045,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, @@ -29679,7 +30097,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")); @@ -29690,7 +30108,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")); @@ -29698,7 +30116,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(); @@ -29707,7 +30129,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, @@ -29759,7 +30181,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")); @@ -29770,7 +30192,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")); @@ -29778,7 +30200,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(); @@ -29787,7 +30213,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, @@ -29839,7 +30265,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")); @@ -29850,7 +30276,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")); @@ -29858,7 +30284,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(); @@ -29867,7 +30297,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, @@ -29919,7 +30349,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")); @@ -29930,7 +30360,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")); @@ -29941,7 +30371,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")); @@ -29952,7 +30382,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")); @@ -29963,7 +30393,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")); @@ -29974,7 +30404,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")); @@ -29985,7 +30415,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")); @@ -29996,7 +30426,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")); @@ -30007,7 +30437,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")); @@ -30035,7 +30465,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")); @@ -30043,7 +30473,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(); @@ -30052,7 +30486,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, @@ -30104,7 +30538,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")); @@ -30115,7 +30549,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")); @@ -30126,7 +30560,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")); @@ -30137,7 +30571,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")); @@ -30148,7 +30582,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")); @@ -30159,7 +30593,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")); @@ -30170,7 +30604,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")); @@ -30181,7 +30615,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")); @@ -30192,7 +30626,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")); @@ -30203,7 +30637,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")); @@ -30214,7 +30648,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")); @@ -30242,7 +30676,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")); @@ -30270,7 +30704,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")); @@ -30278,7 +30712,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(); @@ -30287,7 +30725,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, @@ -30339,7 +30777,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")); @@ -30350,7 +30788,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")); @@ -30361,7 +30799,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")); @@ -30372,7 +30810,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")); @@ -30383,7 +30821,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")); @@ -30394,7 +30832,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")); @@ -30405,7 +30843,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")); @@ -30416,7 +30854,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")); @@ -30427,7 +30865,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")); @@ -30455,7 +30893,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")); @@ -30463,7 +30901,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(); @@ -30472,7 +30914,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, @@ -30524,7 +30966,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")); @@ -30535,7 +30977,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")); @@ -30546,7 +30988,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")); @@ -30557,7 +30999,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")); @@ -30568,7 +31010,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")); @@ -30579,7 +31021,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")); @@ -30590,7 +31032,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")); @@ -30601,7 +31043,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")); @@ -30612,7 +31054,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")); @@ -30639,7 +31081,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")); @@ -30647,7 +31089,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(); @@ -30656,7 +31102,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, @@ -30753,14 +31199,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, @@ -30805,14 +31255,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, @@ -30857,14 +31311,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, @@ -30910,14 +31368,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, @@ -30963,14 +31425,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, @@ -31015,14 +31481,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, @@ -31067,14 +31537,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, @@ -31119,14 +31593,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, @@ -31171,14 +31649,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, @@ -31223,14 +31705,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, @@ -31275,14 +31761,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, @@ -31327,14 +31817,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, @@ -31380,14 +31874,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, @@ -31433,14 +31931,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, @@ -31485,14 +31987,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, @@ -31538,14 +32044,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, @@ -31607,14 +32117,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, @@ -31660,14 +32174,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, @@ -31712,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,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, @@ -31764,14 +32286,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, @@ -31816,14 +32342,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, @@ -31868,14 +32398,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, @@ -31921,14 +32455,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, @@ -31974,14 +32512,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, @@ -32026,14 +32568,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, @@ -32078,14 +32624,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, @@ -32131,14 +32681,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, @@ -32183,14 +32737,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, @@ -32234,14 +32792,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, @@ -32286,14 +32848,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, @@ -32338,14 +32904,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, @@ -32391,14 +32961,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, @@ -32444,14 +33018,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, @@ -32904,14 +33482,16 @@ namespace exprtk details::is_string_concat_node (branch[0]) || details::is_string_function_node (branch[0]) || details::is_string_condition_node (branch[0]) || - details::is_string_ccondition_node (branch[0]) ; + details::is_string_ccondition_node (branch[0]) || + details::is_string_vararg_node (branch[0]) ; const bool b1_is_gen = details::is_string_assignment_node (branch[1]) || details::is_genricstring_range_node(branch[1]) || details::is_string_concat_node (branch[1]) || details::is_string_function_node (branch[1]) || details::is_string_condition_node (branch[1]) || - details::is_string_ccondition_node (branch[1]) ; + details::is_string_ccondition_node (branch[1]) || + details::is_string_vararg_node (branch[1]) ; if (details::e_add == opr) { @@ -33350,45 +33930,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 } @@ -33399,24 +33979,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 } @@ -33427,24 +34007,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 } @@ -33464,6 +34044,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) @@ -33518,6 +34104,7 @@ namespace exprtk inline void return_cleanup() { + #ifndef exprtk_disable_return_statement if (results_context_) { delete results_context_; @@ -33525,6 +34112,7 @@ namespace exprtk } state_.return_stmt_present = false; + #endif } private: @@ -33574,8 +34162,8 @@ namespace exprtk { typedef double T; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; typedef parser_t::dependent_entity_collector::symbol_t symbol_t; symbol_table_t symbol_table; @@ -33610,8 +34198,8 @@ namespace exprtk Sequence& symbol_list) { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_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; @@ -33648,8 +34236,8 @@ namespace exprtk { typedef double T; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; typedef parser_t::dependent_entity_collector::symbol_t symbol_t; symbol_table_t symbol_table; @@ -33684,8 +34272,8 @@ namespace exprtk Sequence& symbol_list) { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_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; @@ -33724,15 +34312,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); } @@ -33774,13 +34362,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); @@ -33794,15 +34382,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); @@ -33817,13 +34405,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); @@ -33873,8 +34461,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; @@ -33900,8 +34488,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; @@ -34530,6 +35118,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) { @@ -34539,8 +35128,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); } } } @@ -34548,6 +35137,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) { @@ -34557,8 +35147,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); } } } @@ -35293,8 +35883,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(); @@ -35740,7 +36330,7 @@ namespace exprtk { T t = T(0); - std::memcpy(reinterpret_cast(&t), + std::memcpy(reinterpret_cast(&t ), reinterpret_cast(&fd), sizeof(fd)); return t; @@ -36017,7 +36607,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); } }; } @@ -36063,7 +36653,10 @@ namespace exprtk 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) @@ -36106,7 +36699,10 @@ namespace exprtk 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) @@ -36149,7 +36745,10 @@ namespace exprtk 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) @@ -36192,7 +36791,10 @@ namespace exprtk 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) @@ -36235,7 +36837,10 @@ namespace exprtk 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; @@ -36282,10 +36887,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); @@ -36328,7 +36937,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; @@ -36373,7 +36985,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; @@ -36418,7 +37033,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; @@ -36470,7 +37088,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; @@ -36522,9 +37143,9 @@ namespace exprtk 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; @@ -36581,7 +37202,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); @@ -36619,14 +37240,14 @@ namespace exprtk vector_t vec(parameters[0]); T increment = scalar_t(parameters[1])(); - T base = ((1 == ps_index) || (3 == ps_index))? scalar_t(parameters[2])() : T(0); + T base = ((1 == ps_index) || (3 == ps_index)) ? scalar_t(parameters[2])() : T(0); 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 { @@ -36670,7 +37291,7 @@ namespace exprtk 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); @@ -36716,7 +37337,7 @@ namespace exprtk 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)) return std::numeric_limits::quiet_NaN(); @@ -36763,7 +37384,7 @@ namespace exprtk 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)) return std::numeric_limits::quiet_NaN(); @@ -36812,7 +37433,7 @@ namespace exprtk 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)) return std::numeric_limits::quiet_NaN(); @@ -36862,7 +37483,7 @@ namespace exprtk 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)) return std::numeric_limits::quiet_NaN(); @@ -36912,7 +37533,7 @@ namespace exprtk 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)) return std::numeric_limits::quiet_NaN(); @@ -36959,7 +37580,7 @@ namespace exprtk 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)) return std::numeric_limits::quiet_NaN(); @@ -37005,7 +37626,7 @@ namespace exprtk 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)) return std::numeric_limits::quiet_NaN(); @@ -37097,9 +37718,9 @@ namespace exprtk namespace information { static const char* library = "Mathematical Expression Toolkit"; - static const char* version = "2.718281828459045235360287471352662497757247" - "09369995957496696762772407663035354759457138"; - static const char* date = "20170107"; + static const char* version = "2.7182818284590452353602874713526624977572470936" + "999595749669676277240766303535475945713821785251"; + static const char* date = "20170505"; static inline std::string data() { diff --git a/exprtk_benchmark.cpp b/exprtk_benchmark.cpp index a38da99..6cb8167 100644 --- a/exprtk_benchmark.cpp +++ b/exprtk_benchmark.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * ExprTk vs Native Benchmarks * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_01.cpp b/exprtk_simple_example_01.cpp index 3bd9a26..4c0037b 100644 --- a/exprtk_simple_example_01.cpp +++ b/exprtk_simple_example_01.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 1 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_02.cpp b/exprtk_simple_example_02.cpp index 0b3477b..cb18b35 100644 --- a/exprtk_simple_example_02.cpp +++ b/exprtk_simple_example_02.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 2 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_03.cpp b/exprtk_simple_example_03.cpp index a7e7947..16b627f 100644 --- a/exprtk_simple_example_03.cpp +++ b/exprtk_simple_example_03.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 3 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_04.cpp b/exprtk_simple_example_04.cpp index 7830a13..7cf9393 100644 --- a/exprtk_simple_example_04.cpp +++ b/exprtk_simple_example_04.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 4 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_05.cpp b/exprtk_simple_example_05.cpp index fa3a67e..a4dbe0c 100644 --- a/exprtk_simple_example_05.cpp +++ b/exprtk_simple_example_05.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 5 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_06.cpp b/exprtk_simple_example_06.cpp index 6566be5..9a5c431 100644 --- a/exprtk_simple_example_06.cpp +++ b/exprtk_simple_example_06.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 6 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_07.cpp b/exprtk_simple_example_07.cpp index 76d02fa..9f50b6d 100644 --- a/exprtk_simple_example_07.cpp +++ b/exprtk_simple_example_07.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 7 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_08.cpp b/exprtk_simple_example_08.cpp index e263bce..a785d82 100644 --- a/exprtk_simple_example_08.cpp +++ b/exprtk_simple_example_08.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 8 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_09.cpp b/exprtk_simple_example_09.cpp index 69f45c2..469c910 100644 --- a/exprtk_simple_example_09.cpp +++ b/exprtk_simple_example_09.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 9 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_10.cpp b/exprtk_simple_example_10.cpp index 006fc2a..43cb0b1 100644 --- a/exprtk_simple_example_10.cpp +++ b/exprtk_simple_example_10.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 10 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_11.cpp b/exprtk_simple_example_11.cpp index fe87553..c6c4daf 100644 --- a/exprtk_simple_example_11.cpp +++ b/exprtk_simple_example_11.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 11 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_12.cpp b/exprtk_simple_example_12.cpp index 162a9ad..5acea5f 100644 --- a/exprtk_simple_example_12.cpp +++ b/exprtk_simple_example_12.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 12 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_13.cpp b/exprtk_simple_example_13.cpp index 1dfa1e5..ec9d3b1 100644 --- a/exprtk_simple_example_13.cpp +++ b/exprtk_simple_example_13.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 13 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_14.cpp b/exprtk_simple_example_14.cpp index c07c4b3..ec7e66a 100644 --- a/exprtk_simple_example_14.cpp +++ b/exprtk_simple_example_14.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 14 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_15.cpp b/exprtk_simple_example_15.cpp index 830a1af..e3a1ec2 100644 --- a/exprtk_simple_example_15.cpp +++ b/exprtk_simple_example_15.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 15 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_16.cpp b/exprtk_simple_example_16.cpp index 512bc8c..ffad092 100644 --- a/exprtk_simple_example_16.cpp +++ b/exprtk_simple_example_16.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 16 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_17.cpp b/exprtk_simple_example_17.cpp index 94e3bf2..300aaed 100644 --- a/exprtk_simple_example_17.cpp +++ b/exprtk_simple_example_17.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 17 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_18.cpp b/exprtk_simple_example_18.cpp index a02663f..54e1775 100644 --- a/exprtk_simple_example_18.cpp +++ b/exprtk_simple_example_18.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 18 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_simple_example_19.cpp b/exprtk_simple_example_19.cpp index a173df7..e088ecc 100644 --- a/exprtk_simple_example_19.cpp +++ b/exprtk_simple_example_19.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 19 * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_test.cpp b/exprtk_test.cpp index d55cfdf..4fcdbe4 100644 --- a/exprtk_test.cpp +++ b/exprtk_test.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Examples and Unit-Tests * - * Author: Arash Partow (1999-2017) * + * Author: Arash Partow (1999-2017) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -1308,13 +1308,13 @@ inline bool run_test01() test_xy(" ((2) y) == (2*y)" ,T(2.0),T(3.0),T(1.0)), test_xy(" (2 (y)) == (2*y)" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; (a)(3) == 6" ,T(2.0),T(3.0),T(1.0)), - test_xy("var a := 2; (a){3} == 6" ,T(2.0),T(3.0),T(1.0)), + test_xy("var a := 2; (A){3} == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; (a)[3] == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; {a}(3) == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; {a}{3} == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; {a}[3] == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; var b := 3; (a)(b) == 6" ,T(2.0),T(3.0),T(1.0)), - test_xy("var a := 2; var b := 3; (a){b} == 6" ,T(2.0),T(3.0),T(1.0)), + test_xy("var a := 2; var b := 3; (a){B} == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; var b := 3; (a)[b] == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; var b := 3; {a}(b) == 6" ,T(2.0),T(3.0),T(1.0)), test_xy("var a := 2; var b := 3; {a}{b} == 6" ,T(2.0),T(3.0),T(1.0)), @@ -1604,7 +1604,7 @@ inline bool run_test01() test_xy("var a := 2; (1 * a) == a",T(0),T(0),T(1)), test_xy("var a.b := 3; (2 * a.b ) == 6",T(0),T(0),T(1)), test_xy("var aa.bb := 3; (2 * aa.bb ) == 6",T(0),T(0),T(1)), - test_xy("var aaa.bbb := 3; (2 * aaa.bbb) == 6",T(0),T(0),T(1)), + test_xy("var aaa.bbb := 3; (2 * aAa.BbB) == 6",T(0),T(0),T(1)), test_xy("var a1.b2 := 3; (2 * a1.b2 ) == 6",T(0),T(0),T(1)) }; @@ -3273,15 +3273,15 @@ struct myfunc : public exprtk::ifunction } }; -#define define_free_functions(Type) \ -Type foo1(Type v0) { return v0; } \ -Type foo2(Type v0, Type v1) { return v0 + v1; } \ -Type foo3(Type v0, Type v1, Type v2) { return v0 + v1 + v2; } \ -Type foo4(Type v0, Type v1, Type v2, Type v3) { return v0 + v1 + v2 + v3; } \ -Type foo5(Type v0, Type v1, Type v2, Type v3, Type v4) { return v0 + v1 + v2 + v3 + v4; } \ -Type foo6(Type v0, Type v1, Type v2, Type v3, Type v4, Type v5) { return v0 + v1 + v2 + v3 + v4 + v5; } \ +#define define_free_functions(N,Type) \ +Type N##1(Type v0) { return v0; } \ +Type N##2(Type v0, Type v1) { return v0 + v1; } \ +Type N##3(Type v0, Type v1, Type v2) { return v0 + v1 + v2; } \ +Type N##4(Type v0, Type v1, Type v2, Type v3) { return v0 + v1 + v2 + v3; } \ +Type N##5(Type v0, Type v1, Type v2, Type v3, Type v4) { return v0 + v1 + v2 + v3 + v4; } \ +Type N##6(Type v0, Type v1, Type v2, Type v3, Type v4, Type v5) { return v0 + v1 + v2 + v3 + v4 + v5; } \ -define_free_functions(numeric_type) +define_free_functions(foo,numeric_type) #undef define_free_functions template @@ -4269,10 +4269,10 @@ inline bool run_test10() "var x[3] := [8]; var y[3] := {1,2,3}; (x += 1) <=> (y += 1); (x[0] == 2) and (x[1] == 3) and (x[2] == 4)", "var x[3] := [8]; var y[2] := {1,2}; (x += 1) <=> (y += 1); (x[0] == 2) and (x[1] == 3) and (x[2] == 9)", "var x[3] := [8]; var y[1] := {1}; (x += 1) <=> (y += 1); (x[0] == 2) and (x[1] == 9) and (x[2] == 9)", - "var x[3] := [0]; var y[4] := {1,2,3,4}; x < y", - "var x[3] := [0]; var y[3] := {1,2,3}; x < y", - "var x[3] := [0]; var y[2] := {1,2}; x < y", - "var x[3] := [0]; var y[1] := {1}; x < y", + "var x[3] := [0]; var y[4] := {1,2,3,4}; X < y", + "var x[3] := [0]; var y[3] := {1,2,3}; x < Y", + "var x[3] := [0]; var y[2] := {1,2}; X < y", + "var x[3] := [0]; var y[1] := {1}; x < Y", "var x[3] := [0]; var y[4] := {1,2,3,4}; x <= y", "var x[3] := [0]; var y[3] := {1,2,3}; x <= y", "var x[3] := [0]; var y[2] := {1,2}; x <= y", @@ -4382,6 +4382,15 @@ inline bool run_test10() "0 == (for (var i := 0; i < 10; i += 1) { ~{continue; break[7]; i += i} })", "1 == (for (var i := 0; i < 10; i += 1) { ~{break[i += 1]; continue; i += i} })", + "var s := 'abc'; s == ~{'abc' } ", + "var s := 'abc'; s == ~{s } ", + "var s := 'abc'; s == ~{'ab' + 'c'} ", + "var s := 'abc'; ~{'abc' } == s ", + "var s := 'abc'; ~{s } == s ", + "var s := 'abc'; ~{'ab' + 'c'} == s ", + "var s := 'abc'; ~{1 + 2; 'abc' + s; s} == s ", + "var s := 'abc'; ~{1 + 2; var x := 'ab'; x + 'c'} == s ", + "var x[10^6] := null; var y[10^7] := null; 0 * (min(x) + min(y)) + x[] + y[] == 10^7 + 10^6" }; @@ -7656,54 +7665,164 @@ struct my_usr : public exprtk::parser::unknown_symbol_resolver } }; +template +struct my_usr_ext : public exprtk::parser::unknown_symbol_resolver +{ + typedef exprtk::symbol_table symbol_table_t; + typedef typename exprtk::parser::unknown_symbol_resolver usr_t; + + my_usr_ext() + : usr_t(usr_t::e_usrmode_extended) + {} + + virtual bool process(const std::string& unknown_symbol, + symbol_table_t& symbol_table, + std::string& error_message) + { + bool result = false; + + if (unknown_symbol[0] == 'v') + { + static T var_default_value = 1.0; + + if (!(result = symbol_table.create_variable(unknown_symbol, var_default_value++))) + { + error_message = "Failed to create variable(" + unknown_symbol + ") in primary symbol table"; + } + } + else if (unknown_symbol[0] == 'c') + { + static T cvar_default_value = 1.0; + + if (!(result = symbol_table.add_constant(unknown_symbol, cvar_default_value++))) + { + error_message = "Failed to create const variable(" + unknown_symbol + ") in primary symbol table"; + } + } + else if (0 == unknown_symbol.find("foo")) + { + //functions of form: fooXX + if (4 >= unknown_symbol.size()) + { + switch(unknown_symbol[3]) + { + case '1' : result = symbol_table.add_function(unknown_symbol,foo1); + break; + + case '2' : result = symbol_table.add_function(unknown_symbol,foo2); + break; + + case '3' : result = symbol_table.add_function(unknown_symbol,foo3); + break; + + case '4' : result = symbol_table.add_function(unknown_symbol,foo4); + break; + + case '5' : result = symbol_table.add_function(unknown_symbol,foo5); + break; + + case '6' : result = symbol_table.add_function(unknown_symbol,foo6); + break; + } + } + + if (!result) + { + error_message = "Failed to add function(" + unknown_symbol + ") in primary symbol table"; + } + } + else + error_message = "Indeterminable symbol type."; + + return result; + } +}; + template inline bool run_test20() { typedef exprtk::expression expression_t; - for (std::size_t i = 0; i < 100; ++i) { - exprtk::symbol_table symbol_table0; - exprtk::symbol_table symbol_table1; - exprtk::symbol_table symbol_table2; - exprtk::symbol_table symbol_table3; - - symbol_table0.add_constants(); - - expression_t expression; - expression.register_symbol_table(symbol_table0); - expression.register_symbol_table(symbol_table1); - expression.register_symbol_table(symbol_table2); - expression.register_symbol_table(symbol_table3); - - exprtk::parser parser; - - my_usr musr; - musr.next_value(true); - parser.enable_unknown_symbol_resolver(&musr); - - std::string expr_str = "v01+c02+v03+c04+v05+c06+v07+c08+v09+c10+" - "v11+c12+v13+c14+v15+c16+v17+c18+v19+c20+" - "v21+c22+v23+c24+v25+c26+v27+c28+v29+c30 "; - - if (!parser.compile(expr_str,expression)) + for (std::size_t i = 0; i < 100; ++i) { - printf("run_test20() - Error: %s Expression: %s\n", - parser.error().c_str(), - expr_str.c_str()); + exprtk::symbol_table symbol_table0; // primary symbol_table + exprtk::symbol_table symbol_table1; + exprtk::symbol_table symbol_table2; + exprtk::symbol_table symbol_table3; - return false; + symbol_table0.add_constants(); + + expression_t expression; + expression.register_symbol_table(symbol_table0); + expression.register_symbol_table(symbol_table1); + expression.register_symbol_table(symbol_table2); + expression.register_symbol_table(symbol_table3); + + exprtk::parser parser; + + my_usr musr; + musr.next_value(true); + parser.enable_unknown_symbol_resolver(&musr); + + std::string expr_str = "v01+c02+v03+c04+v05+c06+v07+c08+v09+c10+" + "v11+c12+v13+c14+v15+c16+v17+c18+v19+c20+" + "v21+c22+v23+c24+v25+c26+v27+c28+v29+c30 "; + + if (!parser.compile(expr_str,expression)) + { + printf("run_test20() - [1] Error: %s Expression: %s\n", + parser.error().c_str(), + expr_str.c_str()); + + return false; + } + + T sum_1_30 = T((1 + 30) * 15); + T result = expression.value(); + + if (sum_1_30 != result) + { + printf("run_test20() - [1] Error in evaluation! (1) Expression: %s\n", + expr_str.c_str()); + + return false; + } } + } - T sum_1_30 = T((1 + 30) * 15); - T result = expression.value(); - - if (sum_1_30 != result) + { + for (std::size_t i = 0; i < 100; ++i) { - printf("run_test20() - Error in evaluation! (1) Expression: %s\n", - expr_str.c_str()); + exprtk::symbol_table symbol_table0; // primary symbol_table + exprtk::symbol_table symbol_table1; + exprtk::symbol_table symbol_table2; + exprtk::symbol_table symbol_table3; - return false; + symbol_table0.add_constants(); + + expression_t expression; + expression.register_symbol_table(symbol_table0); + expression.register_symbol_table(symbol_table1); + expression.register_symbol_table(symbol_table2); + expression.register_symbol_table(symbol_table3); + + exprtk::parser parser; + + my_usr_ext musr; + parser.enable_unknown_symbol_resolver(&musr); + + std::string expr_str = "foo6(foo1(v0),foo2(c1,foo4(v2,c3,v4,c5)),foo3" + "(v6,c7,foo5(v8,c9,v10,c11,v12)),c13,v14,c15) "; + + if (!parser.compile(expr_str,expression)) + { + printf("run_test20() - [2] Error: %s Expression: %s\n", + parser.error().c_str(), + expr_str.c_str()); + + return false; + } } } diff --git a/readme.txt b/readme.txt index 39dc5b2..485791b 100644 --- a/readme.txt +++ b/readme.txt @@ -84,7 +84,7 @@ arithmetic operations, functions and processes: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [SECTION 02 - EXAMPLE EXPRESSIONS] -The following is a short listing of the types of mathematical +The following is a short listing of infix format based mathematical expressions that can be parsed and evaluated using the ExprTk library. (01) sqrt(1 - (3 / x^2)) @@ -1316,7 +1316,7 @@ side-effects, however the latter, statement 5, is the final statement in the expression and hence will be assumed to have a side-effect. During compilation when the DCE optimisation is applied to the above -expression, statement 2 will be removed from the expression, as it has +expression, statement 3 will be removed from the expression, as it has no bearing on the final result of expression, the rest of the statements will all remain. The optimised form of the expression is as follows: @@ -1358,7 +1358,7 @@ most imperative languages. There are two variations of the statement: (a) If-Statement This version of the conditional statement returns the value of the consequent expression when the condition expression is true, else it -will require a quiet NaN value as its result. +will return a quiet NaN value as its result. Example 1: x := if (y < z) y + 3; @@ -2841,7 +2841,7 @@ simple user defined USR: T& default_value, std::string& error_message) { - if (0 != unknown_symbol.find('var_')) + if (0 != unknown_symbol.find("var_")) { error_message = "Invalid symbol: " + unknown_symbol; return false; @@ -2877,13 +2877,84 @@ simple user defined USR: In the example above, a user specified USR is defined, and is -registered with the parser enabling the USR functionality. The when an -unknown symbol is encountered during the compilation process, the +registered with the parser enabling the USR functionality. Then when +an unknown symbol is encountered during the compilation process, the USR's process method will be invoked. The USR in the example will only 'accept' unknown symbols that have a prefix of 'var_' as being valid variables, all other unknown symbols will result in a compilation error being raised. +In the example above the callback of the USR that is invoked during +the unknown symbol resolution process only allows for scalar variables +to be defined and resolved - as that is the simplest and most common +form. + +There is also an extended version of the callback that can be +overridden that will allow for more control and choice over the type +of symbol being resolved. The following is an example definition of +said extended callback: + + template + struct my_usr : public parser_t::unknown_symbol_resolver + { + typedef typename parser_t::unknown_symbol_resolver usr_t; + + my_usr() + : usr_t(usr_t::e_usrmode_extended) + {} + + virtual bool process(const std::string& unknown_symbol, + symbol_table_t& symbol_table, + std::string& error_message) + { + bool result = false; + + if (0 == unknown_symbol.find("var_")) + { + // Default value of zero + result = symbol_table.create_variable(unknown_symbol,0); + + if (!result) + { + error_message = "Failed to create variable..."; + } + } + else if (0 == unknown_symbol.find("str_")) + { + // Default value of empty string + result = symbol_table.create_stringvar(unknown_symbol,""); + + if (!result) + { + error_message = "Failed to create string variable..."; + } + } + else + error_message = "Indeterminable symbol type."; + + return result; + } + }; + + +In the example above, the USR callback when invoked will pass the +primary symbol table associated with the expression being parsed. The +symbol resolution business logic can then determine under what +conditions a symbol will be resolved including its type (scalar, +string, vector etc) and default value. When the callback successfully +returns the symbol parsing and resolution process will again be +executed by the parser. The idea here is that given the primary symbol +table will now have the previously detected unknown symbol registered, +it will be correctly resolved and the general parsing processing can +then resume as per normal. + +Note: In order to have the USR's extended mode callback be invoked It +is necessary to pass the e_usrmode_extended enum value during the +constructor of the user defined USR. + +Note: The primary symbol table for an expression is the first symbol +table to be registered with that instance of the expression. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [SECTION 19 - ENABLING & DISABLING FEATURES] @@ -4338,47 +4409,53 @@ disable certain features and capabilities. The defines can either be part of a compiler command line switch or scoped around the include to the ExprTk header. The defines are as follows: - (1) exprtk_enable_debugging - (2) exprtk_disable_comments - (3) exprtk_disable_break_continue - (4) exprtk_disable_sc_andor - (5) exprtk_disable_enhanced_features - (6) exprtk_disable_string_capabilities - (7) exprtk_disable_superscalar_unroll - (8) exprtk_disable_rtl_io_file + (01) exprtk_enable_debugging + (02) exprtk_disable_comments + (03) exprtk_disable_break_continue + (04) exprtk_disable_sc_andor + (05) exprtk_disable_return_statement + (06) exprtk_disable_enhanced_features + (07) exprtk_disable_string_capabilities + (08) exprtk_disable_superscalar_unroll + (09) exprtk_disable_rtl_io_file + (10) exprtk_disable_rtl_vecops + (11) exprtk_disable_caseinsensitivity -(1) exprtk_enable_debugging +(01) exprtk_enable_debugging This define will enable printing of debug information to stdout during the compilation process. -(2) exprtk_disable_comments +(02) exprtk_disable_comments This define will disable the ability for expressions to have comments. Expressions that have comments when parsed with a build that has this option, will result in a compilation failure. -(3) exprtk_disable_break_continue +(03) exprtk_disable_break_continue This define will disable the loop-wise 'break' and 'continue' capabilities. Any expression that contains those keywords will result in a compilation failure. -(4) exprtk_disable_sc_andor +(04) exprtk_disable_sc_andor This define will disable the short-circuit '&' (and) and '|' (or) operators -(5) exprtk_disable_enhanced_features +(05) exprtk_disable_return_statement +This define will disable use of return statements within expressions. + +(06) exprtk_disable_enhanced_features This define will disable all enhanced features such as strength reduction and special function optimisations and expression specific type instantiations. This feature will reduce compilation times and binary sizes but will also result in massive performance degradation of expression evaluations. -(6) exprtk_disable_string_capabilities +(07) exprtk_disable_string_capabilities This define will disable all string processing capabilities. Any expression that contains a string or string related syntax will result in a compilation failure. -(7) exprtk_disable_superscalar_unroll +(08) exprtk_disable_superscalar_unroll This define will set the loop unroll batch size to 4 operations per loop instead of the default 8 operations. This define is used in operations that involve vectors and aggregations over vectors. When @@ -4386,17 +4463,22 @@ targeting non-superscalar architectures, it may be recommended to build using this particular option if efficiency of evaluations is of concern. -(8) exprtk_disable_rtl_io_file +(09) exprtk_disable_rtl_io_file This define will disable the file I/O RTL package features. When present, any attempts to register the file I/O package with a given symbol table will fail causing a compilation error. -(9) exprtk_disable_rtl_vecops +(10) exprtk_disable_rtl_vecops This define will disable the extended vector operations RTL package features. When present, any attempts to register the vector operations package with a given symbol table will fail causing a compilation error. +(11) exprtk_disable_caseinsensitivity +This define will disable case-insensitivity when matching variables +and functions. Furthermore all reserved and keywords will only be +acknowledged when in all lower-case. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [SECTION 28 - FILES] @@ -4653,4 +4735,4 @@ ExprTk and their structural representations. | | | | | +--<--- [,] <-----+ | | | -+-------------------------------------------------------------+ \ No newline at end of file ++-------------------------------------------------------------+