[honu] add example of lexically scoped macros
This commit is contained in:
parent
42caad96de
commit
a9ba721be8
|
@ -153,16 +153,6 @@
|
|||
(debug 2 "Comma? ~a ~a\n" what is)
|
||||
is)
|
||||
|
||||
#;
|
||||
(define-syntax (parse-more stx)
|
||||
(syntax-parse stx
|
||||
[(_ stuff ...)
|
||||
(define-values (parsed unparsed)
|
||||
(parse (strip-stops #'(stuff ...))))
|
||||
(with-syntax ([(parsed-out ...) (honu->racket parsed)]
|
||||
[(unparsed-out ...) unparsed])
|
||||
#'(begin parsed-out ... (parse-stuff unparsed-out ...)))]))
|
||||
|
||||
(define (do-parse stx parse-more)
|
||||
(syntax-parse stx
|
||||
[(_ stuff ...)
|
||||
|
@ -518,14 +508,3 @@
|
|||
(provide honu-expression/comma)
|
||||
(define-splicing-syntax-class honu-expression/comma
|
||||
[pattern (~seq x ...) #:with (result ...) (parse-comma-expression #'(x ...))])
|
||||
|
||||
#|
|
||||
(provide honu-body)
|
||||
(define-splicing-syntax-class honu-body
|
||||
#:literal-sets (cruft)
|
||||
[pattern (~seq (#%braces code ...))
|
||||
#:with result #'(let-syntax ([parse-more (lambda (stx)
|
||||
(honu->racket (parse-all #'(code ...))))])
|
||||
(parse-more))])
|
||||
|#
|
||||
|
||||
|
|
25
collects/tests/honu/macros2.honu
Normal file
25
collects/tests/honu/macros2.honu
Normal file
|
@ -0,0 +1,25 @@
|
|||
#lang honu
|
||||
|
||||
macro foo (){ x:identifier }{
|
||||
syntax(macro x (){ e:expression }{
|
||||
syntax(e + 2)
|
||||
})
|
||||
}
|
||||
|
||||
foo h
|
||||
|
||||
h 5
|
||||
h 8 * 9
|
||||
|
||||
test(z){
|
||||
macro foo (){ x:identifier }{
|
||||
syntax(macro x (){ e:expression }{
|
||||
syntax(e + z)
|
||||
})
|
||||
}
|
||||
|
||||
foo h
|
||||
h 5
|
||||
}
|
||||
|
||||
test(4)
|
Loading…
Reference in New Issue
Block a user