KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have trouble with boost spirit skippers. I need to parse a file like that : ROW int int [int, int] int [int, int] ... I am able to parse it without problem (thanks to stackoverflow ;) only if I add an '_' after the first int. In fact, I think the skipper eat the end of line after the first int, so the first and second (on second line) look as only one int. I don't understand how to keep eol but eat spaces. I've found examples to use a custom parser like here and here . I tried qi::blank, custom parser with one single rule lit(' ') No matter what skipper I use, space and eol are always eat. My grammar is : a line : struct rowType { unsigned int number; std::list<unsigned int> list; }; the full problem stored in a structure : struct problemType { unsigned int ROW; std::vector<rowType> rows; }; the row parser : 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; }; and the problem parser : 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('_') >>
Tags (comma-separated)
Save Edits
Cancel