C++ Mathematical Expression Library (ExprTk) https://www.partow.net/programming/exprtk/index.html
diff --git a/exprtk.hpp b/exprtk.hpp
index 905694b..1c06b1f 100644
--- a/exprtk.hpp
+++ b/exprtk.hpp
@@ -2436,9 +2436,10 @@
/*
Permit symbols that contain a 'dot'
Allowed : abc.xyz, a123.xyz, abc.123, abc_.xyz a123_.xyz abc._123
- Disallowed: abc.<white-space>, abc.<eof>, abc.<operator +,-,*,/...>
+ Disallowed: .abc, abc.<white-space>, abc.<eof>, abc.<operator +,-,*,/...>
*/
if (
+ (s_itr_ != initial_itr) &&
!is_end(s_itr_ + 1) &&
details::is_letter_or_digit(*s_itr_ + 1) &&
('_' != (*s_itr_ + 1))
@@ -17071,12 +17072,14 @@
for (std::size_t i = 1; i < symbol.size(); ++i)
{
if (
- (!details::is_letter(symbol[i])) &&
- (!details:: is_digit(symbol[i])) &&
+ !details::is_letter_or_digit(symbol[i]) &&
('_' != symbol[i])
)
{
- return false;
+ if (('.' == symbol[i]) && (i < (symbol.size() - 1)))
+ continue;
+ else
+ return false;
}
}
}
@@ -17095,12 +17098,14 @@
for (std::size_t i = 1; i < symbol.size(); ++i)
{
if (
- (!details::is_letter(symbol[i])) &&
- (!details:: is_digit(symbol[i])) &&
+ !details::is_letter_or_digit(symbol[i]) &&
('_' != symbol[i])
)
{
- return false;
+ if (('.' == symbol[i]) && (i < (symbol.size() - 1)))
+ continue;
+ else
+ return false;
}
}
}
@@ -17518,8 +17523,19 @@
{
return details::is_function(expr.control_block_->expr);
}
+
+ static inline bool is_null(const expression<T>& expr)
+ {
+ return details::is_null_node(expr.control_block_->expr);
+ }
};
+ template <typename T>
+ inline bool is_valid(const expression<T>& expr)
+ {
+ return !expression_helper<T>::is_null(expr);
+ }
+
namespace parser_error
{
enum error_mode
diff --git a/exprtk_simple_example_08.cpp b/exprtk_simple_example_08.cpp
index dd7dc23..5f48808 100644
--- a/exprtk_simple_example_08.cpp
+++ b/exprtk_simple_example_08.cpp
@@ -65,6 +65,7 @@
for (std::size_t i = 0; i < parser.error_count(); ++i)
{
error_t error = parser.get_error(i);
+
printf("Error: %02d Position: %02d Type: [%14s] Msg: %s\tExpression: %s\n",
static_cast<unsigned int>(i),
static_cast<unsigned int>(error.token.position),
diff --git a/readme.txt b/readme.txt
index f527a2b..28cad05 100644
--- a/readme.txt
+++ b/readme.txt
@@ -291,6 +291,8 @@
+----------+---------------------------------------------------------+
| nequal | Not-equal test between x and y using normalized epsilon |
+----------+---------------------------------------------------------+
+| pow | x to the power of y. (eg: pow(x,y) == x ^ y) |
++----------+---------------------------------------------------------+
| root | Nth-Root of x. where n is a positive integer. |
| | (eg: root(x,3) == x^(1/3)) |
+----------+---------------------------------------------------------+