促进精神船长问题
ROW intint [int, int]int [int, int]...
struct rowType{ unsigned int number; std::list<unsigned int> list;};
struct problemType{ unsigned int ROW; std::vector<rowType> rows;};
template<typename Iterator>struct row_parser : qi::grammar<Iterator, rowType(), qi::space_type>{ row_parser() : row_parser::base_type(start) { list = '[' >> -(qi::int_ % ',') >> ']'; start = qi::int_ >> list; } qi::rule<Iterator, rowType(), qi::space_type> start; qi::rule<Iterator, std::list<unsigned int>(), qi::space_type> list;};
template<typename Iterator>struct problem_parser : qi::grammar<Iterator,problemType(),qi::space_type>{ problem_parser() : problem_parser::base_type(start) { using boost::phoenix::bind; using qi::lit; start = qi::int_ >> lit('_') >> +(row); //BOOST_SPIRIT_DEBUG_NODE(start); } qi::rule<Iterator, problemType(),qi::space_type> start; row_parser<Iterator> row;};
main() {static const problem_parser<spirit::multi_pass<base_iterator_type> > p;...spirit::qi::phrase_parse(first, last , p, qi::space, pb);}
梦里花落0921
相关分类