diff --git a/Makefile b/Makefile index b30d87d9..929fa5d3 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ EMULATOR ?= simh SRC = system syseng sysen1 sysen2 sysen3 sysnet kshack dragon channa \ midas _teco_ emacs emacs1 rms klh syshst sra mrc ksc eak gren \ bawden _mail_ l lisp liblsp libdoc comlap lspsrc nilcom rwk \ - inquir acount gz sys decsys ecc + inquir acount gz sys decsys ecc alan DOC = info _info_ sysdoc kshack _teco_ emacs emacs1 BIN = sysbin device emacs _teco_ inquir diff --git a/build/build.tcl b/build/build.tcl index 9579be62..0e8d4fb5 100644 --- a/build/build.tcl +++ b/build/build.tcl @@ -656,6 +656,7 @@ respond "*" ":link sys;atsign lisp,sys;purqio >\r" respond "*" ":link sys;ts l,sys;ts lisp\r" respond "*" ":link .info.;lisp step,.info.;step info\r" +respond "*" ":link libdoc;struct 280,alan;struct >\r" respond "*" ":link libdoc;struct doc,alan;struct doc\r" respond "*" ":link .info.;lisp struct,libdoc;struct doc\r" respond "*" ":link l;-read- -this-,lisp;-read- -this-\r" @@ -690,6 +691,7 @@ respond "*" ":link sys;.fasl defs,lisp;.fasl defs\r" respond "*" ":midas inquir;_lsrrtn\r" expect ":KILL" respond "*" ":link liblsp;debug fasl,liblsp;dbg fasl\r" +respond "*" ":link lisp;debug fasl,liblsp;debug fasl\r" respond "*" "complr\013" respond "_" "liblsp;_libdoc;tty\r" respond "_" "inquir;reader\r" @@ -702,11 +704,13 @@ respond "_" "lisp;_nilcom;evonce\r" respond "_" "inquir;inquir\r" respond "_" "\032" type ":kill\r" + respond "*" "complr\013" respond "_" "liblsp;_libdoc;dbg rwk1\r" respond "_" "liblsp;_libdoc;comrd kmp1\r" respond "_" "\032" type ":kill\r" + respond "*" ":lisp inquir;inquir (dump)\r" respond "*" ":link inquir;ts inquir,inquir;inqbin >\r" respond "*" ":link sys;ts inquir,inquir;ts inquir\r" @@ -759,8 +763,89 @@ respond "*" ":link sys1;ts s,sys;ts send\r" respond "*" ":link sys3;ts snd,sys;ts send\r" respond "*" ":link sys3;ts sned,sys;ts send\r" -# NICNAM +# more lisp packages +respond "*" ":link lisp;tty fasl,liblsp;tty fasl\r" +respond "*" "complr\013" +respond "_" "\007" +respond "*" "(load '((lisp) subloa lsp))" +respond "T" "(maklap)" +respond "_" "lisp;_lspsrc;funcel\r" +respond "_" "lisp;_lspsrc;bits\r" +respond "_" "lisp;_lspsrc;reap\r" +respond "_" "lisp;_lspsrc;lexprf\r" +respond "_" "lisp;_lspsrc;ldbhlp\r" +respond "_" "lisp;_nilcom;subloa\r" +respond "_" "\032" +type ":kill\r" +respond "*" "complr\013" +respond "_" "lisp;_nilcom;sharpa\r" +respond "_" "lisp;_nilcom;sharpc\r" +respond "_" "lisp;_nilcom;lsets\r" +respond "_" "lisp;_nilcom;drammp\r" +respond "(Y or N)" "Y" +respond "_" "\032" +type ":kill\r" + +respond "*" "complr\013" +respond "_" "\007" +respond "*" "(load '((lisp) subloa lsp))" +respond "T" "(maklap)" +respond "_" "lisp;_lspsrc;nilaid\r" +respond "_" "\032" +type ":kill\r" + +respond "*" "complr\013" +respond "_" "lisp;_libdoc;sharab\r" +respond "_" "lisp;_libdoc;bs\r" +respond "_" "\032" +type ":kill\r" + +respond "*" "complr\013" +respond "_" "\007" +respond "*" "(load '((lisp) subloa lsp))" +respond "T" "(maklap)" +respond "_" "lisp;_nilcom;thread\r" +respond "_" "\032" +type ":kill\r" + +respond "*" ":midas lisp;_l;lchnsp\r" +expect ":KILL" +respond "*" ":midas lisp;_l;purep\r" +expect ":KILL" + +# struct + +respond "*" ":link alan;dprint fasl,liblsp;dprint fasl\r" +respond "*" ":link alan;struct 9,alan;nstruc 280\r" +respond "*" ":copy liblsp;struct fasl,alan;struct boot\r" +respond "*" ":link alan;struct fasl,liblsp;struct fasl\r" +respond "*" "complr\013" +respond "_" "alan;lspcom\r" +respond "_" "alan;lspenv\r" +respond "_" "alan;lspint\r" +respond "_" "alan;setf\r" +respond "_" "alan;binda\r" +respond "_" "alan;crawl\r" +respond "_" "alan;nstruc 280\r" +respond "_" "\032" +type ":kill\r" +respond "*" ":copy alan;nstruc fasl,liblsp;struct fasl\r" +respond "*" ":link lisp;struct fasl,liblsp;struct fasl\r" + +respond "*" ":midas liblsp;_alan;macits\r" +expect ":KILL" + +#respond "*" "complr\013" +#respond "_" "alan;ljob\r" +#respond "_" "liblsp;_libdoc;gprint rcw3\r" +#respond "_" "alan;lspgub\r" +##source file is damaged +##respond "_" "alan;dprint\r" +#respond "_" "\032" +#type ":kill\r" + +# NICNAM respond "*" ":midas sys2;ts nicnam_sysen3;nicnam\r" expect ":KILL" diff --git a/src/alan/binda.46 b/src/alan/binda.46 new file mode 100755 index 00000000..56b8507d --- /dev/null +++ b/src/alan/binda.46 @@ -0,0 +1,221 @@ +;;;-*- Mode:Lisp; Package:SI -*- + +(declare (and (status feature maclisp) + (load '((alan) lspenv init)))) + +(declare (special *rest* *normal* *optional*)) + +(defun bind-arguments-&parse (pattern body) + (prog (pat x) + (setq pat pattern) + norm (cond ((atom pat) + (setq *rest* pat) + (return body))) + (setq x (car pat)) + (cond ((eq x '&optional) + (go opt)) + ((memq x '(&rest &body)) + (go rst)) + ((eq x '&aux) + (go ax))) + (push x *normal*) + (setq pat (cdr pat)) + (go norm) + opt (cond ((atom (setq pat (cdr pat))) + (setq *rest* pat) + (return body))) + (setq x (car pat)) + (cond ((eq x '&optional) + (go barf)) + ((memq x '(&rest &body)) + (go rst)) + ((eq x '&aux) + (go ax))) + (push (if (atom x) (list x) x) *optional*) + (go opt) + rst (if (atom (setq pat (cdr pat))) + (go barf)) + (setq *rest* (car pat)) + (if (null (setq pat (cdr pat))) + (return body)) + (if (or (atom pat) + (not (eq (car pat) '&aux))) + (go barf)) + ax (return + (do ((l (reverse (cdr pat)) (cdr l)) + (var) (val) + (body body `(((lambda (,var) ,@body) ,val)))) + ((null l) body) + (if (atom (car l)) + (setq var (car l) val nil) + (setq var (caar l) val (cadar l))))) + barf (ferror "Bad pattern: ~S" pattern))) + +(eval-when (eval compile) +(defmacro bind-arguments-ignorable (x) + `(memq ,x '(ignore ignored)))) + +(defun bind-arguments/ macro (x) + (bind-arguments (((pattern form &optional barf) &body body) (cdr x) + (error '|-- bad format.| x)) + (let ((body (bind-arguments-internal pattern form barf body))) + (if (null (cdr body)) + (car body) + `(progn ,@body))))) + +(defun bind-arguments-internal (pattern form barf body) + (cond + ((bind-arguments-ignorable pattern) `(,form ,@body)) + ((null pattern) `((or (null ,form) ,barf) ,@body)) + ((atom pattern) `(((lambda (,pattern) ,@body) ,form))) + (t + (let* ((*normal* nil) + (*optional* nil) + (*rest* nil) + (body (bind-arguments-&parse pattern body)) + (lst? (if (null *normal*) + (or (null *optional*) + (and (atom form) + (null *rest*) + (null (cdr *optional*)))) + (and (null *optional*) + (atom form) + (null *rest*) + (null (cdr *normal*))))) + (lst (if lst? form (gensym))) + (len? (or (null *optional*) + (and (null (cdr *optional*)) + (null *normal*) + (not (null *rest*))))) + (len (if len? `(length ,lst) (gensym))) + (barf (or barf `(ferror '|~S doesn't match pattern ~S| + ,lst ',pattern)))) + (setq body `(,@(bind-arguments-error-check len barf) + ,@(bind-arguments-internal-1 barf body lst len + #'bind-arguments-nth + #'bind-arguments-nthcdr))) + (or len? + (setq body `(((lambda (,len) ,@body) (length ,lst))))) + (if lst? + body + `(((lambda (,lst) ,@body) ,form))))))) + +(defun bind-arguments-internal-1 (barf body lst len ref-one ref-rest) + (let ((n (+ (length *normal*) (length *optional*)))) + (or (null *rest*) + (setq body + (bind-arguments-internal *rest* (funcall ref-rest n lst) + barf body))) + (dolist (opt *optional*) + (setq n (1- n)) + (cond ((cddr opt) + (setq body + `(((lambda (,(caddr opt)) + ,@(if (bind-arguments-ignorable (car opt)) + body + (bind-arguments-internal + (car opt) + `(cond (,(caddr opt) ,(funcall ref-one n lst)) + (t ,(cadr opt))) + barf + body))) + (> ,len ,n))))) + ((not (bind-arguments-ignorable (car opt))) + (setq body + (bind-arguments-internal + (car opt) + `(cond ((> ,len ,n) ,(funcall ref-one n lst)) + (t ,(cadr opt))) + barf + body))))) + (dolist (pat *normal*) + (setq n (1- n)) + (or (bind-arguments-ignorable pat) + (setq body + (bind-arguments-internal pat (funcall ref-one n lst) + barf body)))) + body)) + +(defun bind-arguments-error-check (len barf) + (let ((nlen (length *normal*)) + (olen (length *optional*))) + (if (null *rest*) + (if (null *optional*) + `((or (= ,len ,nlen) + ,barf)) + (if (null *normal*) + `((and (> ,len ,olen) + ,barf)) + `((and (or (< ,len ,nlen) + (> ,len ,(+ olen nlen))) + ,barf)))) + (if (null *normal*) + `() + `((and (< ,len ,nlen) + ,barf)))))) + +(defun bind-arguments-nth (n v) + (caseq n + (0 `(car ,v)) + (1 `(cadr ,v)) + (2 `(caddr ,v)) + (3 `(cadddr ,v)) + (t (bind-arguments-nth (- n 4) `(cddddr ,v))))) + +(defun bind-arguments-nthcdr (n v) + (caseq n + (0 v) + (1 `(cdr ,v)) + (2 `(cddr ,v)) + (3 `(cdddr ,v)) + (t (bind-arguments-nthcdr (- n 4) `(cddddr ,v))))) + +#+maclisp +(defun (defun& macro) (x) + (let ((name (cadr x)) + (pattern (caddr x)) + (body (cdddr x))) + (cond ((memq pattern '(fexpr macro)) + (ferror "Cannot mix &-keywords and ~S definitions: ~S" + pattern x)) + ((eq pattern 'expr) + (setq pattern (pop body))) + ((not (symbolp pattern))) + ((memq name '(fexpr macro)) + (ferror "Cannot mix &-keywords and ~S definitions: ~S" + pattern x)) + ((eq name 'expr) + (setq name pattern) + (setq pattern (pop body)))) + (if (bind-arguments-ignorable pattern) + (let ((n (gensym))) + `(defun ,name ,n ,n ,@body)) + (let* ((*normal* nil) + (*optional* nil) + (*rest* nil) + (body (bind-arguments-&parse pattern body)) + (len (gensym)) + (barf `(ferror '|~S doesn't match pattern ~S| + (listify ,len) ',pattern))) + `(defun ,name ,len + ,@(bind-arguments-error-check len barf) + ,@(bind-arguments-internal-1 barf body len len + #'bind-arguments-arg + #'bind-arguments-listify)))))) + +#+maclisp +(defun bind-arguments-arg (n v) + v ;ignored + `(arg ,(1+ n))) + +#+maclisp +(defun bind-arguments-listify (n v) + (if (zerop n) + `(listify ,v) + `(listify (- ,n ,v)))) + +#+maclisp +(defprop bind-arguments bind-arguments/ macro macro) + +#+lispm +(fdefine 'bind-arguments '(macro . bind-arguments/ macro) t) diff --git a/src/alan/binda.fasl b/src/alan/binda.fasl new file mode 100755 index 00000000..7c4541e7 Binary files /dev/null and b/src/alan/binda.fasl differ diff --git a/src/alan/crawl.18 b/src/alan/crawl.18 new file mode 100755 index 00000000..305ed0b2 --- /dev/null +++ b/src/alan/crawl.18 @@ -0,0 +1,152 @@ +;;;-*-Lisp-*- + +(declare (load '((alan) lspenv init))) + +(defstruct (frame default-pointer conc-name + (eval-when (eval compile))) + n + evf + (up nil) + (down nil)) + +(eval-when (eval compile) + +(defmacro frame-type (&optional (frame 'frame)) + `(car (frame-evf ,frame))) + +(defmacro frame-pdl (&optional (frame 'frame)) + `(cadr (frame-evf ,frame))) + +(defmacro frame-stuff (&optional (frame 'frame)) + `(caddr (frame-evf ,frame))) + +(defmacro frame-env (&optional (frame 'frame)) + `(cadddr (frame-evf ,frame))) + +) + +(defun crawl () + (do ((prev nil frame) + (evf (evalframe nil) + (evalframe (cadr evf))) + (n 0 (1+ n)) + (top) + (frame)) + ((null evf) (crawl-loop top frame)) + (setq frame (make-frame n n + up prev + evf evf)) + (if (null prev) + (setq top frame) + (setf (frame-down prev) frame)))) + +(defun crawl-loop (top bottom) + (let ((frame top)) + (print-crawl-frame frame) + (do ((flag nil)) + (()) + (terpri) + (tyo #/.) + forgive (setq flag nil) + next-char (caseq (tyi) + ((#/d #/D) + (setq frame (crawl-new-frame frame (frame-down)))) + ((#/u #/U) + (setq frame (crawl-new-frame frame (frame-up)))) + ((#/r #/R) + (terpri) + (princ "Form to evaluate and return: ") + (errset (freturn (frame-pdl) (eval (read) (frame-env))))) + ((#/e #/E) + (terpri) + (princ "Form to evaluate: ") + (errset (print (eval (read) (frame-env))))) + ((#/c #/C) + (fretry (frame-pdl) + (frame-evf))) + ((#/g #/G) + (or (get 'gprint1 'lsubr) + (load '((liblsp) gprint fasl))) + (terpri) + (gprint1 (frame-stuff) nil nil nil nil nil nil)) + ((#/t #/T) + (setq frame (crawl-new-frame frame top))) + ((#/b #/B) + (setq frame (crawl-new-frame frame bottom))) + ((#/j #/J) + (princ " -> ") + (setq frame (crawl-find-numbered-frame frame top (read)))) + ((#\form #/l #/L) + (print-crawl-frame frame)) + ((#/q #/Q) + (return 'done)) + ((#/i #/I) + (cond (flag (inspect (frame-stuff))) + (t + (terpri) + (princ "Form to evaluate and inspect: ") + (errset (inspect (eval (read) (frame-env))))))) + ((#/p #/P) + (cond (flag (describe (frame-stuff))) + (t + (terpri) + (princ "Form to evaluate and describe: ") + (errset (describe (eval (read) (frame-env))))))) + ((#\alt) (setq flag t) (go next-char)) + ((#/? #//) + (princ " +CRAWL Commands: + +U - Up a frame +D - Down a frame +T - go to Top frame +B - go to Bottom frame +J - Jump to a numbered frame +E - Evaluate a form in current frame +R - Return from current frame +C - Continue current frame (start over) +G - Grind stuff in current frame +I - Inspect +I - Inspect contents of current frame +P - describe (Print cute) +P - describe contents of current frame +Q - Quit")) + ((#\space #\cr #\lf) + (go forgive)) + (t + (princ " ???")))))) + +(defun crawl-new-frame (old new) + (cond ((null new) + (princ " No more.") + old) + (t + (print-crawl-frame new) + new))) + +(defun print-crawl-frame (frame) + (let ((prinlength 4) + (prinlevel 3)) + (caseq (frame-type) + (eval + (terpri) + (princ (frame-n)) + (princ " Evaluating ") + (prin1 (frame-stuff))) + (apply + (terpri) + (princ (frame-n)) + (princ " Applying ") + (prin1 (car (frame-stuff))) + (terpri) + (princ "To ") + (prin1 (cadr (frame-stuff)))) + (t (error "-- wierd evalframe." (frame-type)))))) + +(defun crawl-find-numbered-frame (old top n) + (do ((frame top (frame-down))) + ((null frame) + (princ " Not found.") + old) + (and (= n (frame-n)) + (return (crawl-new-frame old frame))))) \ No newline at end of file diff --git a/src/alan/crawl.fasl b/src/alan/crawl.fasl new file mode 100755 index 00000000..5e6023d4 Binary files /dev/null and b/src/alan/crawl.fasl differ diff --git a/src/alan/dprint.142 b/src/alan/dprint.142 new file mode 100755 index 00000000..68583dc2 Binary files /dev/null and b/src/alan/dprint.142 differ diff --git a/src/alan/ljob.74 b/src/alan/ljob.74 new file mode 100755 index 00000000..0fbc8541 --- /dev/null +++ b/src/alan/ljob.74 @@ -0,0 +1,291 @@ +; -*- Lisp -*- + +(declare (load '((alan) lspenv init))) + +(declare ;; HUMBLE + (*expr select-job kill-job load-job + deposit-job examine-job + job-uset-write job-uset-read + *atty *dtty) + (*lexpr create-job) + (special current-job) + ;; MACITS + (*expr %getsys %sixbit %unsixbit %squoze %unsquoze) + (fixnum (%sixbit notype) (%squoze notype)) + ) + +(eval-when (eval compile load) + +(or (fboundp '%getsys) (fasload (liblsp) macits)) + +(defvar *uset-vars* + (do ((l (%getsys 'usyms) (cddr l)) + (a nil (cons (cons (logand #o37777777777 (car l)) (cadr l)) a))) + ((null l) a))) + +(defmacro *uset (var &optional (val nil write?)) + (let ((num (cdr (or (assoc (%squoze var) *uset-vars*) + (error "-- unknown .USET variable" var))))) + (if write? + `(job-uset-write ,(+ #o400000 num) ,val) + `(job-uset-read ,num)))) + +) ;end (eval-when (eval compile load) ...) + +(eval-when (eval compile) + +(defun convert-flonum-to-bit (f) + (or (floatp f) (error "-- non flonum argument to BIT or BITS." f)) + (do ((x (-$ f .05)) + (y 1.1 (+$ y .1)) + (n 1 (1+ n)) + (i 1 (lsh i 1))) + ((zerop i) (error "-- bad flonum to BIT or BITS." f)) + (and (zerop (\ n 10.)) + (setq y (+$ y .1)) + (setq n (1+ n))) + (and (< x y) (return i)))) + +(defmacro bit (x) + `',(convert-flonum-to-bit x)) + +(defmacro bits l + `',(do ((l l (cdr l)) + (x 0 (logior x (convert-flonum-to-bit (car l))))) + ((null l) x))) + +) ;end (eval-when (eval compile) ...) + +(defvar *value-handler '*value-handler) +(defvar *break-handler '*break-handler) +(defvar ljob-job-jcl nil) +(defvar ljob-debug-p nil) +(defvar ljob-search-rules + (let ((sr (cons (status homedir) '(sys sys1 sys2 sys3))) + (udir (status udir))) + (if (eq udir (car sr)) + sr + (cons udir sr)))) +(defvar ljob-hang 'finished) +(defconst ljob-start-addr-addr + (or (getddtsym 'j*stadr) #o71)) ;educated guess! + +(defun ljob-interrupt-handler (job) + (*dtty) + (select-job job) + (let* ((pirqc (*uset *pirqc)) + (xpirqc (logand pirqc (bits 1.2 1.8 2.2 3.1 4.4))) + (npirqc (logxor pirqc xpirqc))) + (cond ((= xpirqc (bit 1.2)) ;%pic.z (call) + (*uset *pirqc npirqc) + (stop-job "^Z")) + ((= xpirqc (bit 1.8)) ;%pival (.value) + (*uset *pirqc npirqc) + (funcall *value-handler + (logand #o777777 (*uset *sv40)))) + ((= xpirqc (bit 2.2)) ;%pibrk (.break) + (*uset *pirqc npirqc) + (let ((x (*uset *sv40))) + (funcall *break-handler + (lsh x -27.) ;not necessarily .break! + (logand #o17 (lsh x -23.)) + (logand #o777777 x)))) + ((= xpirqc (bit 3.1)) ;%pilos (.lose) + (*uset *pirqc npirqc) + (error-job ".lose")) + ((= xpirqc (bit 4.4)) ;%pidcl (defered call) + (*uset *pirqc npirqc) + (stop-job "^_D")) + (t + (error-job pirqc))))) + +(defun ljob-channel-interrupt-handler n + n ;ignored (what is it anyway?) + (*dtty) + (error-job "channel interrupt")) + +(defun J (name) + (create-job #'ljob-interrupt-handler + #'ljob-channel-interrupt-handler + name)) + +(defun L (file) + (let ((v (load-job file))) + (and ljob-job-jcl + (*uset *option (logior (bit 4.6) (*uset *option)))) + (*uset *sname (%sixbit (status udir))) + v)) + +(defun gzp () + (*uset *upc (+ (boole 2 #o777777 (*uset *upc)) + (logand #o777777 (arraycall fixnum current-job + ljob-start-addr-addr)))) + (^P)) + +(defun ^P () + (*uset *ustp 0)) + +(defun P () + (^P) + (pass-tty)) + +(defun G () + (gzp) + (pass-tty)) + +(defun pass-tty () + (setq ljob-hang nil) + (terpri) + (*atty) + (ljob-hang) + (*dtty) ;doesn't work to .dtty while interrupting sometimes? + '*) + +(defun ljob-set-jcl (jcl) + (cond ((null jcl) + (setq ljob-job-jcl nil) + (*uset *option (boole 2 (bit 4.6) (*uset *option)))) + (t + (setq ljob-job-jcl (maknam (nconc (explodec jcl) '(#\cr)))) + (*uset *option (logior (bit 4.6) (*uset *option)))))) + +(defun *value-handler (loc) + (cond ((zerop loc) + (error-job ".value")) + (t + (stop-job ".value")))) + +(defun get-valret-string () + (let ((loc (logand #o777777 (*uset *sv40))) + l) + (do ((loc (1+ loc) (1+ loc)) + (cs (examine-job loc) (examine-job loc)) + (c) + (i 5 5)) + (()) + L (setq cs (rot cs 7)) + (and (zerop (setq c (logand #o177 cs))) + (return t)) + (push c l) + (or (zerop (setq i (1- i))) + (go L))) + (implode (nreverse l)))) + +(defun finish-job (why) + (terpri) + (princ ";finished") + (cond (ljob-debug-p + (princ " (") + (princ why) + (tyo #/)))) + (princ ": ") + (print-job) + (terpri) + (kill-job) + (setq ljob-hang 'finished)) + +(defun stop-job (why) + (terpri) + (princ ";stopped") + (cond (ljob-debug-p + (princ " (") + (princ why) + (tyo #/)))) + (princ ": ") + (print-job) + (terpri) + (setq ljob-hang 'stopped)) + +(defun error-job (why) + (terpri) + (princ ";error (") + (princ why) + (princ "): ") + (print-job) + (terpri) + (setq ljob-hang 'error)) + +(defun print-job () + (princ (shortnamestring current-job))) + +(defun *break-handler (op ac loc) + (cond ((not (= op #o45)) ;.break + (cond ((and (= op #o42) (= loc #o33)) ;.logout + (finish-job ".logout")) + (t + (error-job ".break???")))) + ((= ac #o16) + (if (zerop (logand (bits 2.5 2.6) loc)) + (stop-job ".break") + (finish-job ".break"))) + ((= ac #o12) + (let ((req (examine-job loc)) + type) + (cond ((not (zerop (logand req (bit 4.8)))) + (do ((aobjn (examine-job (logand #o777777 req)) + (+ (bits 1.1 3.1) aobjn))) + ((> aobjn 0)) + (*break-handler op ac (logand #o777777 aobjn)))) + ((or (not (zerop (logand req (bit 4.9)))) + (not (= (setq type (logand #o177777 + (lsh req -18.))) 5))) + (error-job ".break 12,??")) + (t + (or (null ljob-job-jcl) + (do ((l (pnget ljob-job-jcl 7) (cdr l)) + (loc (logand #o777777 req) (1+ loc))) + ((not (zerop (examine-job loc)))) + (and (null l) + (return (deposit-job loc 0))) + (deposit-job loc (car l)))) + (^P) + (*atty))))) + (t + (error-job ".break ??,")))) + +;;;(ljob-hang) hangs until the value of ljob-hang is non-null. +(deflap (ljob-hang subr 0) + (skipn 0 (special ljob-hang)) + (*hang) + (popj p)) + +(defun ljob-run-job (xname file jcl) + (do ((name xname) + (x (J xname) (J name))) + ((cond ((null x) (error "-- couldn't create job." xname)) + ((eq (car x) 'inferior) + (let ((file (or file (ljob-search-for xname)))) + (cond ((null (L file)) + (*uset *xjname (%sixbit xname)) + (ljob-set-jcl jcl) + (G) + t) + (t (error "-- can't load file." file))))) + ((eq (car x) 'reowned) + (P) + t) + (t nil))) + (let ((l (exploden name))) + (cond ((> (length l) 5) + (setf (caddr (cdddr l)) + (1+ (caddr (cdddr l))))) + (t (rplacd (last l) (list #/')))) + (setq name (implode l)))) + '*) + +(defun ljob-search-for (name) + (do ((l ljob-search-rules (cdr l)) + (rest (list 'ts name)) + (file)) + ((null l) + (error "-- can't find file to load." name)) + (and (probef (setq file (cons (if (symbolp (car l)) + (list 'dsk (car l)) + (car l)) + rest))) + (return file)))) + +(defun ljob-expand-run-macro (x) + (bind-arguments ((name &optional (jcl `nil)) x + (error "-- wrong format." x)) + `(ljob-run-job ',name ',(get name 'ljob-filename) ,jcl))) diff --git a/src/alan/ljob.fasl b/src/alan/ljob.fasl new file mode 100755 index 00000000..615a5aff Binary files /dev/null and b/src/alan/ljob.fasl differ diff --git a/src/alan/lspcom.20 b/src/alan/lspcom.20 new file mode 100755 index 00000000..1ea337d4 --- /dev/null +++ b/src/alan/lspcom.20 @@ -0,0 +1,60 @@ +;;;-*-lisp-*- + +(declare (load '((alan) lspenv init))) + +(*expr *make-array *rem *del ass mem listp copyalist copytree apropos + defstruct-examine defstruct-deposit y-or-n-p + macroexpand macroexpand-1) + +(*lexpr format ?format ferror cerror describe inspect + gprint gprint1 gprinc pl gexplode gexplodec) + +(unspecial args symbols car cdr) + +(setq use-strt7 t) + +(defmacro xcar (x) `(car ,x)) +(defmacro xrplaca (x v) `(rplaca ,x ,v)) +(defmacro xcdr (x) `(cdr ,x)) +(defmacro xrplacd (x v) `(rplacd ,x ,v)) +(defmacro xcxr (n x) `(cxr ,n ,x)) +(defmacro xrplacx (n x v) `(rplacx ,n ,x ,v)) +(defmacro vcell (sym) `(cdar ,sym)) +(defmacro pname (sym) `(cxr 2 (car ,sym))) + +(defmacro ldb (ppss x) + (setq ppss (macroexpand ppss)) + (setq x (macroexpand x)) + (if (not (fixp ppss)) + `(*ldb (lsh ,ppss #o30) ,x) ;ugh! + (let ((mask (1- (lsh 1 (boole 1 #o77 ppss)))) + (shift (- (lsh ppss -6)))) + (cond ((fixp x) + (boole 1 mask (lsh x shift))) + ((zerop shift) + `(boole 1 ,mask ,x)) + (t + `(boole 1 ,mask (lsh ,x ,shift))))))) + +(defmacro dpb (v ppss x) + (setq v (macroexpand v)) + (setq ppss (macroexpand ppss)) + (setq x (macroexpand x)) + (if (not (fixp ppss)) + `(*dpb ,v (lsh ,ppss #o30) ,x) ;ugh! + (let* ((shift (lsh ppss -6)) + (mask (lsh (1- (lsh 1 (boole 1 #o77 ppss))) shift))) + (let ((vp (cond ((fixp v) + (boole 1 mask (lsh v shift))) + ((zerop shift) + `(boole 1 ,mask ,v)) + (t + `(boole 1 ,mask (lsh ,v ,shift))))) + (xp (if (fixp x) + (boole 4 x mask) + `(boole 4 ,x ,mask)))) + (if (and (fixp vp) (fixp xp)) + (boole 7 vp xp) + `(boole 7 ,vp ,xp)))))) + +(sstatus feature alan/;lspcom) diff --git a/src/alan/lspcom.fasl b/src/alan/lspcom.fasl new file mode 100755 index 00000000..48526e62 Binary files /dev/null and b/src/alan/lspcom.fasl differ diff --git a/src/alan/lspenv.259 b/src/alan/lspenv.259 new file mode 100755 index 00000000..21321694 --- /dev/null +++ b/src/alan/lspenv.259 @@ -0,0 +1,895 @@ +;;;-*-Lisp-*- + +(declare (load '((alan) lspenv init))) + +(setq flush '(defmax backq let defmacro lodbyt mlmac defvst defsetf + setf sharpm macaid cgol subseq string extmac extend + cerror yesnop errck extstr defvsy extbas defvsx cerror + mlsub describe extsfa grindef)) + +(mapatoms + #'(lambda (x) + ((lambda (p) + (and (not (atom p)) + (memq (cadr p) flush) + (remprop x 'autoload))) + (get x 'autoload)))) + +(defun |forget-macromemos/|| (()) nil) + +(defun flush-macromemos (() ()) nil) + +(defun macrofetch (()) nil) + +(defun macromemo (x y ()) (displace x y)) + +;;;In case of fire, break glass: +;;;(defun (macroexpanded macro) (x) (displace x (car (cddddr x)))) + +(defun define-autoloads (file l) + (dolist (name l) + (putprop name file 'autoload))) + +(defun define-autoload-macros (file l) + (define-autoloads file l) + (when (status feature complr) + (dolist (name l) + (putprop name 'autoload-macro 'macro)))) + +(defun autoload-macro (x) + (remprop (car x) 'macro) + (load (or (get (car x) 'autoload) + (error "-- autoload-macro without autoload property." x))) + x) + +;;;BACKQUOTE: +;;; The flags passed back by BACKQUOTIFY can be interpreted as follows: +;;; +;;; |`,|: [a] => a +;;; NIL: [a] => a ;the NIL flag is used only when a is NIL +;;; T: [a] => a ;the T flag is used when a is self-evaluating +;;; QUOTE: [a] => (QUOTE a) +;;; APPEND: [a] => (APPEND . a) +;;; NCONC: [a] => (NCONC . a) +;;; LIST: [a] => (LIST . a) +;;; LIST*: [a] => (LIST* . a) +;;; +;;; The flags are combined according to the following set of rules: +;;; ([a] means that a should be converted according to the previous table) +;;; +;;; \ car || otherwise | QUOTE or | |`,@| | |`,.| | +;;; cdr \ || | T or NIL | | | +;;;==================================================================================== +;;; |`,| || LIST* ([a] [d]) | LIST* ([a] [d]) | APPEND (a [d]) | NCONC (a [d]) | +;;; NIL || LIST ([a]) | QUOTE (a) | a | a | +;;; QUOTE or T || LIST* ([a] [d]) | QUOTE (a . d) | APPEND (a [d]) | NCONC (a [d]) | +;;; APPEND || LIST* ([a] [d]) | LIST* ([a] [d]) | APPEND (a . d) | NCONC (a [d]) | +;;; NCONC || LIST* ([a] [d]) | LIST* ([a] [d]) | APPEND (a [d]) | NCONC (a . d) | +;;; LIST || LIST ([a] . d) | LIST ([a] . d) | APPEND (a [d]) | NCONC (a [d]) | +;;; LIST* || LIST* ([a] . d) | LIST* ([a] . d) | APPEND (a [d]) | NCONC (a [d]) | +;;; +;;; involves starting over again pretending you had read ".,a)" instead of ",@a)" + +(setsyntax '/` 'macro 'xr-backquote-macro) + +(setsyntax '/, 'macro 'xr-comma-macro) + +(declare (special **backquote-count** **backquote-flag** + **backquote-/,-flag** **backquote-/,/@-flag** **backquote-/,/.-flag**)) + +(setq **backquote-count** 0 + **backquote-/,-flag** (copysymbol '|`,| nil) + **backquote-/,/@-flag** (copysymbol '|`,@| nil) + **backquote-/,/.-flag** (copysymbol '|`,.| nil) + ) + +(defun xr-backquote-macro () + ((lambda (**backquote-count** **backquote-flag** thing) + (setq thing (backquotify (read))) + (cond ((eq **backquote-flag** **backquote-/,/@-flag**) + (error '|-- ",@" right after a "`".| thing)) + ((eq **backquote-flag** **backquote-/,/.-flag**) + (error '|-- ",." right after a "`".| thing)) + (t + (backquotify-1 **backquote-flag** thing)))) + (1+ **backquote-count**) + nil + nil)) + +(defun xr-comma-macro () + (or (> **backquote-count** 0) + (error "Comma not inside a backquote.")) + ((lambda (c **backquote-count**) + (cond ((= c #/@) + (tyi) + (cons **backquote-/,/@-flag** (read))) + ((= c #/.) + (tyi) + (cons **backquote-/,/.-flag** (read))) + (t (cons **backquote-/,-flag** (read))))) + (tyipeek) + (1- **backquote-count**))) + +(defun backquotify (code) + (prog (aflag a dflag d) + (cond ((atom code) + (cond ((null code) + (setq **backquote-flag** nil) + (return nil)) + ((or (numberp code) + (eq code t)) + (setq **backquote-flag** t) + (return code)) + (t (setq **backquote-flag** 'quote) + (return code)))) + ((eq (car code) **backquote-/,-flag**) + (setq code (cdr code)) + (go comma)) + ((eq (car code) **backquote-/,/@-flag**) + (setq **backquote-flag** **backquote-/,/@-flag**) + (return (cdr code))) + ((eq (car code) **backquote-/,/.-flag**) + (setq **backquote-flag** **backquote-/,/.-flag**) + (return (cdr code)))) + (setq a (backquotify (car code))) + (setq aflag **backquote-flag**) + (setq d (backquotify (cdr code))) + (setq dflag **backquote-flag**) + (and (eq dflag **backquote-/,/@-flag**) + (error '|-- ",@" after a ".".| code)) + (and (eq dflag **backquote-/,/.-flag**) + (error '|-- ",." after a ".".| code)) + (cond ((eq aflag **backquote-/,/@-flag**) + (cond ((null dflag) + (setq code a) + (go comma))) + (setq **backquote-flag** 'append) + (return (cond ((eq dflag 'append) + (cons a d)) + (t (list a (backquotify-1 dflag d)))))) + ((eq aflag **backquote-/,/.-flag**) + (cond ((null dflag) + (setq code a) + (go comma))) + (setq **backquote-flag** 'nconc) + (return (cond ((eq dflag 'nconc) + (cons a d)) + (t (list a (backquotify-1 dflag d)))))) + ((null dflag) + (cond ((memq aflag '(quote t nil)) + (setq **backquote-flag** 'quote) + (return (list a))) + (t (setq **backquote-flag** 'list) + (return (list (backquotify-1 aflag a)))))) + ((memq dflag '(quote t)) + (cond ((memq aflag '(quote t nil)) + (setq **backquote-flag** 'quote) + (return (cons a d))) + (t (setq **backquote-flag** 'list*) + (return (list (backquotify-1 aflag a) + (backquotify-1 dflag d))))))) + (setq a (backquotify-1 aflag a)) + (and (memq dflag '(list list*)) + (setq **backquote-flag** dflag) + (return (cons a d))) + (setq **backquote-flag** 'list*) + (return (list a (backquotify-1 dflag d))) + + comma (cond ((atom code) + (cond ((null code) + (setq **backquote-flag** nil) + (return nil)) + ((or (numberp code) + (eq code 't)) + (setq **backquote-flag** t) + (return code)) + (t (setq **backquote-flag** + **backquote-/,-flag**) + (return code)))) + ((eq (car code) 'quote) + (setq **backquote-flag** 'quote) + (return (cadr code))) + ((memq (car code) '(append list list* nconc)) + (setq **backquote-flag** (car code)) + (return (cdr code))) + ((eq (car code) 'cons) + (setq **backquote-flag** 'list*) + (return (cdr code))) + (t (setq **backquote-flag** **backquote-/,-flag**) + (return code))))) + +(defun backquotify-1 (flag thing) + (cond ((or (eq flag **backquote-/,-flag**) + (memq flag '(t nil))) + thing) + ((eq flag 'quote) + (list 'quote thing)) + ((eq flag 'list*) + (cond ((null (cddr thing)) + (cons 'cons thing)) + (t (cons 'list* thing)))) + (t (cons flag thing)))) + +(setsyntax '/: (ascii #^J) nil) + +(setsyntax '/" 'macro 'hack-strings) + +(defun hack-strings () + (do ((l nil (cons c l)) + (c (tyi) (tyi))) + ((= c #/") + (list 'quote (maknam (nreverse l)))) + (declare (fixnum c)) + (cond ((= c #//) + (setq c (tyi)))))) + +(setsyntax '/# 'splicing '/#-macro) + +(declare (special /#-macro-arg)) + +(defun /#-macro () + (do ((c (tyi) (tyi)) + (n nil (cond ((null n) (- c #/0)) + (t (+ (* 10. n) + (- c #/0)))))) + ((or (< c #/0) + (> c #/9)) + (or (< c #/a) + (> c #/z) + (setq c (- c #.(- #/a #/A)))) + ((lambda (ch /#-macro-arg) + ((lambda (chf) + (cond (chf (if (eq (car chf) '/#-macro) + (list (funcall (cadr chf))) + (list (subrcall t (cadr chf))))) + ((setq chf (getl ch '(/#-splicing /#-splicing-subr))) + (if (eq (car chf) '/#-splicing) + (funcall (cadr chf)) + (subrcall t (cadr chf)))) + (t (error "-- unknown character to #" ch)))) + (getl ch '(/#-macro /#-macro-subr)))) + (ascii c) + n)) + (declare (fixnum c)))) + +(defun (// /#-macro /#-macro-subr) () + (tyi)) + +(defun (/\ /#-macro /#-macro-subr) () + (let ((frob (read))) + (cdr (or (assq frob /#/\-alist) + (error "-- unknown frob to #\" frob))))) + +(defconst /#/\-alist + #O '((sp . 40) (cr . 15) (lf . 12) (line . 12) + (bs . 10) (alt . 33) (altmode . 33) + (vt . 13) (newline . 15) (help . 4110) + (return . 15) (space . 40) (tab . 11) + (form . 14) (ff . 14) (rubout . 177))) + +(defun (/' /#-macro /#-macro-subr) () + (list 'function (read))) + +(declare (special squid)) + +(defun (/, /#-macro /#-macro-subr) () + (cond ((status feature complr) + (list squid (read))) + (t (eval (read))))) + +(defun (/. /#-macro /#-macro-subr) () (eval (read))) + +(defun (/_ /#-macro /#-macro-subr) () (munkam (read))) + +(defun (/B /#-macro /#-macro-subr) () ((lambda (ibase) (read)) 2.)) + +(defun (/O /#-macro /#-macro-subr) () ((lambda (ibase) (read)) 8.)) + +(defun (/D /#-macro /#-macro-subr) () ((lambda (ibase) (read)) 10.)) + +(defun (/X /#-macro /#-macro-subr) () + ((lambda (old ibase) + (prog2 (sstatus + t) + (read) + (sstatus + old))) + (status +) + 16.)) + +(defun (/R /#-macro /#-macro-subr) () + (cond ((fixp /#-macro-arg) + ((lambda (ibase) (read)) /#-macro-arg)) + (t + (error "-- #r please!" /#-macro-arg)))) + +(defun (/^ /#-macro /#-macro-subr) () + ((lambda (c) + (declare (fixnum c)) + (or (< c #/a) + (> c #/z) + (setq c (- c 40))) + (logxor #o100 c)) + (tyi))) + +(defun (/| /#-splicing /#-splicing-subr) () + (prog (n) + (setq n 0) + (go home) + sharp (caseq (tyi) + (#/# (go sharp)) + (#/| (setq n (1+ n))) + (#// (tyi)) + (-1 (go eof))) + home (caseq (tyi) + (#/| (go bar)) + (#/# (go sharp)) + (#// (tyi) (go home)) + (-1 (go eof)) + (t (go home))) + bar (caseq (tyi) + (#/# (cond ((zerop n) + (return nil)) + (t + (setq n (1- n)) + (go home)))) + (#/| (go bar)) + (#// (tyi) (go home)) + (-1 (go eof)) + (t (go home))) + eof (error "End of file while parsing /#/| comment."))) + +(defun (/Q /#-splicing /#-splicing-subr) () (read) nil) + +(defun (/M /#-splicing /#-splicing-subr) () (list (read))) + +(defun (/N /#-splicing /#-splicing-subr) () (read) nil) + +(defun (/+ /#-splicing /#-splicing-subr) () + ((lambda (test form) + (cond ((feature-test test (status features)) (list form)) + (t nil))) + (read) + (read))) + +(defun (/- /#-splicing /#-splicing-subr) () + ((lambda (test form) + (cond ((feature-test test (status features)) nil) + (t (list form)))) + (read) + (read))) + +(defun (defmacro macro) (x) + (bind-arguments ((name pattern &body body) (cdr x) + (error '|-- bad format.| x)) + (let ((x (gensym))) + `(defun (,name macro) (,x) + (bind-arguments (,pattern (cdr ,x) + (error '|-- bad format.| ,x)) + ,@body))))) + +(defmacro let (pairs &body body) + (do ((pairs pairs (cdr pairs)) + (vars nil) + (vals nil)) + ((atom pairs) + `((lambda ,(nreverse vars) ,@body) ,@(nreverse vals))) + (cond ((atom (car pairs)) + (push (car pairs) vars) + (push nil vals)) + (t + (bind-arguments ((var &optional (init `nil)) + (car pairs) + (error "-- bad variable spec in LET." (car pairs))) + (push var vars) + (push init vals)))))) + +(defmacro let* (pairs &body body) + (cond ((atom pairs) `(progn ,@body)) + ((atom (car pairs)) + `((lambda (,(car pairs)) + (let* ,(cdr pairs) ,@body)) + nil)) + (t + (bind-arguments ((var &optional (init `nil)) + (car pairs) + (error "-- bad variable spec in LET*." (car pairs))) + `((lambda (,var) + (let* ,(cdr pairs) ,@body)) + ,init))))) + +(defmacro push (item list) + `(setf ,list (cons ,item ,list))) + +(defmacro pop (x) + `(prog1 (car ,x) (setf ,x (cdr ,x)))) + +(defmacro if (a b &optional (c nil c?)) + (cond (c? `(cond (,a ,b) (t ,c))) + (t `(and ,a ,b)))) + +(defmacro defvar (var &optional (init nil init?) (doc nil doc?)) + `(progn 'compile + (comment **special** ,var) + (eval-when (eval load compile) + (and (fboundp 'special) (special ,var))) + ,@(and doc? `((putprop ',var ,doc 'variable-documentation))) + ,@(and init? `((or (boundp ',var) (setq ,var ,init)))) + ',var)) + +(defmacro defconst (var &optional (init nil init?) (doc nil doc?)) + `(progn 'compile + (comment **special** ,var) + (eval-when (eval load compile) + (and (fboundp 'special) (special ,var))) + ,@(and doc? `((putprop ',var ,doc 'variable-documentation))) + ,@(and init? `((setq ,var ,init))) + ',var)) + +(defmacro defparameter (var init &optional (doc nil doc?)) + `(progn 'compile + (comment **special** ,var) + (eval-when (eval load compile) + (and (fboundp 'special) (special ,var))) + ,@(and doc? `((putprop ',var ,doc 'variable-documentation))) + (setq ,var ,init) + ',var)) + +(defmacro defconstant (var init &optional (doc nil doc?)) + `(progn 'compile + (comment **special** ,var) + (eval-when (eval load compile) + (and (fboundp 'special) (special ,var)) + (defprop ,var t defconstant)) + ,@(and doc? `((putprop ',var ,doc 'variable-documentation))) + (setq ,var ,init) + ',var)) + +(defmacro lambda (bvl &body body) + `(function (lambda ,bvl ,@body))) + +(defmacro selectq (op &rest stuff) + (do ((arg (cond ((atom op) op) + (t (gensym)))) + (l stuff (cdr l)) + (r nil (cons `(,(cond ((memq (caar l) '(otherwise t)) 't) + ((atom (caar l)) `(eq ,arg ',(caar l))) + ((null (cdaar l)) `(eq ,arg ',(caaar l))) + (t `(memq ,arg ',(caar l)))) + ,@(cdar l)) + r))) + ((null l) ((lambda (l) (cond ((atom op) l) + (t `((lambda (,arg) ,l) ,op)))) + `(cond ,@(nreverse r)))))) + +(defmacro select (op &rest stuff) + (do ((arg (cond ((atom op) op) + (t (gensym)))) + (l stuff (cdr l)) + (r nil (cons `(,(cond ((memq (caar l) '(otherwise t)) 't) + (t `(equal ,arg ,(caar l)))) + ,@(cdar l)) + r))) + ((null l) ((lambda (l) (cond ((atom op) l) + (t `((lambda (,arg) ,l) ,op)))) + `(cond ,@(nreverse r)))))) + +(defmacro grindef (&rest args) + `(plp ,@args)) + +(defmacro first (x) `(car ,x)) +(defmacro second (x) `(cadr ,x)) +(defmacro third (x) `(caddr ,x)) +(defmacro fourth (x) `(cadddr ,x)) +(defmacro fifth (x) `(car (cddddr ,x))) +(defmacro sixth (x) `(cadr (cddddr ,x))) +(defmacro seventh (x) `(caddr (cddddr ,x))) +(defmacro eighth (x) `(cadddr (cddddr ,x))) + +(defmacro rest (x) `(cdr ,x)) + +(defmacro <= (a b) `(not (> ,a ,b))) +(defmacro >= (a b) `(not (< ,a ,b))) +(defmacro / (a b) `(not (> ,a ,b))) +(defmacro / (a b) `(not (< ,a ,b))) +(defmacro / (a b) `(not (= ,a ,b))) + +(defmacro neq (x y) `(not (eq ,x ,y))) + +(defmacro logand x `(boole #b0001 . ,x)) +(defmacro logior x `(boole #b0111 . ,x)) +(defmacro logxor x `(boole #b0110 . ,x)) +(defmacro logeqv x `(boole #b1001 . ,x)) + +(defmacro lognand (x y) `(boole #b1110 ,x ,y)) +(defmacro lognor (x y) `(boole #b1000 ,x ,y)) +(defmacro logandc1 (x y) `(boole #b0010 ,x ,y)) +(defmacro logandc2 (x y) `(boole #b0100 ,x ,y)) +(defmacro logorc1 (x y) `(boole #b1011 ,x ,y)) +(defmacro logorc2 (x y) `(boole #b1101 ,x ,y)) + +(defmacro lognot (x) `(boole #b0110 -1 ,x)) + +(defmacro logtest (x y) `(not (zerop (boole #b0001 ,x ,y)))) + +(defmacro logbitp (i x) `(not (zerop (boole #b0001 (lsh 1 ,i) ,x)))) + +(defmacro dotimes ((var form) &body body) + (let ((dum (gensym))) + `(do ((,var 0 (1+ ,var)) + (,dum ,form)) + ((not (< ,var ,dum))) + (declare (fixnum ,var ,dum)) + . ,body))) + +(defmacro dolist ((var form) &body body) + (let ((dum (gensym))) + `(do ((,dum ,form (cdr ,dum)) + (,var)) + ((null ,dum)) + (setq ,var (car ,dum)) + . ,body))) + +(defmacro arrayp (object) `(eq (typep ,object) 'array)) + +(defmacro rem (pred item list &optional (n #.(lognot (rot 1 -1)))) + `(*rem ,pred ,item ,list ,n)) + +(defmacro remove (item list &optional (n #.(lognot (rot 1 -1)))) + `(*rem #'equal ,item ,list ,n)) + +(defmacro remq (item list &optional (n #.(lognot (rot 1 -1)))) + `(*rem #'eq ,item ,list ,n)) + +(defmacro del (pred item list &optional (n #.(lognot (rot 1 -1)))) + `(*del ,pred ,item ,list ,n)) + +(defmacro aref (array &rest coords) + `(arraycall t ,array ,@coords)) + +(defmacro aset (data array &rest coords) + (let ((g (gensym))) + `((lambda (,g) + (store (arraycall t ,array ,@coords) ,g)) + ,data))) + +(defmacro byte (size &optional (position 0)) + (setq size (macroexpand size)) + (setq position (macroexpand position)) + (if (fixp size) + (if (fixp position) + (dpb position #o0606 (logand size #o77)) + `(dpb ,position #o0606 ,(logand size #o77))) + (if (fixp position) + (let ((pp00 (dpb position #o0606 0))) + (if (zerop pp00) + `(logand ,size #o77) + `(dpb ,size #o0006 ,pp00))) + `(dpb ,position #o0606 (logand ,size #o77))))) + +(defmacro byte-size (byte-spec) + `(logand ,byte-spec #o77)) + +(defmacro byte-position (byte-spec) + `(ldb #o0606 ,byte-spec)) + +;;;In incf and decf we assume that the user is not using bignums. Also we +;;;promote the use of 1+ and 1- for no good reason... +(defmacro incf (ref &optional (inc 1)) + (if (equal inc 1) + `(setf ,ref (1+ ,ref)) + `(setf ,ref (+ ,ref ,inc)))) + +(defmacro decf (ref &optional (dec 1)) + (if (equal dec 1) + `(setf ,ref (1- ,ref)) + `(setf ,ref (- ,ref ,dec)))) + +(defmacro copylist (l) + `(append ,l nil)) + +(defmacro copylist* (l) + `(append ,l nil)) + +(defmacro when (test &body body) + `(cond (,test (progn ,@body)))) + +(defmacro unless (test &body body) + `(cond ((not ,test) (progn ,@body)))) + +(defmacro with-open-stream ((var stream) &body body) + `((lambda (,var) + (unwind-protect (progn ,@body) + (close ,var))) + ,stream)) + +(defmacro with-open-file ((var &rest openargs) &body body) + `((lambda (,var) + (unwind-protect (progn ,@body) + (close ,var))) + (open ,@openargs))) + +(defmacro deflap ((name type &optional (arg1 nil args-p) (arg2 arg1 arg2-p)) + &body lap) + `(progn 'compile + (lap-a-list + '((lap ,name ,type) + ,@(and args-p + `((args ,name + ,(cond ((or (not (atom arg1)) (eq type 'subr)) + (when arg2-p + (error "-- self-contradictory deflap." + name)) + (if (atom arg1) + `(nil . ,arg1) + arg1)) + (t `(,arg1 . ,arg2)))))) + ,@lap + ())) + ',name)) + +(defmacro make-array (dims &rest rest) + (do ((l rest (cddr l)) + (type t)) + ((null l) + (cond ((fixp dims) + `(array nil ,type ,dims)) + ((or (atom dims) + (not (memq (car dims) '(quote list)))) + `(*make-array ,dims '(type ,type))) + ((eq (car dims) 'list) + `(array nil ,type ,@(cdr dims))) + ((fixp (cadr dims)) + `(array nil ,type ,(cadr dims))) + (t + `(array nil ,type ,@(cadr dims))))) + (let ((i (car l)) + (p (cadr l))) + (and (or (fixp p) + (memq p '(t nil))) + (setq p (list 'quote p))) + (if (or (atom i) + (not (eq (car i) 'quote)) + (caseq (cadr i) + ((type /:type) + (or (atom p) + (not (eq (car p) 'quote)) + (progn + (setq type + (caseq (cadr p) + ((art-q t) t) + ((art-32b art-16b art-8b art-4b + art-2b art-1b fixnum) + 'fixnum) + ((art-float flonum) 'flonum) + ((nil) nil) + (t (error "-- unsupported make-array type." + (cadr p))))) + nil))) + ((area /:area named-structure /:named-structure) nil) + ((initial-value /:initial-value) t) + (t (error "-- unsupported make-array option." (cadr i))))) + (return `(*make-array ,dims (list ,@rest))))))) + +(defmacro feature-case (&body clauses) + (let ((name (if (atom (car clauses)) + (pop clauses) + 'feature-case))) + (do ((clauses clauses (cdr clauses)) + (features (status features))) + ((null clauses) + (error "-- no matching features found." name)) + (when (feature-test (caar clauses) features) + (return (if (null (cddar clauses)) + (cadar clauses) + `(progn 'compile + ,@(cdar clauses)))))))) + +(defun feature-test (feature features) + (cond ((atom feature) + (memq feature features)) + ((eq (car feature) 'not) + (not (feature-test (cadr feature) features))) + ((eq (car feature) 'and) + (loop for feature in (cdr feature) + always (feature-test feature features))) + ((eq (car feature) 'or) + (loop for feature in (cdr feature) + thereis (feature-test feature features))) + (t (error "-- unknown feature form." feature)))) + +(defmacro append-symbols args + (do ((l (reverse args) (cdr l)) + (x) + (a nil (if (or (atom x) + (not (eq (car x) 'quote))) + (if (null a) + `(exploden ,x) + `(nconc (exploden ,x) ,a)) + (let ((l (exploden (cadr x)))) + (cond ((null a) `',l) + ((= 1 (length l)) `(cons ,(car l) ,a)) + (t `(append ',l ,a))))))) + ((null l) `(implode ,a)) + (setq x (car l)))) + +;;;first arg is ALWAYS a symbol or a quoted symbol: +(defmacro transgression (message &rest args) + (let* ((chars (nconc (exploden (if (atom message) + message + (cadr message))) + '(#/.))) ;"Bad frob" => "Bad frob." + (new-message + (maknam (if (null args) + chars + (let ((c (car chars))) ;"Bad frob." => "-- bad frob." + (or (< c #/A) + (> c #/Z) + (rplaca chars (+ c #o40))) + (append '(#/- #/- #\space) chars)))))) + `(error ',new-message + ,@(cond ((null args) `()) + ((null (cdr args)) `(,(car args))) + (t `((list ,@args))))))) + +(defvar *val2*) +(defvar *val3*) +(defvar *val4*) +(defvar *val5*) +(defvar *val6*) +(defvar *val7*) +(defvar *val8*) +(defvar *val9*) +(defconst *values-vars* '(*val2* *val3* *val4* *val5* + *val6* *val7* *val8* *val9*)) + +(defmacro values (first &rest rest) + (unless (<= (length rest) (length *values-vars*)) + (error "-- too many values." rest)) + `(prog1 ,first + ,@(loop for var in *values-vars* + for val in rest + collecting `(setq ,var ,val)))) + +(defmacro with-values (((first &rest rest) form) &body body) + (unless (<= (length rest) (length *values-vars*)) + (error "-- too many values." rest)) + `((lambda (,first ,@rest) ,@body) + ,form + ,@(loop for foo in rest + for var in *values-vars* + collecting var))) + +;;;third arg is ALWAYS a symbol or a quoted symbol: +(defmacro check-arg (place predicate description) + (let ((test (if (symbolp predicate) + `(,predicate ,place) + predicate)) + (msg (append-symbols "-- is not " + (if (atom description) + description + (cadr description)) + "."))) + `(do () + (,test) + (setf ,place (error ',msg ,place 'wrng-type-arg))))) + +(declare (or (get 'defstruct-description-predicate 'macro) + (load '((alan) struct)))) + +;;;second arg is ALWAYS a symbol +;;;third arg, if given, is ALWAYS a symbol or a quoted symbol: +(defmacro check-arg-type (place type-name &optional description) + (let ((description (or description + (get type-name 'check-arg-type-description) + (append-symbols "a " type-name))) + (predicate (or (get type-name 'check-arg-type-predicate) + (let ((desc (get type-name 'defstruct-description))) + (and (not (null desc)) + (defstruct-description-predicate desc))) + (append-symbols type-name "?")))) + `(check-arg ,place ,predicate ,description))) + +(defprop :symbol symbolp check-arg-type-predicate) +(defprop :list |a cons| check-arg-type-description) +(defprop :list list-check-arg-type check-arg-type-predicate) +(defmacro list-check-arg-type (x) `(eq 'list (typep ,x))) +(defprop :array |an array| check-arg-type-description) +(defprop :array arrayp check-arg-type-predicate) +(defprop :atom |an atom| check-arg-type-description) +(defprop :atom atom check-arg-type-predicate) +(defprop :hunk hunkp check-arg-type-predicate) +(defprop :file filep check-arg-type-predicate) +(defprop :sfa |an SFA| check-arg-type-description) +(defprop :sfa sfap check-arg-type-predicate) +(defprop :list-or-nil |a cons or nil| check-arg-type-description) +(defprop :list-or-nil list-or-nil-check-arg-type check-arg-type-predicate) +(defmacro list-or-nil-check-arg-type (x) `(or (null ,x) (eq 'list (typep ,x)))) +(defprop :number numberp check-arg-type-predicate) +(defprop :fix |an integer| check-arg-type-description) +(defprop :fix fixp check-arg-type-predicate) +(defprop :fixnum fixnum-check-arg-type check-arg-type-predicate) +(defmacro fixnum-check-arg-type (x) `(and (fixp ,x) (not (bigp ,x)))) +(defprop :bignum bigp check-arg-type-predicate) +(defprop :float floatp check-arg-type-predicate) +(defprop :float |a floating point number| check-arg-type-description) +(defprop :flonum floatp check-arg-type-predicate) + +; So who needs a code walker? + +(defun macrolet-process-body (defs body) + (if (atom body) + body + (cons (macrolet-process-expr defs (car body)) + (macrolet-process-body defs (cdr body))))) + +(defun macrolet-process-expr (defs expr) + (if (atom expr) + expr + (let ((def (assq (car expr) defs))) + (if (null def) + (macrolet-process-body defs expr) + (macrolet-process-expr defs (funcall (cdr def) (cdr expr))))))) + +(defmacro macrolet (defs &body body) + (let ((var (gensym))) + `(progn + ,@(macrolet-process-body + (loop for def in defs + collecting (cons (car def) + `(lambda (,var) + (bind-arguments (,(cadr def) ,var) + ,@(cddr def))))) + body)))) + +(defmacro defsubst (name vars expr) + `(progn 'compile + (defun ,name ,vars ,expr) + (defprop ,name (,vars . ,expr) defsubst) + (defprop ,name expand-defsubst macro))) + +(declare (special dumper-info-list)) + +(defun lspenv-dumper (dump-name init-name) + (let ((f #'(lambda (x) (list (+ #/0 (// x 10.)) (+ #/0 (\ x 10.))))) + (ti (status daytime)) + (d (status date)) + (*nopoint t) + (base 10.)) + (setq dumper-info-list + (list + (status xuname) + (implode (nconc (exploden (cadr d)) + (cons #// + (nconc (exploden (caddr d)) + (cons #// (exploden (car d))))))) + (implode (nconc (exploden (car ti)) + (cons #/: + (nconc (funcall f (cadr ti)) + (cons #/: (funcall f (caddr ti))))))) + dump-name + init-name))) + (sstatus flush t) + (gc) + (cond ((status feature ITS) + (suspend #o160000 dump-name)) + ((status feature TOPS-20) + (suspend dump-name)) + (t + (error "Unknown site for dumping."))) + (sstatus gctime 0) + (defaultf (list (list (status udir)))) + (cond ((status feature ITS) + (let ((init (let ((jcl (status jcl))) + (if (not (null jcl)) + (implode (nreverse (cdr (nreverse jcl)))) + `((DSK ,(status hsname)) + ,(status xuname) + ,init-name))))) + (if (probef init) + (load init)))) + ((status feature TOPS-20) + (let ((init `((PS ,(status hsname)) ,init-name INI))) + (if (probef init) + (load init))))) + '*) + +(sstatus feature alan/;lspenv) diff --git a/src/alan/lspenv.fasl b/src/alan/lspenv.fasl new file mode 100755 index 00000000..1c54c530 Binary files /dev/null and b/src/alan/lspenv.fasl differ diff --git a/src/alan/lspenv.init b/src/alan/lspenv.init new file mode 100755 index 00000000..e50be634 --- /dev/null +++ b/src/alan/lspenv.init @@ -0,0 +1,68 @@ +;;;-*-Lisp-*- + +(cond ((and (status feature complr) + (not (boundp 'alan/;flushed))) + (own-symbol let let* defmacro setf defsetf push pop incf decf if + defvar defconst selectq first second third fourth fifth + sixth seventh eighth rest <= >= / / / logand + logior logxor lognot dotimes dolist arrayp rem + remove remq del ass mem listp create-array aref aset + make-array ldb dpb y-or-n-p yes-or-no-p + ferror cerror describe inspect byte byte-size byte-position + macroexpand macroexpand-1) + (setq alan/;flushed t))) + +(cond ((status feature ITS) + (defprop lspenv (dsk alan) ppn)) + ((status feature OZ) + (defprop lspenv (ps alan/.maclisp) ppn)) + ((status feature EE) + (defprop liblsp (ps maclisp) ppn) + (defprop lspenv (ps alan) ppn)) + ((status feature SCRC-TENEX) + (defprop liblsp (dsk maclisp) ppn) + (defprop lspenv (dsk alan) ppn)) + (t (error '|Unknown site for lisp environment.|))) + +((lambda (fasload noldmsg) + (sstatus feature noldmsg) + (or (status feature alan/;lspint) + (load '((lspenv) lspint))) + (cond ((status feature complr) + (or (status feature alan/;lspcom) + (load '((lspenv) lspcom))))) + (or (status feature alan/;binda) + (load '((lspenv) binda))) + (or (status feature alan/;lspenv) + (load '((lspenv) lspenv))) + (or (status feature alan/;setf) + (load '((lspenv) setf))) + (cond ((not (status feature complr)) + (or (get 'gcdemn 'version) + (load '((lisp) gcdemn))) + (or (status feature alan/;dprint) + (load '((lspenv) dprint))) + (or (status usrhu) + (dprint t)))) + (defprop step ((liblsp) step fasl) autoload) + (defprop dribble ((liblsp) dribbl fasl) autoload) + (defprop apropos ((liblsp) apropo fasl) autoload) + (defprop crawl ((lspenv) crawl fasl) autoload) + (putprop '?format (get 'format 'autoload) 'autoload) + (defprop faslist ((lspenv) faslro fasl) autoload) + (cond ((not (status feature defstruct)) + (define-autoload-macros '((lspenv) struct fasl) + '(defstruct defstruct-define-type)) + (define-autoloads '((lspenv) struct fasl) + '(defstruct-expand-ref-macro defstruct-expand-cons-macro + defstruct-expand-alter-macro defstruct-expand-size-macro)))) + (cond ((not (get 'gprint 'version)) + (define-autoload-macros '((liblsp) gprint fasl) + '(gformat gf)) + (define-autoloads '((liblsp) gprint fasl) + '(gprint gprint1 gprinc pl gexplode gexplodec + plp gset-up-printer)))) + (or noldmsg + (sstatus nofeature noldmsg))) + nil + (status feature nodlmsg)) diff --git a/src/alan/lspgub.71 b/src/alan/lspgub.71 new file mode 100755 index 00000000..3f4f436d --- /dev/null +++ b/src/alan/lspgub.71 @@ -0,0 +1,458 @@ +;;;-*-Lisp-*- + +(declare (load '((alan) lspenv init))) + +(setq base 8) +(setq ibase 8) +(setq *nopoint t) + +(setq pure 1) +(setq fasload nil) + +(sstatus _ nil) + +(sstatus feature noldmsg) + +(setq gc-daemon-print nil) + +(cond ((status feature ITS) + +(defprop ljob-expand-run-macro ((alan) ljob fasl) autoload) +(setq ljob-search-rules '(alan sys sys1 sys2 sys3 bawden)) +(let ((udir (status udir)) + (homedir (status homedir))) + (or (memq homedir ljob-search-rules) + (push homedir ljob-search-rules)) + (or (memq udir ljob-search-rules) + (push udir ljob-search-rules))) +(mapc '(lambda (x) (putprop x 'ljob-expand-run-macro 'macro)) + '(peek p os sn chater vv vj tty fretty dskuse + oldjob probe pb % who% + what j k ddt spell tags + lisp l q ol xlisp xl xq + complr c oc xc qc xqc faslis faslist fl + finger f name whois who whoj w lookup u inquir + mail bug qsend send s lmsend reply + supdup ai ml mc oz ee xx + pty sty telnet tn chtn mul mult multic multics + midas m find dover /@ ftp cftp + macsym macsyma a srccom ttloc ttyloc lsc info tctyp tctype + e emacs + memo %tiful chat cli clu conkil its jade prime rfc + )) + +(sstatus who1 #o52 #/% #o166 0) +(sstatus who3 0) +(sstatus gcwho 3) + +(defprop *uset ((liblsp) lusets fasl) autoload) + +)) ;;end (cond ((status feature ITS) ...)) + +(defun y-or-n-p () + (do ((ch (tyi t) (tyi t))) + (nil) + (declare (fixnum ch)) + (cond ((or (= ch #/Y) (= ch #/y)) + (princ "es" t) (return t)) + ((or (= ch #/N) (= ch #/n)) + (princ "o" t) (return nil)) + ((= ch #\sp) + (princ "Yes" t) (return t)) + ((= ch #\rubout) + (princ "No" t) (return nil)) + (t (tyo 7 t))))) + +(declare (special load-file)) + +(defun loadf n + (do ((ar (and (> n 0) (arg 1))) + (to-load) + (default (namelist nil))) + (()) + (terpri t) + (and (null ar) (cond ((boundp 'load-file) + (setq ar load-file) + (go l)) + (t (go r)))) + (or (eq ar 't) (go l)) + R (princ ";File to load: " t) + (setq ar (readline t)) + L (setq ar (mergef ar default)) + (cond ((setq to-load (probef ar)) + (princ ";Loading " t) + (princ (namestring to-load) t) + (setq load-file ar) + (load to-load) + (return t)) + (t + (princ ";No such file as " t) + (princ (namestring ar) t) + (princ " Try again? " t) + (cond ((y-or-n-p) + (terpri t) + (setq default ar) + (go r))) + (return nil))))) + +(defun dbug (x) + (cond (x (nouuo t) + (sstatus uuolinks)) + (t (nouuo nil)))) + +(defun base (n) + (setq base n) + (setq ibase n) + *) + +(defmacro bind-nointerrupt-nil (&body body) + (let ((old (gensym))) + `((lambda (,old) + (unwind-protect (progn (nointerrupt nil) + ,@body) + (nointerrupt ,old))) + (status nointerrupt)))) + +(defun 20X-^f-function (() ()) + (bind-nointerrupt-nil + (loadf) + (princ " Done." t) + (terpri t))) + +(defun ITS-^f-function (f ()) + (syscall #o1_22 'ttyfls f) + (bind-nointerrupt-nil + (loadf) + (princ " Done." t) + (terpri t))) + +(defvar *elisp-^e-valret* + (cond ((status feature ITS) "E") + (t "EMACSî/ "))) + +(defun elisp-20X-^e-function (() ()) + (valret *elisp-^e-valret*) + (elisp-tty-return '^e)) + +(defun elisp-20X-^z-function (() ()) + (valret) + (elisp-tty-return '^z)) + +(defun elisp-ITS-^e-function (f ()) + (syscall #o1_22 'ttyfls f) + (valret *elisp-^e-valret*) + (elisp-welcome-back)) + +(defun elisp-ITS-^z-function (f ()) + (syscall #o1_22 'ttyfls f) + (valret 0) + (elisp-welcome-back)) + +(defun elisp-tty-return (state) + (check-for-elisp-turds) + (unless (null state) + (elisp-welcome-back))) + +(defun elisp-welcome-back () + (cursorpos 'A t) + (princ ";Back to Lispî/ " t)) + +(defvar *elisp-filename* nil) + +(defun check-for-elisp-turds () + (let ((name (probef (or *elisp-filename* + (setq *elisp-filename* + (cond ((status feature ITS) + `((DSK ,(status hsname)) + _ELISP ,(status uname))) + (t + `((TEMP) ELISP TMP)))))))) + (unless (null name) + (cursorpos 'A t) + (princ ";Reading... " t) + (let ((f (open name))) + (unwind-protect (progn (deletef name) + (bind-nointerrupt-nil (elisp-load f))) + (close f))) + (sstatus uuolinks) + (princ "î/ ;Done.î/ " t)) + name)) + +(defun elisp-load (f) + (loop for form = (read f f) + until (eq form f) + for value = (eval form) + do (when (atom value) + (prin1 value t) + (princ " " t)))) + +(defun print-runtimes (f) + (terpri f) + (princ "R=" f) + (princ-time (runtime) f) + (princ " GC=" f) + (princ-time (status gctime) f)) + +(defun princ-time (r f) + (declare (fixnum r)) + (let ((base 10.) + (*nopoint t)) + (prog (m s d) + (declare (fixnum m s d)) + (setq r (// r 100000.)) + (setq d (\ r 10.)) + (setq r (// r 10.)) + (setq s (\ r 60.)) + (setq r (// r 60.)) + (if (zerop r) (go S)) + (setq m (\ r 60.)) + (setq r (// r 60.)) + (if (zerop r) (go M)) + (princ r f) + (princ ":" f) + (if (< m 10.) + (princ "0" f)) + M (princ m f) + (princ ":" f) + (if (< s 10.) + (princ "0" f)) + S (princ s f) + (princ "." f) + (princ d f)))) + +(push '(print-runtimes t) errlist) + +(defun 20X-^t-function (() ()) + (print-runtimes t) + (terpri t) + (check-for-elisp-turds)) + +(defun ITS-^t-function (f ()) + (syscall #o1_22 'ttyfls f) + (print-runtimes t) + (terpri t) + (check-for-elisp-turds)) + +(declare (special gc-daemon-print)) + +(defun 20X-^d-function (() ()) + (if (setq gc-daemon-print (not gc-daemon-print)) + (princ "î/ ;GC Printing On.î/ " t) + (princ "î/ ;GC Printing Off.î/ " t))) + +(defun ITS-^d-function (f ()) + (syscall #o1_22 'ttyfls f) + (if (setq gc-daemon-print (not gc-daemon-print)) + (princ "î/ ;GC Printing On.î/ " t) + (princ "î/ ;GC Printing Off.î/ " t))) + +(cond ((status feature ITS) + (setq tty-return 'elisp-tty-return) + (sstatus ttyint #^e 'elisp-ITS-^e-function) + (sstatus ttyint #^z 'elisp-ITS-^z-function) + (sstatus ttyint #^t #'ITS-^t-function) + (sstatus ttyint #^d #'ITS-^d-function) + (sstatus ttyint #^f #'ITS-^f-function)) + (t + (sstatus ttyint #^e 'elisp-20X-^e-function) + (sstatus ttyint #^z 'elisp-20X-^z-function) + (sstatus ttyint #^t #'20X-^t-function) + (sstatus ttyint #^d #'20X-^d-function) + (sstatus ttyint #^f #'20X-^f-function))) + +(defvar **-manager nil) +(defvar ** nil) +(defvar *** nil) + +(defun **-manager (val) + (setq *** **) + (setq ** **-manager) + (setq **-manager val) + val) + +(setq read-eval-*-print '**-manager) + +(defvar ++-manager nil) +(defvar -- nil) +(defvar ++ nil) +(defvar +++ nil) + +(defun ++-manager (form) + (unless (eq form '+) + (setq +++ ++) + (setq ++ --) + (setq -- ++-manager) + (setq ++-manager form)) + form) + +(setq read-*-eval-print '++-manager) + +(setq miser-width 20) +(setq major-width 20) +(setq plp-properties + '(convert xmacro defstruct-name defstruct-slot /:function /:value)) +(setq gprint-array-contents nil) +(setq gsymbol-car-format '/:G1block) +(setq gnon-symbol-car-format '/:G1block) + +(defun (bind-arguments /:gformat) (x) + (GF |(2*_(1%gformat-bvl -*!*))| x)) + +(defprop caseq gformat-caseq /:gformat) +(defprop selectq gformat-caseq /:gformat) +(defun gformat-caseq (x) + (GF |(2*_*)<-*>)>)| x)) + +(defprop block gformat-catch /:gformat) +(defprop catch gformat-catch /:gformat) +(defprop *catch gformat-catch /:gformat) +(defun gformat-catch (x) + (GF |(2*_<*->)| x)) + +(defun (defun /:gformat) (x) + (GF |(2*_*_%gformat-bvl )| x)) + +;;;Do this even better someday: +(defun gformat-bvl (x) + (cond ((null x) (GF |'()'|)) + ((atom x) (GF |*| x)) + (t (GF |(1<*,>)| x)))) + +(defun (feature-case /:gformat) (x) + (GF |{2'('*| (car x)) + (when (atom (cadr x)) + (setq x (cdr x)) + (GF |_*| (car x))) + (GF |[)<-*>)>]')'}| (cdr x))) + +(defun (iterate /:gformat) (x) + (GF |(2*_*_(1<*->))| x)) + +(defvar *gformat-loop-keywords* ;Use these if LOOP isn't loaded: + '((for) (as) (repeat) (initially) (finally) (do) (doing) (return) (collect) + (collecting) (append) (appending) (nconc) (nconcing) (count) (counting) + (sum) (summing) (maximize) (minimize) (always) (never) (thereis) (while) + (until) (when) (if) (unless) (with))) + +(defun (loop /:gformat) (x) + (let ((*gformat-loop-keywords* + (if (and (boundp 'loop-keyword-alist) + (boundp 'loop-iteration-keyword-alist)) + (append loop-iteration-keyword-alist loop-keyword-alist) + *gformat-loop-keywords*))) + (GF |(+2*_*<%gformat-loop-element >)| x))) + +(defun gformat-loop-element (x) + (if (assq x *gformat-loop-keywords*) + (GF |!~-2*| x) + (GF |,*| x))) + +(defprop kappa gformat-lambda /:gformat) +(defprop lambda gformat-lambda /:gformat) +(defun gformat-lambda (x) + (GF |(2*_%gformat-bvl <-*>)| x)) + +(defprop named-kappa gformat-named-lambda /:gformat) +(defprop named-lambda gformat-named-lambda /:gformat) +(defun gformat-named-lambda (x) + (GF |(2*_*_%gformat-bvl <-*>)| x)) + +(defun (labels /:gformat) (x) + (GF |(2*_(1<$gformat-definition !>))| x)) + +(defun (perform /:gformat) (x) + (GF |(2*_*)| x)) + +(defun gformat-definition (def) + (GF |{2'('*| (car def)) + (if (symbolp (car def)) ;should call gformat-bvl sometimes. + (GF |_*| (cadr def)) + (GF |-*| (cadr def))) + (GF |[<-*>]')'}| (cddr def))) + +;;;Disarming this kludge once again. +(defun (macroexpanded /:gformat) (x) + (GF |(2*)| x)) + +;;;Can't make PROGN (PROG1, PROG2) choose between: +;;; (progn foo +;;; bar +;;; baz) +;;;and: +;;; (progn +;;; foo +;;; bar +;;; baz) + +;;;TAGBODY? Ugh! + +(defprop unwind-protect gformat-when /:gformat) +(defprop when gformat-when /:gformat) +(defprop unless gformat-when /:gformat) +(defun gformat-when (x) + (GF |(2*_*)| x)) + +(defun (with-open-file /:gformat) (x) + (GF |(2*_(*_*-*))| x)) + +(defun (with-values /:gformat) (x) + (GF |(2*_(1%gformat-bvl -*))| x)) + +(defmacro try (f) + (let ((g (gensym))) + (or (get 'gprint1 'lsubr) + (load '((liblsp) gprint fasl))) + `(do ((,g '* (,f (read)))) + (nil) + (terpri) + (gprint1 ,g nil nil nil nil nil nil) + (terpri)))) + +(declare (special ++)) + +(defun unbound-variable-break (args) + (declare (special args)) + (errprint nil msgfiles) + (let ((obarray (get 'obarray 'array)) + (readtable (get 'readtable 'array))) + (setq ++ (car args)) + (bind-nointerrupt-nil (break unbound-variable)) + args)) + +(defun undefined-function-break (args) + (declare (special args)) + (errprint nil msgfiles) + (let ((obarray (get 'obarray 'array)) + (readtable (get 'readtable 'array))) + (setq ++ (car args)) + (bind-nointerrupt-nil (break undefined-function)) + args)) + +(defun wrong-type-argument-break (args) + (declare (special args)) + (errprint nil msgfiles) + (let ((obarray (get 'obarray 'array)) + (readtable (get 'readtable 'array))) + (setq ++ (car args)) + (rplaca args + (bind-nointerrupt-nil (break wrong-type-argument))) + args)) + +(declare (special flush)) +(or (boundp 'flush) (setq flush t)) + +(defun autoload-warn (x) + (cond ((or (eq flush 't) + (atom (cdr x)) + (memq (caddr x) flush)) + (terpri t) + (princ ";AutoLoading " t) + (prin1 x t) + (terpri t))) + (+internal-autoload x)) + +(setq unbnd-vrbl 'unbound-variable-break + undf-fnctn 'undefined-function-break + wrng-type-arg 'wrong-type-argument-break + autoload 'autoload-warn + ) diff --git a/src/alan/lspgub.fasl b/src/alan/lspgub.fasl new file mode 100755 index 00000000..6b1f6097 Binary files /dev/null and b/src/alan/lspgub.fasl differ diff --git a/src/alan/lspint.46 b/src/alan/lspint.46 new file mode 100755 index 00000000..4bcee100 --- /dev/null +++ b/src/alan/lspint.46 @@ -0,0 +1,205 @@ +;;;-*-Lisp-*- + +(declare (load '((alan) lspenv init))) + +(defun *make-array (dims opts) + (do ((opts opts (cddr opts)) + (type t) + (ival nil) + (ival-p nil)) + ((null opts) + (let ((a (cond ((fixp dims) + (*array nil type dims)) + ((atom dims) + (error '|-- bad dimension list to make-array.| dims)) + (t + (lexpr-funcall '*array nil type dims))))) + (if ival-p + (fillarray a (list ival))) + a)) + (caseq (car opts) + ((type /:type) + (setq type + (caseq (cadr opts) + ((art-q t) t) + ((art-32b art-16b art-8b art-4b art-2b art-1b fixnum) 'fixnum) + ((art-float flonum) 'flonum) + ((nil) nil) + (t (error '|-- unsupported make-array type.| opts))))) + ((area /:area named-structure /:named-structure)) + ((initial-value /:initial-value) + (setq ival (cadr opts)) + (setq ival-p t)) + (t (error '|-- unsupported make-array option.| opts))))) + +(defun expand-defsubst (form) + (let ((def (get (car form) 'defsubst))) + (do ((vars (car def) (cdr vars)) + (exprs (cdr form) (cdr exprs)) + (alist '() (cons (cons (car vars) (car exprs)) alist))) + ((null vars) + (unless (null exprs) + (error "-- too many arguments." form)) + (sublis alist (cdr def))) + (when (null exprs) + (error "-- too few arguments." form))))) + +(defun copyalist (l) + (do ((l l (cdr l)) + (a nil (cons (if (atom (car l)) + (car l) + (cons (caar l) (cdar l))) + a))) + ((atom l) (nreconc a l)))) + +(defun copytree (l) + (do ((l l (cdr l)) + (a nil (cons (copytree (car l)) a))) + ((atom l) (nreconc a l)))) + +(defun *rem (pred item list n) + (declare (fixnum n)) + (do ((list list (cdr list)) + (l nil)) + ((or (null list) + (not (plusp n))) + (nreconc l list)) + (cond ((funcall pred item (car list)) + (setq n (1- n))) + (t + (setq l (cons (car list) l)))))) + +(defun *del (pred item list n) + (declare (fixnum n)) + (do ((l list) + (last nil)) + ((or (null l) + (not (plusp n))) + list) + (cond ((funcall pred item (car l)) + (setq n (1- n)) + (setq l (cdr l)) + (cond ((null last) + (setq list l)) + (t (rplacd last l)))) + (t (setq last l) + (setq l (cdr l)))))) + +(defun ass (pred item list) + (do ((list list (cdr list))) + ((null list) nil) + (and (funcall pred item (caar list)) + (return (car list))))) + +(defun mem (pred item list) + (do ((list list (cdr list))) + ((null list) nil) + (and (funcall pred item (car list)) + (return list)))) + +(defun listp (x) + (or (not (atom x)) + (null x))) + +(defun ferror n + (ferror-cerror-hack nil nil (arg 1) (listify (- 1 n)))) + +(args 'ferror '(1 . 776)) + +(defun cerror n + (ferror-cerror-hack (arg 1) (arg 2) (arg 3) (listify (- 3 n)))) + +(args 'cerror '(4 . 776)) + +(defun ferror-cerror-hack + (proceedable restartable format-string-or-nil format-args) + (format msgfiles "~2&Error: ") + (if (null format-string-or-nil) + (lexpr-funcall #'format msgfiles format-args) + (lexpr-funcall #'format msgfiles format-string-or-nil format-args)) + (or (null *rset) + (let ((bl (cdddr (baklist))) + (prinlevel 2)) + (cond ((not (null bl)) + (format msgfiles "~&While in the function ~S" + (caar bl)) + (do ((i 0 (1+ i)) + (bl (cdr bl) (cdr bl))) + ((or (null bl) + (= i 3))) + (declare (fixnum i)) + (format msgfiles " <- ~S" (caar bl))))))) + (cond (proceedable (format msgfiles "~&(proceedable)")) + (restartable (format msgfiles "~&(restartable)"))) + (terpri msgfiles) + (let ((v (break error))) + (cond (proceedable v) + (restartable (*throw 'error-restart v)) + (t (error "Can't proceed or restart."))))) + +(defun get-macro-definition (sym) + (let ((p (or (getl sym '(macro subr lsubr expr + fsubr fexpr array)) + (let ((f (get sym 'autoload))) + (cond ((null f) nil) + (t + (load f) + (or (getl sym '(macro subr lsubr expr + fsubr fexpr array)) + (ferror "Autoloading failed to define: ~S" + sym)))))))) + (if (eq (car p) 'macro) + (cadr p) + nil))) + +(defun macroexpand (form) + (do () + ((or (atom form) + (not (symbolp (car form)))) + form) + (let ((f (get-macro-definition (car form)))) + (when (null f) + (return form)) + (setq form (funcall f form))))) + +(defun macroexpand-1 (form) + (if (or (atom form) + (not (symbolp (car form)))) + form + (let ((f (get-macro-definition (car form)))) + (if (null f) + form + (funcall f form))))) + +(defun mexp () + (or (get 'gprint1 'lsubr) + (load '((liblsp) gprint fasl))) + (terpri) + (princ '|>|) + (do ((x (read) (read))) + ((eq x t)) + (do () + ((or (atom x) + (not (symbolp (car x))))) + (let ((f (get-macro-definition (car x)))) + (when (null f) + (return nil)) + (terpri) + (princ '|==> |) + (gprint1 (setq x (funcall f x)) nil nil nil nil nil nil))) + (terpri) + (princ '|>|)) + 'done) + +(defun r-p () (do x '(r-p) (read) (eq x t) (print x) (terpri)) 'done) + +(defun xcar (x) (car x)) +(defun xrplaca (x v) (rplaca x v)) +(defun xcdr (x) (cdr x)) +(defun xrplacd (x v) (rplacd x v)) +(defun xcxr (n x) (cxr n x)) +(defun xrplacx (n x v) (rplacx n x v)) +(defun vcell (sym) (cdar sym)) +(defun pname (sym) (cxr 2 (car sym))) + +(sstatus feature alan/;lspint) diff --git a/src/alan/lspint.fasl b/src/alan/lspint.fasl new file mode 100755 index 00000000..2cc80c8f Binary files /dev/null and b/src/alan/lspint.fasl differ diff --git a/src/alan/macits.13 b/src/alan/macits.13 new file mode 100755 index 00000000..02e39c06 --- /dev/null +++ b/src/alan/macits.13 @@ -0,0 +1,110 @@ +; -*- Midas -*- + +title MacITS - Library of MacLisp/ITS interface routines + +.fasl + +if1, .insrt sys:.fasl defs + +maxpush==10 ; Largest n for which 0PUSH-n will work. + +; (%GETSYS name) returns a list of fixnums representing the data returned by +; .GETSYS for SIXBIT /name/. +.entry %GETSYS SUBR 2 ; 1 arg + pushj p,sixmak ; TT: sixbit argument + move r,tt ; R=D+1: area name + setzi a, ; A: accumulate list of answers + jsp t,0push-maxpush ; Make room for data area on FXPDL + hrrzi d,1-maxpush(fxp) + hrli d,-maxpush ; D: aobjn to data area + .getsys d, + jrst getsy2 + subi d,1-maxpush(fxp) ; RH(D): # of words of data + hlre tt,d + imul tt,[-<1,,1>] + sub fxp,tt ; Discard extra words from FXPDL + hrrzi f,(d) ; F: # of words of data + jumple f,cpopj ; No words => all done +getsy1: movei b,(a) + pop fxp,tt + jsp t,fxcons + jsp t,%cons + sojg f,getsy1 + popj p, + +getsy2: sub fxp,r70+maxpush + jumpe r,cpopj + hlre tt,d ; TT: -# words needed + movn f,tt ; F: # words delivered + push fxp,[0] ; allocate that many on FXPDL + aojl tt,.-1 + .getsys d, + .lose ; Can't happen. + jrst getsy1 + +; (%EVAL name) looks up the name in Exec DDT's symbol table. Returns NIL +; if the symbol isn't found. +.entry %EVAL SUBR 2 ; 1 arg + pushj p,squeeze + .eval tt, + tdza a,a + jrst fix1 + popj p, + +; (%GETLOC addr) return the contents addr in the system. +.entry %GETLOC SUBR 2 ; 1 arg + push p,cfix1 ; NCALLable + jsp t,fxnv1 + hrlzi t,(tt) + hrri t,tt + .getloc t, + popj p, + +; (%SIXBIT name) returns a number. +.entry %SIXBIT SUBR 2 ; 1 arg + push p,cfix1 ; NCALLable + jrst sixmak + +; (%UNSIXBIT num) returns a symbol. +.entry %UNSIXBIT SUBR 2 ; 1 arg + jsp t,fxnv1 + jrst sixatm + +; SQUOZE SIXBIT +; 0 +; 1 - 12 "0" - "9" 20 - 31 +; 13 - 44 "A" - "Z" 41 - 72 +; 45 "*" 12 +; 46 "$" 04 +; 47 "%" 05 + +; (%SQUOZE name) returns a number. +.entry %SQUOZE SUBR 2 ; 1 arg + push p,cfix1 ; NCALLable + jrst squeeze + +; (%UNSQUOZE num) returns a symbol. +; Works by converting to SIXBIT because MacLisp lacks a built-in routine to +; do this properly. +.entry %UNSQUOZE SUBR 2 ; 1 arg + jsp t,fxnv1 + ldb d,[004000,,tt] ; D: squoze number less flags + setzi f, +unsqu1: idivi d,50 + jumpe r,unsqu3 + cail r,45 + jrst unsqu2 + addi r,'A-13 + caige r,'A + subi r,<'A-1>-'9 +unsqu3: lshc r,-6 + jumpn d,unsqu1 + move tt,f + jrst sixatm + +unsqu2: subi r,45-'* + caie r,'* + subi r,<'*+1>-'$ + jrst unsqu3 + +fasend diff --git a/src/alan/nstruc.280 b/src/alan/nstruc.280 new file mode 100755 index 00000000..d7acbe3d --- /dev/null +++ b/src/alan/nstruc.280 @@ -0,0 +1,1875 @@ +;;; -*- Mode:Lisp; Package:SI; Lowercase:True -*- +;;; ** (c) Copyright 1980 Massachusetts Institute of Technology ** +;;; ** (c) Copyright 1981 Massachusetts Institute of Technology ** + +;The master copy of this file is in MC:ALAN;NSTRUCT > +;The current PDP10 MacLisp copy is in MC:ALAN;STRUCT > +;The current Lisp machine copy is in AI:LISPM2;STRUCT > +;The current Multics MacLisp copy is in >udd>Mathlab>Bawden>defstruct.lisp +; on MIT-Multics +;The current VMS-NIL copy is in [NIL.SRC.SPEC]STRUCT.LSP on HTJR + +;***** READ THIS PLEASE! ***** +;If you are thinking of munging anything in this file you might want to +;consider finding me (ALAN) and asking me to mung it for you. There is more +;than one copy of this file in the world (it runs in PDP10 and Multics MacLisp, +;NIL, Franz, PSL and on LispMachines) and whatever amazing features you are +;considering adding might be usefull to those people as well. If you still +;cannot contain yourself long enough to find me, AT LEAST send me a piece of +;mail describing what you did and why. Thanks for reading this flame. +; Alan Bawden (ALAN@MC) + +(eval-when (eval compile) + (cond ((and (status feature MacLisp) (status feature PDP10)) + (sstatus feature MacLisp-10)) + (t (sstatus nofeature MacLisp-10)))) + +(eval-when (compile) + (cond ((status feature ITS) + (load '|alan;lspenv init|)) + ((status feature Multics) + (load '|>udd>Mathlab>Bawden>lspenv.lisp|)))) + +#+MacLisp-10 +(cond ((status nofeature noldmsg) + (terpri msgfiles) + (princ '#.(and (status feature MacLisp-10) + (maknam (nconc (exploden ";Loading DEFSTRUCT ") + (exploden (caddr (truename infile)))))) + msgfiles))) + +#+NIL +(herald defstruct) + +#+Multics +(declare (genprefix defstruct-internal-) + (macros t)) + +#+MacLisp +(eval-when (eval compile) + (setsyntax #/: (ascii #\space) nil)) + +(eval-when (eval) + ;;So we may run the thing interpreted we need the simple + ;;defstruct that lives here: + (cond ((status feature ITS) + (load '|alan;struct initial|)) + ((status feature Multics) + (load '|>udd>Mathlab>Bawden>initial_defstruct|)))) + +(eval-when (compile) + ;;To compile the thing this probably is an old fasl: (!) + (cond ((status feature ITS) + (load '|alan;struct boot|)) + ((status feature Multics) + (load '|>udd>Mathlab>Bawden>boot_defstruct|)))) + +#+Multics +(defun nth (n l) + (do ((n n (1- n)) + (l l (cdr l))) + ((zerop n) (car l)))) + +#+Multics +(defun nthcdr (n l) + (do ((n n (1- n)) + (l l (cdr l))) + ((zerop n) l))) + +#+Multics +(defun displace (x y) + (cond ((atom y) + (rplaca x 'progn) + (rplacd x (list y))) + (t + (rplaca x (car y)) + (rplacd x (cdr y)))) + x) + +(eval-when (eval compile load) + +#+MacLisp +(defun defstruct-retry-keyword (x) + (let ((l (exploden x))) + (if (= (car l) #/:) + (implode (cdr l)) + x))) + +#+LispM +(defun defstruct-retry-keyword (x) + (intern (get-pname x) si:pkg-user-package)) + +#+NIL +(defmacro defstruct-retry-keyword (x) + `(to-keyword ,x)) + +);End of eval-when (eval compile load) + +;;; Eval this before attempting incremental compilation +(eval-when (eval compile) + +#+MacLisp-10 +(defmacro append-symbols args + (do ((l (reverse args) (cdr l)) + (x) + (a nil (if (or (atom x) + (not (eq (car x) 'quote))) + (if (null a) + `(exploden ,x) + `(nconc (exploden ,x) ,a)) + (let ((l (exploden (cadr x)))) + (cond ((null a) `',l) + ((= 1 (length l)) `(cons ,(car l) ,a)) + (t `(append ',l ,a))))))) + ((null l) `(implode ,a)) + (setq x (car l)))) + +#+Multics +(defmacro append-symbols args + `(make_atom (catenate ,@args))) + +#+LispM +(defmacro append-symbols args + `(intern (string-append ,@args))) + +#+NIL +(defmacro append-symbols args + `(symbolconc ,@args)) + +(defmacro defstruct-putprop (sym val ind) + `(push `(defprop ,,sym ,,val ,,ind) returns)) + +#+Multics +;;;lcp gobbles (defprop ... macro) at compile time, so we have to use +;;;putprop to be certain macro definitions make it into the object: +(defmacro defstruct-put-macro (sym fcn) + `(push `(putprop ',,sym ',,fcn 'macro) returns)) + +#+MacLisp-10 +(defmacro defstruct-put-macro (sym fcn) + `(push `(defprop ,,sym ,,fcn macro) returns)) + +#+LispM +(defmacro defstruct-put-macro (sym fcn) + (setq fcn (if (and (not (atom fcn)) + (eq (car fcn) 'quote)) + `'(macro . ,(cadr fcn)) + `(cons 'macro ,fcn))) + `(push `(fdefine ',,sym ',,fcn t) returns)) + +#+NIL +(defmacro defstruct-put-macro (sym fcn) + `(push `(add-macro-definition ',,sym ',,fcn) returns)) + +(defmacro make-empty () `'%%defstruct-empty%%) + +(defmacro emptyp (x) `(eq ,x '%%defstruct-empty%%)) + +;;;Here we must deal with the fact that error reporting works +;;;differently everywhere! + +#+MacLisp-10 +;;;first arg is ALWAYS a symbol or a quoted symbol: +(defmacro defstruct-error (message &rest args) + (let* ((chars (nconc (exploden (if (atom message) + message + (cadr message))) + '(#/.))) ;"Bad frob" => "Bad frob." + (new-message + (maknam (if (null args) + chars + (let ((c (car chars))) ;"Bad frob." => "-- bad frob." + (or (< c #/A) + (> c #/Z) + (rplaca chars (+ c #o40))) + (append '(#/- #/- #\space) chars)))))) + `(error ',new-message + ,@(cond ((null args) `()) + ((null (cdr args)) `(,(car args))) + (t `((list ,@args))))))) + +#+Multics +;;;first arg is ALWAYS a string: +(defmacro defstruct-error (message &rest args) + `(error ,(catenate "defstruct: " + message + (if (null args) + "." + ": ")) + ,@(cond ((null args) `()) + ((null (cdr args)) `(,(car args))) + (t `((list ,@args)))))) + +#+(or LispM NIL) +;;;first arg is ALWAYS a string: +(defmacro defstruct-error (message &rest args) + (do ((l args (cdr l)) + (fs "") + (na nil)) + ((null l) + `(ferror nil + ,(string-append message + (if (null args) + "." + (string-append ":" fs))) + ,.(nreverse na))) + (cond ((and (not (atom (car l))) + (eq (caar l) 'quote) + (symbolp (cadar l))) + (setq fs (string-append fs " " (string-downcase (cadar l))))) + (t + (push (car l) na) + (setq fs (string-append fs " ~S")))))) + +);End of eval-when (eval compile) + +;;;If you mung the the ordering af any of the slots in this structure, +;;;be sure to change the version slot and the definition of the function +;;;get-defstruct-description. Munging the defstruct-slot-description +;;;structure should also cause you to change the version "number" in this +;;;manner. +(defstruct (defstruct-description + (:type :list) + (:default-pointer description) + (:conc-name defstruct-description-) + (:alterant ()) + #+stingy-defstruct + (:eval-when (eval compile))) + (version 'one) + type + dummy ;used to be the displace function + slot-alist + named-p + constructors + (default-pointer nil) + (but-first nil) + size + (property-alist nil) + ;;end of "expand-time" slots + name + include + (initial-offset 0) + (eval-when '(eval compile load)) + alterant + (conc-name nil) + (callable-accessors #-(or LispM NIL) nil #+(or LispM NIL) t) + (size-macro nil) + (size-symbol nil) + (predicate nil) + (copier nil) + (print nil) + ) + +(defun get-defstruct-description (name) + (let ((description (get name 'defstruct-description))) + (cond ((null description) + (defstruct-error + "A structure with this name has not been defined" name)) + ((not (eq (defstruct-description-version) 'one)) + (defstruct-error "The internal description of this structure is +incompatible with the currently loaded version of defstruct, +you will need to recompile its definition" + name)) + (t description)))) + +;;;See note above defstruct-description structure before munging this one. +(defstruct (defstruct-slot-description + (:type :list) + (:default-pointer slot-description) + (:conc-name defstruct-slot-description-) + (:alterant ()) + #+stingy-defstruct + (:eval-when (eval compile))) + number + (ppss nil) + init-code + (type 'notype) + (property-alist nil) + ref-macro-name + ) + +;;;Perhaps this structure wants a version slot too? +(defstruct (defstruct-type-description + (:type :list) + (:default-pointer type-description) + (:conc-name defstruct-type-description-) + (:alterant ()) + #+stingy-defstruct + (:eval-when (eval compile))) + ref-expander + ref-no-args + cons-expander + cons-flavor + (cons-keywords nil) + (named-type nil) + (overhead 0) + (defstruct-expander nil) + (predicate nil) + (copier nil) + ) + +;; (DEFSTRUCT ( . ) . ) or (DEFSTRUCT . ) +;; +;; is of the form (