;;; This file contains a general Common Lisp function for reading Lisp ;;; forms from an input file, and writing those forms, and their results ;;; to an output file. The output file need not exist beforehand. ;;; ;;; written by Kurt Krebsbach 4/9/87 (defun produce-output-file (in-file out-file) "Reads in forms, one at a time, from the in-file, writing both the form and the result of evaluating the form to the out-file" (with-open-file (in-stream in-file :direction :input) (with-open-file (out-stream out-file :direction :output :if-exists :supersede) (do ((form (read in-stream nil 'eof-flag) ; initial value (read in-stream nil 'eof-flag))) ; step value ((equal form 'eof-flag) ; termination test (format t "~%File ~A is written" out-file)) ; message (progn (format out-stream ; write the form "~%Form:~%>>>>>~%~A~%" form) (format out-stream "~%Result:~%<<<<<~%~A~%" (eval form)) ; write the result )) )))