<i id='7qk1B'><tr id='7qk1B'><dt id='7qk1B'><q id='7qk1B'><span id='7qk1B'><b id='7qk1B'><form id='7qk1B'><ins id='7qk1B'></ins><ul id='7qk1B'></ul><sub id='7qk1B'></sub></form><legend id='7qk1B'></legend><bdo id='7qk1B'><pre id='7qk1B'><center id='7qk1B'></center></pre></bdo></b><th id='7qk1B'></th></span></q></dt></tr></i><div id='7qk1B'><tfoot id='7qk1B'></tfoot><dl id='7qk1B'><fieldset id='7qk1B'></fieldset></dl></div>

    • <bdo id='7qk1B'></bdo><ul id='7qk1B'></ul>
    <tfoot id='7qk1B'></tfoot>
    1. <small id='7qk1B'></small><noframes id='7qk1B'>

    2. <legend id='7qk1B'><style id='7qk1B'><dir id='7qk1B'><q id='7qk1B'></q></dir></style></legend>
    3. 我如何理解 boost 精神编译器错误

      How do I grok boost spirit compiler errors(我如何理解 boost 精神编译器错误)
        <tbody id='0Nk4X'></tbody>
      1. <legend id='0Nk4X'><style id='0Nk4X'><dir id='0Nk4X'><q id='0Nk4X'></q></dir></style></legend>

          <i id='0Nk4X'><tr id='0Nk4X'><dt id='0Nk4X'><q id='0Nk4X'><span id='0Nk4X'><b id='0Nk4X'><form id='0Nk4X'><ins id='0Nk4X'></ins><ul id='0Nk4X'></ul><sub id='0Nk4X'></sub></form><legend id='0Nk4X'></legend><bdo id='0Nk4X'><pre id='0Nk4X'><center id='0Nk4X'></center></pre></bdo></b><th id='0Nk4X'></th></span></q></dt></tr></i><div id='0Nk4X'><tfoot id='0Nk4X'></tfoot><dl id='0Nk4X'><fieldset id='0Nk4X'></fieldset></dl></div>

          • <tfoot id='0Nk4X'></tfoot>

                <bdo id='0Nk4X'></bdo><ul id='0Nk4X'></ul>
              • <small id='0Nk4X'></small><noframes id='0Nk4X'>

              • 本文介绍了我如何理解 boost 精神编译器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 no_skip 指令来解析表单的输入:

                state PASS<标签>状态失败

                我使用 ascii::blank 作为我的船长.当我包装 no_skip[ trans_assign_expr ] 以解析选项卡时出现编译错误.

                我该如何修复这个错误,一般来说,我如何理解这些错误以便我可以修复未来的错误?boost Spirit 文档从未涵盖使用 Spirit 的这一方面:(

                这是错误

                <前>在/usr/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18:0 包含的文件中,来自/usr/include/boost/spirit/include/qi_grammar.hpp:16,来自../src/RJstate.cpp:9:/usr/include/boost/spirit/home/qi/nonterminal/rule.hpp: 在成员函数 'bool boost::spirit::qi::rule::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&)const [with Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::detail::unused_skipper > >, Attribute = const boost::spirit::unused_type, Iterator = __gnu_cxx::__normal_iterator >, T1 = boost::proto::exprns_::expr >, 0l>, T2 = boost::spirit::unused_type, T3 = boost::spirit::unused_type, T4 = boost::spirit::unused_type]':/usr/include/boost/spirit/home/qi/reference.hpp:43:71: 从 'bool boost::spirit::qi::reference::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute& 实例化) const [with Iterator = __gnu_cxx::__normal_iterator >, Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::detail::unused_skipper > >, 属性= const boost::spirit::unused_type, Subject = const boost::spirit::qi::rule >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>]'/usr/include/boost/spirit/home/qi/directive/no_skip.hpp:64:63: 实例化自 'bool boost::spirit::qi::no_skip_directive::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Iterator = __gnu_cxx::__normal_iterator >, Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::char_class >, Attribute = constboost::spirit::unused_type, Subject = boost::spirit::qi::reference >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >]'/usr/include/boost/spirit/home/qi/detail/fail_function.hpp:45:74: 从 'bool boost::spirit::qi::detail::fail_function::operator()(const Component&) const 实例化[与 Component = boost::spirit::qi::no_skip_directive >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::Spirit::unused_type> > >, Iterator = __gnu_cxx::__normal_iterator >, Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::char_class >]'/usr/include/boost/fusion/algorithm/query/detail/any.hpp:42:83: [跳过8个实例化上下文]/usr/include/boost/function/function_template.hpp:132:42: 实例化自 'static R boost::detail::function::function_obj_invoker4::invoke(boost::detail::function::function_buffer&, T0, T1, T2, T3) [with FunctionObj = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::Spirit::unused_type、boost::spirit::unused_type>、boost::fusion::cons>、boost::proto::exprns_::expr>、0l>、boost::spirit::unused_type、boost::Spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const__gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&]'/usr/include/boost/function/function_template.hpp:913:60: 实例化自 'void boost::function4::assign_to(Functor) [with Functor = boost::spirit::qi::detail::parser_binder >,boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>, boost::fusion::cons >,boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil>> > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0>&, T3 = const boost::spirit::qi::char_class >&]'/usr/include/boost/function/function_template.hpp:722:7: 实例化自 'boost::function4::function4(Functor, typename boost::enable_if_c::value>::value, int>::type) [with Functor = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >, boost::fusion::cons >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, typename boost::enable_if_c::value>::value,int>::type = int]'/usr/include/boost/function/function_template.hpp:1064:16: 实例化自 'boost::function::function(Functor, typename boost::enable_if_c::value>::value, int>::type) [with Functor = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >, boost::fusion::cons >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, typename boost::enable_if_c::value>::value,int>::type = int]'/usr/include/boost/function/function_template.hpp:1105:5: 从 'typename boost::enable_if_c::value>::value, boost::function&>::type boost::function::operator=(Functor) [with Functor = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::未使用类型、boost::spirit::unused_type>、boost::fusion::cons>、boost::proto::exprns_::expr>、0l>、boost::spirit::unused_type、boost::spirit::未使用的类型,boost::spirit::unused_type> > >,boost::fusion::nil> > >,mpl_::bool_>,R = bool,T0 = __gnu_cxx::__normal_iterator >&,T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, typename boost::enable_if_c::value>::value, boost::function&>::type = boost::function >&, const __gnu_cxx::__normal_iterator >&, boost::spirit::context, boost::fusion::vector0 >&, const boost::spirit::qi::char_class >&)>&]'/usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:198:13: 从 'boost::spirit::qi::rule& boost::spirit::qi::rule::operator= 实例化(const Expr&) [with Expr = boost::proto::exprns_::expr >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>&, const boost::proto::exprns_::expr, 0l>&>, 2l>&, const boost::proto::exprns_::expr, 0l>&, boost::spirit::qi::rule >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>&>, 2l>&>, 2l>, Iterator = __gnu_cxx::__normal_iterator >, T1 = boost::proto::exprns_::expr >, 0l>, T2 = boost::spirit::unused_type, T3 = boost::Spirit::unused_type, T4 = boost::spirit::unused_type, boost::spirit::qi::rule = boost::spirit::qi::rule >, boost::proto::exprns_::expr >,0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>]'../src/RJstate.cpp:49:7: 实例化自‘fsm_grammar::fsm_grammar() [with Iterator = __gnu_cxx::__normal_iterator >, Skipper = boost::proto::exprns_::expr >, 0l>]’../src/RJstate.cpp:112:50:从这里实例化/usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:277:17: 错误:不匹配调用 '(const function_type {aka const boost::function >&, const __gnu_cxx::__normal_iterator >&, boost::spirit::context, boost::fusion::vector0 >&, const boost::spirit::qi::char_class >&)>}) (__gnu_cxx::__normal_iterator >&, const __gnu_cxx::__normal_iterator>&, boost::spirit::qi::rule >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>::context_type&, const boost::spirit::qi::detail::unused_skipper > >&)'/usr/include/boost/function/function_template.hpp:1043:7:注意:候选是:/usr/include/boost/function/function_template.hpp:1006:1: 注意:boost::function4::result_type boost::function4::operator()(T0, T1, T2, T3) const [with R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, boost::function4::result_type = bool]/usr/include/boost/function/function_template.hpp:1006:1: 注意:参数 4 从 'const boost::spirit::qi::detail::unused_skipper > >' 到 'const boost:: 没有已知的转换Spirit::qi::char_class >&'

                这是我的代码

                #define BOOST_SPIRIT_DEBUG#include #include <向量>#include <迭代器>#include <fstream>//转发到<boost/spirit/home/qi/nonterminal/grammar.hpp>#include //转发到<boost/spirit/home/qi/nonterminal/rule.hpp>#include #include #include #include #include #include "TestParser.hpp"///////////////////////////////////////////////////////////////////////////////命名空间 qi = boost::spirit::qi;命名空间 ascii = boost::spirit::ascii;template struct fsm_grammar : qi::grammar{fsm_grammar() : fsm_grammar::base_type(script){使用 boost::spirit::double_;使用 boost::spirit::ascii::char_;使用 boost::spirit::ascii::alnum;使用 boost::spirit::ascii::alpha;使用 boost::spirit::lit;使用 boost::spirit::qi::eol;使用 boost::spirit::qi::eoi;使用 boost::spirit::lexeme;使用 boost::spirit::qi::no_skip;使用 boost::spirit::qi::_1;使用 boost::spirit::qi::_val;//id = char_("a-zA-Z")[_val += _1] >>*char_("a-zA-Z_0-9")[_val += _1];id = lexeme[ alpha[_val += _1] >>*alnum[_val += _1] >>!alnum ];state_id = "状态" >>ID;start_expr = "开始" >>ID;trans_assign_expr = lit("	") >>state_id >>+(char_('a','z'));trans_expr = state_id >>>>no_skip[ trans_assign_expr ];assign_expr = char_("a-zA-Z");states_list = "状态" >>+(id);expr = (trans_expr | start_expr | states_list) >>+eol;脚本 = *expr >>EO;BOOST_SPIRIT_DEBUG_NODE(脚本);BOOST_SPIRIT_DEBUG_NODE(states_list);BOOST_SPIRIT_DEBUG_NODE(expr);BOOST_SPIRIT_DEBUG_NODE(start_expr);BOOST_SPIRIT_DEBUG_NODE(assign_expr);BOOST_SPIRIT_DEBUG_NODE(trans_expr);BOOST_SPIRIT_DEBUG_NODE(trans_assign_expr);BOOST_SPIRIT_DEBUG_NODE(state_id);BOOST_SPIRIT_DEBUG_NODE(id);std::string val = "通过";//test_parser(" ",+char_("a-zA-Z"));}qi::rule<Iterator, Skipper>脚本;qi::rule<Iterator, Skipper>状态列表;qi::rule<Iterator, Skipper>表达式;qi::rule<Iterator, Skipper>反式表达式;qi::rule<Iterator, Skipper>trans_assign_expr;qi::rule<Iterator, Skipper>赋值表达式;qi::rule<Iterator, Skipper>开始表达式;qi::rule<Iterator, Skipper>state_id;qi::rule<Iterator, std::string()>ID;};

                解决方案

                正如 llonesmiz 非常恰当地指出的:

                • 寻找静态断言(****** 像这样在错误 'novel' ****** 中)
                • 在失败"行上方直接(我的意思是直接)查找评论.这包括触发模板实例化的点.

                  <块引用>

                  如果您在此处看到编译错误,指出无法将第四个参数转换为所需的目标类型,那么您可能正在尝试使用不兼容的船长类型的规则或语法.

                  在这种情况下,由于您想使用 trans_assign_expr 而没有船长,您必须声明它没有:

                  //没有船长qi::rule<Iterator, std::string()>ID;qi::rule<迭代器>state_id;qi::rule<迭代器>trans_assign_expr;

                这使它编译.不过,输出表明它不/work/.

                我不相信这是您想要做的.由于 lexeme 在这里似乎是更好的选择,无论如何.我会简化 id 规则:

                id = lexeme [ alpha >>*编号];

                lexeme 已经具有本地禁用正在使用的 Skipper 的属性.

                这里的语法略有变化http://liveworkspace.org/code/70f3319342c5678504b16一>

                trans_assign_expr = state_id >>+(char_('a','z'));trans_expr = state_id >>no_skip [ eol >>'	'] >>trans_assign_expr;

                如您所见,我将 with eol 包含在 no_skip 中(以避免船长吃掉标签).这样,船长在 trans_assign_expr仍然有效 - 这使它接受额外的空间.给定输入

                const char input[]="state PASS
                	 state FAIL more";

                现在输出

                真的

                I am trying to use the no_skip directive to parse input of the form:

                state PASS
                <tab> state FAIL
                

                I am using ascii::blank as my skipper. I get an compile error when I wrap no_skip[ trans_assign_expr ] to parse for the tab.

                How do I fix this error, and in general, how do I understand these errors so that I can fix future ones? The boost spirit documentation never covers this aspect of using spirit :(

                This is the error

                In file included from /usr/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18:0,
                                 from /usr/include/boost/spirit/include/qi_grammar.hpp:16,
                                 from ../src/RJstate.cpp:9:
                /usr/include/boost/spirit/home/qi/nonterminal/rule.hpp: In member function ‘bool boost::spirit::qi::rule::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::detail::unused_skipper > >, Attribute = const boost::spirit::unused_type, Iterator = __gnu_cxx::__normal_iterator >, T1 = boost::proto::exprns_::expr >, 0l>, T2 = boost::spirit::unused_type, T3 = boost::spirit::unused_type, T4 = boost::spirit::unused_type]’:
                /usr/include/boost/spirit/home/qi/reference.hpp:43:71:   instantiated from ‘bool boost::spirit::qi::reference::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Iterator = __gnu_cxx::__normal_iterator >, Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::detail::unused_skipper > >, Attribute = const boost::spirit::unused_type, Subject = const boost::spirit::qi::rule >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>]’
                /usr/include/boost/spirit/home/qi/directive/no_skip.hpp:64:63:   instantiated from ‘bool boost::spirit::qi::no_skip_directive::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Iterator = __gnu_cxx::__normal_iterator >, Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::char_class >, Attribute = const boost::spirit::unused_type, Subject = boost::spirit::qi::reference >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >]’
                /usr/include/boost/spirit/home/qi/detail/fail_function.hpp:45:74:   instantiated from ‘bool boost::spirit::qi::detail::fail_function::operator()(const Component&) const [with Component = boost::spirit::qi::no_skip_directive >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, Iterator = __gnu_cxx::__normal_iterator >, Context = boost::spirit::context, boost::fusion::vector0 >, Skipper = boost::spirit::qi::char_class >]’
                /usr/include/boost/fusion/algorithm/query/detail/any.hpp:42:83:   [ skipping 8 instantiation contexts ]
                /usr/include/boost/function/function_template.hpp:132:42:   instantiated from ‘static R boost::detail::function::function_obj_invoker4::invoke(boost::detail::function::function_buffer&, T0, T1, T2, T3) [with FunctionObj = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >, boost::fusion::cons >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&]’
                /usr/include/boost/function/function_template.hpp:913:60:   instantiated from ‘void boost::function4::assign_to(Functor) [with Functor = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >, boost::fusion::cons >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&]’
                /usr/include/boost/function/function_template.hpp:722:7:   instantiated from ‘boost::function4::function4(Functor, typename boost::enable_if_c::value>::value, int>::type) [with Functor = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >, boost::fusion::cons >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, typename boost::enable_if_c::value>::value, int>::type = int]’
                /usr/include/boost/function/function_template.hpp:1064:16:   instantiated from ‘boost::function::function(Functor, typename boost::enable_if_c::value>::value, int>::type) [with Functor = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >, boost::fusion::cons >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, typename boost::enable_if_c::value>::value, int>::type = int]’
                /usr/include/boost/function/function_template.hpp:1105:5:   instantiated from ‘typename boost::enable_if_c::value>::value, boost::function&>::type boost::function::operator=(Functor) [with Functor = boost::spirit::qi::detail::parser_binder >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> >, boost::fusion::cons >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type> > >, boost::fusion::nil> > > >, mpl_::bool_ >, R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, typename boost::enable_if_c::value>::value, boost::function&>::type = boost::function >&, const __gnu_cxx::__normal_iterator >&, boost::spirit::context, boost::fusion::vector0 >&, const boost::spirit::qi::char_class >&)>&]’
                /usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:198:13:   instantiated from ‘boost::spirit::qi::rule& boost::spirit::qi::rule::operator=(const Expr&) [with Expr = boost::proto::exprns_::expr >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>&, const boost::proto::exprns_::expr, 0l>&>, 2l>&, const boost::proto::exprns_::expr, 0l>&, boost::spirit::qi::rule >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>&>, 2l>&>, 2l>, Iterator = __gnu_cxx::__normal_iterator >, T1 = boost::proto::exprns_::expr >, 0l>, T2 = boost::spirit::unused_type, T3 = boost::spirit::unused_type, T4 = boost::spirit::unused_type, boost::spirit::qi::rule = boost::spirit::qi::rule >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>]’
                ../src/RJstate.cpp:49:7:   instantiated from ‘fsm_grammar::fsm_grammar() [with Iterator = __gnu_cxx::__normal_iterator >, Skipper = boost::proto::exprns_::expr >, 0l>]’
                ../src/RJstate.cpp:112:50:   instantiated from here
                /usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:277:17: error: no match for call to ‘(const function_type {aka const boost::function >&, const __gnu_cxx::__normal_iterator >&, boost::spirit::context, boost::fusion::vector0 >&, const boost::spirit::qi::char_class >&)>}) (__gnu_cxx::__normal_iterator >&, const __gnu_cxx::__normal_iterator >&, boost::spirit::qi::rule >, boost::proto::exprns_::expr >, 0l>, boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>::context_type&, const boost::spirit::qi::detail::unused_skipper > >&)’
                /usr/include/boost/function/function_template.hpp:1043:7: note: candidate is:
                /usr/include/boost/function/function_template.hpp:1006:1: note: boost::function4::result_type boost::function4::operator()(T0, T1, T2, T3) const [with R = bool, T0 = __gnu_cxx::__normal_iterator >&, T1 = const __gnu_cxx::__normal_iterator >&, T2 = boost::spirit::context, boost::fusion::vector0 >&, T3 = const boost::spirit::qi::char_class >&, boost::function4::result_type = bool]
                /usr/include/boost/function/function_template.hpp:1006:1: note:   no known conversion for argument 4 from ‘const boost::spirit::qi::detail::unused_skipper > >’ to ‘const boost::spirit::qi::char_class >&’
                

                This is my code

                #define BOOST_SPIRIT_DEBUG
                
                #include <iostream>
                #include <vector>
                #include <iterator>
                #include <fstream>
                
                // forwards to <boost/spirit/home/qi/nonterminal/grammar.hpp>
                #include <boost/spirit/include/qi_grammar.hpp>
                // forwards to <boost/spirit/home/qi/nonterminal/rule.hpp>
                #include <boost/spirit/include/qi_rule.hpp>
                
                #include <boost/spirit/include/qi.hpp>
                
                #include <boost/spirit/include/qi_char_class.hpp>
                #include <boost/spirit/include/qi_no_skip.hpp>
                
                #include <boost/spirit/include/phoenix.hpp>
                
                #include "TestParser.hpp"
                
                ///////////////////////////////////////////////////////////////////////////////
                
                namespace qi = boost::spirit::qi;
                namespace ascii = boost::spirit::ascii;
                
                template <typename Iterator, typename Skipper=qi::space_type>
                struct fsm_grammar : qi::grammar<Iterator, Skipper>
                {
                   fsm_grammar() : fsm_grammar::base_type(script)
                   {
                      using boost::spirit::double_;
                      using boost::spirit::ascii::char_;
                      using boost::spirit::ascii::alnum;
                      using boost::spirit::ascii::alpha;
                      using boost::spirit::lit;
                      using boost::spirit::qi::eol;
                      using boost::spirit::qi::eoi;
                      using boost::spirit::lexeme;
                      using boost::spirit::qi::no_skip;
                      using boost::spirit::qi::_1;
                      using boost::spirit::qi::_val;
                
                      //id = char_("a-zA-Z")[_val += _1] >> *char_("a-zA-Z_0-9")[_val += _1];
                      id = lexeme[ alpha[_val += _1] >> *alnum[_val += _1] >> !alnum ];
                      state_id = "state" >> id;
                      start_expr = "start" >> id;
                      trans_assign_expr = lit("	") >> state_id >> +(char_('a','z'));
                      trans_expr = state_id >> eol >> no_skip[ trans_assign_expr ];
                      assign_expr = char_("a-zA-Z");
                      states_list = "states" >> +(id);
                      expr = (trans_expr | start_expr | states_list) >> +eol;
                      script = *expr >> eoi;
                
                      BOOST_SPIRIT_DEBUG_NODE(script);
                      BOOST_SPIRIT_DEBUG_NODE(states_list);
                      BOOST_SPIRIT_DEBUG_NODE(expr);
                      BOOST_SPIRIT_DEBUG_NODE(start_expr);
                      BOOST_SPIRIT_DEBUG_NODE(assign_expr);
                      BOOST_SPIRIT_DEBUG_NODE(trans_expr);
                      BOOST_SPIRIT_DEBUG_NODE(trans_assign_expr);
                      BOOST_SPIRIT_DEBUG_NODE(state_id);
                      BOOST_SPIRIT_DEBUG_NODE(id);
                
                      std::string val = "PASS";
                      //test_parser("  ",+char_("a-zA-Z"));
                   }
                
                   qi::rule<Iterator, Skipper> script;
                   qi::rule<Iterator, Skipper> states_list;
                   qi::rule<Iterator, Skipper> expr;
                   qi::rule<Iterator, Skipper> trans_expr;
                   qi::rule<Iterator, Skipper> trans_assign_expr;
                   qi::rule<Iterator, Skipper> assign_expr;
                   qi::rule<Iterator, Skipper> start_expr;
                   qi::rule<Iterator, Skipper> state_id;
                   qi::rule<Iterator, std::string()> id;
                };
                

                解决方案

                As llonesmiz very aptly pointed out:

                • look for static asserts (****** like this in the error 'novel' ******)
                • look for comments directly (I mean, directly) above a 'failing' line. This includes the points at which template instantiations were triggered.

                  If you are seeing a compilation error here stating that the forth parameter can't be converted to a required target type then you are probably trying to use a rule or a grammar with an incompatible skipper type.

                  In this case, since you want to use trans_assign_expr without a skipper, you must declare it without one:

                  // no skippers
                  qi::rule<Iterator, std::string()> id;
                  qi::rule<Iterator> state_id;
                  qi::rule<Iterator> trans_assign_expr;
                  

                This makes it compile. The output suggests it doesn't /work/, though.

                I'm not convinced this is what you want to do. Since lexeme seems to be a better option here, anyway. I'd simplify the id rule:

                id = lexeme [ alpha >> *alnum ];
                

                lexeme already has the property of locally disabling the Skipper in use.

                Here is a slight change of the grammar http://liveworkspace.org/code/70f3319342c567854b9f785ac13508d6

                trans_assign_expr = state_id >> +(char_('a','z'));
                trans_expr        = state_id >> no_skip [ eol >> '	' ] >> trans_assign_expr;
                

                As you can see, I include the with eol in a no_skip (to avoid the skipper eating the tab). This way, the skipper is still in effect in trans_assign_expr - which makes it accept the extra space. Given the input

                const char input[]="state PASS
                	 state FAIL more";
                

                The output is now

                <script>
                  <try>state PASS
                	 state F</try>
                  <expr>
                    <try>state PASS
                	 state F</try>
                    <trans_expr>
                      <try>state PASS
                	 state F</try>
                      <state_id>
                        <try>state PASS
                	 state F</try>
                        <id>
                          <try> PASS
                	 state FAIL m</try>
                          <success>
                	 state FAIL more
                </success>
                          <attributes>[[P, A, S, S]]</attributes>
                        </id>
                        <success>
                	 state FAIL more
                </success>
                        <attributes>[]</attributes>
                      </state_id>
                      <trans_assign_expr>
                        <try> state FAIL more
                </try>
                        <state_id>
                          <try> state FAIL more
                </try>
                          <id>
                            <try> FAIL more
                </try>
                            <success> more
                </success>
                            <attributes>[[F, A, I, L]]</attributes>
                          </id>
                          <success> more
                </success>
                          <attributes>[]</attributes>
                        </state_id>
                        <success>
                </success>
                        <attributes>[]</attributes>
                      </trans_assign_expr>
                      <success>
                </success>
                      <attributes>[]</attributes>
                    </trans_expr>
                    <success></success>
                    <attributes>[]</attributes>
                  </expr>
                  <expr>
                    <try></try>
                    <trans_expr>
                      <try></try>
                      <state_id>
                        <try></try>
                        <fail/>
                      </state_id>
                      <fail/>
                    </trans_expr>
                    <start_expr>
                      <try></try>
                      <fail/>
                    </start_expr>
                    <states_list>
                      <try></try>
                      <fail/>
                    </states_list>
                    <fail/>
                  </expr>
                  <success></success>
                  <attributes>[]</attributes>
                </script>
                true
                

                这篇关于我如何理解 boost 精神编译器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to limit the number of running instances in C++(C++中如何限制运行实例的数量)
                Using boost::asio::async_read with stdin?(将 boost::asio::async_read 与 stdin 一起使用?)
                How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?(如何找出特定 Boost 库需要哪些依赖项(即其他 Boost 库)?)
                What#39;s the purpose of a leading quot;::quot; in a C++ method call(引导“::的目的是什么?在 C++ 方法调用中)
                Boost Spirit x3: parse into structs(Boost Spirit x3:解析为结构体)
                How boost auto-linking makes choice?(boost自动链接如何做出选择?)

                    • <small id='vdBPJ'></small><noframes id='vdBPJ'>

                      • <bdo id='vdBPJ'></bdo><ul id='vdBPJ'></ul>
                          <tbody id='vdBPJ'></tbody>
                      • <legend id='vdBPJ'><style id='vdBPJ'><dir id='vdBPJ'><q id='vdBPJ'></q></dir></style></legend>
                          <tfoot id='vdBPJ'></tfoot>

                        1. <i id='vdBPJ'><tr id='vdBPJ'><dt id='vdBPJ'><q id='vdBPJ'><span id='vdBPJ'><b id='vdBPJ'><form id='vdBPJ'><ins id='vdBPJ'></ins><ul id='vdBPJ'></ul><sub id='vdBPJ'></sub></form><legend id='vdBPJ'></legend><bdo id='vdBPJ'><pre id='vdBPJ'><center id='vdBPJ'></center></pre></bdo></b><th id='vdBPJ'></th></span></q></dt></tr></i><div id='vdBPJ'><tfoot id='vdBPJ'></tfoot><dl id='vdBPJ'><fieldset id='vdBPJ'></fieldset></dl></div>