Skip to content

Commit 561eead

Browse files
committed
Merge branch 'master' of github.com:BehaviorTree/BehaviorTree.CPP
2 parents ecd41b1 + 0deb546 commit 561eead

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ else()
187187
target_compile_options(${BTCPP_LIBRARY} PRIVATE -Wall -Wextra)
188188
endif()
189189

190+
add_library(BT::${BTCPP_LIBRARY} ALIAS ${BTCPP_LIBRARY})
191+
190192
#############################################################
191193
message( STATUS "BTCPP_LIB_DESTINATION: ${BTCPP_LIB_DESTINATION} " )
192194
message( STATUS "BTCPP_INCLUDE_DESTINATION: ${BTCPP_INCLUDE_DESTINATION} " )

include/behaviortree_cpp/scripting/operators.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct ExprBinaryArithmetic : ExprBase
150150
minus,
151151
times,
152152
div,
153+
concat,
153154

154155
bit_and,
155156
bit_or,
@@ -171,6 +172,8 @@ struct ExprBinaryArithmetic : ExprBase
171172
return "*";
172173
case div:
173174
return "/";
175+
case concat:
176+
return "..";
174177
case bit_and:
175178
return "&";
176179
case bit_or:
@@ -276,6 +279,12 @@ struct ExprBinaryArithmetic : ExprBase
276279
{
277280
return Any(lhs_v.cast<std::string>() + rhs_v.cast<std::string>());
278281
}
282+
else if(op == concat && ((rhs_v.isString() && lhs_v.isString()) ||
283+
(rhs_v.isString() && lhs_v.isNumber()) ||
284+
(rhs_v.isNumber() && lhs_v.isString())))
285+
{
286+
return Any(lhs_v.cast<std::string>() + rhs_v.cast<std::string>());
287+
}
279288
else
280289
{
281290
throw RuntimeError("Operation not permitted");
@@ -726,6 +735,16 @@ struct Expression : lexy::expression_production
726735
using operand = math_product;
727736
};
728737

738+
// x .. y
739+
struct string_concat : dsl::infix_op_left
740+
{
741+
static constexpr auto op = [] {
742+
return dsl::op<Ast::ExprBinaryArithmetic::concat>(LEXY_LIT(".."));
743+
}();
744+
745+
using operand = math_sum;
746+
};
747+
729748
// ~x
730749
struct bit_prefix : dsl::prefix_op
731750
{
@@ -789,7 +808,7 @@ struct Expression : lexy::expression_production
789808
dsl::op<Ast::ExprBinaryArithmetic::logic_or>(LEXY_LIT("||")) /
790809
dsl::op<Ast::ExprBinaryArithmetic::logic_and>(LEXY_LIT("&&"));
791810

792-
using operand = comparison;
811+
using operand = dsl::groups<string_concat, comparison>;
793812
};
794813

795814
// x ? y : z

0 commit comments

Comments
 (0)