我有一个奇怪的麻烦:
qi::rule <Iterator, std::string ()> str = +alnum;
// will not parse given input
//param = "WELL" >> space >> str >> ((space >> no_case[control]) || (space >> no_case[limit])) >> space >> qi::eol;
// will parse given input ok
param = "WELL" >> space >> +alnum >> ((space >> no_case[control]) || (space >> no_case[limit])) >> space >> qi::eol;
expression = qi::no_skip[param];
输入为“WELL name3 PROD OIL \n”。control 和 limit 是符号表。
我做错了什么?
更新:
定义 BOOST_SPIRIT_QI_DEBUG 并在表达式之前使用 BOOST_SPIRIT_DEBUG_NODE (param) 如果使用 str ,我会得到以下输出:
<param>
<try>WELL name3 PROD OIL </try>
Segmentation fault
在 +alnum 的情况下,我得到:
<param>
<try>WELL name3 PROD OIL </try>
<success></success>
<attributes>[]</attributes>
</param>
回溯:
<param>
<try>WELL name3 PROD OIL </try>
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff64db290 in boost::function4<bool, char*&, char* const&, boost::spirit::context<boost::fusion::cons<std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::fusion::nil>, boost::fusion::vector0<void> >&, boost::spirit::unused_type const&>::operator() (this=
0x7fffffffd700, a0=@0x7fffffffd2d0, a1=@0x7fffffffda20, a2=..., a3=...)
at /opt/libs/boost/boost/function/function_template.hpp:1013
1013 (this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);