rend.red 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. COMMENT The following is needed to get string case correct;
  2. FLAG('(OFF),'EVAL);
  3. OFF RAISE;
  4. COMMENT The following functions, which are referenced in the basic
  5. REDUCE source (RLISP, ALG1, ALG2, MATR and PHYS) should be defined to
  6. complete the definition of REDUCE:
  7. BYE
  8. DELCP
  9. ERROR1
  10. FILETYPE
  11. MKFIL
  12. ORDERP
  13. QUIT
  14. SEPRP
  15. SETPCHAR.
  16. Prototypical descriptions of these functions are as follows;
  17. SYMBOLIC PROCEDURE BYE;
  18. %Returns control to the computer's operating system command level.
  19. %The current REDUCE job cannot be restarted;
  20. EVAL '(QUIT);
  21. SYMBOLIC PROCEDURE DELCP U;
  22. %Returns true if U is a semicolon, dollar sign, or other delimiter.
  23. %This definition replaces the one in the BOOT file;
  24. U EQ '!; OR U EQ '!$ OR U EQ INTERN ASCII 125;
  25. SYMBOLIC PROCEDURE ERROR1;
  26. %This is the only call to an error function in the REDUCE source. It
  27. %should cause an error return, but NOT print anything, as preceding
  28. %statements have already done that. In terms of the LISP error
  29. %function it can be defined as follows;
  30. ERROR(99,NIL);
  31. SYMBOLIC PROCEDURE FILETYPE U;
  32. %determines the extension of a file U;
  33. IF ATOM U THEN NIL
  34. ELSE IF NOT ATOM CAR U AND NULL CDR U THEN FILETYPE CAR U
  35. ELSE IF DEVP CAR U
  36. THEN IF CAR U EQ 'DIR!: THEN FILETYPE CADDR U ELSE FILETYPE CADR U
  37. ELSE IF NOT IDP CDR U THEN NIL ELSE CDR U;
  38. SYMBOLIC PROCEDURE DEVP U;
  39. %determines if U is a file device type.
  40. NOT ATOM U OR IDP U AND CAR REVERSIP EXPLODE U EQ '!:;
  41. %SYMBOLIC PROCEDURE MKFIL U;
  42. %converts file descriptor U into valid system filename;
  43. %U; %this is the simplest one can do;
  44. %SYMBOLIC PROCEDURE ORDERP(U,V);
  45. %Returns true if U has same or higher order than id V by some
  46. %consistent convention (eg unique position in memory);
  47. %It must usually be defined in LAP, as in following DEC 10 version;
  48. %It must also be loaded BEFORE ALG2.RED;
  49. LAP '((ORDERP EXPR 2)
  50. (104960 1 2)
  51. (112640 1 (C 0))
  52. (MOVEI 1 (QUOTE T))
  53. (POPJ P));
  54. %SYMBOLIC PROCEDURE QUIT;
  55. %Returns control to the computer's operating system command level.
  56. %The current REDUCE job can however be restarted;
  57. GLOBAL '(!$EOL!$);
  58. SYMBOLIC PROCEDURE SEPRP U;
  59. %returns true if U is a blank or other separator (eg, tab or ff).
  60. %This definition replaces one in the BOOT file;
  61. U EQ '! OR U EQ '! OR U EQ !$EOL!$ OR U EQ INTERN ASCII 12;
  62. %SYMBOLIC PROCEDURE SETPCHAR U;
  63. %This function sets the terminal prompt character to U and returns
  64. %the previous value;
  65. %U;
  66. COMMENT The following functions are only referenced if various flags are
  67. set, or the functions are actually defined. They are defined in another
  68. module, which is not needed to build the basic system. The name of the
  69. flag follows the function name, enclosed in parentheses:
  70. BFQUOTIENT!: (BIGFLOAT)
  71. CEDIT (?)
  72. COMPD (COMP)
  73. EDIT1 This function provides a link to an editor. However, a
  74. definition is not necessary, since REDUCE checks to see
  75. if it has a function value.
  76. EMBFN (?)
  77. EZGCDF (EZGCD)
  78. FACTORF (FACTOR)
  79. LOAD!-MODULE (property list attribute MODULE-NAME)
  80. This function is used to load an external module into
  81. the system. It is only called if an attribute DOMAIN-MODE
  82. is given to a domain mode tag
  83. PRETTYPRINT (DEFN --- also called by DFPRINT)
  84. This function is used in particular for output of RLISP
  85. expressions in LISP syntax. If that feature is needed,
  86. and the prettyprint module is not available, then it
  87. should be defined as PRINT
  88. RPRINT (PRET)
  89. TEXPT!: (BIGFLOAT)
  90. TEXPT!:ANY (BIGFLOAT)
  91. TIME (TIME) returns elapsed time from some arbitrary initial
  92. point in milliseconds;
  93. COMMENT The FACTOR module also requires a definition for GCTIME, the
  94. time taken for garbage collection. If this is not defined in the given
  95. system, the following definition may be used;
  96. SYMBOLIC PROCEDURE GCTIME; 0;
  97. COMMENT The following definition overrides the standard source version;
  98. REMFLAG('(PRINTPROMPT),'LOSE);
  99. SYMBOLIC PROCEDURE PRINTPROMPT U; NIL;
  100. FLAG('(PRINTPROMPT),'LOSE);
  101. COMMENT There is also one global variable in the system which must be
  102. set independent of the sources, namely **ESC. This variable is used to
  103. "escape" from an input sequence to the top level of REDUCE.
  104. For complete flexibility, it should be defined as a global. Otherwise,
  105. a NEWNAM statement can be used. However, it MUST be defined in LISP
  106. before RLISP is loaded, and cannot be left until this file is defined.
  107. At the moment, this feature is not supported, as it interferes with the
  108. editing facilities;
  109. GLOBAL '(!*!*ESC);
  110. !*!*ESC := '!*ESC!*;
  111. COMMENT In addition, the global variable ESC* is used by the interactive
  112. string editor (defined in CEDIT) as a terminator for input strings. On
  113. ASCII terminals, <escape> is a good candidate;
  114. GLOBAL '(ESC!*);
  115. ESC!* := INTERN ASCII 125; %escape character;
  116. COMMENT We also need to define a function BEGIN, which acts as the
  117. top-level call to REDUCE, and sets the appropriate variables. The
  118. following is a minimum definition;
  119. REMFLAG('(BEGIN),'GO);
  120. FLUID '(LREADFN!* !*ECHO !*MODE !*SLIN);
  121. GLOBAL '(CRCHAR!* DATE!* ORIG!* !*EXTRAECHO !*HELP !*INT);
  122. GLOBAL '(CONTL!* IFL!* IPL!* OFL!* OPL!*);
  123. COMMENT The following two variables are DEC 10 specific;
  124. GLOBAL '(SYSTEM!* !*BAKGAG);
  125. SYMBOLIC PROCEDURE BEGIN;
  126. BEGIN SCALAR A1;
  127. ORIG!* := 0;
  128. !*ECHO := NOT !*INT;
  129. % !*EXTRAECHO := T; %this is needed in systems which do not
  130. %have the "standard" eol convention;
  131. CONTL!* := IFL!* := IPL!* := OFL!* := OPL!* := NIL;
  132. A1 := !*SLIN; !*SLIN := NIL; %shows we have entered this BEGIN;
  133. %The next eight lines are DEC 10 specific;
  134. !*BAKGAG := NIL; %turn off backtrace;
  135. LREADFN!* := NIL; %define a special reading function;
  136. RDSLSH NIL; %modify reader for Rlisp token handling;
  137. SCANSET T; %use table driven scanner;
  138. % IF SYSTEM!* NEQ 0 THEN CHKLEN();
  139. % IF SYSTEM!*=1 THEN BEGIN SCALAR A2;
  140. % SETSYS
  141. % IF PAIRP(A2:=ERRORSET('(JSYS 32 0 "<REDUCE>" 0 1),NIL,NIL))
  142. % THEN BOOLE(1,CAR A2,262143) ELSE 0 END;
  143. %end of DEC 10 specific code;
  144. IF NULL DATE!*
  145. THEN <<IF A1 THEN PRIN2T "Reduce Parsing ..."; GO TO A>>;
  146. IF FILEP '((REDUCE . INI)) THEN <<IN "REDUCE.INI"; TERPRI()>>;
  147. %allows for the automatic load of an initialization file;
  148. LINELENGTH IF !*INT THEN 72 ELSE 115;
  149. PRIN2 "REDUCE 3.0, ";
  150. PRIN2 DATE!*;
  151. PRIN2T " ...";
  152. !*MODE := IF GETD 'ADDSQ THEN 'ALGEBRAIC ELSE 'SYMBOLIC;
  153. DATE!* := NIL;
  154. IF !*HELP THEN PRIN2 "For help, type HELP<escape>";
  155. TERPRI();
  156. A: CRCHAR!* := '! ; %necessary initialization of CRCHAR!*;
  157. BEGIN1();
  158. !*SLIN := T;
  159. RESETPARSER(); %in case *SLIN affects this;
  160. PRIN2T "Entering LISP ...";
  161. SETPCHAR '!*
  162. END;
  163. FLAG('(BEGIN),'GO);
  164. COMMENT And now to set some system dependent variables;
  165. DATE!* := "15-Apr-83";
  166. %!*INT := T; %sets the appropriate interactive mode.
  167. %Needs to be suppressed during bootstrapping
  168. %to avoid CRBUF!* being used;
  169. COMMENT on the DEC 10, the end-of-file condition is not handled
  170. in quite the way described in the Standard LISP Report. The following
  171. statement is necessary to solve this problem;
  172. %!$EOF!$ := '!$EOF!$;
  173. COMMENT And finally ...;
  174. %REMD 'BEGIN2; %used in full bootstrap and needed later;
  175. COMMENT Definitions needed to support Norman-Moore factorizer on
  176. the PDP-10;
  177. FLUID '(LARGEST!-SMALL!-MODULUS);
  178. LARGEST!-SMALL!-MODULUS := 2**32;
  179. SYMBOLIC PROCEDURE LOGAND2(M,N); BOOLE(1,M,N);
  180. SYMBOLIC PROCEDURE LOGOR2(M,N); BOOLE(7,M,N);
  181. SYMBOLIC PROCEDURE LOGXOR2(M,N); BOOLE(6,M,N);
  182. REMFLAG('(IRIGHTSHIFT), 'LOSE);
  183. SYMBOLIC SMACRO PROCEDURE IRIGHTSHIFT(U,N); LSH(U,-N);
  184. FLAG('(IRIGHTSHIFT), 'LOSE);
  185. SYMBOLIC SMACRO PROCEDURE LEFTSHIFT(U,N); LSH(U,N);
  186. COMMENT Definition of MKFIL to handle string file names properly;
  187. SYMBOLIC PROCEDURE MKFIL U;
  188. %U is an ID or string. Result is a permissible LISP 1.6 filename.
  189. BEGIN SCALAR FILE,V,Y,Y1,Z;
  190. IF NULL U THEN FILERR U
  191. ELSE IF NOT STRINGP U
  192. THEN RETURN IF IDP U THEN U ELSE FILERR U;
  193. V := EXPLODEC U;
  194. A: Z := NEXTELM V; V := CDR Z; Z := CAR Z;
  195. IF NULL V THEN NIL
  196. ELSE IF CAR V EQ '!:
  197. THEN <<FILE := MKFRAG('!: . '!! . Z) . FILE; V := CDR V>>
  198. ELSE IF CAR V EQ '!.
  199. THEN IF NULL Z THEN FILERR U
  200. ELSE <<Y := NEXTELM CDR V; V := CDR Y;
  201. FILE := (MKFRAG Z . MKFRAG CAR Y) . FILE;
  202. Z := NIL>>
  203. ELSE IF CAR V EQ '!<
  204. THEN <<Y := NEXTELM CDR V; V := CDR Y;
  205. IF NOT EQCAR(V,'!>) THEN FILERR U;
  206. FILE := MKFRAG CAR Y . 'DIR!: . FILE;
  207. V := CDR V>>
  208. ELSE IF CAR V EQ '!> THEN FILERR U
  209. ELSE IF CAR V EQ '![
  210. THEN <<Y := NEXTELM CDR V; V := CDR Y;
  211. IF NOT EQCAR(V,'!,) THEN FILERR U;
  212. Y1 := MKFRAG CAR Y; Y := NEXTELM CDR V;
  213. V := CDR Y; IF NOT EQCAR(V,'!]) THEN FILERR U;
  214. FILE := LIST(Y1,MKFRAG CAR Y) . FILE;
  215. V := CDR V>>
  216. ELSE IF CAR V EQ '!, OR CAR V EQ '!] THEN FILERR U;
  217. IF V THEN GO TO A
  218. ELSE IF Z
  219. THEN FILE := MKFRAG Z . IF NULL FILE THEN '(DSK!:) ELSE FILE;
  220. RETURN REVERSE FILE
  221. END;
  222. GLOBAL '(LITERS!*);
  223. SYMBOLIC PROCEDURE NEXTELM U;
  224. BEGIN SCALAR X,Y;
  225. WHILE U AND NOT(CAR U MEMQ '(!. !: !< !> ![ !, !]))
  226. DO <<IF LITER CAR U THEN IF Y := ATSOC(CAR U,LITERS!*)
  227. THEN X := CDR Y . X ELSE X := CAR U . X
  228. ELSE IF DIGIT CAR U THEN X := CAR U . X
  229. ELSE X := CAR U . '!! . X;
  230. U := CDR U>>;
  231. RETURN X . U
  232. END;
  233. LITERS!* := '((!a . A) (!b . B) (!c . C) (!d . D) (!e . E) (!f . F)
  234. (!g . G) (!h . H) (!i . I) (!j . J) (!k . K) (!l . L)
  235. (!m . M) (!n . N) (!o . O) (!p . P) (!q . Q) (!r . R)
  236. (!s . S) (!t . T) (!u . U) (!v . V) (!w . W) (!x . X)
  237. (!y . Y) (!z . Z));
  238. SYMBOLIC PROCEDURE FILERR U; TYPERR(U,"file name");
  239. SYMBOLIC PROCEDURE MKFRAG U;
  240. (LAMBDA X; IF NUMBERP X THEN X ELSE INTERN X) COMPRESS REVERSIP U;
  241. END;