Skip to content

Commit c06f525

Browse files
committed
Updates to ExprTk
1 parent 0b03d8f commit c06f525

File tree

2 files changed

+40
-63
lines changed

2 files changed

+40
-63
lines changed

exprtk/exprtk.hpp

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,40 +4042,6 @@ namespace exprtk
40424042
return true;
40434043
}
40444044

4045-
inline bool token_is_then_assign(const token_t::token_type& ttype,
4046-
std::string& token,
4047-
const token_advance_mode mode = e_advance)
4048-
{
4049-
if (current_token_.type != ttype)
4050-
{
4051-
return false;
4052-
}
4053-
4054-
token = current_token_.value;
4055-
4056-
advance_token(mode);
4057-
4058-
return true;
4059-
}
4060-
4061-
template <typename Allocator,
4062-
template <typename,typename> class Container>
4063-
inline bool token_is_then_assign(const token_t::token_type& ttype,
4064-
Container<std::string,Allocator>& token_list,
4065-
const token_advance_mode mode = e_advance)
4066-
{
4067-
if (current_token_.type != ttype)
4068-
{
4069-
return false;
4070-
}
4071-
4072-
token_list.push_back(current_token_.value);
4073-
4074-
advance_token(mode);
4075-
4076-
return true;
4077-
}
4078-
40794045
inline bool peek_token_is(const token_t::token_type& ttype)
40804046
{
40814047
return (lexer_.peek_next_token().type == ttype);
@@ -4592,16 +4558,16 @@ namespace exprtk
45924558
{}
45934559

45944560
control_block(const std::size_t& dsize)
4595-
: ref_count(1),
4561+
: ref_count(1 ),
45964562
size (dsize),
4597-
data (0),
4598-
destruct (true)
4563+
data (0 ),
4564+
destruct (true )
45994565
{ create_data(); }
46004566

46014567
control_block(const std::size_t& dsize, data_t dptr, bool dstrct = false)
4602-
: ref_count(1),
4603-
size (dsize),
4604-
data (dptr ),
4568+
: ref_count(1 ),
4569+
size (dsize ),
4570+
data (dptr ),
46054571
destruct (dstrct)
46064572
{}
46074573

@@ -4852,19 +4818,19 @@ namespace exprtk
48524818
case e_ne : return std::not_equal_to<T>()(arg0,arg1) ? T(1) : T(0);
48534819
case e_gte : return (arg0 >= arg1) ? T(1) : T(0);
48544820
case e_gt : return (arg0 > arg1) ? T(1) : T(0);
4855-
case e_and : return and_opr<T> (arg0,arg1);
4821+
case e_and : return and_opr <T>(arg0,arg1);
48564822
case e_nand : return nand_opr<T>(arg0,arg1);
4857-
case e_or : return or_opr<T> (arg0,arg1);
4858-
case e_nor : return nor_opr<T> (arg0,arg1);
4859-
case e_xor : return xor_opr<T> (arg0,arg1);
4823+
case e_or : return or_opr <T>(arg0,arg1);
4824+
case e_nor : return nor_opr <T>(arg0,arg1);
4825+
case e_xor : return xor_opr <T>(arg0,arg1);
48604826
case e_xnor : return xnor_opr<T>(arg0,arg1);
4861-
case e_root : return root<T> (arg0,arg1);
4862-
case e_roundn : return roundn<T> (arg0,arg1);
4827+
case e_root : return root <T>(arg0,arg1);
4828+
case e_roundn : return roundn <T>(arg0,arg1);
48634829
case e_equal : return equal (arg0,arg1);
48644830
case e_nequal : return nequal (arg0,arg1);
4865-
case e_hypot : return hypot<T> (arg0,arg1);
4866-
case e_shr : return shr<T> (arg0,arg1);
4867-
case e_shl : return shl<T> (arg0,arg1);
4831+
case e_hypot : return hypot <T>(arg0,arg1);
4832+
case e_shr : return shr <T>(arg0,arg1);
4833+
case e_shl : return shl <T>(arg0,arg1);
48684834

48694835
default : exprtk_debug(("numeric::details::process_impl<T> - Invalid binary operation.\n"));
48704836
return std::numeric_limits<T>::quiet_NaN();
@@ -12307,22 +12273,22 @@ namespace exprtk
1230712273
static inline T process_3(const Sequence& arg_list)
1230812274
{
1230912275
return value(arg_list[0]) + value(arg_list[1]) +
12310-
value(arg_list[2]);
12276+
value(arg_list[2]) ;
1231112277
}
1231212278

1231312279
template <typename Sequence>
1231412280
static inline T process_4(const Sequence& arg_list)
1231512281
{
1231612282
return value(arg_list[0]) + value(arg_list[1]) +
12317-
value(arg_list[2]) + value(arg_list[3]);
12283+
value(arg_list[2]) + value(arg_list[3]) ;
1231812284
}
1231912285

1232012286
template <typename Sequence>
1232112287
static inline T process_5(const Sequence& arg_list)
1232212288
{
1232312289
return value(arg_list[0]) + value(arg_list[1]) +
1232412290
value(arg_list[2]) + value(arg_list[3]) +
12325-
value(arg_list[4]);
12291+
value(arg_list[4]) ;
1232612292
}
1232712293
};
1232812294

