Skip to content

Commit

Permalink
fix script parse error while 'A==-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzheng committed Dec 12, 2024
1 parent f5e98fd commit f615f0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/t09_scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static const char* xml_text = R"(
<Sequence>
<Script code=" msg:='hello world' " />
<Script code=" A:=THE_ANSWER; B:=3.14; color:=RED " />
<Precondition if="A>B && color != BLUE" else="FAILURE">
<Precondition if="A>-B && color != BLUE" else="FAILURE">
<Sequence>
<SaySomething message="{A}"/>
<SaySomething message="{B}"/>
Expand Down
6 changes: 3 additions & 3 deletions include/behaviortree_cpp/scripting/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,9 @@ struct Expression : lexy::expression_production
dsl::op<Ast::ExprComparison::greater_equal>(LEXY_LIT(">"
"="));

// The use of dsl::groups ensures that an expression can either contain math or bit
// The use of dsl::groups ensures that an expression can either contain math or bit or string
// operators. Mixing requires parenthesis.
using operand = dsl::groups<math_sum, bit_or>;
using operand = dsl::groups<math_sum, bit_or, string_concat>;
};

// Logical operators, || and &&
Expand All @@ -808,7 +808,7 @@ struct Expression : lexy::expression_production
dsl::op<Ast::ExprBinaryArithmetic::logic_or>(LEXY_LIT("||")) /
dsl::op<Ast::ExprBinaryArithmetic::logic_and>(LEXY_LIT("&&"));

using operand = dsl::groups<string_concat, comparison>;
using operand = comparison;
};

// x ? y : z
Expand Down

0 comments on commit f615f0a

Please sign in to comment.