/* main - the main routine */ main(argc,argv) int argc; char *argv[]; { char *transcript; CONTEXT cntxt; int verbose,i; LVAL expr; /* setup default argument values */ transcript = NULL; verbose = FALSE; /* parse the argument list switches */ #ifndef LSC for (i = 1; i < argc; ++i) if (argv[i][0] == '-') switch(argv[i][1]) { case 't': case 'T': transcript = &argv[i][2]; break; case 'v': case 'V': verbose = TRUE; break; } #endif /* initialize and print the banner line */ osinit(BANNER); /* setup initialization error handler */ xlbegin(&cntxt, CF_TOPLEVEL|CF_CLEANUP|CF_BRKLEVEL,(LVAL)1); if (setjmp(cntxt.c_jmpbuf)) xlfatal("fatal initialization error"); if (setjmp(top_level)) xlfatal("RESTORE not allowed during initialization"); /* initialize xlisp */ xlinit(); xlend(&cntxt); /* reset the error handler */ xlbegin(&cntxt,CF_TOPLEVEL|CF_CLEANUP|CF_BRKLEVEL,true); /* open the transcript file */ if (transcript && (tfp = osaopen(transcript,"w")) == NULL) { sprintf(buf,"error: can't open transcript file: %s", transcript); stdputstr(buf); } /* load "init.lsp" */ if (setjmp(cntxt.c_jmpbuf) == 0) xlload("init.lsp",TRUE,FALSE); /* load any files mentioned on the command line */ if (setjmp(cntxt.c_jmpbuf) == 0) for (i = 1; i < argc; i++) if (argv[i][0] != '-' && !xlload(argv[i],TRUE,verbose)) xlerror("can't load file",cvstring(argv[i])); /* target for restore */ if (setjmp(top_level)) xlbegin(&cntxt,CF_TOPLEVEL|CF_CLEANUP|CF_BRKLEVEL,true); /* protect some pointers */ xlsave1(expr); /* main command processing loop */ for (;;) { /* setup the error return */ if (setjmp(cntxt.c_jmpbuf)) { setvalue(s_evalhook,NIL); setvalue(s_applyhook,NIL); xltrcindent = 0; xldebug = 0; xlflush(); } /* print a prompt */ stdputstr("> "); /* read an expression */ if (!xlread(getvalue(s_stdin),&expr,FALSE)) break; /* save the input expression */ xlrdsave(expr); /* evaluate the expression */ expr = xleval(expr); /* save the result */ xlevsave(expr); /* print it */ stdprint(expr); } xlend(&cntxt); /* clean up */ wrapup(); }lispのインタプリタ(解釈・実行部)はこのように,キーボードからの文字列 を入力(read)し,それをLispの式として解釈・実行(eval)し,結果を出力 (print)することを繰り返し行なっています. Xlispでの read, eval, printのそれぞれを以下に見てみることにします.