diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 87413ce..b090abe 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -1068,7 +1068,6 @@ For instance, for the file {\tt EQ.spad}, we get: \calls{preparse1}{parsepiles} \calls{preparse1}{doSystemCommand} \calls{preparse1}{escaped} -\calls{preparse1}{instring} \calls{preparse1}{indent-pos} \calls{preparse1}{make-full-cvec} \calls{preparse1}{maxindex} @@ -9013,6 +9012,49 @@ loop \chapter{Utility Functions} +\defun{addclose}{addclose} +\calls{addclose}{suffix} +<>= +(defun addclose (line char) + (cond + ((char= (char line (maxindex line)) #\; ) + (setelt line (maxindex line) char) + (if (char= char #\;) line (suffix #\; line))) + ((suffix char line)))) + +@ + +\defun{blankp}{blankp} +<>= +(defun blankp (char) + (or (eq char #\Space) (eq char #\tab))) + +@ + +\defun{drop}{drop} +Return a pointer to the Nth cons of X, counting 0 as the first cons. +\calls{drop}{drop} +\calls{drop}{take} +\calls{drop}{croak} +<>= +(defun drop (n x &aux m) + (cond + ((eql n 0) x) + ((> n 0) (drop (1- n) (cdr x))) + ((>= (setq m (+ (length x) n)) 0) (take m x)) + ((croak (list "Bad args to DROP" n x))))) + +@ + +\defun{escaped}{escaped} +\uses{escaped}{xcape} +<>= +(defun escaped (str n) + (declare (special xcape)) + (and (> n 0) (eq (char str (1- n)) xcape))) + +@ + \defun{fincomblock}{fincomblock} \begin{itemize} \item NUM is the line number of the current line @@ -9047,6 +9089,50 @@ loop @ +\defun{indent-pos}{indent-pos} +<>= +(defun indent-pos (str) + (do ((i 0 (1+ i)) (pos 0)) + ((>= i (length str)) nil) + (case (char str i) + (#\space (incf pos)) + (#\tab (setq pos (next-tab-loc pos))) + (otherwise (return pos))))) + +@ + +\defun{infixtok}{infixtok} +\calls{infixtok}{string2id-n} +<>= +(defun infixtok (s) + (member (string2id-n s 1) '(|then| |else|) :test #'eq)) + +@ + +\defun{is-console}{is-console} +\calls{is-console}{fp-output-stream} +\uses{is-console}{*terminal-io*} +<>= +(defun is-console (stream) + (and (streamp stream) (output-stream-p stream) + (eq (system:fp-output-stream stream) + (system:fp-output-stream *terminal-io*)))) + +@ + +\defun{next-tab-loc}{next-tab-loc} +<>= +(defun next-tab-loc (i) + (* (1+ (truncate i 8)) 8)) + +@ + +\defun{nonblankloc}{nonblankloc} +\calls{nonblankloc}{blankp} +<>= +(defun nonblankloc (str) + (position-if-not #'blankp str)) + \defun{parseprint}{parseprint} <>= (defun parseprint (l) @@ -9057,6 +9143,23 @@ loop @ +\defun{skip-to-endif}{skip-to-endif} +\calls{skip-to-endif}{initial-substring} +\calls{skip-to-endif}{preparseReadLine} +\calls{skip-to-endif}{preparseReadLine1} +\calls{skip-to-endif}{skip-to-endif} +<>= +(defun skip-to-endif (x) + (let (line ind) + (dcq (ind . line) (preparseReadLine1 x)) + (cond + ((not (stringp line)) (cons ind line)) + ((initial-substring line ")endif") (preparseReadLine x)) + ((initial-substring line ")fin") (cons ind nil)) + (t (skip-to-endif x))))) + +@ + \chapter{The Compiler} \section{Compiling EQ.spad} @@ -11748,6 +11851,7 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> <> <> <> @@ -11755,6 +11859,8 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> + <> <> <> @@ -11876,9 +11982,11 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> <> +<> <> <> +<> <> <> @@ -11895,9 +12003,12 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> +<> <> <> <> +<> <> @@ -11913,8 +12024,10 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> <> <> +<> <> @@ -12093,6 +12206,7 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> <> <> <> diff --git a/changelog b/changelog index cf63928..ea59a92 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +20101208 tpd src/axiom-website/patches.html 20101208.01.tpd.patch +20101208 tpd src/interp/vmlisp.lisp treeshake compiler +20101208 tpd src/interp/parsing.lisp treeshake compiler +20101208 tpd books/bookvol9 treeshake compiler 20101207 tpd src/axiom-website/patches.html 20101207.01.tpd.patch 20101207 tpd src/interp/vmlisp.lisp treeshake compiler 20101207 tpd src/interp/parsing.lisp treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index b204c20..0c44112 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3305,5 +3305,7 @@ books/bookvol9 treeshake compiler
books/bookvol9 merge and remove postprop.lisp
20101207.01.tpd.patch books/bookvol9 treeshake compiler
+20101208.01.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index 57b274a..63aae92 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -1569,25 +1569,7 @@ preparse (RETURN (CONS IND NIL)))))) (RETURN (SKIP-IFBLOCK X)) ) ) -(DEFUN SKIP-TO-ENDIF (X) - (PROG (LINE IND) - (DCQ (IND . LINE) (preparseReadLine1 X)) - (COND ((NOT (STRINGP LINE)) (RETURN (CONS IND LINE))) - ((INITIAL-SUBSTRING LINE ")endif") - (RETURN (preparseReadLine X))) - ((INITIAL-SUBSTRING LINE ")fin") (RETURN (CONS IND NIL))) - ('T (RETURN (SKIP-TO-ENDIF X)))))) - -(defun ESCAPED (STR N) (and (> N 0) (EQ (CHAR STR (1- N)) XCAPE))) - -(defun INFIXTOK (S) (MEMBER (STRING2ID-N S 1) '(|then| |else|) :test #'eq)) - -(defun ADDCLOSE (LINE CHAR) - (cond ((char= (char LINE (MAXINDEX LINE)) #\; ) - (SETELT LINE (MAXINDEX LINE) CHAR) - (if (char= CHAR #\;) LINE (suffix #\; LINE))) - ((suffix char LINE)))) @ parse <<*>>= diff --git a/src/interp/vmlisp.lisp.pamphlet b/src/interp/vmlisp.lisp.pamphlet index e019c30..eca79fd 100644 --- a/src/interp/vmlisp.lisp.pamphlet +++ b/src/interp/vmlisp.lisp.pamphlet @@ -146,9 +146,6 @@ documentclass{article} (defmacro mapelt (f vec) `(map 'vector ,f ,vec)) -(defmacro maxindex (x) - `(the fixnum (1- (the fixnum (length ,x))))) - (defmacro minus (x) `(- ,x)) @@ -573,13 +570,13 @@ documentclass{article} ; 9.13 Streams -(defun IS-CONSOLE (stream) - (and (streamp stream) (output-stream-p stream) - (eq (system:fp-output-stream stream) - (system:fp-output-stream *terminal-io*)))) - ; 10.0 Control Structures +;;; 20101207 tpd moving this from vmlisp breaks the build. +(defmacro maxindex (x) + `(the fixnum (1- (the fixnum (length ,x))))) + + ; 10.8.4 Auxiliary Operators (defun nilfn (&rest ignore) @@ -3495,13 +3492,6 @@ LP (COND ((NULL X) (define-function 'LISPELT #'ELT) -(defun DROP (N X &aux m) - "Return a pointer to the Nth cons of X, counting 0 as the first cons." - (COND ((EQL N 0) X) - ((> N 0) (DROP (1- N) (CDR X))) - ((>= (setq m (+ (length x) N)) 0) (take m x)) - ((CROAK (list "Bad args to DROP" N X))))) - (DEFUN TAKE (N X &aux m) "Returns a list of the first N elements of list X." (COND ((EQL N 0) NIL) @@ -4054,19 +4044,6 @@ terminals and empty or at-end files. In Common Lisp, we must assume record size (terpri stream) (finish-output stream))) -;; moved here from preparse.lisp - -(defun NEXT-TAB-LOC (i) (* (1+ (truncate i 8)) 8)) - -(defun INDENT-POS (STR) - (do ((i 0 (1+ i)) - (pos 0)) - ((>= i (length str)) nil) - (case (char str i) - (#\space (incf pos)) - (#\tab (setq pos (next-tab-loc pos))) - (otherwise (return pos))))) - ;;(defun expand-tabs (str) ;; (let ((bpos (nonblankloc str)) ;; (tpos (indent-pos str))) @@ -4088,9 +4065,6 @@ terminals and empty or at-end files. In Common Lisp, we must assume record size (if (eq (char str lpos) #\Return) (subseq str 0 lpos) str))) str)) -(defun blankp (char) (or (eq char #\Space) (eq char #\tab))) - -(defun nonblankloc (str) (position-if-not #'blankp str)) ;; stream handling for paste-in generation