[honu] dont splice the output of a macro directly into the output

This commit is contained in:
Jon Rafkind 2012-04-23 16:43:27 -06:00
parent 80d57148d1
commit 4799d08022
4 changed files with 25 additions and 3 deletions

View File

@ -5,6 +5,7 @@
(require (for-meta meta-level
racket/base
racket/class
(prefix-in list: racket/list)
"private/macro2.rkt"
"private/class.rkt"
"private/operator.rkt"
@ -87,6 +88,7 @@
[datum->syntax datum_to_syntax]
[syntax->datum syntax_to_datum]
[syntax->list syntax_to_list]
[list:first first]
[symbol->string symbol_to_string]
[string-append string_append])
print printf

View File

@ -212,6 +212,7 @@
(define-honu-syntax honu-syntax
(lambda (code context)
(syntax-parse code #:literal-sets (cruft)
#;
[(_ (#%parens single) . rest)
(define context #'single)
(define compressed (phase0:compress-dollars #'single))

View File

@ -166,12 +166,18 @@
(if (null? (syntax->datum #'(unparsed-out ...)))
(if (parsed-syntax? #'output)
#'output
#;
#'(parse-more output)
(with-syntax ([(out ...) #'output])
#'(parse-more out ...)))
#;
#'(begin (parse-more output unparsed-out ...))
(if (parsed-syntax? #'output)
#'(begin output (parse-more unparsed-out ...))
#;
#'(parse-more output unparsed-out ...)
(with-syntax ([(out ...) #'output])
#'(parse-more out ... unparsed-out ...)))))]
#'(begin (parse-more out ...) (parse-more unparsed-out ...))))))]
[() #'(begin)]))
(define (do-parse-rest/local stx)
@ -398,7 +404,7 @@
(define output
(if current
(if binary-transformer
(binary-transformer (parse-all current) right)
(binary-transformer (parse-all-expression current) right)
(error 'binary "cannot be used as a binary operator in ~a" #'head))
(if unary-transformer
(unary-transformer right)
@ -447,6 +453,8 @@
[body:honu-body
(if current
(values (left current) stream)
(values (left #'body.result) #'())
#;
(do-parse #'(rest ...) precedence left #'body.result))]
#;
[((semicolon more ...) . rest)
@ -582,6 +590,16 @@
(define (parse-one code)
(parse (strip-stops code)))
;; keep parsing some expression until only a parsed term remains
(define (parse-all-expression code)
(define-values (parsed unparsed)
(parse code))
(when (not (empty-syntax? unparsed))
(raise-syntax-error 'parse-all-expression "expected no more syntax" code))
(if (parsed-syntax? parsed)
parsed
(parse-all-expression parsed)))
(define (parse-all code)
(let loop ([all '()]
[code code])

View File

@ -32,11 +32,13 @@
values
hash
regexp
error
(racket:rename-out
[honu-cond cond]
[null empty]
[make-hash mutable_hash]
[hash-set! hash_update]
[hash-ref hash_lookup]
[current-inexact-milliseconds currentMilliseconds]
[string-length string_length]
[string-append string_append]
@ -44,5 +46,4 @@
[racket:find-files find_files]
[racket:empty? empty?]
[regexp-match regexp_match]
[racket:first first]
[racket:rest rest]))