// pe_driver.cpp : a postfix evaluator driver #include #include "Lexer.h" #include "term_control.h" #include "error_handling.h" #include "Postfix_Evaluator.h" using namespace std; /** * ----------------------------------------------------------------------------- * just print a prompt. * ----------------------------------------------------------------------------- */ void prompt() { cout << term_cc(BLUE) << "> " << term_cc() << flush; } /** * ----------------------------------------------------------------------------- * the body * ----------------------------------------------------------------------------- */ int main() { Lexer lexer; string line; Postfix_Evaluator pe; while (cin) { prompt(); getline(cin, line); lexer.set_input(line); if (!lexer.has_more_token()) continue; try { pe.set_expression(lexer); cout << term_cc(CYAN) << "= " << pe.eval() << term_cc() << endl; } catch (runtime_error &e) { error_return(e.what()); } } return 0; }