-
Notifications
You must be signed in to change notification settings - Fork 4
/
ext.rkt
53 lines (41 loc) · 1.19 KB
/
ext.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#lang racket/base
(require (for-syntax racket/base)
syntax/parse/pre)
;; indirection ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide
current-reviewer)
(struct reviewer
(recur-proc
track-error-proc
track-warning-proc
track-binding-proc
push-scope-proc
pop-scope-proc))
(define current-reviewer
(make-parameter #f))
(define-syntax (define-reviewer-procs stx)
(syntax-case stx ()
[(_ {id accessor} ...)
#'(begin
(provide id ...)
(define id
(make-keyword-procedure
(lambda (kws kw-args . args)
(keyword-apply
(accessor (current-reviewer))
kws kw-args args))))
...)]))
(define-reviewer-procs
{recur reviewer-recur-proc}
{track-error reviewer-track-error-proc}
{track-warning reviewer-track-warning-proc}
{track-binding reviewer-track-binding-proc}
{push-scope reviewer-push-scope-proc}
{pop-scope reviewer-pop-scope-proc})
(module+ private
(provide (struct-out reviewer)))
;; syntax classes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide
expression)
(define-syntax-class expression
(pattern e #:do [(recur this-syntax)]))