diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index a91f9d2..c88c09d 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -3480,6 +3480,224 @@ This function is used to build the scanKeyTable @ +\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. +An A-forest is an A-tree-list +An A-tree has a root which is an A, and subtrees which is an A-forest. + +A forest with more than one tree corresponds to a Scratchpad pile +structure (t1;t2;t3;...;tn), and a tree corresponds to a pile item. +The ( ; and ) tokens are inserted into a >1-forest, otherwise +the root of the first tree is concatenated with its forest. +column t is the number of spaces before the first non-space in line t + +\defun{insertpile}{insertpile} +<>= +(defun |insertpile| (s) + (let (stream a t1 h1 t2 h tmp1) + (cond + ((|npNull| s) (list nil 0 nil s)) + (t + (setq tmp1 (list (car s) (cdr s))) + (setq h (car tmp1)) + (setq t2 (cadr tmp1)) + (cond + ((|pilePlusComment| h) + (setq tmp1 (|pilePlusComments| s)) + (setq h1 (car tmp1)) + (setq t1 (cadr tmp1)) + (setq a (|pileTree| (- 1) t1)) + (cons (list (|pileCforest| + (append h1 (cons (elt a 2) nil)))) + (elt a 3))) + (t + (setq stream (cadar s)) + (setq a (|pileTree| -1 s)) + (cons (list (list (elt a 2) stream)) (elt a 3)))))))) + +@ + +\defun{pilePlusComment}{pilePlusComment} +<>= +(defun |pilePlusComment| (arg) + (eq (|tokType| (caar arg)) '|comment|)) + +@ +\defun{pilePlusComments}{pilePlusComments} +<>= +(defun |pilePlusComments| (s) + (let (t1 h1 t2 h tmp1) + (cond + ((|npNull| s) (list nil s)) + (t + (setq tmp1 (list (car s) (cdr s))) + (setq h (car tmp1)) + (setq t2 (cadr tmp1)) + (cond + ((|pilePlusComment| h) + (setq tmp1 (|pilePlusComments| t2)) + (setq h1 (car tmp1)) + (setq t1 (cadr tmp1)) + (list (cons h h1) t1)) + (t + (list nil s))))))) + +@ + +\defun{pileTree}{pileTree} +<>= +(defun |pileTree| (n s) + (let (hh t1 h tmp1) + (cond + ((|npNull| s) (list nil n nil s)) + (t + (setq tmp1 (list (car s) (cdr s))) + (setq h (car tmp1)) + (setq t1 (cadr tmp1)) + (setq hh (|pileColumn| (car h))) + (cond + ((< n hh) (|pileForests| (car h) hh t1)) + (t (list nil n nil s))))))) + +@ + +\defun{pileColumn}{pileColumn} +<>= +(defun |pileColumn| (arg) + (cdr (|tokPosn| (caar arg)))) + +@ + +\defun{pileForests}{pileForests} +<>= +(defun |pileForests| (h n s) + (let (t1 h1 tmp1) + (setq tmp1 (|pileForest| n s)) + (setq h1 (car tmp1)) + (setq t1 (cadr tmp1)) + (cond + ((|npNull| h1) (list t n h s)) + (t (|pileForests| (|pileCtree| h h1) n t1))))) + +@ + +\defun{pileForest}{pileForest} +<>= +(defun |pileForest| (n s) + (let (t1 h1 t2 h hh b tmp) + (setq tmp (|pileTree| n s)) + (setq b (car tmp)) + (setq hh (cadr tmp)) + (setq h (caddr tmp)) + (setq t2 (cadddr tmp)) + (cond + (b + (setq tmp (|pileForest1| hh t2)) + (setq h1 (car tmp)) + (setq t1 (cadr tmp)) + (list (cons h h1) t1)) + (t + (list nil s))))) + +@ + +\defun{pileForest1}{pileForest1} +<>= +(defun |pileForest1| (n s) + (let (t1 h1 t2 h n1 b tmp) + (setq tmp (|eqpileTree| n s)) + (setq b (car tmp)) + (setq n1 (cadr tmp)) + (setq h (caddr tmp)) + (setq t2 (cadddr tmp)) + (cond + (b + (setq tmp (|pileForest1| n t2)) + (setq h1 (car tmp)) + (setq t1 (cadr tmp)) + (list (cons h h1) t1)) + (t (list nil s))))) + +@ + +\defun{eqpileTree}{eqpileTree} +<>= +(defun |eqpileTree| (n s) + (let (hh t1 h tmp) + (cond + ((|npNull| s) (list nil n nil s)) + (t + (setq tmp (list (car s) (cdr s))) + (setq h (car tmp)) + (setq t1 (cadr tmp)) + (setq hh (|pileColumn| (car h))) + (cond + ((equal hh n) (|pileForests| (car h) hh t1)) + (t (list nil n nil s))))))) + +@ + +\defun{pileCtree}{pileCtree} +<>= +(defun |pileCtree| (x y) + (|dqAppend| x (|pileCforest| y))) + +@ + +\defun{pileCforest}{pileCforest} +Only enpiles forests with $>=2$ trees +<>= +(defun |pileCforest| (x) + (let (f) + (cond + ((null x) nil) + ((null (cdr x)) (setq f (car x)) + (cond + ((eq (|tokPart| (caar f)) 'if) (|enPile| f)) + (t f))) + (t (|enPile| (|separatePiles| x)))))) + +@ + +\defun{enPile}{enPile} +<>= +(defun |enPile| (x) + (|dqConcat| + (list + (|dqUnit| (|tokConstruct| '|key| 'settab (|firstTokPosn| x))) + x + (|dqUnit| (|tokConstruct| '|key| 'backtab (|lastTokPosn| x)))))) + +@ + +\defun{firstTokPosn}{firstTokPosn} +<>= +(defun |firstTokPosn| (arg) (|tokPosn| (caar arg))) + +@ + +\defun{lastTokPosn}{lastTokPosn} +<>= +(defun |lastTokPosn| (arg) (|tokPosn| (cadr arg))) + +@ + +\defun{separatePiles}{separatePiles} +<>= +(defun |separatePiles| (x) + (let (semicolon a) + (cond + ((null x) nil) + ((null (cdr x)) (car x)) + (t + (setq a (car x)) + (setq semicolon + (|dqUnit| (|tokConstruct| '|key| 'backset (|lastTokPosn| a)))) + (|dqConcat| (list a semicolon (|separatePiles| (cdr x)))))))) + +@ + \chapter{The Interpreter Syntax} \section{syntax assignment} \label{assignment} @@ -19464,11 +19682,14 @@ maxindex <> <> <> +<> <> +<> <> <> <> +<> <> <> <> @@ -19559,6 +19780,7 @@ maxindex <> <> <> +<> <> <> <> @@ -19582,6 +19804,7 @@ maxindex <> <> +<> <> <> <> @@ -19647,6 +19870,15 @@ maxindex <> <> <> +<> +<> +<> +<> +<> +<> +<> +<> +<> <> <> <> @@ -19726,6 +19958,7 @@ maxindex <> <> <> +<> <> <> <> diff --git a/changelog b/changelog index f4c17d7..3c9efe7 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +20091104 tpd src/axiom-website/patches.html 20091104.01.tpd.patch +20091104 tpd books/bookvol5 merge pile.lisp +20091104 tpd src/interp/pile.lisp removed, merge with bookvol5 +20091104 tpd src/interp/Makefile remove pile.lisp 20091103 tpd src/axiom-website/patches.html 20091103.03.tpd.patch 20091103 tpd books/bookvol10.3 fix OrderedFreeMonoid.regress 20091103 tpd src/axiom-website/patches.html 20091103.02.tpd.patch diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 7c24163..5a4d0f1 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -2221,5 +2221,7 @@ rename ListOfTerms to listOfTerms
books/bookvol10.4 Examples, Help, Regress RationalFunctionSum
20091103.03.tpd.patch books/bookvol10.3 fix OrderedFreeMonoid.regress
+20091104.01.tpd.patch +books/bookvol5 merge, remove pile.lisp
diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet index 14b3866..1d624a7 100644 --- a/src/interp/Makefile.pamphlet +++ b/src/interp/Makefile.pamphlet @@ -174,7 +174,7 @@ OBJS= ${OUT}/vmlisp.${O} \ ${OUT}/nrungo.${O} ${OUT}/nrunopt.${O} \ ${OUT}/nruntime.${O} ${OUT}/osyscmd.${O} \ ${OUT}/packtran.${O} ${OUT}/pathname.${O} \ - ${OUT}/pf2sex.${O} ${OUT}/pile.${O} \ + ${OUT}/pf2sex.${O} \ ${OUT}/posit.${O} \ ${OUT}/ptrees.${O} ${OUT}/ptrop.${O} \ ${OUT}/record.${O} ${OUT}/regress.${O} \ @@ -3356,29 +3356,6 @@ ${MID}/topics.lisp: ${IN}/topics.lisp.pamphlet @ -\subsection{pile.lisp} -<>= -${OUT}/pile.${O}: ${MID}/pile.lisp - @ echo 136 making ${OUT}/pile.${O} from ${MID}/pile.lisp - @ ( cd ${MID} ; \ - if [ -z "${NOISE}" ] ; then \ - echo '(progn (compile-file "${MID}/pile.lisp"' \ - ':output-file "${OUT}/pile.${O}") (${BYE}))' | ${DEPSYS} ; \ - else \ - echo '(progn (compile-file "${MID}/pile.lisp"' \ - ':output-file "${OUT}/pile.${O}") (${BYE}))' | ${DEPSYS} \ - >${TMP}/trace ; \ - fi ) - -@ -<>= -${MID}/pile.lisp: ${IN}/pile.lisp.pamphlet - @ echo 137 making ${MID}/pile.lisp from ${IN}/pile.lisp.pamphlet - @ (cd ${MID} ; \ - ${TANGLE} ${IN}/pile.lisp.pamphlet >pile.lisp ) - -@ - \subsection{cparse.lisp} <>= ${OUT}/cparse.${O}: ${MID}/cparse.lisp @@ -4463,9 +4440,6 @@ clean: <> <> -<> -<> - <> <> diff --git a/src/interp/pile.lisp.pamphlet b/src/interp/pile.lisp.pamphlet deleted file mode 100644 index 92e1ffe..0000000 --- a/src/interp/pile.lisp.pamphlet +++ /dev/null @@ -1,295 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/interp pile.lisp} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -<<*>>= -(IN-PACKAGE "BOOT") - -;-- insertpiles converts a line-list to a line-forest where -; -;-- a line is a token-dequeue and has a column which is an integer. -;-- an A-forest is an A-tree-list -;-- an A-tree has a root which is an A, and subtrees which is an A-forest. -; -;-- A forest with more than one tree corresponds to a Scratchpad pile -;-- structure (t1;t2;t3;...;tn), and a tree corresponds to a pile item. -;-- The ( ; and ) tokens are inserted into a >1-forest, otherwise -;-- the root of the first tree is concatenated with its forest. -;-- column t is the number of spaces before the first non-space in line t -; -;pileColumn t==CDR tokPosn CAAR t - -(DEFUN |pileColumn| (|t|) - (PROG () (RETURN (CDR (|tokPosn| (CAAR |t|)))))) - -;pileComment t== EQ(tokType CAAR t,"negcomment") - -(DEFUN |pileComment| (|t|) - (PROG () (RETURN (EQ (|tokType| (CAAR |t|)) '|negcomment|)))) - -;pilePlusComment t== EQ(tokType CAAR t,"comment") - -(DEFUN |pilePlusComment| (|t|) - (PROG () (RETURN (EQ (|tokType| (CAAR |t|)) '|comment|)))) - -;-- insertpile is used by next so s is non-null -;-- bite off a line-tree, return it and the remaining line-list. -; -;insertpile (s)== -; if npNull s -; then [false,0,[],s] -; else -; [h,t]:=[car s,cdr s] -; if pilePlusComment h -; then -; [h1,t1]:=pilePlusComments s -; a:=pileTree(-1,t1) -; cons([pileCforest [:h1,a.2]],a.3) -; else -; stream:=CADAR s -; a:=pileTree(-1,s) -; cons([[a.2,stream]],a.3) - -(DEFUN |insertpile| (|s|) - (PROG (|stream| |a| |t1| |h1| |t| |h| |LETTMP#1|) - (RETURN - (COND - ((|npNull| |s|) (LIST NIL 0 NIL |s|)) - ('T (SETQ |LETTMP#1| (LIST (CAR |s|) (CDR |s|))) - (SETQ |h| (CAR |LETTMP#1|)) (SETQ |t| (CADR |LETTMP#1|)) - (COND - ((|pilePlusComment| |h|) - (SETQ |LETTMP#1| (|pilePlusComments| |s|)) - (SETQ |h1| (CAR |LETTMP#1|)) (SETQ |t1| (CADR |LETTMP#1|)) - (SETQ |a| (|pileTree| (- 1) |t1|)) - (CONS (LIST (|pileCforest| - (APPEND |h1| (CONS (ELT |a| 2) NIL)))) - (ELT |a| 3))) - ('T (SETQ |stream| (CADAR |s|)) - (SETQ |a| (|pileTree| (- 1) |s|)) - (CONS (LIST (LIST (ELT |a| 2) |stream|)) (ELT |a| 3))))))))) - -;pilePlusComments s== -; if npNull s -; then [[],s] -; else -; [h,t]:=[car s,cdr s] -; if pilePlusComment h -; then -; [h1,t1]:=pilePlusComments t -; [cons(h,h1),t1] -; else [[],s] - -(DEFUN |pilePlusComments| (|s|) - (PROG (|t1| |h1| |t| |h| |LETTMP#1|) - (RETURN - (COND - ((|npNull| |s|) (LIST NIL |s|)) - ('T (SETQ |LETTMP#1| (LIST (CAR |s|) (CDR |s|))) - (SETQ |h| (CAR |LETTMP#1|)) (SETQ |t| (CADR |LETTMP#1|)) - (COND - ((|pilePlusComment| |h|) - (SETQ |LETTMP#1| (|pilePlusComments| |t|)) - (SETQ |h1| (CAR |LETTMP#1|)) (SETQ |t1| (CADR |LETTMP#1|)) - (LIST (CONS |h| |h1|) |t1|)) - ('T (LIST NIL |s|)))))))) - -;pileTree(n,s)== -; if npNull s -; then [false,n,[],s] -; else -; [h,t]:=[car s,cdr s] -; hh:=pileColumn CAR h -; if hh > n -; then pileForests(CAR h,hh,t) -; else [false,n,[],s] - -(DEFUN |pileTree| (|n| |s|) - (PROG (|hh| |t| |h| |LETTMP#1|) - (RETURN - (COND - ((|npNull| |s|) (LIST NIL |n| NIL |s|)) - ('T (SETQ |LETTMP#1| (LIST (CAR |s|) (CDR |s|))) - (SETQ |h| (CAR |LETTMP#1|)) (SETQ |t| (CADR |LETTMP#1|)) - (SETQ |hh| (|pileColumn| (CAR |h|))) - (COND - ((< |n| |hh|) (|pileForests| (CAR |h|) |hh| |t|)) - ('T (LIST NIL |n| NIL |s|)))))))) - -;eqpileTree(n,s)== -; if npNull s -; then [false,n,[],s] -; else -; [h,t]:=[car s,cdr s] -; hh:=pileColumn CAR h -; if hh = n -; then pileForests(CAR h,hh,t) -; else [false,n,[],s] - -(DEFUN |eqpileTree| (|n| |s|) - (PROG (|hh| |t| |h| |LETTMP#1|) - (RETURN - (COND - ((|npNull| |s|) (LIST NIL |n| NIL |s|)) - ('T (SETQ |LETTMP#1| (LIST (CAR |s|) (CDR |s|))) - (SETQ |h| (CAR |LETTMP#1|)) (SETQ |t| (CADR |LETTMP#1|)) - (SETQ |hh| (|pileColumn| (CAR |h|))) - (COND - ((EQUAL |hh| |n|) (|pileForests| (CAR |h|) |hh| |t|)) - ('T (LIST NIL |n| NIL |s|)))))))) - -;pileForest(n,s)== -; [b,hh,h,t]:= pileTree(n,s) -; if b -; then -; [h1,t1]:=pileForest1(hh,t) -; [cons(h,h1),t1] -; else [[],s] - -(DEFUN |pileForest| (|n| |s|) - (PROG (|t1| |h1| |t| |h| |hh| |b| |LETTMP#1|) - (RETURN - (PROGN - (SETQ |LETTMP#1| (|pileTree| |n| |s|)) - (SETQ |b| (CAR |LETTMP#1|)) - (SETQ |hh| (CADR |LETTMP#1|)) - (SETQ |h| (CADDR |LETTMP#1|)) - (SETQ |t| (CADDDR |LETTMP#1|)) - (COND - (|b| (SETQ |LETTMP#1| (|pileForest1| |hh| |t|)) - (SETQ |h1| (CAR |LETTMP#1|)) - (SETQ |t1| (CADR |LETTMP#1|)) - (LIST (CONS |h| |h1|) |t1|)) - ('T (LIST NIL |s|))))))) - -;pileForest1(n,s)== -; [b,n1,h,t]:= eqpileTree(n,s) -; if b -; then -; [h1,t1]:=pileForest1(n,t) -; [cons(h,h1),t1] -; else [[],s] - -(DEFUN |pileForest1| (|n| |s|) - (PROG (|t1| |h1| |t| |h| |n1| |b| |LETTMP#1|) - (RETURN - (PROGN - (SETQ |LETTMP#1| (|eqpileTree| |n| |s|)) - (SETQ |b| (CAR |LETTMP#1|)) - (SETQ |n1| (CADR |LETTMP#1|)) - (SETQ |h| (CADDR |LETTMP#1|)) - (SETQ |t| (CADDDR |LETTMP#1|)) - (COND - (|b| (SETQ |LETTMP#1| (|pileForest1| |n| |t|)) - (SETQ |h1| (CAR |LETTMP#1|)) - (SETQ |t1| (CADR |LETTMP#1|)) - (LIST (CONS |h| |h1|) |t1|)) - ('T (LIST NIL |s|))))))) - -;pileForests(h,n,s)== -; [h1,t1]:=pileForest(n,s) -; if npNull h1 -; then [true,n,h,s] -; else pileForests(pileCtree(h,h1),n,t1) - -(DEFUN |pileForests| (|h| |n| |s|) - (PROG (|t1| |h1| |LETTMP#1|) - (RETURN - (PROGN - (SETQ |LETTMP#1| (|pileForest| |n| |s|)) - (SETQ |h1| (CAR |LETTMP#1|)) - (SETQ |t1| (CADR |LETTMP#1|)) - (COND - ((|npNull| |h1|) (LIST T |n| |h| |s|)) - ('T (|pileForests| (|pileCtree| |h| |h1|) |n| |t1|))))))) - -;pileCtree(x,y)==dqAppend(x,pileCforest y) - -(DEFUN |pileCtree| (|x| |y|) - (PROG () (RETURN (|dqAppend| |x| (|pileCforest| |y|))))) - -;-- only enpiles forests with >=2 trees -; -;pileCforest x== -; if null x -; then [] -; else if null cdr x -; then -; f:= car x -; if EQ(tokPart CAAR f,"IF") -; then enPile f -; else f -; else enPile separatePiles x - -(DEFUN |pileCforest| (|x|) - (PROG (|f|) - (RETURN - (COND - ((NULL |x|) NIL) - ((NULL (CDR |x|)) (SETQ |f| (CAR |x|)) - (COND - ((EQ (|tokPart| (CAAR |f|)) 'IF) (|enPile| |f|)) - ('T |f|))) - ('T (|enPile| (|separatePiles| |x|))))))) - -;firstTokPosn t== tokPosn CAAR t - -(DEFUN |firstTokPosn| (|t|) (PROG () (RETURN (|tokPosn| (CAAR |t|))))) - -;lastTokPosn t== tokPosn CADR t - -(DEFUN |lastTokPosn| (|t|) (PROG () (RETURN (|tokPosn| (CADR |t|))))) - -;separatePiles x== -; if null x -; then [] -; else if null cdr x -; then car x -; else -; a:=car x -; semicolon:=dqUnit tokConstruct("key", "BACKSET",lastTokPosn a) -; dqConcat [a,semicolon,separatePiles cdr x] - -(DEFUN |separatePiles| (|x|) - (PROG (|semicolon| |a|) - (RETURN - (COND - ((NULL |x|) NIL) - ((NULL (CDR |x|)) (CAR |x|)) - ('T (SETQ |a| (CAR |x|)) - (SETQ |semicolon| - (|dqUnit| - (|tokConstruct| '|key| 'BACKSET (|lastTokPosn| |a|)))) - (|dqConcat| - (LIST |a| |semicolon| (|separatePiles| (CDR |x|))))))))) - -;enPile x== -; dqConcat [dqUnit tokConstruct("key","SETTAB",firstTokPosn x), -; x, _ -; dqUnit tokConstruct("key","BACKTAB",lastTokPosn x)] - -(DEFUN |enPile| (|x|) - (PROG () - (RETURN - (|dqConcat| - (LIST (|dqUnit| - (|tokConstruct| '|key| 'SETTAB - (|firstTokPosn| |x|))) - |x| - (|dqUnit| - (|tokConstruct| '|key| 'BACKTAB - (|lastTokPosn| |x|)))))))) - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document}