diff --git a/Makefile b/Makefile index d81702c..59a7110 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # ************************************************************** # * C++ Mathematical Expression Toolkit Library * # * * -# * Author: Arash Partow (1999-2015) * +# * Author: Arash Partow (1999-2016) * # * URL: http://www.partow.net/programming/exprtk/index.html * # * * # * Copyright notice: * diff --git a/exprtk.hpp b/exprtk.hpp index a9aba4a..17bb65b 100644 --- a/exprtk.hpp +++ b/exprtk.hpp @@ -2,7 +2,7 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2015) * + * Author: Arash Partow (1999-2016) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -405,14 +405,14 @@ namespace exprtk static const std::string cntrl_struct_list[] = { - "for", "if", "repeat", "switch", "while" + "if", "switch", "for", "while", "repeat" }; static const std::size_t cntrl_struct_list_size = sizeof(cntrl_struct_list) / sizeof(std::string); static const std::string arithmetic_ops_list[] = { - "+", "-", "*", "/", "%", "^" + "+", "-", "*", "/", "%", "^" }; static const std::size_t arithmetic_ops_list_size = sizeof(arithmetic_ops_list) / sizeof(std::string); @@ -488,7 +488,7 @@ namespace exprtk inline bool is_logic_opr(const std::string& lgc_opr) { - for (std::size_t i = 0; i < cntrl_struct_list_size; ++i) + for (std::size_t i = 0; i < logic_ops_list_size; ++i) { if (imatch(lgc_opr,logic_ops_list[i])) { @@ -2401,9 +2401,10 @@ namespace exprtk 8. 123.456E-3 */ const char* initial_itr = s_itr_; - bool dot_found = false; - bool e_found = false; - bool post_e_sign_found = false; + 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_)) @@ -2450,7 +2451,7 @@ namespace exprtk continue; } - else if (e_found && details::is_sign(*s_itr_)) + else if (e_found && details::is_sign(*s_itr_) && !post_e_digit_found) { if (post_e_sign_found) { @@ -2465,6 +2466,13 @@ namespace exprtk continue; } + else if (e_found && details::is_digit(*s_itr_)) + { + post_e_digit_found = true; + ++s_itr_; + + continue; + } else if (('.' != (*s_itr_)) && !details::is_digit(*s_itr_)) break; else @@ -17708,7 +17716,7 @@ namespace exprtk { if ( (e_bf_unknown != bf) && - (static_cast(bf) < details::base_function_list_size) + (static_cast(bf) < (details::base_function_list_size + 1)) ) { disabled_func_set_.insert(details::base_function_list[bf - 1]); @@ -17721,7 +17729,7 @@ namespace exprtk { if ( (e_ctrl_unknown != ctrl_struct) && - (static_cast(ctrl_struct) < details::cntrl_struct_list_size) + (static_cast(ctrl_struct) < (details::cntrl_struct_list_size + 1)) ) { disabled_ctrl_set_.insert(details::cntrl_struct_list[ctrl_struct - 1]); @@ -17734,7 +17742,7 @@ namespace exprtk { if ( (e_logic_unknown != logic) && - (static_cast(logic) < details::logic_ops_list_size) + (static_cast(logic) < (details::logic_ops_list_size + 1)) ) { disabled_logic_set_.insert(details::logic_ops_list[logic - 1]); @@ -17747,7 +17755,7 @@ namespace exprtk { if ( (e_arith_unknown != arithmetic) && - (static_cast(arithmetic) < details::arithmetic_ops_list_size) + (static_cast(arithmetic) < (details::arithmetic_ops_list_size + 1)) ) { disabled_arithmetic_set_.insert(details::arithmetic_ops_list[arithmetic - 1]); @@ -17760,7 +17768,7 @@ namespace exprtk { if ( (e_assign_unknown != assignment) && - (static_cast(assignment) < details::assignment_ops_list_size) + (static_cast(assignment) < (details::assignment_ops_list_size + 1)) ) { disabled_assignment_set_.insert(details::assignment_ops_list[assignment - 1]); @@ -17773,7 +17781,7 @@ namespace exprtk { if ( (e_ineq_unknown != inequality) && - (static_cast(inequality) < details::inequality_ops_list_size) + (static_cast(inequality) < (details::inequality_ops_list_size + 1)) ) { disabled_inequality_set_.insert(details::inequality_ops_list[inequality - 1]); @@ -17786,7 +17794,7 @@ namespace exprtk { if ( (e_bf_unknown != bf) && - (static_cast(bf) < details::base_function_list_size) + (static_cast(bf) < (details::base_function_list_size + 1)) ) { des_itr_t itr = disabled_func_set_.find(details::base_function_list[bf - 1]); @@ -17804,7 +17812,7 @@ namespace exprtk { if ( (e_ctrl_unknown != ctrl_struct) && - (static_cast(ctrl_struct) < details::cntrl_struct_list_size) + (static_cast(ctrl_struct) < (details::cntrl_struct_list_size + 1)) ) { des_itr_t itr = disabled_ctrl_set_.find(details::cntrl_struct_list[ctrl_struct - 1]); @@ -17822,7 +17830,7 @@ namespace exprtk { if ( (e_logic_unknown != logic) && - (static_cast(logic) < details::logic_ops_list_size) + (static_cast(logic) < (details::logic_ops_list_size + 1)) ) { des_itr_t itr = disabled_logic_set_.find(details::logic_ops_list[logic - 1]); @@ -17840,7 +17848,7 @@ namespace exprtk { if ( (e_arith_unknown != arithmetic) && - (static_cast(arithmetic) < details::arithmetic_ops_list_size) + (static_cast(arithmetic) < (details::arithmetic_ops_list_size + 1)) ) { des_itr_t itr = disabled_arithmetic_set_.find(details::arithmetic_ops_list[arithmetic - 1]); @@ -17858,7 +17866,7 @@ namespace exprtk { if ( (e_assign_unknown != assignment) && - (static_cast(assignment) < details::assignment_ops_list_size) + (static_cast(assignment) < (details::assignment_ops_list_size + 1)) ) { des_itr_t itr = disabled_assignment_set_.find(details::assignment_ops_list[assignment - 1]); @@ -17876,7 +17884,7 @@ namespace exprtk { if ( (e_ineq_unknown != inequality) && - (static_cast(inequality) < details::inequality_ops_list_size) + (static_cast(inequality) < (details::inequality_ops_list_size + 1)) ) { des_itr_t itr = disabled_inequality_set_.find(details::inequality_ops_list[inequality - 1]); @@ -19018,6 +19026,10 @@ namespace exprtk template inline expression_node_ptr parse_function_call(ifunction* function, const std::string& function_name) { + #ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable: 4127) + #endif if (0 == NumberofParameters) { set_error( @@ -19027,6 +19039,9 @@ namespace exprtk return error_node(); } + #ifdef _MSC_VER + #pragma warning(pop) + #endif expression_node_ptr branch[NumberofParameters]; expression_node_ptr result = error_node(); @@ -21904,7 +21919,7 @@ namespace exprtk return error_node(); } - else if ((scope_element::e_string == se.type)) + else if (scope_element::e_string == se.type) { str_node = se.str_node; se.active = true; @@ -22090,7 +22105,7 @@ namespace exprtk return error_node(); } - else if ((scope_element::e_variable == se.type)) + else if (scope_element::e_variable == se.type) { var_node = se.var_node; se.active = true; @@ -32019,7 +32034,7 @@ namespace exprtk }; template - inline T integrate(expression& e, + inline T integrate(const expression& e, T& x, const T& r0, const T& r1, const std::size_t number_of_intervals = 1000000) @@ -32043,12 +32058,12 @@ namespace exprtk } template - inline T integrate(expression& e, + inline T integrate(const expression& e, const std::string& variable_name, const T& r0, const T& r1, const std::size_t number_of_intervals = 1000000) { - symbol_table& sym_table = e.get_symbol_table(); + const symbol_table& sym_table = e.get_symbol_table(); if (!sym_table.valid()) return std::numeric_limits::quiet_NaN(); @@ -32069,7 +32084,7 @@ namespace exprtk } template - inline T derivative(expression& e, + inline T derivative(const expression& e, T& x, const T& h = T(0.00000001)) { @@ -32088,7 +32103,7 @@ namespace exprtk } template - inline T second_derivative(expression& e, + inline T second_derivative(const expression& e, T& x, const T& h = T(0.00001)) { @@ -32108,7 +32123,7 @@ namespace exprtk } template - inline T third_derivative(expression& e, + inline T third_derivative(const expression& e, T& x, const T& h = T(0.0001)) { @@ -32127,11 +32142,11 @@ namespace exprtk } template - inline T derivative(expression& e, + inline T derivative(const expression& e, const std::string& variable_name, const T& h = T(0.00000001)) { - symbol_table& sym_table = e.get_symbol_table(); + const symbol_table& sym_table = e.get_symbol_table(); if (!sym_table.valid()) { @@ -32154,11 +32169,11 @@ namespace exprtk } template - inline T second_derivative(expression& e, + inline T second_derivative(const expression& e, const std::string& variable_name, const T& h = T(0.00001)) { - symbol_table& sym_table = e.get_symbol_table(); + const symbol_table& sym_table = e.get_symbol_table(); if (!sym_table.valid()) { @@ -32181,11 +32196,11 @@ namespace exprtk } template - inline T third_derivative(expression& e, + inline T third_derivative(const expression& e, const std::string& variable_name, const T& h = T(0.0001)) { - symbol_table& sym_table = e.get_symbol_table(); + const symbol_table& sym_table = e.get_symbol_table(); if (!sym_table.valid()) { @@ -33706,9 +33721,9 @@ namespace exprtk namespace information { static const char* library = "Mathematical Expression Toolkit"; - static const char* version = "2.7182818284590452353602874713526" - "624977572470936999595749669676277"; - static const char* date = "20150731"; + static const char* version = "2.71828182845904523536028747135266" + "2497757247093699959574966967627724"; + static const char* date = "20160113"; static inline std::string data() { diff --git a/exprtk_benchmark.cpp b/exprtk_benchmark.cpp index 866e694..26b6b7f 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 4792c87..165c711 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 4f1848e..3d707ab 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 11b8575..49c484a 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 8ff7817..21c6075 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 6b528aa..4adb3a0 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 d80fe86..13dd714 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 05b6ce2..52b7a85 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 b214966..ab80fd5 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 e7f9839..93a866e 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 76c5150..5e78e8a 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 8417b82..4852155 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 e02b9e0..5c4542e 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 6dd2b3c..30e2372 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 e105d9f..3be1065 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 8016bf5..f8cf1ed 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-2015) * + * Author: Arash Partow (1999-2016) * * 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 c75f297..ff11671 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-2015) * + * Author: Arash Partow (1999-2016) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_test.cpp b/exprtk_test.cpp index 0826c1e..df5c98c 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-2015) * + * Author: Arash Partow (1999-2016) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -301,6 +301,14 @@ static const test_t global_test_list[] = test_t("( 7 + 2 )",9.0), test_t("( 8 + 1 )",9.0), test_t("( 9 + 0 )",9.0), + test_t("1E1+1",11.0), + test_t("1e1+1",11.0), + test_t("1E1-1", 9.0), + test_t("1e1-1", 9.0), + test_t("1E01+1",11.0), + test_t("1e01+1",11.0), + test_t("1E01-1", 9.0), + test_t("1e01-1", 9.0), test_t("1+2",+3.0), test_t("1-2",-1.0), test_t("1*2",+2.0), diff --git a/readme.txt b/readme.txt index 845b689..04cb5cd 100644 --- a/readme.txt +++ b/readme.txt @@ -1886,7 +1886,7 @@ will not contain symbols denoting functions. [17 - ENABLING AND DISABLING FEATURES] The parser can be configured via its settings instance to either allow or disallow certain features that are available within the ExprTk -grammar. The features fall into one of the following three categories: +grammar. The features fall into one of the following six categories: (1) Base Functions (2) Control Flow Structures