diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index 2ecc9af..2fc5268 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -4533,6 +4533,71 @@ always positioned ON the first character. \end{chunk} +\subsection{Parsing stack} +\defstruct{stack} +\begin{chunk}{initvars} +(defstruct stack "A stack" + (store nil) ; contents of the stack + (size 0) ; number of elements in Store + (top nil) ; first element of Store + (updated nil) ; whether something has been pushed on the stack + ; since this flag was last set to NIL +) + +\end{chunk} + +\defun{stack-load}{stack-load} +\usesstruct{stack-load}{stack} +\begin{chunk}{defun stack-load} +(defun stack-load (list stack) + (setf (stack-store stack) list) + (setf (stack-size stack) (length list)) + (setf (stack-top stack) (car list))) + +\end{chunk} + +\defun{stack-clear}{stack-clear} +\usesstruct{stack-clear}{stack} +\begin{chunk}{defun stack-clear} +(defun stack-clear (stack) + (setf (stack-store stack) nil) + (setf (stack-size stack) 0) + (setf (stack-top stack) nil) + (setf (stack-updated stack) nil)) + +\end{chunk} + +\defmacro{stack-/-empty} +\usesstruct{stack-/-empty}{stack} +\begin{chunk}{defmacro stack-/-empty} +(defmacro stack-/-empty (stack) `(> (stack-size ,stack) 0)) + +\end{chunk} + +\defun{stack-push}{stack-push} +\usesstruct{stack-push}{stack} +\begin{chunk}{defun stack-push} +(defun stack-push (x stack) + (push x (stack-store stack)) + (setf (stack-top stack) x) + (setf (stack-updated stack) t) + (incf (stack-size stack)) + x) + +\end{chunk} + +\defun{stack-pop}{stack-pop} +\usesstruct{stack-pop}{stack} +\begin{chunk}{defun stack-pop} +(defun stack-pop (stack) + (let ((y (pop (stack-store stack)))) + (decf (stack-size stack)) + (setf (stack-top stack) + (if (stack-/-empty stack) (car (stack-store stack)))) + y)) + +\end{chunk} + \chapter{Parse Transformers} \section{Direct called parse routines} \defun{parseTransform}{parseTransform} @@ -14148,6 +14213,7 @@ if \verb|$InteractiveMode| then use a null outputstream \getchunk{defmacro pop-stack-2} \getchunk{defmacro pop-stack-3} \getchunk{defmacro pop-stack-4} +\getchunk{defmacro stack-/-empty} \getchunk{defmacro star} \getchunk{defun action} @@ -14485,6 +14551,10 @@ if \verb|$InteractiveMode| then use a null outputstream \getchunk{defun skip-to-endif} \getchunk{defun spad} \getchunk{defun spad-fixed-arg} +\getchunk{defun stack-clear} +\getchunk{defun stack-load} +\getchunk{defun stack-pop} +\getchunk{defun stack-push} \getchunk{defun storeblanks} \getchunk{defun s-process} diff --git a/changelog b/changelog index 57bf9a9..9aaa0c9 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20110220 tpd src/axiom-website/patches.html 20110220.03.tpd.patch +20110220 tpd src/interp/parsing.lisp treeshake compiler +20110220 tpd books/bookvol9 treeshake compiler 20110220 tpd src/axiom-website/patches.html 20110220.02.tpd.patch 20110220 tpd src/interp/vmlisp.lisp move numericFailure code for plot3d 20110220 tpd books/bookvol5 move numericFailure code for plot3d diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 21e5b7d..20eb6ff 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3399,5 +3399,7 @@ books/bookvol9, bookvol5 fixup seebook xrefs
books/bookvol9 treeshake compiler
20110220.02.tpd.patch books/bookvol5 move numericFailure code for plot3d
+20110220.03.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index b997a4d..11194ea 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -16,44 +16,6 @@ \end{chunk} \chapter{META/LISP Parser Generator and Lexical Analysis Utilities (Parsing)} \subsection{Stack} -\begin{chunk}{*} -(defstruct Stack "A stack" - (Store nil) ; contents of the stack - (Size 0) ; number of elements in Store - (Top nil) ; first element of Store - - (Updated nil) ; whether something has been pushed on the stack - ; since this flag was last set to NIL -) - -(defun stack-load (list stack) - (setf (stack-store stack) list) - (setf (stack-size stack) (length list)) - (setf (stack-top stack) (car list))) - -(defun stack-clear (stack) - (setf (stack-store stack) nil) - (setf (stack-size stack) 0) - (setf (stack-top stack) nil) - (setf (stack-updated stack) nil)) - -(defmacro stack-/-empty (stack) `(> (stack-size ,stack) 0)) - -(defun stack-push (x stack) - (push x (stack-store stack)) - (setf (stack-top stack) x) - (setf (stack-updated stack) t) - (incf (stack-size stack)) - x) - -(defun stack-pop (stack) - (let ((y (pop (stack-store stack)))) - (decf (stack-size stack)) - (setf (stack-top stack) - (if (stack-/-empty stack) (car (stack-store stack)))) - y)) - -\end{chunk} \subsection{Token} \begin{chunk}{*} (defstruct Token