-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinspect.rkt
37 lines (32 loc) · 893 Bytes
/
inspect.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
#lang racket
(provide (all-from-out racket)
define
let
trace!
dump)
(require syntax/parse/define
(rename-in racket
[define origin-define]
[let origin-let]))
(define m (make-hash))
(define (trace! name val)
(hash-set! m name (append (hash-ref m name '())
(list val))))
(define (dump)
m)
(define-syntax-parser let
[(_ loop ([n e] ...) body ...)
#'(origin-let loop ([n e] ...)
(trace! 'n n) ...
body ...)]
[(_ ([n e] ...) body ...)
#'(origin-let ([n e] ...)
(trace! 'n n) ...
body ...)])
(define-syntax-parser define
[(_ n:id e)
#'(begin (origin-define n e)
(trace! 'n n))]
[(_ anyway ...)
#'(origin-define anyway ...)])
(module reader syntax/module-reader re-algo/inspect)