diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index b34e59e..a2b27d4 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -4343,10 +4343,11 @@ leave it alone." \end{chunk} +\defvar{current-fragment} +A string containing remaining chars from readline; needed because +Symbolics read-line returns embedded newlines in a c-m-Y. \begin{chunk}{initvars} -(defparameter Current-Fragment nil - "A string containing remaining chars from readline; needed because -Symbolics read-line returns embedded newlines in a c-m-Y.") +(defvar current-fragment nil) \end{chunk} @@ -4399,6 +4400,14 @@ always positioned ON the first character. \end{chunk} +\defvar{current-line} +The current input line. +\begin{chunk}{initvars} +(defvar current-line (make-line)) + +\end{chunk} + + \defmacro{line-clear} \usesstruct{line-clear}{line} \begin{chunk}{defmacro line-clear} @@ -4625,9 +4634,10 @@ NonBlank is true if the token is not preceded by a blank. \end{chunk} \defvar{current-token} +Token at head of input stream. \usesstruct{current-token}{token} \begin{chunk}{initvars} -(defparameter current-token (make-token) "Token at head of input stream.") +(defvar current-token (make-token)) \end{chunk} @@ -9107,7 +9117,7 @@ of the symbol being parsed. The original list read: \defdollar{defstack} \begin{chunk}{initvars} -(defparameter $defstack nil) +(defvar $defstack nil) \end{chunk} @@ -9125,23 +9135,25 @@ of the symbol being parsed. The original list read: \defdollar{vl} \begin{chunk}{initvars} -(defparameter $vl nil) +(defvar $vl nil) \end{chunk} +\defdollar{is-gensymlist} \begin{chunk}{initvars} -(defparameter $IS-GENSYMLIST nil) +(defvar $is-gensymlist nil) \end{chunk} +\defvar{initial-gensym} \begin{chunk}{initvars} -(defparameter Initial-Gensym (list (gensym))) +(defvar initial-gensym (list (gensym))) \end{chunk} \defdollar{is-eqlist} \begin{chunk}{initvars} -(defparameter $is-eqlist nil) +(defvar $is-eqlist nil) \end{chunk} @@ -11341,7 +11353,7 @@ loop Stack of results of reduced productions. \usesstruct{reduce-stack}{stack} \begin{chunk}{initvars} -(defparameter reduce-stack (make-stack) ) +(defvar reduce-stack (make-stack) ) \end{chunk} diff --git a/changelog b/changelog index 6a26aaf..fd519b0 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20110227 tpd src/axiom-website/patches.html 20110227.01.tpd.patch +20110227 tpd src/interp/parsing.lisp treeshake compiler +20110227 tpd books/bookvol9 treeshake compiler 20110220 tpd src/axiom-website/patches.html 20110220.04.tpd.patch 20110220 tpd src/interp/parsing.lisp treeshake compiler 20110220 tpd books/bookvol9 treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index ff17328..40f8d51 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3403,5 +3403,7 @@ books/bookvol5 move numericFailure code for plot3d
books/bookvol9 treeshake compiler
20110220.04.tpd.patch books/bookvol9 treeshake compiler
+20110227.01.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index f1e7e3c..aa0e959 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -20,22 +20,16 @@ \subsection{Reduction} \section{Recursive descent parsing support routines} \subsection{Stacking and retrieving reductions of rules.} -(defmacro sequence (subrules &optional (actions nil)) - `(and ,(pop subrules) . - ,(append (mapcar #'(lambda (x) (list 'must x)) subrules) - (if actions `((progn . ,(append actions '(t)))))))) - -\end{chunk} +;(defmacro sequence (subrules &optional (actions nil)) +; `(and ,(pop subrules) . +; ,(append (mapcar #'(lambda (x) (list 'must x)) subrules) +; (if actions `((progn . ,(append actions '(t)))))))) \section{Routines for handling lexical scanning} Lexical scanning of tokens is performed off of the current line. No token can span more than 1 line. All real I/O is handled in a line-oriented fashion (in a slight paradox) below the character level. All character routines implicitly assume the parameter Current-Line. We do not make Current-Line an explicit optional parameter for reasons of efficiency. -\begin{chunk}{*} -(defparameter Current-Line (make-line) "Current input line.") - -\end{chunk} \subsection{Manipulating the token stack and reading tokens} This section is broken up into 3 levels: \begin{itemize} @@ -45,9 +39,6 @@ This section is broken up into 3 levels: \item Line handling: Next Line, Print Next Line \item Random Stuff \end{itemize} -\subsubsection{String grabbing} -\begin{chunk}{*} -\end{chunk} \subsubsection{Token handling} Tokens are acquired from a stream of characters. Lexical analysis is performed by the functiond Get Token. One-token lookahead is maintained in variables @@ -56,15 +47,6 @@ Advance Token. The functions Match Current Token and Match Next Token recognize classes of tokens, by type, or by type and symbol. The current and next tokens can be shoved back on the input stream (to the current line) with Unget-Tokens. \begin{chunk}{*} -(defmacro Defun-Parse-Token (token) - `(defun ,(intern (concatenate 'string "PARSE-" (string token))) () - (let* ((tok (match-current-token ',token)) - (symbol (if tok (token-symbol tok)))) - (when tok - (Push-Reduction ',(intern (concatenate 'string (string token) "-TOKEN")) - (copy-tree symbol)) - (advance-token) - t)))) (defun token-stack-show () (if (= Valid-Tokens 0) @@ -683,20 +665,29 @@ or the chracters ?, !, ' or %" ; Parsing of operator tokens depends on tables initialized by BOTTOMUP.LISP -(defmacro defun-parse-token (token) - `(defun ,(intern (concatenate 'string "PARSE-" (string token))) () - (let* ((tok (match-current-token ',token)) - (symbol (if tok (token-symbol tok)))) - (if tok (progn (push-reduction - ',(intern (concatenate 'string (string token) - "-TOKEN")) - (copy-tree symbol)) - (advance-token) - t))))) - -(defun-parse-token SPADSTRING) -(defun-parse-token KEYWORD) -(defun-parse-token ARGUMENT-DESIGNATOR) +(defun parse-spadstring () + (let* ((tok (match-current-token 'spadstring)) + (symbol (if tok (token-symbol tok)))) + (when tok + (push-reduction 'spadstring-token (copy-tree symbol)) + (advance-token) + t))) + +(defun parse-keyword () + (let* ((tok (match-current-token 'keyword)) + (symbol (if tok (token-symbol tok)))) + (when tok + (push-reduction 'keyword-token (copy-tree symbol)) + (advance-token) + t))) + +(defun parse-argument-designator () + (let* ((tok (match-current-token 'argument-designator)) + (symbol (if tok (token-symbol tok)))) + (when tok + (push-reduction 'argument-designator-token (copy-tree symbol)) + (advance-token) + t))) (defun TRANSLABEL (X AL) (TRANSLABEL1 X AL) X) @@ -1011,11 +1002,38 @@ empty (if File-Closed (return nil)) ; ID: letters, _ and then numbers ; NUMBER: digits, ., digits, e, +-, digits -(defun-parse-token STRING) -(defun-parse-token BSTRING) -(defun-parse-token IDENTIFIER) -(defun-parse-token NUMBER) - +(defun parse-string () + (let* ((tok (match-current-token 'string)) + (symbol (if tok (token-symbol tok)))) + (when tok + (push-reduction 'string-token (copy-tree symbol)) + (advance-token) + t))) + +(defun parse-bstring () + (let* ((tok (match-current-token 'bstring)) + (symbol (if tok (token-symbol tok)))) + (when tok + (push-reduction 'bstring-token (copy-tree symbol)) + (advance-token) + t))) + +(defun parse-identifier () + (let* ((tok (match-current-token 'identifier)) + (symbol (if tok (token-symbol tok)))) + (when tok + (push-reduction 'identifier-token (copy-tree symbol)) + (advance-token) + t))) + +(defun parse-number () + (let* ((tok (match-current-token 'number)) + (symbol (if tok (token-symbol tok)))) + (when tok + (push-reduction 'number-token (copy-tree symbol)) + (advance-token) + t))) + ; Meta tokens fall into the following categories: ; ; Number