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