Getting Error: error C2039: 'value_type' : is not a member of 'ebnf::Production_type' ./container.hpp 117

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting Error: error C2039: 'value_type' : is not a member of 'ebnf::Production_type' ./container.hpp 117

grandpsykick

In the code I'vd posted below, when I compile, I get the error: error C2039: 'value_type' : is not a member of 'ebnf::Production_type' ./container.hpp 117 

I'm using Boost 1.56.0, windows, visual studio 2012. I am relatively new to this library so, detailed help would be appreciated. 

---------------------------------------------------------- 
#ifndef _EBNF_PARSER_HPP_ 
#define _EBNF_PARSER_HPP_ 

#include <boost\config\warning_disable.hpp>
#include <boost\spirit\include\qi.hpp>
#include <boost\fusion\adapted\std_pair.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/variant/recursive_variant.hpp>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>

namespace ebnf 
{ 
    struct Production_type 
    { 
        bool Nonterminal; 
        bool Repeat; 
        bool Alternative; 
        bool Pad; 
        unsigned MinRepeat; 
        unsigned MaxRepeat; 
        std::string String; 
        std::vector<Production_type> Child; 
    }; 
} 

// Making BOOST aware of the internal structure of "Production_type" 
BOOST_FUSION_ADAPT_STRUCT(ebnf::Production_type, 
                          (bool, Nonterminal) 
                          (bool, Repeat) 
                          (bool, Alternative) 
                          (bool, Pad) 
                          (unsigned, MinRepeat) 
                          (unsigned, MaxRepeat) 
                          (std::string, String) 
                          (std::vector<ebnf::Production_type>, Child)) 

namespace ebnf 
{ 
    /// Lowering BOOST scopes 
    namespace spirit = boost::spirit; 
    namespace qi     = spirit::qi; 
    namespace ascii  = spirit::ascii; 
    namespace phx    = boost::phoenix; 

    /// Renaming complex types 
    typedef std::pair<std::string, Production_type> Rule_type; 
    typedef std::map<std::string, Production_type>  Grammar_type; 

    /// Definition of Metafunctions 
    //--------------------------------------------------------------------------------------// 
    struct push_alternative_type 
    { 
        template<typename, typename>
        struct result {typedef void type;}; 

        void operator()(Production_type & rule, const Production_type & subrule) const 
        { 
            rule.Nonterminal = false; 
            rule.Repeat      = false; 
            rule.Alternative = true; 
            rule.Pad         = false; 
            rule.MinRepeat   = 0; 
            rule.MaxRepeat   = 0; 
            rule.String      = ""; 
            rule.Child.push_back(subrule); 
        } 
    }; 

    struct make_nil_type 
    { 
        template<typename>
        struct result {typedef void type;}; 

        void operator()(Production_type & rule) const 
        { 
            rule.Nonterminal = false; 
            rule.Repeat      = false; 
            rule.Alternative = false; 
            rule.Pad         = false; 
            rule.MinRepeat   = 0; 
            rule.MaxRepeat   = 0; 
            rule.String      = ""; 
        } 
    }; 

    struct make_terminal_type 
    { 
        template<typename, typename, typename>
        struct result {typedef void type;}; 

        void operator()(Production_type & rule, const std::string & terminal, bool isLiteral) const 
        { 
            rule.Nonterminal = false; 
            rule.Repeat      = false; 
            rule.Alternative = false; 
            rule.Pad         = isLiteral; 
            rule.MinRepeat   = 0; 
            rule.MaxRepeat   = 0; 
            rule.String      = terminal; 
        } 
    }; 

    struct make_nonterminal_type 
    { 
        template<typename, typename>
        struct result {typedef void type;}; 

        void operator()(Production_type & rule, const std::string & nonterminal) const 
        { 
            rule.Nonterminal = true; 
            rule.Repeat      = false; 
            rule.Alternative = false; 
            rule.Pad         = true; 
            rule.MinRepeat   = 0; 
            rule.MaxRepeat   = 0; 
            rule.String      = nonterminal; 
        } 
    }; 

    struct make_repeat_type 
    { 
        template<typename, typename, typename, typename>
        struct result {typedef Production_type type;}; 

