Boost logo

Boost :

Subject: [boost] [Spirit X3] move_to
From: Mikhail Strelnikov (mikhail.strelnikov_at_[hidden])
Date: 2016-03-18 01:01:21


Hi,

I'm using Boost 1.60 with Spirit X3 from develop branch (because it has this
fix
<http://boost.2283326.n4.nabble.com/Single-element-attributes-in-X3-quot-still-quot-broken-td4681549.html>
).

If I change the rule from this:

auto a2 = rule<class i2, ast::a2>{} = a1 >> a2_v2;

to this:

auto a2 = rule<class i2, ast::a2>{} = a1 >> '(' >> a2_v2 >> ')';

it stops compiling (both gcc and clang) with error "no matching function
for call to 'move_to'".

Here is full source code:

#include <boost/spirit/home/x3.hpp>
#include <boost/spirit/home/x3/support/ast/variant.hpp>
#include <boost/fusion/include/define_struct_inline.hpp>

#include <string>
#include <vector>

namespace ast
{
    BOOST_FUSION_DEFINE_STRUCT_INLINE
    (
        a1,
        (std::string, v)
    )

    BOOST_FUSION_DEFINE_STRUCT_INLINE
    (
        a2,
        (a1, v1)
        (std::vector<double>, v2)
    )

    BOOST_FUSION_DEFINE_STRUCT_INLINE
    (
        a3,
        (std::vector<a2>, v1)
    )
}

using namespace boost::spirit::x3;

auto a0 = rule<class i0, std::string>{} = lexeme[+alpha];
auto a1 = rule<class i1, ast::a1>{} = a0;

auto a2_v2 = rule<class a2_v2, std::vector<double>>{} = -(double_ % ',');
auto a2 = rule<class i2, ast::a2>{} = a1 >> '(' >> a2_v2
>> ')';
//auto a2 = rule<class i2, ast::a2>{} = a1 >> a2_v2;

auto a3_v1 = rule<class a3_v1, std::vector<ast::a2>>{} = *(a2 >> ';');
auto a3 = rule<class i3, ast::a3>{} = a3_v1;

using data = ast::a3;

int main()
{
    std::string script = "";

    auto begin = script.begin();
    auto end = script.end();

    data v;

    bool ok = (boost::spirit::x3::phrase_parse(begin, end, a3, space, v) &&
begin == end);
}

Here is how it is compiled:

#!/bin/bash

wget --no-clobber
http://netcologne.dl.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.gz
tar -zxvf boost_1_60_0.tar.gz

wget --no-clobber https://github.com/boostorg/spirit/archive/develop.zip
unzip develop.zip

mv ./boost_1_60_0/boost/spirit ./boost_1_60_0/boost/spirit_old

g++ -std=c++14 test.cpp -I./spirit-develop/include/ -I./boost_1_60_0/ -o
test


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk