X-Git-Url: http://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=main.scm;h=e6ac821f2e7407604a72c622dca82aeb79e56d5b;hp=ce9241ac11537abaf0766e6876e138b24645efd3;hb=HEAD;hpb=685089345e07943eaab2eec10208ba513ca537b2 diff --git a/main.scm b/main.scm old mode 100644 new mode 100755 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) @@ -27,8 +30,15 @@ (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)