diff --git a/books/bookvol9.pamphlet b/books/bookvol9.pamphlet index bd7e2fa..605c3ab 100644 --- a/books/bookvol9.pamphlet +++ b/books/bookvol9.pamphlet @@ -4292,6 +4292,43 @@ leave it alone." \end{chunk} +\defun{skip-ifblock}{skip-ifblock} +\calls{skip-ifblock}{preparseReadLine1} +\calls{skip-ifblock}{skip-ifblock} +\calls{skip-ifblock}{initial-substring} +\calls{skip-ifblock}{string2BootTree} +\calls{skip-ifblock}{storeblanks} +\begin{chunk}{defun skip-ifblock} +(defun skip-ifblock (x) + (let (line ind) + (dcq (ind . line) (preparseReadLine1)) + (cond + ((not (stringp line)) + (cons ind line)) + ((zerop (size line)) + (skip-ifblock x)) + ((char= (elt line 0) #\) ) + (cond + ((initial-substring ")if" line) + (cond + ((eval (|string2BootTree| (storeblanks line 3))) + (preparseReadLine X)) + (t (skip-ifblock x)))) + ((initial-substring ")elseif" line) + (cond + ((eval (|string2BootTree| (storeblanks line 7))) + (preparseReadLine X)) + (t (skip-ifblock x)))) + ((initial-substring ")else" line) + (preparseReadLine x)) + ((initial-substring ")endif" line) + (preparseReadLine x)) + ((initial-substring ")fin" line) + (cons ind nil)))) + (t (skip-ifblock x))))) + +\end{chunk} + \defun{preparseReadLine1}{preparseReadLine1} \calls{preparseReadLine1}{get-a-line} \calls{preparseReadLine1}{expand-tabs} @@ -9038,6 +9075,21 @@ of the symbol being parsed. The original list read: \end{chunk} +\defun{killColons}{killColons} +\calls{killColons}{killColons} +\begin{chunk}{defun killColons} +(defun |killColons| (x) + (cond + ((atom x) x) + ((and (pairp x) (eq (qcar x) '|Record|)) x) + ((and (pairp x) (eq (qcar x) '|Union|)) x) + ((and (pairp x) (eq (qcar x) '|:|) (pairp (qcdr x)) + (pairp (qcdr (qcdr x))) (eq (qcdr (qcdr (qcdr x))) nil)) + (|killColons| (third x))) + (t (cons (|killColons| (car x)) (|killColons| (cdr x)))))) + +\end{chunk} + \defplist{/}{postSlash} \begin{chunk}{postvars} (eval-when (eval load) @@ -11133,6 +11185,20 @@ if X matches initial segment of inputstream. \end{chunk} +\defun{skip-blanks}{skip-blanks} +\calls{skip-blanks}{current-char} +\calls{skip-blanks}{token-lookahead-type} +\calls{skip-blanks}{advance-char} +\begin{chunk}{defun skip-blanks} +(defun skip-blanks () + (loop (let ((cc (current-char))) + (if (not cc) (return nil)) + (if (eq (token-lookahead-type cc) 'white) + (if (not (advance-char)) (return nil)) + (return t))))) + +\end{chunk} + \defun{match-advance-string}{match-advance-string} The match-string function returns length of X if X matches initial segment of inputstream. @@ -11619,6 +11685,110 @@ Stack of results of reduced productions. \chapter{Utility Functions} +\defun{parse-spadstring}{parse-spadstring} +\calls{parse-spadstring}{match-current-token} +\calls{parse-spadstring}{token-symbol} +\calls{parse-spadstring}{push-reduction} +\calls{parse-spadstring}{advance-token} +\begin{chunk}{defun parse-spadstring} +(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))) + +\end{chunk} + +\defun{parse-string}{parse-string} +\calls{parse-string}{match-current-token} +\calls{parse-string}{token-symbol} +\calls{parse-string}{push-reduction} +\calls{parse-string}{advance-token} +\begin{chunk}{defun parse-string} +(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))) + +\end{chunk} + +\defun{parse-identifier}{parse-identifier} +\calls{parse-identifier}{match-current-token} +\calls{parse-identifier}{token-symbol} +\calls{parse-identifier}{push-reduction} +\calls{parse-identifier}{advance-token} +\begin{chunk}{defun parse-identifier} +(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))) + +\end{chunk} + +\defun{parse-number}{parse-number} +\calls{parse-number}{match-current-token} +\calls{parse-number}{token-symbol} +\calls{parse-number}{push-reduction} +\calls{parse-number}{advance-token} +\begin{chunk}{defun parse-number} +(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))) + +\end{chunk} + + +\defun{parse-keyword}{parse-keyword} +\calls{parse-keyword}{match-current-token} +\calls{parse-keyword}{token-symbol} +\calls{parse-keyword}{push-reduction} +\calls{parse-keyword}{advance-token} +\begin{chunk}{defun parse-keyword} +(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))) + +\end{chunk} + +\defun{parse-argument-designator}{parse-argument-designator} +\calls{parse-argument-designator}{push-reduction} +\calls{parse-argument-designator}{match-current-token} +\calls{parse-argument-designator}{token-symbol} +\calls{parse-argument-designator}{advance-token} +\begin{chunk}{defun parse-argument-designator} +(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))) + +\end{chunk} + +\defun{print-package}{print-package} +\begin{chunk}{defun print-package} +(defun print-package (package) + (format out-stream "~&~%(IN-PACKAGE ~S )~%~%" package)) + +\end{chunk} + \defun{checkWarning}{checkWarning} \calls{checkWarning}{postError} \calls{checkWarning}{concat} @@ -14754,6 +14924,8 @@ if \verb|$InteractiveMode| then use a null outputstream \getchunk{defun is-console} \getchunk{defun isTokenDelimiter} +\getchunk{defun killColons} + \getchunk{defun line-advance-char} \getchunk{defun line-at-end-p} \getchunk{defun line-current-segment} @@ -14784,6 +14956,12 @@ if \verb|$InteractiveMode| then use a null outputstream \getchunk{defun PARSE-AnyId} \getchunk{defun PARSE-Application} +\getchunk{defun parse-argument-designator} +\getchunk{defun parse-identifier} +\getchunk{defun parse-keyword} +\getchunk{defun parse-number} +\getchunk{defun parse-spadstring} +\getchunk{defun parse-string} \getchunk{defun PARSE-Category} \getchunk{defun PARSE-Command} \getchunk{defun PARSE-CommandTail} @@ -14953,6 +15131,7 @@ if \verb|$InteractiveMode| then use a null outputstream \getchunk{defun postType} \getchunk{defun postWhere} \getchunk{defun postWith} +\getchunk{defun print-package} \getchunk{defun preparse} \getchunk{defun preparse1} \getchunk{defun preparse-echo} @@ -14970,6 +15149,8 @@ if \verb|$InteractiveMode| then use a null outputstream \getchunk{defun /RQ,LIB} \getchunk{defun setDefOp} +\getchunk{defun skip-blanks} +\getchunk{defun skip-ifblock} \getchunk{defun skip-to-endif} \getchunk{defun spad} \getchunk{defun spad-fixed-arg} diff --git a/changelog b/changelog index 56c6096..1ddf6ce 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20110310 tpd src/axiom-website/patches.html 20110310.01.tpd.patch +20110310 tpd src/interp/parsing.lisp treeshake compiler +20110310 tpd books/bookvol9 treeshake compiler 20110303 tpd src/axiom-website/patches.html 20110303.01.tpd.patch 20110303 tpd src/interp/parsing.lisp treeshake compiler 20110303 tpd books/bookvol9 treeshake compiler diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 1986ec2..96b705d 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -3425,5 +3425,7 @@ books/bookvol9 treeshake compiler
books/bookvol9 treeshake compiler
20110303.01.tpd.patch books/bookvol9 treeshake compiler
+20110310.01.tpd.patch +books/bookvol9 treeshake compiler
diff --git a/src/interp/parsing.lisp.pamphlet b/src/interp/parsing.lisp.pamphlet index add433b..2082639 100644 --- a/src/interp/parsing.lisp.pamphlet +++ b/src/interp/parsing.lisp.pamphlet @@ -618,30 +618,6 @@ or the chracters ?, !, ' or %" ; Parsing of operator tokens depends on tables initialized by BOTTOMUP.LISP -(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) (defun TRANSLABEL1 (X AL) @@ -955,14 +931,6 @@ empty (if File-Closed (return nil)) ; ID: letters, _ and then numbers ; NUMBER: digits, ., digits, e, +-, digits -(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)))) @@ -971,22 +939,6 @@ empty (if File-Closed (return nil)) (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 @@ -1011,13 +963,6 @@ empty (if File-Closed (return nil)) (special-char (return (get-special-token token))) (eof (return nil))))) -(defun skip-blanks () - (loop (let ((cc (current-char))) - (if (not cc) (return nil)) - (if (eq (token-lookahead-type cc) 'white) - (if (not (advance-char)) (return nil)) - (return t))))) - (defparameter Escape-Character #\\ "Superquoting character.") (defun token-lookahead-type (char) @@ -1129,9 +1074,6 @@ special character be the atom whose print name is the character itself." (mapcar #'(lambda (x) (format out-stream "~&(DEFPARAMETER ~S NIL)~%" x)) fluids) (terpri out-stream)) -(defun print-package (package) - (format out-stream "~&~%(IN-PACKAGE ~S )~%~%" package)) - (defparameter Meta_Prefix nil) (defun set-prefix (prefix) (setq META_PREFIX prefix)) @@ -1183,30 +1125,6 @@ preparse (do ((lines (PREPARSE in-stream) (PREPARSE in-stream))) ((null lines))))) T) -(DEFUN SKIP-IFBLOCK (X) - (PROG (LINE IND) - (DCQ (IND . LINE) (preparseReadLine1)) - (IF (NOT (STRINGP LINE)) (RETURN (CONS IND LINE))) - (IF (ZEROP (SIZE LINE)) (RETURN (SKIP-IFBLOCK X))) - (COND ((CHAR= (ELT LINE 0) #\) ) - (COND - ((INITIAL-SUBSTRING ")if" LINE) - (COND ((EVAL (|string2BootTree| (STOREBLANKS LINE 3))) - (RETURN (preparseReadLine X))) - ('T (RETURN (SKIP-IFBLOCK X))))) - ((INITIAL-SUBSTRING ")elseif" LINE) - (COND ((EVAL (|string2BootTree| (STOREBLANKS LINE 7))) - (RETURN (preparseReadLine X))) - ('T (RETURN (SKIP-IFBLOCK X))))) - ((INITIAL-SUBSTRING ")else" LINE) - (RETURN (preparseReadLine X))) - ((INITIAL-SUBSTRING ")endif" LINE) - (RETURN (preparseReadLine X))) - ((INITIAL-SUBSTRING ")fin" LINE) - (RETURN (CONS IND NIL)))))) - (RETURN (SKIP-IFBLOCK X)) ) ) - - \end{chunk} parse \begin{chunk}{*} @@ -1654,16 +1572,6 @@ parse (DEFUN |postSequence| (#0=#:G167652) (PROG (|l|) (RETURN (PROGN (SPADLET |l| (CDR #0#)) (CONS (QUOTE (|elt| $ |makeRecord|)) (|postTranList| |l|)))))) ;--------------------> NEW DEFINITION (see br-saturn.boot.pamphlet) -;killColons x == -; atom x => x -; x is ['Record,:.] => x -; x is ['Union,:.] => x -; x is [":",.,y] => killColons y -; [killColons first x,:killColons rest x] - -;;; *** |killColons| REDEFINED - -(DEFUN |killColons| (|x|) (PROG (|ISTMP#1| |ISTMP#2| |y|) (RETURN (COND ((ATOM |x|) |x|) ((AND (PAIRP |x|) (EQ (QCAR |x|) (QUOTE |Record|))) |x|) ((AND (PAIRP |x|) (EQ (QCAR |x|) (QUOTE |Union|))) |x|) ((AND (PAIRP |x|) (EQ (QCAR |x|) (QUOTE |:|)) (PROGN (SPADLET |ISTMP#1| (QCDR |x|)) (AND (PAIRP |ISTMP#1|) (PROGN (SPADLET |ISTMP#2| (QCDR |ISTMP#1|)) (AND (PAIRP |ISTMP#2|) (EQ (QCDR |ISTMP#2|) NIL) (PROGN (SPADLET |y| (QCAR |ISTMP#2|)) (QUOTE T))))))) (|killColons| |y|)) ((QUOTE T) (CONS (|killColons| (CAR |x|)) (|killColons| (CDR |x|)))))))) ;removeSuperfluousMapping sig1 == ; --get rid of this asap ; sig1 is [x,:y] and x is ['Mapping,:.] => [rest x,:y]