Add some documentation to the abi
[scheme.git] / main.scm
1 (load "codegen.scm")
2
3 ; returns (os filename)
4 (define (parse-args)
5   (define (parse-os x)
6     (if (null? x) 'darwin ; todo: replace this with the os
7                                         ; it was compiled with
8         (if
9          (or (equal? (car x) "-t")
10              (equal? (car x) "--target"))
11          (case (cadr x)
12            ("darwin" 'darwin)
13            ("linux"  'linux)
14            (else (error #f "unknown os")))         
15          (parse-os (cdr x)))))
16   (define (parse-file x)
17     (if (null? x) 'stdin
18         (if
19          (or (equal? (car x) "-t")
20              (equal? (car x) "--target"))
21          (parse-file (cddr x))
22          (car x))))
23   (let ((args (cdr (command-line))))
24     (list (parse-os args) (parse-file args))))
25
26
27 (define target (car (parse-args)))
28 (define file (cadr (parse-args)))
29
30 (compile-to-binary
31  (if (eqv? file 'stdin)
32      (read)
33      (call-with-input-file file read))
34  "a.out" target)