diff --git a/books/bookvol5.pamphlet b/books/bookvol5.pamphlet index 6349513..0bb103d 100644 --- a/books/bookvol5.pamphlet +++ b/books/bookvol5.pamphlet @@ -5494,6 +5494,28 @@ and the current token (\$ttok) \section{Trees} +\defun{pfAnd?}{Is this an And node?} +\calls{pfAnd?}{pfAbSynOp?} +<>= +(defun |pfAnd?| (pf) + (|pfAbSynOp?| pf '|And|)) + +@ + +\defun{pfAndLeft}{Return the Left part of an And node} +<>= +(defun |pfAndLeft| (pf) + (cadr pf)) + +@ + +\defun{pfAndRight}{Return the Right part of an And node} +<>= +(defun |pfAndRight| (|pf|) + (caddr |pf|)) + +@ + \defun{pfApplication?}{Is this an Application node?} \calls{pfApplication?}{pfAbSynOp?} <>= @@ -5608,6 +5630,30 @@ and the current token (\$ttok) @ +\defun{pfFree?}{Is this a Free node?} +\calls{pfFree?}{pfAbSynOp?} +<>= +(defun |pfFree?| (pf) + (|pfAbSynOp?| pf '|Free|)) + +@ + +\defun{pf0FreeItems}{Return the parts of the Items of a Free node} +\calls{pf0FreeItems}{pfParts} +\calls{pf0FreeItems}{pfFreeItems} +<>= +(defun |pf0FreeItems| (pf) + (|pfParts| (|pfFreeItems| pf))) + +@ + +\defun{pfFreeItems}{Return the Items of a Free node} +<>= +(defun |pfFreeItems| (pf) + (cadr pf)) + +@ + \defun{pfForin?}{Is this a ForIn node?} \calls{pfForin?}{pfAbSynOp?} <>= @@ -5690,6 +5736,38 @@ and the current token (\$ttok) @ +\defun{pfLambda?}{Is this a Lambda node?} +\calls{pfLambda?}{pfAbSynOp?} +<>= +(defun |pfLambda?| (pf) + (|pfAbSynOp?| pf '|Lambda|)) + +@ + +\defun{pfLocal?}{Is this a Local node?} +\calls{pfLocal?}{pfAbSynOp?} +<>= +(defun |pfLocal?| (pf) + (|pfAbSynOp?| pf '|Local|)) + +@ + +\defun{pf0LocalItems}{Return the parts of Items of a Local node} +\calls{pf0LocalItems}{pfParts} +\calls{pf0LocalItems}{pfLocalItems} +<>= +(defun |pf0LocalItems| (pf) + (|pfParts| (|pfLocalItems| pf))) + +@ + +\defun{pfLocalItems}{Return the Items of a Local node} +<>= +(defun |pfLocalItems| (pf) + (cadr pf)) + +@ + \defun{pfLoop?}{Is this a Loop node?} \calls{pfLoop?}{pfAbSynOp?} <>= @@ -5707,6 +5785,66 @@ and the current token (\$ttok) @ +\defun{pfMLambda?}{Is this an MLambda node?} +\calls{pfMLambda?}{pfAbSynOp?} +<>= +(defun |pfMLambda?| (pf) + (|pfAbSynOp?| pf '|MLambda|)) + +@ + +\defun{pfNot?}{Is this a Not node?} +\calls{pfNot?}{pfAbSynOp?} +<>= +(defun |pfNot?| (pf) + (|pfAbSynOp?| pf '|Not|)) + +@ + +\defun{pfNotArg}{Return the Arg part of a Not node} +<>= +(defun |pfNotArg| (pf) + (cadr pf)) + +@ + +\defun{pfNovalue?}{Is this a Novalue node?} +\calls{pfNovalue?}{pfAbSynOp?} +<>= +(defun |pfNovalue?| (pf) + (|pfAbSynOp?| pf '|Novalue|)) + +@ + +\defun{pfNovalueExpr}{Return the Expr part of a Novalue node} +<>= +(defun |pfNovalueExpr| (pf) + (cadr pf)) + +@ + +\defun{pfOr?}{Is this an Or node?} +\calls{pfOr?}{pfAbSynOp?} +<>= +(defun |pfOr?| (pf) + (|pfAbSynOp?| pf '|Or|)) + +@ + +\defun{pfOrLeft}{Return the Left part of an Or node} +<>= +(defun |pfOrLeft| (pf) + (cadr pf)) + +@ + +\defun{pfOrRight}{Return the Right part of an Or node} +<>= +(defun |pfOrRight| (pf) + (caddr pf)) + +@ + \defun{pfPretend?}{Is this a Pretend node?} \calls{pfPretend?}{pfAbSynOp?} <>= @@ -5729,6 +5867,36 @@ and the current token (\$ttok) @ +\defun{pfRestrict?}{Is this a Restrict node?} +\calls{pfRestrict?}{pfAbSynOp?} +<>= +(defun |pfRestrict?| (pf) + (|pfAbSynOp?| pf '|Restrict|)) + +@ + +\defun{pfRestrictExpr}{Return the Expr part of a Restrict node} +<>= +(defun |pfRestrictExpr| (pf) + (cadr pf)) + +@ + +\defun{pfRestrictType}{Return the Type part of a Restrict node} +<>= +(defun |pfRestrictType| (pf) + (caddr pf)) + +@ + +\defun{pfRule?}{Is this a Rule node?} +\calls{pfRule?}{pfAbSynOp?} +<>= +(defun |pfRule?| (pf) + (|pfAbSynOp?| pf '|Rule|)) + +@ + \defun{pfSequence?}{ Is this a Sequence node?} \calls{pfSequence?}{pfAbSynOp?} <>= @@ -5828,6 +5996,14 @@ and the current token (\$ttok) @ +\defun{pfWrong?}{Is this a Wrong node?} +\calls{pfWrong?}{pfAbSynOp?} +<>= +(defun |pfWrong?| (pf) + (|pfAbSynOp?| pf '|Wrong|)) + +@ + \chapter{Pftree to s-expression translation} Pftree to s-expression translation. Used to interface the new parser technology to the interpreter. The input is a parseTree and the @@ -6459,6 +6635,45 @@ output is an old-parser-style s-expression. @ +\defun{pfLambda2Sex}{Convert a Lambda node to an S-expression} +\calls{pfLambda2Sex}{pfLambdaTran} +<>= +(defun |pfLambda2Sex| (pf) + (let (body argList tmp1) + (setq tmp1 (|pfLambdaTran| pf)) + (setq argList (car tmp1)) + (setq body (cdr tmp1)) + (cons 'adef (cons argList body)))) + +@ + +\defun{pfRule2Sex}{Convert a Rule node to an S-expression} +\calls{pfRule2Sex}{pfLhsRule2Sex} +\calls{pfRule2Sex}{pfRuleLhsItems} +\calls{pfRule2Sex}{pfRhsRule2Sex} +\calls{pfRule2Sex}{pfRuleRhs} +\calls{pfRule2Sex}{ruleLhsTran} +\calls{pfRule2Sex}{rulePredicateTran} +\usesdollar{pfRule2Sex}{multiVarPredicateList} +\usesdollar{pfRule2Sex}{predicateList} +\usesdollar{pfRule2Sex}{quotedOpList} +<>= +(defun |pfRule2Sex| (pf) + (let (|$multiVarPredicateList| |$predicateList| |$quotedOpList| rhs lhs) + (declare (special |$multiVarPredicateList| |$predicateList| |$quotedOpList|)) + (setq |$quotedOpList| nil) + (setq |$predicateList| nil) + (setq |$multiVarPredicateList| nil) + (setq lhs (|pfLhsRule2Sex| (|pfRuleLhsItems| pf))) + (setq rhs (|pfRhsRule2Sex| (|pfRuleRhs| pf))) + (setq lhs (|ruleLhsTran| lhs)) + (|rulePredicateTran| + (if |$quotedOpList| + (list '|rule| lhs rhs (cons '|construct| |$quotedOpList|)) + (list '|rule| lhs rhs))))) + +@ + \defun{opTran}{Translate ops into internal symbols} \usesdollar{opTran}{dotdot} <>= @@ -34127,6 +34342,9 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> +<> +<> <> <> <> @@ -34144,6 +34362,8 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> +<> <> <> <> @@ -34155,16 +34375,32 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> +<> <> <> +<> <> +<> <> <> <> +<> +<> <> +<> +<> +<> +<> +<> <> <> <> +<> +<> +<> +<> +<> <> <> <> @@ -34181,7 +34417,10 @@ This needs to work off the internal exposure list, not the file. <> <> <> +<> <> +<> +<> <> <> <> diff --git a/changelog b/changelog index cc37007..7b90eec 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20100208 tpd src/axiom-website/patches.html 20100208.02.tpd.patch +20100208 tpd src/interp/ptrees.lisp treeshake +20100208 tpd src/interp/pf2sex.lisp treeshake 20100208 tpd src/axiom-website/patches.html 20100208.01.tpd.patch 20100208 tpd src/interp/ptrees.lisp treeshake 20100208 tpd src/interp/pf2sex.lisp treeshake diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 9e37978..b721a18 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -2443,5 +2443,7 @@ books/bookvol5 merge and remove monitor.lisp
books/bookvol5 treeshake ptrees, pf2sex
20100208.01.tpd.patch books/bookvol5 treeshake ptrees, pf2sex
+20100208.02.tpd.patch +books/bookvol5 treeshake ptrees, pf2sex
diff --git a/src/interp/pf2sex.lisp.pamphlet b/src/interp/pf2sex.lisp.pamphlet index 9605208..bd2e8f0 100644 --- a/src/interp/pf2sex.lisp.pamphlet +++ b/src/interp/pf2sex.lisp.pamphlet @@ -247,19 +247,6 @@ Value = NIL (|pf2Sex1| (|pfLambdaBody| |pf|)))))) ('T (CONS '|id| (LIST '(NIL) '(NIL) (|pf2Sex1| |pf|)))))))) -;pfLambda2Sex pf == -; [argList, :body] := pfLambdaTran pf -; ["ADEF", argList, :body] - -(DEFUN |pfLambda2Sex| (|pf|) - (PROG (|body| |argList| |LETTMP#1|) - (RETURN - (PROGN - (SETQ |LETTMP#1| (|pfLambdaTran| |pf|)) - (SETQ |argList| (CAR |LETTMP#1|)) - (SETQ |body| (CDR |LETTMP#1|)) - (CONS 'ADEF (CONS |argList| |body|)))))) - ;pfCollectArgTran pf == ; pfCollect? pf => ; conds := [pf2Sex1 x for x in pfParts pfCollectIterators pf] @@ -361,37 +348,6 @@ Value = NIL ('T |bfForm|)))))) -;pfRule2Sex pf == -; $quotedOpList:local := nil -; $predicateList:local := nil -; $multiVarPredicateList:local := nil -; lhs := pfLhsRule2Sex pfRuleLhsItems pf -; rhs := pfRhsRule2Sex pfRuleRhs pf -; lhs := ruleLhsTran lhs -; rulePredicateTran -; $quotedOpList => ["rule", lhs, rhs, ["construct", :$quotedOpList]] -; ["rule", lhs, rhs] - -(DEFUN |pfRule2Sex| (|pf|) - (PROG (|$multiVarPredicateList| |$predicateList| |$quotedOpList| - |rhs| |lhs|) - (DECLARE (SPECIAL |$multiVarPredicateList| |$predicateList| - |$quotedOpList|)) - (RETURN - (PROGN - (SETQ |$quotedOpList| NIL) - (SETQ |$predicateList| NIL) - (SETQ |$multiVarPredicateList| NIL) - (SETQ |lhs| (|pfLhsRule2Sex| (|pfRuleLhsItems| |pf|))) - (SETQ |rhs| (|pfRhsRule2Sex| (|pfRuleRhs| |pf|))) - (SETQ |lhs| (|ruleLhsTran| |lhs|)) - (|rulePredicateTran| - (COND - (|$quotedOpList| - (LIST '|rule| |lhs| |rhs| - (CONS '|construct| |$quotedOpList|))) - ('T (LIST '|rule| |lhs| |rhs|)))))))) - ;ruleLhsTran ruleLhs == ; for pred in $predicateList repeat ; [name, predLhs, :predRhs] := pred diff --git a/src/interp/ptrees.lisp.pamphlet b/src/interp/ptrees.lisp.pamphlet index cd0596c..37764b7 100644 --- a/src/interp/ptrees.lisp.pamphlet +++ b/src/interp/ptrees.lisp.pamphlet @@ -256,48 +256,16 @@ (DEFUN |pfAnd| (|pfleft| |pfright|) (PROG () (RETURN (|pfTree| '|And| (LIST |pfleft| |pfright|))))) -;pfAnd?(pf) == pfAbSynOp? (pf, 'And) - -(DEFUN |pfAnd?| (|pf|) (PROG () (RETURN (|pfAbSynOp?| |pf| '|And|)))) - -;pfAndLeft pf == CADR pf -- was ==> - -(DEFUN |pfAndLeft| (|pf|) (PROG () (RETURN (CADR |pf|)))) - -;pfAndRight pf == CADDR pf -- was ==> - -(DEFUN |pfAndRight| (|pf|) (PROG () (RETURN (CADDR |pf|)))) - ;pfOr(pfleft, pfright) == pfTree('Or, [pfleft, pfright]) (DEFUN |pfOr| (|pfleft| |pfright|) (PROG () (RETURN (|pfTree| '|Or| (LIST |pfleft| |pfright|))))) -;pfOr?(pf) == pfAbSynOp? (pf, 'Or) - -(DEFUN |pfOr?| (|pf|) (PROG () (RETURN (|pfAbSynOp?| |pf| '|Or|)))) - -;pfOrLeft pf == CADR pf -- was ==> - -(DEFUN |pfOrLeft| (|pf|) (PROG () (RETURN (CADR |pf|)))) - -;pfOrRight pf == CADDR pf -- was ==> - -(DEFUN |pfOrRight| (|pf|) (PROG () (RETURN (CADDR |pf|)))) - ;pfNot(arg) == pfTree('Not, [arg]) (DEFUN |pfNot| (|arg|) (PROG () (RETURN (|pfTree| '|Not| (LIST |arg|))))) -;pfNot?(pf) == pfAbSynOp? (pf, 'Not) - -(DEFUN |pfNot?| (|pf|) (PROG () (RETURN (|pfAbSynOp?| |pf| '|Not|)))) - -;pfNotArg pf == CADR pf -- was ==> - -(DEFUN |pfNotArg| (|pf|) (PROG () (RETURN (CADR |pf|)))) - ;pfEnSequence a== ; if null a ; then pfTuple pfListOf a @@ -560,11 +528,6 @@ (DEFUN |pfWrong| (|pfwhy| |pfrubble|) (PROG () (RETURN (|pfTree| '|Wrong| (LIST |pfwhy| |pfrubble|))))) -;pfWrong?(pf) == pfAbSynOp? (pf, 'Wrong) - -(DEFUN |pfWrong?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|Wrong|)))) - ;pfWrongWhy pf == CADR pf -- was ==> (DEFUN |pfWrongWhy| (|pf|) (PROG () (RETURN (CADR |pf|)))) @@ -793,19 +756,6 @@ (DEFUN |pfRestrict| (|pfexpr| |pftype|) (PROG () (RETURN (|pfTree| '|Restrict| (LIST |pfexpr| |pftype|))))) -;pfRestrict?(pf) == pfAbSynOp? (pf, 'Restrict) - -(DEFUN |pfRestrict?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|Restrict|)))) - -;pfRestrictExpr pf == CADR pf -- was ==> - -(DEFUN |pfRestrictExpr| (|pf|) (PROG () (RETURN (CADR |pf|)))) - -;pfRestrictType pf == CADDR pf -- was ==> - -(DEFUN |pfRestrictType| (|pf|) (PROG () (RETURN (CADDR |pf|)))) - ;pfRetractTo(pfexpr, pftype) == pfTree('RetractTo, [pfexpr, pftype]) (DEFUN |pfRetractTo| (|pfexpr| |pftype|) @@ -846,11 +796,6 @@ (PROG () (RETURN (|pfTree| '|Lambda| (LIST |pfargs| |pfrets| |pfbody|))))) -;pfLambda?(pf) == pfAbSynOp? (pf, 'Lambda) - -(DEFUN |pfLambda?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|Lambda|)))) - ;pfLambdaArgs pf == CADR pf -- was ==> (DEFUN |pfLambdaArgs| (|pf|) (PROG () (RETURN (CADR |pf|)))) @@ -910,11 +855,6 @@ (DEFUN |pfMLambda| (|pfargs| |pfbody|) (PROG () (RETURN (|pfTree| '|MLambda| (LIST |pfargs| |pfbody|))))) -;pfMLambda?(pf) == pfAbSynOp? (pf, 'MLambda) - -(DEFUN |pfMLambda?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|MLambda|)))) - ;pfMLambdaArgs pf == CADR pf -- was ==> (DEFUN |pfMLambdaArgs| (|pf|) (PROG () (RETURN (CADR |pf|)))) @@ -984,15 +924,6 @@ (DEFUN |pfNovalue| (|pfexpr|) (PROG () (RETURN (|pfTree| '|Novalue| (LIST |pfexpr|))))) -;pfNovalue?(pf) == pfAbSynOp? (pf, 'Novalue) - -(DEFUN |pfNovalue?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|Novalue|)))) - -;pfNovalueExpr pf == CADR pf -- was ==> - -(DEFUN |pfNovalueExpr| (|pf|) (PROG () (RETURN (CADR |pf|)))) - ;-- Loop := (Iterators: [Iterator]) ;pfLoop(pfiterators) == pfTree('Loop, [pfiterators]) @@ -1165,11 +1096,6 @@ (DEFUN |pfRule| (|pflhsitems| |pfrhs|) (PROG () (RETURN (|pfTree| '|Rule| (LIST |pflhsitems| |pfrhs|))))) -;pfRule?(pf) == pfAbSynOp? (pf, 'Rule) - -(DEFUN |pfRule?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|Rule|)))) - ;pfRuleLhsItems pf == CADR pf -- was ==> (DEFUN |pfRuleLhsItems| (|pf|) (PROG () (RETURN (CADR |pf|)))) @@ -1268,20 +1194,6 @@ (DEFUN |pfLocal| (|pfitems|) (PROG () (RETURN (|pfTree| '|Local| (LIST |pfitems|))))) -;pfLocal?(pf) == pfAbSynOp? (pf, 'Local) - -(DEFUN |pfLocal?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|Local|)))) - -;pfLocalItems pf == CADR pf -- was ==> - -(DEFUN |pfLocalItems| (|pf|) (PROG () (RETURN (CADR |pf|)))) - -;pf0LocalItems pf == pfParts pfLocalItems pf - -(DEFUN |pf0LocalItems| (|pf|) - (PROG () (RETURN (|pfParts| (|pfLocalItems| |pf|))))) - ;-- Free := (Items: [Typed]) ;pfFree(pfitems) == pfTree('Free, [pfitems]) @@ -1289,20 +1201,6 @@ (DEFUN |pfFree| (|pfitems|) (PROG () (RETURN (|pfTree| '|Free| (LIST |pfitems|))))) -;pfFree?(pf) == pfAbSynOp? (pf, 'Free) - -(DEFUN |pfFree?| (|pf|) - (PROG () (RETURN (|pfAbSynOp?| |pf| '|Free|)))) - -;pfFreeItems pf == CADR pf -- was ==> - -(DEFUN |pfFreeItems| (|pf|) (PROG () (RETURN (CADR |pf|)))) - -;pf0FreeItems pf == pfParts pfFreeItems pf - -(DEFUN |pf0FreeItems| (|pf|) - (PROG () (RETURN (|pfParts| (|pfFreeItems| |pf|))))) - ;-- Import := (Items: [QualType]) ;pfImport(pfitems) == pfTree('Import, [pfitems])