diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index 1301f29..1140d6d 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -34564,6 +34564,18 @@ Compile with noisy output @ +\defun{ncINTERPFILE}{Interpreter interface to the compiler} +\calls{ncINTERPFILE}{SpadInterpretStream} +\usesdollar{ncINTERPFILE}{EchoLines} +\usesdollar{ncINTERPFILE}{ReadingFile} +<>= +(defun |ncINTERPFILE| (file echo) + (let ((|$EchoLines| echo) (|$ReadingFile| t)) + (declare (special |$EchoLines| |$ReadingFile|)) + (|SpadInterpretStream| 1 file nil))) + +@ + \defvar{boot-line-stack} <>= (defvar boot-line-stack nil "List of lines returned from preparse") @@ -34620,6 +34632,7 @@ Compile with noisy output \uses{spad}{*eof*} \uses{spad}{file-closed} \uses{spad}{xcape} +\catches{spad}{spad-reader} <>= (defun spad (&optional (*spad-input-file* nil) (*spad-output-file* nil) &aux (*comp370-apply* #'print-defun) @@ -34806,6 +34819,7 @@ searchCurrentEnv(x,currentEnv) == @ +\chapter{File Parsing} \defun{addBindingInteractive}{Bind a variable in the interactive environment} \calls{addBindingInteractive}{assq} <>= @@ -34870,6 +34884,227 @@ searchCurrentEnv(x,currentEnv) == @ +<>= +(defvar $index 0 "File line number of most recently read line") + +@ + +<>= +(defvar $linelist nil "Stack of preparsed lines") + +@ + +<>= +(defvar echolinestack nil "Stack of lines to list") + +@ + +<>= +(defvar $preparse-last-line nil "Most recently read line") + +@ + +\defun{initialize-preparse}{initialize-preparse} +\calls{initialize-preparse}{get-a-line} +\usesdollar{initialize-preparse}{index} +\usesdollar{initialize-preparse}{linelist} +\usesdollar{initialize-preparse}{echolinestack} +\usesdollar{initialize-preparse}{preparse-last-line} +<>= +(defun initialize-preparse (strm) + (setq $index 0) + (setq $linelist nil) + (setq $echolinestack nil) + (setq $preparse-last-line (get-a-line strm))) + +@ + +\defun{preparse}{preparse} +\calls{preparse}{preparse} +\calls{preparse}{preparse1} +\calls{preparse}{parseprint} +\calls{preparse}{ifcar} +\usesdollar{preparse}{comblocklist} +\usesdollar{preparse}{skipme} +\usesdollar{preparse}{preparse-last-line} +\usesdollar{preparse}{index} +\usesdollar{preparse}{docList} +\usesdollar{preparse}{preparseReportIfTrue} +\usesdollar{preparse}{headerDocumentation} +\usesdollar{preparse}{maxSignatureLineNumber} +\usesdollar{preparse}{constructorLineNumber} +<>= +(defun preparse (strm &aux (stack ())) + (declare (special $comblocklist $skipme $preparse-last-line $index |$docList| + $preparseReportIfTrue |$headerDocumentation| + |$maxSignatureLineNumber| |$constructorLineNumber|)) + (setq $comblocklist nil) + (setq $skipme nil) + (when $preparse-last-line + (if (pairp $preparse-last-line) + (setq stack $preparse-last-line) + (push $preparse-last-line stack)) + (setq $index (- $index (length stack)))) + (let ((u (preparse1 stack))) + (if $skipme + (preparse strm) + (progn + (when $preparseReportIfTrue (parseprint u)) + (setq |$headerDocumentation| nil) + (setq |$docList| nil) + (setq |$maxSignatureLineNumber| 0) + (setq |$constructorLineNumber| (ifcar (ifcar u))) + u)))) + +@ + +\defun{preparse1}{Build the lines from the input for piles} +\calls{preparse1}{preparseReadLine} +\calls{preparse1}{atEndOfUnit} +\calls{preparse1}{preparse-echo} +\calls{preparse1}{fincomblock} +\calls{preparse1}{parsepiles} +\calls{preparse1}{doSystemCommand} +\calls{preparse1}{escaped} +\calls{preparse1}{instring} +\calls{preparse1}{indent-pos} +\calls{preparse1}{getfullstr} +\calls{preparse1}{droptrailingblanks} +\calls{preparse1}{maxindex} +\calls{preparse1}{strposl} +\calls{preparse1}{is-console} +\catches{preparse1}{spad-reader} +\usesdollar{preparse1}{linelist} +\usesdollar{preparse1}{echolinestack} +\usesdollar{preparse1}{byConstructors} +\usesdollar{preparse1}{skipme} +\usesdollar{preparse1}{constructorsSeen} +\usesdollar{preparse1}{preparse-last-line} +<>= +(defun preparse1 (linelist) + (prog (($linelist linelist) $echolinestack num a i l psloc + instring pcount comsym strsym oparsym cparsym n ncomsym + (sloc -1) (continue nil) (parenlev 0) (ncomblock ()) + (lines ()) (locs ()) (nums ()) functor) + (declare (special $linelist $echolinestack |$byConstructors| $skipme + |$constructorsSeen| $preparse-last-line)) +READLOOP + (dcq (num . a) (preparseReadLine linelist)) + (when (atEndOfUnit a) + (preparse-echo linelist) + (cond + ((null lines) (return nil)) + (ncomblock (fincomblock nil nums locs ncomblock nil))) + (return + (pair (nreverse nums) (parsepiles (nreverse locs) (nreverse lines))))) + ; this is a command line, don't parse it + (when (and (null lines) (> (length a) 0) (eq (char a 0) #\) )) + (preparse-echo linelist) + (setq $preparse-last-line nil) ;don't reread this line + (setq line a) + (catch 'spad_reader (|doSystemCommand| (subseq line 1))) + (go READLOOP)) + (setq l (length a)) + ; if we get a null line, read the next line + (when (eq l 0) (go READLOOP)) + ; otherwise we have to parse this line + (setq psloc sloc) + (setq i 0) + (setq instring nil) + (setq pcount 0) +STRLOOP ;; handle things that need ignoring, quoting, or grouping + ; are we in a comment, quoting, or grouping situation? + (setq strsym (or (position #\" a :start i ) l)) + (setq comsym (or (search "--" a :start2 i ) l)) + (setq ncomsym (or (search "++" a :start2 i ) l)) + (setq oparsym (or (position #\( a :start i ) l)) + (setq cparsym (or (position #\) a :start i ) l)) + (setq n (min strsym comsym ncomsym oparsym cparsym)) + (cond + ; nope, we found no comment, quoting, or grouping + ((= n l) (go NOCOMS)) + ((escaped a n)) + ; scan until we hit the end of the string + ((= n strsym) (setq instring (not instring))) + (instring) + ;; handle -- comments by ignoring them + ((= n comsym) + (setq a (subseq a 0 n)) + (go NOCOMS)) ; discard trailing comment + ;; handle ++ comments by chunking them together + ((= n ncomsym) + (setq sloc (indent-pos a)) + (cond + ((= sloc n) + (when (and ncomblock (not (= n (car ncomblock)))) + (fincomblock num nums locs ncomblock linelist) + (setq ncomblock nil)) + (setq ncomblock (cons n (cons a (ifcdr ncomblock)))) + (setq a "")) + (t + (push (strconc (getfullstr n " ") (substring a n ())) $linelist) + (setq $index (1- $index)) + (setq a (subseq a 0 n)))) + (go NOCOMS)) + ; know how deep we are into parens + ((= n oparsym) (setq pcount (1+ pcount))) + ((= n cparsym) (setq pcount (1- pcount)))) + (setq i (1+ n)) + (go STRLOOP) +NOCOMS + ; remember the indentation level + (setq sloc (indent-pos a)) + (setq a (droptrailingblanks a)) + (when (null sloc) + (setq sloc psloc) + (go READLOOP)) + ; handle line that ends in a continuation character + (cond + ((eq (elt a (maxindex a)) xcape) + (setq continue t) + (setq a (subseq a (maxindex a)))) + ((setq continue nil))) + ; test for skipping constructors + (when (and (null lines) (= sloc 0)) + (if (and |$byConstructors| + (null (search "==>" a)) + (not + (member + (setq functor + (intern (substring a 0 (strposl ": (=" a 0 nil)))) + |$byConstructors|))) + (setq $skipme 't) + (progn + (push functor |$constructorsSeen|) + (setq $skipme nil)))) + ; is this thing followed by ++ comments? + (when (and lines (eql sloc 0)) + (when (and ncomblock (not (zerop (car ncomblock)))) + (fincomblock num nums locs ncomblock linelist)) + (when (not (is-console in-stream)) + (setq $preparse-last-line (nreverse $echolinestack))) + (return + (pair (nreverse nums) (parsepiles (nreverse locs) (nreverse lines))))) + (when (> parenlev 0) + (push nil locs) + (setq sloc psloc) + (go REREAD)) + (when ncomblock + (fincomblock num nums locs ncomblock linelist) + (setq ncomblock ())) + (push sloc locs) +REREAD + (preparse-echo linelist) + (push a lines) + (push num nums) + (setq parenlev (+ parenlev pcount)) + (when (and (is-console in-stream) (not continue)) + (setq $preparse-last-line nil) + (return + (pair (nreverse nums) (parsepiles (nreverse locs) (nreverse lines))))) + (go READLOOP))) + +@ \chapter{Handling output} \section{Special Character Tables} @@ -40039,6 +40274,7 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> <> <> <> @@ -40216,6 +40452,7 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> <> <> <> @@ -40714,6 +40951,8 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> +<> <> <> <> @@ -40914,6 +41153,7 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> <> <> <> diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index c6d12f9..2cad8ab 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -841,6 +841,48 @@ Compile a library quietly @ +\defun{recompile-lib-file-if-necessary}{recompile-lib-file-if-necessary} +\calls{recompile-lib-file-if-necessary}{compile-lib-file} +\uses{recompile-lib-file-if-necessary}{*lisp-bin-filetype*} +<>= +(defun recompile-lib-file-if-necessary (lfile) + (let* ((bfile (make-pathname :type *lisp-bin-filetype* :defaults lfile)) + (bdate (and (probe-file bfile) (file-write-date bfile))) + (ldate (and (probe-file lfile) (file-write-date lfile)))) + (unless (and ldate bdate (> bdate ldate)) + (compile-lib-file lfile) + (list bfile)))) + +@ + +\defun{spad-fixed-arg}{spad-fixed-arg} +<>= +(defun spad-fixed-arg (fname ) + (and (equal (symbol-package fname) (find-package "BOOT")) + (not (get fname 'compiler::spad-var-arg)) + (search ";" (symbol-name fname)) + (or (get fname 'compiler::fixed-args) + (setf (get fname 'compiler::fixed-args) t))) + nil) + +@ + +\defun{compile-lib-file}{compile-lib-file} +<>= +(defun compile-lib-file (fn &rest opts) + (unwind-protect + (progn + (trace (compiler::fast-link-proclaimed-type-p + :exitcond nil + :entrycond (spad-fixed-arg (car system::arglist)))) + (trace (compiler::t1defun + :exitcond nil + :entrycond (spad-fixed-arg (caar system::arglist)))) + (apply #'compile-file fn opts)) + (untrace compiler::fast-link-proclaimed-type-p compiler::t1defun))) + +@ + \defun{compileAsharpCmd}{compileAsharpCmd} \calls{compileAsharpCmd}{terminateSystemCommand(5)} \calls{compileAsharpCmd}{compileAsharpCmd1} @@ -1140,11 +1182,14 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> <> +<> <> <> <> <> +<> <> +<> <> @ diff --git a/changelog b/changelog index 67b7b6f..e0de596 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +20100815 tpd src/axiom-website/patches.html 20100815.01.tpd.patch +20100815 tpd src/interp/vmlisp.lisp treeshake the compiler code +20100815 tpd src/interp/parsing.lisp treeshake the compiler code +20100815 tpd src/interp/nci.lisp treeshake the compiler code +20100815 tpd books/bookvol5 treeshake the compiler code +20100815 tpd books/bookvol9 treeshake the compiler code 20100814 tpd src/axiom-website/patches.html 20100814.02.tpd.patch 20100814 tpd src/interp/patches.lisp treeshake the compile code 20100814 tpd src/interp/compiler.lisp treeshake the compiler code diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 0892fd3..4fabe41 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3065,5 +3065,7 @@ src/axiom-website/download.html update ubuntu yum advice
books/bookvol9 cross-reference functions and variables
20100814.02.tpd.patch books/bookvol9 treeshake the compiler code
+20100815.01.tpd.patch +books/bookvol9 treeshake the compiler code
diff --git a/src/interp/nci.lisp.pamphlet b/src/interp/nci.lisp.pamphlet index 29fd34a..28afa58 100644 --- a/src/interp/nci.lisp.pamphlet +++ b/src/interp/nci.lisp.pamphlet @@ -28,11 +28,6 @@ (|zeroOneTran| (|packageTran| (catch 'SPAD_READER (|parseFromString| s))))) -(defun |ncINTERPFILE| (file echo) - (let ((|$EchoLines| echo) (|$ReadingFile| t)) - (declare (special |$EchoLines| |$ReadingFile|)) - (|SpadInterpretStream| 1 file nil))) - (defun |ncGetFunction| (op dom sig) (|applyInPackage| #'|getNCfunction| (list (|rePackageTran| op "boot") diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index 59723bd..f166421 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -3211,17 +3211,9 @@ preparse <<*>>= ; Global storage -(defparameter $INDEX 0 "File line number of most recently read line.") -(defparameter $preparse-last-line () "Most recently read line.") (defparameter $preparseReportIfTrue NIL "Should we print listings?") -(defparameter $LineList nil "Stack of preparsed lines.") -(defparameter $EchoLineStack nil "Stack of lines to list.") (defparameter $IOIndex 0 "Number of latest terminal input line.") -(defun Initialize-Preparse (strm) - (setq $INDEX 0 $LineList nil $EchoLineStack nil) - (setq $preparse-last-line (get-a-line strm))) - (defmacro pptest () `(/rp ">scratchpad>test.boot")) (defun /RP (&optional (*boot-input-file* nil) (*boot-output-file* nil) @@ -3239,114 +3231,6 @@ preparse (do ((lines (PREPARSE in-stream) (PREPARSE in-stream))) ((null lines))))) T) -(defun PREPARSE (Strm &aux (stack ())) - (SETQ $COMBLOCKLIST NIL $skipme NIL) - (when $preparse-last-line - (if (pairp $preparse-last-line) - (setq stack $preparse-last-line) - (push $preparse-last-line stack)) - (setq $INDEX (- $INDEX (length stack)))) - (let ((U (PREPARSE1 stack))) - (if $skipme (preparse strm) - (progn - (if $preparseReportIfTrue (PARSEPRINT U)) - (setq |$headerDocumentation| NIL) - (SETQ |$docList| NIL) - (SETQ |$maxSignatureLineNumber| 0) - (SETQ |$constructorLineNumber| (IFCAR (IFCAR U))) - U)))) - -(defun PREPARSE1 (LineList) - (PROG (($LINELIST LineList) $EchoLineStack NUM A I L PSLOC - INSTRING PCOUNT COMSYM STRSYM OPARSYM CPARSYM N NCOMSYM - (SLOC -1) (CONTINUE NIL) (PARENLEV 0) (NCOMBLOCK ()) - (LINES ()) (LOCS ()) (NUMS ()) functor ) - READLOOP (DCQ (NUM . A) (preparseReadLine LineList)) - (cond ((atEndOfUnit A) - (PREPARSE-ECHO LineList) - (COND ((NULL LINES) (RETURN NIL)) - (NCOMBLOCK - (FINCOMBLOCK NIL NUMS LOCS NCOMBLOCK NIL))) - (RETURN (PAIR (NREVERSE NUMS) - (PARSEPILES (NREVERSE LOCS) (NREVERSE LINES)))))) - (cond ((and (NULL LINES) (> (LENGTH A) 0) (EQ (CHAR A 0) #\) )) - ; this is a command line, don't parse it - (PREPARSE-ECHO LineList) - (setq $preparse-last-line nil) ;don't reread this line - (SETQ LINE a) - (CATCH 'SPAD_READER (|doSystemCommand| (subseq LINE 1))) - (GO READLOOP))) - (setq L (LENGTH A)) - (if (EQ L 0) (GO READLOOP)) - (setq PSLOC SLOC) - (setq I 0 INSTRING () PCOUNT 0) - STRLOOP (setq STRSYM (OR (position #\" A :start I ) L)) - (setq COMSYM (OR (search "--" A :start2 I ) L)) - (setq NCOMSYM (OR (search "++" A :start2 I ) L)) - (setq OPARSYM (OR (position #\( A :start I ) L)) - (setq CPARSYM (OR (position #\) A :start I ) L)) - (setq N (MIN STRSYM COMSYM NCOMSYM OPARSYM CPARSYM)) - (cond ((= N L) (GO NOCOMS)) - ((ESCAPED A N)) - ((= N STRSYM) (setq INSTRING (NOT INSTRING))) - (INSTRING) - ((= N COMSYM) (setq A (subseq A 0 N)) (GO NOCOMS)) ; discard trailing comment - ((= N NCOMSYM) - (setq SLOC (INDENT-POS A)) - (COND - ((= SLOC N) - (COND ((AND NCOMBLOCK (NOT (= N (CAR NCOMBLOCK)))) - (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist) - (SETQ NCOMBLOCK NIL))) - (SETQ NCOMBLOCK (CONS N (CONS A (IFCDR NCOMBLOCK)))) - (SETQ A "")) - ('T (PUSH (STRCONC (GETFULLSTR N " ") - (SUBSTRING A N ())) $LINELIST) - (SETQ $INDEX (SUB1 $INDEX)) - (SETQ A (SUBSEQ A 0 N)))) - (GO NOCOMS)) - ((= N OPARSYM) (setq PCOUNT (1+ PCOUNT))) - ((= N CPARSYM) (setq PCOUNT (1- PCOUNT)))) - (setq I (1+ N)) - (GO STRLOOP) - NOCOMS (setq SLOC (INDENT-POS A)) - (setq A (DROPTRAILINGBLANKS A)) - (cond ((NULL SLOC) (setq SLOC PSLOC) (GO READLOOP))) - (cond ((EQ (ELT A (MAXINDEX A)) XCAPE) - (setq CONTINUE T a (subseq A (MAXINDEX A)))) - ((setq CONTINUE NIL))) - (if (and (null LINES) (= SLOC 0)) ;;test for skipping constructors - (if (and |$byConstructors| - (null (search "==>" a)) - (not (member (setq functor (intern - (substring a 0 (STRPOSL ": (=" A 0 NIL)))) - |$byConstructors|))) - (setq $skipme 't) - (progn (push functor |$constructorsSeen|) (setq $skipme nil)))) - (when (and LINES (EQL SLOC 0)) - (IF (AND NCOMBLOCK (NOT (ZEROP (CAR NCOMBLOCK)))) - (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist)) - (IF (NOT (IS-CONSOLE in-stream)) - (setq $preparse-last-line - (nreverse $echolinestack))) - (RETURN (PAIR (NREVERSE NUMS) - (PARSEPILES (NREVERSE LOCS) (NREVERSE LINES))))) - (cond ((> PARENLEV 0) (PUSH NIL LOCS) (setq SLOC PSLOC) (GO REREAD))) - (COND (NCOMBLOCK - (FINCOMBLOCK NUM NUMS LOCS NCOMBLOCK linelist) - (setq NCOMBLOCK ()))) - (PUSH SLOC LOCS) - REREAD (PREPARSE-ECHO LineList) - (PUSH A LINES) - (PUSH NUM NUMS) - (setq PARENLEV (+ PARENLEV PCOUNT)) - (when (and (is-console in-stream) (not continue)) - (setq $preparse-last-line nil) - (RETURN (PAIR (NREVERSE NUMS) - (PARSEPILES (NREVERSE LOCS) (NREVERSE LINES))))) - - (GO READLOOP))) - ;; NUM is the line number of the current line ;; OLDNUMS is the list of line numbers of previous lines ;; OLDLOCS is the list of previous indentation locations diff --git a/src/interp/vmlisp.lisp.pamphlet b/src/interp/vmlisp.lisp.pamphlet index 24030f5..a84c648 100644 --- a/src/interp/vmlisp.lisp.pamphlet +++ b/src/interp/vmlisp.lisp.pamphlet @@ -2125,14 +2125,6 @@ do the compile, and then rename the result back to code.o. (rshut nrstream))) filespec) -(defun recompile-lib-file-if-necessary (lfile) - (let* ((bfile (make-pathname :type *lisp-bin-filetype* :defaults lfile)) - (bdate (and (probe-file bfile) (file-write-date bfile))) - (ldate (and (probe-file lfile) (file-write-date lfile)))) - (if ldate - (if (and bdate (> bdate ldate)) nil - (progn (compile-lib-file lfile) (list bfile)))))) - (defun spad-fixed-arg (fname ) (and (equal (symbol-package fname) (find-package "BOOT")) (not (get fname 'compiler::spad-var-arg)) @@ -2141,17 +2133,6 @@ do the compile, and then rename the result back to code.o. (setf (get fname 'compiler::fixed-args) t))) nil) -(defun compile-lib-file (fn &rest opts) - (unwind-protect - (progn - (trace (compiler::fast-link-proclaimed-type-p - :exitcond nil - :entrycond (spad-fixed-arg (car system::arglist)))) - (trace (compiler::t1defun :exitcond nil - :entrycond (spad-fixed-arg (caar system::arglist)))) - (apply #'compile-file fn opts)) - (untrace compiler::fast-link-proclaimed-type-p compiler::t1defun))) - ;; (RDROPITEMS filearg keys) don't delete, used in files.spad (defun rdropitems (filearg keys &aux (ctable (getindextable filearg))) (mapc #'(lambda(x)