diff options
-rw-r--r-- | src/interp/ChangeLog | 19 | ||||
-rw-r--r-- | src/interp/Makefile.in | 13 | ||||
-rw-r--r-- | src/interp/Makefile.pamphlet | 30 | ||||
-rw-r--r-- | src/interp/cparse.boot (renamed from src/interp/cparse.boot.pamphlet) | 101 | ||||
-rw-r--r-- | src/interp/posit.boot | 7 | ||||
-rw-r--r-- | src/interp/ptrees.boot.pamphlet | 45 | ||||
-rw-r--r-- | src/interp/ptrop.boot.pamphlet | 98 | ||||
-rw-r--r-- | src/interp/serror.boot (renamed from src/interp/serror.boot.pamphlet) | 102 |
8 files changed, 186 insertions, 229 deletions
diff --git a/src/interp/ChangeLog b/src/interp/ChangeLog index 2669f2de..6bc4a8e6 100644 --- a/src/interp/ChangeLog +++ b/src/interp/ChangeLog @@ -1,5 +1,24 @@ 2007-09-13 Gabriel Dos Reis <gdr@cs.tamu.edu> + * Makefile.pamphlet (OBJS): Don't include ptrop.$(FASLEXT). + (ptrees.$(FASLEXT)): New rule. + (cparse.$(FASLEXT)): Likewise. + * ptrop.boot.pamphlet: Move content to ptrees.boot.pamphlet. + * ptrees.boot.pamphlet: Import posit, serror. + * cparse.boot: New. Import ptrees. + * cparse.boot.pamphlet: Move content to cparse.boot. Remove. + * serror.boot: New. + (pfSourceStok): Move to posit.boot. + (npMissingMate): Move to cparse.boot. + (npMissing): Likewise. + (npCompMissing): Likewise. + (npRecorverTrap): Likewise. + (npListAndRecover): Likewise. + (npMoveTo): Likewise. + * serror.boot.pamphlet: Move content to serror.boot. Remove. + +2007-09-13 Gabriel Dos Reis <gdr@cs.tamu.edu> + * i-output.boot.pamphlet (exptNeedsPren): Use GETL, not GET. 2007-09-12 Gabriel Dos Reis <gdr@cs.tamu.edu> diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in index 948d730b..3a4f4720 100644 --- a/src/interp/Makefile.in +++ b/src/interp/Makefile.in @@ -91,7 +91,7 @@ OBJS= vmlisp.$(FASLEXT) hash.$(FASLEXT) \ packtran.$(FASLEXT) pathname.$(FASLEXT) \ pf2sex.$(FASLEXT) pile.$(FASLEXT) \ posit.$(FASLEXT) property.$(FASLEXT) \ - ptrees.$(FASLEXT) ptrop.$(FASLEXT) \ + ptrees.$(FASLEXT) \ record.$(FASLEXT) \ rulesets.$(FASLEXT) \ scan.$(FASLEXT) serror.$(FASLEXT) \ @@ -133,7 +133,7 @@ AXIOMsys_boot_sources = astr.boot alql.boot buildom.boot cattable.boot \ intfile.boot lisplib.boot macex.boot match.boot msg.boot \ msgdb.boot newfort.boot nrunfast.boot nrungo.boot nrunopt.boot \ nruntime.boot osyscmd.boot packtran.boot pathname.boot \ - pf2sex.boot pile.boot posit.boot ptrees.boot ptrop.boot \ + pf2sex.boot pile.boot posit.boot ptrees.boot \ record.boot rulesets.boot scan.boot serror.boot server.boot \ setvars.boot sfsfun.boot simpbool.boot slam.boot template.boot \ termrw.boot trace.boot fortcall.boot @@ -480,6 +480,12 @@ $(AUTO)/%.$(FASLEXT): %.$(FASLEXT) $(INSTALL) $< $@ +cparse.$(FASLEXT): cparse.clisp ptrees.$(FASLEXT) + $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< + +ptrees.$(FASLEXT): ptrees.clisp posit.$(FASLEXT) serror.$(FASLEXT) + $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< + pile.$(FASLEXT): pile.clisp scan.$(FASLEXT) $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< @@ -492,6 +498,9 @@ incl.$(FASLEXT): incl.clisp cstream.$(FASLEXT) cformat.$(FASLEXT) cformat.$(FASLEXT): cformat.clisp unlisp.$(FASLEXT) posit.$(FASLEXT) $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< +serror.$(FASLEXT): serror.boot posit.$(FASLEXT) + $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< + unlisp.$(FASLEXT): unlisp.lisp sys-macros.$(FASLEXT) $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet index 9861ca75..6441ae64 100644 --- a/src/interp/Makefile.pamphlet +++ b/src/interp/Makefile.pamphlet @@ -364,7 +364,7 @@ OBJS= vmlisp.$(FASLEXT) hash.$(FASLEXT) \ packtran.$(FASLEXT) pathname.$(FASLEXT) \ pf2sex.$(FASLEXT) pile.$(FASLEXT) \ posit.$(FASLEXT) property.$(FASLEXT) \ - ptrees.$(FASLEXT) ptrop.$(FASLEXT) \ + ptrees.$(FASLEXT) \ record.$(FASLEXT) \ rulesets.$(FASLEXT) \ scan.$(FASLEXT) serror.$(FASLEXT) \ @@ -406,7 +406,7 @@ AXIOMsys_boot_sources = astr.boot alql.boot buildom.boot cattable.boot \ intfile.boot lisplib.boot macex.boot match.boot msg.boot \ msgdb.boot newfort.boot nrunfast.boot nrungo.boot nrunopt.boot \ nruntime.boot osyscmd.boot packtran.boot pathname.boot \ - pf2sex.boot pile.boot posit.boot ptrees.boot ptrop.boot \ + pf2sex.boot pile.boot posit.boot ptrees.boot \ record.boot rulesets.boot scan.boot serror.boot server.boot \ setvars.boot sfsfun.boot simpbool.boot slam.boot template.boot \ termrw.boot trace.boot fortcall.boot @@ -1974,6 +1974,29 @@ distclean-local: clean-local $(AUTO)/%.$(FASLEXT): %.$(FASLEXT) $(INSTALL) $< $@ +## +## OpenAxiom's front-end consists of two parts: +## (a) the interprerter's parser -- also referred to as new parser +## (b) the compiler parser -- also referred to as parser +## +## The new parser component is always included in a running OpenAxiom +## image. However the old parser component is so called `autoloaded'. +## While in theory that should work, in practice it turns out that +## people tend to override functions in the autoload part, correcting +## bugs only there. The consequence is that the same function will +## bahave very differently based on the history of the seesion. Ideal +## recipe for creating heisenbugs. +## +## The new parser component roughtly is: +## astr.boot dq.boot incl.boot pile.boot ptrees.boot +## posit.boot cparse.boot format.boot cstream.boot +## + +cparse.$(FASLEXT): cparse.clisp ptrees.$(FASLEXT) + $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< + +ptrees.$(FASLEXT): ptrees.clisp posit.$(FASLEXT) serror.$(FASLEXT) + $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< pile.$(FASLEXT): pile.clisp scan.$(FASLEXT) $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< @@ -1987,6 +2010,9 @@ incl.$(FASLEXT): incl.clisp cstream.$(FASLEXT) cformat.$(FASLEXT) cformat.$(FASLEXT): cformat.clisp unlisp.$(FASLEXT) posit.$(FASLEXT) $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< +serror.$(FASLEXT): serror.boot posit.$(FASLEXT) + $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< + unlisp.$(FASLEXT): unlisp.lisp sys-macros.$(FASLEXT) $(BOOTSYS) -- --compile --output=$@ --load-directory=. $< diff --git a/src/interp/cparse.boot.pamphlet b/src/interp/cparse.boot index 7e9aeaa0..c49ee250 100644 --- a/src/interp/cparse.boot.pamphlet +++ b/src/interp/cparse.boot @@ -1,21 +1,3 @@ -\documentclass{article} -\usepackage{axiom} - -\title{\File{src/interp/cparse.boot} Pamphlet} -\author{The Axiom Team} - -\begin{document} -\maketitle - -\begin{abstract} -\end{abstract} - -\tableofcontents -\eject - -\section{License} - -<<license>>= -- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -- All rights reserved. -- @@ -47,9 +29,7 @@ -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -@ -<<*>>= -<<license>> +import '"ptrees" )package "BOOT" @@ -933,9 +913,76 @@ npDefinition()== npPP function npDefinitionItem pfSequenceToList x== pfSequence? x => pfSequenceArgs x pfListOf [x] -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} + +--% Diagnostic routines + +npMissingMate(close,open)== + ncSoftError(tokPosn open, 'S2CY0008, []) + npMissing close + +npMissing s== + ncSoftError(tokPosn $stok,'S2CY0007, [PNAME s]) + THROW("TRAPPOINT","TRAPPED") + +npCompMissing s == npEqKey s or npMissing s + +npRecoverTrap()== + npFirstTok() + pos1 := tokPosn $stok + npMoveTo 0 + pos2 := tokPosn $stok + syIgnoredFromTo(pos1, pos2) + npPush [pfWrong(pfDocument ['"pile syntax error"],pfListOf [])] + + +npListAndRecover(f)== + a:=$stack + b:=nil + $stack:=nil + done:=false + c:=$inputStream + while not done repeat + found:=CATCH("TRAPPOINT",APPLY(f,nil)) + if found="TRAPPED" + then + $inputStream:=c + npRecoverTrap() + else if not found + then + $inputStream:=c + syGeneralErrorHere() + npRecoverTrap() + if npEqKey "BACKSET" + then + c:=$inputStream + else if npEqPeek "BACKTAB" + then + done:=true + else + $inputStream:=c + syGeneralErrorHere() + npRecoverTrap() + if npEqPeek "BACKTAB" + then done:=true + else + npNext() + c:=$inputStream + b:=cons(npPop1(),b) + $stack:=a + npPush NREVERSE b + +npMoveTo n== + if null $inputStream + then true + else + if npEqPeek "BACKTAB" + then if n=0 + then true + else (npNext();npMoveTo(n-1)) + else if npEqPeek "BACKSET" + then if n=0 + then true + else (npNext();npMoveTo n) + else if npEqKey "SETTAB" + then npMoveTo(n+1) + else (npNext();npMoveTo n) diff --git a/src/interp/posit.boot b/src/interp/posit.boot index b9c546e4..37ab021a 100644 --- a/src/interp/posit.boot +++ b/src/interp/posit.boot @@ -92,6 +92,13 @@ poGetLineObject posn == CAR posn pfGetLineObject posn == poGetLineObject posn +pfSourceStok x== + if pfLeaf? x + then x + else if null pfParts x + then 'NoToken + else pfSourceStok pfFirst x + pfSourceToken form == if pfLeaf? form then pfLeafToken form diff --git a/src/interp/ptrees.boot.pamphlet b/src/interp/ptrees.boot.pamphlet index dea41bdc..414b09af 100644 --- a/src/interp/ptrees.boot.pamphlet +++ b/src/interp/ptrees.boot.pamphlet @@ -62,6 +62,9 @@ THE PFORM DATA STRUCTURE <<*>>= <<license>> +import '"posit" +import '"serror" + )package "BOOT" --% SPECIAL NODES @@ -741,7 +744,47 @@ pfFlattenApp x== [x] - +--% Utility operations on Abstract Syntax Trees + +-- An S-expression which people can read. +pfSexpr pform == + strip pform where + strip pform == + pfId? pform => pfIdSymbol pform + pfLiteral? pform => pfLiteralString pform + pfLeaf? pform => tokPart pform + + pfApplication? pform => + args := + a := pfApplicationArg pform + if pfTuple? a then pf0TupleParts a else [a] + [strip p for p in cons(pfApplicationOp pform, args)] + + cons(pfAbSynOp pform, [strip p for p in pfParts pform]) + +pfCopyWithPos( pform , pos ) == + pfLeaf? pform => pfLeaf( pfAbSynOp pform , tokPart pform , pos ) + pfTree( pfAbSynOp pform , [ pfCopyWithPos( p , pos ) for p in pfParts pform ] ) + +pfMapParts(f, pform) == + pfLeaf? pform => pform + parts0 := pfParts pform + parts1 := [FUNCALL(f, p) for p in parts0] + -- Return the original if no changes. + same := true + for p0 in parts0 for p1 in parts1 while same repeat same := EQ(p0,p1) + same => pform + pfTree(pfAbSynOp pform, parts1) + + +pf0ApplicationArgs pform == + arg := pfApplicationArg pform + pf0FlattenSyntacticTuple arg + +pf0FlattenSyntacticTuple pform == + not pfTuple? pform => [pform] + [:pf0FlattenSyntacticTuple p for p in pf0TupleParts pform] + @ \eject \begin{thebibliography}{99} diff --git a/src/interp/ptrop.boot.pamphlet b/src/interp/ptrop.boot.pamphlet deleted file mode 100644 index 70a65623..00000000 --- a/src/interp/ptrop.boot.pamphlet +++ /dev/null @@ -1,98 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/interp ptrop.boot} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= --- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. --- All rights reserved. --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- - Redistributions of source code must retain the above copyright --- notice, this list of conditions and the following disclaimer. --- --- - Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in --- the documentation and/or other materials provided with the --- distribution. --- --- - Neither the name of The Numerical ALgorithms Group Ltd. nor the --- names of its contributors may be used to endorse or promote products --- derived from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS --- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED --- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER --- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, --- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, --- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -@ -<<*>>= -<<license>> - -)package "BOOT" - ---% Utility operations on Abstract Syntax Trees - --- An S-expression which people can read. -pfSexpr pform == - strip pform where - strip pform == - pfId? pform => pfIdSymbol pform - pfLiteral? pform => pfLiteralString pform - pfLeaf? pform => tokPart pform - - pfApplication? pform => - args := - a := pfApplicationArg pform - if pfTuple? a then pf0TupleParts a else [a] - [strip p for p in cons(pfApplicationOp pform, args)] - - cons(pfAbSynOp pform, [strip p for p in pfParts pform]) - -pfCopyWithPos( pform , pos ) == - pfLeaf? pform => pfLeaf( pfAbSynOp pform , tokPart pform , pos ) - pfTree( pfAbSynOp pform , [ pfCopyWithPos( p , pos ) for p in pfParts pform ] ) - -pfMapParts(f, pform) == - pfLeaf? pform => pform - parts0 := pfParts pform - parts1 := [FUNCALL(f, p) for p in parts0] - -- Return the original if no changes. - same := true - for p0 in parts0 for p1 in parts1 while same repeat same := EQ(p0,p1) - same => pform - pfTree(pfAbSynOp pform, parts1) - - -pf0ApplicationArgs pform == - arg := pfApplicationArg pform - pf0FlattenSyntacticTuple arg - -pf0FlattenSyntacticTuple pform == - not pfTuple? pform => [pform] - [:pf0FlattenSyntacticTuple p for p in pf0TupleParts pform] - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/interp/serror.boot.pamphlet b/src/interp/serror.boot index 753655e9..0435e7ac 100644 --- a/src/interp/serror.boot.pamphlet +++ b/src/interp/serror.boot @@ -1,18 +1,7 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/interp serror.boot} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -- All rights reserved. +-- Copyright (C) 2007, Gabriel Dos Reis. +-- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are @@ -42,9 +31,7 @@ -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -@ -<<*>>= -<<license>> +import '"posit" --% Functions to handle specific errors (mostly syntax) @@ -67,23 +54,6 @@ syIgnoredFromTo(pos1, pos2) == ncSoftError(From pos1, 'S2CY0003, []) ncSoftError(To pos2, 'S2CY0004, []) -npMissingMate(close,open)== - ncSoftError(tokPosn open, 'S2CY0008, []) - npMissing close - -npMissing s== - ncSoftError(tokPosn $stok,'S2CY0007, [PNAME s]) - THROW("TRAPPOINT","TRAPPED") - -npCompMissing s == npEqKey s or npMissing s - -pfSourceStok x== - if pfLeaf? x - then x - else if null pfParts x - then 'NoToken - else pfSourceStok pfFirst x - npTrapForm(x)== a:=pfSourceStok x EQ(a,'NoToken)=> @@ -96,69 +66,3 @@ npTrap()== ncSoftError(tokPosn $stok,'S2CY0002,[]) THROW("TRAPPOINT","TRAPPED") -npRecoverTrap()== - npFirstTok() - pos1 := tokPosn $stok - npMoveTo 0 - pos2 := tokPosn $stok - syIgnoredFromTo(pos1, pos2) - npPush [pfWrong(pfDocument ['"pile syntax error"],pfListOf [])] - - -npListAndRecover(f)== - a:=$stack - b:=nil - $stack:=nil - done:=false - c:=$inputStream - while not done repeat - found:=CATCH("TRAPPOINT",APPLY(f,nil)) - if found="TRAPPED" - then - $inputStream:=c - npRecoverTrap() - else if not found - then - $inputStream:=c - syGeneralErrorHere() - npRecoverTrap() - if npEqKey "BACKSET" - then - c:=$inputStream - else if npEqPeek "BACKTAB" - then - done:=true - else - $inputStream:=c - syGeneralErrorHere() - npRecoverTrap() - if npEqPeek "BACKTAB" - then done:=true - else - npNext() - c:=$inputStream - b:=cons(npPop1(),b) - $stack:=a - npPush NREVERSE b - -npMoveTo n== - if null $inputStream - then true - else - if npEqPeek "BACKTAB" - then if n=0 - then true - else (npNext();npMoveTo(n-1)) - else if npEqPeek "BACKSET" - then if n=0 - then true - else (npNext();npMoveTo n) - else if npEqKey "SETTAB" - then npMoveTo(n+1) - else (npNext();npMoveTo n) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} |