-
Notifications
You must be signed in to change notification settings - Fork 25
Description
I'm trying to create a rule for a string consisting of specified substrings and I seem to fail with it. Here's a simplified example:
#include <iostream>
#include <boost/parser/parser.hpp>
using namespace std;
namespace bp = boost::parser;
namespace
{
namespace rule
{
constexpr boost::parser::rule<struct field_tag, string> field = "field";
constexpr auto field_def {*bp::string("AB")};
BOOST_PARSER_DEFINE_RULES(field);
}
}
int main()
{
string ret;
string input{"ABABABAB"};
const auto result{bp::parse(input, rule::field, ret)};
cout << "Parsed successfully: " << result << endl;
cout << "Result: \"" << ret << "\"" << endl;
return 0;
}It fails to compile for me both with g++-15 and clang++-20 (I tried both develop and master branches). If I get it right, the repetition (from *) should result in sequence of std::string attributes, which I expect to collapse to one std::string attribute of the rule itself.
Taking a look at the attribute generation rules I see there's no such exception for std::string directly, some similar exception concerns only char:
If C is exactly std::string, and T is either char or char32_t, the combination yields a std::string.
So I just wanted to ask if there's no such exception (for std::string sequence combined to single std::string) intentionally and I just miss something or that's something expected to work? Could you also please suggest a workaround, if possible, for such cases, when the grammar defines the form substrings being repeated? My real-world example is in fact parsing IPv6 address to a string.