compile-psyntax.scm 841 B

12345678910111213141516171819202122232425262728
  1. (use-modules (ice-9 syncase))
  2. ;; XXX - We need to be inside (ice-9 syncase) since psyntax.ss calls
  3. ;; `eval' int he `interaction-environment' aka the current module and
  4. ;; it expects to have `andmap' there. The reason for this escapes me
  5. ;; at the moment.
  6. ;;
  7. (define-module (ice-9 syncase))
  8. (define source (list-ref (command-line) 1))
  9. (define target (list-ref (command-line) 2))
  10. (let ((in (open-input-file source))
  11. (out (open-output-file (string-append target ".tmp"))))
  12. (with-fluids ((expansion-eval-closure
  13. (module-eval-closure (current-module))))
  14. (let loop ((x (read in)))
  15. (if (eof-object? x)
  16. (begin
  17. (close-port out)
  18. (close-port in))
  19. (begin
  20. (write (sc-expand3 x 'c '(compile load eval)) out)
  21. (newline out)
  22. (loop (read in)))))))
  23. (system (format #f "mv -f ~s.tmp ~s" target target))