精神不能自动分配属性单元素结构(或融合序列) [英] Spirit unable to assign attribute to single-element struct (or fusion sequence)
问题描述
我的目标是有我的齐::语法
返回属性。我有一个精神做这显著困难::词法
虽然。
我期望与下面给定的语法,如果我把它叫做精神::气::解析(开始,结束,语法,输出);
,该结构的ident输出
将有语义分析的内容。
的错误似乎大多流出来这行:启动(%)= lexer.identifier;
系统注
- 升压1.47.0
- 的Mac OS X 10.7.2
- 铛++或g ++(如下图所示的错误是从铛++)
编译命令
G ++ -g -c -O0 -Wall -DBOOST_SPIRIT_DEBUG -DBOOST_SPIRIT_LEXERTL_DEBUG -DBOOST_SPIRIT_USE_PHOENIX_V3 -DBOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT reduced.cpp
来源$ C $ C
的#include<升压/融合/有/ adapt_struct.hpp>#包括LT&;升压/精神/家庭/ lex.hpp>
#包括LT&;升压/精神的/ home /法/词法/ lexertl / lexer.hpp>
#包括LT&;升压/精神/家庭/ qi.hpp>命名空间的精神=提振精神::;结构IDENT {
性病::字符串值;
};BOOST_FUSION_ADAPT_STRUCT(IDENT,
(标准::字符串,值)
)结构my_lexer:精神:: ::法词法<精神:: ::法:: lexertl&actor_lexer LT;> > {
精神:: ::法与token_def LT;标准::字符串>标识符;
};结构my_grammar:精神::补气::语法< my_lexer :: iterator_type,IDENT()> {
my_grammar(常量my_lexer&安培;词法分析器):my_grammar :: base_type(开始){
启动(%)= lexer.identifier;
} 精神::齐::规则< my_lexer :: iterator_type,IDENT()>开始;
};
2的错误报道
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:38:24:错误:没有匹配的构造函数'的ident'的初始化
ATTR =属性(第一个,最后一个);
^ ~~~~~~~~~~~
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:94:13:注意:在成员函数'的boost ::精神特质:: :: assign_to_attribute_from_iterators&LT的实例; IDENT,字符常量*
无效> ::通话这里要求
致电(第一,最后,attr)使用;
^
在文件从../reduced-example/reduced.cpp:4包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/lexer.hpp:20包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/token.hpp:530:13:注意:在函数模板专业化的实例化的boost ::精神::性状: :assign_to<字符常量*,IDENT>'
这里要求
精神::特点:: assign_to(t.value()开始(),t.value()结束(),ATTR);
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:330:59:注意:在成员函数的实例化的boost ::精神特质:: :: assign_to_attribute_from_value< IDENT,
提振::精神::法:: lexertl ::令牌LT;字符常量*,提振:: MPL :: vector0< MPL _ ::呐>中MPL _ :: bool_< 1>中unsigned long类型>中无效> ::通话这里要求
assign_to_attribute_from_value<属性,T> ::调用(VAL,attr)使用;
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:353:9:注意:在函数模板专业化实例
的boost ::精神特质:: ::详细:: assign_to<的boost ::精神:: ::法:: lexertl令牌LT;字符常量*,提振:: MPL :: vector0< MPL _ ::呐>中mpl_ :: bool_< 1>中unsigned long类型>中的ident>'这里要求
细节:: assign_to(VAL,ATTR,is_not_wrapped_container());
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:106:21:注意:在函数模板专业化实例
的boost ::精神::特点:: assign_to<的boost ::精神::法:: lexertl ::令牌LT;字符常量*,提振:: MPL :: vector0< MPL _ ::呐>中MPL _ :: bool_< 1&GT ;,无符号长>中的ident>'这里要求
精神::特点:: assign_to(T,attr)使用;
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:21包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/reference.hpp:16包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/reference.hpp:43:20:注:(跳过在回溯5上下文;使用-ftemplate-回溯极限= 0查看所有)
返回ref.get()解析(第一个,最后,背景,船长,attr)使用。
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:16包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/function.hpp:64包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/$p$pprocessor/iteration/detail/iter/forward1.hpp:67包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/function/detail/function_iterate.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/function/detail/maybe_include.hpp:33包括:
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1042:5:注意:在函数模板专业化的实例化的boost :: function4< BOOL,
boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中
lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT; &安培;, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*
提高:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT 1为卤素; &GT; &GT;常量和放大器;,提振精神:: ::背景下&;提高::融合::利弊&LT;&IDENT放大器;,
提高::融合::零&gt;中的boost ::融合:: vector0&LT;无效&GT; &GT; &放;,提振精神:: :: unused_type常量
&>::function4<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>,字符型,无符号长&GT;常量,无符号长&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT;'
这里要求
base_type(F)
^
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1083:5:注意:在函数模板特殊化'的boost ::功能和LT的实例;布尔
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中
lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT; &安培;, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*
提高:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT 1为卤素; &GT; &GT;常量和放大器;,提振精神:: ::背景下&;提高::融合::利弊&LT;&IDENT放大器;,
提高::融合::零&gt;中的boost ::融合:: vector0&LT;无效&GT; &GT; &放;,提振精神:: :: unused_type常量
&)>::function<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>,字符型,无符号长&GT;常量,无符号长&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT;'
这里要求
self_type(F).swap(*此);
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:182:19:注意:在函数模板特殊化'的boost ::功能和LT的实例;布尔
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中
lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT; &安培;, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*
提高:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT 1为卤素; &GT; &GT;常量和放大器;,提振精神:: ::背景下&;提高::融合::利弊&LT;&IDENT放大器;,
提高::融合::零&gt;中的boost ::融合:: vector0&LT;无效&GT; &GT; &放;,提振精神:: :: unused_type常量
&)>::operator=<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>,字符型,无符号长&GT;常量,无符号长&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT;'
这里要求
lhs.f =细节:: bind_parser&LT;自动&GT;(
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:230:13:注意:在函数模板专业化实例
'boost::spirit::qi::rule<boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中无符号
长&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &gt;中IDENT()的boost ::精神:: unused_type,提振精神:: :: unused_type,提振精神:: :: unused_type&GT; ::定义&LT; MPL _ :: bool_&LT; 1&gt;中
提振精神:: :: ::法与token_def LT;的std :: basic_string的&LT;焦炭&gt;中焦,无符号长&GT; &GT;'这里要求
定义&LT; MPL :: true_&GT;(R,EXPR,特点::火柴&LT;气虚::域,EXPR&GT;());
^
../reduced-example/reduced.cpp:23:9:注意:在函数模板专业化的实例化的boost ::精神::齐::操作符%=&LT;的boost ::精神:: ::法与token_def LT; STD :: basic_string的&LT;焦炭&gt;中焦,无符号长&GT; &GT;'
这里要求
启动(%)= lexer.identifier;
^
../reduced-example/reduced.cpp:9:8:注意:候选构造函数(隐含的默认构造函数)不可行的:需要0参数,但提供了2
结构IDENT {
^
../reduced-example/reduced.cpp:9:8:注意:候选构造函数(隐式拷贝构造函数)不可行的:需要1个参数,但提供了2
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:17包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/parser.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/domain.hpp:18包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/context.hpp:18包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/nonterminal/expand_arg.hpp:20包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/string_traits.hpp:16包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/container.hpp:368:22:错误:没有成员名为'的ident''空'
返回c.empty();
〜^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/container.hpp:375:47:注意:在成员函数'的boost ::精神特质:: :: is_empty_container&LT的实例; IDENT,无效&GT; ::通话这里要求
返回is_empty_container&LT;集装箱&GT; ::调用(C);
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:37:17:注意:在函数模板专业化的实例化的boost ::精神特质:: :: is_empty&LT ; IDENT&GT;'这里要求
如果(::特质is_empty(attr)使用)
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:94:13:注意:在成员函数'的boost ::精神特质:: :: assign_to_attribute_from_iterators&LT的实例; IDENT,字符常量*
无效&GT; ::通话这里要求
致电(第一,最后,attr)使用;
^
在文件从../reduced-example/reduced.cpp:4包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/lexer.hpp:20包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/token.hpp:530:13:注意:在函数模板专业化的实例化的boost ::精神::性状: :assign_to&LT;字符常量*,IDENT&GT;'
这里要求
精神::特点:: assign_to(t.value()开始(),t.value()结束(),ATTR);
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:330:59:注意:在成员函数的实例化的boost ::精神特质:: :: assign_to_attribute_from_value&LT; IDENT,
提振::精神::法:: lexertl ::令牌LT;字符常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中无效&GT; ::通话这里要求
assign_to_attribute_from_value&LT;属性,T&GT; ::调用(VAL,attr)使用;
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:353:9:注:(跳过在回溯7环境;使用-ftemplate-回溯极限= 0查看全部)
细节:: assign_to(VAL,ATTR,is_not_wrapped_container());
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:16包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/function.hpp:64包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/$p$pprocessor/iteration/detail/iter/forward1.hpp:67包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/function/detail/function_iterate.hpp:14包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/function/detail/maybe_include.hpp:33包括:
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1042:5:注意:在函数模板专业化的实例化的boost :: function4&LT; BOOL,
boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中
lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT; &安培;, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*
提高:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT 1为卤素; &GT; &GT;常量和放大器;,提振精神:: ::背景下&;提高::融合::利弊&LT;&IDENT放大器;,
提高::融合::零&gt;中的boost ::融合:: vector0&LT;无效&GT; &GT; &放;,提振精神:: :: unused_type常量
&>::function4<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>,字符型,无符号长&GT;常量,无符号长&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT;'
这里要求
base_type(F)
^
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1083:5:注意:在函数模板特殊化'的boost ::功能和LT的实例;布尔
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中
lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT; &安培;, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*
提高:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT 1为卤素; &GT; &GT;常量和放大器;,提振精神:: ::背景下&;提高::融合::利弊&LT;&IDENT放大器;,
提高::融合::零&gt;中的boost ::融合:: vector0&LT;无效&GT; &GT; &放;,提振精神:: :: unused_type常量
&)>::function<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>,字符型,无符号长&GT;常量,无符号长&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT;'
这里要求
self_type(F).swap(*此);
^
在文件从../reduced-example/reduced.cpp:3包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15包括:
在文件从/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18包括:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:182:19:注意:在函数模板特殊化'的boost ::功能和LT的实例;布尔
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中
lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT; &安培;, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*
提高:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中unsigned long类型&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT 1为卤素; &GT; &GT;常量和放大器;,提振精神:: ::背景下&;提高::融合::利弊&LT;&IDENT放大器;,
提高::融合::零&gt;中的boost ::融合:: vector0&LT;无效&GT; &GT; &放;,提振精神:: :: unused_type常量
&)>::operator=<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>,字符型,无符号长&GT;常量,无符号长&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &GT;'
这里要求
lhs.f =细节:: bind_parser&LT;自动&GT;(
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:230:13:注意:在函数模板专业化实例
'boost::spirit::qi::rule<boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char常量*,提振:: MPL :: vector0&LT; MPL _ ::呐&gt;中MPL _ :: bool_&LT; 1&gt;中无符号
长&gt;中lexertl ::详细::数据,字符常量*,MPL _ :: bool_&LT; 1&gt;中MPL _ :: bool_&LT; 1 GT; &GT; &gt;中IDENT()的boost ::精神:: unused_type,提振精神:: :: unused_type,提振精神:: :: unused_type&GT; ::定义&LT; MPL _ :: bool_&LT; 1&gt;中
提振精神:: :: ::法与token_def LT;的std :: basic_string的&LT;焦炭&gt;中焦,无符号长&GT; &GT;'这里要求
定义&LT; MPL :: true_&GT;(R,EXPR,特点::火柴&LT;气虚::域,EXPR&GT;());
^
../reduced-example/reduced.cpp:23:9:注意:在函数模板专业化的实例化的boost ::精神::齐::操作符%=&LT;的boost ::精神:: ::法与token_def LT; STD :: basic_string的&LT;焦炭&gt;中焦,无符号长&GT; &GT;'
这里要求
启动(%)= lexer.identifier;
^
我最终意识到,我所定义的结构是在精神上被用作一个元组。因为精神将尽量减少群体(比如,一个可选&LT; INT,INT&GT;
是可选&LT; INT&GT;
)。因此,我猜测,一个元组LT; A&GT;
将被转换为 A
。这似乎是这种情况。
我能破code的测试用例进一步减少为以下内容:
的#include&LT;升压/融合/有/ adapt_struct.hpp&GT;
#包括LT&;升压/精神/家庭/ qi.hpp&GT;
#包括LT&;串GT;结构IDENT {
性病::串;
};BOOST_FUSION_ADAPT_STRUCT(IDENT,
(标准::字符串,一)
)诠释主(){
提振精神:: ::气::规则&LT;为const char * IDENT()&GT; - [R;
R =的boost ::精神::语义[ABC];
}
从下面的邮件列表的帖子(的 1 ,<一个href=\"http://boost.2283326.n4.nabble.com/Spirit-Qi-Adapted-struct-with-single-std-string-member-gives-error-value-type-is-not-a-member-of-Strt-td2715434.html\"相对=nofollow> 2 ),我发现,我可以解决此问题做:
R =的boost ::精神::语义[ABC]&GT;&GT;提振精神:: :: EPS;
虽然算不上高雅,但它至少解决了这个问题。如果别人有做单一元素结构的方法,我会非常感兴趣,但。
My goal is to have my qi::grammar
return an attribute. I'm having significant difficulty doing this with a spirit::lexer
though.
I'd expect that with the given grammar below, if I called it with spirit::qi::parse(begin, end, grammar, output);
, that the struct ident output
would have the contents of the parsed lexeme.
The error seems to mostly flow out of this line: start %= lexer.identifier;
System Notes
- Boost 1.47.0
- Mac OS X 10.7.2
- clang++ or g++ (errors shown below are from clang++)
Compile Command
g++ -g -c -O0 -Wall -DBOOST_SPIRIT_DEBUG -DBOOST_SPIRIT_LEXERTL_DEBUG -DBOOST_SPIRIT_USE_PHOENIX_V3 -DBOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT reduced.cpp
Source Code
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/home/lex.hpp>
#include <boost/spirit/home/lex/lexer/lexertl/lexer.hpp>
#include <boost/spirit/home/qi.hpp>
namespace spirit = boost::spirit;
struct ident {
std::string value;
};
BOOST_FUSION_ADAPT_STRUCT(ident,
(std::string, value)
)
struct my_lexer : spirit::lex::lexer< spirit::lex::lexertl::actor_lexer<> > {
spirit::lex::token_def<std::string> identifier;
};
struct my_grammar : spirit::qi::grammar<my_lexer::iterator_type, ident()> {
my_grammar(const my_lexer & lexer) : my_grammar::base_type(start) {
start %= lexer.identifier;
}
spirit::qi::rule<my_lexer::iterator_type, ident()> start;
};
2 Errors Reported
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:38:24: error: no matching constructor for initialization of 'ident'
attr = Attribute(first, last);
^ ~~~~~~~~~~~
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:94:13: note: in instantiation of member function 'boost::spirit::traits::assign_to_attribute_from_iterators<ident, char const *,
void>::call' requested here
call(first, last, attr);
^
In file included from ../reduced-example/reduced.cpp:4:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/lexer.hpp:20:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/token.hpp:530:13: note: in instantiation of function template specialization 'boost::spirit::traits::assign_to<char const *, ident>'
requested here
spirit::traits::assign_to(t.value().begin(), t.value().end(), attr);
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:330:59: note: in instantiation of member function 'boost::spirit::traits::assign_to_attribute_from_value<ident,
boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, void>::call' requested here
assign_to_attribute_from_value<Attribute, T>::call(val, attr);
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:353:9: note: in instantiation of function template specialization
'boost::spirit::traits::detail::assign_to<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, ident>' requested here
detail::assign_to(val, attr, is_not_wrapped_container());
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:106:21: note: in instantiation of function template specialization
'boost::spirit::traits::assign_to<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, ident>' requested here
spirit::traits::assign_to(t, attr);
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:21:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/reference.hpp:16:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/reference.hpp:43:20: note: (skipping 5 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
return ref.get().parse(first, last, context, skipper, attr);
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:16:
In file included from /home/wlynch/Boost/1.47.0/include/boost/function.hpp:64:
In file included from /home/wlynch/Boost/1.47.0/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:67:
In file included from /home/wlynch/Boost/1.47.0/include/boost/function/detail/function_iterate.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/function/detail/maybe_include.hpp:33:
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1042:5: note: in instantiation of function template specialization 'boost::function4<bool,
boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>,
lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > &, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *,
boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > const &, boost::spirit::context<boost::fusion::cons<ident &,
boost::fusion::nil>, boost::fusion::vector0<void> > &, boost::spirit::unused_type const
&>::function4<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> const, unsigned long>, mpl_::bool_<1> > >'
requested here
base_type(f)
^
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1083:5: note: in instantiation of function template specialization 'boost::function<bool
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>,
lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > &, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *,
boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > const &, boost::spirit::context<boost::fusion::cons<ident &,
boost::fusion::nil>, boost::fusion::vector0<void> > &, boost::spirit::unused_type const
&)>::function<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> const, unsigned long>, mpl_::bool_<1> > >'
requested here
self_type(f).swap(*this);
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:182:19: note: in instantiation of function template specialization 'boost::function<bool
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>,
lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > &, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *,
boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > const &, boost::spirit::context<boost::fusion::cons<ident &,
boost::fusion::nil>, boost::fusion::vector0<void> > &, boost::spirit::unused_type const
&)>::operator=<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> const, unsigned long>, mpl_::bool_<1> > >'
requested here
lhs.f = detail::bind_parser<Auto>(
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:230:13: note: in instantiation of function template specialization
'boost::spirit::qi::rule<boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned
long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > >, ident (), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>::define<mpl_::bool_<1>,
boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> >' requested here
define<mpl::true_>(r, expr, traits::matches<qi::domain, Expr>());
^
../reduced-example/reduced.cpp:23:9: note: in instantiation of function template specialization 'boost::spirit::qi::operator%=<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> >'
requested here
start %= lexer.identifier;
^
../reduced-example/reduced.cpp:9:8: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 2 were provided
struct ident {
^
../reduced-example/reduced.cpp:9:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:17:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/parser.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/domain.hpp:18:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/context.hpp:18:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/nonterminal/expand_arg.hpp:20:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/string_traits.hpp:16:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/container.hpp:368:22: error: no member named 'empty' in 'ident'
return c.empty();
~ ^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/support/container.hpp:375:47: note: in instantiation of member function 'boost::spirit::traits::is_empty_container<ident, void>::call' requested here
return is_empty_container<Container>::call(c);
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:37:17: note: in instantiation of function template specialization 'boost::spirit::traits::is_empty<ident>' requested here
if (traits::is_empty(attr))
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:94:13: note: in instantiation of member function 'boost::spirit::traits::assign_to_attribute_from_iterators<ident, char const *,
void>::call' requested here
call(first, last, attr);
^
In file included from ../reduced-example/reduced.cpp:4:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/lexer.hpp:20:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/lexertl/token.hpp:530:13: note: in instantiation of function template specialization 'boost::spirit::traits::assign_to<char const *, ident>'
requested here
spirit::traits::assign_to(t.value().begin(), t.value().end(), attr);
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:13:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/lexer/token_def.hpp:20:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:330:59: note: in instantiation of member function 'boost::spirit::traits::assign_to_attribute_from_value<ident,
boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, void>::call' requested here
assign_to_attribute_from_value<Attribute, T>::call(val, attr);
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/detail/assign_to.hpp:353:9: note: (skipping 7 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
detail::assign_to(val, attr, is_not_wrapped_container());
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:16:
In file included from /home/wlynch/Boost/1.47.0/include/boost/function.hpp:64:
In file included from /home/wlynch/Boost/1.47.0/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:67:
In file included from /home/wlynch/Boost/1.47.0/include/boost/function/detail/function_iterate.hpp:14:
In file included from /home/wlynch/Boost/1.47.0/include/boost/function/detail/maybe_include.hpp:33:
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1042:5: note: in instantiation of function template specialization 'boost::function4<bool,
boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>,
lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > &, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *,
boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > const &, boost::spirit::context<boost::fusion::cons<ident &,
boost::fusion::nil>, boost::fusion::vector0<void> > &, boost::spirit::unused_type const
&>::function4<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> const, unsigned long>, mpl_::bool_<1> > >'
requested here
base_type(f)
^
/home/wlynch/Boost/1.47.0/include/boost/function/function_template.hpp:1083:5: note: in instantiation of function template specialization 'boost::function<bool
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>,
lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > &, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *,
boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > const &, boost::spirit::context<boost::fusion::cons<ident &,
boost::fusion::nil>, boost::fusion::vector0<void> > &, boost::spirit::unused_type const
&)>::function<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> const, unsigned long>, mpl_::bool_<1> > >'
requested here
self_type(f).swap(*this);
^
In file included from ../reduced-example/reduced.cpp:3:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/lex/tokenize_and_parse.hpp:15:
In file included from /home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/grammar.hpp:18:
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:182:19: note: in instantiation of function template specialization 'boost::function<bool
(boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>,
lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > &, boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *,
boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > > const &, boost::spirit::context<boost::fusion::cons<ident &,
boost::fusion::nil>, boost::fusion::vector0<void> > &, boost::spirit::unused_type const
&)>::operator=<boost::spirit::qi::detail::parser_binder<boost::spirit::lex::reference<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> const, unsigned long>, mpl_::bool_<1> > >'
requested here
lhs.f = detail::bind_parser<Auto>(
^
/home/wlynch/Boost/1.47.0/include/boost/spirit/home/qi/nonterminal/rule.hpp:230:13: note: in instantiation of function template specialization
'boost::spirit::qi::rule<boost::spirit::lex::lexertl::iterator<boost::spirit::lex::lexertl::functor<boost::spirit::lex::lexertl::token<char const *, boost::mpl::vector0<mpl_::na>, mpl_::bool_<1>, unsigned
long>, lexertl::detail::data, char const *, mpl_::bool_<1>, mpl_::bool_<1> > >, ident (), boost::spirit::unused_type, boost::spirit::unused_type, boost::spirit::unused_type>::define<mpl_::bool_<1>,
boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> >' requested here
define<mpl::true_>(r, expr, traits::matches<qi::domain, Expr>());
^
../reduced-example/reduced.cpp:23:9: note: in instantiation of function template specialization 'boost::spirit::qi::operator%=<boost::spirit::lex::token_def<std::basic_string<char>, char, unsigned long> >'
requested here
start %= lexer.identifier;
^
I ended up realizing that the struct I defined is being used in spirit as a tuple. Because spirit will try to minimize the groups (like, an optional<int, int>
is an optional<int>
). Therefore, I guessed that a tuple<A>
will be converted to an A
. Which seems to be the case.
I was able to further reduce the test case of broken code to the following:
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/home/qi.hpp>
#include <string>
struct ident {
std::string a;
};
BOOST_FUSION_ADAPT_STRUCT(ident,
(std::string, a)
)
int main() {
boost::spirit::qi::rule<const char*, ident()> r;
r = boost::spirit::lexeme["abc"];
}
From the following mailing list postings (1, 2) that I found, I can work around this issue by doing:
r = boost::spirit::lexeme["abc"] >> boost::spirit::eps;
While not really elegant, it solves the problem at least. If someone else has a method to do the single element struct, I'd be greatly interested though.
这篇关于精神不能自动分配属性单元素结构(或融合序列)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!