#include #include #include #include #include #include #include #include #include namespace ecgp { namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; typedef std::pair string_pair; struct cxnblock { ecgp::string_pair evokespair; int type; }; } BOOST_FUSION_ADAPT_STRUCT( // global scope required ecgp::cxnblock, (ecgp::string_pair, evokespair) (int, type) ) namespace ecgp { template struct cxnblock_grammar : qi::grammar { cxnblock_grammar() : cxnblock_grammar::base_type(start) { using qi::int_; ewoks %= ascii::alnum >> ascii::alnum; start %= ewoks >> int_; } qi::rule ewoks; qi::rule start; }; } int main() { using boost::spirit::ascii::space; typedef std::string::const_iterator string_iterator; typedef ecgp::cxnblock_grammar cxnblock_grammar; cxnblock_grammar b; ecgp::cxnblock cxnblk; std::string str; str += "a b"; std::string::const_iterator iter = str.begin(); std::string::const_iterator end = str.end(); bool r = phrase_parse(iter, end, b, space, cxnblk); if (r && iter == end) { std::cout << "OK\n"; } else { std::string rest(iter, end); std::cout << "fail: " << rest << "\n"; } /* } */ return 0; }