#include #include using namespace boost::spirit; using namespace boost; using namespace std; struct record_grammar:public grammar{ template struct definition{ rule identifier; rule string_literal; rule prop_decl; rule prop_list; rule record_list; rule record; definition(const record_grammar &self){ identifier = lexeme_d[ alpha_p >> *(alnum_p | ch_p('_') ) ]; string_literal = lexeme_d[ ch_p('"') >> *( (anychar_p - ch_p('"') ) | str_p("\\\"") ) >> ch_p('"') ]; prop_decl = identifier >> ch_p('=') >> string_literal; prop_list = prop_decl >> *(ch_p(',') >> prop_decl); record_list = record >> *(ch_p(',') >> record); record = identifier >> identifier >> ch_p('{') >> !( ( prop_list >> !(ch_p(',') >> record_list) ) | record_list ) >> ch_p('}'); }; rule const& start(){return record_list;} }; }; int main(){ string input; string temp; while(getline(cin, temp)){ input += temp; } record_grammar g; parse_info<> info = parse(input.c_str(), g, space_p); if(!info.full){ cout << "Error found at location: " << info.stop << endl; }else{ cout << "Success!" << endl; } }