main5.red 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. % MAIN5.RED : Small READ-EVAL-PRINT Loop
  2. % Needs IO, SUB2, SUB3, SUB4, SUB5
  3. IN "xxx-header.red"$
  4. IN "PT:STUBS3.RED"$
  5. IN "PT:STUBS4.RED"$
  6. IN "PT:STUBS5.RED"$
  7. on syslisp;
  8. Compiletime FLUID '(DEBUG FnTypeList !*RAISE !$EOF!$ !*PVAL !*ECHO);
  9. Procedure FirstCall;
  10. Begin scalar x, Done, Hcount;
  11. Init();
  12. InitHeap();
  13. InitObList();
  14. TestGet();
  15. InitEval();
  16. Prin2t '"(very) MINI-PSL: A Read-Eval-Print Loop, terminate with Q";
  17. Prin2T '" !*RAISE and !*PVAL have been set T";
  18. Prin2T '" Should be able to execute any COMPILED expressions";
  19. Prin2T '" typed in. Run (TESTSERIES) when ready";
  20. LispVar(DEBUG) := 'NIL; % For nice I/O
  21. InitRead();
  22. LispVar(!$EOF!$) := MkID Char EOF$
  23. Hcount :=0;
  24. LispVar(!*RAISE) := 'T; % Upcase input IDs
  25. While Not Done do
  26. <<Hcount:=Hcount+1;
  27. Prin2 Hcount; Prin2 '" lisp> ";
  28. x:=READ();
  29. if x eq 'Q then Done := 'T
  30. else if x eq !$EOF!$ then
  31. <<terpri();
  32. Prin2T " **** Top Level EOF ****">>
  33. else <<Terpri();
  34. x:=EVAL x;
  35. If LISPVAR(!*PVAL) then Print x>>;
  36. >>;
  37. Quit;
  38. End;
  39. % ---- Test Routines:
  40. syslsp procedure TestSeries();
  41. <<Dashed "TESTs called by TESTSERIES";
  42. TestUndefined()>>;
  43. syslsp procedure TestGet();
  44. Begin
  45. Dashed "Tests of GET and PUT";
  46. Shouldbe("GET('FOO,'FEE)",GET('FOO,'FEE),NIL);
  47. Shouldbe("PUT('FOO,'FEE,'FUM)",PUT('FOO,'FEE,'FUM),'FUM);
  48. Shouldbe("GET('FOO,'FEE)",GET('FOO,'FEE),'FUM);
  49. Shouldbe("REMPROP('FOO,'FEE)",REMPROP('FOO,'FEE),'FUM);
  50. Shouldbe("GET('FOO,'FEE)",GET('FOO,'FEE),NIL);
  51. end;
  52. syslsp procedure TestUndefined;
  53. <<Print "Calling SHOULDBEUNDEFINED";
  54. ShouldBeUndefined(1)>>;
  55. % Some dummies:
  56. procedure UnbindN N;
  57. Stderror '"UNBIND only added at MAIN6";
  58. procedure Lbind1(x,y);
  59. StdError '"LBIND1 only added at MAIN6";
  60. Off syslisp;
  61. End;