Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X3: Kleene star can't into single-element sequence #178

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Commits on Mar 19, 2016

  1. Kleene star can't into single-element sequence

    This will fail to compile with error "'value_type': is not a member of 'ast::a3'".
    
    
    #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 a1 = rule<class i1, ast::a1>{} = lexeme[+alpha];
    
    auto a2 = rule<class i2, ast::a2>{} = a1 >> '(' >> -(double_ % ',') >> ')';
    
    auto a3 = rule<class i3, ast::a3>{} = *(a2 >> ';');
    
    using data = ast::a3;
    
    int main()
    {
        std::string script = "foo(1,2,3);";
    
        auto begin = script.begin();
        auto   end = script.end();
    
        data v;
    
        bool ok = (boost::spirit::x3::phrase_parse(begin, end, a3, space, v) && begin == end);
    }
    
    
    Fixed by adding container_value specialization: for single-element fusion sequence return container_value of that one element.
    hia3 committed Mar 19, 2016
    Configuration menu
    Copy the full SHA
    efd9493 View commit details
    Browse the repository at this point in the history