#include "parser.h" #include "expression.h" #include "safe_int.h" #include #include #include using namespace std; int main() { Parser* parser = Parser::get_parser(); istream_iterator in(cin); try { ExpressionPtr root = parser->parse(in); cout << root->eval() << endl; } catch (const Parser::BadInput& e) { cout << e.get_message() << endl; return 1; } catch (const safe_int::divide_by_zero& e) { cout << "Divide by zero" << endl; return 1; } catch (const safe_int::overflow& e) { cout << "Overflow" << endl; return 1; } catch (const safe_int::underflow& e) { cout << "Underflow" << endl; return 1; } return 0; }