break.red 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. %
  2. % BREAK.RED - Break using new top loop
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 23 October 1981
  9. % Copyright (c) 1981 University of Utah
  10. %
  11. % <PSL.KERNEL>BREAK.RED.2, 11-Oct-82 17:52:13, Edit by BENSON
  12. % Changed CATCH/THROW to new definition
  13. % <PSL.INTERP>BREAK.RED.6, 28-Jul-82 14:29:59, Edit by BENSON
  14. % Added A for abort-to-top-level
  15. % <PSL.INTERP>BREAK.RED.3, 30-Apr-82 14:34:33, Edit by BENSON
  16. % Added binding of !*DEFN to NIL
  17. fluid '(!*Break !*QuitBreak BreakEval!* BreakName!* BreakValue!*
  18. ErrorForm!*
  19. BreakLevel!* MaxBreakLevel!*
  20. TopLoopName!* TopLoopEval!* TopLoopRead!* TopLoopPrint!*
  21. !*DEFN % break binds !*DEFN to NIL
  22. BreakIn!* BreakOut!*);
  23. LoadTime <<
  24. BreakLevel!* := 0;
  25. MaxBreakLevel!* := 5;
  26. >>;
  27. lisp procedure Break(); %. Enter top loop within evaluation
  28. (lambda(BreakLevel!*);
  29. begin scalar OldIn, OldOut, !*QuitBreak,BreakValue!*, !*Defn;
  30. OldIn := RDS BreakIn!*;
  31. OldOut := WRS BreakOut!*;
  32. !*QuitBreak := T;
  33. if TopLoopName!* then
  34. << if TopLoopEval!* neq 'BreakEval then
  35. << BreakEval!* := TopLoopEval!*;
  36. BreakName!* := ConCat(TopLoopName!*, " break") >>;
  37. Catch('!$Break!$, TopLoop(TopLoopRead!*,
  38. TopLoopPrint!*,
  39. 'BreakEval,
  40. BreakName!*,
  41. "Break loop")) >>
  42. else
  43. << BreakEval!* := 'Eval;
  44. BreakName!* := "lisp break";
  45. Catch('!$Break!$, TopLoop('Read,
  46. 'Print,
  47. 'BreakEval,
  48. BreakName!*,
  49. "Break loop")) >>;
  50. RDS OldIn;
  51. WRS OldOut;
  52. return if !*QuitBreak then begin scalar !*Break, !*EmsgP;
  53. return StdError "Exit to ErrorSet";
  54. end else
  55. Eval ErrorForm!*;
  56. end)(BreakLevel!* + 1);
  57. lisp procedure BreakEval U;
  58. begin scalar F;
  59. return if IDP U and (F := get(U, 'BreakFunction)) then
  60. Apply(F, NIL)
  61. else BreakValue!*:=Apply(BreakEval!*, list U);
  62. end;
  63. lisp procedure BreakQuit();
  64. << !*QuitBreak := T;
  65. Throw('!$Break!$, NIL) >>;
  66. lisp procedure BreakContinue();
  67. << ErrorForm!* := MkQuote BreakValue!*;
  68. BreakRetry() >>;
  69. lisp procedure BreakRetry();
  70. if !*ContinuableError then
  71. << !*QuitBreak := NIL;
  72. Throw('!$Break!$, NIL) >>
  73. else
  74. << Prin2T
  75. "Can only continue from a continuable error; use Q (BreakQuit) to quit";
  76. TerPri() >>;
  77. lisp procedure HelpBreak();
  78. << EvLoad '(HELP);
  79. DisplayHelpFile 'Break >>;
  80. lisp procedure BreakErrMsg();
  81. PrintF("ErrorForm!* : %r %n", ErrorForm!*);
  82. lisp procedure BreakEdit();
  83. if GetD 'Edit then ErrorForm!* := Edit ErrorForm!*
  84. else ErrorPrintF("*** Editor not loaded");
  85. LoadTime DefList('((Q BreakQuit)
  86. (!? HelpBreak)
  87. (A Reset) % Abort to top level
  88. (M BreakErrMsg)
  89. (E BreakEdit)
  90. (C BreakContinue)
  91. (R BreakRetry)
  92. (I InterpBackTrace)
  93. (V VerboseBackTrace)
  94. (T BackTrace)),
  95. 'BreakFunction);
  96. END;