diff --git a/.travis.yml b/.travis.yml index 5ce5a53..adfae02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,20 @@ +dist: xenial + language: cpp sudo: required -dist: trusty - -compiler: - - gcc +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-7 + - g++-7 script: - - make clean all + - export CC=gcc-7 + - export CXX=g++-7 + - make clean + - make all -j 4 - ./exprtk_test diff --git a/Makefile b/Makefile index 16e0357..7bd2367 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # ************************************************************** # * C++ Mathematical Expression Toolkit Library * # * * -# * Author: Arash Partow (1999-2018) * +# * Author: Arash Partow (1999-2019) * # * URL: http://www.partow.net/programming/exprtk/index.html * # * * # * Copyright notice: * @@ -16,7 +16,7 @@ COMPILER := -c++ -#COMPILER := -clang +#COMPILER := -clang++ OPTIMIZATION_OPT := -O1 BASE_OPTIONS := -pedantic-errors -Wall -Wextra -Werror -Wno-long-long OPTIONS := $(BASE_OPTIONS) $(OPTIMIZATION_OPT) diff --git a/exprtk.hpp b/exprtk.hpp index 802955a..5f8cac1 100644 --- a/exprtk.hpp +++ b/exprtk.hpp @@ -2,7 +2,7 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2018) * + * Author: Arash Partow (1999-2019) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -3106,7 +3106,7 @@ namespace exprtk std::size_t changes = 0; - for (std::size_t i = 0; i < (g.token_list_.size() - 1); ++i) + for (int i = 0; i < static_cast(g.token_list_.size() - 1); ++i) { token t; @@ -3117,6 +3117,9 @@ namespace exprtk g.token_list_.erase(g.token_list_.begin() + static_cast(i + 1)); ++changes; + + if (static_cast(i + 1) >= g.token_list_.size()) + break; } } @@ -3132,7 +3135,7 @@ namespace exprtk std::size_t changes = 0; - for (std::size_t i = 0; i < (g.token_list_.size() - 2); ++i) + for (int i = 0; i < static_cast(g.token_list_.size() - 2); ++i) { token t; @@ -3143,6 +3146,9 @@ namespace exprtk g.token_list_.erase(g.token_list_.begin() + static_cast(i + 1), g.token_list_.begin() + static_cast(i + 3)); ++changes; + + if (static_cast(i + 2) >= g.token_list_.size()) + break; } } @@ -3788,6 +3794,91 @@ namespace exprtk std::vector > error_list_; }; + class sequence_validator_3tokens : public lexer::token_scanner + { + private: + + typedef lexer::token::token_type token_t; + typedef std::pair > token_triplet_t; + typedef std::set set_t; + + public: + + using lexer::token_scanner::operator(); + + sequence_validator_3tokens() + : lexer::token_scanner(3) + { + add_invalid(lexer::token::e_number , lexer::token::e_number , lexer::token::e_number); + add_invalid(lexer::token::e_string , lexer::token::e_string , lexer::token::e_string); + add_invalid(lexer::token::e_comma , lexer::token::e_comma , lexer::token::e_comma ); + + add_invalid(lexer::token::e_add ,lexer::token::e_add , lexer::token::e_add); + add_invalid(lexer::token::e_sub ,lexer::token::e_sub , lexer::token::e_sub); + add_invalid(lexer::token::e_div ,lexer::token::e_div , lexer::token::e_div); + add_invalid(lexer::token::e_mul ,lexer::token::e_mul , lexer::token::e_mul); + add_invalid(lexer::token::e_mod ,lexer::token::e_mod , lexer::token::e_mod); + add_invalid(lexer::token::e_pow ,lexer::token::e_pow , lexer::token::e_pow); + + add_invalid(lexer::token::e_add ,lexer::token::e_sub , lexer::token::e_add); + add_invalid(lexer::token::e_sub ,lexer::token::e_add , lexer::token::e_sub); + add_invalid(lexer::token::e_div ,lexer::token::e_mul , lexer::token::e_div); + add_invalid(lexer::token::e_mul ,lexer::token::e_div , lexer::token::e_mul); + add_invalid(lexer::token::e_mod ,lexer::token::e_pow , lexer::token::e_mod); + add_invalid(lexer::token::e_pow ,lexer::token::e_mod , lexer::token::e_pow); + } + + bool result() + { + return error_list_.empty(); + } + + bool operator() (const lexer::token& t0, const lexer::token& t1, const lexer::token& t2) + { + const set_t::value_type p = std::make_pair(t0.type,std::make_pair(t1.type,t2.type)); + + if (invalid_comb_.find(p) != invalid_comb_.end()) + { + error_list_.push_back(std::make_pair(t0,t1)); + } + + return true; + } + + std::size_t error_count() const + { + return error_list_.size(); + } + + std::pair error(const std::size_t index) + { + if (index < error_list_.size()) + { + return error_list_[index]; + } + else + { + static const lexer::token error_token; + return std::make_pair(error_token,error_token); + } + } + + void clear_errors() + { + error_list_.clear(); + } + + private: + + void add_invalid(token_t t0, token_t t1, token_t t2) + { + invalid_comb_.insert(std::make_pair(t0,std::make_pair(t1,t2))); + } + + set_t invalid_comb_; + std::vector > error_list_; + }; + struct helper_assembly { inline bool register_scanner(lexer::token_scanner* scanner) @@ -5152,7 +5243,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline bool all_nodes_valid(const Sequence*,Allocator>& b) { for (std::size_t i = 0; i < b.size(); ++i) @@ -5179,7 +5270,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline bool all_nodes_variables(Sequence*,Allocator>& b) { for (std::size_t i = 0; i < b.size(); ++i) @@ -5205,7 +5296,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline void free_all_nodes(NodeAllocator& node_allocator, Sequence*,Allocator>& b) { for (std::size_t i = 0; i < b.size(); ++i) @@ -5315,7 +5406,7 @@ namespace exprtk }; template class Sequence> + template class Sequence> class sequence_vector_impl : public vector_holder_base { public: @@ -5763,7 +5854,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline void execute(Sequence*,bool>,Allocator>& branch) { for (std::size_t i = 0; i < branch.size(); ++i) @@ -6591,7 +6682,7 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> + template class Sequence> switch_node(const Sequence& arg_list) { if (1 != (arg_list.size() & 1)) @@ -6669,7 +6760,7 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> + template class Sequence> switch_n_node(const Sequence& arg_list) : switch_node(arg_list) {} @@ -6688,7 +6779,7 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> + template class Sequence> multi_switch_node(const Sequence& arg_list) { if (0 != (arg_list.size() & 1)) @@ -8862,7 +8953,7 @@ namespace exprtk typedef irange_t* irange_ptr; template class Sequence> + template class Sequence> str_vararg_node(const Sequence& arg_list) : final_node_(arg_list.back()), final_deletable_(branch_deletable(final_node_)), @@ -9328,7 +9419,7 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> + template class Sequence> vararg_node(const Sequence& arg_list) { arg_list_ .resize(arg_list.size()); @@ -9388,7 +9479,7 @@ namespace exprtk typedef expression_node* expression_ptr; template class Sequence> + template class Sequence> vararg_varnode(const Sequence& arg_list) { arg_list_.resize(arg_list.size()); @@ -12232,7 +12323,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12299,7 +12390,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12366,7 +12457,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12422,7 +12513,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12493,7 +12584,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12564,7 +12655,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12644,7 +12735,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -12724,7 +12815,7 @@ namespace exprtk template class Sequence> + template class Sequence> static inline T process(const Sequence& arg_list) { switch (arg_list.size()) @@ -13739,7 +13830,7 @@ namespace exprtk bfunc_t p2) { return allocator - .template allocate_type + .template allocate_type (p0, p1, p2); } @@ -13827,7 +13918,7 @@ namespace exprtk static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, bfunc_t p3, bfunc_t p4) { return allocator - .template allocate_type + .template allocate_type (p0, p1, p2, p3, p4); } @@ -13924,7 +14015,7 @@ namespace exprtk bfunc_t p4, bfunc_t p5, bfunc_t p6) { return allocator - .template allocate_type + .template allocate_type (p0, p1, p2, p3, p4, p5, p6); } @@ -14009,7 +14100,7 @@ namespace exprtk static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, tfunc_t p3) { return allocator - .template allocate_type + .template allocate_type (p0, p1, p2, p3); } @@ -14100,7 +14191,7 @@ namespace exprtk static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2) { return allocator - .template allocate_type + .template allocate_type (p0, p1, p2); } @@ -14201,7 +14292,7 @@ namespace exprtk static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3, qfunc_t p4) { return allocator - .template allocate_type + .template allocate_type (p0, p1, p2, p3, p4); } @@ -14284,7 +14375,7 @@ namespace exprtk static inline expression_node* allocate(Allocator& allocator, T0 p0, T1 p1, T2 p2, T3 p3) { return allocator - .template allocate_type + .template allocate_type (p0, p1, p2, p3); } @@ -15410,37 +15501,37 @@ namespace exprtk template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[1]) { - return allocate(operation,branch[0]); + return allocate(operation, branch[0]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[2]) { - return allocate(operation,branch[0],branch[1]); + return allocate(operation, branch[0], branch[1]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[3]) { - return allocate(operation,branch[0],branch[1],branch[2]); + return allocate(operation, branch[0], branch[1], branch[2]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[4]) { - return allocate(operation,branch[0],branch[1],branch[2],branch[3]); + return allocate(operation, branch[0], branch[1], branch[2], branch[3]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[5]) { - return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4]); + return allocate(operation, branch[0],branch[1], branch[2], branch[3], branch[4]); } template inline expression_node* allocate(OpType& operation, ExprNode (&branch)[6]) { - return allocate(operation,branch[0],branch[1],branch[2],branch[3],branch[4],branch[5]); + return allocate(operation, branch[0], branch[1], branch[2], branch[3], branch[4], branch[5]); } template @@ -15452,7 +15543,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline expression_node* allocate(const Sequence& seq) const { return (new node_type(seq)); @@ -16003,20 +16094,20 @@ namespace exprtk typedef T (*ff00_functor)(); typedef T (*ff01_functor)(T); - typedef T (*ff02_functor)(T,T); - typedef T (*ff03_functor)(T,T,T); - typedef T (*ff04_functor)(T,T,T,T); - typedef T (*ff05_functor)(T,T,T,T,T); - typedef T (*ff06_functor)(T,T,T,T,T,T); - typedef T (*ff07_functor)(T,T,T,T,T,T,T); - typedef T (*ff08_functor)(T,T,T,T,T,T,T,T); - typedef T (*ff09_functor)(T,T,T,T,T,T,T,T,T); - typedef T (*ff10_functor)(T,T,T,T,T,T,T,T,T,T); - typedef T (*ff11_functor)(T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff12_functor)(T,T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff13_functor)(T,T,T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff14_functor)(T,T,T,T,T,T,T,T,T,T,T,T,T,T); - typedef T (*ff15_functor)(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T); + typedef T (*ff02_functor)(T, T); + typedef T (*ff03_functor)(T, T, T); + typedef T (*ff04_functor)(T, T, T, T); + typedef T (*ff05_functor)(T, T, T, T, T); + typedef T (*ff06_functor)(T, T, T, T, T, T); + typedef T (*ff07_functor)(T, T, T, T, T, T, T); + typedef T (*ff08_functor)(T, T, T, T, T, T, T, T); + typedef T (*ff09_functor)(T, T, T, T, T, T, T, T, T); + typedef T (*ff10_functor)(T, T, T, T, T, T, T, T, T, T); + typedef T (*ff11_functor)(T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff12_functor)(T, T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff13_functor)(T, T, T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff14_functor)(T, T, T, T, T, T, T, T, T, T, T, T, T, T); + typedef T (*ff15_functor)(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T); protected: @@ -16732,7 +16823,7 @@ namespace exprtk return (*this); } - inline bool operator==(const symbol_table& st) + inline bool operator==(const symbol_table& st) const { return (this == &st) || (control_block_ == st.control_block_); } @@ -17729,7 +17820,7 @@ namespace exprtk return *this; } - inline bool operator==(const expression& e) + inline bool operator==(const expression& e) const { return (this == &e); } @@ -18516,7 +18607,7 @@ namespace exprtk { parser_.state_.scope_depth++; #ifdef exprtk_enable_debugging - std::string depth(2 * parser_.state_.scope_depth,'-'); + const std::string depth(2 * parser_.state_.scope_depth,'-'); exprtk_debug(("%s> Scope Depth: %02d\n", depth.c_str(), static_cast(parser_.state_.scope_depth))); @@ -18528,7 +18619,7 @@ namespace exprtk parser_.sem_.deactivate(parser_.state_.scope_depth); parser_.state_.scope_depth--; #ifdef exprtk_enable_debugging - std::string depth(2 * parser_.state_.scope_depth,'-'); + const std::string depth(2 * parser_.state_.scope_depth,'-'); exprtk_debug(("<%s Scope Depth: %02d\n", depth.c_str(), static_cast(parser_.state_.scope_depth))); @@ -19000,8 +19091,9 @@ namespace exprtk enum usr_symbol_type { - e_usr_variable_type = 0, - e_usr_constant_type = 1 + e_usr_unknown_type = 0, + e_usr_variable_type = 1, + e_usr_constant_type = 2 }; enum usr_mode @@ -19080,7 +19172,7 @@ namespace exprtk {} template class Sequence> + template class Sequence> inline std::size_t symbols(Sequence& symbols_list) { if (!collect_variables_ && !collect_functions_) @@ -19103,7 +19195,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline std::size_t assignment_symbols(Sequence& assignment_list) { if (!collect_assignments_) @@ -19908,7 +20000,8 @@ namespace exprtk if (settings_.sequence_check_enabled()) { - helper_assembly_.register_scanner(&sequence_validator_); + helper_assembly_.register_scanner(&sequence_validator_ ); + helper_assembly_.register_scanner(&sequence_validator_3tkns_); } } } @@ -20084,9 +20177,10 @@ namespace exprtk { if (helper_assembly_.error_token_scanner) { - lexer::helper::bracket_checker* bracket_checker_ptr = 0; - lexer::helper::numeric_checker* numeric_checker_ptr = 0; - lexer::helper::sequence_validator* sequence_validator_ptr = 0; + lexer::helper::bracket_checker* bracket_checker_ptr = 0; + lexer::helper::numeric_checker* numeric_checker_ptr = 0; + lexer::helper::sequence_validator* sequence_validator_ptr = 0; + lexer::helper::sequence_validator_3tokens* sequence_validator3_ptr = 0; if (0 != (bracket_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) { @@ -20134,6 +20228,26 @@ namespace exprtk sequence_validator_ptr->clear_errors(); } } + else if (0 != (sequence_validator3_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) + { + for (std::size_t i = 0; i < sequence_validator3_ptr->error_count(); ++i) + { + std::pair error_token = sequence_validator3_ptr->error(i); + + set_error( + make_error(parser_error::e_token, + error_token.first, + "ERR007 - Invalid token sequence: '" + + error_token.first.value + "' and '" + + error_token.second.value + "'", + exprtk_error_location)); + } + + if (sequence_validator3_ptr->error_count()) + { + sequence_validator3_ptr->clear_errors(); + } + } } return false; @@ -20278,9 +20392,9 @@ namespace exprtk #ifdef exprtk_enable_debugging inline void next_token() { - std::string ct_str = current_token().value; + const std::string ct_str = current_token().value; parser_helper::next_token(); - std::string depth(2 * state_.scope_depth,' '); + const std::string depth(2 * state_.scope_depth,' '); exprtk_debug(("%s" "prev[%s] --> curr[%s]\n", depth.c_str(), @@ -20316,7 +20430,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR007 - Invalid expression encountered", + "ERR008 - Invalid expression encountered", exprtk_error_location)); } @@ -20330,7 +20444,7 @@ namespace exprtk end_token = current_token(); - std::string sub_expr = construct_subexpr(begin_token,end_token); + const std::string sub_expr = construct_subexpr(begin_token, end_token); exprtk_debug(("parse_corpus(%02d) Subexpr: %s\n", static_cast(arg_list.size() - 1), @@ -20539,7 +20653,7 @@ namespace exprtk else if (current_state.left < precedence) break; - lexer::token prev_token = current_token(); + const lexer::token prev_token = current_token(); next_token(); @@ -20553,7 +20667,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR008 - Invalid arithmetic operation '" + details::to_str(current_state.operation) + "'", + "ERR009 - Invalid arithmetic operation '" + details::to_str(current_state.operation) + "'", exprtk_error_location)); return error_node(); @@ -20565,7 +20679,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR009 - Invalid inequality operation '" + details::to_str(current_state.operation) + "'", + "ERR010 - Invalid inequality operation '" + details::to_str(current_state.operation) + "'", exprtk_error_location)); return error_node(); @@ -20577,7 +20691,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR010 - Invalid assignment operation '" + details::to_str(current_state.operation) + "'", + "ERR011 - Invalid assignment operation '" + details::to_str(current_state.operation) + "'", exprtk_error_location)); return error_node(); @@ -20596,7 +20710,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR011 - Return statements cannot be part of sub-expressions", + "ERR012 - Return statements cannot be part of sub-expressions", exprtk_error_location)); return error_node(); @@ -20619,7 +20733,7 @@ namespace exprtk prev_token, !synthesis_error_.empty() ? synthesis_error_ : - "ERR012 - General parsing error at token: '" + prev_token.value + "'", + "ERR013 - General parsing error at token: '" + prev_token.value + "'", exprtk_error_location)); } @@ -20689,7 +20803,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR013 - Failed to find variable node in symbol table", + "ERR014 - Failed to find variable node in symbol table", exprtk_error_location)); free_node(node_allocator_,node); @@ -20869,7 +20983,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR014 - Invalid number of parameters for function: '" + function_name + "'", + "ERR015 - Invalid number of parameters for function: '" + function_name + "'", exprtk_error_location)); return error_node(); @@ -20883,7 +20997,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR015 - Failed to generate call to function: '" + function_name + "'", + "ERR016 - Failed to generate call to function: '" + function_name + "'", exprtk_error_location)); return error_node(); @@ -20902,7 +21016,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR016 - Expecting ifunction '" + function_name + "' to have non-zero parameter count", + "ERR017 - Expecting ifunction '" + function_name + "' to have non-zero parameter count", exprtk_error_location)); return error_node(); @@ -20925,7 +21039,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR017 - Expecting argument list for function: '" + function_name + "'", + "ERR018 - Expecting argument list for function: '" + function_name + "'", exprtk_error_location)); return error_node(); @@ -20940,7 +21054,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR018 - Failed to parse argument " + details::to_str(i) + " for function: '" + function_name + "'", + "ERR019 - Failed to parse argument " + details::to_str(i) + " for function: '" + function_name + "'", exprtk_error_location)); return error_node(); @@ -20952,7 +21066,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR019 - Invalid number of arguments for function: '" + function_name + "'", + "ERR020 - Invalid number of arguments for function: '" + function_name + "'", exprtk_error_location)); return error_node(); @@ -20965,7 +21079,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR020 - Invalid number of arguments for function: '" + function_name + "'", + "ERR021 - Invalid number of arguments for function: '" + function_name + "'", exprtk_error_location)); return error_node(); @@ -20994,7 +21108,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR021 - Expecting '()' to proceed call to function: '" + function_name + "'", + "ERR022 - Expecting '()' to proceed call to function: '" + function_name + "'", exprtk_error_location)); free_node(node_allocator_,result); @@ -21019,7 +21133,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR022 - Expected a '(' at start of function call to '" + function_name + + "ERR023 - Expected a '(' at start of function call to '" + function_name + "', instead got: '" + current_token().value + "'", exprtk_error_location)); @@ -21031,7 +21145,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR023 - Expected at least one input parameter for function call '" + function_name + "'", + "ERR024 - Expected at least one input parameter for function call '" + function_name + "'", exprtk_error_location)); return 0; @@ -21057,7 +21171,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR024 - Expected a ',' between function input parameters, instead got: '" + current_token().value + "'", + "ERR025 - Expected a ',' between function input parameters, instead got: '" + current_token().value + "'", exprtk_error_location)); return 0; @@ -21069,7 +21183,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR025 - Invalid number of input parameters passed to function '" + function_name + "'", + "ERR026 - Invalid number of input parameters passed to function '" + function_name + "'", exprtk_error_location)); return 0; @@ -21092,7 +21206,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, diagnostic_token, - "ERR026 - No entry found for base operation: " + operation_name, + "ERR027 - No entry found for base operation: " + operation_name, exprtk_error_location)); return error_node(); @@ -21139,7 +21253,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, diagnostic_token, - "ERR027 - Invalid number of input parameters for call to function: '" + operation_name + "'", + "ERR028 - Invalid number of input parameters for call to function: '" + operation_name + "'", exprtk_error_location)); return error_node(); @@ -21159,7 +21273,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR028 - Expected ',' between if-statement condition and consequent", + "ERR029 - Expected ',' between if-statement condition and consequent", exprtk_error_location)); result = false; } @@ -21168,7 +21282,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR029 - Failed to parse consequent for if-statement", + "ERR030 - Failed to parse consequent for if-statement", exprtk_error_location)); result = false; } @@ -21177,7 +21291,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR030 - Expected ',' between if-statement consequent and alternative", + "ERR031 - Expected ',' between if-statement consequent and alternative", exprtk_error_location)); result = false; } @@ -21186,7 +21300,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR031 - Failed to parse alternative for if-statement", + "ERR032 - Failed to parse alternative for if-statement", exprtk_error_location)); result = false; } @@ -21195,7 +21309,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR032 - Expected ')' at the end of if-statement", + "ERR033 - Expected ')' at the end of if-statement", exprtk_error_location)); result = false; } @@ -21217,7 +21331,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR033 - Return types of ternary if-statement differ", + "ERR034 - Return types of ternary if-statement differ", exprtk_error_location)); result = false; @@ -21252,7 +21366,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR034 - Failed to parse body of consequent for if-statement", + "ERR035 - Failed to parse body of consequent for if-statement", exprtk_error_location)); result = false; @@ -21275,7 +21389,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR035 - Expected ';' at the end of the consequent for if-statement", + "ERR036 - Expected ';' at the end of the consequent for if-statement", exprtk_error_location)); result = false; @@ -21286,7 +21400,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR036 - Failed to parse body of consequent for if-statement", + "ERR037 - Failed to parse body of consequent for if-statement", exprtk_error_location)); result = false; @@ -21306,7 +21420,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR037 - Failed to parse body of the 'else' for if-statement", + "ERR038 - Failed to parse body of the 'else' for if-statement", exprtk_error_location)); result = false; @@ -21319,7 +21433,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR038 - Failed to parse body of if-else statement", + "ERR039 - Failed to parse body of if-else statement", exprtk_error_location)); result = false; @@ -21332,7 +21446,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR039 - Expected ';' at the end of the 'else-if' for the if-statement", + "ERR040 - Expected ';' at the end of the 'else-if' for the if-statement", exprtk_error_location)); result = false; @@ -21343,7 +21457,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR040 - Failed to parse body of the 'else' for if-statement", + "ERR041 - Failed to parse body of the 'else' for if-statement", exprtk_error_location)); result = false; @@ -21368,7 +21482,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR041 - Return types of ternary if-statement differ", + "ERR042 - Return types of ternary if-statement differ", exprtk_error_location)); result = false; @@ -21400,7 +21514,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR042 - Expected '(' at start of if-statement, instead got: '" + current_token().value + "'", + "ERR043 - Expected '(' at start of if-statement, instead got: '" + current_token().value + "'", exprtk_error_location)); return error_node(); @@ -21410,7 +21524,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR043 - Failed to parse condition for if-statement", + "ERR044 - Failed to parse condition for if-statement", exprtk_error_location)); return error_node(); @@ -21442,7 +21556,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR044 - Invalid if-statement", + "ERR045 - Invalid if-statement", exprtk_error_location)); free_node(node_allocator_,condition); @@ -21463,7 +21577,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR045 - Encountered invalid condition branch for ternary if-statement", + "ERR046 - Encountered invalid condition branch for ternary if-statement", exprtk_error_location)); return error_node(); @@ -21473,7 +21587,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR046 - Expected '?' after condition of ternary if-statement", + "ERR047 - Expected '?' after condition of ternary if-statement", exprtk_error_location)); result = false; @@ -21483,7 +21597,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR047 - Failed to parse consequent for ternary if-statement", + "ERR048 - Failed to parse consequent for ternary if-statement", exprtk_error_location)); result = false; @@ -21493,7 +21607,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR048 - Expected ':' between ternary if-statement consequent and alternative", + "ERR049 - Expected ':' between ternary if-statement consequent and alternative", exprtk_error_location)); result = false; @@ -21503,7 +21617,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR049 - Failed to parse alternative for ternary if-statement", + "ERR050 - Failed to parse alternative for ternary if-statement", exprtk_error_location)); result = false; @@ -21526,7 +21640,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR050 - Return types of ternary if-statement differ", + "ERR051 - Return types of ternary if-statement differ", exprtk_error_location)); result = false; @@ -21563,7 +21677,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR051 - Expected '(' at start of while-loop condition statement", + "ERR052 - Expected '(' at start of while-loop condition statement", exprtk_error_location)); return error_node(); @@ -21573,7 +21687,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR052 - Failed to parse condition for while-loop", + "ERR053 - Failed to parse condition for while-loop", exprtk_error_location)); return error_node(); @@ -21583,7 +21697,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR053 - Expected ')' at end of while-loop condition statement", + "ERR054 - Expected ')' at end of while-loop condition statement", exprtk_error_location)); result = false; @@ -21598,7 +21712,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR054 - Failed to parse body of while-loop")); + "ERR055 - Failed to parse body of while-loop")); result = false; } else if (0 == (result_node = expression_generator_.while_loop(condition, @@ -21608,7 +21722,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR055 - Failed to synthesize while-loop", + "ERR056 - Failed to synthesize while-loop", exprtk_error_location)); result = false; @@ -21684,7 +21798,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR056 - Expected '" + token_t::to_str(seperator) + "' in body of repeat until loop", + "ERR057 - Expected '" + token_t::to_str(seperator) + "' in body of repeat until loop", exprtk_error_location)); return error_node(); @@ -21708,7 +21822,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR057 - Failed to parse body of repeat until loop", + "ERR058 - Failed to parse body of repeat until loop", exprtk_error_location)); return error_node(); @@ -21722,7 +21836,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR058 - Expected '(' before condition statement of repeat until loop", + "ERR059 - Expected '(' before condition statement of repeat until loop", exprtk_error_location)); free_node(node_allocator_,branch); @@ -21736,7 +21850,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR059 - Failed to parse condition for repeat until loop", + "ERR060 - Failed to parse condition for repeat until loop", exprtk_error_location)); free_node(node_allocator_,branch); @@ -21748,7 +21862,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR060 - Expected ')' after condition of repeat until loop", + "ERR061 - Expected ')' after condition of repeat until loop", exprtk_error_location)); free_node(node_allocator_, branch); @@ -21769,7 +21883,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR061 - Failed to synthesize repeat until loop", + "ERR062 - Failed to synthesize repeat until loop", exprtk_error_location)); free_node(node_allocator_,condition); @@ -21805,7 +21919,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR062 - Expected '(' at start of for-loop", + "ERR063 - Expected '(' at start of for-loop", exprtk_error_location)); return error_node(); @@ -21825,7 +21939,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR063 - Expected a variable at the start of initialiser section of for-loop", + "ERR064 - Expected a variable at the start of initialiser section of for-loop", exprtk_error_location)); return error_node(); @@ -21835,7 +21949,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR064 - Expected variable assignment of initialiser section of for-loop", + "ERR065 - Expected variable assignment of initialiser section of for-loop", exprtk_error_location)); return error_node(); @@ -21850,7 +21964,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR065 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration", + "ERR066 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration", exprtk_error_location)); return error_node(); @@ -21882,7 +21996,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR066 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM", + "ERR067 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM", exprtk_error_location)); sem_.free_element(nse); @@ -21904,7 +22018,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR067 - Failed to parse initialiser of for-loop", + "ERR068 - Failed to parse initialiser of for-loop", exprtk_error_location)); result = false; @@ -21914,7 +22028,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR068 - Expected ';' after initialiser of for-loop", + "ERR069 - Expected ';' after initialiser of for-loop", exprtk_error_location)); result = false; @@ -21928,7 +22042,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR069 - Failed to parse condition of for-loop", + "ERR070 - Failed to parse condition of for-loop", exprtk_error_location)); result = false; @@ -21938,7 +22052,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR070 - Expected ';' after condition section of for-loop", + "ERR071 - Expected ';' after condition section of for-loop", exprtk_error_location)); result = false; @@ -21952,7 +22066,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR071 - Failed to parse incrementor of for-loop", + "ERR072 - Failed to parse incrementor of for-loop", exprtk_error_location)); result = false; @@ -21962,7 +22076,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR072 - Expected ')' after incrementor section of for-loop", + "ERR073 - Expected ')' after incrementor section of for-loop", exprtk_error_location)); result = false; @@ -21978,7 +22092,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR073 - Failed to parse body of for-loop", + "ERR074 - Failed to parse body of for-loop", exprtk_error_location)); result = false; @@ -22030,7 +22144,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR074 - Expected keyword 'switch'", + "ERR075 - Expected keyword 'switch'", exprtk_error_location)); return error_node(); @@ -22045,7 +22159,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR075 - Expected '{' for call to switch statement", + "ERR076 - Expected '{' for call to switch statement", exprtk_error_location)); return error_node(); @@ -22058,7 +22172,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR076 - Expected either a 'case' or 'default' statement", + "ERR077 - Expected either a 'case' or 'default' statement", exprtk_error_location)); return error_node(); @@ -22075,7 +22189,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR077 - Expected ':' for case of switch statement", + "ERR078 - Expected ':' for case of switch statement", exprtk_error_location)); return error_node(); @@ -22090,7 +22204,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR078 - Expected ';' at end of case for switch statement", + "ERR079 - Expected ';' at end of case for switch statement", exprtk_error_location)); return error_node(); @@ -22116,7 +22230,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR079 - Expected ':' for default of switch statement", + "ERR080 - Expected ':' for default of switch statement", exprtk_error_location)); return error_node(); @@ -22138,7 +22252,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR080 - Expected ';' at end of default for switch statement", + "ERR081 - Expected ';' at end of default for switch statement", exprtk_error_location)); return error_node(); @@ -22154,7 +22268,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR081 - Expected '}' at end of switch statement", + "ERR082 - Expected '}' at end of switch statement", exprtk_error_location)); return error_node(); @@ -22177,7 +22291,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR082 - Expected token '[*]'", + "ERR083 - Expected token '[*]'", exprtk_error_location)); return error_node(); @@ -22192,7 +22306,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR083 - Expected '{' for call to [*] statement", + "ERR084 - Expected '{' for call to [*] statement", exprtk_error_location)); return error_node(); @@ -22205,7 +22319,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR084 - Expected a 'case' statement for multi-switch", + "ERR085 - Expected a 'case' statement for multi-switch", exprtk_error_location)); return error_node(); @@ -22223,7 +22337,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR085 - Expected ':' for case of [*] statement", + "ERR086 - Expected ':' for case of [*] statement", exprtk_error_location)); return error_node(); @@ -22239,7 +22353,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR086 - Expected ';' at end of case for [*] statement", + "ERR087 - Expected ';' at end of case for [*] statement", exprtk_error_location)); return error_node(); @@ -22268,7 +22382,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR087 - Expected '}' at end of [*] statement", + "ERR088 - Expected '}' at end of [*] statement", exprtk_error_location)); return error_node(); @@ -22310,7 +22424,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR088 - Unsupported vararg function: " + symbol, + "ERR089 - Unsupported vararg function: " + symbol, exprtk_error_location)); return error_node(); @@ -22327,7 +22441,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR089 - Expected '(' for call to vararg function: " + symbol, + "ERR090 - Expected '(' for call to vararg function: " + symbol, exprtk_error_location)); return error_node(); @@ -22349,7 +22463,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR090 - Expected ',' for call to vararg function: " + symbol, + "ERR091 - Expected ',' for call to vararg function: " + symbol, exprtk_error_location)); return error_node(); @@ -22370,7 +22484,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR091 - Expected '[' as start of string range definition", + "ERR092 - Expected '[' as start of string range definition", exprtk_error_location)); free_node(node_allocator_,expression); @@ -22398,7 +22512,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR092 - Failed to generate string range node", + "ERR093 - Failed to generate string range node", exprtk_error_location)); free_node(node_allocator_,expression); @@ -22437,7 +22551,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline expression_node_ptr simplify(Sequence& expression_list, Sequence& side_effect_list, const bool specialise_on_final_type = false) @@ -22534,7 +22648,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR093 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + + "ERR094 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + ((!source.empty()) ? std::string(" section of " + source): ""), exprtk_error_location)); @@ -22581,7 +22695,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR094 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source, + "ERR095 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source, exprtk_error_location)); return error_node(); @@ -22615,7 +22729,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR095 - Expected '[' for start of range", + "ERR096 - Expected '[' for start of range", exprtk_error_location)); return false; @@ -22636,7 +22750,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR096 - Failed parse begin section of range", + "ERR097 - Failed parse begin section of range", exprtk_error_location)); return false; @@ -22659,7 +22773,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR097 - Range lower bound less than zero! Constraint: r0 >= 0", + "ERR098 - Range lower bound less than zero! Constraint: r0 >= 0", exprtk_error_location)); return false; @@ -22676,7 +22790,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR098 - Expected ':' for break in range", + "ERR099 - Expected ':' for break in range", exprtk_error_location)); rp.free(); @@ -22699,7 +22813,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR099 - Failed parse end section of range", + "ERR100 - Failed parse end section of range", exprtk_error_location)); rp.free(); @@ -22724,7 +22838,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR100 - Range upper bound less than zero! Constraint: r1 >= 0", + "ERR101 - Range upper bound less than zero! Constraint: r1 >= 0", exprtk_error_location)); return false; @@ -22741,7 +22855,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR101 - Expected ']' for start of range", + "ERR102 - Expected ']' for start of range", exprtk_error_location)); rp.free(); @@ -22762,7 +22876,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR102 - Invalid range, Constraint: r0 <= r1", + "ERR103 - Invalid range, Constraint: r0 <= r1", exprtk_error_location)); return false; @@ -22803,7 +22917,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR103 - Unknown string symbol", + "ERR104 - Unknown string symbol", exprtk_error_location)); return error_node(); @@ -22917,7 +23031,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR104 - Overflow in range for string: '" + const_str + "'[" + + "ERR105 - Overflow in range for string: '" + const_str + "'[" + (rp.n0_c.first ? details::to_str(static_cast(rp.n0_c.second)) : "?") + ":" + (rp.n1_c.first ? details::to_str(static_cast(rp.n1_c.second)) : "?") + "]", exprtk_error_location)); @@ -22961,7 +23075,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR105 - Symbol '" + symbol+ " not a vector", + "ERR106 - Symbol '" + symbol+ " not a vector", exprtk_error_location)); return error_node(); @@ -22987,7 +23101,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR106 - Failed to parse index for vector: '" + symbol + "'", + "ERR107 - Failed to parse index for vector: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -22997,7 +23111,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR107 - Expected ']' for index of vector: '" + symbol + "'", + "ERR108 - Expected ']' for index of vector: '" + symbol + "'", exprtk_error_location)); free_node(node_allocator_,index_expr); @@ -23016,7 +23130,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR108 - Index of " + details::to_str(index) + " out of range for " + "ERR109 - Index of " + details::to_str(index) + " out of range for " "vector '" + symbol + "' of size " + details::to_str(vec_size), exprtk_error_location)); @@ -23048,7 +23162,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR109 - Zero parameter call to vararg function: " + "ERR110 - Zero parameter call to vararg function: " + vararg_function_name + " not allowed", exprtk_error_location)); @@ -23073,7 +23187,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR110 - Expected ',' for call to vararg function: " + "ERR111 - Expected ',' for call to vararg function: " + vararg_function_name, exprtk_error_location)); @@ -23087,7 +23201,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR111 - Zero parameter call to vararg function: " + "ERR112 - Zero parameter call to vararg function: " + vararg_function_name + " not allowed", exprtk_error_location)); @@ -23099,7 +23213,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR112 - Invalid number of parameters to call to vararg function: " + "ERR113 - Invalid number of parameters to call to vararg function: " + vararg_function_name + ", require at least " + details::to_str(static_cast(vararg_function->min_num_args())) + " parameters", exprtk_error_location)); @@ -23111,7 +23225,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR113 - Invalid number of parameters to call to vararg function: " + "ERR114 - Invalid number of parameters to call to vararg function: " + vararg_function_name + ", require no more than " + details::to_str(static_cast(vararg_function->max_num_args())) + " parameters", exprtk_error_location)); @@ -23174,7 +23288,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR114 - Failed parameter type check for function '" + function_name_ + "', " + "ERR115 - Failed parameter type check for function '" + function_name_ + "', " "Expected '" + param_seq_list_[0] + "' call set: '" + param_seq +"'", exprtk_error_location)); } @@ -23195,7 +23309,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR115 - Failed parameter type check for function '" + function_name_ + "', " + "ERR116 - Failed parameter type check for function '" + function_name_ + "', " "Best match: '" + param_seq_list_[max_diff_index] + "' call set: '" + param_seq +"'", exprtk_error_location)); } @@ -23280,7 +23394,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR116 - Invalid parameter sequence of '" + err_param_seq + + "ERR117 - Invalid parameter sequence of '" + err_param_seq + "' for function: " + function_name_, exprtk_error_location)); @@ -23302,7 +23416,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR117 - Invalid parameter sequence of '" + err_param_seq + + "ERR118 - Invalid parameter sequence of '" + err_param_seq + "' for function: " + function_name_, exprtk_error_location)); return; @@ -23336,7 +23450,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR118 - Type checker instantiation failure for generic function: " + function_name, + "ERR119 - Type checker instantiation failure for generic function: " + function_name, exprtk_error_location)); return error_node(); @@ -23351,7 +23465,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR119 - Mismatch in zero parameter condition for generic function: " + "ERR120 - Mismatch in zero parameter condition for generic function: " + function_name, exprtk_error_location)); @@ -23370,7 +23484,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR120 - Zero parameter call to generic function: " + "ERR121 - Zero parameter call to generic function: " + function_name + " not allowed", exprtk_error_location)); @@ -23402,7 +23516,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR121 - Expected ',' for call to generic function: " + function_name, + "ERR122 - Expected ',' for call to generic function: " + function_name, exprtk_error_location)); return error_node(); @@ -23419,7 +23533,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR122 - Zero parameter call to generic function: " + "ERR123 - Zero parameter call to generic function: " + function_name + " not allowed", exprtk_error_location)); @@ -23436,7 +23550,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR123 - Expected ',' for call to generic function: " + function_name, + "ERR124 - Expected ',' for call to generic function: " + function_name, exprtk_error_location)); return error_node(); @@ -23504,7 +23618,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR124 - Expected ',' for call to string function: " + function_name, + "ERR125 - Expected ',' for call to string function: " + function_name, exprtk_error_location)); return error_node(); @@ -23520,7 +23634,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR125 - Expected ',' for call to string function: " + function_name, + "ERR126 - Expected ',' for call to string function: " + function_name, exprtk_error_location)); return error_node(); @@ -23560,7 +23674,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR126 - Expected '(' for special function '" + sf_name + "'", + "ERR127 - Expected '(' for special function '" + sf_name + "'", exprtk_error_location)); return error_node(); @@ -23581,7 +23695,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR127 - Expected ',' before next parameter of special function '" + sf_name + "'", + "ERR128 - Expected ',' before next parameter of special function '" + sf_name + "'", exprtk_error_location)); return p.error_node(); @@ -23594,7 +23708,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR128 - Invalid number of parameters for special function '" + sf_name + "'", + "ERR129 - Invalid number of parameters for special function '" + sf_name + "'", exprtk_error_location)); return p.error_node(); @@ -23621,7 +23735,7 @@ namespace exprtk set_error( make_error(parser_error::e_token, current_token(), - "ERR129 - Invalid special function[1]: " + sf_name, + "ERR130 - Invalid special function[1]: " + sf_name, exprtk_error_location)); return error_node(); @@ -23635,7 +23749,7 @@ namespace exprtk set_error( make_error(parser_error::e_token, current_token(), - "ERR130 - Invalid special function[2]: " + sf_name, + "ERR131 - Invalid special function[2]: " + sf_name, exprtk_error_location)); return error_node(); @@ -23667,7 +23781,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR131 - Break call within a break call is not allowed", + "ERR132 - Break call within a break call is not allowed", exprtk_error_location)); return error_node(); @@ -23690,7 +23804,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR132 - Failed to parse return expression for 'break' statement", + "ERR133 - Failed to parse return expression for 'break' statement", exprtk_error_location)); return error_node(); @@ -23700,7 +23814,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR133 - Expected ']' at the completion of break's return expression", + "ERR134 - Expected ']' at the completion of break's return expression", exprtk_error_location)); free_node(node_allocator_,return_expr); @@ -23718,7 +23832,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR134 - Invalid use of 'break', allowed only in the scope of a loop", + "ERR135 - Invalid use of 'break', allowed only in the scope of a loop", exprtk_error_location)); } @@ -23741,7 +23855,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR135 - Invalid use of 'continue', allowed only in the scope of a loop", + "ERR136 - Invalid use of 'continue', allowed only in the scope of a loop", exprtk_error_location)); return error_node(); @@ -23758,7 +23872,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", exprtk_error_location)); return error_node(); @@ -23768,7 +23882,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR137 - Failed to determine size of vector '" + vec_name + "'", + "ERR138 - Failed to determine size of vector '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -23780,7 +23894,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR138 - Expected a literal number as size of vector '" + vec_name + "'", + "ERR139 - Expected a literal number as size of vector '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -23799,7 +23913,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR139 - Invalid vector size. Must be an integer greater than zero, size: " + + "ERR140 - Invalid vector size. Must be an integer greater than zero, size: " + details::to_str(details::numeric::to_int32(vector_size)), exprtk_error_location)); @@ -23819,7 +23933,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR140 - Expected ']' as part of vector size definition", + "ERR141 - Expected ']' as part of vector size definition", exprtk_error_location)); return error_node(); @@ -23831,7 +23945,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR141 - Expected ':=' as part of vector definition", + "ERR142 - Expected ':=' as part of vector definition", exprtk_error_location)); return error_node(); @@ -23845,7 +23959,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR142 - Failed to parse single vector initialiser", + "ERR143 - Failed to parse single vector initialiser", exprtk_error_location)); return error_node(); @@ -23858,7 +23972,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR143 - Expected ']' to close single value vector initialiser", + "ERR144 - Expected ']' to close single value vector initialiser", exprtk_error_location)); return error_node(); @@ -23905,7 +24019,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR144 - Expected '{' as part of vector initialiser list", + "ERR145 - Expected '{' as part of vector initialiser list", exprtk_error_location)); return error_node(); @@ -23925,7 +24039,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR145 - Expected '{' as part of vector initialiser list", + "ERR146 - Expected '{' as part of vector initialiser list", exprtk_error_location)); return error_node(); @@ -23943,7 +24057,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR146 - Expected ',' between vector initialisers", + "ERR147 - Expected ',' between vector initialisers", exprtk_error_location)); return error_node(); @@ -23955,9 +24069,9 @@ namespace exprtk } if ( - !token_is(token_t::e_rbracket ,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rcrlbracket,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rsqrbracket,prsrhlpr_t::e_hold) + !token_is(token_t::e_rbracket , prsrhlpr_t::e_hold) && + !token_is(token_t::e_rcrlbracket, prsrhlpr_t::e_hold) && + !token_is(token_t::e_rsqrbracket, prsrhlpr_t::e_hold) ) { if (!token_is(token_t::e_eof)) @@ -23965,7 +24079,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR147 - Expected ';' at end of vector definition", + "ERR148 - Expected ';' at end of vector definition", exprtk_error_location)); return error_node(); @@ -23977,7 +24091,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR148 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'", + "ERR149 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -23997,7 +24111,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR149 - Illegal redefinition of local vector: '" + vec_name + "'", + "ERR150 - Illegal redefinition of local vector: '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -24031,7 +24145,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR150 - Failed to add new local vector '" + vec_name + "' to SEM", + "ERR151 - Failed to add new local vector '" + vec_name + "' to SEM", exprtk_error_location)); sem_.free_element(nse); @@ -24055,10 +24169,14 @@ namespace exprtk if (null_initialisation) result = expression_generator_(T(0.0)); else if (vec_to_vec_initialiser) + { + expression_node_ptr vec_node = node_allocator_.allocate(vec_holder); + result = expression_generator_( details::e_assign, - node_allocator_.allocate(vec_holder), + vec_node, vec_initilizer_list[0]); + } else result = node_allocator_ .allocate >( @@ -24086,7 +24204,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR151 - Illegal redefinition of local variable: '" + str_name + "'", + "ERR152 - Illegal redefinition of local variable: '" + str_name + "'", exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -24118,7 +24236,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR152 - Failed to add new local string variable '" + str_name + "' to SEM", + "ERR153 - Failed to add new local string variable '" + str_name + "' to SEM", exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -24164,7 +24282,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR153 - Illegal variable definition", + "ERR154 - Illegal variable definition", exprtk_error_location)); return error_node(); @@ -24185,7 +24303,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR154 - Expected a symbol for variable definition", + "ERR155 - Expected a symbol for variable definition", exprtk_error_location)); return error_node(); @@ -24195,7 +24313,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR155 - Illegal redefinition of reserved keyword: '" + var_name + "'", + "ERR156 - Illegal redefinition of reserved keyword: '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -24205,7 +24323,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR156 - Illegal redefinition of variable '" + var_name + "'", + "ERR157 - Illegal redefinition of variable '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -24215,7 +24333,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR157 - Illegal redefinition of local variable: '" + var_name + "'", + "ERR158 - Illegal redefinition of local variable: '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -24235,7 +24353,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR158 - Failed to parse initialisation expression", + "ERR159 - Failed to parse initialisation expression", exprtk_error_location)); return error_node(); @@ -24243,9 +24361,9 @@ namespace exprtk } if ( - !token_is(token_t::e_rbracket ,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rcrlbracket,prsrhlpr_t::e_hold) && - !token_is(token_t::e_rsqrbracket,prsrhlpr_t::e_hold) + !token_is(token_t::e_rbracket , prsrhlpr_t::e_hold) && + !token_is(token_t::e_rcrlbracket, prsrhlpr_t::e_hold) && + !token_is(token_t::e_rsqrbracket, prsrhlpr_t::e_hold) ) { if (!token_is(token_t::e_eof,prsrhlpr_t::e_hold)) @@ -24253,7 +24371,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR159 - Expected ';' after variable definition", + "ERR160 - Expected ';' after variable definition", exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -24281,7 +24399,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 + "'", exprtk_error_location)); free_node(node_allocator_, initialisation_expression); @@ -24313,7 +24431,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", exprtk_error_location)); free_node(node_allocator_, initialisation_expression); @@ -24350,7 +24468,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR162 - Expected a '{}' for uninitialised var definition", + "ERR163 - Expected a '{}' for uninitialised var definition", exprtk_error_location)); return error_node(); @@ -24360,7 +24478,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR163 - Expected ';' after uninitialised variable definition", + "ERR164 - Expected ';' after uninitialised variable definition", exprtk_error_location)); return error_node(); @@ -24377,7 +24495,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR164 - Illegal redefinition of local variable: '" + var_name + "'", + "ERR165 - Illegal redefinition of local variable: '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -24407,7 +24525,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR165 - Failed to add new local variable '" + var_name + "' to SEM", + "ERR166 - Failed to add new local variable '" + var_name + "' to SEM", exprtk_error_location)); sem_.free_element(nse); @@ -24440,7 +24558,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR166 - Expected '(' at start of swap statement", + "ERR167 - Expected '(' at start of swap statement", exprtk_error_location)); return error_node(); @@ -24459,7 +24577,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", exprtk_error_location)); return error_node(); @@ -24471,7 +24589,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR168 - First parameter to swap is an invalid vector element: '" + var0_name + "'", + "ERR169 - First parameter to swap is an invalid vector element: '" + var0_name + "'", exprtk_error_location)); return error_node(); @@ -24504,7 +24622,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR169 - First parameter to swap is an invalid variable: '" + var0_name + "'", + "ERR170 - First parameter to swap is an invalid variable: '" + var0_name + "'", exprtk_error_location)); return error_node(); @@ -24518,7 +24636,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR170 - Expected ',' between parameters to swap", + "ERR171 - Expected ',' between parameters to swap", exprtk_error_location)); if (variable0_generated) @@ -24536,7 +24654,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR171 - Expected a symbol for variable or vector element definition", + "ERR172 - Expected a symbol for variable or vector element definition", exprtk_error_location)); if (variable0_generated) @@ -24553,7 +24671,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR172 - Second parameter to swap is an invalid vector element: '" + var1_name + "'", + "ERR173 - Second parameter to swap is an invalid vector element: '" + var1_name + "'", exprtk_error_location)); if (variable0_generated) @@ -24591,7 +24709,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR173 - Second parameter to swap is an invalid variable: '" + var1_name + "'", + "ERR174 - Second parameter to swap is an invalid variable: '" + var1_name + "'", exprtk_error_location)); if (variable0_generated) @@ -24610,7 +24728,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR174 - Expected ')' at end of swap statement", + "ERR175 - Expected ')' at end of swap statement", exprtk_error_location)); if (variable0_generated) @@ -24667,7 +24785,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR175 - Return call within a return call is not allowed", + "ERR176 - Return call within a return call is not allowed", exprtk_error_location)); return error_node(); @@ -24691,7 +24809,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR176 - Expected '[' at start of return statement", + "ERR177 - Expected '[' at start of return statement", exprtk_error_location)); return error_node(); @@ -24714,7 +24832,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR177 - Expected ',' between values during call to return", + "ERR178 - Expected ',' between values during call to return", exprtk_error_location)); return error_node(); @@ -24726,13 +24844,13 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR178 - Zero parameter return statement not allowed", + "ERR179 - Zero parameter return statement not allowed", exprtk_error_location)); return error_node(); } - lexer::token prev_token = current_token(); + const lexer::token prev_token = current_token(); if (token_is(token_t::e_rsqrbracket)) { @@ -24741,7 +24859,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR179 - Invalid ']' found during return call", + "ERR180 - Invalid ']' found during return call", exprtk_error_location)); return error_node(); @@ -24794,7 +24912,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR180 - Invalid sequence of variable '"+ symbol + "' and bracket", + "ERR181 - Invalid sequence of variable '"+ symbol + "' and bracket", exprtk_error_location)); return false; @@ -24842,7 +24960,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR181 - Invalid sequence of brackets", + "ERR182 - Invalid sequence of brackets", exprtk_error_location)); return false; @@ -24939,7 +25057,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR182 - Failed to generate node for function: '" + symbol + "'", + "ERR183 - Failed to generate node for function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -24965,7 +25083,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR183 - Failed to generate node for vararg function: '" + symbol + "'", + "ERR184 - Failed to generate node for vararg function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -24991,7 +25109,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR184 - Failed to generate node for generic function: '" + symbol + "'", + "ERR185 - Failed to generate node for generic function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -25018,7 +25136,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR185 - Failed to generate node for string function: '" + symbol + "'", + "ERR186 - Failed to generate node for string function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -25044,7 +25162,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR186 - Invalid use of reserved symbol '" + symbol + "'", + "ERR187 - Invalid use of reserved symbol '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -25064,7 +25182,7 @@ namespace exprtk { T default_value = T(0); - typename unknown_symbol_resolver::usr_symbol_type usr_symbol_type; + typename unknown_symbol_resolver::usr_symbol_type usr_symbol_type = unknown_symbol_resolver::e_usr_unknown_type; if (unknown_symbol_resolver_->process(symbol, usr_symbol_type, default_value, error_message)) { @@ -25107,7 +25225,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR187 - Failed to create variable: '" + symbol + "'" + + "ERR188 - Failed to create variable: '" + symbol + "'" + (error_message.empty() ? "" : " - " + error_message), exprtk_error_location)); @@ -25127,7 +25245,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR188 - Failed to resolve symbol: '" + symbol + "'" + + "ERR189 - Failed to resolve symbol: '" + symbol + "'" + (error_message.empty() ? "" : " - " + error_message), exprtk_error_location)); } @@ -25139,7 +25257,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR189 - Undefined symbol: '" + symbol + "'", + "ERR190 - Undefined symbol: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -25246,7 +25364,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR190 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value, + "ERR191 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value, exprtk_error_location)); return error_node(); @@ -25270,7 +25388,7 @@ namespace exprtk set_error( make_error(parser_error::e_numeric, current_token(), - "ERR191 - Failed generate node for scalar: '" + current_token().value + "'", + "ERR192 - Failed generate node for scalar: '" + current_token().value + "'", exprtk_error_location)); return error_node(); @@ -25284,7 +25402,7 @@ namespace exprtk set_error( make_error(parser_error::e_numeric, current_token(), - "ERR192 - Failed to convert '" + current_token().value + "' to a number", + "ERR193 - Failed to convert '" + current_token().value + "' to a number", exprtk_error_location)); return error_node(); @@ -25311,7 +25429,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR193 - Expected ')' instead of: '" + current_token().value + "'", + "ERR194 - Expected ')' instead of: '" + current_token().value + "'", exprtk_error_location)); free_node(node_allocator_,branch); @@ -25336,7 +25454,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR194 - Expected ']' instead of: '" + current_token().value + "'", + "ERR195 - Expected ']' instead of: '" + current_token().value + "'", exprtk_error_location)); free_node(node_allocator_,branch); @@ -25361,7 +25479,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR195 - Expected '}' instead of: '" + current_token().value + "'", + "ERR196 - Expected '}' instead of: '" + current_token().value + "'", exprtk_error_location)); free_node(node_allocator_,branch); @@ -25401,7 +25519,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR196 - Premature end of expression[1]", + "ERR197 - Premature end of expression[1]", exprtk_error_location)); return error_node(); @@ -25411,7 +25529,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR197 - Premature end of expression[2]", + "ERR198 - Premature end of expression[2]", exprtk_error_location)); return error_node(); @@ -26293,15 +26411,19 @@ namespace exprtk return (*this)(operation,branch); } - inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr b0, expression_node_ptr b1) + inline expression_node_ptr operator() (const details::operator_type& operation, expression_node_ptr& b0, expression_node_ptr& b1) { - if ((0 == b0) || (0 == b1)) - return error_node(); - else + expression_node_ptr result = error_node(); + + if ((0 != b0) && (0 != b1)) { expression_node_ptr branch[2] = { b0, b1 }; - return expression_generator::operator()(operation,branch); + result = expression_generator::operator()(operation, branch); + b0 = branch[0]; + b1 = branch[1]; } + + return result; } inline expression_node_ptr conditional(expression_node_ptr condition, @@ -26527,7 +26649,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr const_optimise_switch(Sequence& arg_list) { expression_node_ptr result = error_node(); @@ -26563,7 +26685,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr const_optimise_mswitch(Sequence& arg_list) { expression_node_ptr result = error_node(); @@ -26688,7 +26810,7 @@ namespace exprtk }; template class Sequence> + template class Sequence> inline expression_node_ptr switch_statement(Sequence& arg_list) { if (arg_list.empty()) @@ -26728,7 +26850,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr multi_switch_statement(Sequence& arg_list) { if (!all_nodes_valid(arg_list)) @@ -27040,7 +27162,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr const_optimise_varargfunc(const details::operator_type& operation, Sequence& arg_list) { expression_node_ptr temp_node = error_node(); @@ -27084,7 +27206,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr varnode_optimise_varargfunc(const details::operator_type& operation, Sequence& arg_list) { switch (operation) @@ -27107,7 +27229,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr vectorize_func(const details::operator_type& operation, Sequence& arg_list) { if (1 == arg_list.size()) @@ -27132,7 +27254,7 @@ namespace exprtk } template class Sequence> + template class Sequence> inline expression_node_ptr vararg_function(const details::operator_type& operation, Sequence& arg_list) { if (!all_nodes_valid(arg_list)) @@ -27494,7 +27616,7 @@ namespace exprtk template class Sequence> + template class Sequence> inline bool is_constant_foldable(const Sequence& b) const { for (std::size_t i = 0; i < b.size(); ++i) @@ -28032,7 +28154,7 @@ namespace exprtk case_stmt(details::e_xnor, details::xnor_op) \ #ifndef exprtk_disable_cardinal_pow_optimisation - template class IPowNode> + template class IPowNode> inline expression_node_ptr cardinal_pow_optimisation_impl(const TType& v, const unsigned int& p) { switch (p) @@ -29295,7 +29417,7 @@ namespace exprtk typedef details::T0oT1oT2_base_node* sf3ext_base_ptr; sf3ext_base_ptr n = static_cast(sf3node); - std::string id = "t" + expr_gen.to_str(operation) + "(" + n->type_id() + ")"; + const std::string id = "t" + expr_gen.to_str(operation) + "(" + n->type_id() + ")"; switch (n->type()) { @@ -29338,7 +29460,7 @@ namespace exprtk sf3ext_base_ptr n = static_cast(sf3node); - std::string id = "(" + n->type_id() + ")" + expr_gen.to_str(operation) + "t"; + const std::string id = "(" + n->type_id() + ")" + expr_gen.to_str(operation) + "t"; switch (n->type()) { @@ -29467,7 +29589,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29527,7 +29652,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29588,7 +29716,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29648,7 +29779,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29708,7 +29842,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29768,7 +29905,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -29828,7 +29968,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -29888,7 +30031,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -30002,7 +30148,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -30116,7 +30265,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -30239,7 +30391,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)"; } }; @@ -30361,7 +30516,10 @@ namespace exprtk static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t"; } }; @@ -30490,7 +30648,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30574,7 +30736,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30658,7 +30824,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30742,7 +30912,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -30826,7 +31000,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31015,7 +31193,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31254,7 +31436,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31443,7 +31629,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31631,7 +31821,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t)"; } }; @@ -31683,7 +31877,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31739,7 +31937,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31795,7 +31997,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31851,7 +32057,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31908,7 +32118,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -31965,7 +32179,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -32021,7 +32239,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -32077,7 +32299,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -32133,7 +32359,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "(t" << expr_gen.to_str(o2) << "t))"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "(t" << expr_gen.to_str(o2) + << "t))"; } }; @@ -32189,7 +32419,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32245,7 +32479,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32301,7 +32539,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32357,7 +32599,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32414,7 +32660,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32471,7 +32721,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32527,7 +32781,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32584,7 +32842,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "t" << expr_gen.to_str(o0) << "((t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t)"); + return details::build_string() + << "t" << expr_gen.to_str(o0) + << "((t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t)"; } }; @@ -32657,7 +32919,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32714,7 +32980,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32770,7 +33040,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32826,7 +33100,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32882,7 +33160,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32938,7 +33220,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -32995,7 +33281,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33052,7 +33342,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33108,7 +33402,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "((t" << expr_gen.to_str(o0) << "t)" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "((t" << expr_gen.to_str(o0) + << "t)" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33164,7 +33462,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33221,7 +33523,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33277,7 +33583,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33332,7 +33642,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33388,7 +33702,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33444,7 +33762,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33501,7 +33823,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -33558,7 +33884,11 @@ namespace exprtk const details::operator_type o1, const details::operator_type o2) { - return (details::build_string() << "(t" << expr_gen.to_str(o0) << "(t" << expr_gen.to_str(o1) << "t)" << expr_gen.to_str(o2) << "t"); + return details::build_string() + << "(t" << expr_gen.to_str(o0) + << "(t" << expr_gen.to_str(o1) + << "t)" << expr_gen.to_str(o2) + << "t"; } }; @@ -34672,13 +35002,14 @@ namespace exprtk lexer::helper::helper_assembly helper_assembly_; - lexer::helper::commutative_inserter commutative_inserter_; - lexer::helper::operator_joiner operator_joiner_2_; - lexer::helper::operator_joiner operator_joiner_3_; - lexer::helper::symbol_replacer symbol_replacer_; - lexer::helper::bracket_checker bracket_checker_; - lexer::helper::numeric_checker numeric_checker_; - lexer::helper::sequence_validator sequence_validator_; + lexer::helper::commutative_inserter commutative_inserter_; + lexer::helper::operator_joiner operator_joiner_2_; + lexer::helper::operator_joiner operator_joiner_3_; + lexer::helper::symbol_replacer symbol_replacer_; + lexer::helper::bracket_checker bracket_checker_; + lexer::helper::numeric_checker numeric_checker_; + lexer::helper::sequence_validator sequence_validator_; + lexer::helper::sequence_validator_3tokens sequence_validator_3tkns_; template friend void details::disable_type_checking(ParserType& p); @@ -35855,7 +36186,7 @@ namespace exprtk def_fp_retval(6) template class Sequence> + template class Sequence> inline bool add(const std::string& name, const std::string& expression, const Sequence& var_list, @@ -35951,7 +36282,7 @@ namespace exprtk private: template class Sequence> + template class Sequence> bool compile_expression(const std::string& name, const std::string& expression, const Sequence& input_var_list, @@ -36738,7 +37069,7 @@ namespace exprtk } } - bool eof() + bool eof() const { switch (mode) { @@ -36749,7 +37080,7 @@ namespace exprtk } } - file_mode get_file_mode(const std::string& access) + file_mode get_file_mode(const std::string& access) const { if (access.empty() || access.size() > 2) return e_error; @@ -36827,11 +37158,9 @@ namespace exprtk inline T operator() (const std::size_t& ps_index, parameter_list_t parameters) { - std::string file_name; + std::string file_name = to_str(string_t(parameters[0])); std::string access; - file_name = to_str(string_t(parameters[0])); - if (file_name.empty()) return T(0); @@ -36912,27 +37241,27 @@ namespace exprtk case 0 : { const string_t buffer(parameters[1]); amount = buffer.size(); - return T(fd->write(buffer,amount) ? 1 : 0); + return T(fd->write(buffer, amount) ? 1 : 0); } case 1 : { const string_t buffer(parameters[1]); amount = std::min(buffer.size(), static_cast(scalar_t(parameters[2])())); - return T(fd->write(buffer,amount) ? 1 : 0); + return T(fd->write(buffer, amount) ? 1 : 0); } case 2 : { const vector_t vec(parameters[1]); amount = vec.size(); - return T(fd->write(vec,amount) ? 1 : 0); + return T(fd->write(vec, amount) ? 1 : 0); } case 3 : { const vector_t vec(parameters[1]); amount = std::min(vec.size(), static_cast(scalar_t(parameters[2])())); - return T(fd->write(vec,amount) ? 1 : 0); + return T(fd->write(vec, amount) ? 1 : 0); } } @@ -37133,10 +37462,10 @@ namespace exprtk namespace details { template - inline void kahan_sum(T& sum, T& error, T v) + inline void kahan_sum(T& sum, T& error, const T v) { - T x = v - error; - T y = sum + x; + const T x = v - error; + const T y = sum + x; error = (y - sum) - x; sum = y; } @@ -37860,7 +38189,7 @@ namespace exprtk else if (helper::invalid_range(y, r0, r1)) return std::numeric_limits::quiet_NaN(); - T a = scalar_t(parameters[0])(); + const T a = scalar_t(parameters[0])(); for (std::size_t i = r0; i <= r1; ++i) { @@ -37958,7 +38287,7 @@ namespace exprtk else if (helper::invalid_range(z, r0, r1)) return std::numeric_limits::quiet_NaN(); - T a = scalar_t(parameters[0])(); + const T a = scalar_t(parameters[0])(); for (std::size_t i = r0; i <= r1; ++i) { @@ -38236,9 +38565,9 @@ namespace exprtk namespace information { static const char* library = "Mathematical Expression Toolkit"; - static const char* version = "2.718281828459045235360287471352662497757247093699" - "95957496696762772407663035354759457138217852516642"; - static const char* date = "20180913"; + static const char* version = "2.71828182845904523536028747135266249775724709369995" + "9574966967627724076630353547594571382178525166427427"; + static const char* date = "20190101"; static inline std::string data() { diff --git a/exprtk_benchmark.cpp b/exprtk_benchmark.cpp index e219765..318a042 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 46ee209..7a586ce 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 4e3b915..94f18aa 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 b929192..6d1528e 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 eb1a4e3..6a8c81e 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 408f6d4..2902f8b 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 e3d81b3..9cb6dc0 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 736a7b9..208ae06 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 1c2d552..2ebe90c 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 79fb3f9..7a7ccb8 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 6ce237b..4cb66f2 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 87bacf7..b625bc1 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 b80411b..3863c6f 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 1dfbd31..24f3c22 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 397a86d..5541e63 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 f3a2ef5..4c34b93 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 64c366e..5ce1489 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 a80e0ca..1b92298 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 c5bdf04..615cb83 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-2018) * + * Author: Arash Partow (1999-2019) * * 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 d317559..8c786d1 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-2018) * + * Author: Arash Partow (1999-2019) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * diff --git a/exprtk_test.cpp b/exprtk_test.cpp index 75747aa..bb2960a 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-2018) * + * Author: Arash Partow (1999-2019) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -2674,6 +2674,10 @@ inline bool run_test02() template inline bool run_test03() { + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + std::string expression_string = "A+A0+aA+Aa0+b+B1+Bb+bB1+A+A0+AA+AA0+B+B1+BB+BB1+a+a0+aa+aa0+b+b1+bb+bb1+" "c+C2+Cc+Cc2+D+D3+dD+dD3+C+C2+CC+CC2+D+D3+DD+DD3+c+c2+cc+cc2+d+d3+dd+dd3+" "E+E4+eE+Ee4+f+F5+Ff+fF5+E+E4+EE+EE4+F+F5+FF+FF5+e+e4+ee+ee4+f+f5+ff+ff5+" @@ -2711,9 +2715,9 @@ inline bool run_test03() for (std::size_t r = 0; r < rounds; ++r) { - exprtk::symbol_table symbol_table_0; - exprtk::symbol_table symbol_table_1; - exprtk::expression expression; + symbol_table_t symbol_table_0; + symbol_table_t symbol_table_1; + expression_t expression; std::vector v; v.resize(variable_list_size); @@ -2812,7 +2816,7 @@ inline bool run_test03() "1 v y", "x v 1", "y v 1", - + "(x == 'a string' )", "(x == 'a string'[1:2] )", "(x == 'a string' + 'b string' )", @@ -2820,7 +2824,22 @@ inline bool run_test03() "('a string' == x )", "('a string'[1:2] == x )", "('a string' + 'b string' == x )", - "(('a string' + 'b string')[3:5] == x)" + "(('a string' + 'b string')[3:5] == x)", + + "var a; var b; 3in(a)+sin(b) ", + "var a; var b; sin(a)+3in(b) ", + "var a; var b; sqrt(a)<3in(8) ", + "var a; var b; (1.99-3in((b-b))) ", + "var a; var b; ((3in(sin((b+b)))/1.06)-a) ", + "var a; var b; ((sin(3in((b+b)))/1.06)-a) ", + "var a; var b; (3in(x*(y+z))+cos(x*(y-z))) ", + "var a; var b; (cos(x*(y+z))+3in(x*(y-z))) ", + + "1++++", + "1+-+-+", + "1===", + "1====", + "[*][*][*][*][*]" }; const std::size_t invalid_expr_size = sizeof(invalid_expr) / sizeof(std::string); @@ -2828,9 +2847,9 @@ inline bool run_test03() { for (std::size_t i = 0; i < invalid_expr_size; ++i) { - exprtk::symbol_table symbol_table; - - exprtk::expression expression; + symbol_table_t symbol_table; + expression_t expression; + parser_t parser; T x = T(0); std::string s; @@ -2840,8 +2859,6 @@ inline bool run_test03() symbol_table.add_stringvar("s",s); symbol_table.add_vector ("v",v); - exprtk::parser parser; - if (parser.compile(invalid_expr[i],expression)) { printf("run_test03() - Error: [1] Invalid expression compiled successfuly. Expression: %s\n", @@ -2857,14 +2874,13 @@ inline bool run_test03() std::string s; std::vector v(10, T(1.234)); - exprtk::symbol_table symbol_table; + symbol_table_t symbol_table; + parser_t parser; symbol_table.add_variable ("x",x); symbol_table.add_stringvar("s",s); symbol_table.add_vector ("v",v); - exprtk::parser parser; - for (std::size_t i = 0; i < invalid_expr_size; ++i) { exprtk::expression expression; @@ -2878,6 +2894,64 @@ inline bool run_test03() } } } + + { + const std::string base_expression = + "1+(2+2(3+3(4+4cos(((((a+((x*(e-tan((cos((((((b/(tan(((1.60*a)-0.34))-0.76))-x)+y)-3.27)+a))/pi))))^a))+y)*b)-e))+e)/z)+w)+" + "(((b+(a/((((tan((b*((((((a-(cos((cos(tan(((a+a)*3.33)))-b))/2.52))*x)/b)+3.07)^0.86)+b)))*3.95)/0.39)*y)+a)))*a)*z)"; + + const std::string mod = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^+-/*,;:<>=%?[]{}() #&'\"\\\t\r\n"; + + symbol_table_t symbol_table; + expression_t expression; + parser_t parser; + + T a = T(1.1 ); + T b = T(2.2 ); + T c = T(3.3 ); + T d = T(4.5 ); + T e = T(4.5 ); + T x = T(2.123456); + T y = T(3.123456); + T z = T(4.123456); + T w = T(5.123456); + + symbol_table.add_variable("a", a); + symbol_table.add_variable("b", b); + symbol_table.add_variable("c", c); + symbol_table.add_variable("d", d); + symbol_table.add_variable("e", e); + + symbol_table.add_variable("x", x); + symbol_table.add_variable("y", y); + symbol_table.add_variable("z", z); + symbol_table.add_variable("w", w); + + expression.register_symbol_table(symbol_table); + + T total = T(0); + + for (std::size_t j = 0; j < base_expression.size(); ++j) + { + std::string expression_str = base_expression; + const char old_c = base_expression[j]; + + for (std::size_t i = 0; i < mod.size(); ++i) + { + expression_str[j] = mod[i]; + + if (parser.compile(expression_str, expression)) + { + total += expression.value(); + } + } + + expression_str[j] = old_c; + } + + if (total == T(12345.6789)) { printf(" "); } + } } return true; diff --git a/readme.txt b/readme.txt index f3c2254..9191b83 100644 --- a/readme.txt +++ b/readme.txt @@ -706,6 +706,61 @@ This allows for the original element to be modified independently of the expression instance and to also allow the expression to be evaluated using the current value of the element. +Note: Any variable reference provided to a given symbol_table +instance, must have a life time at least as long as the life-time of +the symbol_table instance. In the event the variable reference is +invalidated before the symbol_table or any dependent expression +instances have been destructed, then any associated expression +evaluations or variable referencing via the symbol_table instance will +result in undefined behaviour. + +The following bit of code instantiates a symbol_table and expression +instance, then proceeds to demonstrate various ways in which +references to variables can be added to the symbol_table, and how +those references are subsequently invalidated resulting in various +forms of undefined behaviour. + + typedef exprtk::symbol_table symbol_table_t; + + symbol_table_t symbol_table; + expression_t expression; + + { + double x = 123.4567; + symbol_table.add_variable("x", x); + } // Reference to variable x has been invalidated + + std::deque y {1.1, 2.2, 3.3}; + + symbol_table.add_variable("y", y.back()); + + y.pop_back(); // Reference to variable y has been invalidated + + std::vector z {4.4, 5.5, 6.6}; + + symbol_table.add_variable("z", z.front()); + + z.erase(z.begin()); + // Reference to variable z has been invalidated + + double* w = new double(123.456); + + symbol_table.add_variable("w", *w); + + delete w; // Reference to variable w has been invalidated + + const std::string expression_str = "x + y / z * w"; + + // Compilation of expression will succeed + parser.compile(expression_str,expression); + + expression.value(); + // Evaluation will result in undefined behaviour + + symbol_table.get_variable("x")->ref() = 135.791; + // Assignment will result in undefined behaviour + + The example below demonstrates the relationship between variables, symbol_table and expression. Note the variables are modified as they normally would in a program, and when the expression is evaluated the @@ -2999,6 +3054,24 @@ 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. +Note: For a successful symbol resolution using the normal USR all of +the following are required: + + (1) Only if successful shall the process method return TRUE + (2) The default_value parameter will have been set + (3) The error_message parameter will be empty + (4) usr_symbol_type input parameter field will be set to either: + (*) e_usr_variable_type + (*) e_usr_constant_type + +Note: For a successful symbol resolution using the extended USR all of +the following are required: + + (1) Only if successful shall the process method return TRUE + (2) symbol_table parameter will have had the newly resolved + variable or string added to it + (3) error_message parameter will be empty + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [SECTION 19 - ENABLING & DISABLING FEATURES]