diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index be5fff2..19d6869 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -891,6 +891,27 @@ character. Otherwise, it returns nil. @ +\defun{next}{next} +<>= +(defun |next| (f s) + (|Delay| (function |next1|) (list f s))) + +@ + +\defun{next1}{next1} +<>= +(defun |next1| (&rest z) + (let (h s f) + (setq f (car z)) + (setq s (cadr z)) + (cond + ((|StreamNull| s) |StreamNil|) + (t + (setq h (apply f (list s))) + (|incAppend| (car h) (|next| f (cdr h))))))) + +@ + \defun{incString}{incString} <>= (defun |incString| (s) @@ -1458,6 +1479,47 @@ contiguous comment spanning enough lines to overflow the stack. @ +\defun{incZip}{incZip} +<>= +(defun |incZip| (g f1 f2) + (|Delay| (function |incZip1|) (list g f1 f2))) + +@ + +\defun{incZip1}{incZip1} +<>= +(defun |incZip1| (&rest z) + (let (f2 f1 g) + (setq g (car z)) + (setq f1 (cadr z)) + (setq f2 (caddr z)) + (cond + ((|StreamNull| f1) |StreamNil|) + ((|StreamNull| f2) |StreamNil|) + (t + (cons + (funcall g (car f1) (car f2)) + (|incZip| g (cdr f1) (cdr f2))))))) + +@ + +\defun{incIgen}{incIgen} +<>= +(defun |incIgen| (n) + (|Delay| (function |incIgen1|) (list n))) + +@ + +\defun{incIgen1}{incIgen1} +<>= +(defun |incIgen1| (&rest z) + (let (n) + (setq n (car z)) + (setq n (+ n 1)) + (cons n (|incIgen| n)))) + +@ + \defun{incRenumberLine}{incRenumberLine} <>= (defun |incRenumberLine| (xl gno) @@ -1783,6 +1845,7 @@ contiguous comment spanning enough lines to overflow the stack. (t (cons (|xlCmdBug| eb str lno ufos) |StreamNil|)))))))) @ + \defun{xlPrematureEOF}{xlPrematureEOF} <>= (defun |xlPrematureEOF| (eb str lno ufos) @@ -1812,6 +1875,27 @@ contiguous comment spanning enough lines to overflow the stack. @ +\defun{incAppend}{incAppend} +<>= +(defun |incAppend| (x y) + (|Delay| (function |incAppend1|) (list x y))) + +@ + +\defun{incAppend1}{incAppend1} +<>= +(defun |incAppend1| (&rest z) + (let (y x) + (setq x (car z)) + (setq y (cadr z)) + (cond + ((|StreamNull| x) + (cond ((|StreamNull| y) |StreamNil|) (t y))) + (t + (cons (car x) (|incAppend| (cdr x) y)))))) + +@ + \defun{incLine1}{incLine1} <>= (defun |incLine1| (eb str str1 gno lno ufo) @@ -3480,6 +3564,47 @@ This function is used to build the scanKeyTable @ +\chapter{Stream Utilities} +The input stream is parsed into a large s-expression by repeated calls +to Delay. Delay takes a function f and an argument x and returns a list +consisting of \verb}("nonnullstream" f x)|. Eventually multiple calls are made +and a large list structure is created that consists of +\verb|("nonnullstream" f x ("nonnullstream" f1 x1 ("nonnullstream" f2 x2...| + +This delay structure is given to StreamNull which walks along the +list looking at the head. If the head is ``nonnullstream'' then the +function is applied to the argument. + +So, in effect, the input is ``zipped up'' into a Delay data structure +which is then evaluated by calling StreamNull. This "zippered stream" +parser was a research project at IBM and Axiom was the testbed (which +explains the strange parsing technique). + +\defun{npNull}{npNull} +<>= +(defun |npNull| (x) (|StreamNull| x)) + +@ + +\defun{StreamNull}{StreamNull} +<>= +(defun |StreamNull| (x) + (let (st) + (cond + ((or (null x) (eqcar x '|nullstream|)) t) + (t + ((lambda nil + (loop + (cond + ((not (eqcar x '|nonnullstream|)) (return nil)) + (t + (setq st (apply (cadr x) (cddr x))) + (rplaca x (car st)) + (rplacd x (cdr st))))))) + (eqcar x '|nullstream|))))) + +@ + \chapter{Code Piles} The insertpiles function converts a line-list to a line-forest where a line is a token-dequeue and has a column which is an integer. @@ -19784,6 +19909,8 @@ maxindex <> <> <> +<> +<> <> <> <> @@ -19793,6 +19920,8 @@ maxindex <> <> <> +<> +<> <> <> <> @@ -19820,6 +19949,8 @@ maxindex <> <> <> +<> +<> <> <> <> @@ -19901,9 +20032,12 @@ maxindex <> <> <> +<> +<> <> <> <> +<> <> <> @@ -20065,6 +20199,7 @@ maxindex <> <> <> +<> <> <> <> diff --git a/changelog b/changelog index 7f6852b..c3accc1 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20091104 tpd src/axiom-website/patches.html 20091104.03.tpd.patch +20091104 tpd books/bookvol5 merge cstream.lisp +20091104 tpd src/interp/cstream.lisp removed, merge with bookvol5 20091104 tpd src/axiom-website/patches.html 20091104.02.tpd.patch 20091104 tpd books/bookvol5 merge dq.lisp 20091104 tpd src/interp/dq.lisp removed, merge with bookvol5 diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index cdc440c..609c127 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -2225,5 +2225,7 @@ books/bookvol10.3 fix OrderedFreeMonoid.regress
books/bookvol5 merge, remove pile.lisp
20091104.02.tpd.patch books/bookvol5 merge, remove dq.lisp
+20091104.03.tpd.patch +books/bookvol5 merge, remove cstream.lisp
diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet index 12ec90e..5b3972a 100644 --- a/src/interp/Makefile.pamphlet +++ b/src/interp/Makefile.pamphlet @@ -146,7 +146,7 @@ OBJS= ${OUT}/vmlisp.${O} \ ${OUT}/cformat.${O} ${OUT}/cfuns.${O} \ ${OUT}/clam.${O} ${OUT}/clammed.${O} \ ${OUT}/compat.${O} ${OUT}/compress.${O} \ - ${OUT}/cparse.${O} ${OUT}/cstream.${O} \ + ${OUT}/cparse.${O} \ ${OUT}/database.${O} \ ${OUT}/fname.${O} ${OUT}/format.${O} \ ${OUT}/g-boot.${O} ${OUT}/g-cndata.${O} \ @@ -3447,29 +3447,6 @@ ${MID}/ptrop.lisp: ${IN}/ptrop.lisp.pamphlet @ -\subsection{cstream.lisp} -<>= -${OUT}/cstream.${O}: ${MID}/cstream.lisp - @ echo 136 making ${OUT}/cstream.${O} from ${MID}/cstream.lisp - @ ( cd ${MID} ; \ - if [ -z "${NOISE}" ] ; then \ - echo '(progn (compile-file "${MID}/cstream.lisp"' \ - ':output-file "${OUT}/cstream.${O}") (${BYE}))' | ${DEPSYS} ; \ - else \ - echo '(progn (compile-file "${MID}/cstream.lisp"' \ - ':output-file "${OUT}/cstream.${O}") (${BYE}))' | ${DEPSYS} \ - >${TMP}/trace ; \ - fi ) - -@ -<>= -${MID}/cstream.lisp: ${IN}/cstream.lisp.pamphlet - @ echo 137 making ${MID}/cstream.lisp from ${IN}/cstream.lisp.pamphlet - @ (cd ${MID} ; \ - ${TANGLE} ${IN}/cstream.lisp.pamphlet >cstream.lisp ) - -@ - \subsection{astr.lisp} <>= ${OUT}/astr.${O}: ${MID}/astr.lisp @@ -4132,9 +4109,6 @@ clean: <> <> -<> -<> - <> <> <> diff --git a/src/interp/cstream.lisp.pamphlet b/src/interp/cstream.lisp.pamphlet deleted file mode 100644 index 7e1787a..0000000 --- a/src/interp/cstream.lisp.pamphlet +++ /dev/null @@ -1,218 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/interp cstream.lisp} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -The input stream is parsed into a large s-expression by repeated calls -to Delay. Delay takes a function f and an argument x and returns a list -consisting of ("nonnullstream" f x). Eventually multiple calls are made -and a large list structure is created that consists of -("nonnullstream" f x ("nonnullstream" f1 x1 ("nonnullstream" f2 x2... - -This delay structure is given to StreamNull which walks along the -list looking at the head. If the head is "nonnullstream" then the -function is applied to the argument. - -So, in effect, the input is "zipped up" into a Delay data structure -which is then evaluated by calling StreamNull. This "zippered stream" -parser was a research project at IBM and Axiom was the testbed (which -explains the strange parsing technique). - -@ -<<*>>= - -(IN-PACKAGE "BOOT") -; -;--% Stream Utilities -; -;npNull x== StreamNull x -(DEFUN |npNull| (|x|) (PROG NIL (RETURN (|StreamNull| |x|)))) - -;StreamNull x== -; null x or EQCAR (x,"nullstream") => true -; while EQCAR(x,"nonnullstream") repeat -; st:=APPLY(CADR x,CDDR x) -; RPLACA(x,CAR st) -; RPLACD(x,CDR st) -; EQCAR(x,"nullstream") -(DEFUN |StreamNull| (|x|) - (PROG (|st|) - (RETURN - (COND - ((OR (NULL |x|) (EQCAR |x| (QUOTE |nullstream|))) T) - ((QUOTE T) - (PROGN - ((LAMBDA NIL - (LOOP - (COND - ((NOT (EQCAR |x| (QUOTE |nonnullstream|))) (RETURN NIL)) - ((QUOTE T) - (PROGN - (SETQ |st| (APPLY (CADR |x|) (CDDR |x|))) - (RPLACA |x| (CAR |st|)) - (RPLACD |x| (CDR |st|)))))))) - (EQCAR |x| (QUOTE |nullstream|)))))))) - -;incIgen n==Delay(function incIgen1,[n]) -(DEFUN |incIgen| (|n|) - (PROG NIL - (RETURN - (|Delay| (FUNCTION |incIgen1|) (LIST |n|))))) - -;incIgen1(:z)== -; [n]:=z -; n:=n+1 -; cons(n,incIgen n) -(DEFUN |incIgen1| (&REST |z|) - (PROG (|n|) - (RETURN - (PROGN - (SETQ |n| (CAR |z|)) - (SETQ |n| (+ |n| 1)) - (CONS |n| (|incIgen| |n|)))))) - -;incZip(g,f1,f2)==Delay(function incZip1,[g,f1,f2]) -(DEFUN |incZip| (|g| |f1| |f2|) - (PROG NIL - (RETURN - (|Delay| (FUNCTION |incZip1|) (LIST |g| |f1| |f2|))))) - -;incZip1(:z)== -; [g,f1,f2]:=z -; StreamNull f1 => StreamNil -; StreamNull f2 => StreamNil -; cons(FUNCALL(g,car f1,car f2),incZip(g,cdr f1,cdr f2)) -(DEFUN |incZip1| (&REST |z|) - (PROG (|f2| |f1| |g|) - (RETURN - (PROGN - (SETQ |g| (CAR |z|)) - (SETQ |f1| (CADR . #0=(|z|))) - (SETQ |f2| (CADDR . #0#)) - (COND - ((|StreamNull| |f1|) |StreamNil|) - ((|StreamNull| |f2|) |StreamNil|) - ((QUOTE T) - (CONS - (FUNCALL |g| (CAR |f1|) (CAR |f2|)) - (|incZip| |g| (CDR |f1|) (CDR |f2|))))))))) - -;incAppend(x,y)==Delay(function incAppend1,[x,y]) -(DEFUN |incAppend| (|x| |y|) - (PROG NIL - (RETURN - (|Delay| (FUNCTION |incAppend1|) (LIST |x| |y|))))) - -;incAppend1(:z)== -; [x,y]:=z -; if StreamNull x -; then if StreamNull y -; then StreamNil -; else y -; else cons(car x,incAppend(cdr x,y)) -(DEFUN |incAppend1| (&REST |z|) - (PROG (|y| |x|) - (RETURN - (PROGN - (SETQ |x| (CAR |z|)) - (SETQ |y| (CADR |z|)) - (COND - ((|StreamNull| |x|) - (COND - ((|StreamNull| |y|) |StreamNil|) - (#0=(QUOTE T) |y|))) - (#0# (CONS (CAR |x|) (|incAppend| (CDR |x|) |y|)))))))) - -;next(f,s)==Delay(function next1,[f,s]) -(DEFUN |next| (|f| |s|) - (PROG NIL - (RETURN - (|Delay| (FUNCTION |next1|) (LIST |f| |s|))))) - -;next1(:z)== -; [f,s]:=z -; StreamNull s=> StreamNil -; h:= APPLY(f, [s]) -; incAppend(car h,next(f,cdr h)) -(DEFUN |next1| (&REST |z|) - (PROG (|h| |s| |f|) - (RETURN - (PROGN - (SETQ |f| (CAR |z|)) - (SETQ |s| (CADR |z|)) - (COND - ((|StreamNull| |s|) |StreamNil|) - ((QUOTE T) - (PROGN - (SETQ |h| (APPLY |f| (LIST |s|))) - (|incAppend| (CAR |h|) (|next| |f| (CDR |h|)))))))))) - -;nextown(f,g,s)==Delay(function nextown1,[f,g,s]) -(DEFUN |nextown| (|f| |g| |s|) - (PROG NIL - (RETURN - (|Delay| (FUNCTION |nextown1|) (LIST |f| |g| |s|))))) - -;nextown1 (:z)== -; [f,g,s]:=z -; StreamNull s=> -; spadcall1 g -; StreamNil -; StreamNull s -; h:=spadcall2 (f, s) -; incAppend(car h,nextown(f,g,cdr h)) -(DEFUN |nextown1| (&REST |z|) - (PROG (|h| |s| |g| |f|) - (RETURN - (PROGN - (SETQ |f| (CAR |z|)) - (SETQ |g| (CADR . #0=(|z|))) - (SETQ |s| (CADDR . #0#)) - (COND - ((|StreamNull| |s|) (PROGN (|spadcall1| |g|) |StreamNil|)) - ((QUOTE T) - (PROGN - (|StreamNull| |s|) - (SETQ |h| (|spadcall2| |f| |s|)) - (|incAppend| (CAR |h|) (|nextown| |f| |g| (CDR |h|)))))))))) - -;nextown2(f,g,e,x)==nextown(cons(f,e),cons(g,e),x) -(DEFUN |nextown2| (|f| |g| |e| |x|) - (PROG NIL - (RETURN - (|nextown| (CONS |f| |e|) (CONS |g| |e|) |x|)))) - -;spadcall1(g)== -; [impl, :env] := g -; APPLY(impl, [env]) -(DEFUN |spadcall1| (|g|) - (PROG (|env| |impl|) - (RETURN - (PROGN - (SETQ |impl| (CAR |g|)) - (SETQ |env| (CDR |g|)) - (APPLY |impl| (LIST |env|)))))) - -;spadcall2(f,args) == -; [impl, :env] := f -; APPLY(impl, [args, env]) -(DEFUN |spadcall2| (|f| |args|) - (PROG (|env| |impl|) - (RETURN - (PROGN - (SETQ |impl| (CAR |f|)) - (SETQ |env| (CDR |f|)) - (APPLY |impl| (LIST |args| |env|)))))) - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document}