/* * Lisp top level read-eval-print loop * Don Hopkins */ #include "lisp.h" /* * Top level read-eval-print loop. Upon entry, set up longjmp warm * start vector, initialize lisp, and push to the input stream * lisp-init.l. Upon warm start (when longjmp(Top_Level, 1) is * executed in abort()), set input and output streams back to what * they originally were, and initialize Ob_List, Ob_Stack, and * Back_Trace. */ main() { object obj; if(setjmp(Top_Level)) { while (Output_Stack != Nil) pop_output(); while (Input_Stack != Nil) pop_input(); Ob_List = Nil; Ob_Stack = Nil; Back_Trace = Nil; Ob_Push(); fputs("\n<* Lisp warm started. *>\n*\n", Output_File); } else { initialize(); Ob_Push(); fputs("\n<* Lisp initialized. *>\n", Output_File); if (push_stream(&Input_Stack, &Input_File, make_atom(LISP_INIT_FILE), "r") != Nil) fprintf(Output_File, "<* Reading from %s ... *>\n", LISP_INIT_FILE); } while (1) { fflush(Output_File); Ob_Save(obj = sread()); if (Input_Stack != Nil) { read_line(); } Ob_Save(obj = eval(obj)); fputs("==> ", Output_File); printcr(obj); fputs("*\n", Output_File); Ob_Unbind(); Ob_Unbind(); } }