From b823df23a76e482044b7f92ed8f61351ce3d7cfb Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Tue, 9 Aug 2011 11:49:54 -0600 Subject: [PATCH] [honu] handle empty files --- collects/honu/core/private/honu-typed-scheme.rkt | 9 ++++++--- collects/honu/core/read.rkt | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/collects/honu/core/private/honu-typed-scheme.rkt b/collects/honu/core/private/honu-typed-scheme.rkt index 5ac7605041..e229f81720 100644 --- a/collects/honu/core/private/honu-typed-scheme.rkt +++ b/collects/honu/core/private/honu-typed-scheme.rkt @@ -452,9 +452,12 @@ Then, in the pattern above for 'if', 'then' would be bound to the following synt (define-syntax (honu-unparsed-begin stx) (emit-remark "Honu unparsed begin!" stx) (debug "honu unparsed begin: ~a at phase ~a\n" (syntax->datum stx) (syntax-local-phase-level)) - (define expanded (honu-expand (stx-cdr stx))) - (debug "expanded ~a\n" expanded) - expanded) + (syntax-parse stx + [(_) #'(void)] + [(_ forms ...) + (define expanded (honu-expand #'(forms ...))) + (debug "expanded ~a\n" expanded) + expanded])) (define-syntax (#%dynamic-honu-module-begin stx) (syntax-case stx () diff --git a/collects/honu/core/read.rkt b/collects/honu/core/read.rkt index 288c3a6cc0..01b1904e20 100644 --- a/collects/honu/core/read.rkt +++ b/collects/honu/core/read.rkt @@ -153,7 +153,7 @@ ;; (printf "next ~a\n" next) (match next [(struct* position-token ([token (? token-eof?)] [start-pos start] [end-pos end])) - ;; (printf "done lexing\n") + ; (printf "done lexing ~a\n" tokens) (reverse tokens)] [(struct* position-token ([token (? token-end-of-line-comment?)] [start-pos start] @@ -357,7 +357,7 @@ [else (loop (cdr use))]))) (if (null? tokens) - eof + (datum->syntax #f '() #f) (datum->syntax #f (do-parse '() tokens dispatch-table) #f))) @@ -380,6 +380,7 @@ (port-count-lines! port) port) +#; (test-case "Basic tests" (check-equal? (strip (lex-string "5"))