Fix total pattern match verification
[scheme.git] / main.scm
old mode 100644 (file)
new mode 100755 (executable)
index ce9241a..e6ac821
--- a/main.scm
+++ b/main.scm
@@ -1,16 +1,19 @@
+#!/usr/bin/scheme --script
+
 (load "codegen.scm")
+(load "platform.scm")
 
 ; returns (os filename)
 (define (parse-args)
   (define (parse-os x)
-    (if (null? x) 'darwin ; todo: replace this with the os
+    (if (null? x) host-os ; todo: replace this with the os
                                        ; it was compiled with
        (if
         (or (equal? (car x) "-t")
             (equal? (car x) "--target"))
         (case (cadr x)
-          ("darwin" 'darwin)
-          ("linux"  'linux)
+          (("darwin") 'darwin)
+          (("linux")  'linux)
           (else (error #f "unknown os")))         
         (parse-os (cdr x)))))
   (define (parse-file x)
 (define target (car (parse-args)))
 (define file (cadr (parse-args)))
 
+                                       ; reads in all datums until eof
+(define (read-prog port)
+  (let ([x (read port)])
+    (if (eof-object? x)
+       '()
+       (cons x (read-prog port)))))
+
 (compile-to-binary
  (if (eqv? file 'stdin)
-     (read)
-     (call-with-input-file file read))
+     (read-prog (current-input-port))     
+     (call-with-input-file file read-prog))
  "a.out" target)