build.red 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. % module build; % Code to help with bootstrapping REDUCE from Lisp.
  2. % Author: Anthony C. Hearn.
  3. % The baroque syntax in this file is a consequence of the bootstrapping
  4. % process.
  5. global '(loaded!-packages!* oldchan!*);
  6. % Since some of the early modules may have tabs in them, we must redefine
  7. % seprp.
  8. symbolic procedure seprp u;
  9. or(eq(u,'! ),eq(u,'! ),eq(u,!$eol!$));
  10. symbolic procedure concat2(u,v);
  11. % This would be better supported at a lower level.
  12. compress('!" . append(explode2 u,nconc(explode2 v,list '!")));
  13. symbolic procedure string!-downcase u;
  14. % This definition is designed to overcome bootstrapping difficulties
  15. % in the various Lisps used.
  16. begin scalar y,z;
  17. if null stringp u then u := '!" . append(explode2 u,'(!"))
  18. else u := explode u;
  19. a: if null u then return compress reverse z;
  20. y := atsoc(car u,
  21. '((A . "a") (B . "b") (C . "c") (D . "d") (E . "e") (F . "f")
  22. (G . "g") (H . "h") (I . "i") (J . "j") (K . "k") (L . "l")
  23. (M . "m") (N . "n") (O . "o") (P . "p") (Q . "q") (R . "r")
  24. (S . "s") (T . "t") (U . "u") (V . "v") (W . "w") (X . "x")
  25. (Y . "y") (Z . "z")));
  26. if y then z := car explode2 cdr y . z else z := car u . z;
  27. u := cdr u;
  28. go to a
  29. end;
  30. symbolic procedure mod2file(u,v);
  31. concat2("$reduce/packages/",concat2(string!-downcase v,
  32. concat2("/",concat2(string!-downcase u,".red"))));
  33. symbolic procedure inmodule(u,v);
  34. begin
  35. u := open(mod2file(u,v),'input);
  36. v := rds u;
  37. cursym!* := '!*semicol!*;
  38. a: if eq(cursym!*,'end) then return progn(rds v, close u);
  39. prin2 eval form xread nil;
  40. go to a;
  41. end;
  42. symbolic procedure load!-package!-sources(u,v);
  43. begin scalar !*int,!*echo,w;
  44. inmodule(u,v);
  45. if (w := get(u,'package)) then w := cdr w;
  46. a: if w then progn(inmodule(car w,v), w := cdr w, go to a);
  47. loaded!-packages!* := u . loaded!-packages!*;
  48. end;
  49. % endmodule;
  50. end;