@@ -12374,22 +12340,22 @@ namespace exprtk
1237412340
static inline T process_3(const Sequence& arg_list)
1237512341
{
1237612342
return value(arg_list[0]) * value(arg_list[1]) *
12377-
value(arg_list[2]);
12343+
value(arg_list[2]) ;
1237812344
}
1237912345

1238012346
template <typename Sequence>
1238112347
static inline T process_4(const Sequence& arg_list)
1238212348
{
1238312349
return value(arg_list[0]) * value(arg_list[1]) *
12384-
value(arg_list[2]) * value(arg_list[3]);
12350+
value(arg_list[2]) * value(arg_list[3]) ;
1238512351
}
1238612352

1238712353
template <typename Sequence>
1238812354
static inline T process_5(const Sequence& arg_list)
1238912355
{
1239012356
return value(arg_list[0]) * value(arg_list[1]) *
1239112357
value(arg_list[2]) * value(arg_list[3]) *
12392-
value(arg_list[4]);
12358+
value(arg_list[4]) ;
1239312359
}
1239412360
};
1239512361

@@ -26027,11 +25993,11 @@ namespace exprtk
2602725993
inline bool is_constpow_operation(const details::operator_type& operation, expression_node_ptr(&branch)[2])
2602825994
{
2602925995
if (
26030-
!is_constant_node(branch[1]) ||
26031-
is_constant_node(branch[0]) ||
26032-
is_variable_node(branch[0]) ||
26033-
is_vector_node (branch[0]) ||
26034-
is_generally_string_node(branch[0])
25996+
!details::is_constant_node(branch[1]) ||
25997+
details::is_constant_node(branch[0]) ||
25998+
details::is_variable_node(branch[0]) ||
25999+
details::is_vector_node (branch[0]) ||
26000+
details::is_generally_string_node(branch[0])
2603526001
)
2603626002
return false;
2603726003

@@ -27673,6 +27639,8 @@ namespace exprtk
2767327639
}
2767427640
else if (details::is_vector_elem_node(branch[0]))
2767527641
{
27642+
lodge_assignment(e_st_vecelem,branch[0]);
27643+
2767627644
switch (operation)
2767727645
{
2767827646
#define case_stmt(op0,op1) \
@@ -27691,6 +27659,8 @@ namespace exprtk
2769127659
}
2769227660
else if (details::is_rebasevector_elem_node(branch[0]))
2769327661
{
27662+
lodge_assignment(e_st_vecelem,branch[0]);
27663+
2769427664
switch (operation)
2769527665
{
2769627666
#define case_stmt(op0,op1) \
@@ -27709,6 +27679,8 @@ namespace exprtk
2770927679
}
2771027680
else if (details::is_rebasevector_celem_node(branch[0]))
2771127681
{
27682+
lodge_assignment(e_st_vecelem,branch[0]);
27683+
2771227684
switch (operation)
2771327685
{
2771427686
#define case_stmt(op0,op1) \
@@ -38263,9 +38235,9 @@ namespace exprtk
3826338235
namespace information
3826438236
{
3826538237
static const char* library = "Mathematical Expression Toolkit";
38266-
static const char* version = "2.71828182845904523536028747135266249775724709369"
38267-
"9959574966967627724076630353547594571382178525166";
38268-
static const char* date = "20180101";
38238+
static const char* version = "2.718281828459045235360287471352662497757247093699"
38239+
"95957496696762772407663035354759457138217852516642";
38240+
static const char* date = "20180913";
3826938241

3827038242
static inline std::string data()
3827138243
{

exprtk/exprtk_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,11 @@ inline bool run_test02()
24522452
test_ab<T>("var x := 'XXXXX'; var y := '01234567890'; var i := 0; x[0:i+3] <=> y[:]; (x == '0123X') and (y == 'XXXX4567890')", "","",T(1.0)),
24532453
test_ab<T>("var x := 'XXXXX'; var y := '01234567890'; var i := 0; x[0:i+4] <=> y[:]; (x == '01234') and (y == 'XXXXX567890')", "","",T(1.0)),
24542454

2455+
test_ab<T>("var v[4] := {1,2,3,4}; for (var i := 0; i < v[]; i += 1) { v[i] += 10; v[i] == 0 }; sum(v) == (1 + 2 + 3 + 4) + (v[] * 10)", "","",T(1.0)),
2456+
test_ab<T>("var v[4] := {1,2,3,4}; for (var i := 0; i < v[]; i += 1) { v[i] -= 10; v[i] == 0 }; sum(v) == (1 + 2 + 3 + 4) - (v[] * 10)", "","",T(1.0)),
2457+
test_ab<T>("var v[4] := {1,2,3,4}; for (var i := 0; i < v[]; i += 1) { v[i] *= 10; v[i] == 0 }; sum(v) == (1 + 2 + 3 + 4) * 10", "","",T(1.0)),
2458+
test_ab<T>("var v[4] := {1,2,3,4}; for (var i := 0; i < v[]; i += 1) { v[i] /= 10; v[i] == 0 }; sum(v) == (1 + 2 + 3 + 4) / 10", "","",T(1.0)),
2459+
24552460
test_ab<T>("a like b", "abcd", "abcd*", T(1.0)),
24562461
test_ab<T>("a like b", "abcd", "abcd" , T(1.0)),
24572462
test_ab<T>("a like b", "abcd", "abc*" , T(1.0)),

0 commit comments

Comments
 (0)