// LISP Interpreter Main Program // // File: lisp.cc // Author: course // Version: 1 #include "lisp.h" #include "obtype.h" #include "prims.h" #include // The LISP local variable environment. // object * environment = NIL; // Input and output streams. All input and output must // use these: e.g., as in *out << "Hello there!" << // endl; // estream * in; ostream * out; // Macros to write messages to screen. // static inline void welcome() { cout << "Welcome to lisp51, Lisp-in-C++." << endl; } static inline void goodbye() { cout << endl << "Goodbye." << endl; } // Function to initialize LISP interpreter data // structures. // static void initialize_data(); // main -- arranges for all the initializations and // then calls the read-eval-print loop // main() { welcome(); enable_out_of_memory_error (true); out = &cout; initialize_data(); // Setup LISP data structures. { // Load in lisp51.lsp if it exits. // ifstream * input = new ifstream ( "lisp51.lsp" ); if (*input) { in = new estream (*input, *out); in->echo (false); toplevel (true, true); // Silent, stop on error. delete in; } delete input; } in = &ein; toplevel (false, false); // Noisy, continue on error. goodbye(); return 0; } // initialize_data --- Init the Interpreter data // structures. // void initialize_data () { // Initialize object management. preserve_stack::initialize(); initialize_all_object_types(); // Preserve all symbols that now exist. // preserve_all_existing_symbols(); // Initialize primitive functions. // initialize_primitive_functions(); // Initialize the environment and catch_area stack. // environment = NIL; catch_area::initialize(); }