        Production_type operator()(Production_type & rule, const Production_type & subrule, 
                                   unsigned min, unsigned max) const 
        { 
            rule.Nonterminal = false; 
            rule.Repeat      = true; 
            rule.Alternative = false; 
            rule.Pad         = false; 
            rule.MinRepeat   = min; 
            rule.MaxRepeat   = max; 
            rule.String      = ""; 
            rule.Child.push_back(subrule); 
        } 
    }; 

    struct push_subrule_type 
    { 
        template<typename, typename>
        struct result {typedef void type;}; 

        void operator()(Production_type & rule, const Production_type & subrule) const 
        { 
            rule.Nonterminal = false; 
            rule.Repeat      = false; 
            rule.Alternative = false; 
            rule.Pad         = false; 
            rule.MinRepeat   = 0; 
            rule.MaxRepeat   = 0; 
            rule.String      = ""; 
            rule.Child.push_back(subrule); 
        } 
    }; 

    struct error_handler_type 
    { 
        template<typename, typename, typename>
        struct result {typedef void type;}; 

        template<typename Iterator>
        void operator()(const qi::info & what, Iterator err_pos, Iterator last) const 
        { 
            std::cout << "Error! Expecting " 
                      << what << " || Found: \"" 
                      << std::string(err_pos, last) 
                      << "\"" << std::endl; 
        } 
    }; 

    /// Wrapping metafunction in Phoenix actors 
    const phx::function<push_alternative_type> push_alternative = push_alternative_type(); 
    const phx::function<make_nil_type> make_nil = make_nil_type(); 
    const phx::function<make_terminal_type> make_terminal = make_terminal_type(); 
    const phx::function<make_nonterminal_type> make_nonterminal = make_nonterminal_type(); 
    const phx::function<make_repeat_type> make_repeat = make_repeat_type(); 
    const phx::function<push_subrule_type> push_subrule = push_subrule_type(); 
    const phx::function<error_handler_type> error_handler = error_handler_type(); 
    //--------------------------------------------------------------------------------------// 

    /// Defining Spirit EBNF Parser 
    // NOTE: this is a subset of EBNF, execptions are not included 
    template<typename Iterator>
    struct parser : qi::grammar<Iterator, Grammar_type(), ascii::space_type>
    { 
        qi::rule<Iterator, Grammar_type(), ascii::space_type> syntax; 
        qi::rule<Iterator, Rule_type(), ascii::space_type> rule; 
        qi::rule<Iterator, Production_type(), ascii::space_type> definition; 
        qi::rule<Iterator, Production_type(), ascii::space_type> production; 
        qi::rule<Iterator, Production_type(), ascii::space_type> term; 
        qi::rule<Iterator, Production_type(), ascii::space_type> sequence; 
        qi::rule<Iterator, Production_type(), ascii::space_type> opt_sequence; 
        qi::rule<Iterator, Production_type(), ascii::space_type> rpt_sequence; 
        qi::rule<Iterator, Production_type(), ascii::space_type> rpt_0_sequence; 
        qi::rule<Iterator, Production_type(), ascii::space_type> rpt_1_sequence; 
        qi::rule<Iterator, Production_type(), ascii::space_type> spc_sequence; 
        qi::rule<Iterator, Production_type(), ascii::space_type> grp_sequence; 
        qi::rule<Iterator, std::string()> identifier; 
        qi::rule<Iterator, std::string()> terminal; 
        qi::rule<Iterator, std::string()> comment; 

