[honu] use an empty "begin" if nothing was parsed

This commit is contained in:
Jon Rafkind 2011-09-15 12:50:31 -06:00
parent 0b4e630b8c
commit 219516b321
2 changed files with 5 additions and 19 deletions

View File

@ -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

View File

@ -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))