Skip to content

Commit c03bc8b

Browse files
committed
ignore newlines in script
1 parent d5ea17b commit c03bc8b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

include/behaviortree_cpp/scripting/operators.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ struct stmt
806806
// This is because we can't easily know whether we need to request more input when seeing a
807807
// newline or not. Once we're having a e.g. parenthesized expression, we know that we need more
808808
// input until we've reached ), so then change the whitespace rule.
809-
static constexpr auto whitespace = dsl::ascii::blank | escaped_newline;
809+
static constexpr auto whitespace = dsl::ascii::blank | escaped_newline | dsl::newline;
810810

811811
static constexpr auto rule = [] {
812812
// We can't use `dsl::eol` as our terminator directly,

tests/script_parser_test.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,23 @@ TEST(ParserTest, Issue595)
381381
ASSERT_EQ(status, BT::NodeStatus::SUCCESS);
382382
ASSERT_EQ(0, counters[0]);
383383
}
384+
385+
TEST(ParserTest, NewLine)
386+
{
387+
BT::BehaviorTreeFactory factory;
388+
389+
const std::string xml_text = R"(
390+
<root BTCPP_format="4" >
391+
<BehaviorTree ID="Main">
392+
<Script code="A:=5;&#10;B:=6"/>
393+
</BehaviorTree>
394+
</root> )";
395+
396+
397+
auto tree = factory.createTreeFromText(xml_text);
398+
const auto status = tree.tickWhileRunning();
399+
400+
ASSERT_EQ(status, BT::NodeStatus::SUCCESS);
401+
ASSERT_EQ(tree.rootBlackboard()->get<int>("A"), 5);
402+
ASSERT_EQ(tree.rootBlackboard()->get<int>("B"), 6);
403+
}

0 commit comments

Comments
 (0)