C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow
2017-04-06 08:26:48 +10:00
parent b579791618
commit e7d96c48ef
23 changed files with 85 additions and 47 deletions

View File

@ -2,7 +2,7 @@
******************************************************************
* C++ Mathematical Expression Toolkit Library *
* *
* Author: Arash Partow (1999-2017) *
* Author: Arash Partow (1999-2017) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -409,7 +409,7 @@ namespace exprtk
static const std::string cntrl_struct_list[] =
{
"if", "switch", "for", "while", "repeat"
"if", "switch", "for", "while", "repeat", "return"
};
static const std::size_t cntrl_struct_list_size = sizeof(cntrl_struct_list) / sizeof(std::string);
@ -4207,11 +4207,13 @@ namespace exprtk
return std::string(view.begin(),view.size());
}
#ifndef exprtk_disable_return_statement
namespace details
{
template <typename T> class return_node;
template <typename T> class return_envelope_node;
}
#endif
template <typename T>
class results_context
@ -4261,8 +4263,10 @@ namespace exprtk
bool results_available_;
ts_list_t parameter_list_;
#ifndef exprtk_disable_return_statement
friend class details::return_node<T>;
friend class details::return_envelope_node<T>;
#endif
};
namespace details
@ -11526,6 +11530,7 @@ namespace exprtk
}
};
#ifndef exprtk_disable_return_statement
template <typename T>
class return_node : public generic_function_node<T,null_igenfunc<T> >
{
@ -11626,6 +11631,7 @@ namespace exprtk
expression_ptr body_;
bool body_deletable_;
};
#endif
#define exprtk_define_unary_op(OpName) \
template <typename T> \
@ -18889,7 +18895,8 @@ namespace exprtk
e_ctrl_switch,
e_ctrl_for_loop,
e_ctrl_while_loop,
e_ctrl_repeat_loop
e_ctrl_repeat_loop,
e_ctrl_return
};
enum settings_logic_opr
@ -24003,6 +24010,7 @@ namespace exprtk
return result;
}
#ifndef exprtk_disable_return_statement
inline expression_node_ptr parse_return_statement()
{
if (state_.parsing_return_stmt)
@ -24112,6 +24120,12 @@ namespace exprtk
return result;
}
#else
inline expression_node_ptr parse_return_statement()
{
return error_node();
}
#endif
inline bool post_variable_process(const std::string& symbol)
{
@ -24522,7 +24536,10 @@ namespace exprtk
{
return parse_swap_statement();
}
else if (details::imatch(current_token().value,symbol_return))
else if (
details::imatch(current_token().value,symbol_return) &&
settings_.control_struct_enabled(current_token().value)
)
{
return parse_return_statement();
}
@ -26522,6 +26539,7 @@ namespace exprtk
}
#endif
#ifndef exprtk_disable_return_statement
inline expression_node_ptr return_call(std::vector<expression_node_ptr>& arg_list)
{
if (!all_nodes_valid(arg_list))
@ -26565,6 +26583,19 @@ namespace exprtk
return result;
}
#else
inline expression_node_ptr return_call(std::vector<expression_node_ptr>&)
{
return error_node();
}
inline expression_node_ptr return_envelope(expression_node_ptr,
results_context_t*,
bool*&)
{
return error_node();
}
#endif
inline expression_node_ptr vector_element(const std::string& symbol,
vector_holder_ptr vector_base,
@ -33518,6 +33549,7 @@ namespace exprtk
inline void return_cleanup()
{
#ifndef exprtk_disable_return_statement
if (results_context_)
{
delete results_context_;
@ -33525,6 +33557,7 @@ namespace exprtk
}
state_.return_stmt_present = false;
#endif
}
private:
@ -36619,7 +36652,7 @@ namespace exprtk
vector_t vec(parameters[0]);
T increment = scalar_t(parameters[1])();
T base = ((1 == ps_index) || (3 == ps_index))? scalar_t(parameters[2])() : T(0);
T base = ((1 == ps_index) || (3 == ps_index)) ? scalar_t(parameters[2])() : T(0);
std::size_t r0 = 0;
std::size_t r1 = vec.size() - 1;
@ -37097,9 +37130,9 @@ namespace exprtk
namespace information
{
static const char* library = "Mathematical Expression Toolkit";
static const char* version = "2.718281828459045235360287471352662497757247"
"09369995957496696762772407663035354759457138";
static const char* date = "20170107";
static const char* version = "2.71828182845904523536028747135266249775724709"
"3699959574966967627724076630353547594571382178";
static const char* date = "20170404";
static inline std::string data()
{