BSD 4 release
[unix-history] / usr / src / cmd / lisp / lisp.c
CommitLineData
31cef89c
BJ
1static char *sccsid = "@(#)lisp.c 34.1 10/3/80";
2
a22cc832
JF
3#include "global.h"
4
5/* main *****************************************************************/
6/* Execution of the lisp system begins here. This is the top level */
7/* executor which is an infinite loop. The structure is similar to */
8/* error. */
9
10extern char _sobuf[];
11extern lispval reborn;
12extern int rlevel;
13static int virgin = 0;
14int Xargc;
15char **Xargv;
31cef89c 16extern int environ;
a22cc832 17
31cef89c 18main(argc,argv,arge)
a22cc832
JF
19char **argv;
20{
21 lispval temp, matom();
22 extern int errp;
31cef89c
BJ
23 extern int holbeg,holend,usehole;
24 extern int *curhbeg;
25
a22cc832
JF
26 snpand(0);
27
31cef89c 28 environ = arge;
a22cc832
JF
29 setbuf(stdout,_sobuf);
30 Xargc = argc;
31 Xargv = argv;
32 virgin = 0;
33 initial();
34/* printf("poport = 0%o\n",poport); */
35 while(retval = setexit())
36 switch (retval) {
37
38 case BRGOTO: error("GOTO LABEL NOT FOUND",FALSE);
39
40 case BRRETN: error("NO PROG TO RETURN FROM",FALSE);
41
42 case BRRETB:
43 default: popnames(orgbnp);
44
45 }
46 for(EVER) {
47 lbot = np = orgnp;
48 rlevel = 0;
49 depth = 0;
50 errp = 0;
51 clearerr(piport = stdin);
52 clearerr(poport = stdout);
53 np++->val = matom("top-level");
54 np++->val = nil;
55 Lapply();
56 }
57}
58Ntpl()
59{
31cef89c 60 lispval Lread(),Istsrch();
a22cc832
JF
61 snpand(0);
62
63 if (virgin == 0) {
31cef89c 64 fputs(Istsrch(matom("version"))->d.cdr->d.cdr->d.cdr,poport);
a22cc832
JF
65 virgin = 1;
66 }
67 lbot = np;
68 np++->val = P(stdin);
69 np++->val = eofa;
70 while (TRUE)
71 {
72 fputs("\n-> ",stdout);
73 dmpport(stdout);
74 vtemp = Lread();
75 if(vtemp == eofa) exit(0);
76 printr(eval(vtemp),stdout);
77 }
78 }
79
31cef89c 80#ifndef VMS
a22cc832
JF
81exit(code)
82{
83 extern int fvirgin;
84 extern char *stabf;
85 if(!fvirgin) unlink(stabf);
86 _cleanup();
87 proflush();
88 _exit(code);
89}
31cef89c 90#endif