From 283f6b2bf1b9bb56439ccffd507e6fd8eef3840a Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Mon, 9 Oct 2023 10:42:17 +0200 Subject: [PATCH] ignore newlines in script --- .../behaviortree_cpp/scripting/operators.hpp | 2 +- tests/script_parser_test.cpp | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/behaviortree_cpp/scripting/operators.hpp b/include/behaviortree_cpp/scripting/operators.hpp index c9e365416..26935b8ff 100644 --- a/include/behaviortree_cpp/scripting/operators.hpp +++ b/include/behaviortree_cpp/scripting/operators.hpp @@ -806,7 +806,7 @@ struct stmt // This is because we can't easily know whether we need to request more input when seeing a // newline or not. Once we're having a e.g. parenthesized expression, we know that we need more // input until we've reached ), so then change the whitespace rule. - static constexpr auto whitespace = dsl::ascii::blank | escaped_newline; + static constexpr auto whitespace = dsl::ascii::blank | escaped_newline | dsl::newline; static constexpr auto rule = [] { // We can't use `dsl::eol` as our terminator directly, diff --git a/tests/script_parser_test.cpp b/tests/script_parser_test.cpp index b5dcdb3cb..e95a5c0ba 100644 --- a/tests/script_parser_test.cpp +++ b/tests/script_parser_test.cpp @@ -381,3 +381,23 @@ TEST(ParserTest, Issue595) ASSERT_EQ(status, BT::NodeStatus::SUCCESS); ASSERT_EQ(0, counters[0]); } + +TEST(ParserTest, NewLine) +{ + BT::BehaviorTreeFactory factory; + + const std::string xml_text = R"( + + +