program-command-interpreter.sl 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %
  3. % Program-Command-Interpreter.SL - Perform Program Command
  4. %
  5. % Author: Alan Snyder
  6. % Hewlett-Packard/CRC
  7. % Date: 10 August 1982
  8. % Revised: 8 December 1982
  9. %
  10. % 8-Dec-82 Alan Snyder
  11. % Changed use of DSKIN (now an EXPR).
  12. %
  13. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  14. % This file redefines the start-up routine for PSL (Lisp Reader) to first read
  15. % and interpret the program command string. If the command string contains a
  16. % recognized command name, then the corresponding function is immediately
  17. % executed and the program QUITs. Otherwise, the normal top-level function
  18. % definition is restored and invoked as normal. Commands are defined using the
  19. % property PROGRAM-COMMAND (see below). This file defines only one command,
  20. % COMPILE, which is used to compile Lisp files (not RLisp files).
  21. (BothTimes (load common))
  22. (load parse-command-string get-command-string compiler)
  23. (fluid '(*usermode *redefmsg CurrentReadMacroIndicator* CurrentScanTable*))
  24. (cond ((funboundp 'original-main)
  25. (copyd 'original-main 'main)))
  26. (de main ()
  27. (let ((CurrentReadMacroIndicator* 'LispReadMacro) % Crock!
  28. (CurrentScanTable* LispScanTable*)
  29. (c-list (parse-command-string (get-command-string)))
  30. (*usermode nil)
  31. (*redefmsg nil))
  32. (perform-program-command c-list)
  33. (copyd 'main 'original-main)
  34. )
  35. (original-main)
  36. )
  37. (de perform-program-command (c-list)
  38. (if (not (Null c-list))
  39. (let ((command (car c-list)))
  40. (if (StringP command)
  41. (let* ((command-id (intern (string-upcase command)))
  42. (func (get command-id 'PROGRAM-COMMAND)))
  43. (if func (apply func (list c-list))))))))
  44. (put 'COMPILE 'PROGRAM-COMMAND 'compile-program-command)
  45. (fluid '(*quiet_faslout *WritingFASLFile))
  46. (de compile-program-command (c-list)
  47. (setq c-list (cdr c-list))
  48. (for (in file-name-root c-list)
  49. (do (let* ((form (list 'COMPILE-FILE file-name-root))
  50. (*break NIL)
  51. (result (ErrorSet form T NIL))
  52. )
  53. (if (FixP result)
  54. (progn
  55. (if *WritingFASLFile (faslend))
  56. (printf "%n ***** Error during compilation of %w.%n"
  57. file-name-root)
  58. ))
  59. )))
  60. (quit))
  61. (de compile-file (file-name-root)
  62. (let ((source-fn (string-concat file-name-root ".SL"))
  63. (binary-fn (string-concat file-name-root ".B"))
  64. (*quiet_faslout T)
  65. )
  66. (if (not (FileP source-fn))
  67. (printf "Unable to open source file: %w%n" source-fn)
  68. % else
  69. (printf "%n----- Compiling %w%n" source-fn binary-fn)
  70. (faslout file-name-root)
  71. (dskin source-fn)
  72. (faslend)
  73. (printf "%nDone compiling %w%n%n" source-fn)
  74. )))