[honu] dont splice the output of a macro directly into the output
This commit is contained in:
parent
80d57148d1
commit
4799d08022
|
@ -5,6 +5,7 @@
|
||||||
(require (for-meta meta-level
|
(require (for-meta meta-level
|
||||||
racket/base
|
racket/base
|
||||||
racket/class
|
racket/class
|
||||||
|
(prefix-in list: racket/list)
|
||||||
"private/macro2.rkt"
|
"private/macro2.rkt"
|
||||||
"private/class.rkt"
|
"private/class.rkt"
|
||||||
"private/operator.rkt"
|
"private/operator.rkt"
|
||||||
|
@ -87,6 +88,7 @@
|
||||||
[datum->syntax datum_to_syntax]
|
[datum->syntax datum_to_syntax]
|
||||||
[syntax->datum syntax_to_datum]
|
[syntax->datum syntax_to_datum]
|
||||||
[syntax->list syntax_to_list]
|
[syntax->list syntax_to_list]
|
||||||
|
[list:first first]
|
||||||
[symbol->string symbol_to_string]
|
[symbol->string symbol_to_string]
|
||||||
[string-append string_append])
|
[string-append string_append])
|
||||||
print printf
|
print printf
|
||||||
|
|
|
@ -212,6 +212,7 @@
|
||||||
(define-honu-syntax honu-syntax
|
(define-honu-syntax honu-syntax
|
||||||
(lambda (code context)
|
(lambda (code context)
|
||||||
(syntax-parse code #:literal-sets (cruft)
|
(syntax-parse code #:literal-sets (cruft)
|
||||||
|
#;
|
||||||
[(_ (#%parens single) . rest)
|
[(_ (#%parens single) . rest)
|
||||||
(define context #'single)
|
(define context #'single)
|
||||||
(define compressed (phase0:compress-dollars #'single))
|
(define compressed (phase0:compress-dollars #'single))
|
||||||
|
|
|
@ -166,12 +166,18 @@
|
||||||
(if (null? (syntax->datum #'(unparsed-out ...)))
|
(if (null? (syntax->datum #'(unparsed-out ...)))
|
||||||
(if (parsed-syntax? #'output)
|
(if (parsed-syntax? #'output)
|
||||||
#'output
|
#'output
|
||||||
|
#;
|
||||||
|
#'(parse-more output)
|
||||||
(with-syntax ([(out ...) #'output])
|
(with-syntax ([(out ...) #'output])
|
||||||
#'(parse-more out ...)))
|
#'(parse-more out ...)))
|
||||||
|
#;
|
||||||
|
#'(begin (parse-more output unparsed-out ...))
|
||||||
(if (parsed-syntax? #'output)
|
(if (parsed-syntax? #'output)
|
||||||
#'(begin output (parse-more unparsed-out ...))
|
#'(begin output (parse-more unparsed-out ...))
|
||||||
|
#;
|
||||||
|
#'(parse-more output unparsed-out ...)
|
||||||
(with-syntax ([(out ...) #'output])
|
(with-syntax ([(out ...) #'output])
|
||||||
#'(parse-more out ... unparsed-out ...)))))]
|
#'(begin (parse-more out ...) (parse-more unparsed-out ...))))))]
|
||||||
[() #'(begin)]))
|
[() #'(begin)]))
|
||||||
|
|
||||||
(define (do-parse-rest/local stx)
|
(define (do-parse-rest/local stx)
|
||||||
|
@ -398,7 +404,7 @@
|
||||||
(define output
|
(define output
|
||||||
(if current
|
(if current
|
||||||
(if binary-transformer
|
(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))
|
(error 'binary "cannot be used as a binary operator in ~a" #'head))
|
||||||
(if unary-transformer
|
(if unary-transformer
|
||||||
(unary-transformer right)
|
(unary-transformer right)
|
||||||
|
@ -447,6 +453,8 @@
|
||||||
[body:honu-body
|
[body:honu-body
|
||||||
(if current
|
(if current
|
||||||
(values (left current) stream)
|
(values (left current) stream)
|
||||||
|
(values (left #'body.result) #'())
|
||||||
|
#;
|
||||||
(do-parse #'(rest ...) precedence left #'body.result))]
|
(do-parse #'(rest ...) precedence left #'body.result))]
|
||||||
#;
|
#;
|
||||||
[((semicolon more ...) . rest)
|
[((semicolon more ...) . rest)
|
||||||
|
@ -582,6 +590,16 @@
|
||||||
(define (parse-one code)
|
(define (parse-one code)
|
||||||
(parse (strip-stops 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)
|
(define (parse-all code)
|
||||||
(let loop ([all '()]
|
(let loop ([all '()]
|
||||||
[code code])
|
[code code])
|
||||||
|
|
|
@ -32,11 +32,13 @@
|
||||||
values
|
values
|
||||||
hash
|
hash
|
||||||
regexp
|
regexp
|
||||||
|
error
|
||||||
(racket:rename-out
|
(racket:rename-out
|
||||||
[honu-cond cond]
|
[honu-cond cond]
|
||||||
[null empty]
|
[null empty]
|
||||||
[make-hash mutable_hash]
|
[make-hash mutable_hash]
|
||||||
[hash-set! hash_update]
|
[hash-set! hash_update]
|
||||||
|
[hash-ref hash_lookup]
|
||||||
[current-inexact-milliseconds currentMilliseconds]
|
[current-inexact-milliseconds currentMilliseconds]
|
||||||
[string-length string_length]
|
[string-length string_length]
|
||||||
[string-append string_append]
|
[string-append string_append]
|
||||||
|
@ -44,5 +46,4 @@
|
||||||
[racket:find-files find_files]
|
[racket:find-files find_files]
|
||||||
[racket:empty? empty?]
|
[racket:empty? empty?]
|
||||||
[regexp-match regexp_match]
|
[regexp-match regexp_match]
|
||||||
[racket:first first]
|
|
||||||
[racket:rest rest]))
|
[racket:rest rest]))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user