-
-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathdoclang2.rkt
31 lines (26 loc) · 1.05 KB
/
doclang2.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#lang racket/base
;; A slightly nicer version of doclang where the parameters are keyword-based
;; rather than positional.
(require (for-syntax racket/base
syntax/parse)
"private/doc-begin.rkt")
(provide (except-out (all-from-out racket/base) #%module-begin)
(rename-out [*module-begin #%module-begin]))
;; Module wrapper ----------------------------------------
(define-syntax (*module-begin stx)
(syntax-parse stx
[(_ (~or (~optional (~seq #:id id))
(~optional (~seq #:post-process post-process))
(~optional (~seq #:exprs exprs))
(~optional (~seq #:begin (decl ...))))
...
. body)
(with-syntax ([id (or (attribute id)
#'doc)]
[post-process (or (attribute post-process)
#'values)]
[exprs (or (attribute exprs)
#'())])
#'(#%module-begin
(~? (~@ decl ...))
(doc-begin id post-process exprs . body)))]))