diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 0e4715a..13b5fa4 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -1371,6 +1371,41 @@ Symbolics read-line returns embedded newlines in a c-m-Y.") \section{Line Handling} +\subsection{Line Buffer} +The philosophy of lines is that +\begin{itemize} +\item NEXT LINE will always return a non-blank line or fail. +\item Every line is terminated by a blank character. +\end{itemize} +Hence there is always a current character, because there is never a +non-blank line, and there is always a separator character between tokens +on separate lines. Also, when a line is read, the character pointer is +always positioned ON the first character. +\defstruct{Line} +<>= +;(defstruct Line "Line of input file to parse." +; (Buffer (make-string 0) :type string) +; (Current-Char #\Return :type character) +; (Current-Index 1 :type fixnum) +; (Last-Index 0 :type fixnum) +; (Number 0 :type fixnum)) + +@ + +\defun{Line-New-Line}{Line-New-Line} +\usesstruct{Line-New-Line}{Line} +<>= +(defun Line-New-Line (string line &optional (linenum nil)) + "Sets string to be the next line stored in line." + (setf (Line-Last-Index line) (1- (length string))) + (setf (Line-Current-Index line) 0) + (setf (Line-Current-Char line) + (or (and (> (length string) 0) (elt string 0)) #\Return)) + (setf (Line-Buffer line) string) + (setf (Line-Number line) (or linenum (1+ (Line-Number line))))) + +@ + \defun{storeblanks}{storeblanks} <>= (defun storeblanks (line n) @@ -1598,6 +1633,22 @@ Symbolics read-line returns embedded newlines in a c-m-Y.") @ +\defun{postError}{postError} +\calls{postError}{nequal} +\calls{postError}{bumperrorcount} +<>= +(defun |postError| (msg) + (let (xmsg) + (bumperrorcount '|precompilation|) + (setq xmsg + (if (and (nequal |$defOp| '|$defOp|) (null |InteractiveMode|)) + (cons |$defOp| (cons ": " msg)) + msg)) + (push xmsg |$postStack|) + nil)) + +@ + \defun{setDefOp}{setDefOp} \usesdollar{setDefOp}{defOp} \usesdollar{setDefOp}{topOp} @@ -1817,6 +1868,64 @@ Symbolics read-line returns embedded newlines in a c-m-Y.") @ +\chapter{DEF forms} + +\defun{def-process}{def-process} +\calls{def-process}{def} +\calls{def-process}{b-mdef} +\calls{def-process}{eqcar} +\calls{def-process}{def-process} +\calls{def-process}{is-console} +\calls{def-process}{say} +\calls{def-process}{deftran} +\calls{def-process}{print-full} +\calls{def-process}{deftran} +\usesdollar{def-process}{macroassoc} +<>= +(defun def-process (x &aux $macroassoc) + (cond + ((eqcar x 'def) + (def (second x) (third x) (first (cddddr x)))) + ((eqcar x 'mdef) + (b-mdef (second x) (third x) (first (cddddr x)))) + ((and (eqcar x 'where) (eqcar (second x) 'def)) + (let* ((u (second x)) (y (cdr u))) + (def-process + (list 'def + (car y) + (car (setq y (cdr y))) + (car (setq y (cdr y))) + (cons 'where (cons (car (setq y (cdr y))) (cddr x))))))) + ((is-console *standard-output*) + (say " VALUE = " (eval (deftran x)))) + ((print-full (deftran x))))) + +@ + +\defun{def-rename}{def-rename} +\calls{def-rename}{def-rename1} +<>= +(defun def-rename (x) + (def-rename1 x)) + +@ + +\defun{def-rename1}{def-rename1} +\calls{def-rename1}{def-rename1} +<>= +(defun def-rename1 (x) + (cond + ((symbolp x) + (let ((y (get x 'rename))) (if y (first y) x))) + ((and (listp x) x) + (if (eqcar x 'quote) + x + (cons (def-rename1 (first x)) (def-rename1 (cdr x))))) + (x))) + +@ + + \chapter{The Compiler} \section{Compiling EQ.spad} @@ -4878,8 +4987,8 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> -<> <> +<> <> <> @@ -4924,6 +5033,9 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> +<> +<> <> @@ -4938,6 +5050,8 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> +<> + <> <> @@ -4946,6 +5060,7 @@ if \verb|$InteractiveMode| then use a null outputstream <> <> <> +<> <> <> <> diff --git a/changelog b/changelog index e7d48b1..5d9aaed 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,8 @@ +20101007 tpd src/axiom-website/patches.html 20101007.01.tpd.patch +20101007 tpd src/interp/parsing.lisp treeshake compiler +20101007 tpd books/bookvol9 treeshake compiler +20101007 tpd src/scripts/tex/axiom.sty add usesstruct +20101007 tpd src/doc/axiom.sty.pamphlet add usesstruct 20101006 tpd src/axiom-website/patches.html 20101006.04.tpd.patch 20101006 tpd src/interp/parsing.lisp treeshake compiler 20101006 tpd books/bookvol9 treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 34d848d..206c152 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3200,5 +3200,7 @@ books/bookvol9 treeshake compiler
books/bookvol9 treeshake compiler
20101006.04.tpd.patch books/bookvol9 treeshake compiler
+20101007.01.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/doc/axiom.sty.pamphlet b/src/doc/axiom.sty.pamphlet index cb4bc2d..48ed547 100644 --- a/src/doc/axiom.sty.pamphlet +++ b/src/doc/axiom.sty.pamphlet @@ -254,6 +254,18 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% +%% uses marks a special variable use +%% if the special variable starts with dollar we need to fake it +%% +<>= +\newcommand{\usesstruct}[2]{% e.g. \usesstruct{thisfunc}{structname} +[\$#2 p\pageref{#2}]\\% +\index{\${#2}!{usedby #1}}% +\index{#1!{uses \${#2}}}} +@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% uses marks items that need attention %% <>= diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index e7c84f1..13c6124 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -42,18 +42,7 @@ Familiarity with this document is assumed. @ \section{Data structure declarations (defstructs) for parsing objects} <<*>>= -@ -\subsection{Line Buffer} -The philosophy of lines is that -\begin{itemize} -\item NEXT LINE will always get you a non-blank line or fail. -\item Every line is terminated by a blank character. -\end{itemize} -Hence there is always a current character, because there is never a -non-blank line, and there is always a separator character between tokens -on separate lines. Also, when a line is read, the character pointer is -always positioned ON the first character. -<<*>>= + (defstruct Line "Line of input file to parse." (Buffer (make-string 0) :type string) (Current-Char #\Return :type character) @@ -81,15 +70,6 @@ always positioned ON the first character. (Line-Current-Index line) (Line-Last-Index line)))) -(defun Line-New-Line (string line &optional (linenum nil)) - "Sets string to be the next line stored in line." - (setf (Line-Last-Index line) (1- (length string))) - (setf (Line-Current-Index line) 0) - (setf (Line-Current-Char line) - (or (and (> (length string) 0) (elt string 0)) #\Return)) - (setf (Line-Buffer line) string) - (setf (Line-Number line) (or linenum (1+ (Line-Number line))))) - (defun Line-Advance-Char (line) (setf (Line-Current-Char line) (elt (Line-Buffer line) (incf (Line-Current-Index line))))) @@ -1353,20 +1333,6 @@ foo defined inside of fum gets renamed as fum,foo.") (and (pairp x) (member (car x) '(|One| |Zero| LENGTH \# QCSIZE QVSIZE QLENGTH))))) -(defun DEF-PROCESS (X &aux $MACROASSOC) - (COND ((EQCAR X 'DEF) (DEF (SECOND X) (THIRD X) (FIRST (CDDDDR X)))) - ((EQCAR X 'MDEF) (B-MDEF (SECOND X) (THIRD X) (FIRST (CDDDDR X)))) - ((AND (EQCAR X 'WHERE) (EQCAR (cadr X) 'DEF)) - (let* ((u (cadr X)) (Y (cdr U))) - (DEF-PROCESS (LIST 'DEF - (car Y) - (car (setq Y (cdr Y))) - (car (setq Y (cdr Y))) - (CONS 'WHERE (cons (car (setq Y (cdr Y))) (cddr X))))))) - ((IS-CONSOLE *STANDARD-OUTPUT*) - (SAY " VALUE = " (EVAL (DEFTRAN X)))) - ((print-full (DEFTRAN X))))) - (defun B-MDEF (FORM SIGNATURE $BODY) (declare (ignore SIGNATURE)) (let* ($OpAssoc @@ -1444,16 +1410,6 @@ foo defined inside of fum gets renamed as fum,foo.") ; This two-level call allows DEF-RENAME to be locally bound to do ; nothing (see boot2Lisp) yet still allow function call (lisp2BootAndComp) -(defun DEF-RENAME (X) (DEF-RENAME1 X)) - -(defun DEF-RENAME1 (X) - (COND ((symbolp X) (let ((y (get x 'rename))) (if y (first y) x))) - ((and (listp X) X) - (if (EQCAR X 'QUOTE) - X - (CONS (DEF-RENAME1 (FIRST X)) (DEF-RENAME1 (CDR X))))) - (X))) - (defun DEFTRAN (X) (let (op Y) (COND ((STRINGP X) (DEF-STRING X)) @@ -4135,17 +4091,6 @@ parse ;;; *** |postConstruct| REDEFINED (DEFUN |postConstruct| (|u|) (PROG (|b| |a| |p| |ISTMP#2| |q| |l| |ISTMP#1| |y|) (RETURN (SEQ (COND ((AND (PAIRP |u|) (EQ (QCAR |u|) (QUOTE |construct|)) (PROGN (SPADLET |ISTMP#1| (QCDR |u|)) (AND (PAIRP |ISTMP#1|) (EQ (QCDR |ISTMP#1|) NIL) (PROGN (SPADLET |b| (QCAR |ISTMP#1|)) (QUOTE T))))) (SPADLET |a| (COND ((AND (PAIRP |b|) (EQ (QCAR |b|) (QUOTE |,|))) (|comma2Tuple| |b|)) ((QUOTE T) |b|))) (COND ((AND (PAIRP |a|) (EQ (QCAR |a|) (QUOTE SEGMENT)) (PROGN (SPADLET |ISTMP#1| (QCDR |a|)) (AND (PAIRP |ISTMP#1|) (PROGN (SPADLET |p| (QCAR |ISTMP#1|)) (SPADLET |ISTMP#2| (QCDR |ISTMP#1|)) (AND (PAIRP |ISTMP#2|) (EQ (QCDR |ISTMP#2|) NIL) (PROGN (SPADLET |q| (QCAR |ISTMP#2|)) (QUOTE T))))))) (CONS (QUOTE |construct|) (CONS (|postTranSegment| |p| |q|) NIL))) ((AND (PAIRP |a|) (EQ (QCAR |a|) (QUOTE |@Tuple|)) (PROGN (SPADLET |l| (QCDR |a|)) (QUOTE T))) (COND ((PROG (#0=#:G166378) (SPADLET #0# NIL) (RETURN (DO ((#1=#:G166388 NIL #0#) (#2=#:G166389 |l| (CDR #2#)) (|x| NIL)) ((OR #1# (ATOM #2#) (PROGN (SETQ |x| (CAR #2#)) NIL)) #0#) (SEQ (EXIT (SETQ #0# (OR #0# (AND (PAIRP |x|) (EQ (QCAR |x|) (QUOTE |:|)) (PROGN (SPADLET |ISTMP#1| (QCDR |x|)) (AND (PAIRP |ISTMP#1|) (EQ (QCDR |ISTMP#1|) NIL) (PROGN (SPADLET |y| (QCAR |ISTMP#1|)) (QUOTE T)))))))))))) (|postMakeCons| |l|)) ((PROG (#3=#:G166396) (SPADLET #3# NIL) (RETURN (DO ((#4=#:G166402 NIL #3#) (#5=#:G166403 |l| (CDR #5#)) (|x| NIL)) ((OR #4# (ATOM #5#) (PROGN (SETQ |x| (CAR #5#)) NIL)) #3#) (SEQ (EXIT (SETQ #3# (OR #3# (AND (PAIRP |x|) (EQ (QCAR |x|) (QUOTE SEGMENT)))))))))) (|tuple2List| |l|)) ((QUOTE T) (CONS (QUOTE |construct|) (|postTranList| |l|))))) ((QUOTE T) (CONS (QUOTE |construct|) (CONS (|postTran| |a|) NIL))))) ((QUOTE T) |u|)))))) -;postError msg == -; BUMPERRORCOUNT 'precompilation -; xmsg:= -; $defOp ^= '$defOp and not InteractiveMode => [$defOp,'": ",:msg] -; msg -; $postStack:= [xmsg,:$postStack] -; nil - -;;; *** |postError| REDEFINED - -(DEFUN |postError| (|msg|) (PROG (|xmsg|) (RETURN (PROGN (BUMPERRORCOUNT (QUOTE |precompilation|)) (SPADLET |xmsg| (COND ((AND (NEQUAL |$defOp| (QUOTE |$defOp|)) (NULL |InteractiveMode|)) (CONS |$defOp| (CONS ": " |msg|))) ((QUOTE T) |msg|))) (SPADLET |$postStack| (CONS |xmsg| |$postStack|)) NIL)))) ;postMakeCons l == ; null l => 'nil ; l is [[":",a],:l'] => diff --git a/src/scripts/tex/axiom.sty b/src/scripts/tex/axiom.sty index 0785095..f49836e 100644 --- a/src/scripts/tex/axiom.sty +++ b/src/scripts/tex/axiom.sty @@ -93,6 +93,10 @@ [\$#2 p\pageref{#2}]\\% \index{\${#2}!{usedby #1}}% \index{#1!{uses \${#2}}}} +\newcommand{\usesstruct}[2]{% e.g. \usesstruct{thisfunc}{structname} +[\$#2 p\pageref{#2}]\\% +\index{\${#2}!{usedby #1}}% +\index{#1!{uses \${#2}}}} \newcommand{\tpdhere}[1]{% e.g. \tpdhere{Some note} {\bf TPDHERE: #1}% \index{TPDHERE!{#1}}}