        parser() : parser::base_type(syntax) 
        { 
            using qi::int_; 
            using qi::eps; 
            using qi::char_; 
            using qi::_1; 
            using qi::_2; 
            using qi::_3; 
            using qi::_4; 
            using qi::_val; 
            using qi::lit; 
            using phx::push_back; 
            using qi::on_error; 
            using qi::fail; 

            syntax         = +rule; 
            rule           = identifier > ":=" > definition > ';'; 
            definition     = production[push_alternative(_val, _1)] % '|'; 
            production     = +term[push_subrule(_val, _1)]; 
            term           = sequence | (int_ > '*' > sequence)[make_repeat(_val, _2, _1, _1)]; 
            sequence       = opt_sequence | rpt_sequence | grp_sequence | 
                             spc_sequence[make_terminal(_val, _1, true)] | 
                             identifier[make_nonterminal(_val, _1)] | 
                             terminal[make_terminal(_val, _1, true)] | 
                             eps[make_nil(_val)]; 
            opt_sequence   = lit('[') > definition[make_repeat(_val, _1, 0, 1)] > ']' | 
                             definition[make_repeat(_val, _1, 0, 1)] > lit('!') ; 
            rpt_sequence   = rpt_0_sequence | rpt_1_sequence; 
            rpt_0_sequence = lit('{') > definition[make_repeat(_val, _1, 0, 0)] > '}' | 
                             definition[make_repeat(_val, _1, 0, 0)] > lit('*'); 
            rpt_1_sequence = definition[make_repeat(_val, _1, 1, 0)] > lit('+'); 
            grp_sequence   = lit('(') > definition > ')'; 
            terminal       = lit('\'') > +(char_ - '\'') > '\'' | 
                             lit('"') > +(char_ - '"') > '"'; 
            identifier     = char_('<') > +(char_ - '>' - '<') > char_('>'); 
            spc_sequence   = lit('?') > +(char_ - '?') > '?'; 
            comment        = lit("(*") > *(char_ - "*)") > "*)"; 

            BOOST_SPIRIT_DEBUG_NODE(syntax); 
            BOOST_SPIRIT_DEBUG_NODE(rule); 
            BOOST_SPIRIT_DEBUG_NODE(definition); 
            BOOST_SPIRIT_DEBUG_NODE(production); 
            BOOST_SPIRIT_DEBUG_NODE(term); 
            BOOST_SPIRIT_DEBUG_NODE(sequence); 
            BOOST_SPIRIT_DEBUG_NODE(opt_sequence); 
            BOOST_SPIRIT_DEBUG_NODE(rpt_sequence); 
            BOOST_SPIRIT_DEBUG_NODE(rpt_0_sequence); 
            BOOST_SPIRIT_DEBUG_NODE(rpt_1_sequence); 
            BOOST_SPIRIT_DEBUG_NODE(spc_sequence); 
            BOOST_SPIRIT_DEBUG_NODE(grp_sequence); 
            BOOST_SPIRIT_DEBUG_NODE(identifier); 
            BOOST_SPIRIT_DEBUG_NODE(terminal); 
            BOOST_SPIRIT_DEBUG_NODE(comment); 

            on_error<fail>(syntax, error_handler(_4, _3, _2)); 
        } 
    }; 
} 

#endif // _EBNF_PARSER_HPP_ 
----------------------------------------------------------

 


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Getting Error: error C2039: 'value_type' : is not a member of 'ebnf::Production_type' ./container.hpp 117

Joel de Guzman
On 10/14/14, 1:34 AM, Price, Miles wrote:
> In the code I'vd posted below, when I compile, I get the error: error C2039: 'value_type'
> : is not a member of 'ebnf::Production_type' ./container.hpp 117
>
> I'm using Boost 1.56.0, windows, visual studio 2012. I am relatively new to this library
> so, detailed help would be appreciated.
>
[snip]

You might want to simplify your code as per support policy:
http://boost-spirit.com/home/feedback-and-support/

That will give you a better chance for others to investigate and
look into the code.

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Getting Error: error C2039: 'value_type' : is not a member of 'ebnf::Production_type' ./container.hpp 117

sehe
In reply to this post by grandpsykick
On 13-10-14 19:34, Price, Miles wrote:

I'm using Boost 1.56.0, windows, visual studio 2012. I am relatively new to this library so, detailed help would be appreciated. 
Many many things the matter her.

I suggest cutting all rule definitions and enabling one at a time checking what works.

Two things spotted in a flash:

  • all rules (well, nearly all) expose a Production_rule, while clearly not all of them produce attributes that are compatible with the fusion adaptation of such a rule, e.g.

            spc_sequence   = lit('?') > +(char_ - '?') > '?';  // synthesizes a `vector<char>`

       This is what yields the error message you cite (it's trying to treat the exposed attribute type as a container of `char` or compatible, and it's failing because it is not a container type).

  • note that automatic attribute propagation is automatically suppressed in the presence of Semantic Actions. This explains why some of those rules /do/ compile


  • your polymorphics functors should have same arity for the result_of protocol as for the invokation, e.g.

    struct make_terminal_type
    {
        template<typename, typename, typename>
        struct result {typedef void type;};

        template <typename Production_type, typename String, typename Bool>
        void operator()(Production_type & rule, const String & terminal, Bool isLiteral) const

  • your polymorphics functors should return a value unless declared void (make_repeat_type)

That should do for now. Minimize the code, take it step by step.

Good luck,
Seth


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general