** add/expose parameter for logging 'hits'
This commit is contained in:
parent
dc0c4bcad8
commit
066d89d993
7
trivial/parameters.rkt
Normal file
7
trivial/parameters.rkt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#lang typed/racket/base
|
||||||
|
|
||||||
|
(provide
|
||||||
|
(all-from-out trivial/private/parameters))
|
||||||
|
|
||||||
|
(require
|
||||||
|
trivial/private/parameters)
|
|
@ -27,6 +27,7 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(require
|
(require
|
||||||
|
trivial/private/parameters
|
||||||
racket/syntax
|
racket/syntax
|
||||||
syntax/parse
|
syntax/parse
|
||||||
syntax/id-table
|
syntax/id-table
|
||||||
|
@ -121,21 +122,31 @@
|
||||||
f-let))
|
f-let))
|
||||||
|
|
||||||
(define ((make-alias id-stx parser) stx)
|
(define ((make-alias id-stx parser) stx)
|
||||||
(or (parser stx)
|
(cond
|
||||||
(syntax-parse stx
|
[(parser stx)
|
||||||
[_:id
|
=> (lambda (r)
|
||||||
id-stx]
|
(when (*TRIVIAL-LOG*) (printf "[LOG] alias ~a\n" (syntax->datum id-stx)))
|
||||||
[(_ e* ...)
|
r)]
|
||||||
#:with app-stx (format-id stx "#%app")
|
[else
|
||||||
#`(app-stx #,id-stx e* ...)])))
|
(syntax-parse stx
|
||||||
|
[_:id
|
||||||
|
id-stx]
|
||||||
|
[(_ e* ...)
|
||||||
|
#:with app-stx (format-id stx "#%app")
|
||||||
|
#`(app-stx #,id-stx e* ...)])]))
|
||||||
|
|
||||||
(define ((make-keyword-alias id-sym parser) stx)
|
(define ((make-keyword-alias id-sym parser) stx)
|
||||||
(or (parser stx)
|
(cond
|
||||||
|
[(parser stx)
|
||||||
|
=> (lambda (r)
|
||||||
|
(when (*TRIVIAL-LOG*) (printf "[LOG] keyword ~a\n" id-sym))
|
||||||
|
r)]
|
||||||
|
[else
|
||||||
(syntax-parse stx
|
(syntax-parse stx
|
||||||
[(_ e* ...)
|
[(_ e* ...)
|
||||||
#:with id-stx (case id-sym
|
#:with id-stx (case id-sym
|
||||||
[(define) #'tr:define]
|
[(define) #'tr:define]
|
||||||
[(let) #'tr:let]
|
[(let) #'tr:let]
|
||||||
[(set!) #'tr:set!]
|
[(set!) #'tr:set!]
|
||||||
[else (error 'trivial "Unknown keyword '~a'" id-sym)])
|
[else (error 'trivial "Unknown keyword '~a'" id-sym)])
|
||||||
(syntax/loc stx (id-stx e* ...))])))
|
(syntax/loc stx (id-stx e* ...))])]))
|
||||||
|
|
11
trivial/private/parameters.rkt
Normal file
11
trivial/private/parameters.rkt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#lang typed/racket/base
|
||||||
|
|
||||||
|
(provide
|
||||||
|
*TRIVIAL-LOG*
|
||||||
|
)
|
||||||
|
|
||||||
|
;; =============================================================================
|
||||||
|
|
||||||
|
(: *TRIVIAL-LOG* (Parameterof Boolean))
|
||||||
|
(define *TRIVIAL-LOG* (make-parameter #f))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user