summaryrefslogtreecommitdiff
path: root/module/ice-9/compile-psyntax.scm
blob: 853586e12f1b07d6ff7afe59c551ffc1e623ae78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(use-modules (ice-9 expand-support))
(let ((source (list-ref (command-line) 1))
      (target (list-ref (command-line) 2)))
  (let ((in (open-input-file source))
        (out (open-output-file (string-append target ".tmp"))))
    (write '(eval-when (compile) (set-current-module (resolve-module '(guile))))
           out)
    (newline out)
    (let loop ((x (read in)))
      (if (eof-object? x)
          (begin
            (close-port out)
            (close-port in))
          (begin
            (write (strip-expansion-structures
                    (sc-expand x 'c '(compile load eval)))
                   out)
            (newline out)
            (loop (read in))))))
  (system (format #f "mv -f ~s.tmp ~s" target target)))