// Arithmetic interpreter main program. // // File: interpreter.cc // Author: course // Version: 2 // // This file defines the arithmetic interpreter main // program. // #include "lexeme.h" #include "parser.h" int main () { enable_out_of_memory_error(true); for (;;) { init_lexemes(); init_avalues(); if (setjmp (error_jmp)) { // Come here if an error occurs, // after the error message is printed. cout << "\n"; flush_lexemes(); continue; } cout << "Please enter your program, " << "ending with a '" << EOF_MARKER << "'.\n" << "Type ^D to quit.\n\n"; if (end_lexemes()) break; avalue result = program(); // program() may write to cout, so it must // be finished before next statement begins. cout << "\nValue:\n" << result << "\n\n"; } return 0; }