From 219516b3217bac09238e234de0447559156e6df5 Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Thu, 15 Sep 2011 12:50:31 -0600 Subject: [PATCH] [honu] use an empty "begin" if nothing was parsed --- .../honu/core/private/honu-typed-scheme.rkt | 6 +++++- collects/honu/core/private/parse2.rkt | 18 ------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/collects/honu/core/private/honu-typed-scheme.rkt b/collects/honu/core/private/honu-typed-scheme.rkt index 72ca2a2abd..173ff2515c 100644 --- a/collects/honu/core/private/honu-typed-scheme.rkt +++ b/collects/honu/core/private/honu-typed-scheme.rkt @@ -461,7 +461,11 @@ Then, in the pattern above for 'if', 'then' would be bound to the following synt (debug "expanded ~a unexpanded ~a\n" (if parsed (syntax->datum parsed) parsed) (syntax->datum unparsed)) - (with-syntax ([parsed parsed] + ;; if parsed is #f then we don't want to expand to anything that will print + ;; so use an empty form, begin, `parsed' could be #f becuase there was no expression + ;; in the input such as parsing just ";". hygiene should ensure that this variable + ;; will not collide with anything else + (with-syntax ([parsed (if (not parsed) #'(begin) parsed)] [(unparsed ...) unparsed]) (if (null? (syntax->datum #'(unparsed ...))) #'parsed diff --git a/collects/honu/core/private/parse2.rkt b/collects/honu/core/private/parse2.rkt index bee6c93539..8c19bf65e7 100644 --- a/collects/honu/core/private/parse2.rkt +++ b/collects/honu/core/private/parse2.rkt @@ -346,24 +346,6 @@ (loop (cons parsed all) unparsed)))) -(define (parse2 forms) - (debug "parse forms ~a\n" forms) - (when (stx-pair? forms) - (define head (stx-car forms)) - (if (honu-macro? head) - (begin - (debug "honu macro ~a\n" head) - (let-values ([(parsed rest) - ((syntax-local-value head) forms #f)]) - (with-syntax ([parsed parsed] - [rest rest]) - #'(splicing-let-syntax ([more-parsing (lambda (stx) - (debug "more parsing!!\n") - (parse stx))]) - parsed - (more-parsing . rest))))) - #'(debug "regular parsing\n")))) - ;; rest will be some subset of full (define (parsed-things full rest) (define full-datum (syntax->datum full))