#include "boost/spirit/core.hpp" using namespace boost::spirit; #include #include using namespace std; struct expr_grammar : public grammar { static const int escaped_expr_id = 1; template struct definition { definition(expr_grammar const& self) { escaped_expr = ch_p('{') >> ch_p('}') ; } rule > escaped_expr; rule const& start() const { return escaped_expr; } }; }; int main() { cout << "Type an expression...or [q or Q] to quit\n\n"; expr_grammar g; string str; while (getline(cin, str)) { if (str[0] == 'q' || str[0] == 'Q') break; parse_info<> info = parse(str.c_str(), g, space_p); if (info.full) cout << "Parsing succeeded\n"; else cout << "Parsing failed\n"; } return 0; }