3

Why this does not compile? (commented r3 will compile, but I want semicolon in the rule)

#include <boost/spirit/home/x3.hpp>
#include <boost/fusion/include/adapt_struct.hpp>

#include <string>
#include <vector>

struct v
{
    std::string value;
};

BOOST_FUSION_ADAPT_STRUCT
(
    v,
    (std::string, value)
)

using namespace boost::spirit::x3;

auto r1 = rule<struct s1, std::string>{} = lexeme[+alpha];

auto r2 = rule<struct s2, v>{} = r1;

using ast = std::vector<v>;

auto r3 = rule<struct s3, ast>{} = *(r2 >> ';');
//auto r3 = rule<struct s3, ast>{} = *r2;

int main()
{
    std::string script("a;");
    auto begin = script.begin();
    auto   end = script.end();

    ast a;

    phrase_parse(begin, end, r3, space, a);

    return a.size();
}
sms
  • 1,014
  • 10
  • 20
  • 1
    Seems like the same bug described [here](http://boost.2283326.n4.nabble.com/Single-element-attributes-in-X3-still-broken-tp4681549p4682073.html) which is [fixed in develop/master](https://github.com/boostorg/spirit/commit/a8e391bd99dddb3f9ece84bdb1bb9236b0a37cf7) and will be in boost 1.61. (I hope this is an appropriate comment, if it isn't I'll remove it) – llonesmiz Mar 16 '16 at 04:51
  • @jv_ This answers my question, thank you! – sms Mar 16 '16 at 11:15
  • @sms Were you able to solve the problem then? Maybe you could write an answer describing what you did so that the question does not remain unanswered. I'll upvote it. – llonesmiz Mar 16 '16 at 11:59

1 Answers1

5

As @jv_ suggested, I've downloaded develop branch. After that the code worked without any changes.

sms
  • 1,014
  • 10
  • 20