From: Luke Lau Date: Tue, 13 Aug 2019 13:03:53 +0000 (+0100) Subject: Update main.scm to properly read in multi-expression programs X-Git-Url: http://git.lukelau.me/?p=scheme.git;a=commitdiff_plain;h=9fd836fa6cbc686d277684101319f835d55fc5b3 Update main.scm to properly read in multi-expression programs --- diff --git a/main.scm b/main.scm old mode 100644 new mode 100755 index df8e656..e6ac821 --- a/main.scm +++ b/main.scm @@ -1,3 +1,5 @@ +#!/usr/bin/scheme --script + (load "codegen.scm") (load "platform.scm") @@ -10,8 +12,8 @@ (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) @@ -28,10 +30,12 @@ (define target (car (parse-args))) (define file (cadr (parse-args))) + ; reads in all datums until eof (define (read-prog port) - (if (port-input-empty? port) + (let ([x (read port)]) + (if (eof-object? x) '() - (cons (read) (read-prog port)))) + (cons x (read-prog port))))) (compile-to-binary (if (eqv? file 'stdin)