diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index 19d6869..e7e586e 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -5137,6 +5137,74 @@ even if the predicate in any while clauses are not false. @ +\chapter{Abstract Syntax Trees (ptrees)} +\begin{verbatim} +Abstract Syntax Trees + +These functions create and examine abstract +syntax trees. These are called pform, for short. + +!! This file also contains constructors for concrete syntax, although +!! they should be somewhere else. + +THE PFORM DATA STRUCTURE + Leaves: [hd, tok, pos] + Trees: [hd, tree, tree, ...] + hd is either an id or (id . alist) + +\end{verbatim} + +\defun{tokConstruct}{tokConstruct} +The tokConstruct function is a constructer and selectors for leaf tokens +<>= +(defun |tokConstruct| (hd tok &rest pos) + (let (a) + (setq a (cons hd tok)) + (cond + ((ifcar pos) + (cond + ((|pfNoPosition?| (car pos)) + a) + (t + (|ncPutQ| a '|posn| (car pos)) + a))) + (t a)))) + +@ + +\defun{tokType}{tokType} +<>= +(defun |tokType| (x) (|ncTag| x)) + +@ + +\defun{tokPart}{tokPart} +<>= +(defun |tokPart| (x) (cdr x)) + +@ + +\defun{tokPosn}{tokPosn} +<>= +(defun |tokPosn| (x) + (let (a) + (setq a (qassq '|posn| (|ncAlist| x))) + (cond + (a (cdr a)) + (t (|pfNoPosition|))))) + +@ + +\defun{pfAbSynOp?}{pfAbSynOp?} +<>= +(defun |pfAbSynOp?| (form op) + (let (hd) + (setq hd (car form)) + (or (eq hd op) (eqcar hd op)))) + + +@ + \chapter{System Command Handling} \defdollar{systemCommands} The system commands are the top-level commands available in Axiom @@ -19713,13 +19781,11 @@ $traceletflag |Catch| |CatchAsCan| currenttime -|dqToList| error expand-tabs |%fname| |incAppend| |%id| -|insertpile| |intInterpretPform| |intnplisp| |intSayKeyedMsg| @@ -19738,7 +19804,6 @@ maxindex |next| |npParse| |%origin| -|pfAbSynOp?| |%pform| |poGlobalLinePosn| |porigin| @@ -20045,6 +20110,7 @@ maxindex <> <> +<> <> <> <> @@ -20209,6 +20275,10 @@ maxindex <> <> +<> +<> +<> +<> <> <> <> diff --git a/changelog b/changelog index d88c64f..317b322 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20091105 tpd src/axiom-website/patches.html 20091105.01.tpd.patch +20091105 tpd src/interp/ptrees.lisp partial merge +20091105 tpd books/bookvol5 partial merge of ptrees 20091104 tpd src/axiom-website/patches.html 20091104.04.tpd.patch 20091104 tpd src/interp/int-top.lisp removed 20091104 tpd src/axiom-website/patches.html 20091104.03.tpd.patch diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index e4e2008..907f984 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -2229,5 +2229,7 @@ books/bookvol5 merge, remove dq.lisp
books/bookvol5 merge, remove cstream.lisp
20091104.04.tpd.patch src/interp/int-top.lisp removed
+20091105.01.tpd.patch +books/bookvol5 partial merge of ptrees
diff --git a/src/interp/ptrees.lisp.pamphlet b/src/interp/ptrees.lisp.pamphlet index cc45333..40f1a39 100644 --- a/src/interp/ptrees.lisp.pamphlet +++ b/src/interp/ptrees.lisp.pamphlet @@ -9,64 +9,8 @@ \eject \tableofcontents \eject -\begin{verbatim} -Abstract Syntax Trees - -This file provides functions to create and examine abstract -syntax trees. These are called pform, for short. -The definition of valid pforms see ABSTRACT BOOT. - -!! This file also contains constructors for concrete syntax, although -!! they should be somewhere else. - -THE PFORM DATA STRUCTURE - Leaves: [hd, tok, pos] - Trees: [hd, tree, tree, ...] - hd is either an id or (id . alist) - -\end{verbatim} <<*>>= (in-package "BOOT") -;--constructer and selectors for leaf tokens -; -;tokConstruct(hd,tok,:pos)== -; a:=cons(hd,tok) -; IFCAR pos => -; pfNoPosition? CAR pos=> a -; ncPutQ(a,"posn",CAR pos) -; a -; a - -(DEFUN |tokConstruct| (|hd| |tok| &REST |pos|) - (PROG (|a|) - (RETURN - (PROGN - (SETQ |a| (CONS |hd| |tok|)) - (COND - ((IFCAR |pos|) - (COND - ((|pfNoPosition?| (CAR |pos|)) |a|) - ('T (PROGN (|ncPutQ| |a| '|posn| (CAR |pos|)) |a|)))) - ('T |a|)))))) - -;tokType x== ncTag x - -(DEFUN |tokType| (|x|) (PROG () (RETURN (|ncTag| |x|)))) - -;tokPart x== CDR x - -(DEFUN |tokPart| (|x|) (PROG () (RETURN (CDR |x|)))) - -;tokPosn x== -; a:= QASSQ("posn",ncAlist x) -; if a then CDR a else pfNoPosition() - -(DEFUN |tokPosn| (|x|) - (PROG (|a|) - (RETURN - (PROGN - (SETQ |a| (QASSQ '|posn| (|ncAlist| |x|))) - (COND (|a| (CDR |a|)) ('T (|pfNoPosition|))))))) ;pfAbSynOp form == ; hd := CAR form @@ -76,17 +20,6 @@ THE PFORM DATA STRUCTURE (PROG (|hd|) (RETURN (PROGN (SETQ |hd| (CAR |form|)) (OR (IFCAR |hd|) |hd|))))) -;pfAbSynOp?(form, op) == -; hd := CAR form -; EQ(hd, op) or EQCAR(hd, op) - -(DEFUN |pfAbSynOp?| (|form| |op|) - (PROG (|hd|) - (RETURN - (PROGN - (SETQ |hd| (CAR |form|)) - (OR (EQ |hd| |op|) (EQCAR |hd| |op|)))))) - ;pfLeaf? form == ; MEMQ(pfAbSynOp form, ; '(id idsy symbol string char float expression integer